Index: test/cctest/cctest.h |
diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h |
index 6359835235c069d8e2807ce667151775381aa7f1..b4e31f26df5e3a1fe7976a49f7c654b34e5c084c 100644 |
--- a/test/cctest/cctest.h |
+++ b/test/cctest/cctest.h |
@@ -346,19 +346,13 @@ static inline v8::Local<v8::Value> CompileRun(v8::Local<v8::String> source) { |
static inline v8::Local<v8::Value> PreCompileCompileRun(const char* source) { |
+ // Compile once just to get the preparse data, then compile the second time |
+ // using the data. |
v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
- v8::Local<v8::String> source_string = |
- v8::String::NewFromUtf8(isolate, source); |
- v8::ScriptData* preparse = v8::ScriptData::PreCompile(source_string); |
- v8::ScriptCompiler::Source script_source( |
- source_string, new v8::ScriptCompiler::CachedData( |
- reinterpret_cast<const uint8_t*>(preparse->Data()), |
- preparse->Length())); |
- v8::Local<v8::Script> script = |
- v8::ScriptCompiler::Compile(isolate, &script_source); |
- v8::Local<v8::Value> result = script->Run(); |
- delete preparse; |
- return result; |
+ v8::ScriptCompiler::Source script_source(v8_str(source)); |
+ v8::ScriptCompiler::Compile(isolate, &script_source, |
+ v8::ScriptCompiler::kProduceDataToCache); |
+ return v8::ScriptCompiler::Compile(isolate, &script_source)->Run(); |
} |