Jul. 14th, 2009

rbandrews: (Lambda)
Virtual machines work in one of two ways: either they use a stack and push/pop things on it, or they use registers.

Stacks are vastly easier to write because it more closely matches the way parsers work: you evaluate sub-expressions, push return values on to the stack, and so on. But you have to use more memory for the stack.

Registers are faster because they more closely match the way hardware works: a single register machine instruction encompasses two or four stack machine instructions, and you don't have to shuffle things around to get at things. But you have to deal with register allocation algorithms.

So, here's my idea: why not a VM with a variable number of registers? Each function would get run through some algorithm that figures out how many registers it needs to run, and then the VM just has that many registers for running that function. Function return values are always one register anyway (either the value or a reference to the value).

Profile

rbandrews: (Default)
rbandrews

July 2024

S M T W T F S
 123456
78910111213
14151617181920
212223242526 27
28293031   

Style Credit

Page generated Jun. 9th, 2025 06:50 am
Powered by Dreamwidth Studios

Expand Cut Tags

No cut tags