Commit 63e46a69 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[Liftoff] Remove redundant stack_base field

This information is already stored in ControlBase::stack_depth.

R=titzer@chromium.org

Bug: v8:8423
Change-Id: Ie707878b5d7ee5180e44881086d05a590c0dea21
Reviewed-on: https://chromium-review.googlesource.com/c/1373786Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58199}
parent e5984c64
...@@ -268,13 +268,15 @@ class StackTransferRecipe { ...@@ -268,13 +268,15 @@ class StackTransferRecipe {
// TODO(clemensh): Don't copy the full parent state (this makes us N^2). // TODO(clemensh): Don't copy the full parent state (this makes us N^2).
void LiftoffAssembler::CacheState::InitMerge(const CacheState& source, void LiftoffAssembler::CacheState::InitMerge(const CacheState& source,
uint32_t num_locals, uint32_t num_locals,
uint32_t arity) { uint32_t arity,
uint32_t stack_depth) {
uint32_t stack_base = stack_depth + num_locals;
DCHECK(stack_state.empty()); DCHECK(stack_state.empty());
DCHECK_GE(source.stack_height(), stack_base); DCHECK_GE(source.stack_height(), stack_base);
stack_state.resize(stack_base + arity, VarState(kWasmStmt)); stack_state.resize(stack_base + arity, VarState(kWasmStmt));
// |------locals------|--(in between)--|--(discarded)--|----merge----| // |------locals------|---(in between)----|--(discarded)--|----merge----|
// <-- num_locals --> ^stack_base <-- arity --> // <-- num_locals --> <-- stack_depth -->^stack_base <-- arity -->
// First, initialize merge slots and locals. Keep them in the registers which // First, initialize merge slots and locals. Keep them in the registers which
// are being used in {source}, but avoid using a register multiple times. Use // are being used in {source}, but avoid using a register multiple times. Use
......
...@@ -121,8 +121,6 @@ class LiftoffAssembler : public TurboAssembler { ...@@ -121,8 +121,6 @@ class LiftoffAssembler : public TurboAssembler {
LiftoffRegList used_registers; LiftoffRegList used_registers;
uint32_t register_use_count[kAfterMaxLiftoffRegCode] = {0}; uint32_t register_use_count[kAfterMaxLiftoffRegCode] = {0};
LiftoffRegList last_spilled_regs; LiftoffRegList last_spilled_regs;
// TODO(clemensh): Remove stack_base; use ControlBase::stack_depth.
uint32_t stack_base = 0;
bool has_unused_register(RegClass rc, LiftoffRegList pinned = {}) const { bool has_unused_register(RegClass rc, LiftoffRegList pinned = {}) const {
if (kNeedI64RegPair && rc == kGpRegPair) { if (kNeedI64RegPair && rc == kGpRegPair) {
...@@ -232,7 +230,7 @@ class LiftoffAssembler : public TurboAssembler { ...@@ -232,7 +230,7 @@ class LiftoffAssembler : public TurboAssembler {
// TODO(clemensh): Don't copy the full parent state (this makes us N^2). // TODO(clemensh): Don't copy the full parent state (this makes us N^2).
void InitMerge(const CacheState& source, uint32_t num_locals, void InitMerge(const CacheState& source, uint32_t num_locals,
uint32_t arity); uint32_t arity, uint32_t stack_depth);
void Steal(CacheState& source); void Steal(CacheState& source);
......
...@@ -371,7 +371,6 @@ class LiftoffCompiler { ...@@ -371,7 +371,6 @@ class LiftoffCompiler {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
} }
block->label_state.stack_base = __ num_locals();
// The function-prologue stack check is associated with position 0, which // The function-prologue stack check is associated with position 0, which
// is never a position of any instruction in the function. // is never a position of any instruction in the function.
...@@ -446,13 +445,9 @@ class LiftoffCompiler { ...@@ -446,13 +445,9 @@ class LiftoffCompiler {
DEBUG_CODE_COMMENT(WasmOpcodes::OpcodeName(opcode)); DEBUG_CODE_COMMENT(WasmOpcodes::OpcodeName(opcode));
} }
void Block(FullDecoder* decoder, Control* block) { void Block(FullDecoder* decoder, Control* block) {}
block->label_state.stack_base = __ cache_state()->stack_height();
}
void Loop(FullDecoder* decoder, Control* loop) { void Loop(FullDecoder* decoder, Control* loop) {
loop->label_state.stack_base = __ cache_state()->stack_height();
// Before entering a loop, spill all locals to the stack, in order to free // Before entering a loop, spill all locals to the stack, in order to free
// the cache registers, and to avoid unnecessarily reloading stack values // the cache registers, and to avoid unnecessarily reloading stack values
// into registers at branches. // into registers at branches.
...@@ -489,7 +484,6 @@ class LiftoffCompiler { ...@@ -489,7 +484,6 @@ class LiftoffCompiler {
__ emit_cond_jump(kEqual, if_block->else_state->label.get(), kWasmI32, __ emit_cond_jump(kEqual, if_block->else_state->label.get(), kWasmI32,
value); value);
if_block->label_state.stack_base = __ cache_state()->stack_height();
// Store the state (after popping the value) for executing the else branch. // Store the state (after popping the value) for executing the else branch.
if_block->else_state->state.Split(*__ cache_state()); if_block->else_state->state.Split(*__ cache_state());
} }
...@@ -501,7 +495,8 @@ class LiftoffCompiler { ...@@ -501,7 +495,8 @@ class LiftoffCompiler {
// Init the merge point from the else state, then merge the if state into // Init the merge point from the else state, then merge the if state into
// that. // that.
DCHECK_EQ(0, c->end_merge.arity); DCHECK_EQ(0, c->end_merge.arity);
c->label_state.InitMerge(c->else_state->state, __ num_locals(), 0); c->label_state.InitMerge(c->else_state->state, __ num_locals(), 0,
c->stack_depth);
__ MergeFullStackWith(c->label_state); __ MergeFullStackWith(c->label_state);
} else { } else {
c->label_state.Split(*__ cache_state()); c->label_state.Split(*__ cache_state());
...@@ -1241,7 +1236,8 @@ class LiftoffCompiler { ...@@ -1241,7 +1236,8 @@ class LiftoffCompiler {
void BrImpl(Control* target) { void BrImpl(Control* target) {
if (!target->br_merge()->reached) { if (!target->br_merge()->reached) {
target->label_state.InitMerge(*__ cache_state(), __ num_locals(), target->label_state.InitMerge(*__ cache_state(), __ num_locals(),
target->br_merge()->arity); target->br_merge()->arity,
target->stack_depth);
} }
__ MergeStackWith(target->label_state, target->br_merge()->arity); __ MergeStackWith(target->label_state, target->br_merge()->arity);
__ jmp(target->label.get()); __ jmp(target->label.get());
...@@ -1336,7 +1332,7 @@ class LiftoffCompiler { ...@@ -1336,7 +1332,7 @@ class LiftoffCompiler {
if (c->reachable()) { if (c->reachable()) {
if (!c->end_merge.reached) { if (!c->end_merge.reached) {
c->label_state.InitMerge(*__ cache_state(), __ num_locals(), c->label_state.InitMerge(*__ cache_state(), __ num_locals(),
c->end_merge.arity); c->end_merge.arity, c->stack_depth);
} }
__ MergeFullStackWith(c->label_state); __ MergeFullStackWith(c->label_state);
__ emit_jump(c->label.get()); __ emit_jump(c->label.get());
......
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