Index: src/ppc/builtins-ppc.cc |
diff --git a/src/ppc/builtins-ppc.cc b/src/ppc/builtins-ppc.cc |
index 63e8c0f3e35e6d5ff77d72f1bf8518d0961ad050..51e44bae9b99175895d9456ef9be218e818ff01e 100644 |
--- a/src/ppc/builtins-ppc.cc |
+++ b/src/ppc/builtins-ppc.cc |
@@ -999,8 +999,8 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { |
FrameScope frame_scope(masm, StackFrame::MANUAL); |
__ PushStandardFrame(r4); |
- // 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(r3, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
Label array_done; |
Register debug_info = r5; |
@@ -1016,8 +1016,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, r0); |
__ Assert(ne, kFunctionDataShouldBeBytecodeArrayOnInterpreterEntry); |
__ CompareObjectType(kInterpreterBytecodeArrayRegister, r3, no_reg, |
@@ -1076,6 +1081,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(r7, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
+ __ LoadP(r7, FieldMemOperand(r7, SharedFunctionInfo::kCodeOffset)); |
+ __ addi(r7, r7, Operand(Code::kHeaderSize - kHeapObjectTag)); |
+ __ StoreP(r7, FieldMemOperand(r4, JSFunction::kCodeEntryOffset), r0); |
+ __ RecordWriteCodeEntryField(r4, r7, r8); |
+ __ JumpToJSEntry(r7); |
} |