Skip to content

Commit

Permalink
Version 4.2.77.10 (cherry-pick)
Browse files Browse the repository at this point in the history
Merged 567e45a

Promote code from code cache to compilation cache.

BUG=chromium:399580
LOG=N
TBR=vogelheim@chromium.org

Review URL: https://codereview.chromium.org/1028483003

Cr-Commit-Position: refs/branch-heads/4.2@{crosswalk-project#11}
Cr-Branched-From: 3dfd929-refs/heads/4.2.77@{crosswalk-project#2}
Cr-Branched-From: e011092-refs/heads/master@{#26757}
  • Loading branch information
hashseed committed Mar 20, 2015
1 parent b8c8da9 commit 1236eaf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand Down
5 changes: 5 additions & 0 deletions src/compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1288,17 +1288,22 @@ 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,
language_mode);
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.
Expand Down
31 changes: 31 additions & 0 deletions test/cctest/test-serialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1236eaf

Please sign in to comment.