Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Unified Diff: src/builtins/mips64/builtins-mips64.cc

Issue 2335513004: [Interpreter] Adds stackcheck in InterpreterPushArgsAndCall/Construct builtins. (Closed)
Patch Set: Addressed comments from Ross. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/builtins/mips/builtins-mips.cc ('k') | src/builtins/x64/builtins-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/mips64/builtins-mips64.cc
diff --git a/src/builtins/mips64/builtins-mips64.cc b/src/builtins/mips64/builtins-mips64.cc
index 818ae2b054a2ca21e7726e212ce45f7ca845d49a..00ecf7ea9f445a30b173764c248198b2428ca93d 100644
--- a/src/builtins/mips64/builtins-mips64.cc
+++ b/src/builtins/mips64/builtins-mips64.cc
@@ -1152,13 +1152,33 @@ void Builtins::Generate_InterpreterMarkBaselineOnReturn(MacroAssembler* masm) {
__ Jump(ra);
}
+static void Generate_StackOverflowCheck(MacroAssembler* masm, Register num_args,
+ Register scratch1, Register scratch2,
+ Label* stack_overflow) {
+ // Check the stack for overflow. We are not trying to catch
+ // interruptions (e.g. debug break and preemption) here, so the "real stack
+ // limit" is checked.
+ __ LoadRoot(scratch1, Heap::kRealStackLimitRootIndex);
+ // Make scratch1 the space we have left. The stack might already be overflowed
+ // here which will cause scratch1 to become negative.
+ __ dsubu(scratch1, sp, scratch1);
+ // Check if the arguments will overflow the stack.
+ __ dsll(scratch2, num_args, kPointerSizeLog2);
+ // Signed comparison.
+ __ Branch(stack_overflow, le, scratch1, Operand(scratch2));
+}
+
static void Generate_InterpreterPushArgs(MacroAssembler* masm,
Register num_args, Register index,
- Register last_addr, Register scratch) {
+ Register scratch, Register scratch2,
+ Label* stack_overflow) {
+ // Generate_StackOverflowCheck(masm, num_args, scratch, scratch2,
+ // stack_overflow);
+
// Find the address of the last argument.
- __ mov(last_addr, num_args);
- __ dsll(last_addr, last_addr, kPointerSizeLog2);
- __ Dsubu(last_addr, index, Operand(last_addr));
+ __ mov(scratch2, num_args);
+ __ dsll(scratch2, scratch2, kPointerSizeLog2);
+ __ Dsubu(scratch2, index, Operand(scratch2));
// Push the arguments.
Label loop_header, loop_check;
@@ -1168,7 +1188,7 @@ static void Generate_InterpreterPushArgs(MacroAssembler* masm,
__ Daddu(index, index, Operand(-kPointerSize));
__ push(scratch);
__ bind(&loop_check);
- __ Branch(&loop_header, gt, index, Operand(last_addr));
+ __ Branch(&loop_header, gt, index, Operand(scratch2));
}
// static
@@ -1182,11 +1202,12 @@ void Builtins::Generate_InterpreterPushArgsAndCallImpl(
// they are to be pushed onto the stack.
// -- a1 : the target to call (can be any Object).
// -----------------------------------
+ Label stack_overflow;
__ Daddu(a3, a0, Operand(1)); // Add one for receiver.
// This function modifies a2, t0 and a4.
- Generate_InterpreterPushArgs(masm, a3, a2, a4, t0);
+ Generate_InterpreterPushArgs(masm, a3, a2, a4, t0, &stack_overflow);
// Call the target.
if (function_type == CallableType::kJSFunction) {
@@ -1199,6 +1220,13 @@ void Builtins::Generate_InterpreterPushArgsAndCallImpl(
tail_call_mode),
RelocInfo::CODE_TARGET);
}
+
+ __ bind(&stack_overflow);
+ {
+ __ TailCallRuntime(Runtime::kThrowStackOverflow);
+ // Unreachable code.
+ __ break_(0xCC);
+ }
}
// static
@@ -1211,12 +1239,13 @@ void Builtins::Generate_InterpreterPushArgsAndConstructImpl(
// -- a2 : allocation site feedback if available, undefined otherwise.
// -- a4 : address of the first argument
// -----------------------------------
+ Label stack_overflow;
// Push a slot for the receiver.
__ push(zero_reg);
// This function modifies t0, a4 and a5.
- Generate_InterpreterPushArgs(masm, a0, a4, a5, t0);
+ Generate_InterpreterPushArgs(masm, a0, a4, a5, t0, &stack_overflow);
__ AssertUndefinedOrAllocationSite(a2, t0);
if (construct_type == CallableType::kJSFunction) {
@@ -1233,6 +1262,13 @@ void Builtins::Generate_InterpreterPushArgsAndConstructImpl(
// Call the constructor with a0, a1, and a3 unmodified.
__ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET);
}
+
+ __ bind(&stack_overflow);
+ {
+ __ TailCallRuntime(Runtime::kThrowStackOverflow);
+ // Unreachable code.
+ __ break_(0xCC);
+ }
}
// static
@@ -1246,17 +1282,25 @@ void Builtins::Generate_InterpreterPushArgsAndConstructArray(
// arguments should be consecutive above this, in the same order as
// they are to be pushed onto the stack.
// -----------------------------------
+ Label stack_overflow;
__ Daddu(a4, a0, Operand(1)); // Add one for receiver.
// This function modifies a3, a5 and a6.
- Generate_InterpreterPushArgs(masm, a4, a3, a5, a6);
+ Generate_InterpreterPushArgs(masm, a4, a3, a5, a6, &stack_overflow);
// ArrayConstructor stub expects constructor in a3. Set it here.
__ mov(a3, a1);
ArrayConstructorStub stub(masm->isolate());
__ TailCallStub(&stub);
+
+ __ bind(&stack_overflow);
+ {
+ __ TailCallRuntime(Runtime::kThrowStackOverflow);
+ // Unreachable code.
+ __ break_(0xCC);
+ }
}
void Builtins::Generate_InterpreterEnterBytecodeDispatch(MacroAssembler* masm) {
@@ -2156,27 +2200,6 @@ void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
}
}
-static void ArgumentAdaptorStackCheck(MacroAssembler* masm,
- Label* stack_overflow) {
- // ----------- S t a t e -------------
- // -- a0 : actual number of arguments
- // -- a1 : function (passed through to callee)
- // -- a2 : expected number of arguments
- // -- a3 : new target (passed through to callee)
- // -----------------------------------
- // Check the stack for overflow. We are not trying to catch
- // interruptions (e.g. debug break and preemption) here, so the "real stack
- // limit" is checked.
- __ LoadRoot(a5, Heap::kRealStackLimitRootIndex);
- // Make a5 the space we have left. The stack might already be overflowed
- // here which will cause a5 to become negative.
- __ dsubu(a5, sp, a5);
- // Check if the arguments will overflow the stack.
- __ dsll(at, a2, kPointerSizeLog2);
- // Signed comparison.
- __ Branch(stack_overflow, le, a5, Operand(at));
-}
-
static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
// __ sll(a0, a0, kSmiTagSize);
__ dsll32(a0, a0, 0);
@@ -2940,7 +2963,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
// a3: new target (passed through to callee)
__ bind(&enough);
EnterArgumentsAdaptorFrame(masm);
- ArgumentAdaptorStackCheck(masm, &stack_overflow);
+ Generate_StackOverflowCheck(masm, a2, a5, at, &stack_overflow);
// Calculate copy start address into a0 and copy end address into a4.
__ SmiScale(a0, a0, kPointerSizeLog2);
@@ -2971,7 +2994,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
{ // Too few parameters: Actual < expected.
__ bind(&too_few);
EnterArgumentsAdaptorFrame(masm);
- ArgumentAdaptorStackCheck(masm, &stack_overflow);
+ Generate_StackOverflowCheck(masm, a2, a5, at, &stack_overflow);
// Calculate copy start address into a0 and copy end address into a7.
// a0: actual number of arguments as a smi
« no previous file with comments | « src/builtins/mips/builtins-mips.cc ('k') | src/builtins/x64/builtins-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698