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;
#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));
using AsAtomicTagged = base::AsAtomicPointerImpl<AtomicTagged_t>;
......
......@@ -42,10 +42,16 @@ V8_INLINE Address DecompressTaggedAny(Address on_heap_addr,
// 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) {
// |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 & 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
......
......@@ -307,6 +307,7 @@ void TurboAssembler::DecompressAnyTagged(Register destination,
DCHECK(!AreAliased(destination, scratch));
RecordComment("[ DecompressAnyTagged");
movsxlq(destination, field_operand);
if (kUseBranchlessPtrDecompression) {
// Branchlessly compute |masked_root|:
// masked_root = HAS_SMI_TAG(destination) ? 0 : kRootRegister;
STATIC_ASSERT((kSmiTagSize == 1) && (kSmiTag < 32));
......@@ -315,9 +316,15 @@ void TurboAssembler::DecompressAnyTagged(Register destination,
andl(masked_root, Immediate(kSmiTagMask));
negq(masked_root);
andq(masked_root, kRootRegister);
// Now this add operation will either leave the value unchanged if it is a smi
// or add the isolate root if it is a heap object.
// Now this add operation will either leave the value unchanged if it is
// 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("]");
}
......
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