Commit dcf3b663 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[builtins] Defer throw in InterpreterEntryTrampoline

Bug: v8:9771
Change-Id: I6ffa794e1b3e22f2c584a9959222b63c84a47374
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1825222
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Auto-Submit: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63994}
parent be116477
...@@ -1121,19 +1121,17 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1121,19 +1121,17 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ Push(kInterpreterBytecodeArrayRegister, r0); __ Push(kInterpreterBytecodeArrayRegister, r0);
// Allocate the local and temporary register file on the stack. // Allocate the local and temporary register file on the stack.
Label stack_overflow;
{ {
// Load frame size from the BytecodeArray object. // Load frame size from the BytecodeArray object.
__ ldr(r4, FieldMemOperand(kInterpreterBytecodeArrayRegister, __ ldr(r4, FieldMemOperand(kInterpreterBytecodeArrayRegister,
BytecodeArray::kFrameSizeOffset)); BytecodeArray::kFrameSizeOffset));
// Do a stack check to ensure we don't go over the limit. // Do a stack check to ensure we don't go over the limit.
Label ok;
__ sub(r9, sp, Operand(r4)); __ sub(r9, sp, Operand(r4));
LoadRealStackLimit(masm, r2); LoadRealStackLimit(masm, r2);
__ cmp(r9, Operand(r2)); __ cmp(r9, Operand(r2));
__ b(hs, &ok); __ b(lo, &stack_overflow);
__ CallRuntime(Runtime::kThrowStackOverflow);
__ bind(&ok);
// If ok, push undefined as the initial value for all register file entries. // If ok, push undefined as the initial value for all register file entries.
Label loop_header; Label loop_header;
...@@ -1201,6 +1199,10 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1201,6 +1199,10 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ bind(&compile_lazy); __ bind(&compile_lazy);
GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy);
__ bkpt(0); // Should not return. __ bkpt(0); // Should not return.
__ bind(&stack_overflow);
__ CallRuntime(Runtime::kThrowStackOverflow);
__ bkpt(0); // Should not return.
} }
static void Generate_InterpreterPushArgs(MacroAssembler* masm, static void Generate_InterpreterPushArgs(MacroAssembler* masm,
......
...@@ -1248,13 +1248,13 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1248,13 +1248,13 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ Push(kInterpreterBytecodeArrayRegister, x0); __ Push(kInterpreterBytecodeArrayRegister, x0);
// Allocate the local and temporary register file on the stack. // Allocate the local and temporary register file on the stack.
Label stack_overflow;
{ {
// Load frame size from the BytecodeArray object. // Load frame size from the BytecodeArray object.
__ Ldr(w11, FieldMemOperand(kInterpreterBytecodeArrayRegister, __ Ldr(w11, FieldMemOperand(kInterpreterBytecodeArrayRegister,
BytecodeArray::kFrameSizeOffset)); BytecodeArray::kFrameSizeOffset));
// Do a stack check to ensure we don't go over the limit. // Do a stack check to ensure we don't go over the limit.
Label ok;
__ Sub(x10, sp, Operand(x11)); __ Sub(x10, sp, Operand(x11));
{ {
UseScratchRegisterScope temps(masm); UseScratchRegisterScope temps(masm);
...@@ -1262,9 +1262,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1262,9 +1262,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
LoadRealStackLimit(masm, scratch); LoadRealStackLimit(masm, scratch);
__ Cmp(x10, scratch); __ Cmp(x10, scratch);
} }
__ B(hs, &ok); __ B(lo, &stack_overflow);
__ CallRuntime(Runtime::kThrowStackOverflow);
__ Bind(&ok);
// If ok, push undefined as the initial value for all register file entries. // If ok, push undefined as the initial value for all register file entries.
// Note: there should always be at least one stack slot for the return // Note: there should always be at least one stack slot for the return
...@@ -1335,6 +1333,10 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1335,6 +1333,10 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ bind(&compile_lazy); __ bind(&compile_lazy);
GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy);
__ Unreachable(); // Should not return. __ Unreachable(); // Should not return.
__ bind(&stack_overflow);
__ CallRuntime(Runtime::kThrowStackOverflow);
__ Unreachable(); // Should not return.
} }
static void Generate_InterpreterPushArgs(MacroAssembler* masm, static void Generate_InterpreterPushArgs(MacroAssembler* masm,
......
...@@ -1137,19 +1137,17 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1137,19 +1137,17 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ Push(rcx); __ Push(rcx);
// Allocate the local and temporary register file on the stack. // Allocate the local and temporary register file on the stack.
Label stack_overflow;
{ {
// Load frame size from the BytecodeArray object. // Load frame size from the BytecodeArray object.
__ movl(rcx, FieldOperand(kInterpreterBytecodeArrayRegister, __ movl(rcx, FieldOperand(kInterpreterBytecodeArrayRegister,
BytecodeArray::kFrameSizeOffset)); BytecodeArray::kFrameSizeOffset));
// Do a stack check to ensure we don't go over the limit. // Do a stack check to ensure we don't go over the limit.
Label ok;
__ movq(rax, rsp); __ movq(rax, rsp);
__ subq(rax, rcx); __ subq(rax, rcx);
__ cmpq(rax, RealStackLimitAsOperand(masm)); __ cmpq(rax, RealStackLimitAsOperand(masm));
__ j(above_equal, &ok, Label::kNear); __ j(below, &stack_overflow);
__ CallRuntime(Runtime::kThrowStackOverflow);
__ bind(&ok);
// If ok, push undefined as the initial value for all register file entries. // If ok, push undefined as the initial value for all register file entries.
Label loop_header; Label loop_header;
...@@ -1222,6 +1220,10 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ...@@ -1222,6 +1220,10 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ bind(&compile_lazy); __ bind(&compile_lazy);
GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy);
__ int3(); // Should not return. __ int3(); // Should not return.
__ bind(&stack_overflow);
__ CallRuntime(Runtime::kThrowStackOverflow);
__ int3(); // Should not return.
} }
static void Generate_InterpreterPushArgs(MacroAssembler* masm, static void Generate_InterpreterPushArgs(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