Commit 0ec75c91 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[ptr-compr] Add State related cases in DecompressionOptimizer

Relevant opcodes:
 * kFrameState
 * kStateValues
 * kTypedStateValues

The code to decompress CompressedHeapConstants is not there for the
opcodes stated above. We can only do this optimization for Loads
for the moment.

Bug: v8:7703
Change-Id: I226089f1b2b78d0bd742785c7c9924284a97c72d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1879942
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64732}
parent bff5a053
......@@ -91,6 +91,18 @@ void DecompressionOptimizer::MarkNodeInputs(Node* node) {
? State::kOnly32BitsObserved
: State::kEverythingObserved); // value
break;
// The deopt code knows how to handle Compressed inputs, both
// MachineRepresentation kCompressed values and CompressedHeapConstants.
case IrOpcode::kFrameState: // Fall through.
// TODO(v8:7703): kStateValues doesn't appear in any test linked to Loads or
// HeapConstants. Do we care about this case?
case IrOpcode::kStateValues: // Fall through.
case IrOpcode::kTypedStateValues:
for (int i = 0; i < node->op()->ValueInputCount(); ++i) {
MaybeMarkAndQueueForRevisit(node->InputAt(i),
State::kOnly32BitsObserved);
}
break;
default:
// To be conservative, we assume that all value inputs need to be 64 bits
// unless noted otherwise.
......
......@@ -260,6 +260,54 @@ TEST_F(DecompressionOptimizerTest, Word32SarSmiUntag) {
EXPECT_EQ(LoadMachRep(load), CompressedMachRep(MachineType::AnyTagged()));
}
// -----------------------------------------------------------------------------
// FrameState and TypedStateValues interaction.
TEST_F(DecompressionOptimizerTest, TypedStateValues) {
// Skip test if decompression elimination is enabled.
if (FLAG_turbo_decompression_elimination) {
return;
}
// Define variables.
Node* const control = graph()->start();
Node* object = Parameter(Type::Any(), 0);
Node* effect = graph()->start();
Node* index = Parameter(Type::UnsignedSmall(), 1);
const int number_of_inputs = 2;
const ZoneVector<MachineType>* types_for_state_values =
new (graph()->zone()->New(sizeof(ZoneVector<MachineType>)))
ZoneVector<MachineType>(number_of_inputs, graph()->zone());
SparseInputMask dense = SparseInputMask::Dense();
// Test for both AnyTagged and TaggedPointer.
for (size_t i = 0; i < arraysize(types); ++i) {
for (size_t j = 0; j < arraysize(heap_constants); ++j) {
// Create the graph.
Node* load = graph()->NewNode(machine()->Load(types[i]), object, index,
effect, control);
Node* constant_1 =
graph()->NewNode(common()->HeapConstant(heap_constants[j]));
Node* typed_state_values = graph()->NewNode(
common()->TypedStateValues(types_for_state_values, dense), load,
constant_1);
Node* constant_2 =
graph()->NewNode(common()->HeapConstant(heap_constants[j]));
graph()->SetEnd(graph()->NewNode(
common()->FrameState(BailoutId::None(),
OutputFrameStateCombine::Ignore(), nullptr),
typed_state_values, typed_state_values, typed_state_values,
constant_2, UndefinedConstant(), graph()->start()));
// Change the nodes, and test the change.
Reduce();
EXPECT_EQ(LoadMachRep(load), CompressedMachRep(types[i]));
EXPECT_EQ(constant_1->opcode(), IrOpcode::kCompressedHeapConstant);
EXPECT_EQ(constant_2->opcode(), IrOpcode::kCompressedHeapConstant);
}
}
}
} // namespace compiler
} // namespace internal
} // namespace v8
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