Everything that is valid json plus arraybuffers and arraybuffer-views
can be restored automatically (without making changes to other code).
Properties that should not be part of the state buffer needed to be
annotated using a magic `_state_skip` property. Shared arraybuffer views
are broken during restoration and also need to be annotated. Adapters
are not (and should never be) saved.
Current limitations:
- Before restoring, the cpu needs to be initialised with the original
settings. This is not a hard requirement and can be fixed later.
- Pending asynchronous operations are lost. It's a good idea to pause
the cpu before saving the state.
This change was necessary for several reasons:
- Code is much clearer and more modular
- The CPU object is now serializeable and therefore can be safed and
restored
- A dynamic translator from instructions to (optimized) JavaScript is
planned. It would use `new Function` to create functions at runtime.
Functions created this way don't have access to any scope (except for
the global scope) and therefore were not have been able to modify
registers, etc. This is now possible through the cpu object
- Possibly, but not necessarily a speedgain can be achieved.
See http://mrale.ph/blog/2012/09/23/grokking-v8-closures-for-fun.html
Additionally, some code was moved around.