From 83362913f611018b04fa1eb69ed5ecf045094a39 Mon Sep 17 00:00:00 2001 From: Matheus Marchini Date: Mon, 29 Apr 2019 10:35:39 -0700 Subject: [PATCH] deps: V8: backport d915b8d Original commit message: [snapshot] Fix copy-IET integration with Code Cache R=bmeurer@chromium.org, jgruber@chromium.org, yangguo@chromium.org Bug: v8:9122 Change-Id: I6336d2fc0249269a749d99dcae7c172b2ccaac75 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1570582 Reviewed-by: Jakob Gruber Commit-Queue: Jakob Gruber Cr-Commit-Position: refs/heads/master@{#60937} Refs: https://github.com/v8/v8/commit/d915b8d668615a7d6d75cf7a61d3ca5a3d139799 --- common.gypi | 2 +- deps/v8/src/snapshot/code-serializer.cc | 61 ++++++++++++++++++++++++ deps/v8/test/cctest/cctest.status | 10 ++++ deps/v8/test/cctest/test-log.cc | 63 +++++++++++++++++++++++++ deps/v8/test/cctest/test-serialize.cc | 14 +++++- 5 files changed, 147 insertions(+), 3 deletions(-) diff --git a/common.gypi b/common.gypi index 83efbb8898956b..223043e55194c3 100644 --- a/common.gypi +++ b/common.gypi @@ -38,7 +38,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.17', + 'v8_embedder_string': '-node.18', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/snapshot/code-serializer.cc b/deps/v8/src/snapshot/code-serializer.cc index f72446564f47f5..47aa104bae79e1 100644 --- a/deps/v8/src/snapshot/code-serializer.cc +++ b/deps/v8/src/snapshot/code-serializer.cc @@ -187,6 +187,18 @@ void CodeSerializer::SerializeObject(HeapObject obj) { return; } + // NOTE(mmarchini): If we try to serialize an InterpreterData our process + // will crash since it stores a code object. Instead, we serialize the + // bytecode array stored within the InterpreterData, which is the important + // information. On deserialization we'll create our code objects again, if + // --interpreted-frames-native-stack is on. See v8:9122 for more context +#ifndef V8_TARGET_ARCH_ARM + if (V8_UNLIKELY(FLAG_interpreted_frames_native_stack) && + obj->IsInterpreterData()) { + obj = InterpreterData::cast(obj)->bytecode_array(); + } +#endif // V8_TARGET_ARCH_ARM + if (obj->IsBytecodeArray()) { // Clear the stack frame cache if present BytecodeArray::cast(obj)->ClearFrameCacheFromSourcePositionTable(); @@ -210,6 +222,48 @@ void CodeSerializer::SerializeGeneric(HeapObject heap_object) { serializer.Serialize(); } +#ifndef V8_TARGET_ARCH_ARM +// NOTE(mmarchini): when FLAG_interpreted_frames_native_stack is on, we want to +// create duplicates of InterpreterEntryTrampoline for the deserialized +// functions, otherwise we'll call the builtin IET for those functions (which +// is not what a user of this flag wants). +void CreateInterpreterDataForDeserializedCode(Isolate* isolate, + Handle sfi, + bool log_code_creation) { + Script script = Script::cast(sfi->script()); + Handle