Commit d7d01a9c authored by Leszek Swirski's avatar Leszek Swirski Committed by V8 LUCI CQ

[maglev] Fix spill slots for InitialValue

InitialValue needs to have a spill slot (e.g. for deopts) but shouldn't
emit an actual spill (since they're already on stack).

Drive-by, fix printing of Checkpoint and CheckMaps parameters.

Bug: v8:7700
Change-Id: I3c1acfce6638b1ad604f7c7a1938694814c326ee
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3497371
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79320}
parent 22dbf686
......@@ -118,12 +118,18 @@ class MaglevCodeGeneratingNodeProcessor {
if (std::is_base_of<ValueNode, NodeT>::value) {
ValueNode* value_node = node->template Cast<ValueNode>();
if (value_node->is_spilled()) {
if (FLAG_code_comments) __ RecordComment("-- Spill:");
compiler::AllocatedOperand source =
compiler::AllocatedOperand::cast(value_node->result().operand());
// We shouldn't spill nodes which already output to the stack.
DCHECK(!source.IsStackSlot());
__ movq(GetStackSlot(value_node->spill_slot()), ToRegister(source));
if (!source.IsStackSlot()) {
if (FLAG_code_comments) __ RecordComment("-- Spill:");
DCHECK(!source.IsStackSlot());
__ movq(GetStackSlot(value_node->spill_slot()), ToRegister(source));
} else {
// Otherwise, the result source stack slot should be equal to the
// spill slot.
DCHECK_EQ(source.index(), value_node->spill_slot().index());
}
}
}
}
......
......@@ -258,12 +258,13 @@ void EmitDeopt(MaglevCodeGenState* code_gen_state, Node* node,
for (int i = 0; i < compilation_unit->register_count(); ++i) {
ValueNode* node = checkpoint_state->get(interpreter::Register(i));
if (node == nullptr) continue;
__ Push(GetStackSlot(node->spill_slot()));
__ Push(ToMemOperand(node->spill_slot()));
num_saved_slots++;
}
if (checkpoint_state->accumulator()) {
ValueNode* accumulator = checkpoint_state->accumulator();
if (accumulator) {
__ movq(kInterpreterAccumulatorRegister,
GetStackSlot(checkpoint_state->accumulator()->spill_slot()));
ToMemOperand(accumulator->spill_slot()));
}
__ RecordComment("Load registers from extra pushed slots");
......@@ -387,7 +388,7 @@ void Checkpoint::GenerateCode(MaglevCodeGenState* code_gen_state,
const ProcessingState& state) {}
void Checkpoint::PrintParams(std::ostream& os,
MaglevGraphLabeller* graph_labeller) const {
os << "(" << accumulator() << ")";
os << "(" << PrintNodeLabel(graph_labeller, accumulator()) << ")";
}
void SoftDeopt::AllocateVreg(MaglevVregAllocationState* vreg_state,
......@@ -551,7 +552,7 @@ void CheckMaps::GenerateCode(MaglevCodeGenState* code_gen_state,
}
void CheckMaps::PrintParams(std::ostream& os,
MaglevGraphLabeller* graph_labeller) const {
os << "(" << map() << ")";
os << "(" << *map().object() << ")";
}
void LoadField::AllocateVreg(MaglevVregAllocationState* vreg_state,
......
......@@ -374,10 +374,12 @@ void StraightForwardRegisterAllocator::AllocateNodeResult(ValueNode* node) {
DCHECK(node->Is<InitialValue>());
DCHECK_LT(operand.fixed_slot_index(), 0);
// Set the stack slot to exactly where the value is.
node->result().SetAllocated(compiler::AllocatedOperand::STACK_SLOT,
MachineRepresentation::kTagged,
operand.fixed_slot_index());
info->stack_slot = node->result().operand();
compiler::AllocatedOperand location(compiler::AllocatedOperand::STACK_SLOT,
MachineRepresentation::kTagged,
operand.fixed_slot_index());
node->result().SetAllocated(location);
node->Spill(location);
info->stack_slot = location;
return;
}
......
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