Revision: 10300
Author:   [email protected]
Date:     Thu Dec 22 08:23:47 2011
Log:      Remove unnecessary environment from LStoreKeyedFastElements.

This was a left-over from a time when bounds-check was performed
as part of this instruction.

I also refactored and improved the code for smi-only arrays.

[email protected]
Review URL: http://codereview.chromium.org/9023006
http://code.google.com/p/v8/source/detail?r=10300

Modified:
 /branches/bleeding_edge/src/arm/lithium-arm.cc
 /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc
 /branches/bleeding_edge/src/hydrogen-instructions.h
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc
 /branches/bleeding_edge/src/ia32/lithium-ia32.cc
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
 /branches/bleeding_edge/src/mips/lithium-mips.cc
 /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc
 /branches/bleeding_edge/src/x64/lithium-x64.cc

=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc      Tue Dec 20 02:57:12 2011
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc      Thu Dec 22 08:23:47 2011
@@ -1938,8 +1938,7 @@
   LOperand* key = needs_write_barrier
       ? UseTempRegister(instr->key())
       : UseRegisterOrConstantAtStart(instr->key());
-
-  return AssignEnvironment(new LStoreKeyedFastElement(obj, key, val));
+  return new LStoreKeyedFastElement(obj, key, val);
 }


=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Tue Dec 20 02:57:12 2011 +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Thu Dec 22 08:23:47 2011
@@ -3403,13 +3403,6 @@
   Register elements = ToRegister(instr->object());
Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg;
   Register scratch = scratch0();
-
- // This instruction cannot handle the FAST_SMI_ONLY_ELEMENTS -> FAST_ELEMENTS
-  // conversion, so it deopts in that case.
-  if (instr->hydrogen()->ValueNeedsSmiCheck()) {
-    __ tst(value, Operand(kSmiTagMask));
-    DeoptimizeIf(ne, instr->environment());
-  }

   // Do the store.
   if (instr->key()->IsConstantOperand()) {
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Wed Dec 14 05:01:27 2011 +++ /branches/bleeding_edge/src/hydrogen-instructions.h Thu Dec 22 08:23:47 2011
@@ -3932,10 +3932,6 @@
       return StoringValueNeedsWriteBarrier(value());
     }
   }
-
-  bool ValueNeedsSmiCheck() {
-    return value_is_smi();
-  }

   virtual void PrintDataTo(StringStream* stream);

=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Wed Dec 14 05:01:27 2011
+++ /branches/bleeding_edge/src/hydrogen.cc     Thu Dec 22 08:23:47 2011
@@ -3513,6 +3513,9 @@

     switch (boilerplate_elements_kind) {
       case FAST_SMI_ONLY_ELEMENTS:
+        // Smi-only arrays need a smi check.
+        AddInstruction(new(zone()) HCheckSmi(value));
+        // Fall through.
       case FAST_ELEMENTS:
         AddInstruction(new(zone()) HStoreKeyedFastElement(
             elements,
@@ -4223,12 +4226,20 @@
                                                     bool is_store) {
   if (is_store) {
     ASSERT(val != NULL);
-    if (elements_kind == FAST_DOUBLE_ELEMENTS) {
-      return new(zone()) HStoreKeyedFastDoubleElement(
-          elements, checked_key, val);
-    } else {  // FAST_ELEMENTS or FAST_SMI_ONLY_ELEMENTS.
-      return new(zone()) HStoreKeyedFastElement(
-          elements, checked_key, val, elements_kind);
+    switch (elements_kind) {
+      case FAST_DOUBLE_ELEMENTS:
+        return new(zone()) HStoreKeyedFastDoubleElement(
+            elements, checked_key, val);
+      case FAST_SMI_ONLY_ELEMENTS:
+        // Smi-only arrays need a smi check.
+        AddInstruction(new(zone()) HCheckSmi(val));
+        // Fall through.
+      case FAST_ELEMENTS:
+        return new(zone()) HStoreKeyedFastElement(
+            elements, checked_key, val, elements_kind);
+      default:
+        UNREACHABLE();
+        return NULL;
     }
   }
   // It's an element load (!is_store).
@@ -4399,9 +4410,6 @@
       if (elements_kind == FAST_SMI_ONLY_ELEMENTS ||
           elements_kind == FAST_ELEMENTS ||
           elements_kind == FAST_DOUBLE_ELEMENTS) {
-        if (is_store && elements_kind == FAST_SMI_ONLY_ELEMENTS) {
-          AddInstruction(new(zone()) HCheckSmi(val));
-        }
         if (is_store && elements_kind != FAST_DOUBLE_ELEMENTS) {
           AddInstruction(new(zone()) HCheckMap(
               elements, isolate()->factory()->fixed_array_map(),
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Tue Dec 20 02:57:12 2011 +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Thu Dec 22 08:23:47 2011
@@ -3314,13 +3314,6 @@
   Register value = ToRegister(instr->value());
   Register elements = ToRegister(instr->object());
Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg;
-
- // This instruction cannot handle the FAST_SMI_ONLY_ELEMENTS -> FAST_ELEMENTS
-  // conversion, so it deopts in that case.
-  if (instr->hydrogen()->ValueNeedsSmiCheck()) {
-    __ test(value, Immediate(kSmiTagMask));
-    DeoptimizeIf(not_zero, instr->environment());
-  }

   // Do the store.
   if (instr->key()->IsConstantOperand()) {
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Tue Dec 20 02:57:12 2011 +++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Thu Dec 22 08:23:47 2011
@@ -2023,8 +2023,7 @@
   LOperand* key = needs_write_barrier
       ? UseTempRegister(instr->key())
       : UseRegisterOrConstantAtStart(instr->key());
-
- return AssignEnvironment(new(zone()) LStoreKeyedFastElement(obj, key, val));
+  return new(zone()) LStoreKeyedFastElement(obj, key, val);
 }


=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Tue Dec 20 04:36:36 2011 +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Thu Dec 22 08:23:47 2011
@@ -3310,13 +3310,6 @@
   Register elements = ToRegister(instr->object());
Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg;
   Register scratch = scratch0();
-
- // This instruction cannot handle the FAST_SMI_ONLY_ELEMENTS -> FAST_ELEMENTS
-  // conversion, so it deopts in that case.
-  if (instr->hydrogen()->ValueNeedsSmiCheck()) {
-    __ And(at, value, Operand(kSmiTagMask));
-    DeoptimizeIf(ne, instr->environment(), at, Operand(zero_reg));
-  }

   // Do the store.
   if (instr->key()->IsConstantOperand()) {
=======================================
--- /branches/bleeding_edge/src/mips/lithium-mips.cc Tue Dec 20 04:36:36 2011 +++ /branches/bleeding_edge/src/mips/lithium-mips.cc Thu Dec 22 08:23:47 2011
@@ -1941,8 +1941,7 @@
   LOperand* key = needs_write_barrier
       ? UseTempRegister(instr->key())
       : UseRegisterOrConstantAtStart(instr->key());
-
-  return AssignEnvironment(new LStoreKeyedFastElement(obj, key, val));
+  return new LStoreKeyedFastElement(obj, key, val);
 }


=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Tue Dec 20 02:57:12 2011 +++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Thu Dec 22 08:23:47 2011
@@ -3199,13 +3199,6 @@
   Register value = ToRegister(instr->value());
   Register elements = ToRegister(instr->object());
Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg;
-
- // This instruction cannot handle the FAST_SMI_ONLY_ELEMENTS -> FAST_ELEMENTS
-  // conversion, so it deopts in that case.
-  if (instr->hydrogen()->ValueNeedsSmiCheck()) {
-    Condition cc = masm()->CheckSmi(value);
-    DeoptimizeIf(NegateCondition(cc), instr->environment());
-  }

   // Do the store.
   if (instr->key()->IsConstantOperand()) {
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc      Tue Dec 20 02:57:12 2011
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc      Thu Dec 22 08:23:47 2011
@@ -1929,8 +1929,7 @@
   LOperand* key = needs_write_barrier
       ? UseTempRegister(instr->key())
       : UseRegisterOrConstantAtStart(instr->key());
-
-  return AssignEnvironment(new LStoreKeyedFastElement(obj, key, val));
+  return new LStoreKeyedFastElement(obj, key, val);
 }


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

Reply via email to