Splitting from #8:
given its python it would also be useful to implement memory as copy on write. the constructor for the class would be given the ngaImage as an array of integers. memory for the vm is however a dictionary of addresses that have been written to. reads are first checked against the changed memory, falling back to the array for the default value.
Things to do to make this work:
- add a dictionary for the copy-on-write
- update i_st() to update this
- update i_fe() to check this and select either the raw memory or the dictionary value
- update findEntry(), i_li(), extractString(), injectString(), execute(), run() to check both memory areas
For this, we should add a functions for handling this and use them, to make overall maintenance and remove what would otherwise be unneeded duplications.
RFC: What are the primary advantages / disadvantages of this?
I'm not a Python developer; while I do use Python, I'm far from being an expert in it, and have no real idea of the tradeoffs involved.
runtime overhead during memory access and additional code traded for:
instant startup allowing arrays of hundreds (thousands++) of VMs at near zero cost
lower overall memory use where base image is baked into the source code
allows unbounded growth on demand as the memory size is not fixed at startup
freeze/restore state is more efficient as only changed memory and registers are copied