diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc index f63e05f2cf..c29c65662b 100644 --- a/src/arm/builtins-arm.cc +++ b/src/arm/builtins-arm.cc @@ -768,7 +768,7 @@ static void Generate_CheckStackOverflow(MacroAssembler* masm, __ SmiTag(argc); } __ Push(r1, argc); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&okay); } @@ -920,7 +920,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { __ LoadRoot(r2, Heap::kRealStackLimitRootIndex); __ cmp(r9, Operand(r2)); __ b(hs, &ok); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&ok); // If ok, push undefined as the initial value for all register file entries. @@ -1794,7 +1794,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { { FrameScope frame(masm, StackFrame::MANUAL); EnterArgumentsAdaptorFrame(masm); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bkpt(0); } } diff --git a/src/arm64/builtins-arm64.cc b/src/arm64/builtins-arm64.cc index 8297fc3e2b..b2f1b2a036 100644 --- a/src/arm64/builtins-arm64.cc +++ b/src/arm64/builtins-arm64.cc @@ -780,7 +780,7 @@ static void Generate_CheckStackOverflow(MacroAssembler* masm, __ SmiTag(argc); } __ Push(function, argc); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); // We should never return from the APPLY_OVERFLOW builtin. if (__ emit_debug_code()) { __ Unreachable(); @@ -945,7 +945,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { __ Sub(x10, jssp, Operand(x11)); __ CompareRoot(x10, Heap::kRealStackLimitRootIndex); __ B(hs, &ok); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ Bind(&ok); // If ok, push undefined as the initial value for all register file entries. @@ -1863,7 +1863,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { { FrameScope frame(masm, StackFrame::MANUAL); EnterArgumentsAdaptorFrame(masm); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ Unreachable(); } } diff --git a/src/contexts.h b/src/contexts.h index 01ce999ef0..d56224046a 100644 --- a/src/contexts.h +++ b/src/contexts.h @@ -101,7 +101,6 @@ enum BindingFlags { reflect_apply_prepare_builtin) \ V(REFLECT_CONSTRUCT_PREPARE_BUILTIN_INDEX, JSFunction, \ reflect_construct_prepare_builtin) \ - V(STACK_OVERFLOW_BUILTIN_INDEX, JSFunction, stack_overflow_builtin) \ V(STRING_ADD_LEFT_BUILTIN_INDEX, JSFunction, string_add_left_builtin) \ V(STRING_ADD_RIGHT_BUILTIN_INDEX, JSFunction, string_add_right_builtin) diff --git a/src/full-codegen/arm/full-codegen-arm.cc b/src/full-codegen/arm/full-codegen-arm.cc index 7c7ec9f1b4..f507cb1880 100644 --- a/src/full-codegen/arm/full-codegen-arm.cc +++ b/src/full-codegen/arm/full-codegen-arm.cc @@ -155,7 +155,7 @@ void FullCodeGenerator::Generate() { __ LoadRoot(r2, Heap::kRealStackLimitRootIndex); __ cmp(r9, Operand(r2)); __ b(hs, &ok); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&ok); } __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); diff --git a/src/full-codegen/arm64/full-codegen-arm64.cc b/src/full-codegen/arm64/full-codegen-arm64.cc index bcae5563e5..9ad8e10b5f 100644 --- a/src/full-codegen/arm64/full-codegen-arm64.cc +++ b/src/full-codegen/arm64/full-codegen-arm64.cc @@ -159,7 +159,7 @@ void FullCodeGenerator::Generate() { __ Sub(x10, jssp, locals_count * kPointerSize); __ CompareRoot(x10, Heap::kRealStackLimitRootIndex); __ B(hs, &ok); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ Bind(&ok); } __ LoadRoot(x10, Heap::kUndefinedValueRootIndex); diff --git a/src/full-codegen/ia32/full-codegen-ia32.cc b/src/full-codegen/ia32/full-codegen-ia32.cc index 08a5a6277a..3c18ac9066 100644 --- a/src/full-codegen/ia32/full-codegen-ia32.cc +++ b/src/full-codegen/ia32/full-codegen-ia32.cc @@ -150,7 +150,7 @@ void FullCodeGenerator::Generate() { ExternalReference::address_of_real_stack_limit(isolate()); __ cmp(ecx, Operand::StaticVariable(stack_limit)); __ j(above_equal, &ok, Label::kNear); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&ok); } __ mov(eax, Immediate(isolate()->factory()->undefined_value())); diff --git a/src/full-codegen/mips/full-codegen-mips.cc b/src/full-codegen/mips/full-codegen-mips.cc index 2f35ef5a30..2e3cb94f71 100644 --- a/src/full-codegen/mips/full-codegen-mips.cc +++ b/src/full-codegen/mips/full-codegen-mips.cc @@ -162,7 +162,7 @@ void FullCodeGenerator::Generate() { __ Subu(t5, sp, Operand(locals_count * kPointerSize)); __ LoadRoot(a2, Heap::kRealStackLimitRootIndex); __ Branch(&ok, hs, t5, Operand(a2)); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&ok); } __ LoadRoot(t5, Heap::kUndefinedValueRootIndex); diff --git a/src/full-codegen/mips64/full-codegen-mips64.cc b/src/full-codegen/mips64/full-codegen-mips64.cc index bbc73d4496..6900a94645 100644 --- a/src/full-codegen/mips64/full-codegen-mips64.cc +++ b/src/full-codegen/mips64/full-codegen-mips64.cc @@ -159,7 +159,7 @@ void FullCodeGenerator::Generate() { __ Dsubu(t1, sp, Operand(locals_count * kPointerSize)); __ LoadRoot(a2, Heap::kRealStackLimitRootIndex); __ Branch(&ok, hs, t1, Operand(a2)); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&ok); } __ LoadRoot(t1, Heap::kUndefinedValueRootIndex); diff --git a/src/full-codegen/x64/full-codegen-x64.cc b/src/full-codegen/x64/full-codegen-x64.cc index a4724567ff..3ba34645ea 100644 --- a/src/full-codegen/x64/full-codegen-x64.cc +++ b/src/full-codegen/x64/full-codegen-x64.cc @@ -147,7 +147,7 @@ void FullCodeGenerator::Generate() { __ subp(rcx, Immediate(locals_count * kPointerSize)); __ CompareRoot(rcx, Heap::kRealStackLimitRootIndex); __ j(above_equal, &ok, Label::kNear); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&ok); } __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex); diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc index 368b649a69..6b32d9d2c3 100644 --- a/src/ia32/builtins-ia32.cc +++ b/src/ia32/builtins-ia32.cc @@ -522,7 +522,7 @@ static void Generate_CheckStackOverflow(MacroAssembler* masm, __ SmiTag(eax); } __ push(eax); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&okay); } @@ -660,7 +660,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { ExternalReference::address_of_real_stack_limit(masm->isolate()); __ cmp(ecx, Operand::StaticVariable(stack_limit)); __ j(above_equal, &ok); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&ok); // If ok, push undefined as the initial value for all register file entries. @@ -1699,7 +1699,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { { FrameScope frame(masm, StackFrame::MANUAL); EnterArgumentsAdaptorFrame(masm); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ int3(); } } diff --git a/src/mips/builtins-mips.cc b/src/mips/builtins-mips.cc index 6e51b0764e..558c0757e1 100644 --- a/src/mips/builtins-mips.cc +++ b/src/mips/builtins-mips.cc @@ -762,7 +762,7 @@ static void Generate_CheckStackOverflow(MacroAssembler* masm, __ SmiTag(argc); } __ Push(a1, argc); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&okay); } @@ -911,7 +911,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { __ Subu(t1, sp, Operand(t0)); __ LoadRoot(a2, Heap::kRealStackLimitRootIndex); __ Branch(&ok, hs, t1, Operand(a2)); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&ok); // If ok, push undefined as the initial value for all register file entries. @@ -1811,7 +1811,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { { FrameScope frame(masm, StackFrame::MANUAL); EnterArgumentsAdaptorFrame(masm); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ break_(0xCC); } } diff --git a/src/mips64/builtins-mips64.cc b/src/mips64/builtins-mips64.cc index 655d5904d0..ceb3bcd66f 100644 --- a/src/mips64/builtins-mips64.cc +++ b/src/mips64/builtins-mips64.cc @@ -762,7 +762,7 @@ static void Generate_CheckStackOverflow(MacroAssembler* masm, __ SmiTag(argc); } __ Push(a1, argc); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&okay); } @@ -909,7 +909,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { __ Dsubu(a5, sp, Operand(a4)); __ LoadRoot(a2, Heap::kRealStackLimitRootIndex); __ Branch(&ok, hs, a5, Operand(a2)); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&ok); // If ok, push undefined as the initial value for all register file entries. @@ -1808,7 +1808,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { { FrameScope frame(masm, StackFrame::MANUAL); EnterArgumentsAdaptorFrame(masm); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ break_(0xCC); } } diff --git a/src/runtime.js b/src/runtime.js index 749feb68a8..11f0ab2ea1 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -320,11 +320,6 @@ function CONCAT_ITERABLE_TO_ARRAY(iterable) { }; -function STACK_OVERFLOW(length) { - throw %make_range_error(kStackOverflow); -} - - /* ------------------------------------- - - - C o n v e r s i o n s - - - ------------------------------------- @@ -543,7 +538,6 @@ $toString = ToString; "equals_builtin", EQUALS, "reflect_apply_prepare_builtin", REFLECT_APPLY_PREPARE, "reflect_construct_prepare_builtin", REFLECT_CONSTRUCT_PREPARE, - "stack_overflow_builtin", STACK_OVERFLOW, "string_add_left_builtin", STRING_ADD_LEFT, "string_add_right_builtin", STRING_ADD_RIGHT, ]); diff --git a/src/runtime/runtime-internal.cc b/src/runtime/runtime-internal.cc index 0127f2381e..18b9481afc 100644 --- a/src/runtime/runtime-internal.cc +++ b/src/runtime/runtime-internal.cc @@ -88,6 +88,13 @@ RUNTIME_FUNCTION(Runtime_ReThrow) { } +RUNTIME_FUNCTION(Runtime_ThrowStackOverflow) { + SealHandleScope shs(isolate); + DCHECK_EQ(0, args.length()); + return isolate->StackOverflow(); +} + + RUNTIME_FUNCTION(Runtime_UnwindAndFindExceptionHandler) { SealHandleScope shs(isolate); DCHECK(args.length() == 0); diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index e4893c0dff..3d1078588a 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -311,6 +311,7 @@ namespace internal { F(NewSyntaxError, 2, 1) \ F(NewReferenceError, 2, 1) \ F(ThrowIteratorResultNotAnObject, 1, 1) \ + F(ThrowStackOverflow, 0, 1) \ F(ThrowStrongModeImplicitConversion, 0, 1) \ F(PromiseRejectEvent, 3, 1) \ F(PromiseRevokeReject, 1, 1) \ diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc index 9012cab3bb..685701ef74 100644 --- a/src/x64/builtins-x64.cc +++ b/src/x64/builtins-x64.cc @@ -525,7 +525,7 @@ static void Generate_CheckStackOverflow(MacroAssembler* masm, __ Integer32ToSmi(rax, rax); } __ Push(rax); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&okay); } @@ -718,7 +718,7 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { __ subp(rdx, rcx); __ CompareRoot(rdx, Heap::kRealStackLimitRootIndex); __ j(above_equal, &ok, Label::kNear); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ bind(&ok); // If ok, push undefined as the initial value for all register file entries. @@ -1619,7 +1619,7 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { { FrameScope frame(masm, StackFrame::MANUAL); EnterArgumentsAdaptorFrame(masm); - __ InvokeBuiltin(Context::STACK_OVERFLOW_BUILTIN_INDEX, CALL_FUNCTION); + __ CallRuntime(Runtime::kThrowStackOverflow, 0); __ int3(); } }