Index: src/s390/builtins-s390.cc |
diff --git a/src/s390/builtins-s390.cc b/src/s390/builtins-s390.cc |
index 6d264d1ad85878dbd9963fe2b519ad206a8e9e7c..86531fa888299569a9b833776755ec83159cb967 100644 |
--- a/src/s390/builtins-s390.cc |
+++ b/src/s390/builtins-s390.cc |
@@ -987,8 +987,8 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { |
FrameScope frame_scope(masm, StackFrame::MANUAL); |
__ PushStandardFrame(r3); |
- // Get the bytecode array from the function object and load the pointer to the |
- // first entry into kInterpreterBytecodeRegister. |
+ // Get the bytecode array from the function object (or from the DebugInfo if |
+ // it is present) and load it into kInterpreterBytecodeArrayRegister. |
__ LoadP(r2, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset)); |
Label array_done; |
Register debug_info = r4; |
@@ -1004,8 +1004,13 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { |
FieldMemOperand(debug_info, DebugInfo::kAbstractCodeIndex)); |
__ bind(&array_done); |
+ // Check function data field is actually a BytecodeArray object. |
+ Label bytecode_array_not_present; |
+ __ CompareRoot(kInterpreterBytecodeArrayRegister, |
+ Heap::kUndefinedValueRootIndex); |
+ __ beq(&bytecode_array_not_present); |
+ |
if (FLAG_debug_code) { |
- // Check function data field is actually a BytecodeArray object. |
__ TestIfSmi(kInterpreterBytecodeArrayRegister); |
__ Assert(ne, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); |
__ CompareObjectType(kInterpreterBytecodeArrayRegister, r2, no_reg, |
@@ -1066,6 +1071,18 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { |
// Even though the first bytecode handler was called, we will never return. |
__ Abort(kUnexpectedReturnFromBytecodeHandler); |
+ |
+ // If the bytecode array is no longer present, then the underlying function |
+ // has been switched to a different kind of code and we heal the closure by |
+ // switching the code entry field over to the new code object as well. |
+ __ bind(&bytecode_array_not_present); |
+ __ LeaveFrame(StackFrame::JAVA_SCRIPT); |
+ __ LoadP(r6, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset)); |
+ __ LoadP(r6, FieldMemOperand(r6, SharedFunctionInfo::kCodeOffset)); |
+ __ AddP(r6, r6, Operand(Code::kHeaderSize - kHeapObjectTag)); |
+ __ StoreP(r6, FieldMemOperand(r3, JSFunction::kCodeEntryOffset), r0); |
+ __ RecordWriteCodeEntryField(r3, r6, r7); |
+ __ JumpToJSEntry(r6); |
} |
void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) { |