Reviewers: fschneider,

Description:
Prohibit moving instructions with side effects via 'EmitAtUses'.

It's not generally safe to decide to delay the evaluation of an expression
with side effects until it is used.

BUG=v8:1138

Please review this at http://codereview.chromium.org/6474035/

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

Affected files:
  M src/hydrogen-instructions.h


Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index d6d5cfb891f1dbffc7f85d7c82ef87b33f804811..701813133c4795807d4d070fe915fc0a074ece9b 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -2208,7 +2208,11 @@ class HCompare: public HBinaryOperation {
   }

   void SetInputRepresentation(Representation r);
-  virtual bool EmitAtUses() const { return uses()->length() <= 1; }
+
+  virtual bool EmitAtUses() const {
+    return !HasSideEffects() && (uses()->length() <= 1);
+  }
+
   virtual Representation RequiredInputRepresentation(int index) const {
     return input_representation_;
   }
@@ -2246,7 +2250,10 @@ class HCompareJSObjectEq: public HBinaryOperation {
     SetFlag(kUseGVN);
   }

-  virtual bool EmitAtUses() const { return uses()->length() <= 1; }
+  virtual bool EmitAtUses() const {
+    return !HasSideEffects() && (uses()->length() <= 1);
+  }
+
   virtual Representation RequiredInputRepresentation(int index) const {
     return Representation::Tagged();
   }
@@ -2265,7 +2272,11 @@ class HUnaryPredicate: public HUnaryOperation {
     set_representation(Representation::Tagged());
     SetFlag(kUseGVN);
   }
-  virtual bool EmitAtUses() const { return uses()->length() <= 1; }
+
+  virtual bool EmitAtUses() const {
+    return !HasSideEffects() && (uses()->length() <= 1);
+  }
+
   virtual Representation RequiredInputRepresentation(int index) const {
     return Representation::Tagged();
   }
@@ -2322,7 +2333,9 @@ class HIsConstructCall: public HInstruction {
     SetFlag(kUseGVN);
   }

-  virtual bool EmitAtUses() const { return uses()->length() <= 1; }
+  virtual bool EmitAtUses() const {
+    return !HasSideEffects() && (uses()->length() <= 1);
+  }

   DECLARE_CONCRETE_INSTRUCTION(IsConstructCall, "is_construct_call")

@@ -2427,7 +2440,9 @@ class HInstanceOf: public HInstruction {
   HValue* left() const { return operands_[1]; }
   HValue* right() const { return operands_[2]; }

-  virtual bool EmitAtUses() const { return uses()->length() <= 1; }
+  virtual bool EmitAtUses() const {
+    return !HasSideEffects() && (uses()->length() <= 1);
+  }

   virtual Representation RequiredInputRepresentation(int index) const {
     return Representation::Tagged();


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

Reply via email to