diff --git a/src/snapshot/code-serializer.cc b/src/snapshot/code-serializer.cc index df728fcfc96..f5f233d0649 100644 --- a/src/snapshot/code-serializer.cc +++ b/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