Reviewers: Jakob,

Message:
PTAL

Description:
Handle holes in smi-untag from LoadKeyed requiring hole handling.

Please review this at https://chromiumcodereview.appspot.com/15737003/

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

Affected files:
  M src/arm/lithium-arm.h
  M src/arm/lithium-codegen-arm.cc
  M src/hydrogen-instructions.h
  M src/ia32/lithium-codegen-ia32.cc
  M src/ia32/lithium-ia32.h
  M src/x64/lithium-codegen-x64.cc
  M src/x64/lithium-x64.h


Index: src/arm/lithium-arm.h
diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h
index 9bcd44ae05e1e8557e2280c2e4e760cff92f7c44..c9d61b9f49dcf1c258486f2eff1ca6aa38da074f 100644
--- a/src/arm/lithium-arm.h
+++ b/src/arm/lithium-arm.h
@@ -2087,6 +2087,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:
Index: src/arm/lithium-codegen-arm.cc
diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc
index 09a0e9c066fcc671526ee5dd344a2cd6016c2691..ee8aac98158ec37be3c72a17114212dcc6ef5444 100644
--- a/src/arm/lithium-codegen-arm.cc
+++ b/src/arm/lithium-codegen-arm.cc
@@ -4905,6 +4905,17 @@ void LCodeGen::DoSmiUntag(LSmiUntag* instr) {
     // 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()) {
+      Label done;
+      __ SmiUntag(result, input, SetCC);
+      __ b(cc, &done);
+      __ mov(result, Operand(Smi::FromInt(0)));
+      __ bind(&done);
+    } else {
+      __ SmiUntag(result, input);
+    }
   } else {
     __ SmiUntag(result, input);
   }
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index d06e3184f817f2849d6e53395e3bff72aa061621..5e26333f7ae881b5dc1c537f1cc78cdb6ccd2a28 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -5411,7 +5411,7 @@ class HLoadKeyed
              IsFastDoubleElementsKind(elements_kind));

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

Index: src/ia32/lithium-codegen-ia32.cc
diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index b6244af4129a3349a7df107922128d18706631c9..b9951ea699e242274357215d103063c01ab6369b 100644
--- a/src/ia32/lithium-codegen-ia32.cc
+++ b/src/ia32/lithium-codegen-ia32.cc
@@ -5026,14 +5026,26 @@ void LCodeGen::DoSmiTag(LSmiTag* instr) {

 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()) {
+      Label done;
+      __ test(result, Immediate(kSmiTagMask));
+      __ j(equal, &done);
+      __ xor_(result, result);
+      __ bind(&done);
+    } else {
+      __ AssertSmi(result);
+    }
   } else {
-    __ AssertSmi(ToRegister(input));
+    __ AssertSmi(result);
   }
-  __ SmiUntag(ToRegister(input));
+  __ SmiUntag(result);
 }


Index: src/ia32/lithium-ia32.h
diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h
index b32ead91381f804c6a82ab51a7623c05b3642c89..a7d9fb4a762711b6bbdd8eedc627581f8a69ee9c 100644
--- a/src/ia32/lithium-ia32.h
+++ b/src/ia32/lithium-ia32.h
@@ -2153,6 +2153,7 @@ class LSmiUntag: public LTemplateInstruction<1, 1, 0> {
   LOperand* value() { return inputs_[0]; }

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

   bool needs_check() const { return needs_check_; }

Index: src/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index 9a1ce9800993d683dc04ea27bee12b54b70c9168..ff2e2b16a5d8c67bc6e1d1e9394be5f65e320da7 100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -4606,6 +4606,17 @@ void LCodeGen::DoSmiUntag(LSmiUntag* instr) {
   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()) {
+      Label done;
+      Condition cc = masm()->CheckSmi(input);
+      __ j(cc, &done);
+      __ xor_(input, input);
+      __ bind(&done);
+    } else {
+      __ AssertSmi(input);
+    }
   } else {
     __ AssertSmi(input);
   }
Index: src/x64/lithium-x64.h
diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h
index 747d8e73d48c640766c4f9e6830894c62f8d94b8..9926fc38749c8edcb1385d55f14dbb1a78957387 100644
--- a/src/x64/lithium-x64.h
+++ b/src/x64/lithium-x64.h
@@ -2011,6 +2011,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:


--
--
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