From b1d7878c7fff3111e7dcfda9b4aad42e374a4ba4 Mon Sep 17 00:00:00 2001 From: "jkummerow@chromium.org" Date: Thu, 7 Feb 2013 13:15:41 +0000 Subject: [PATCH] Fix DoubleStackSlot-to-DoubleStackSlot moves on ia32. Unify platform-independent code. BUG=173907 Review URL: https://codereview.chromium.org/12207063 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13617 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/lithium-codegen-arm.cc | 21 ++------------------- src/ia32/lithium-codegen-ia32.cc | 14 ++------------ src/lithium.cc | 12 ++++++++++++ src/lithium.h | 1 + src/mips/lithium-codegen-mips.cc | 21 ++------------------- src/x64/lithium-codegen-x64.cc | 10 +--------- 6 files changed, 20 insertions(+), 59 deletions(-) diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 9fdb22b..45ebfae 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -568,30 +568,13 @@ MemOperand LCodeGen::ToMemOperand(LOperand* op) const { ASSERT(!op->IsRegister()); ASSERT(!op->IsDoubleRegister()); ASSERT(op->IsStackSlot() || op->IsDoubleStackSlot()); - int index = op->index(); - if (index >= 0) { - // Local or spill slot. Skip the frame pointer, function, and - // context in the fixed part of the frame. - return MemOperand(fp, -(index + 3) * kPointerSize); - } else { - // Incoming parameter. Skip the return address. - return MemOperand(fp, -(index - 1) * kPointerSize); - } + return MemOperand(fp, StackSlotOffset(op->index())); } MemOperand LCodeGen::ToHighMemOperand(LOperand* op) const { ASSERT(op->IsDoubleStackSlot()); - int index = op->index(); - if (index >= 0) { - // Local or spill slot. Skip the frame pointer, function, context, - // and the first word of the double in the fixed part of the frame. - return MemOperand(fp, -(index + 3) * kPointerSize + kPointerSize); - } else { - // Incoming parameter. Skip the return address and the first word of - // the double. - return MemOperand(fp, -(index - 1) * kPointerSize + kPointerSize); - } + return MemOperand(fp, StackSlotOffset(op->index()) + kPointerSize); } diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index dfced7c..05152b7 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -549,23 +549,13 @@ Operand LCodeGen::ToOperand(LOperand* op) const { if (op->IsRegister()) return Operand(ToRegister(op)); if (op->IsDoubleRegister()) return Operand(ToDoubleRegister(op)); ASSERT(op->IsStackSlot() || op->IsDoubleStackSlot()); - int index = op->index(); - if (index >= 0) { - // Local or spill slot. Skip the frame pointer, function, and - // context in the fixed part of the frame. - return Operand(ebp, -(index + 3) * kPointerSize); - } else { - // Incoming parameter. Skip the return address. - return Operand(ebp, -(index - 1) * kPointerSize); - } + return Operand(ebp, StackSlotOffset(op->index())); } Operand LCodeGen::HighOperand(LOperand* op) { ASSERT(op->IsDoubleStackSlot()); - int index = op->index(); - int offset = (index >= 0) ? index + 3 : index - 1; - return Operand(ebp, -offset * kPointerSize); + return Operand(ebp, StackSlotOffset(op->index()) + kPointerSize); } diff --git a/src/lithium.cc b/src/lithium.cc index ff5af7f..5967e42 100644 --- a/src/lithium.cc +++ b/src/lithium.cc @@ -257,6 +257,18 @@ int ElementsKindToShiftSize(ElementsKind elements_kind) { } +int StackSlotOffset(int index) { + if (index >= 0) { + // Local or spill slot. Skip the frame pointer, function, and + // context in the fixed part of the frame. + return -(index + 3) * kPointerSize; + } else { + // Incoming parameter. Skip the return address. + return -(index - 1) * kPointerSize; + } +} + + LChunk::LChunk(CompilationInfo* info, HGraph* graph) : spill_slot_count_(0), info_(info), diff --git a/src/lithium.h b/src/lithium.h index 2473837..dd979a9 100644 --- a/src/lithium.h +++ b/src/lithium.h @@ -709,6 +709,7 @@ class LChunk: public ZoneObject { int ElementsKindToShiftSize(ElementsKind elements_kind); +int StackSlotOffset(int index); enum NumberUntagDMode { NUMBER_CANDIDATE_IS_SMI, diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 13dd63c..86669f4 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -528,30 +528,13 @@ MemOperand LCodeGen::ToMemOperand(LOperand* op) const { ASSERT(!op->IsRegister()); ASSERT(!op->IsDoubleRegister()); ASSERT(op->IsStackSlot() || op->IsDoubleStackSlot()); - int index = op->index(); - if (index >= 0) { - // Local or spill slot. Skip the frame pointer, function, and - // context in the fixed part of the frame. - return MemOperand(fp, -(index + 3) * kPointerSize); - } else { - // Incoming parameter. Skip the return address. - return MemOperand(fp, -(index - 1) * kPointerSize); - } + return MemOperand(fp, StackSlotOffset(op->index())); } MemOperand LCodeGen::ToHighMemOperand(LOperand* op) const { ASSERT(op->IsDoubleStackSlot()); - int index = op->index(); - if (index >= 0) { - // Local or spill slot. Skip the frame pointer, function, context, - // and the first word of the double in the fixed part of the frame. - return MemOperand(fp, -(index + 3) * kPointerSize + kPointerSize); - } else { - // Incoming parameter. Skip the return address and the first word of - // the double. - return MemOperand(fp, -(index - 1) * kPointerSize + kPointerSize); - } + return MemOperand(fp, StackSlotOffset(op->index()) + kPointerSize); } diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index f71bf38..b3c4bc8 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -464,15 +464,7 @@ Operand LCodeGen::ToOperand(LOperand* op) const { // Does not handle registers. In X64 assembler, plain registers are not // representable as an Operand. ASSERT(op->IsStackSlot() || op->IsDoubleStackSlot()); - int index = op->index(); - if (index >= 0) { - // Local or spill slot. Skip the frame pointer, function, and - // context in the fixed part of the frame. - return Operand(rbp, -(index + 3) * kPointerSize); - } else { - // Incoming parameter. Skip the return address. - return Operand(rbp, -(index - 1) * kPointerSize); - } + return Operand(rbp, StackSlotOffset(op->index())); } -- 2.7.4