Reviewers: vogelheim,
Description:
Version 4.2.77.10 (cherry-pick)
Merged 567e45a1927c123838ba76e5483ed6177d055275
Promote code from code cache to compilation cache.
BUG=chromium:399580
LOG=N
[email protected]
Please review this at https://codereview.chromium.org/1028483003/
Base URL: https://chromium.googlesource.com/v8/[email protected]
Affected files (+37, -1 lines):
M include/v8-version.h
M src/compiler.cc
M test/cctest/test-serialize.cc
Index: include/v8-version.h
diff --git a/include/v8-version.h b/include/v8-version.h
index
b8eb8b117146ac58ff4f60627aa603b0a31c0d1c..865f038bfecd0440e84ed761e5484b73d49f60dc
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.)
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
4b8157bee6a274ce3594391ec9e7244e03fd9d6c..d794ae2b204ec3db35a299e9f3552576c1529665
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1288,6 +1288,7 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
MaybeHandle<SharedFunctionInfo> maybe_result;
Handle<SharedFunctionInfo> 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<SharedFunctionInfo> 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<SharedFunctionInfo> 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.
Index: test/cctest/test-serialize.cc
diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
index
9a348ad434d8fac5a7b02e20071ae86b2a674585..55eac60f37a27b27d9e923d2820f6dc2bf149352
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<String> src = isolate->factory()
+ ->NewStringFromUtf8(CStrVector(source))
+ .ToHandleChecked();
+ ScriptData* cache = NULL;
+
+ CompileScript(isolate, src, src, &cache,
+ v8::ScriptCompiler::kProduceCodeCache);
+
+ DisallowCompilation no_compile_expected(isolate);
+ Handle<SharedFunctionInfo> 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;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" 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/d/optout.