Revision: 12376
Author:   [email protected]
Date:     Fri Aug 24 02:06:23 2012
Log:      MIPS: Check that index and length are Smi in bounds check.

Port r12362 (cd39337c)

BUG=
TEST=

Review URL: https://chromiumcodereview.appspot.com/10876053
Patch from Akos Palfi <[email protected]>.
http://code.google.com/p/v8/source/detail?r=12376

Modified:
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc
 /branches/bleeding_edge/src/mips/lithium-codegen-mips.h

=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Tue Aug 21 04:33:49 2012 +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.cc Fri Aug 24 02:06:23 2012
@@ -3658,9 +3658,31 @@
       : isolate()->builtins()->StoreIC_Initialize();
   CallCode(ic, RelocInfo::CODE_TARGET, instr);
 }
+
+
+void LCodeGen::DeoptIfTaggedButNotSmi(LEnvironment* environment,
+                                      HValue* value,
+                                      LOperand* operand) {
+  if (value->representation().IsTagged() && !value->type().IsSmi()) {
+    if (operand->IsRegister()) {
+      __ And(at, ToRegister(operand), Operand(kSmiTagMask));
+      DeoptimizeIf(ne, environment, at, Operand(zero_reg));
+    } else {
+      __ li(at, ToOperand(operand));
+      __ And(at, at, Operand(kSmiTagMask));
+      DeoptimizeIf(ne, environment, at, Operand(zero_reg));
+    }
+  }
+}


 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
+  DeoptIfTaggedButNotSmi(instr->environment(),
+                         instr->hydrogen()->length(),
+                         instr->length());
+  DeoptIfTaggedButNotSmi(instr->environment(),
+                         instr->hydrogen()->index(),
+                         instr->index());
   if (instr->index()->IsConstantOperand()) {
     int constant_index =
         ToInteger32(LConstantOperand::cast(instr->index()));
=======================================
--- /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Wed Jul 25 07:38:32 2012 +++ /branches/bleeding_edge/src/mips/lithium-codegen-mips.h Fri Aug 24 02:06:23 2012
@@ -307,6 +307,10 @@
                         bool deoptimize_on_minus_zero,
                         LEnvironment* env);

+  void DeoptIfTaggedButNotSmi(LEnvironment* environment,
+                              HValue* value,
+                              LOperand* operand);
+
   // Emits optimized code for typeof x == "y".  Modifies input register.
   // Returns the condition on which a final split to
   // true and false label should be made, to optimize fallthrough.

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

Reply via email to