Commit 90975cd4 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[ptr-compr][x64] Tweak isolate root bias value and decompression code

... in order to improve quality of C++ assembly.

This CL also switches C++ code to use branchful decompression.

Bug: v8:9353
Change-Id: Id6a5cc5db2ad729b4394cd541a7ec8035c0d4571
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1677204
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62372}
parent 45561dc4
......@@ -2725,7 +2725,7 @@ void TurboAssembler::DecompressAnyTagged(const Register& destination,
const MemOperand& field_operand) {
RecordComment("[ DecompressAnyTagged");
Ldrsw(destination, field_operand);
if (kUseBranchlessPtrDecompression) {
if (kUseBranchlessPtrDecompressionInGeneratedCode) {
UseScratchRegisterScope temps(this);
// Branchlessly compute |masked_root|:
// masked_root = HAS_SMI_TAG(destination) ? 0 : kRootRegister;
......@@ -2749,7 +2749,7 @@ void TurboAssembler::DecompressAnyTagged(const Register& destination,
void TurboAssembler::DecompressAnyTagged(const Register& destination,
const Register& source) {
RecordComment("[ DecompressAnyTagged");
if (kUseBranchlessPtrDecompression) {
if (kUseBranchlessPtrDecompressionInGeneratedCode) {
UseScratchRegisterScope temps(this);
// Branchlessly compute |masked_root|:
// masked_root = HAS_SMI_TAG(destination) ? 0 : kRootRegister;
......
......@@ -12,7 +12,8 @@ namespace internal {
// Actual value of root register is offset from the root array's start
// to take advantage of negative displacement values.
// TODO(sigurds): Choose best value.
constexpr int kRootRegisterBias = 128;
// TODO(ishell): Choose best value for ptr-compr.
constexpr int kRootRegisterBias = kSystemPointerSize == kTaggedSize ? 128 : 0;
constexpr size_t kMaxPCRelativeCodeRangeInMB = 2048;
} // namespace internal
......
......@@ -317,7 +317,7 @@ void TurboAssembler::DecompressTaggedPointer(Register destination,
void TurboAssembler::DecompressRegisterAnyTagged(Register destination,
Register scratch) {
if (kUseBranchlessPtrDecompression) {
if (kUseBranchlessPtrDecompressionInGeneratedCode) {
// Branchlessly compute |masked_root|:
// masked_root = HAS_SMI_TAG(destination) ? 0 : kRootRegister;
STATIC_ASSERT((kSmiTagSize == 1) && (kSmiTag < 32));
......
......@@ -239,7 +239,8 @@ using AtomicTagged_t = base::AtomicWord;
// Defines whether the branchless or branchful implementation of pointer
// decompression should be used.
constexpr bool kUseBranchlessPtrDecompression = true;
constexpr bool kUseBranchlessPtrDecompressionInRuntime = false;
constexpr bool kUseBranchlessPtrDecompressionInGeneratedCode = true;
STATIC_ASSERT(kTaggedSize == (1 << kTaggedSizeLog2));
STATIC_ASSERT((kTaggedSize == 8) == TAGGED_SIZE_8_BYTES);
......
......@@ -40,10 +40,8 @@ V8_INLINE Address GetIsolateRoot<Isolate*>(Isolate* isolate) {
// Decompresses smi value.
V8_INLINE Address DecompressTaggedSigned(Tagged_t raw_value) {
// Current compression scheme requires |raw_value| to be sign-extended
// from int32_t to intptr_t.
intptr_t value = static_cast<intptr_t>(static_cast<int32_t>(raw_value));
return static_cast<Address>(value);
// For runtime code the upper 32-bits of the Smi value do not matter.
return static_cast<Address>(raw_value);
}
// Decompresses weak or strong heap object pointer or forwarding pointer,
......@@ -62,18 +60,18 @@ V8_INLINE Address DecompressTaggedPointer(TOnHeapAddress on_heap_addr,
template <typename TOnHeapAddress>
V8_INLINE Address DecompressTaggedAny(TOnHeapAddress on_heap_addr,
Tagged_t raw_value) {
// Current compression scheme requires |raw_value| to be sign-extended
// from int32_t to intptr_t.
intptr_t value = static_cast<intptr_t>(static_cast<int32_t>(raw_value));
if (kUseBranchlessPtrDecompression) {
if (kUseBranchlessPtrDecompressionInRuntime) {
// Current compression scheme requires |raw_value| to be sign-extended
// from int32_t to intptr_t.
intptr_t value = static_cast<intptr_t>(static_cast<int32_t>(raw_value));
// |root_mask| is 0 if the |value| was a smi or -1 otherwise.
Address root_mask = static_cast<Address>(-(value & kSmiTagMask));
Address root_or_zero = root_mask & GetIsolateRoot(on_heap_addr);
return root_or_zero + static_cast<Address>(value);
} else {
return HAS_SMI_TAG(value)
? static_cast<Address>(value)
: (GetIsolateRoot(on_heap_addr) + static_cast<Address>(value));
return HAS_SMI_TAG(raw_value)
? DecompressTaggedSigned(raw_value)
: DecompressTaggedPointer(on_heap_addr, raw_value);
}
}
......
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