Commit 39fca64d authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[ptr-compr] Add a switch for branchless/branchful decompression

Bug: v8:7703
Change-Id: Ic6cd8b337813ecff2a0d030aa3a57304e784378a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1511486Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60391}
parent 64a94207
...@@ -225,6 +225,10 @@ using AtomicTagged_t = base::AtomicWord; ...@@ -225,6 +225,10 @@ using AtomicTagged_t = base::AtomicWord;
#endif // V8_COMPRESS_POINTERS #endif // V8_COMPRESS_POINTERS
// Defines whether the branchless or branchful implementation of pointer
// decompression should be used.
constexpr bool kUseBranchlessPtrDecompression = true;
STATIC_ASSERT(kTaggedSize == (1 << kTaggedSizeLog2)); STATIC_ASSERT(kTaggedSize == (1 << kTaggedSizeLog2));
using AsAtomicTagged = base::AsAtomicPointerImpl<AtomicTagged_t>; using AsAtomicTagged = base::AsAtomicPointerImpl<AtomicTagged_t>;
......
...@@ -42,10 +42,16 @@ V8_INLINE Address DecompressTaggedAny(Address on_heap_addr, ...@@ -42,10 +42,16 @@ V8_INLINE Address DecompressTaggedAny(Address on_heap_addr,
// Current compression scheme requires |raw_value| to be sign-extended // Current compression scheme requires |raw_value| to be sign-extended
// from int32_t to intptr_t. // from int32_t to intptr_t.
intptr_t value = static_cast<intptr_t>(static_cast<int32_t>(raw_value)); 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. if (kUseBranchlessPtrDecompression) {
Address root_mask = static_cast<Address>(-(value & kSmiTagMask)); // |root_mask| is 0 if the |value| was a smi or -1 otherwise.
Address root_or_zero = root_mask & GetRootFromOnHeapAddress(on_heap_addr); Address root_mask = static_cast<Address>(-(value & kSmiTagMask));
return root_or_zero + static_cast<Address>(value); Address root_or_zero = root_mask & GetRootFromOnHeapAddress(on_heap_addr);
return root_or_zero + static_cast<Address>(value);
} else {
return HAS_SMI_TAG(value) ? static_cast<Address>(value)
: (GetRootFromOnHeapAddress(on_heap_addr) +
static_cast<Address>(value));
}
} }
#ifdef V8_COMPRESS_POINTERS #ifdef V8_COMPRESS_POINTERS
......
...@@ -307,17 +307,24 @@ void TurboAssembler::DecompressAnyTagged(Register destination, ...@@ -307,17 +307,24 @@ void TurboAssembler::DecompressAnyTagged(Register destination,
DCHECK(!AreAliased(destination, scratch)); DCHECK(!AreAliased(destination, scratch));
RecordComment("[ DecompressAnyTagged"); RecordComment("[ DecompressAnyTagged");
movsxlq(destination, field_operand); movsxlq(destination, field_operand);
// Branchlessly compute |masked_root|: if (kUseBranchlessPtrDecompression) {
// masked_root = HAS_SMI_TAG(destination) ? 0 : kRootRegister; // Branchlessly compute |masked_root|:
STATIC_ASSERT((kSmiTagSize == 1) && (kSmiTag < 32)); // masked_root = HAS_SMI_TAG(destination) ? 0 : kRootRegister;
Register masked_root = scratch; STATIC_ASSERT((kSmiTagSize == 1) && (kSmiTag < 32));
movl(masked_root, destination); Register masked_root = scratch;
andl(masked_root, Immediate(kSmiTagMask)); movl(masked_root, destination);
negq(masked_root); andl(masked_root, Immediate(kSmiTagMask));
andq(masked_root, kRootRegister); negq(masked_root);
// Now this add operation will either leave the value unchanged if it is a smi andq(masked_root, kRootRegister);
// or add the isolate root if it is a heap object. // Now this add operation will either leave the value unchanged if it is
addq(destination, masked_root); // a smi or add the isolate root if it is a heap object.
addq(destination, masked_root);
} else {
Label done;
JumpIfSmi(destination, &done);
addq(destination, kRootRegister);
bind(&done);
}
RecordComment("]"); RecordComment("]");
} }
......
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