Commit c6dc8be7 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Rename "shrink_slots" to "required_slots" for clarity

Change-Id: Ia433525116637fdf3273919af31f2e6eee62bfd0
Reviewed-on: https://chromium-review.googlesource.com/c/1462002Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59495}
parent bfb2a104
...@@ -3049,8 +3049,8 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3049,8 +3049,8 @@ void CodeGenerator::AssembleConstructFrame() {
unwinding_info_writer_.MarkFrameConstructed(__ pc_offset()); unwinding_info_writer_.MarkFrameConstructed(__ pc_offset());
} }
int shrink_slots = frame()->GetTotalFrameSlotCount() - int required_slots = frame()->GetTotalFrameSlotCount() -
call_descriptor->CalculateFixedFrameSize(); call_descriptor->CalculateFixedFrameSize();
if (info()->is_osr()) { if (info()->is_osr()) {
// TurboFan OSR-compiled functions cannot be entered directly. // TurboFan OSR-compiled functions cannot be entered directly.
...@@ -3062,16 +3062,16 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3062,16 +3062,16 @@ void CodeGenerator::AssembleConstructFrame() {
// remaining stack slots. // remaining stack slots.
if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
osr_pc_offset_ = __ pc_offset(); osr_pc_offset_ = __ pc_offset();
shrink_slots -= osr_helper()->UnoptimizedFrameSlots(); required_slots -= osr_helper()->UnoptimizedFrameSlots();
ResetSpeculationPoison(); ResetSpeculationPoison();
} }
const RegList saves = call_descriptor->CalleeSavedRegisters(); const RegList saves = call_descriptor->CalleeSavedRegisters();
const RegList saves_fp = call_descriptor->CalleeSavedFPRegisters(); const RegList saves_fp = call_descriptor->CalleeSavedFPRegisters();
if (shrink_slots > 0) { if (required_slots > 0) {
DCHECK(frame_access_state()->has_frame()); DCHECK(frame_access_state()->has_frame());
if (info()->IsWasm() && shrink_slots > 128) { if (info()->IsWasm() && required_slots > 128) {
// 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
...@@ -3081,14 +3081,14 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3081,14 +3081,14 @@ 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 ((shrink_slots * kSystemPointerSize) < (FLAG_stack_size * 1024)) { if ((required_slots * kSystemPointerSize) < (FLAG_stack_size * 1024)) {
UseScratchRegisterScope temps(tasm()); UseScratchRegisterScope temps(tasm());
Register scratch = temps.Acquire(); Register scratch = temps.Acquire();
__ ldr(scratch, FieldMemOperand( __ ldr(scratch, FieldMemOperand(
kWasmInstanceRegister, kWasmInstanceRegister,
WasmInstanceObject::kRealStackLimitAddressOffset)); WasmInstanceObject::kRealStackLimitAddressOffset));
__ ldr(scratch, MemOperand(scratch)); __ ldr(scratch, MemOperand(scratch));
__ add(scratch, scratch, Operand(shrink_slots * kSystemPointerSize)); __ add(scratch, scratch, Operand(required_slots * kSystemPointerSize));
__ cmp(sp, scratch); __ cmp(sp, scratch);
__ b(cs, &done); __ b(cs, &done);
} }
...@@ -3109,11 +3109,11 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3109,11 +3109,11 @@ void CodeGenerator::AssembleConstructFrame() {
} }
// Skip callee-saved and return slots, which are pushed below. // Skip callee-saved and return slots, which are pushed below.
shrink_slots -= base::bits::CountPopulation(saves); required_slots -= base::bits::CountPopulation(saves);
shrink_slots -= frame()->GetReturnSlotCount(); required_slots -= frame()->GetReturnSlotCount();
shrink_slots -= 2 * base::bits::CountPopulation(saves_fp); required_slots -= 2 * base::bits::CountPopulation(saves_fp);
if (shrink_slots > 0) { if (required_slots > 0) {
__ sub(sp, sp, Operand(shrink_slots * kSystemPointerSize)); __ sub(sp, sp, Operand(required_slots * kSystemPointerSize));
} }
} }
......
...@@ -2396,8 +2396,8 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2396,8 +2396,8 @@ void CodeGenerator::AssembleConstructFrame() {
// The frame has been previously padded in CodeGenerator::FinishFrame(). // The frame has been previously padded in CodeGenerator::FinishFrame().
DCHECK_EQ(frame()->GetTotalFrameSlotCount() % 2, 0); DCHECK_EQ(frame()->GetTotalFrameSlotCount() % 2, 0);
int shrink_slots = frame()->GetTotalFrameSlotCount() - int required_slots = frame()->GetTotalFrameSlotCount() -
call_descriptor->CalculateFixedFrameSize(); call_descriptor->CalculateFixedFrameSize();
CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits, CPURegList saves = CPURegList(CPURegister::kRegister, kXRegSizeInBits,
call_descriptor->CalleeSavedRegisters()); call_descriptor->CalleeSavedRegisters());
...@@ -2428,11 +2428,11 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2428,11 +2428,11 @@ void CodeGenerator::AssembleConstructFrame() {
// to allocate the remaining stack slots. // to allocate the remaining stack slots.
if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
osr_pc_offset_ = __ pc_offset(); osr_pc_offset_ = __ pc_offset();
shrink_slots -= osr_helper()->UnoptimizedFrameSlots(); required_slots -= osr_helper()->UnoptimizedFrameSlots();
ResetSpeculationPoison(); ResetSpeculationPoison();
} }
if (info()->IsWasm() && shrink_slots > 128) { if (info()->IsWasm() && required_slots > 128) {
// 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
...@@ -2441,14 +2441,14 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2441,14 +2441,14 @@ 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 (shrink_slots * kSystemPointerSize < FLAG_stack_size * 1024) { if (required_slots * kSystemPointerSize < FLAG_stack_size * 1024) {
UseScratchRegisterScope scope(tasm()); UseScratchRegisterScope scope(tasm());
Register scratch = scope.AcquireX(); Register scratch = scope.AcquireX();
__ Ldr(scratch, FieldMemOperand( __ Ldr(scratch, FieldMemOperand(
kWasmInstanceRegister, kWasmInstanceRegister,
WasmInstanceObject::kRealStackLimitAddressOffset)); WasmInstanceObject::kRealStackLimitAddressOffset));
__ Ldr(scratch, MemOperand(scratch)); __ Ldr(scratch, MemOperand(scratch));
__ Add(scratch, scratch, shrink_slots * kSystemPointerSize); __ Add(scratch, scratch, required_slots * kSystemPointerSize);
__ Cmp(sp, scratch); __ Cmp(sp, scratch);
__ B(hs, &done); __ B(hs, &done);
} }
...@@ -2479,9 +2479,9 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2479,9 +2479,9 @@ void CodeGenerator::AssembleConstructFrame() {
} }
// Skip callee-saved slots, which are pushed below. // Skip callee-saved slots, which are pushed below.
shrink_slots -= saves.Count(); required_slots -= saves.Count();
shrink_slots -= saves_fp.Count(); required_slots -= saves_fp.Count();
shrink_slots -= returns; required_slots -= returns;
// Build remainder of frame, including accounting for and filling-in // Build remainder of frame, including accounting for and filling-in
// frame-specific header information, i.e. claiming the extra slot that // frame-specific header information, i.e. claiming the extra slot that
...@@ -2490,16 +2490,17 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2490,16 +2490,17 @@ void CodeGenerator::AssembleConstructFrame() {
switch (call_descriptor->kind()) { switch (call_descriptor->kind()) {
case CallDescriptor::kCallJSFunction: case CallDescriptor::kCallJSFunction:
if (call_descriptor->PushArgumentCount()) { if (call_descriptor->PushArgumentCount()) {
__ Claim(shrink_slots + 1); // Claim extra slot for argc. __ Claim(required_slots + 1); // Claim extra slot for argc.
__ Str(kJavaScriptCallArgCountRegister, __ Str(kJavaScriptCallArgCountRegister,
MemOperand(fp, OptimizedBuiltinFrameConstants::kArgCOffset)); MemOperand(fp, OptimizedBuiltinFrameConstants::kArgCOffset));
} else { } else {
__ Claim(shrink_slots); __ Claim(required_slots);
} }
break; break;
case CallDescriptor::kCallCodeObject: { case CallDescriptor::kCallCodeObject: {
UseScratchRegisterScope temps(tasm()); UseScratchRegisterScope temps(tasm());
__ Claim(shrink_slots + 1); // Claim extra slot for frame type marker. __ Claim(required_slots +
1); // Claim extra slot for frame type marker.
Register scratch = temps.AcquireX(); Register scratch = temps.AcquireX();
__ Mov(scratch, __ Mov(scratch,
StackFrame::TypeToMarker(info()->GetOutputStackFrameType())); StackFrame::TypeToMarker(info()->GetOutputStackFrameType()));
...@@ -2507,7 +2508,8 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2507,7 +2508,8 @@ void CodeGenerator::AssembleConstructFrame() {
} break; } break;
case CallDescriptor::kCallWasmFunction: { case CallDescriptor::kCallWasmFunction: {
UseScratchRegisterScope temps(tasm()); UseScratchRegisterScope temps(tasm());
__ Claim(shrink_slots + 2); // Claim extra slots for marker + instance. __ Claim(required_slots +
2); // Claim extra slots for marker + instance.
Register scratch = temps.AcquireX(); Register scratch = temps.AcquireX();
__ Mov(scratch, __ Mov(scratch,
StackFrame::TypeToMarker(info()->GetOutputStackFrameType())); StackFrame::TypeToMarker(info()->GetOutputStackFrameType()));
...@@ -2521,7 +2523,8 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2521,7 +2523,8 @@ void CodeGenerator::AssembleConstructFrame() {
FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue2Offset)); FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue2Offset));
__ ldr(kWasmInstanceRegister, __ ldr(kWasmInstanceRegister,
FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset)); FieldMemOperand(kWasmInstanceRegister, Tuple2::kValue1Offset));
__ Claim(shrink_slots + 2); // Claim extra slots for marker + instance. __ Claim(required_slots +
2); // Claim extra slots for marker + instance.
Register scratch = temps.AcquireX(); Register scratch = temps.AcquireX();
__ Mov(scratch, __ Mov(scratch,
StackFrame::TypeToMarker(info()->GetOutputStackFrameType())); StackFrame::TypeToMarker(info()->GetOutputStackFrameType()));
...@@ -2530,7 +2533,7 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2530,7 +2533,7 @@ void CodeGenerator::AssembleConstructFrame() {
MemOperand(fp, WasmCompiledFrameConstants::kWasmInstanceOffset)); MemOperand(fp, WasmCompiledFrameConstants::kWasmInstanceOffset));
} break; } break;
case CallDescriptor::kCallAddress: case CallDescriptor::kCallAddress:
__ Claim(shrink_slots); __ Claim(required_slots);
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
......
...@@ -4186,8 +4186,8 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -4186,8 +4186,8 @@ void CodeGenerator::AssembleConstructFrame() {
} }
} }
int shrink_slots = frame()->GetTotalFrameSlotCount() - int required_slots = frame()->GetTotalFrameSlotCount() -
call_descriptor->CalculateFixedFrameSize(); call_descriptor->CalculateFixedFrameSize();
if (info()->is_osr()) { if (info()->is_osr()) {
// TurboFan OSR-compiled functions cannot be entered directly. // TurboFan OSR-compiled functions cannot be entered directly.
...@@ -4199,13 +4199,13 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -4199,13 +4199,13 @@ void CodeGenerator::AssembleConstructFrame() {
// remaining stack slots. // remaining stack slots.
if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
osr_pc_offset_ = __ pc_offset(); osr_pc_offset_ = __ pc_offset();
shrink_slots -= osr_helper()->UnoptimizedFrameSlots(); required_slots -= osr_helper()->UnoptimizedFrameSlots();
} }
const RegList saves = call_descriptor->CalleeSavedRegisters(); const RegList saves = call_descriptor->CalleeSavedRegisters();
if (shrink_slots > 0) { if (required_slots > 0) {
DCHECK(frame_access_state()->has_frame()); DCHECK(frame_access_state()->has_frame());
if (info()->IsWasm() && shrink_slots > 128) { if (info()->IsWasm() && required_slots > 128) {
// 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
...@@ -4215,14 +4215,14 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -4215,14 +4215,14 @@ 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 (shrink_slots * kSystemPointerSize < FLAG_stack_size * 1024) { if (required_slots * kSystemPointerSize < FLAG_stack_size * 1024) {
Register scratch = esi; Register scratch = esi;
__ push(scratch); __ push(scratch);
__ mov(scratch, __ mov(scratch,
FieldOperand(kWasmInstanceRegister, FieldOperand(kWasmInstanceRegister,
WasmInstanceObject::kRealStackLimitAddressOffset)); WasmInstanceObject::kRealStackLimitAddressOffset));
__ mov(scratch, Operand(scratch, 0)); __ mov(scratch, Operand(scratch, 0));
__ add(scratch, Immediate(shrink_slots * kSystemPointerSize)); __ add(scratch, Immediate(required_slots * kSystemPointerSize));
__ cmp(esp, scratch); __ cmp(esp, scratch);
__ pop(scratch); __ pop(scratch);
__ j(above_equal, &done); __ j(above_equal, &done);
...@@ -4239,10 +4239,10 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -4239,10 +4239,10 @@ void CodeGenerator::AssembleConstructFrame() {
} }
// Skip callee-saved and return slots, which are created below. // Skip callee-saved and return slots, which are created below.
shrink_slots -= base::bits::CountPopulation(saves); required_slots -= base::bits::CountPopulation(saves);
shrink_slots -= frame()->GetReturnSlotCount(); required_slots -= frame()->GetReturnSlotCount();
if (shrink_slots > 0) { if (required_slots > 0) {
__ sub(esp, Immediate(shrink_slots * kSystemPointerSize)); __ sub(esp, Immediate(required_slots * kSystemPointerSize));
} }
} }
......
...@@ -3401,8 +3401,8 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3401,8 +3401,8 @@ void CodeGenerator::AssembleConstructFrame() {
} }
} }
int shrink_slots = frame()->GetTotalFrameSlotCount() - int required_slots = frame()->GetTotalFrameSlotCount() -
call_descriptor->CalculateFixedFrameSize(); call_descriptor->CalculateFixedFrameSize();
if (info()->is_osr()) { if (info()->is_osr()) {
// TurboFan OSR-compiled functions cannot be entered directly. // TurboFan OSR-compiled functions cannot be entered directly.
...@@ -3414,7 +3414,7 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3414,7 +3414,7 @@ void CodeGenerator::AssembleConstructFrame() {
// remaining stack slots. // remaining stack slots.
if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
osr_pc_offset_ = __ pc_offset(); osr_pc_offset_ = __ pc_offset();
shrink_slots -= osr_helper()->UnoptimizedFrameSlots(); required_slots -= osr_helper()->UnoptimizedFrameSlots();
ResetSpeculationPoison(); ResetSpeculationPoison();
} }
...@@ -3423,11 +3423,11 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3423,11 +3423,11 @@ void CodeGenerator::AssembleConstructFrame() {
const int returns = frame()->GetReturnSlotCount(); const int returns = frame()->GetReturnSlotCount();
// Skip callee-saved and return slots, which are pushed below. // Skip callee-saved and return slots, which are pushed below.
shrink_slots -= base::bits::CountPopulation(saves); required_slots -= base::bits::CountPopulation(saves);
shrink_slots -= 2 * base::bits::CountPopulation(saves_fpu); required_slots -= 2 * base::bits::CountPopulation(saves_fpu);
shrink_slots -= returns; required_slots -= returns;
if (shrink_slots > 0) { if (required_slots > 0) {
__ Subu(sp, sp, Operand(shrink_slots * kSystemPointerSize)); __ Subu(sp, sp, Operand(required_slots * kSystemPointerSize));
} }
// Save callee-saved FPU registers. // Save callee-saved FPU registers.
......
...@@ -3560,8 +3560,8 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3560,8 +3560,8 @@ void CodeGenerator::AssembleConstructFrame() {
} }
} }
int shrink_slots = frame()->GetTotalFrameSlotCount() - int required_slots = frame()->GetTotalFrameSlotCount() -
call_descriptor->CalculateFixedFrameSize(); call_descriptor->CalculateFixedFrameSize();
if (info()->is_osr()) { if (info()->is_osr()) {
// TurboFan OSR-compiled functions cannot be entered directly. // TurboFan OSR-compiled functions cannot be entered directly.
...@@ -3573,7 +3573,7 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3573,7 +3573,7 @@ void CodeGenerator::AssembleConstructFrame() {
// remaining stack slots. // remaining stack slots.
if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
osr_pc_offset_ = __ pc_offset(); osr_pc_offset_ = __ pc_offset();
shrink_slots -= osr_helper()->UnoptimizedFrameSlots(); required_slots -= osr_helper()->UnoptimizedFrameSlots();
ResetSpeculationPoison(); ResetSpeculationPoison();
} }
...@@ -3582,11 +3582,11 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3582,11 +3582,11 @@ void CodeGenerator::AssembleConstructFrame() {
const int returns = frame()->GetReturnSlotCount(); const int returns = frame()->GetReturnSlotCount();
// Skip callee-saved and return slots, which are pushed below. // Skip callee-saved and return slots, which are pushed below.
shrink_slots -= base::bits::CountPopulation(saves); required_slots -= base::bits::CountPopulation(saves);
shrink_slots -= base::bits::CountPopulation(saves_fpu); required_slots -= base::bits::CountPopulation(saves_fpu);
shrink_slots -= returns; required_slots -= returns;
if (shrink_slots > 0) { if (required_slots > 0) {
__ Dsubu(sp, sp, Operand(shrink_slots * kSystemPointerSize)); __ Dsubu(sp, sp, Operand(required_slots * kSystemPointerSize));
} }
if (saves_fpu != 0) { if (saves_fpu != 0) {
......
...@@ -2323,8 +2323,8 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2323,8 +2323,8 @@ void CodeGenerator::AssembleConstructFrame() {
} }
} }
int shrink_slots = frame()->GetTotalFrameSlotCount() - int required_slots = frame()->GetTotalFrameSlotCount() -
call_descriptor->CalculateFixedFrameSize(); call_descriptor->CalculateFixedFrameSize();
if (info()->is_osr()) { if (info()->is_osr()) {
// TurboFan OSR-compiled functions cannot be entered directly. // TurboFan OSR-compiled functions cannot be entered directly.
__ Abort(AbortReason::kShouldNotDirectlyEnterOsrFunction); __ Abort(AbortReason::kShouldNotDirectlyEnterOsrFunction);
...@@ -2335,7 +2335,7 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2335,7 +2335,7 @@ void CodeGenerator::AssembleConstructFrame() {
// remaining stack slots. // remaining stack slots.
if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
osr_pc_offset_ = __ pc_offset(); osr_pc_offset_ = __ pc_offset();
shrink_slots -= osr_helper()->UnoptimizedFrameSlots(); required_slots -= osr_helper()->UnoptimizedFrameSlots();
ResetSpeculationPoison(); ResetSpeculationPoison();
} }
...@@ -2345,8 +2345,8 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2345,8 +2345,8 @@ void CodeGenerator::AssembleConstructFrame() {
~kConstantPoolRegister.bit() ~kConstantPoolRegister.bit()
: call_descriptor->CalleeSavedRegisters(); : call_descriptor->CalleeSavedRegisters();
if (shrink_slots > 0) { if (required_slots > 0) {
if (info()->IsWasm() && shrink_slots > 128) { if (info()->IsWasm() && required_slots > 128) {
// 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
...@@ -2356,14 +2356,14 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2356,14 +2356,14 @@ 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 ((shrink_slots * kSystemPointerSize) < (FLAG_stack_size * 1024)) { if ((required_slots * kSystemPointerSize) < (FLAG_stack_size * 1024)) {
Register scratch = ip; Register scratch = ip;
__ LoadP( __ LoadP(
scratch, scratch,
FieldMemOperand(kWasmInstanceRegister, FieldMemOperand(kWasmInstanceRegister,
WasmInstanceObject::kRealStackLimitAddressOffset)); WasmInstanceObject::kRealStackLimitAddressOffset));
__ LoadP(scratch, MemOperand(scratch), r0); __ LoadP(scratch, MemOperand(scratch), r0);
__ Add(scratch, scratch, shrink_slots * kSystemPointerSize, r0); __ Add(scratch, scratch, required_slots * kSystemPointerSize, r0);
__ cmpl(sp, scratch); __ cmpl(sp, scratch);
__ bge(&done); __ bge(&done);
} }
...@@ -2386,11 +2386,11 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -2386,11 +2386,11 @@ void CodeGenerator::AssembleConstructFrame() {
} }
// Skip callee-saved and return slots, which are pushed below. // Skip callee-saved and return slots, which are pushed below.
shrink_slots -= base::bits::CountPopulation(saves); required_slots -= base::bits::CountPopulation(saves);
shrink_slots -= frame()->GetReturnSlotCount(); required_slots -= frame()->GetReturnSlotCount();
shrink_slots -= (kDoubleSize / kSystemPointerSize) * required_slots -= (kDoubleSize / kSystemPointerSize) *
base::bits::CountPopulation(saves_fp); base::bits::CountPopulation(saves_fp);
__ Add(sp, sp, -shrink_slots * kSystemPointerSize, r0); __ Add(sp, sp, -required_slots * kSystemPointerSize, r0);
} }
// Save callee-saved Double registers. // Save callee-saved Double registers.
......
...@@ -3024,8 +3024,8 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3024,8 +3024,8 @@ void CodeGenerator::AssembleConstructFrame() {
} }
} }
int shrink_slots = frame()->GetTotalFrameSlotCount() - int required_slots = frame()->GetTotalFrameSlotCount() -
call_descriptor->CalculateFixedFrameSize(); call_descriptor->CalculateFixedFrameSize();
if (info()->is_osr()) { if (info()->is_osr()) {
// TurboFan OSR-compiled functions cannot be entered directly. // TurboFan OSR-compiled functions cannot be entered directly.
__ Abort(AbortReason::kShouldNotDirectlyEnterOsrFunction); __ Abort(AbortReason::kShouldNotDirectlyEnterOsrFunction);
...@@ -3036,15 +3036,15 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3036,15 +3036,15 @@ void CodeGenerator::AssembleConstructFrame() {
// remaining stack slots. // remaining stack slots.
if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
osr_pc_offset_ = __ pc_offset(); osr_pc_offset_ = __ pc_offset();
shrink_slots -= osr_helper()->UnoptimizedFrameSlots(); required_slots -= osr_helper()->UnoptimizedFrameSlots();
ResetSpeculationPoison(); ResetSpeculationPoison();
} }
const RegList saves_fp = call_descriptor->CalleeSavedFPRegisters(); const RegList saves_fp = call_descriptor->CalleeSavedFPRegisters();
const RegList saves = call_descriptor->CalleeSavedRegisters(); const RegList saves = call_descriptor->CalleeSavedRegisters();
if (shrink_slots > 0) { if (required_slots > 0) {
if (info()->IsWasm() && shrink_slots > 128) { if (info()->IsWasm() && required_slots > 128) {
// 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
...@@ -3054,14 +3054,14 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3054,14 +3054,14 @@ 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 ((shrink_slots * kSystemPointerSize) < (FLAG_stack_size * 1024)) { if ((required_slots * kSystemPointerSize) < (FLAG_stack_size * 1024)) {
Register scratch = r1; Register scratch = r1;
__ LoadP( __ LoadP(
scratch, scratch,
FieldMemOperand(kWasmInstanceRegister, FieldMemOperand(kWasmInstanceRegister,
WasmInstanceObject::kRealStackLimitAddressOffset)); WasmInstanceObject::kRealStackLimitAddressOffset));
__ LoadP(scratch, MemOperand(scratch)); __ LoadP(scratch, MemOperand(scratch));
__ AddP(scratch, scratch, Operand(shrink_slots * kSystemPointerSize)); __ AddP(scratch, scratch, Operand(required_slots * kSystemPointerSize));
__ CmpLogicalP(sp, scratch); __ CmpLogicalP(sp, scratch);
__ bge(&done); __ bge(&done);
} }
...@@ -3082,11 +3082,11 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3082,11 +3082,11 @@ void CodeGenerator::AssembleConstructFrame() {
} }
// Skip callee-saved and return slots, which are pushed below. // Skip callee-saved and return slots, which are pushed below.
shrink_slots -= base::bits::CountPopulation(saves); required_slots -= base::bits::CountPopulation(saves);
shrink_slots -= frame()->GetReturnSlotCount(); required_slots -= frame()->GetReturnSlotCount();
shrink_slots -= (kDoubleSize / kSystemPointerSize) * required_slots -= (kDoubleSize / kSystemPointerSize) *
base::bits::CountPopulation(saves_fp); base::bits::CountPopulation(saves_fp);
__ lay(sp, MemOperand(sp, -shrink_slots * kSystemPointerSize)); __ lay(sp, MemOperand(sp, -required_slots * kSystemPointerSize));
} }
// Save callee-saved Double registers. // Save callee-saved Double registers.
......
...@@ -3678,8 +3678,8 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3678,8 +3678,8 @@ void CodeGenerator::AssembleConstructFrame() {
unwinding_info_writer_.MarkFrameConstructed(pc_base); unwinding_info_writer_.MarkFrameConstructed(pc_base);
} }
int shrink_slots = frame()->GetTotalFrameSlotCount() - int required_slots = frame()->GetTotalFrameSlotCount() -
call_descriptor->CalculateFixedFrameSize(); call_descriptor->CalculateFixedFrameSize();
if (info()->is_osr()) { if (info()->is_osr()) {
// TurboFan OSR-compiled functions cannot be entered directly. // TurboFan OSR-compiled functions cannot be entered directly.
...@@ -3691,16 +3691,16 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3691,16 +3691,16 @@ void CodeGenerator::AssembleConstructFrame() {
// remaining stack slots. // remaining stack slots.
if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --"); if (FLAG_code_comments) __ RecordComment("-- OSR entrypoint --");
osr_pc_offset_ = __ pc_offset(); osr_pc_offset_ = __ pc_offset();
shrink_slots -= static_cast<int>(osr_helper()->UnoptimizedFrameSlots()); required_slots -= static_cast<int>(osr_helper()->UnoptimizedFrameSlots());
ResetSpeculationPoison(); ResetSpeculationPoison();
} }
const RegList saves = call_descriptor->CalleeSavedRegisters(); const RegList saves = call_descriptor->CalleeSavedRegisters();
const RegList saves_fp = call_descriptor->CalleeSavedFPRegisters(); const RegList saves_fp = call_descriptor->CalleeSavedFPRegisters();
if (shrink_slots > 0) { if (required_slots > 0) {
DCHECK(frame_access_state()->has_frame()); DCHECK(frame_access_state()->has_frame());
if (info()->IsWasm() && shrink_slots > 128) { if (info()->IsWasm() && required_slots > 128) {
// 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
...@@ -3710,12 +3710,13 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3710,12 +3710,13 @@ 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 (shrink_slots * kSystemPointerSize < FLAG_stack_size * 1024) { if (required_slots * kSystemPointerSize < FLAG_stack_size * 1024) {
__ movq(kScratchRegister, __ movq(kScratchRegister,
FieldOperand(kWasmInstanceRegister, FieldOperand(kWasmInstanceRegister,
WasmInstanceObject::kRealStackLimitAddressOffset)); WasmInstanceObject::kRealStackLimitAddressOffset));
__ movq(kScratchRegister, Operand(kScratchRegister, 0)); __ movq(kScratchRegister, Operand(kScratchRegister, 0));
__ addq(kScratchRegister, Immediate(shrink_slots * kSystemPointerSize)); __ addq(kScratchRegister,
Immediate(required_slots * kSystemPointerSize));
__ cmpq(rsp, kScratchRegister); __ cmpq(rsp, kScratchRegister);
__ j(above_equal, &done); __ j(above_equal, &done);
} }
...@@ -3732,12 +3733,12 @@ void CodeGenerator::AssembleConstructFrame() { ...@@ -3732,12 +3733,12 @@ void CodeGenerator::AssembleConstructFrame() {
} }
// Skip callee-saved and return slots, which are created below. // Skip callee-saved and return slots, which are created below.
shrink_slots -= base::bits::CountPopulation(saves); required_slots -= base::bits::CountPopulation(saves);
shrink_slots -= base::bits::CountPopulation(saves_fp) * required_slots -= base::bits::CountPopulation(saves_fp) *
(kQuadWordSize / kSystemPointerSize); (kQuadWordSize / kSystemPointerSize);
shrink_slots -= frame()->GetReturnSlotCount(); required_slots -= frame()->GetReturnSlotCount();
if (shrink_slots > 0) { if (required_slots > 0) {
__ subq(rsp, Immediate(shrink_slots * kSystemPointerSize)); __ subq(rsp, Immediate(required_slots * kSystemPointerSize));
} }
} }
......
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