Commit 26fc3d58 authored by Kanghua Yu's avatar Kanghua Yu Committed by Commit Bot

[x64] Reduce unnecessary LEA instruction in prologue

--- Optimized code ---
optimization_id = 26
kind = OPTIMIZED_FUNCTION
compiler = turbofan
...
    leaq rcx,[rip+0x0]             => TO BE REDUCED
    movq rcx,[rcx-0x37]            => movq rcx,[rip-0x37]
    testb [rcx+0xf],0x1
    jnz CompileLazyDeoptimizedCode

Change-Id: I06c10ebd33af6524c4ad9ce466fd0880268f4a83
Reviewed-on: https://chromium-review.googlesource.com/880642Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Kanghua Yu <kanghua.yu@intel.com>
Cr-Commit-Position: refs/heads/master@{#51011}
parent 0f6eafe8
......@@ -579,13 +579,10 @@ void CodeGenerator::AssembleTailCallAfterGap(Instruction* instr,
// 4. if it is not zero then it jumps to the builtin.
void CodeGenerator::BailoutIfDeoptimized() {
Label current;
// Load effective address to get the address of the current instruction into
// rcx.
__ leaq(rcx, Operand(&current));
__ bind(&current);
int pc = __ pc_offset();
int offset = Code::kCodeDataContainerOffset - (Code::kHeaderSize + pc);
__ movp(rcx, Operand(rcx, offset));
__ movp(rcx, Operand(&current, offset));
__ testl(FieldOperand(rcx, CodeDataContainer::kKindSpecificFlagsOffset),
Immediate(1 << Code::kMarkedForDeoptimizationBit));
Handle<Code> code = isolate()->builtins()->builtin_handle(
......
......@@ -207,9 +207,9 @@ Operand::Operand(Register index,
set_disp32(disp);
}
Operand::Operand(Label* label) : rex_(0), len_(1) {
Operand::Operand(Label* label, int addend) : rex_(0), len_(1), addend_(addend) {
DCHECK_NOT_NULL(label);
DCHECK(addend == 0 || (is_int8(addend) && label->is_bound()));
set_modrm(0, rbp);
set_disp64(reinterpret_cast<intptr_t>(label));
}
......@@ -542,7 +542,7 @@ void Assembler::emit_operand(int code, const Operand& adr) {
DCHECK_EQ(9u, length);
Label* label = *bit_cast<Label* const*>(&adr.buf_[1]);
if (label->is_bound()) {
int offset = label->pos() - pc_offset() - sizeof(int32_t);
int offset = label->pos() - pc_offset() - sizeof(int32_t) + adr.addend_;
DCHECK_GE(0, offset);
emitl(offset);
} else if (label->is_linked()) {
......
......@@ -357,7 +357,7 @@ class Operand BASE_EMBEDDED {
Operand(const Operand& base, int32_t offset);
// [rip + disp/r]
explicit Operand(Label* label);
explicit Operand(Label* label, int addend = 0);
// Checks whether either base or index register is the given register.
// Does not check the "reg" part of the Operand.
......@@ -376,6 +376,8 @@ class Operand BASE_EMBEDDED {
// The number of bytes of buf_ in use.
byte len_;
int8_t addend_; // for rip + offset + addend
// Set the ModR/M byte without an encoded 'reg' register. The
// register is encoded later as part of the emit_operand operation.
// set_modrm can be called before or after set_sib and set_disp*.
......
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