Commit 612368b8 authored by jyan's avatar jyan Committed by Commit bot

S390: [interpreter] Heal closures when bytecode array is gone.

Port 5c8609de

Original commit message:

    This ensures the InterpreterEntryTrampoline heals code entry fields
    inside closures when being called without a valid bytecode array. This
    is preparatory work to allow removal of bytecode when switching some
    functions to other types of code.

R=mstarzinger@chromium.org, joransiu@ca.ibm.com, bjaideep@ca.ibm.com, michael_dawson@ca.ibm.com, mbrandy@us.ibm.com

BUG=v8:4280
LOG=N

Review URL: https://codereview.chromium.org/1921673004

Cr-Commit-Position: refs/heads/master@{#35776}
parent 2e4280f2
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment