Index: src/mips64/builtins-mips64.cc |
diff --git a/src/mips64/builtins-mips64.cc b/src/mips64/builtins-mips64.cc |
index 932881c484225376a71f94f401147a413b73dc7e..da2376b10cc2e3fa516d907a8102a3df2740c638 100644 |
--- a/src/mips64/builtins-mips64.cc |
+++ b/src/mips64/builtins-mips64.cc |
@@ -972,8 +972,8 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { |
FrameScope frame_scope(masm, StackFrame::MANUAL); |
__ PushStandardFrame(a1); |
- // 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. |
__ ld(a0, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
Label load_debug_bytecode_array, bytecode_array_loaded; |
Register debug_info = kInterpreterBytecodeArrayRegister; |
@@ -985,8 +985,11 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { |
FieldMemOperand(a0, SharedFunctionInfo::kFunctionDataOffset)); |
__ bind(&bytecode_array_loaded); |
+ // Check function data field is actually a BytecodeArray object. |
+ Label bytecode_array_not_present; |
+ __ JumpIfRoot(kInterpreterBytecodeArrayRegister, |
+ Heap::kUndefinedValueRootIndex, &bytecode_array_not_present); |
if (FLAG_debug_code) { |
- // Check function data field is actually a BytecodeArray object. |
__ SmiTst(kInterpreterBytecodeArrayRegister, a4); |
__ Assert(ne, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry, a4, |
Operand(zero_reg)); |
@@ -1051,6 +1054,18 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { |
__ ld(kInterpreterBytecodeArrayRegister, |
FieldMemOperand(debug_info, DebugInfo::kAbstractCodeIndex)); |
__ Branch(&bytecode_array_loaded); |
+ |
+ // 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); |
+ __ ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
+ __ ld(a4, FieldMemOperand(a4, SharedFunctionInfo::kCodeOffset)); |
+ __ Daddu(a4, a4, Operand(Code::kHeaderSize - kHeapObjectTag)); |
+ __ sd(a4, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
+ __ RecordWriteCodeEntryField(a1, a4, a5); |
+ __ Jump(a4); |
} |