diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 29d4e73cba..a35134952d 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -3955,7 +3955,7 @@ HInstruction* HUnaryMathOperation::New( case kMathFloor: return H_CONSTANT_DOUBLE(std::floor(d)); case kMathClz32: { - uint32_t i = static_cast(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 index 0000000000..c751618928 --- /dev/null +++ b/test/mjsunit/regress/regress-347906.js @@ -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();