Reviewers: rossberg,

Description:
[strong] Fix weird work-around for magic truncating int conversions.

Bitwise operations in strong mode must not magically truncate
oddballs to integers, but must throw in this case.  This basically
disable the whole truncate-to-int32 optimization for strong mode
bitwise operations, but is still better than having to do oddball
checks for every strong bitwise operation (which esp. includes the
BinaryOpIC stubs for that).

[email protected]

Please review this at https://codereview.chromium.org/1288313003/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+4, -19 lines):
  M src/hydrogen.cc
  M src/hydrogen-instructions.h


Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 807a65102940649f0cd132a30b2cef254810323f..4d9e3527dcbe9c9c7791e802eb1c5b5993d2ffe8 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -4155,8 +4155,10 @@ class HBitwiseBinaryOperation : public HBinaryOperation { Strength strength, HType type = HType::TaggedNumber())
       : HBinaryOperation(context, left, right, strength, type) {
     SetFlag(kFlexibleRepresentation);
-    SetFlag(kTruncatingToInt32);
-    if (!is_strong(strength)) SetFlag(kAllowUndefinedAsNaN);
+    if (!is_strong(strength)) {
+      SetFlag(kTruncatingToInt32);
+      SetFlag(kAllowUndefinedAsNaN);
+    }
     SetAllSideEffects();
   }

Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 9b2a2f6a078341f7cacbc40eaec9557450444801..204a300bda4645102ece56251354fb71c67939ac 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -11008,23 +11008,6 @@ HValue* HGraphBuilder::BuildBinaryOperation(
     Add<HPushArguments>(left, right);
     instr = AddUncasted<HInvokeFunction>(function, 2);
   } else {
-    if (is_strong(strength) && Token::IsBitOp(op)) {
-      // TODO(conradw): This is not efficient, but is necessary to prevent
- // conversion of oddball values to numbers in strong mode. It would be - // better to prevent the conversion rather than adding a runtime check.
-      IfBuilder if_builder(this);
-      if_builder.If<HHasInstanceTypeAndBranch>(left, ODDBALL_TYPE);
-      if_builder.OrIf<HHasInstanceTypeAndBranch>(right, ODDBALL_TYPE);
-      if_builder.Then();
-      Add<HCallRuntime>(
-          isolate()->factory()->empty_string(),
- Runtime::FunctionForId(Runtime::kThrowStrongModeImplicitConversion),
-          0);
-      if (!graph()->info()->IsStub()) {
-        Add<HSimulate>(opt_id, REMOVABLE_SIMULATE);
-      }
-      if_builder.End();
-    }
     switch (op) {
       case Token::ADD:
         instr = AddUncasted<HAdd>(left, right, strength);


--
--
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/d/optout.

Reply via email to