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 6999585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:33:38+00:00 2026-05-27T20:33:38+00:00

Why are register-based virtual machines better than stack-based ones? Specifically, in the Parrot VM’s

  • 0

Why are register-based virtual machines better than stack-based ones?

Specifically, in the Parrot VM’s document, the designer explains the benefits of register machines:

[…] many programs in high-level languages consist of nested function and method calls, sometimes with lexical variables to hold intermediate results. Under non-JIT settings, a stack-based VM will be popping and then pushing the same operands many times, while a register-based VM will simply allocate the right amount of registers and operate on them, which can significantly reduce the amount of operations and CPU time.

but why are the same operands pushed many times?

  • 1 1 Answer
  • 0 Views
  • 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. Editorial Team
    Editorial Team
    2026-05-27T20:33:39+00:00Added an answer on May 27, 2026 at 8:33 pm

    It seems like they describe a VM which executes the code as described in the language design, bytecode-by-bytecode without compiling or optimisation. In that case it is true. Think about code doing something like this for example:

    x = first(a,b,c)
    y = second(a,b,c)
    third(y,x)
    

    With a register based system, you might be able to simply put the arguments in whatever position they’re expected (if registers can be used to pass arguments). If all registers are “global”, not per-function (or at least restored when poping the call-stack) you might not need to do anything between the call to first and second.

    If you have a stack-based VM, you’d end up with something like (hopefully you do have swap):

    push a
    push b
    push c
    call first
    push a # pushing same arguments again
    push b
    push c
    call second
    swap
    call third
    

    Also if you calculate a math expression which reuses the same variables, you might need to do something like this:

    push a
    push b
    add
    push a
    push c
    add
    add
    

    instead of (assuming there are registers a,b,c and you can destroy the contents of b and c):

    add b, a
    add c, a
    add b, c # result in b
    

    this avoids restoring a, which needed to be done in a separate push in the first case.

    Then again, I’m just guessing the examples, maybe they meant some other case…

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

Sidebar

Related Questions

How does a register based virtual machine work? I am looking for introduction to
Why is the JVM a stack based virtual machine? What exactly does that mean
I'm curious, why did Sun decide to make the JVM stack-based and Google decide
I've got a Django-based site that allows users to register (but requires an admin
I'm using and x86 based core to manipulate a 32-bit memory mapped register. My
Using Unity, I'd like to automatically register all interface/class combinations in an assembly based
I'm attempting to register a GIS based dll on a test computer and I'm
I'm trying register presenters with Windsor using the convention based method but trying to
Brief I have an installation package (MSI based) which attempts to register a dll
I'm searching for a PHP/MySQL based CMS with some basics like Register/Login. It shouldn't

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.