[wasm] Use a consistent limit for large frames

For large frames we are executing a special stack check that checks the
remaining stack space before allocating the new frame. Different
platforms used different limits for the frame size so far. Liftoff
already uses 4KB everywhere, hence use the same limit also for TurboFan.

Drive-by: Remove an outdated and misleading comment, and other minor
simplification.

R=ahaas@chromium.org

Bug: v8:12017
Change-Id: I6548b2293ec255349bf4e08c26fd05b7e0df0497
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3063501
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Georg Neis <neis@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#76034}
This commit is contained in:
Clemens Backes 2021-07-30 16:55:23 +02:00 committed by V8 LUCI CQ
parent a876146449
commit f7de8c8062
4 changed files with 18 additions and 16 deletions

View File

@ -3814,7 +3814,7 @@ void CodeGenerator::AssembleConstructFrame() {
if (required_slots > 0) { if (required_slots > 0) {
DCHECK(frame_access_state()->has_frame()); DCHECK(frame_access_state()->has_frame());
#if V8_ENABLE_WEBASSEMBLY #if V8_ENABLE_WEBASSEMBLY
if (info()->IsWasm() && required_slots > 128) { if (info()->IsWasm() && required_slots * kSystemPointerSize > 4 * KB) {
// For WebAssembly functions with big frames we have to do the stack // For WebAssembly functions with big frames we have to do the stack
// overflow check before we construct the frame. Otherwise we may not // overflow check before we construct the frame. Otherwise we may not
// have enough space on the stack to call the runtime for the stack // have enough space on the stack to call the runtime for the stack
@ -3824,7 +3824,7 @@ void CodeGenerator::AssembleConstructFrame() {
// If the frame is bigger than the stack, we throw the stack overflow // If the frame is bigger than the stack, we throw the stack overflow
// exception unconditionally. Thereby we can avoid the integer overflow // exception unconditionally. Thereby we can avoid the integer overflow
// check in the condition code. // check in the condition code.
if ((required_slots * kSystemPointerSize) < (FLAG_stack_size * 1024)) { if (required_slots * kSystemPointerSize < FLAG_stack_size * KB) {
UseScratchRegisterScope temps(tasm()); UseScratchRegisterScope temps(tasm());
Register scratch = temps.Acquire(); Register scratch = temps.Acquire();
__ ldr(scratch, FieldMemOperand( __ ldr(scratch, FieldMemOperand(
@ -3837,12 +3837,11 @@ void CodeGenerator::AssembleConstructFrame() {
} }
__ Call(wasm::WasmCode::kWasmStackOverflow, RelocInfo::WASM_STUB_CALL); __ Call(wasm::WasmCode::kWasmStackOverflow, RelocInfo::WASM_STUB_CALL);
// We come from WebAssembly, there are no references for the GC. // The call does not return, hence we can ignore any references and just
// define an empty safepoint.
ReferenceMap* reference_map = zone()->New<ReferenceMap>(zone()); ReferenceMap* reference_map = zone()->New<ReferenceMap>(zone());
RecordSafepoint(reference_map); RecordSafepoint(reference_map);
if (FLAG_debug_code) { if (FLAG_debug_code) __ stop();
__ stop();
}
__ bind(&done); __ bind(&done);
} }

View File

@ -3139,7 +3139,7 @@ void CodeGenerator::AssembleConstructFrame() {
} }
#if V8_ENABLE_WEBASSEMBLY #if V8_ENABLE_WEBASSEMBLY
if (info()->IsWasm() && required_slots > 128) { if (info()->IsWasm() && required_slots * kSystemPointerSize > 4 * KB) {
// For WebAssembly functions with big frames we have to do the stack // For WebAssembly functions with big frames we have to do the stack
// overflow check before we construct the frame. Otherwise we may not // overflow check before we construct the frame. Otherwise we may not
// have enough space on the stack to call the runtime for the stack // have enough space on the stack to call the runtime for the stack
@ -3148,7 +3148,7 @@ void CodeGenerator::AssembleConstructFrame() {
// If the frame is bigger than the stack, we throw the stack overflow // If the frame is bigger than the stack, we throw the stack overflow
// exception unconditionally. Thereby we can avoid the integer overflow // exception unconditionally. Thereby we can avoid the integer overflow
// check in the condition code. // check in the condition code.
if (required_slots * kSystemPointerSize < FLAG_stack_size * 1024) { if (required_slots * kSystemPointerSize < FLAG_stack_size * KB) {
UseScratchRegisterScope scope(tasm()); UseScratchRegisterScope scope(tasm());
Register scratch = scope.AcquireX(); Register scratch = scope.AcquireX();
__ Ldr(scratch, FieldMemOperand( __ Ldr(scratch, FieldMemOperand(
@ -3170,12 +3170,11 @@ void CodeGenerator::AssembleConstructFrame() {
} }
__ Call(wasm::WasmCode::kWasmStackOverflow, RelocInfo::WASM_STUB_CALL); __ Call(wasm::WasmCode::kWasmStackOverflow, RelocInfo::WASM_STUB_CALL);
// We come from WebAssembly, there are no references for the GC. // The call does not return, hence we can ignore any references and just
// define an empty safepoint.
ReferenceMap* reference_map = zone()->New<ReferenceMap>(zone()); ReferenceMap* reference_map = zone()->New<ReferenceMap>(zone());
RecordSafepoint(reference_map); RecordSafepoint(reference_map);
if (FLAG_debug_code) { if (FLAG_debug_code) __ Brk(0);
__ Brk(0);
}
__ Bind(&done); __ Bind(&done);
} }
#endif // V8_ENABLE_WEBASSEMBLY #endif // V8_ENABLE_WEBASSEMBLY

View File

@ -4537,7 +4537,7 @@ void CodeGenerator::AssembleConstructFrame() {
if (required_slots > 0) { if (required_slots > 0) {
DCHECK(frame_access_state()->has_frame()); DCHECK(frame_access_state()->has_frame());
#if V8_ENABLE_WEBASSEMBLY #if V8_ENABLE_WEBASSEMBLY
if (info()->IsWasm() && required_slots > 128) { if (info()->IsWasm() && required_slots * kSystemPointerSize > 4 * KB) {
// For WebAssembly functions with big frames we have to do the stack // For WebAssembly functions with big frames we have to do the stack
// overflow check before we construct the frame. Otherwise we may not // overflow check before we construct the frame. Otherwise we may not
// have enough space on the stack to call the runtime for the stack // have enough space on the stack to call the runtime for the stack
@ -4547,7 +4547,7 @@ void CodeGenerator::AssembleConstructFrame() {
// If the frame is bigger than the stack, we throw the stack overflow // If the frame is bigger than the stack, we throw the stack overflow
// exception unconditionally. Thereby we can avoid the integer overflow // exception unconditionally. Thereby we can avoid the integer overflow
// check in the condition code. // check in the condition code.
if (required_slots * kSystemPointerSize < FLAG_stack_size * 1024) { if (required_slots * kSystemPointerSize < FLAG_stack_size * KB) {
Register scratch = esi; Register scratch = esi;
__ push(scratch); __ push(scratch);
__ mov(scratch, __ mov(scratch,
@ -4562,6 +4562,8 @@ void CodeGenerator::AssembleConstructFrame() {
__ wasm_call(wasm::WasmCode::kWasmStackOverflow, __ wasm_call(wasm::WasmCode::kWasmStackOverflow,
RelocInfo::WASM_STUB_CALL); RelocInfo::WASM_STUB_CALL);
// The call does not return, hence we can ignore any references and just
// define an empty safepoint.
ReferenceMap* reference_map = zone()->New<ReferenceMap>(zone()); ReferenceMap* reference_map = zone()->New<ReferenceMap>(zone());
RecordSafepoint(reference_map); RecordSafepoint(reference_map);
__ AssertUnreachable(AbortReason::kUnexpectedReturnFromWasmTrap); __ AssertUnreachable(AbortReason::kUnexpectedReturnFromWasmTrap);

View File

@ -4732,7 +4732,7 @@ void CodeGenerator::AssembleConstructFrame() {
if (required_slots > 0) { if (required_slots > 0) {
DCHECK(frame_access_state()->has_frame()); DCHECK(frame_access_state()->has_frame());
#if V8_ENABLE_WEBASSEMBLY #if V8_ENABLE_WEBASSEMBLY
if (info()->IsWasm() && required_slots > 128) { if (info()->IsWasm() && required_slots * kSystemPointerSize > 4 * KB) {
// For WebAssembly functions with big frames we have to do the stack // For WebAssembly functions with big frames we have to do the stack
// overflow check before we construct the frame. Otherwise we may not // overflow check before we construct the frame. Otherwise we may not
// have enough space on the stack to call the runtime for the stack // have enough space on the stack to call the runtime for the stack
@ -4742,7 +4742,7 @@ void CodeGenerator::AssembleConstructFrame() {
// If the frame is bigger than the stack, we throw the stack overflow // If the frame is bigger than the stack, we throw the stack overflow
// exception unconditionally. Thereby we can avoid the integer overflow // exception unconditionally. Thereby we can avoid the integer overflow
// check in the condition code. // check in the condition code.
if (required_slots * kSystemPointerSize < FLAG_stack_size * 1024) { if (required_slots * kSystemPointerSize < FLAG_stack_size * KB) {
__ movq(kScratchRegister, __ movq(kScratchRegister,
FieldOperand(kWasmInstanceRegister, FieldOperand(kWasmInstanceRegister,
WasmInstanceObject::kRealStackLimitAddressOffset)); WasmInstanceObject::kRealStackLimitAddressOffset));
@ -4755,6 +4755,8 @@ void CodeGenerator::AssembleConstructFrame() {
__ near_call(wasm::WasmCode::kWasmStackOverflow, __ near_call(wasm::WasmCode::kWasmStackOverflow,
RelocInfo::WASM_STUB_CALL); RelocInfo::WASM_STUB_CALL);
// The call does not return, hence we can ignore any references and just
// define an empty safepoint.
ReferenceMap* reference_map = zone()->New<ReferenceMap>(zone()); ReferenceMap* reference_map = zone()->New<ReferenceMap>(zone());
RecordSafepoint(reference_map); RecordSafepoint(reference_map);
__ AssertUnreachable(AbortReason::kUnexpectedReturnFromWasmTrap); __ AssertUnreachable(AbortReason::kUnexpectedReturnFromWasmTrap);