Revision: 4156
Author: [email protected]
Date: Wed Mar 17 02:58:28 2010
Log: Revert r4146. Add a special case in Math.round for a SMI result. Also
change the imp...
[email protected],
Review URL: http://codereview.chromium.org/1042006
http://code.google.com/p/v8/source/detail?r=4156
Modified:
/branches/bleeding_edge/src/runtime.cc
=======================================
--- /branches/bleeding_edge/src/runtime.cc Tue Mar 16 06:23:41 2010
+++ /branches/bleeding_edge/src/runtime.cc Wed Mar 17 02:58:28 2010
@@ -5325,21 +5325,12 @@
NoHandleAllocation ha;
ASSERT(args.length() == 1);
Counters::math_round.Increment();
- CONVERT_DOUBLE_CHECKED(x, args[0]);
-
- if (x > 0 && x < Smi::kMaxValue) {
- return Smi::FromInt(static_cast<int>(x + 0.5));
- }
-
+
+ CONVERT_DOUBLE_CHECKED(x, args[0]);
if (signbit(x) && x >= -0.5) return Heap::minus_zero_value();
-
- // if the magnitude is big enough, there's no place for fraction part.
If we
- // try to add 0.5 to this number, 1.0 will be added instead.
- if (x >= 9007199254740991.0 || x <= -9007199254740991.0) {
- return args[0];
- }
-
- return Heap::NumberFromDouble(floor(x + 0.5));
+ double integer = ceil(x);
+ if (integer - x > 0.5) { integer -= 1.0; }
+ return Heap::NumberFromDouble(integer);
}
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev