Hi v8-users,
I'm working on a desktop application which is very sensible to the startup
time, I saw that V8's snapshot feature is exactly for this purpose, so I
patched V8 to make it accept external snapshot files.
For small snapshot files this worked perfectly, but after I tried with
large extra js files (like jquery), the v8::Initialize would fail with
following stack trace:
Current executable set to './out/Release/v8_shell' (x86_64).
(lldb) run
Process 22132 launched: './out/Release/v8_shell' (x86_64)
Process 22132 stopped
* thread #1: tid = 0x2f53c, 0x00000001000876fd
v8_shell`v8::internal::Heap::ClearJSFunctionResultCaches() [inlined]
v8::internal::FixedArray::get(context=0x0000000000000000, index=56) at
objects-inl.h:1956, queue = 'com.apple.main-thread, stop reason =
EXC_BAD_ACCESS (code=1, address=0x1cf)
frame #0: 0x00000001000876fd
v8_shell`v8::internal::Heap::ClearJSFunctionResultCaches() [inlined]
v8::internal::FixedArray::get(context=0x0000000000000000, index=56) at
objects-inl.h:1956
1953
1954 Object* FixedArray::get(int index) {
1955 ASSERT(index >= 0 && index < this->length());
-> 1956 return READ_FIELD(this, kHeaderSize + index * kPointerSize);
1957 }
1958
1959
(lldb) bt
* thread #1: tid = 0x2f53c, 0x00000001000876fd
v8_shell`v8::internal::Heap::ClearJSFunctionResultCaches() [inlined]
v8::internal::FixedArray::get(context=0x0000000000000000, index=56) at
objects-inl.h:1956, queue = 'com.apple.main-thread, stop reason =
EXC_BAD_ACCESS (code=1, address=0x1cf)
frame #0: 0x00000001000876fd
v8_shell`v8::internal::Heap::ClearJSFunctionResultCaches() [inlined]
v8::internal::FixedArray::get(context=0x0000000000000000, index=56) at
objects-inl.h:1956
frame #1: 0x00000001000876fd
v8_shell`v8::internal::Heap::ClearJSFunctionResultCaches(this=<unavailable>)
+ 93 at heap.cc:850
frame #2: 0x0000000100088e5f
v8_shell`v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace,
v8::internal::GarbageCollector, char const*, char const*) [inlined]
v8::internal::Heap::GarbageCollectionPrologue(this=<unavailable>) + 24 at
heap.cc:440
frame #3: 0x0000000100088e47
v8_shell`v8::internal::Heap::CollectGarbage(this=0x0000000101803210,
space=<unavailable>, collector=<unavailable>, gc_reason=0x00000001003a1f58,
collector_reason=<unavailable>) + 263 at heap.cc:676
frame #4: 0x0000000100089bad
v8_shell`v8::internal::Heap::ReserveSpace(int*, unsigned char**) [inlined]
v8::internal::Heap::CollectGarbage(this=0x0000000101803210,
gc_reason=<unavailable>) + 109 at heap-inl.h:546
frame #5: 0x0000000100089b81
v8_shell`v8::internal::Heap::ReserveSpace(int*, unsigned char**) [inlined]
v8::internal::AbortIncrementalMarkingAndCollectGarbage(v8::internal::Heap*,
v8::internal::AllocationSpace, char const*) + 16 at heap.cc:780
frame #6: 0x0000000100089b71
v8_shell`v8::internal::Heap::ReserveSpace(this=0x0000000101803210,
sizes=0x00007fff5fbff6a0, locations_out=0x00007fff5fbff660) + 49 at
heap.cc:809
frame #7: 0x000000010020a939
v8_shell`v8::internal::Deserializer::Deserialize(this=0x00007fff5fbff648,
isolate=0x0000000101803200) + 41 at serialize.cc:815
frame #8: 0x000000010011ca4a
v8_shell`v8::internal::Isolate::Init(this=0x0000000101803200,
des=0x00007fff5fbff648) + 2522 at isolate.cc:2260
frame #9: 0x000000010023125c
v8_shell`v8::internal::V8::Initialize(des=<unavailable>) + 124 at v8.cc:78
frame #10: 0x000000010020d3b0
v8_shell`v8::internal::Snapshot::Initialize(snapshot_file=<unavailable>) +
880 at snapshot-common.cc:152
frame #11: 0x0000000100009368 v8_shell`v8::V8::Initialize(char const*)
[inlined] v8::InitializeHelper(snapshot_file=0x0000000100396e30) + 18 at
api.cc:315
frame #12: 0x0000000100009356
v8_shell`v8::V8::Initialize(snapshot_file=0x0000000100396e30) + 38 at
api.cc:5179
frame #13: 0x0000000100001093 v8_shell`main(argc=1,
argv=0x00007fff5fbff810) + 67 at shell.cc:75
frame #14: 0x0000000100001044
v8_shell`___lldb_unnamed_function1$$v8_shell + 52
As I searched in the mailing list, there seems to be a object space
limitation on the snapshot feature, is this true? And is there a way to get
round of the size limitation (like changing some predefined constant
variable)?
I also notice that ScriptData can be used to precompile script, is the
ScriptData serializable so I could write it in a file and the load it in
clients' machines? And is there any benchmark on how much time ScriptData
could save?
My patch for V8 can be found here,
<https://gist.github.com/zcbenz/8837916>there is nothing special in it and it
just made V8 to accept external
snapshot file.
Thanks,
Cheng
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.