Reviewers: William Hesse,

Description:
Change the code for materializing double constants on ia32.

Instead of using the stack, use a temporary integer register
and avoid memory access.


Please review this at http://codereview.chromium.org/6452002/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/ia32/lithium-codegen-ia32.cc
  M     src/ia32/lithium-ia32.h
  M     src/ia32/lithium-ia32.cc


Index: src/ia32/lithium-codegen-ia32.cc
===================================================================
--- src/ia32/lithium-codegen-ia32.cc    (revision 6672)
+++ src/ia32/lithium-codegen-ia32.cc    (working copy)
@@ -945,20 +945,16 @@
   if (BitCast<uint64_t, double>(v) == 0) {
     __ xorpd(res, res);
   } else {
-    int32_t v_int32 = static_cast<int32_t>(v);
-    if (static_cast<double>(v_int32) == v) {
-      __ push_imm32(v_int32);
-      __ cvtsi2sd(res, Operand(esp, 0));
-      __ add(Operand(esp), Immediate(kPointerSize));
-    } else {
-      uint64_t int_val = BitCast<uint64_t, double>(v);
-      int32_t lower = static_cast<int32_t>(int_val);
-      int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt));
-      __ push_imm32(upper);
-      __ push_imm32(lower);
-      __ movdbl(res, Operand(esp, 0));
-      __ add(Operand(esp), Immediate(2 * kPointerSize));
-    }
+    Register temp = ToRegister(instr->TempAt(0));
+    uint64_t int_val = BitCast<uint64_t, double>(v);
+    int32_t lower = static_cast<int32_t>(int_val);
+    int32_t upper = static_cast<int32_t>(int_val >> (kBitsPerInt));
+    __ Set(temp, Immediate(upper));
+    __ movd(res, Operand(temp));
+    __ psllq(res, 32);
+    __ Set(temp, Immediate(lower));
+    __ movd(xmm0, Operand(temp));
+    __ por(res, xmm0);
   }
 }

Index: src/ia32/lithium-ia32.cc
===================================================================
--- src/ia32/lithium-ia32.cc    (revision 6672)
+++ src/ia32/lithium-ia32.cc    (working copy)
@@ -1676,7 +1676,11 @@
   if (r.IsInteger32()) {
     return DefineAsRegister(new LConstantI);
   } else if (r.IsDouble()) {
-    return DefineAsRegister(new LConstantD);
+    double value = instr->DoubleValue();
+    LOperand* temp = (BitCast<uint64_t, double>(value) != 0)
+        ? TempRegister()
+        : NULL;
+    return DefineAsRegister(new LConstantD(temp));
   } else if (r.IsTagged()) {
     return DefineAsRegister(new LConstantT);
   } else {
Index: src/ia32/lithium-ia32.h
===================================================================
--- src/ia32/lithium-ia32.h     (revision 6672)
+++ src/ia32/lithium-ia32.h     (working copy)
@@ -941,8 +941,12 @@
 };


-class LConstantD: public LTemplateInstruction<1, 0, 0> {
+class LConstantD: public LTemplateInstruction<1, 0, 1> {
  public:
+  explicit LConstantD(LOperand* temp) {
+    temps_[0] = temp;
+  }
+
   DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d")
   DECLARE_HYDROGEN_ACCESSOR(Constant)



--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to