Persistent V8

91 views
Skip to first unread message

Gillis Van Ginderachter

unread,
Nov 7, 2012, 9:55:17 AM11/7/12
to v8-u...@googlegroups.com
Hi,

We're currently working on a project making the V8 engine persistent. So the point of this project is that when your program (that uses V8 engine) crashes, it will continue from the last saved checkpoint.

To make this possible we make use of the Ken library (see http://ai.eecs.umich.edu/~tpkelly/Ken/). The Ken library provides abstractions for the presistent heap. So instead of using malloc and free, the Ken library provides ken_malloc and ken_free to store memory on the persistent heap.

We've been digging in de V8 code already and examined how V8 does memory management. Based on those examinations we've ported the code to use the Ken library:
  • the class VirtualMemory now uses the Ken back-end instead of mmap
  • the new/delete operators also use the Ken back-end
  • all malloc/free have been replaced with ken_malloc/ken_free
So the whole V8 now uses the Ken back-end.

There is one problem though. When the program restores from a crash the default Isolate is restored together with the global object and the global context. After that restore, variables are changed. So if I declared "a=1" in the initial state, then crash the program and restart it, "a" suddenly is a string. So restoring doesn't really work...

This being said, we need your help. Is there a better way to make the V8 engine persistent? Something like persisting only the VirtualMemory, and when restoring we rebuild the heap/gc or something?

Thanks in advance,
Gillis

PS: the current code can be found on GitHub (see https://github.com/supergillis/v8-ken)

Yang Guo

unread,
Nov 12, 2012, 5:06:32 AM11/12/12
to v8-u...@googlegroups.com, super...@gmail.com
Objects on the V8 heap use raw pointers to refer to other objects. When you restore the heap to memory addresses different than the original, you will have to update those references. V8 does have a snapshot mechanism that serializes the heap, but it has some limitations, e.g. for code objects.

Yang
Reply all
Reply to author
Forward
0 new messages