Register-based virtual machine?
Posted: Sun Dec 25, 2016 12:10 pm
I understand that MicroPython, like CPython, is built around a stack-based virtual machine and corresponding bytecode. Have there been any thoughts about the alternative: a register-based VM (as used by, for example, recent versions of Lua [1])?
In general, the performance of register-based machines is better than stack-based ones. For example, a register-based Java interpreter was found to require 25-35% less time to execute benchmarks than a stack-based interpreter [2]. The downsides of this register-based VM were increased bytecode size (by 25%) and increased complexity of the compiler and VM.
However, a recent paper [3] describes a register-based bytecode which is smaller than the equivalent stack-based code, and concludes:
"Because of the advantages in speed and its small bytecode size, a register-based virtual machine can be best applied on systems where both computational and storage facilities are limited (e.g. embedded systems)"
Would it be possible to add a register-based bytecode to MicroPython, either as a configuration option or a replacement for the current stack-based bytecode? Do you think this would produce a significant increase in performance?
If so, has anybody worked on implementing such a bytecode? Is this a feature which MicroPython might have in the future, or is the performance increase not worth the added complexity?
[1] https://www.lua.org/doc/jucs05.pdf
[2] https://www.usenix.org/legacy/events/ve ... -yunhe.pdf
[3] https://arxiv.org/pdf/1611.00467v1.pdf
In general, the performance of register-based machines is better than stack-based ones. For example, a register-based Java interpreter was found to require 25-35% less time to execute benchmarks than a stack-based interpreter [2]. The downsides of this register-based VM were increased bytecode size (by 25%) and increased complexity of the compiler and VM.
However, a recent paper [3] describes a register-based bytecode which is smaller than the equivalent stack-based code, and concludes:
"Because of the advantages in speed and its small bytecode size, a register-based virtual machine can be best applied on systems where both computational and storage facilities are limited (e.g. embedded systems)"
Would it be possible to add a register-based bytecode to MicroPython, either as a configuration option or a replacement for the current stack-based bytecode? Do you think this would produce a significant increase in performance?
If so, has anybody worked on implementing such a bytecode? Is this a feature which MicroPython might have in the future, or is the performance increase not worth the added complexity?
[1] https://www.lua.org/doc/jucs05.pdf
[2] https://www.usenix.org/legacy/events/ve ... -yunhe.pdf
[3] https://arxiv.org/pdf/1611.00467v1.pdf