Commit 31ec4d44 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[ptr-compr] Add a flag to to enable/disable the old system

The plan is to eliminate the DecompressionElimination reducer
as well as the Compressed representation. We are adding a flag to
easily swap between the old system and the new one.

Bug: v8:7703, v8:9206
Change-Id: I083fc7a835962eddfd60e9c403131587489f4632
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1815134
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64185}
parent 1302c935
......@@ -9,6 +9,7 @@
#include "src/base/bits.h"
#include "src/common/globals.h"
#include "src/flags/flags.h"
namespace v8 {
namespace internal {
......@@ -243,79 +244,79 @@ class MachineType {
// pointer flag is enabled. Otherwise, they returned the corresponding tagged
// one.
constexpr static MachineRepresentation RepCompressedTagged() {
#ifdef V8_COMPRESS_POINTERS
return MachineRepresentation::kCompressed;
#else
return MachineRepresentation::kTagged;
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
return MachineRepresentation::kCompressed;
} else {
return MachineRepresentation::kTagged;
}
}
constexpr static MachineRepresentation RepCompressedTaggedSigned() {
#ifdef V8_COMPRESS_POINTERS
return MachineRepresentation::kCompressedSigned;
#else
return MachineRepresentation::kTaggedSigned;
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
return MachineRepresentation::kCompressedSigned;
} else {
return MachineRepresentation::kTaggedSigned;
}
}
constexpr static MachineRepresentation RepCompressedTaggedPointer() {
#ifdef V8_COMPRESS_POINTERS
return MachineRepresentation::kCompressedPointer;
#else
return MachineRepresentation::kTaggedPointer;
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
return MachineRepresentation::kCompressedPointer;
} else {
return MachineRepresentation::kTaggedPointer;
}
}
constexpr static MachineType TypeRawTagged() {
#ifdef V8_COMPRESS_POINTERS
return MachineType::Int32();
#else
return MachineType::Pointer();
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
return MachineType::Int32();
} else {
return MachineType::Pointer();
}
}
constexpr static MachineType TypeCompressedTagged() {
#ifdef V8_COMPRESS_POINTERS
return MachineType::AnyCompressed();
#else
return MachineType::AnyTagged();
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
return MachineType::AnyCompressed();
} else {
return MachineType::AnyTagged();
}
}
constexpr static MachineType TypeCompressedTaggedSigned() {
#ifdef V8_COMPRESS_POINTERS
return MachineType::CompressedSigned();
#else
return MachineType::TaggedSigned();
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
return MachineType::CompressedSigned();
} else {
return MachineType::TaggedSigned();
}
}
constexpr static MachineType TypeCompressedTaggedPointer() {
#ifdef V8_COMPRESS_POINTERS
return MachineType::CompressedPointer();
#else
return MachineType::TaggedPointer();
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
return MachineType::CompressedPointer();
} else {
return MachineType::TaggedPointer();
}
}
constexpr bool IsCompressedTagged() const {
#ifdef V8_COMPRESS_POINTERS
return IsCompressed();
#else
return IsTagged();
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
return IsCompressed();
} else {
return IsTagged();
}
}
constexpr bool IsCompressedTaggedSigned() const {
#ifdef V8_COMPRESS_POINTERS
return IsCompressedSigned();
#else
return IsTaggedSigned();
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
return IsCompressedSigned();
} else {
return IsTaggedSigned();
}
}
constexpr bool IsCompressedTaggedPointer() const {
#ifdef V8_COMPRESS_POINTERS
return IsCompressedPointer();
#else
return IsTaggedPointer();
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
return IsCompressedPointer();
} else {
return IsTaggedPointer();
}
}
static MachineType TypeForRepresentation(const MachineRepresentation& rep,
......@@ -417,11 +418,11 @@ inline bool IsAnyCompressed(MachineRepresentation rep) {
}
inline bool IsAnyCompressedTagged(MachineRepresentation rep) {
#ifdef V8_COMPRESS_POINTERS
return IsAnyCompressed(rep);
#else
return IsAnyTagged(rep);
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
return IsAnyCompressed(rep);
} else {
return IsAnyTagged(rep);
}
}
// Gets the log2 of the element size in bytes of the machine type.
......@@ -443,7 +444,6 @@ V8_EXPORT_PRIVATE inline int ElementSizeLog2Of(MachineRepresentation rep) {
case MachineRepresentation::kTaggedSigned:
case MachineRepresentation::kTaggedPointer:
case MachineRepresentation::kTagged:
return kSystemPointerSizeLog2;
case MachineRepresentation::kCompressedSigned:
case MachineRepresentation::kCompressedPointer:
case MachineRepresentation::kCompressed:
......
......@@ -1759,11 +1759,11 @@ struct LateOptimizationPhase {
data->broker(), data->common(),
data->machine(), temp_zone);
SelectLowering select_lowering(data->jsgraph(), temp_zone);
#ifdef V8_COMPRESS_POINTERS
DecompressionElimination decompression_elimination(
&graph_reducer, data->graph(), data->machine(), data->common());
AddReducer(data, &graph_reducer, &decompression_elimination);
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
DecompressionElimination decompression_elimination(
&graph_reducer, data->graph(), data->machine(), data->common());
AddReducer(data, &graph_reducer, &decompression_elimination);
}
AddReducer(data, &graph_reducer, &branch_condition_elimination);
AddReducer(data, &graph_reducer, &dead_code_elimination);
AddReducer(data, &graph_reducer, &machine_reducer);
......@@ -1848,11 +1848,11 @@ struct CsaOptimizationPhase {
CommonOperatorReducer common_reducer(&graph_reducer, data->graph(),
data->broker(), data->common(),
data->machine(), temp_zone);
#ifdef V8_COMPRESS_POINTERS
DecompressionElimination decompression_elimination(
&graph_reducer, data->graph(), data->machine(), data->common());
AddReducer(data, &graph_reducer, &decompression_elimination);
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
DecompressionElimination decompression_elimination(
&graph_reducer, data->graph(), data->machine(), data->common());
AddReducer(data, &graph_reducer, &decompression_elimination);
}
AddReducer(data, &graph_reducer, &branch_condition_elimination);
AddReducer(data, &graph_reducer, &dead_code_elimination);
AddReducer(data, &graph_reducer, &machine_reducer);
......
......@@ -131,7 +131,7 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
std::pair<MachineType, const Operator*> InsertDecompressionIfNeeded(
MachineType type) {
const Operator* decompress_op = nullptr;
if (COMPRESS_POINTERS_BOOL) {
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
switch (type.representation()) {
case MachineRepresentation::kTaggedPointer:
type = MachineType::CompressedPointer();
......@@ -188,7 +188,7 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
std::pair<MachineRepresentation, Node*> InsertCompressionIfNeeded(
MachineRepresentation rep, Node* value) {
if (COMPRESS_POINTERS_BOOL) {
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
switch (rep) {
case MachineRepresentation::kTaggedPointer:
rep = MachineRepresentation::kCompressedPointer;
......@@ -237,7 +237,7 @@ class V8_EXPORT_PRIVATE RawMachineAssembler {
object, value);
}
void OptimizedStoreMap(Node* object, Node* value) {
if (COMPRESS_POINTERS_BOOL) {
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
DCHECK(AccessBuilder::ForMap().machine_type.IsCompressedPointer());
value =
AddNode(machine()->ChangeTaggedPointerToCompressedPointer(), value);
......
......@@ -1522,6 +1522,11 @@ DEFINE_BOOL(interpreted_frames_native_stack, false,
"profilers).")
#endif
// TODO(v8:9206, solanes): remove this when smi-corrupting reducer is fully on.
DEFINE_BOOL_READONLY(turbo_decompression_elimination, true,
"enable the decompression elimination system when "
"pointer compression is enabled.")
//
// Disassembler only flags
//
......
......@@ -406,67 +406,69 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) {
{
TNode<IntPtrT> index = m.IntPtrConstant(2);
TNode<Object> load_constant = m.LoadConstantPoolEntry(index);
#ifdef V8_COMPRESS_POINTERS
Matcher<Node*> constant_pool_matcher =
IsChangeCompressedToTagged(m.IsLoadFromObject(
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.IsLoadFromObject(
MachineType::AnyTagged(),
c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
c::IsIntPtrConstant(BytecodeArray::kConstantPoolOffset -
kHeapObjectTag));
EXPECT_THAT(
load_constant,
m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher,
c::IsIntPtrConstant(FixedArray::OffsetOfElementAt(2) -
kHeapObjectTag),
LoadSensitivity::kCritical));
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
Matcher<Node*> constant_pool_matcher =
IsChangeCompressedToTagged(m.IsLoadFromObject(
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.IsLoadFromObject(
MachineType::AnyTagged(),
c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
c::IsIntPtrConstant(BytecodeArray::kConstantPoolOffset -
kHeapObjectTag));
EXPECT_THAT(
load_constant,
m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher,
c::IsIntPtrConstant(FixedArray::OffsetOfElementAt(2) -
kHeapObjectTag),
LoadSensitivity::kCritical));
}
}
{
Node* index = m.Parameter(2);
TNode<Object> load_constant =
m.LoadConstantPoolEntry(m.ReinterpretCast<IntPtrT>(index));
#if V8_COMPRESS_POINTERS
Matcher<Node*> constant_pool_matcher =
IsChangeCompressedToTagged(m.IsLoadFromObject(
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.IsLoadFromObject(
MachineType::AnyTagged(),
c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
c::IsIntPtrConstant(BytecodeArray::kConstantPoolOffset -
kHeapObjectTag));
EXPECT_THAT(
load_constant,
m.IsLoad(
MachineType::AnyTagged(), constant_pool_matcher,
c::IsIntPtrAdd(
c::IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag),
c::IsWordShl(index, c::IsIntPtrConstant(kTaggedSizeLog2))),
LoadSensitivity::kCritical));
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
Matcher<Node*> constant_pool_matcher =
IsChangeCompressedToTagged(m.IsLoadFromObject(
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.IsLoadFromObject(
MachineType::AnyTagged(),
c::IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
c::IsIntPtrConstant(BytecodeArray::kConstantPoolOffset -
kHeapObjectTag));
EXPECT_THAT(
load_constant,
m.IsLoad(
MachineType::AnyTagged(), constant_pool_matcher,
c::IsIntPtrAdd(
c::IsIntPtrConstant(FixedArray::kHeaderSize -
kHeapObjectTag),
c::IsWordShl(index, c::IsIntPtrConstant(kTaggedSizeLog2))),
LoadSensitivity::kCritical));
}
}
}
}
......@@ -479,15 +481,17 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) {
m.ReinterpretCast<HeapObject>(m.IntPtrConstant(0xDEADBEEF));
int offset = 16;
TNode<Object> load_field = m.LoadObjectField(object, offset);
#ifdef V8_COMPRESS_POINTERS
EXPECT_THAT(load_field, IsChangeCompressedToTagged(m.IsLoadFromObject(
MachineType::AnyCompressed(), Eq(object),
c::IsIntPtrConstant(offset - kHeapObjectTag))));
#else
EXPECT_THAT(load_field, m.IsLoadFromObject(
MachineType::AnyTagged(), Eq(object),
c::IsIntPtrConstant(offset - kHeapObjectTag)));
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
EXPECT_THAT(load_field,
IsChangeCompressedToTagged(m.IsLoadFromObject(
MachineType::AnyCompressed(), Eq(object),
c::IsIntPtrConstant(offset - kHeapObjectTag))));
} else {
EXPECT_THAT(
load_field,
m.IsLoadFromObject(MachineType::AnyTagged(), Eq(object),
c::IsIntPtrConstant(offset - kHeapObjectTag)));
}
}
}
......@@ -569,25 +573,28 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadFeedbackVector) {
m.IsLoad(MachineType::Pointer(), c::IsLoadParentFramePointer(),
c::IsIntPtrConstant(Register::function_closure().ToOperand() *
kSystemPointerSize)));
#ifdef V8_COMPRESS_POINTERS
Matcher<Node*> load_vector_cell_matcher =
IsChangeCompressedPointerToTaggedPointer(m.IsLoadFromObject(
MachineType::CompressedPointer(), load_function_matcher,
c::IsIntPtrConstant(JSFunction::kFeedbackCellOffset -
kHeapObjectTag)));
EXPECT_THAT(load_feedback_vector,
IsChangeCompressedPointerToTaggedPointer(m.IsLoadFromObject(
MachineType::CompressedPointer(), load_vector_cell_matcher,
c::IsIntPtrConstant(Cell::kValueOffset - kHeapObjectTag))));
#else
Matcher<Node*> load_vector_cell_matcher = m.IsLoadFromObject(
MachineType::TaggedPointer(), load_function_matcher,
c::IsIntPtrConstant(JSFunction::kFeedbackCellOffset - kHeapObjectTag));
EXPECT_THAT(load_feedback_vector,
m.IsLoadFromObject(
MachineType::TaggedPointer(), load_vector_cell_matcher,
c::IsIntPtrConstant(Cell::kValueOffset - kHeapObjectTag)));
#endif
if (COMPRESS_POINTERS_BOOL && FLAG_turbo_decompression_elimination) {
Matcher<Node*> load_vector_cell_matcher =
IsChangeCompressedPointerToTaggedPointer(m.IsLoadFromObject(
MachineType::CompressedPointer(), load_function_matcher,
c::IsIntPtrConstant(JSFunction::kFeedbackCellOffset -
kHeapObjectTag)));
EXPECT_THAT(
load_feedback_vector,
IsChangeCompressedPointerToTaggedPointer(m.IsLoadFromObject(
MachineType::CompressedPointer(), load_vector_cell_matcher,
c::IsIntPtrConstant(Cell::kValueOffset - kHeapObjectTag))));
} else {
Matcher<Node*> load_vector_cell_matcher = m.IsLoadFromObject(
MachineType::TaggedPointer(), load_function_matcher,
c::IsIntPtrConstant(JSFunction::kFeedbackCellOffset -
kHeapObjectTag));
EXPECT_THAT(
load_feedback_vector,
m.IsLoadFromObject(
MachineType::TaggedPointer(), load_vector_cell_matcher,
c::IsIntPtrConstant(Cell::kValueOffset - kHeapObjectTag)));
}
}
}
......
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