diff options
author | Marcel Laverdet <marcel@laverdet.com> | 2018-07-29 10:37:56 -0600 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-09-04 14:47:09 +0200 |
commit | 0d3da39f575afba5ab6a5a34f4e88a798a66dc6d (patch) | |
tree | 37d8ec90aa2eba4fbde7f5077c545b66723ccc85 /deps | |
parent | bb3575242cc87f59882bbcefa253353313f5606b (diff) | |
download | node-new-0d3da39f575afba5ab6a5a34f4e88a798a66dc6d.tar.gz |
deps: cherry-pick 22116dd from upstream V8
Refs: https://github.com/v8/v8/commit/22116dd6c884c026225e56dd8e442a660193e729
Original commit message:
[snapshot] fix resetting function code.
Unconditionally setting the JSFunction code to that of the SFI
may skip initializing the feedback vector.
R=leszeks@chromium.org
Bug: v8:7857
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: I65d4bf32493be4cade2eaf3d665d44f93e80f809
Reviewed-on: https://chromium-review.googlesource.com/1107618
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53881}
PR-URL: https://github.com/nodejs/node/pull/21992
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Diffstat (limited to 'deps')
-rw-r--r-- | deps/v8/src/api.cc | 7 | ||||
-rw-r--r-- | deps/v8/src/snapshot/partial-serializer.cc | 2 | ||||
-rw-r--r-- | deps/v8/test/cctest/test-serialize.cc | 41 |
3 files changed, 47 insertions, 3 deletions
diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 50e88904af..5df3188ab6 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -766,8 +766,11 @@ StartupData SnapshotCreator::CreateBlob( // Complete in-object slack tracking for all functions. fun->CompleteInobjectSlackTrackingIfActive(); - // Also, clear out feedback vectors. - fun->feedback_cell()->set_value(isolate->heap()->undefined_value()); + // Also, clear out feedback vectors, or any optimized code. + if (fun->has_feedback_vector()) { + fun->feedback_cell()->set_value(isolate->heap()->undefined_value()); + fun->set_code(isolate->builtins()->builtin(i::Builtins::kCompileLazy)); + } } // Clear out re-compilable data from all shared function infos. Any diff --git a/deps/v8/src/snapshot/partial-serializer.cc b/deps/v8/src/snapshot/partial-serializer.cc index 8b4c9d8d92..5624ba9887 100644 --- a/deps/v8/src/snapshot/partial-serializer.cc +++ b/deps/v8/src/snapshot/partial-serializer.cc @@ -105,7 +105,7 @@ void PartialSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code, // Unconditionally reset the JSFunction to its SFI's code, since we can't // serialize optimized code anyway. JSFunction* closure = JSFunction::cast(obj); - closure->set_code(closure->shared()->GetCode()); + if (closure->is_compiled()) closure->set_code(closure->shared()->GetCode()); } CheckRehashability(obj); diff --git a/deps/v8/test/cctest/test-serialize.cc b/deps/v8/test/cctest/test-serialize.cc index 453cb10881..c26a7e7348 100644 --- a/deps/v8/test/cctest/test-serialize.cc +++ b/deps/v8/test/cctest/test-serialize.cc @@ -2640,6 +2640,47 @@ TEST(SnapshotCreatorNoExternalReferencesDefault) { delete[] blob.data; } +v8::StartupData CreateCustomSnapshotArrayJoinWithKeep() { + v8::SnapshotCreator creator; + v8::Isolate* isolate = creator.GetIsolate(); + { + v8::HandleScope handle_scope(isolate); + { + v8::Local<v8::Context> context = v8::Context::New(isolate); + v8::Context::Scope context_scope(context); + CompileRun( + "[].join('');\n" + "function g() { return String([1,2,3]); }\n"); + ExpectString("g()", "1,2,3"); + creator.SetDefaultContext(context); + } + } + return creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kKeep); +} + +TEST(SnapshotCreatorArrayJoinWithKeep) { + DisableAlwaysOpt(); + v8::StartupData blob = CreateCustomSnapshotArrayJoinWithKeep(); + + // Deserialize with an incomplete list of external references. + { + v8::Isolate::CreateParams params; + params.snapshot_blob = &blob; + params.array_buffer_allocator = CcTest::array_buffer_allocator(); + // Test-appropriate equivalent of v8::Isolate::New. + v8::Isolate* isolate = TestIsolate::New(params); + { + v8::Isolate::Scope isolate_scope(isolate); + v8::HandleScope handle_scope(isolate); + v8::Local<v8::Context> context = v8::Context::New(isolate); + v8::Context::Scope context_scope(context); + ExpectString("g()", "1,2,3"); + } + isolate->Dispose(); + } + delete[] blob.data; +} + TEST(SnapshotCreatorNoExternalReferencesCustomFail1) { DisableAlwaysOpt(); v8::StartupData blob = CreateSnapshotWithDefaultAndCustom(); |