diff --git a/include/v8-version.h b/include/v8-version.h index b8eb8b11714..865f038bfec 100644 --- a/include/v8-version.h +++ b/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 4 #define V8_MINOR_VERSION 2 #define V8_BUILD_NUMBER 77 -#define V8_PATCH_LEVEL 9 +#define V8_PATCH_LEVEL 10 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/src/compiler.cc b/src/compiler.cc index 4b8157bee6a..d794ae2b204 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -1288,6 +1288,7 @@ Handle Compiler::CompileScript( MaybeHandle maybe_result; Handle result; if (extension == NULL) { + // First check per-isolate compilation cache. maybe_result = compilation_cache->LookupScript( source, script_name, line_offset, column_offset, is_embedder_debug_script, is_shared_cross_origin, context, @@ -1295,10 +1296,14 @@ Handle Compiler::CompileScript( if (maybe_result.is_null() && FLAG_serialize_toplevel && compile_options == ScriptCompiler::kConsumeCodeCache && !isolate->debug()->is_loaded()) { + // Then check cached code provided by embedder. HistogramTimerScope timer(isolate->counters()->compile_deserialize()); Handle result; if (CodeSerializer::Deserialize(isolate, *cached_data, source) .ToHandle(&result)) { + // Promote to per-isolate compilation cache. + DCHECK(!result->dont_cache()); + compilation_cache->PutScript(source, context, language_mode, result); return result; } // Deserializer failed. Fall through to compile. diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc index 9a348ad434d..55eac60f37a 100644 --- a/test/cctest/test-serialize.cc +++ b/test/cctest/test-serialize.cc @@ -793,6 +793,37 @@ TEST(SerializeToplevelOnePlusOne) { } +TEST(CodeCachePromotedToCompilationCache) { + FLAG_serialize_toplevel = true; + LocalContext context; + Isolate* isolate = CcTest::i_isolate(); + + v8::HandleScope scope(CcTest::isolate()); + + const char* source = "1 + 1"; + + Handle src = isolate->factory() + ->NewStringFromUtf8(CStrVector(source)) + .ToHandleChecked(); + ScriptData* cache = NULL; + + CompileScript(isolate, src, src, &cache, + v8::ScriptCompiler::kProduceCodeCache); + + DisallowCompilation no_compile_expected(isolate); + Handle copy = CompileScript( + isolate, src, src, &cache, v8::ScriptCompiler::kConsumeCodeCache); + + CHECK(isolate->compilation_cache() + ->LookupScript(src, src, 0, 0, false, false, + isolate->native_context(), SLOPPY) + .ToHandleChecked() + .is_identical_to(copy)); + + delete cache; +} + + TEST(SerializeToplevelInternalizedString) { FLAG_serialize_toplevel = true; LocalContext context;