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

[maglev] Consistently increment input_location for lazy deopt

The DeepForEachInput helper was not incrementing the input_location
index in the IsResultRegister case, while other paths (graph printing,
code gen) were. Change these to consistently only increment the index
when the input is used (i.e. match DeepForEachInput).

Bug: v8:7700
Change-Id: Iaa54ef4e44db54023e3c19a088d14ad204bb2620
Fixed: chromium:1360800
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3905722
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarJakob Linke <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83355}
parent 831ef4e6
...@@ -233,14 +233,13 @@ class TranslationArrayProcessor { ...@@ -233,14 +233,13 @@ class TranslationArrayProcessor {
} }
private: private:
const InputLocation* EmitDeoptFrame(const MaglevCompilationUnit& unit, void EmitDeoptFrame(const MaglevCompilationUnit& unit,
const CheckpointedInterpreterState& state, const CheckpointedInterpreterState& state,
const InputLocation* input_locations) { const InputLocation* input_locations) {
if (state.parent) { if (state.parent) {
// Deopt input locations are in the order of deopt frame emission, so // Deopt input locations are in the order of deopt frame emission, so
// update the pointer after emitting the parent frame. // update the pointer after emitting the parent frame.
input_locations = EmitDeoptFrame(*unit.caller(), *state.parent, input_locations);
EmitDeoptFrame(*unit.caller(), *state.parent, input_locations);
} }
// Returns are used for updating an accumulator or register after a lazy // Returns are used for updating an accumulator or register after a lazy
...@@ -252,9 +251,8 @@ class TranslationArrayProcessor { ...@@ -252,9 +251,8 @@ class TranslationArrayProcessor {
GetDeoptLiteral(*unit.shared_function_info().object()), GetDeoptLiteral(*unit.shared_function_info().object()),
unit.register_count(), return_offset, return_count); unit.register_count(), return_offset, return_count);
return EmitDeoptFrameValues(unit, state.register_frame, input_locations, EmitDeoptFrameValues(unit, state.register_frame, input_locations,
interpreter::Register::invalid_value(), interpreter::Register::invalid_value(), return_count);
return_count);
} }
void EmitEagerDeopt(EagerDeoptInfo* deopt_info) { void EmitEagerDeopt(EagerDeoptInfo* deopt_info) {
...@@ -283,8 +281,8 @@ class TranslationArrayProcessor { ...@@ -283,8 +281,8 @@ class TranslationArrayProcessor {
if (deopt_info->state.parent) { if (deopt_info->state.parent) {
// Deopt input locations are in the order of deopt frame emission, so // Deopt input locations are in the order of deopt frame emission, so
// update the pointer after emitting the parent frame. // update the pointer after emitting the parent frame.
input_locations = EmitDeoptFrame( EmitDeoptFrame(*unit.caller(), *deopt_info->state.parent,
*unit.caller(), *deopt_info->state.parent, input_locations); input_locations);
} }
// Return offsets are counted from the end of the translation frame, which // Return offsets are counted from the end of the translation frame, which
...@@ -400,10 +398,10 @@ class TranslationArrayProcessor { ...@@ -400,10 +398,10 @@ class TranslationArrayProcessor {
result_location.index() + result_size - 1); result_location.index() + result_size - 1);
} }
const InputLocation* EmitDeoptFrameValues( void EmitDeoptFrameValues(
const MaglevCompilationUnit& compilation_unit, const MaglevCompilationUnit& compilation_unit,
const CompactInterpreterFrameState* checkpoint_state, const CompactInterpreterFrameState* checkpoint_state,
const InputLocation* input_locations, const InputLocation*& input_location,
interpreter::Register result_location, int result_size) { interpreter::Register result_location, int result_size) {
// Closure // Closure
if (compilation_unit.inlining_depth() == 0) { if (compilation_unit.inlining_depth() == 0) {
...@@ -418,7 +416,6 @@ class TranslationArrayProcessor { ...@@ -418,7 +416,6 @@ class TranslationArrayProcessor {
// TODO(leszeks): The input locations array happens to be in the same order // TODO(leszeks): The input locations array happens to be in the same order
// as parameters+context+locals+accumulator are accessed here. We should // as parameters+context+locals+accumulator are accessed here. We should
// make this clearer and guard against this invariant failing. // make this clearer and guard against this invariant failing.
const InputLocation* input_location = input_locations;
// Parameters // Parameters
{ {
...@@ -430,9 +427,9 @@ class TranslationArrayProcessor { ...@@ -430,9 +427,9 @@ class TranslationArrayProcessor {
translation_array_builder().StoreOptimizedOut(); translation_array_builder().StoreOptimizedOut();
} else { } else {
EmitDeoptFrameSingleValue(value, *input_location); EmitDeoptFrameSingleValue(value, *input_location);
input_location++;
} }
i++; i++;
input_location++;
}); });
} }
...@@ -447,18 +444,15 @@ class TranslationArrayProcessor { ...@@ -447,18 +444,15 @@ class TranslationArrayProcessor {
checkpoint_state->ForEachLocal( checkpoint_state->ForEachLocal(
compilation_unit, [&](ValueNode* value, interpreter::Register reg) { compilation_unit, [&](ValueNode* value, interpreter::Register reg) {
DCHECK_LE(i, reg.index()); DCHECK_LE(i, reg.index());
if (InReturnValues(reg, result_location, result_size)) { if (InReturnValues(reg, result_location, result_size)) return;
input_location++;
return;
}
while (i < reg.index()) { while (i < reg.index()) {
translation_array_builder().StoreOptimizedOut(); translation_array_builder().StoreOptimizedOut();
i++; i++;
} }
DCHECK_EQ(i, reg.index()); DCHECK_EQ(i, reg.index());
EmitDeoptFrameSingleValue(value, *input_location); EmitDeoptFrameSingleValue(value, *input_location);
i++;
input_location++; input_location++;
i++;
}); });
while (i < compilation_unit.register_count()) { while (i < compilation_unit.register_count()) {
translation_array_builder().StoreOptimizedOut(); translation_array_builder().StoreOptimizedOut();
...@@ -473,12 +467,11 @@ class TranslationArrayProcessor { ...@@ -473,12 +467,11 @@ class TranslationArrayProcessor {
result_location, result_size)) { result_location, result_size)) {
ValueNode* value = checkpoint_state->accumulator(compilation_unit); ValueNode* value = checkpoint_state->accumulator(compilation_unit);
EmitDeoptFrameSingleValue(value, *input_location); EmitDeoptFrameSingleValue(value, *input_location);
input_location++;
} else { } else {
translation_array_builder().StoreOptimizedOut(); translation_array_builder().StoreOptimizedOut();
} }
} }
return input_location;
} }
int GetDeoptLiteral(Object obj) { int GetDeoptLiteral(Object obj) {
......
...@@ -429,8 +429,8 @@ void PrintLazyDeopt(std::ostream& os, std::vector<BasicBlock*> targets, ...@@ -429,8 +429,8 @@ void PrintLazyDeopt(std::ostream& os, std::vector<BasicBlock*> targets,
} else { } else {
os << PrintNodeLabel(graph_labeller, node) << ":" os << PrintNodeLabel(graph_labeller, node) << ":"
<< deopt_info->input_locations[index].operand(); << deopt_info->input_locations[index].operand();
index++;
} }
index++;
}); });
os << "}\n"; os << "}\n";
} }
......
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