Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 132469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:16:03+00:00 2026-05-11T06:16:03+00:00

I heard that some languages go from interpreted to compiled by unrolling the interpreter

  • 0

I heard that some languages go from interpreted to compiled by ‘unrolling the interpreter loop’.

Let’s say I have the following pseudo-c-code interpreter for an ast tree.

int interpret(node) {     switch(node) {         case PLUS:              return interpret(child(0))+interpret(child(1));         case MINUS:              return interpret(child(0))-interpret(child(1));            } } 

How do I unroll this loop to create a compiled program?

I see you all downvoting this like I don’t know what I am talking about, but here is a quote from Wikipedia that states exactly what I am describing.

‘Factor was originally only interpreted, but is now fully compiled (the non-optimizing compiler basically unrolls the interpreter loop’

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T06:16:03+00:00Added an answer on May 11, 2026 at 6:16 am

    ‘Unrolling a loop’ normally means replacing a repetition with a sequence of actions. The loop:

    for (int i = 0; i < 4; ++i) {     a[i] = b[i] + c[i]; } 

    would unroll into the equivalent:

    a[0] = b[0] + c[0]; a[1] = b[1] + c[1]; a[2] = b[2] + c[2]; a[3] = b[3] + c[3]; 

    It appears to me that whoever was being quoted by Wikipedia was using the phrase in a somewhat metaphorical sense. So, in that sense…

    Your sample would normally be invoked inside a interpreter that is walking a tree of AST nodes, which might look something like this:

     ASSIGN     |  +--+---+  |      | REF   MINUS  |      |  x   +--+---+      |      |     VAR    PLUS      |      |      a   +--+--+          |     |         VAR  CONST          |     |          b     3 

    and the interpret function would have additional options:

    int interpret(node) {     switch(node) {         case PLUS:              return interpret(child(0))+interpret(child(1));         case MINUS:              return interpret(child(0))-interpret(child(1));                case ASSIGN:              return set(child(0), interpret(child(1));         case VAR:              return fetch(child(0));         case CONST:              return value(child(0));         ...     } } 

    If you walk the AST with that interpet function (actually performing the operations), you’re interpreting. But if the function records the actions to be performed, rather than executing them, you’re compiling. In pseudocode (actually, pseudocode twice, as I’m assuming a hypothetical stack machine as the compilation target):

    string compile(node) {     switch(node) {         case PLUS:              return(compile(child(0))) + compile(child(1)) + ADD);         case MINUS:              return(compile(child(0))) + compile(child(1)) + SUB);         case ASSIGN:              return(PUSHA(child(0))) + compile(child(1)) + STORE);         case REF:              return(PUSHA(child(0)));         case VAR:              return(PUSHA(child(0)) + FETCH);         case CONST:              return(PUSHLIT + value(child(0)));         ...     } } 

    Invoking compile on that AST (ignoring any pseudocode typos 😉 would spit out something like:

    PUSHA x PUSHA a FETCH PUSHA b FETCH PUSHLIT 3 ADD  SUB STORE 

    FWIW, I’d tend to think of that as unrolling the AST, rather than unrolling the interpreter, but won’t criticize somebody else’s metaphor without reading it in context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have heard that prepared statements with SQLite should improve performance. I wrote some
I've heard that in some programming languages it is faster to check if the
I've heard that some custom component authors use an RTL routine that checks to
I heard that in PHP there are some alternatives for the functions substr() and
I have a product setup executable that copies some files to the user's hard
I'm planning to release some compiled code that shall be linked by client applications
I have heard of several things, quoted from Wikipedia: Java Runtime Environment, A JVM
I've heard many times that all programming is really a subset of math. Some
One of the arguments I've heard against functional languages is that single assignment coding
I've heard some conflicting things about the acceptability of scripting languages (e.g., Lua) in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.