Fixed constant folding for Math.clz32.
authorsvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 28 Feb 2014 13:07:10 +0000 (13:07 +0000)
committersvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 28 Feb 2014 13:07:10 +0000 (13:07 +0000)
LOG=y
BUG=347906
R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/184353002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19609 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/hydrogen-instructions.cc
test/mjsunit/regress/regress-347906.js [new file with mode: 0644]

index 29d4e73..a351349 100644 (file)
@@ -3955,7 +3955,7 @@ HInstruction* HUnaryMathOperation::New(
       case kMathFloor:
         return H_CONSTANT_DOUBLE(std::floor(d));
       case kMathClz32: {
-        uint32_t i = static_cast<uint32_t>(constant->Integer32Value());
+        uint32_t i = DoubleToUint32(d);
         return H_CONSTANT_INT(
             (i == 0) ? 32 : CompilerIntrinsics::CountLeadingZeros(i));
       }
diff --git a/test/mjsunit/regress/regress-347906.js b/test/mjsunit/regress/regress-347906.js
new file mode 100644 (file)
index 0000000..c751618
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --allow-natives-syntax --harmony
+
+function foo() {
+  return Math.clz32(12.34);
+}
+
+foo();
+foo();
+%OptimizeFunctionOnNextCall(foo);
+foo();