Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Revert of [Interpreter] Remove InterpreterExitTrampoline and replace …
Browse files Browse the repository at this point in the history
…with returning to the entry trampoline. (patchset #6 id:170001 of https://codereview.chromium.org/1969423002/ )

Reason for revert:
Breaks
https://build.chromium.org/p/client.v8.ports/builders/V8%20Linux%20-%20arm%20-%20sim/builds/619

Might only affect pure release builds?

Original issue's description:
> [Interpreter] Remove InterpreterExitTrampoline and replace with returning to the entry trampoline.
>
> In order to support compiling to baseline on return we need to be able to
> return to the actual return address. With this change this is what the
> Return bytecode now does, removing the need for the
> InterpreterExitTrampoline.
>
> This change also removes the InterpreterNotifyDeoptXXX builtins and
> unifies FCG and Igntion to both use NotifyDeoptXXX. As part of this
> change, FullCodegenerator::State is moved to Deoptimize::BailoutState.
>
> BUG=v8:4280
> LOG=N
>
> Committed: https://crrev.com/34c9626e2ee56fe805de549697ca5323aed7cb66
> Cr-Commit-Position: refs/heads/master@{#36288}

TBR=mstarzinger@chromium.org,oth@chromium.org,rmcilroy@chromium.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:4280

Review-Url: https://codereview.chromium.org/1986353002
Cr-Commit-Position: refs/heads/master@{#36294}
  • Loading branch information
mi-ac authored and Commit bot committed May 17, 2016
1 parent 0151651 commit c473f29
Show file tree
Hide file tree
Showing 27 changed files with 992 additions and 800 deletions.
98 changes: 72 additions & 26 deletions src/arm/builtins-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
Generate_JSEntryTrampolineHelper(masm, true);
}


// Generate code for entering a JS function with the interpreter.
// On entry to the function the receiver and arguments have been pushed on the
// stack left to right. The actual argument count matches the formal parameter
Expand Down Expand Up @@ -1059,19 +1060,9 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ ldr(ip, MemOperand(kInterpreterDispatchTableRegister, r1, LSL,
kPointerSizeLog2));
__ Call(ip);
masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset());

// The return value is in r0.

// Get the arguments + reciever count.
__ ldr(r2, MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp));
__ ldr(r2, FieldMemOperand(r2, BytecodeArray::kParameterSizeOffset));

// Leave the frame (also dropping the register file).
__ LeaveFrame(StackFrame::JAVA_SCRIPT);

__ add(sp, sp, r2, LeaveCC);
__ Jump(lr);
// 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
Expand All @@ -1086,6 +1077,21 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ Jump(r4);
}


void Builtins::Generate_InterpreterExitTrampoline(MacroAssembler* masm) {
// The return value is in accumulator, which is already in r0.

// Leave the frame (also dropping the register file).
__ LeaveFrame(StackFrame::JAVA_SCRIPT);

// Drop receiver + arguments and return.
__ ldr(ip, FieldMemOperand(kInterpreterBytecodeArrayRegister,
BytecodeArray::kParameterSizeOffset));
__ add(sp, sp, ip, LeaveCC);
__ Jump(lr);
}


static void Generate_InterpreterPushArgs(MacroAssembler* masm, Register index,
Register limit, Register scratch) {
Label loop_header, loop_check;
Expand All @@ -1098,6 +1104,7 @@ static void Generate_InterpreterPushArgs(MacroAssembler* masm, Register index,
__ b(gt, &loop_header);
}


// static
void Builtins::Generate_InterpreterPushArgsAndCallImpl(
MacroAssembler* masm, TailCallMode tail_call_mode) {
Expand All @@ -1123,6 +1130,7 @@ void Builtins::Generate_InterpreterPushArgsAndCallImpl(
RelocInfo::CODE_TARGET);
}


// static
void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) {
// ----------- S t a t e -------------
Expand All @@ -1147,16 +1155,8 @@ void Builtins::Generate_InterpreterPushArgsAndConstruct(MacroAssembler* masm) {
__ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
}

void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) {
// Set the return address to the correct point in the interpreter entry
// trampoline.
Smi* interpreter_entry_return_pc_offset(
masm->isolate()->heap()->interpreter_entry_return_pc_offset());
DCHECK_NE(interpreter_entry_return_pc_offset, Smi::FromInt(0));
__ Move(r2, masm->isolate()->builtins()->InterpreterEntryTrampoline());
__ add(lr, r2, Operand(interpreter_entry_return_pc_offset->value() +
Code::kHeaderSize - kHeapObjectTag));

static void Generate_EnterBytecodeDispatch(MacroAssembler* masm) {
// Initialize the dispatch table register.
__ mov(kInterpreterDispatchTableRegister,
Operand(ExternalReference::interpreter_dispatch_table_address(
Expand Down Expand Up @@ -1188,6 +1188,55 @@ void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) {
__ mov(pc, ip);
}


static void Generate_InterpreterNotifyDeoptimizedHelper(
MacroAssembler* masm, Deoptimizer::BailoutType type) {
// Enter an internal frame.
{
FrameScope scope(masm, StackFrame::INTERNAL);

// Pass the deoptimization type to the runtime system.
__ mov(r1, Operand(Smi::FromInt(static_cast<int>(type))));
__ push(r1);
__ CallRuntime(Runtime::kNotifyDeoptimized);
// Tear down internal frame.
}

// Drop state (we don't use these for interpreter deopts) and and pop the
// accumulator value into the accumulator register.
__ Drop(1);
__ Pop(kInterpreterAccumulatorRegister);

// Enter the bytecode dispatch.
Generate_EnterBytecodeDispatch(masm);
}


void Builtins::Generate_InterpreterNotifyDeoptimized(MacroAssembler* masm) {
Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::EAGER);
}


void Builtins::Generate_InterpreterNotifySoftDeoptimized(MacroAssembler* masm) {
Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::SOFT);
}


void Builtins::Generate_InterpreterNotifyLazyDeoptimized(MacroAssembler* masm) {
Generate_InterpreterNotifyDeoptimizedHelper(masm, Deoptimizer::LAZY);
}

void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) {
// Set the address of the interpreter entry trampoline as a return address.
// This simulates the initial call to bytecode handlers in interpreter entry
// trampoline. The return will never actually be taken, but our stack walker
// uses this address to determine whether a frame is interpreted.
__ Move(lr, masm->isolate()->builtins()->InterpreterEntryTrampoline());

Generate_EnterBytecodeDispatch(masm);
}


void Builtins::Generate_CompileLazy(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r0 : argument count (preserved for callee)
Expand Down Expand Up @@ -1477,17 +1526,14 @@ static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm,
__ SmiUntag(r6);
// Switch on the state.
Label with_tos_register, unknown_state;
__ cmp(r6,
Operand(static_cast<int>(Deoptimizer::BailoutState::NO_REGISTERS)));
__ cmp(r6, Operand(FullCodeGenerator::NO_REGISTERS));
__ b(ne, &with_tos_register);
__ add(sp, sp, Operand(1 * kPointerSize)); // Remove state.
__ Ret();

__ bind(&with_tos_register);
DCHECK_EQ(kInterpreterAccumulatorRegister.code(), r0.code());
__ ldr(r0, MemOperand(sp, 1 * kPointerSize));
__ cmp(r6,
Operand(static_cast<int>(Deoptimizer::BailoutState::TOS_REGISTER)));
__ cmp(r6, Operand(FullCodeGenerator::TOS_REG));
__ b(ne, &unknown_state);
__ add(sp, sp, Operand(2 * kPointerSize)); // Remove state.
__ Ret();
Expand Down
Loading

0 comments on commit c473f29

Please sign in to comment.