Skip to content

Commit

Permalink
[x64] Optimize test code for deoptimization
Browse files Browse the repository at this point in the history
This avoids loading a big int32 immediate filled with zeros to do the check.

It changes from:
  f7431700000020       testl [rbx+0x17],0x20000000
to
  f6431a20             testb [rbx+0x1a],0x20

Change-Id: Id969a4662af6fe09897931a8dba8bf4fef519169
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4667388
Auto-Submit: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#88679}
  • Loading branch information
victorgomes authored and V8 LUCI CQ committed Jul 5, 2023
1 parent fec1b61 commit e31afee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/codegen/x64/macro-assembler-x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2876,9 +2876,14 @@ void MacroAssembler::CmpInstanceTypeRange(Register map,
}

void MacroAssembler::TestCodeIsMarkedForDeoptimization(Register code) {
const int kByte4Offset = 3 * kByteSize;
const int kByte4OffsetInBits = kByte4Offset * 8;
static_assert(V8_TARGET_LITTLE_ENDIAN == 1);
static_assert(FIELD_SIZE(Code::kFlagsOffset) * kBitsPerByte == 32);
testl(FieldOperand(code, Code::kFlagsOffset),
Immediate(1 << Code::kMarkedForDeoptimizationBit));
static_assert(Code::kMarkedForDeoptimizationBit > kByte4OffsetInBits);
testb(
FieldOperand(code, Code::kFlagsOffset + kByte4Offset),
Immediate(1 << (Code::kMarkedForDeoptimizationBit - kByte4OffsetInBits)));
}

void MacroAssembler::TestCodeIsTurbofanned(Register code) {
Expand Down

0 comments on commit e31afee

Please sign in to comment.