Commit cf878af2 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[ptr-compr] Adding the branchful/branchless decompression choice to codegen

I missed these cases when adding the branchful decompression on codegen.

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:7703
Change-Id: Idb3f5ca81e00bb17fa08ba2b2506b642ffbd7b4b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1571623
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61045}
parent 0ba2c733
...@@ -2801,10 +2801,10 @@ void TurboAssembler::DecompressTaggedSigned(const Register& destination, ...@@ -2801,10 +2801,10 @@ void TurboAssembler::DecompressTaggedSigned(const Register& destination,
RecordComment("]"); RecordComment("]");
} }
void TurboAssembler::DecompressTaggedPointer(const Register& destination, void TurboAssembler::DecompressTaggedSigned(const Register& destination,
const Register& source) { const Register& source) {
RecordComment("[ DecompressTaggedPointer"); RecordComment("[ DecompressTaggedSigned");
Add(destination, kRootRegister, Operand(source, SXTW)); Sxtw(destination, source);
RecordComment("]"); RecordComment("]");
} }
...@@ -2816,6 +2816,13 @@ void TurboAssembler::DecompressTaggedPointer(const Register& destination, ...@@ -2816,6 +2816,13 @@ void TurboAssembler::DecompressTaggedPointer(const Register& destination,
RecordComment("]"); RecordComment("]");
} }
void TurboAssembler::DecompressTaggedPointer(const Register& destination,
const Register& source) {
RecordComment("[ DecompressTaggedPointer");
Add(destination, kRootRegister, Operand(source, SXTW));
RecordComment("]");
}
void TurboAssembler::DecompressAnyTagged(const Register& destination, void TurboAssembler::DecompressAnyTagged(const Register& destination,
const MemOperand& field_operand) { const MemOperand& field_operand) {
RecordComment("[ DecompressAnyTagged"); RecordComment("[ DecompressAnyTagged");
...@@ -2841,6 +2848,31 @@ void TurboAssembler::DecompressAnyTagged(const Register& destination, ...@@ -2841,6 +2848,31 @@ void TurboAssembler::DecompressAnyTagged(const Register& destination,
RecordComment("]"); RecordComment("]");
} }
void TurboAssembler::DecompressAnyTagged(const Register& destination,
const Register& source) {
RecordComment("[ DecompressAnyTagged");
if (kUseBranchlessPtrDecompression) {
UseScratchRegisterScope temps(this);
// Branchlessly compute |masked_root|:
// masked_root = HAS_SMI_TAG(destination) ? 0 : kRootRegister;
STATIC_ASSERT((kSmiTagSize == 1) && (kSmiTag == 0));
Register masked_root = temps.AcquireX();
// Sign extend tag bit to entire register.
Sbfx(masked_root, source, 0, kSmiTagSize);
And(masked_root, 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.
Add(destination, masked_root, Operand(source, SXTW));
} else {
Label done;
Sxtw(destination, source);
JumpIfSmi(destination, &done);
Add(destination, kRootRegister, destination);
bind(&done);
}
RecordComment("]");
}
void MacroAssembler::CompareAndSplit(const Register& lhs, void MacroAssembler::CompareAndSplit(const Register& lhs,
const Operand& rhs, const Operand& rhs,
Condition cond, Condition cond,
......
...@@ -1196,12 +1196,15 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -1196,12 +1196,15 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void DecompressTaggedSigned(const Register& destination, void DecompressTaggedSigned(const Register& destination,
const MemOperand& field_operand); const MemOperand& field_operand);
void DecompressTaggedPointer(const Register& destination, void DecompressTaggedSigned(const Register& destination,
const Register& source); const Register& source);
void DecompressTaggedPointer(const Register& destination, void DecompressTaggedPointer(const Register& destination,
const MemOperand& field_operand); const MemOperand& field_operand);
void DecompressTaggedPointer(const Register& destination,
const Register& source);
void DecompressAnyTagged(const Register& destination, void DecompressAnyTagged(const Register& destination,
const MemOperand& field_operand); const MemOperand& field_operand);
void DecompressAnyTagged(const Register& destination, const Register& source);
protected: protected:
// The actual Push and Pop implementations. These don't generate any code // The actual Push and Pop implementations. These don't generate any code
......
...@@ -1581,27 +1581,15 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1581,27 +1581,15 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ Str(i.InputOrZeroRegister64(0), i.MemoryOperand(1)); __ Str(i.InputOrZeroRegister64(0), i.MemoryOperand(1));
break; break;
case kArm64DecompressSigned: { case kArm64DecompressSigned: {
__ Sxtw(i.OutputRegister(), i.InputRegister(0)); __ DecompressTaggedSigned(i.OutputRegister(), i.InputRegister(0));
break; break;
} }
case kArm64DecompressPointer: { case kArm64DecompressPointer: {
__ Add(i.OutputRegister(), kRootRegister, __ DecompressTaggedPointer(i.OutputRegister(), i.InputRegister(0));
Operand(i.InputRegister(0), SXTW));
break; break;
} }
case kArm64DecompressAny: { case kArm64DecompressAny: {
// TODO(solanes): Do branchful compute? __ DecompressAnyTagged(i.OutputRegister(), i.InputRegister(0));
// Branchlessly compute |masked_root|:
STATIC_ASSERT((kSmiTagSize == 1) && (kSmiTag == 0));
UseScratchRegisterScope temps(tasm());
Register masked_root = temps.AcquireX();
// Sign extend tag bit to entire register.
__ Sbfx(masked_root, i.InputRegister(0), 0, kSmiTagSize);
__ And(masked_root, 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.
__ Add(i.OutputRegister(), masked_root,
Operand(i.InputRegister(0), SXTW));
break; break;
} }
// TODO(solanes): Combine into one Compress? They seem to be identical. // TODO(solanes): Combine into one Compress? They seem to be identical.
......
...@@ -1961,29 +1961,17 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1961,29 +1961,17 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
} }
case kX64DecompressSigned: { case kX64DecompressSigned: {
CHECK(instr->HasOutput()); CHECK(instr->HasOutput());
ASSEMBLE_MOVX(movsxlq); ASSEMBLE_MOVX(DecompressTaggedSigned);
break; break;
} }
case kX64DecompressPointer: { case kX64DecompressPointer: {
CHECK(instr->HasOutput()); CHECK(instr->HasOutput());
ASSEMBLE_MOVX(movsxlq); ASSEMBLE_MOVX(DecompressTaggedPointer);
__ addq(i.OutputRegister(), kRootRegister);
break; break;
} }
case kX64DecompressAny: { case kX64DecompressAny: {
CHECK(instr->HasOutput()); CHECK(instr->HasOutput());
ASSEMBLE_MOVX(movsxlq); ASSEMBLE_MOVX(DecompressAnyTagged);
// TODO(solanes): Do branchful compute?
// Branchlessly compute |masked_root|:
STATIC_ASSERT((kSmiTagSize == 1) && (kSmiTag < 32));
Register masked_root = kScratchRegister;
__ movl(masked_root, i.OutputRegister());
__ 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.
__ addq(i.OutputRegister(), masked_root);
break; break;
} }
// TODO(solanes): Combine into one Compress? They seem to be identical. // TODO(solanes): Combine into one Compress? They seem to be identical.
......
...@@ -293,11 +293,10 @@ void TurboAssembler::DecompressTaggedSigned(Register destination, ...@@ -293,11 +293,10 @@ void TurboAssembler::DecompressTaggedSigned(Register destination,
RecordComment("]"); RecordComment("]");
} }
void TurboAssembler::DecompressTaggedPointer(Register destination, void TurboAssembler::DecompressTaggedSigned(Register destination,
Register source) { Register source) {
RecordComment("[ DecompressTaggedPointer"); RecordComment("[ DecompressTaggedSigned");
movsxlq(destination, source); movsxlq(destination, source);
addq(destination, kRootRegister);
RecordComment("]"); RecordComment("]");
} }
...@@ -309,12 +308,16 @@ void TurboAssembler::DecompressTaggedPointer(Register destination, ...@@ -309,12 +308,16 @@ void TurboAssembler::DecompressTaggedPointer(Register destination,
RecordComment("]"); RecordComment("]");
} }
void TurboAssembler::DecompressAnyTagged(Register destination, void TurboAssembler::DecompressTaggedPointer(Register destination,
Operand field_operand, Register source) {
RecordComment("[ DecompressTaggedPointer");
movsxlq(destination, source);
addq(destination, kRootRegister);
RecordComment("]");
}
void TurboAssembler::DecompressRegisterAnyTagged(Register destination,
Register scratch) { Register scratch) {
DCHECK(!AreAliased(destination, scratch));
RecordComment("[ DecompressAnyTagged");
movsxlq(destination, field_operand);
if (kUseBranchlessPtrDecompression) { if (kUseBranchlessPtrDecompression) {
// Branchlessly compute |masked_root|: // Branchlessly compute |masked_root|:
// masked_root = HAS_SMI_TAG(destination) ? 0 : kRootRegister; // masked_root = HAS_SMI_TAG(destination) ? 0 : kRootRegister;
...@@ -333,6 +336,24 @@ void TurboAssembler::DecompressAnyTagged(Register destination, ...@@ -333,6 +336,24 @@ void TurboAssembler::DecompressAnyTagged(Register destination,
addq(destination, kRootRegister); addq(destination, kRootRegister);
bind(&done); bind(&done);
} }
}
void TurboAssembler::DecompressAnyTagged(Register destination,
Operand field_operand,
Register scratch) {
DCHECK(!AreAliased(destination, scratch));
RecordComment("[ DecompressAnyTagged");
movsxlq(destination, field_operand);
DecompressRegisterAnyTagged(destination, scratch);
RecordComment("]");
}
void TurboAssembler::DecompressAnyTagged(Register destination, Register source,
Register scratch) {
DCHECK(!AreAliased(destination, scratch));
RecordComment("[ DecompressAnyTagged");
movsxlq(destination, source);
DecompressRegisterAnyTagged(destination, scratch);
RecordComment("]"); RecordComment("]");
} }
......
...@@ -510,10 +510,16 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -510,10 +510,16 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// The following macros work even when pointer compression is not enabled. // The following macros work even when pointer compression is not enabled.
void DecompressTaggedSigned(Register destination, Operand field_operand); void DecompressTaggedSigned(Register destination, Operand field_operand);
void DecompressTaggedPointer(Register destination, Register source); void DecompressTaggedSigned(Register destination, Register source);
void DecompressTaggedPointer(Register destination, Operand field_operand); void DecompressTaggedPointer(Register destination, Operand field_operand);
void DecompressTaggedPointer(Register destination, Register source);
// Auxiliary function used by DecompressAnyTagged to perform the actual
// decompression. Assumes destination is already signed extended.
void DecompressRegisterAnyTagged(Register destination, Register scratch);
void DecompressAnyTagged(Register destination, Operand field_operand, void DecompressAnyTagged(Register destination, Operand field_operand,
Register scratch = kScratchRegister); Register scratch = kScratchRegister);
void DecompressAnyTagged(Register destination, Register source,
Register scratch = kScratchRegister);
protected: protected:
static const int kSmiShift = kSmiTagSize + kSmiShiftSize; static const int kSmiShift = kSmiTagSize + kSmiShiftSize;
......
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