Open mbebenita opened 9 years ago
This is a subset of #1413.
We should identify a good point to snapshot. The best from a performance perspective would be after the BG MIDlet has finished its initialization, but I'm not sure we can actually do it (because the startup flow of the BG MIDlet could be different each time).
In my benchmark in https://github.com/mozilla/j2me.js/pull/1434#issuecomment-94961084, we spend ~3 seconds initializing platform code (right before the startApp method of the BG MIDlet is called), ~3 seconds before the FG MIDlet is started by the BG MIDlet and ~13 seconds after that (which probably includes time spent both in the BG MIDlet and in the FG MIDlet).
When restoring, we would also need to restore any data that is created/changed by JS natives (for example localized strings, state of the mutexes and so on).
If we could save the state of a J2ME application, we could save quite a bit of time during startup by skipping all the initialization code.
I envision this working as follows:
Saving:
Restoring:
In this scheme, we would only serialize the object graph, not the entire state of the VM. This should be a great start.