Reviewers: Jakob,

Message:
PTAL

Description:
Take all uses into account to clear int32 truncation.

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

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

Affected files:
  M src/hydrogen.cc
  A + test/mjsunit/regress/regress-int32-truncation.js


Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 42f5dad0668234cec796fa43dd7c886caced038d..f656fb04b7fcf8efcc01835517f1189901eb5b15 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -3195,9 +3195,8 @@ void HGraph::InsertRepresentationChanges() {
       HValue* use = it.value();
       Representation input_representation =
           use->RequiredInputRepresentation(it.index());
-      if ((input_representation.IsInteger32() &&
-           !use->CheckFlag(HValue::kTruncatingToInt32)) ||
-          input_representation.IsDouble()) {
+      if (!input_representation.IsInteger32() ||
+          !use->CheckFlag(HValue::kTruncatingToInt32)) {
         if (FLAG_trace_representation) {
           PrintF("#%d Phi is not truncating because of #%d %s\n",
                  phi->id(), it.value()->id(), it.value()->Mnemonic());
Index: test/mjsunit/regress/regress-int32-truncation.js
diff --git a/test/mjsunit/regress/regress-2489.js b/test/mjsunit/regress/regress-int32-truncation.js
similarity index 81%
copy from test/mjsunit/regress/regress-2489.js
copy to test/mjsunit/regress/regress-int32-truncation.js
index 882c4f794a88e24d1d64e86a466b27c39f51e625..e245537946445ce332be90b8e48e493355014340 100644
--- a/test/mjsunit/regress/regress-2489.js
+++ b/test/mjsunit/regress/regress-int32-truncation.js
@@ -27,24 +27,35 @@

 // Flags: --allow-natives-syntax

-"use strict";
-
-function f(a, b) {
-  return g("c", "d");
+function f(i, b) {
+  var a = 0;
+  if (b) {
+    var c = 1 << i;
+    a = c + c;
+  }
+  var x = a >> 3;
+  return a;
 }

-function g(a, b) {
-  g.constructor.apply(this, arguments);
-}
+f(1, false);
+f(1, true);
+%OptimizeFunctionOnNextCall(f);
+assertEquals((1<<30)*2, f(30, true));

-g.constructor = function(a, b) {
-  assertEquals("c", a);
-  assertEquals("d", b);
+
+var global = 1;
+
+function f2(b) {
+  var a = 0;
+  if (b) {
+    a = global;
+  }
+  var x = a >> 3;
+  return a;
 }

-f("a", "b");
-f("a", "b");
-%OptimizeFunctionOnNextCall(f);
-f("a", "b");
-g.x = "deopt";
-f("a", "b");
+f2(false);
+f2(true);
+%OptimizeFunctionOnNextCall(f2);
+global = 2.5;
+assertEquals(global, f2(true));


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