OK, I found it. The problem is the uninitialized code stub for loading the dictionary - your use case starts it as a failure, since the stub is not initialized by other means, for example, compilation.
Below is a patch against v8 trunk version 22629, which fixes the problem for me, tested on Windows with VS 2010 and Linux with g ++ 4.9. Please let me know how you do this:
Index: src/code-stubs.cc =================================================================== --- src/code-stubs.cc (revision 22629) +++ src/code-stubs.cc (working copy) @@ -236,6 +236,8 @@ CODE_STUB_LIST(DEF_CASE) #undef DEF_CASE case UninitializedMajorKey: return "<UninitializedMajorKey>Stub"; + case NoCache: + return "<NoCache>Stub"; default: if (!allow_unknown_keys) { UNREACHABLE(); @@ -939,6 +941,13 @@
As a workaround, if you donβt want to compile your own V8 now, you can execute the code on each Isolate that uses the KeyedLoadDictionaryElementStub directly, before your code runs --- this should initialize the stubs. For me, something similar to the following works:
Isolate* isolate = Isolate::New(); Isolate::Scope isolate_scope(isolate); HandleScope handle_scope(isolate); Local<Context> context = Context::New(isolate); Context::Scope context_scope(context); Local<Array> a = Array::New(isolate); context->Global()->Set(String::NewFromUtf8(isolate, "a"), a); // Workaround code for initializing KeyedLoadDictionaryElementStub Local<String> workaround_source = String::NewFromUtf8(isolate, "Math.random()"); Local<Script> workaround_script = Script::Compile(workaround_source); Local<Value> workaround_value = workaround_script->Run(); // End workaround Local<String> source = String::NewFromUtf8(isolate, "a[0]"); Local<Script> script = Script::Compile(source); // ...and so on
msandiford
source share