Commit 1d567568 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[ptr-compr][csa] Loading CompressedXXX (+ Change node) instead of TaggedXXX

We translate loads with TaggedXXX (XXX in {"", "Signed", "Pointer"})
representation in CSA into loads of CompressedXXX +
ChangeCompressedXXXToTaggedXXX in the raw-machine-assembler.

This way, CSA doesn't need to know about Compressed values since we
are introducing an explicit "decompress" node.

Also updating tests that were checking for the load nodes.

Cq-Include-Trybots: luci.v8.try:v8_linux64_pointer_compression_rel_ng
Cq-Include-Trybots: luci.v8.try:v8_linux64_arm64_pointer_compression_rel_ng

Bug: v8:8977, v8:7703
Change-Id: Ie22ca8123a25ef005c1ff7383776f9355020fa42
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1565897Reviewed-by: 's avatarMichael Stanton <mvstanton@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60873}
parent e02ca14a
...@@ -132,13 +132,39 @@ class V8_EXPORT_PRIVATE RawMachineAssembler { ...@@ -132,13 +132,39 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
} }
Node* Load(MachineType rep, Node* base, Node* index, Node* Load(MachineType rep, Node* base, Node* index,
LoadSensitivity needs_poisoning = LoadSensitivity::kSafe) { LoadSensitivity needs_poisoning = LoadSensitivity::kSafe) {
// change_op is used below to change to the correct Tagged representation
const Operator* change_op = nullptr;
#ifdef V8_COMPRESS_POINTERS
switch (rep.representation()) {
case MachineRepresentation::kTaggedPointer:
rep = MachineType::CompressedPointer();
change_op = machine()->ChangeCompressedPointerToTaggedPointer();
break;
case MachineRepresentation::kTaggedSigned:
rep = MachineType::CompressedSigned();
change_op = machine()->ChangeCompressedSignedToTaggedSigned();
break;
case MachineRepresentation::kTagged:
rep = MachineType::AnyCompressed();
change_op = machine()->ChangeCompressedToTagged();
break;
default:
break;
}
#endif
const Operator* op = machine()->Load(rep); const Operator* op = machine()->Load(rep);
CHECK_NE(PoisoningMitigationLevel::kPoisonAll, poisoning_level_); CHECK_NE(PoisoningMitigationLevel::kPoisonAll, poisoning_level_);
if (needs_poisoning == LoadSensitivity::kCritical && if (needs_poisoning == LoadSensitivity::kCritical &&
poisoning_level_ == PoisoningMitigationLevel::kPoisonCriticalOnly) { poisoning_level_ == PoisoningMitigationLevel::kPoisonCriticalOnly) {
op = machine()->PoisonedLoad(rep); op = machine()->PoisonedLoad(rep);
} }
return AddNode(op, base, index);
Node* load = AddNode(op, base, index);
if (change_op != nullptr) {
load = AddNode(change_op, load);
}
return load;
} }
Node* Store(MachineRepresentation rep, Node* base, Node* value, Node* Store(MachineRepresentation rep, Node* base, Node* value,
WriteBarrierKind write_barrier) { WriteBarrierKind write_barrier) {
......
...@@ -2190,6 +2190,7 @@ IS_UNOP_MATCHER(ChangeInt32ToFloat64) ...@@ -2190,6 +2190,7 @@ IS_UNOP_MATCHER(ChangeInt32ToFloat64)
IS_UNOP_MATCHER(ChangeInt32ToInt64) IS_UNOP_MATCHER(ChangeInt32ToInt64)
IS_UNOP_MATCHER(ChangeUint32ToFloat64) IS_UNOP_MATCHER(ChangeUint32ToFloat64)
IS_UNOP_MATCHER(ChangeUint32ToUint64) IS_UNOP_MATCHER(ChangeUint32ToUint64)
IS_UNOP_MATCHER(ChangeCompressedToTagged)
IS_UNOP_MATCHER(TruncateFloat64ToFloat32) IS_UNOP_MATCHER(TruncateFloat64ToFloat32)
IS_UNOP_MATCHER(TruncateInt64ToInt32) IS_UNOP_MATCHER(TruncateInt64ToInt32)
IS_UNOP_MATCHER(Float32Abs) IS_UNOP_MATCHER(Float32Abs)
......
...@@ -421,6 +421,7 @@ Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher); ...@@ -421,6 +421,7 @@ Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsChangeInt32ToInt64(const Matcher<Node*>& input_matcher); Matcher<Node*> IsChangeInt32ToInt64(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsChangeUint32ToFloat64(const Matcher<Node*>& input_matcher); Matcher<Node*> IsChangeUint32ToFloat64(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsChangeUint32ToUint64(const Matcher<Node*>& input_matcher); Matcher<Node*> IsChangeUint32ToUint64(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsChangeCompressedToTagged(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsTruncateFloat64ToFloat32(const Matcher<Node*>& input_matcher); Matcher<Node*> IsTruncateFloat64ToFloat32(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsTruncateInt64ToInt32(const Matcher<Node*>& input_matcher); Matcher<Node*> IsTruncateInt64ToInt32(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsFloat32Abs(const Matcher<Node*>& input_matcher); Matcher<Node*> IsFloat32Abs(const Matcher<Node*>& input_matcher);
......
...@@ -434,6 +434,20 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { ...@@ -434,6 +434,20 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) {
{ {
Node* index = m.IntPtrConstant(2); Node* index = m.IntPtrConstant(2);
Node* load_constant = m.LoadConstantPoolEntry(index); Node* load_constant = m.LoadConstantPoolEntry(index);
#ifdef V8_COMPRESS_POINTERS
Matcher<Node*> constant_pool_matcher =
IsChangeCompressedToTagged(m.IsLoad(
MachineType::AnyCompressed(),
c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
c::IsIntPtrConstant(BytecodeArray::kConstantPoolOffset -
kHeapObjectTag)));
EXPECT_THAT(load_constant,
IsChangeCompressedToTagged(m.IsLoad(
MachineType::AnyCompressed(), constant_pool_matcher,
c::IsIntPtrConstant(FixedArray::OffsetOfElementAt(2) -
kHeapObjectTag),
LoadSensitivity::kCritical)));
#else
Matcher<Node*> constant_pool_matcher = m.IsLoad( Matcher<Node*> constant_pool_matcher = m.IsLoad(
MachineType::AnyTagged(), MachineType::AnyTagged(),
c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
...@@ -445,10 +459,27 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { ...@@ -445,10 +459,27 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) {
c::IsIntPtrConstant(FixedArray::OffsetOfElementAt(2) - c::IsIntPtrConstant(FixedArray::OffsetOfElementAt(2) -
kHeapObjectTag), kHeapObjectTag),
LoadSensitivity::kCritical)); LoadSensitivity::kCritical));
#endif
} }
{ {
Node* index = m.Parameter(2); Node* index = m.Parameter(2);
Node* load_constant = m.LoadConstantPoolEntry(index); Node* load_constant = m.LoadConstantPoolEntry(index);
#if V8_COMPRESS_POINTERS
Matcher<Node*> constant_pool_matcher =
IsChangeCompressedToTagged(m.IsLoad(
MachineType::AnyCompressed(),
c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
c::IsIntPtrConstant(BytecodeArray::kConstantPoolOffset -
kHeapObjectTag)));
EXPECT_THAT(
load_constant,
IsChangeCompressedToTagged(m.IsLoad(
MachineType::AnyCompressed(), constant_pool_matcher,
c::IsIntPtrAdd(
c::IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag),
c::IsWordShl(index, c::IsIntPtrConstant(kTaggedSizeLog2))),
LoadSensitivity::kCritical)));
#else
Matcher<Node*> constant_pool_matcher = m.IsLoad( Matcher<Node*> constant_pool_matcher = m.IsLoad(
MachineType::AnyTagged(), MachineType::AnyTagged(),
c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray), c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
...@@ -462,6 +493,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) { ...@@ -462,6 +493,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) {
c::IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), c::IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag),
c::IsWordShl(index, c::IsIntPtrConstant(kTaggedSizeLog2))), c::IsWordShl(index, c::IsIntPtrConstant(kTaggedSizeLog2))),
LoadSensitivity::kCritical)); LoadSensitivity::kCritical));
#endif
} }
} }
} }
...@@ -473,9 +505,15 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) { ...@@ -473,9 +505,15 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) {
Node* object = m.IntPtrConstant(0xDEADBEEF); Node* object = m.IntPtrConstant(0xDEADBEEF);
int offset = 16; int offset = 16;
Node* load_field = m.LoadObjectField(object, offset); Node* load_field = m.LoadObjectField(object, offset);
#ifdef V8_COMPRESS_POINTERS
EXPECT_THAT(load_field, IsChangeCompressedToTagged(m.IsLoad(
MachineType::AnyCompressed(), object,
c::IsIntPtrConstant(offset - kHeapObjectTag))));
#else
EXPECT_THAT(load_field, EXPECT_THAT(load_field,
m.IsLoad(MachineType::AnyTagged(), object, m.IsLoad(MachineType::AnyTagged(), object,
c::IsIntPtrConstant(offset - kHeapObjectTag))); c::IsIntPtrConstant(offset - kHeapObjectTag)));
#endif
} }
} }
...@@ -553,6 +591,16 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadFeedbackVector) { ...@@ -553,6 +591,16 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadFeedbackVector) {
m.IsLoad(MachineType::Pointer(), c::IsLoadParentFramePointer(), m.IsLoad(MachineType::Pointer(), c::IsLoadParentFramePointer(),
c::IsIntPtrConstant(Register::function_closure().ToOperand() * c::IsIntPtrConstant(Register::function_closure().ToOperand() *
kSystemPointerSize))); kSystemPointerSize)));
#ifdef V8_COMPRESS_POINTERS
Matcher<Node*> load_vector_cell_matcher = IsChangeCompressedToTagged(
m.IsLoad(MachineType::AnyCompressed(), load_function_matcher,
c::IsIntPtrConstant(JSFunction::kFeedbackCellOffset -
kHeapObjectTag)));
EXPECT_THAT(load_feedback_vector,
IsChangeCompressedToTagged(m.IsLoad(
MachineType::AnyCompressed(), load_vector_cell_matcher,
c::IsIntPtrConstant(Cell::kValueOffset - kHeapObjectTag))));
#else
Matcher<Node*> load_vector_cell_matcher = m.IsLoad( Matcher<Node*> load_vector_cell_matcher = m.IsLoad(
MachineType::AnyTagged(), load_function_matcher, MachineType::AnyTagged(), load_function_matcher,
c::IsIntPtrConstant(JSFunction::kFeedbackCellOffset - kHeapObjectTag)); c::IsIntPtrConstant(JSFunction::kFeedbackCellOffset - kHeapObjectTag));
...@@ -560,6 +608,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadFeedbackVector) { ...@@ -560,6 +608,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadFeedbackVector) {
load_feedback_vector, load_feedback_vector,
m.IsLoad(MachineType::AnyTagged(), load_vector_cell_matcher, m.IsLoad(MachineType::AnyTagged(), load_vector_cell_matcher,
c::IsIntPtrConstant(Cell::kValueOffset - kHeapObjectTag))); c::IsIntPtrConstant(Cell::kValueOffset - kHeapObjectTag)));
#endif
} }
} }
......
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