MIPS: Handle holes in smi-untag from LoadKeyed requiring hole handling.
authorpalfia@homejinni.com <palfia@homejinni.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 22 May 2013 23:09:22 +0000 (23:09 +0000)
committerpalfia@homejinni.com <palfia@homejinni.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 22 May 2013 23:09:22 +0000 (23:09 +0000)
Port r14756 (fda1989f)

BUG=

Review URL: https://codereview.chromium.org/15690003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14761 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/mips/lithium-codegen-mips.cc
src/mips/lithium-mips.cc
src/mips/lithium-mips.h

index ae0d628..49743fd 100644 (file)
@@ -4610,6 +4610,22 @@ void LCodeGen::DoSmiUntag(LSmiUntag* instr) {
     __ And(scratch, input, Operand(kHeapObjectTag));
     __ SmiUntag(result, input);
     DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg));
+  } else if (instr->hydrogen()->value()->IsLoadKeyed()) {
+    HLoadKeyed* load = HLoadKeyed::cast(instr->hydrogen()->value());
+    if (load->UsesMustHandleHole()) {
+      __ And(scratch, input, Operand(kHeapObjectTag));
+      __ SmiUntag(result, input);
+      if (load->hole_mode() == ALLOW_RETURN_HOLE) {
+        Label done;
+        __ Branch(&done, eq, scratch, Operand(zero_reg));
+        __ li(result, Operand(Smi::FromInt(0)));
+        __ bind(&done);
+      } else {
+        DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg));
+      }
+    } else {
+      __ SmiUntag(result, input);
+    }
   } else {
     __ SmiUntag(result, input);
   }
index 5ca8cd9..04125d1 100644 (file)
@@ -1773,6 +1773,13 @@ LInstruction* LChunkBuilder::DoChange(HChange* instr) {
       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();
index 1abea90..197254f 100644 (file)
@@ -2034,6 +2034,7 @@ class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
   LOperand* value() { return inputs_[0]; }
   bool needs_check() const { return needs_check_; }
 
+  DECLARE_HYDROGEN_ACCESSOR(Change);
   DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag")
 
  private: