Revision: 14756
Author:   [email protected]
Date:     Wed May 22 09:32:33 2013
Log:      Handle holes in smi-untag from LoadKeyed requiring hole handling.

[email protected]

Review URL: https://chromiumcodereview.appspot.com/15737003
http://code.google.com/p/v8/source/detail?r=14756

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

=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.cc      Thu May 16 07:27:39 2013
+++ /branches/bleeding_edge/src/arm/lithium-arm.cc      Wed May 22 09:32:33 2013
@@ -1900,6 +1900,13 @@
       if (instr->value()->type().IsSmi()) {
         value = UseRegisterAtStart(instr->value());
         res = DefineAsRegister(new(zone()) LSmiUntag(value, false));
+        if (instr->value()->IsLoadKeyed()) {
+          HLoadKeyed* load_keyed = HLoadKeyed::cast(instr->value());
+          if (load_keyed->UsesMustHandleHole() &&
+              load_keyed->hole_mode() == NEVER_RETURN_HOLE) {
+            res = AssignEnvironment(res);
+          }
+        }
       } else {
         value = UseRegister(instr->value());
         LOperand* temp1 = TempRegister();
=======================================
--- /branches/bleeding_edge/src/arm/lithium-arm.h       Wed May 15 07:24:47 2013
+++ /branches/bleeding_edge/src/arm/lithium-arm.h       Wed May 22 09:32:33 2013
@@ -2087,6 +2087,7 @@
   LOperand* value() { return inputs_[0]; }
   bool needs_check() const { return needs_check_; }

+  DECLARE_HYDROGEN_ACCESSOR(Change);
   DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")

  private:
=======================================
--- /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Fri May 17 08:38:14 2013 +++ /branches/bleeding_edge/src/arm/lithium-codegen-arm.cc Wed May 22 09:32:33 2013
@@ -4905,6 +4905,21 @@
     // If the input is a HeapObject, SmiUntag will set the carry flag.
     __ SmiUntag(result, input, SetCC);
     DeoptimizeIf(cs, instr->environment());
+  } else if (instr->hydrogen()->value()->IsLoadKeyed()) {
+    HLoadKeyed* load = HLoadKeyed::cast(instr->hydrogen()->value());
+    if (load->UsesMustHandleHole()) {
+      __ SmiUntag(result, input, SetCC);
+      if (load->hole_mode() == ALLOW_RETURN_HOLE) {
+        Label done;
+        __ b(cc, &done);
+        __ mov(result, Operand(Smi::FromInt(0)));
+        __ bind(&done);
+      } else {
+        DeoptimizeIf(cs, instr->environment());
+      }
+    } else {
+      __ SmiUntag(result, input);
+    }
   } else {
     __ SmiUntag(result, input);
   }
=======================================
--- /branches/bleeding_edge/src/hydrogen-instructions.h Wed May 22 08:33:53 2013 +++ /branches/bleeding_edge/src/hydrogen-instructions.h Wed May 22 09:32:33 2013
@@ -5411,7 +5411,7 @@
              IsFastDoubleElementsKind(elements_kind));

       if (IsFastSmiOrObjectElementsKind(elements_kind)) {
-        if (elements_kind == FAST_SMI_ELEMENTS) {
+        if (IsFastSmiElementsKind(elements_kind)) {
           set_type(HType::Smi());
         }

=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Wed May 15 07:24:47 2013 +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Wed May 22 09:32:33 2013
@@ -5026,14 +5026,30 @@

 void LCodeGen::DoSmiUntag(LSmiUntag* instr) {
   LOperand* input = instr->value();
+  Register result = ToRegister(input);
   ASSERT(input->IsRegister() && input->Equals(instr->result()));
   if (instr->needs_check()) {
-    __ test(ToRegister(input), Immediate(kSmiTagMask));
+    __ test(result, Immediate(kSmiTagMask));
     DeoptimizeIf(not_zero, instr->environment());
+  } else if (instr->hydrogen()->value()->IsLoadKeyed()) {
+    HLoadKeyed* load = HLoadKeyed::cast(instr->hydrogen()->value());
+    if (load->UsesMustHandleHole()) {
+      __ test(result, Immediate(kSmiTagMask));
+      if (load->hole_mode() == ALLOW_RETURN_HOLE) {
+        Label done;
+        __ j(equal, &done);
+        __ xor_(result, result);
+        __ bind(&done);
+      } else {
+        DeoptimizeIf(not_zero, instr->environment());
+      }
+    } else {
+      __ AssertSmi(result);
+    }
   } else {
-    __ AssertSmi(ToRegister(input));
+    __ AssertSmi(result);
   }
-  __ SmiUntag(ToRegister(input));
+  __ SmiUntag(result);
 }


=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.cc Thu May 16 07:27:39 2013 +++ /branches/bleeding_edge/src/ia32/lithium-ia32.cc Wed May 22 09:32:33 2013
@@ -1929,7 +1929,16 @@
       ASSERT(to.IsInteger32());
       if (instr->value()->type().IsSmi()) {
         LOperand* value = UseRegister(instr->value());
-        return DefineSameAsFirst(new(zone()) LSmiUntag(value, false));
+        LInstruction* result =
+            DefineSameAsFirst(new(zone()) LSmiUntag(value, false));
+        if (instr->value()->IsLoadKeyed()) {
+          HLoadKeyed* load_keyed = HLoadKeyed::cast(instr->value());
+          if (load_keyed->UsesMustHandleHole() &&
+              load_keyed->hole_mode() == NEVER_RETURN_HOLE) {
+            return AssignEnvironment(result);
+          }
+        }
+        return result;
       } else {
         bool truncating = instr->CanTruncateToInt32();
         if (CpuFeatures::IsSafeForSnapshot(SSE2)) {
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-ia32.h     Wed May 15 07:24:47 2013
+++ /branches/bleeding_edge/src/ia32/lithium-ia32.h     Wed May 22 09:32:33 2013
@@ -2153,6 +2153,7 @@
   LOperand* value() { return inputs_[0]; }

   DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
+  DECLARE_HYDROGEN_ACCESSOR(Change);

   bool needs_check() const { return needs_check_; }

=======================================
--- /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Wed May 15 07:24:47 2013 +++ /branches/bleeding_edge/src/x64/lithium-codegen-x64.cc Wed May 22 09:32:33 2013
@@ -4606,6 +4606,21 @@
   if (instr->needs_check()) {
     Condition is_smi = __ CheckSmi(input);
     DeoptimizeIf(NegateCondition(is_smi), instr->environment());
+  } else if (instr->hydrogen()->value()->IsLoadKeyed()) {
+    HLoadKeyed* load = HLoadKeyed::cast(instr->hydrogen()->value());
+    if (load->UsesMustHandleHole()) {
+      Condition cc = masm()->CheckSmi(input);
+      if (load->hole_mode() == ALLOW_RETURN_HOLE) {
+        Label done;
+        __ j(cc, &done);
+        __ xor_(input, input);
+        __ bind(&done);
+      } else {
+        DeoptimizeIf(NegateCondition(cc), instr->environment());
+      }
+    } else {
+      __ AssertSmi(input);
+    }
   } else {
     __ AssertSmi(input);
   }
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.cc      Wed May 15 07:24:47 2013
+++ /branches/bleeding_edge/src/x64/lithium-x64.cc      Wed May 22 09:32:33 2013
@@ -1825,7 +1825,16 @@
       ASSERT(to.IsInteger32());
       LOperand* value = UseRegister(instr->value());
       if (instr->value()->type().IsSmi()) {
-        return DefineSameAsFirst(new(zone()) LSmiUntag(value, false));
+        LInstruction* result =
+            DefineSameAsFirst(new(zone()) LSmiUntag(value, false));
+        if (instr->value()->IsLoadKeyed()) {
+          HLoadKeyed* load_keyed = HLoadKeyed::cast(instr->value());
+          if (load_keyed->UsesMustHandleHole() &&
+              load_keyed->hole_mode() == NEVER_RETURN_HOLE) {
+            return AssignEnvironment(result);
+          }
+        }
+        return result;
       } else {
         bool truncating = instr->CanTruncateToInt32();
         LOperand* xmm_temp = truncating ? NULL : FixedTemp(xmm1);
=======================================
--- /branches/bleeding_edge/src/x64/lithium-x64.h       Wed May 15 07:24:47 2013
+++ /branches/bleeding_edge/src/x64/lithium-x64.h       Wed May 22 09:32:33 2013
@@ -2011,6 +2011,7 @@
   LOperand* value() { return inputs_[0]; }
   bool needs_check() const { return needs_check_; }

+  DECLARE_HYDROGEN_ACCESSOR(Change);
   DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")

  private:

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to