From eb04a6a95fc32805d5051459b927b98f3818dd97 Mon Sep 17 00:00:00 2001 From: "serya@chromium.org" Date: Tue, 6 Apr 2010 10:40:25 +0000 Subject: [PATCH] JS implementation of isFinite. Review URL: http://codereview.chromium.org/1608003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4344 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/runtime.cc | 15 --------------- src/runtime.h | 1 - src/v8natives.js | 5 ++++- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/runtime.cc b/src/runtime.cc index 4b35924c47..40b37d96e1 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -7100,21 +7100,6 @@ static Object* Runtime_DateDaylightSavingsOffset(Arguments args) { } -static Object* Runtime_NumberIsFinite(Arguments args) { - NoHandleAllocation ha; - ASSERT(args.length() == 1); - - CONVERT_DOUBLE_CHECKED(value, args[0]); - Object* result; - if (isnan(value) || (fpclassify(value) == FP_INFINITE)) { - result = Heap::false_value(); - } else { - result = Heap::true_value(); - } - return result; -} - - static Object* Runtime_GlobalReceiver(Arguments args) { ASSERT(args.length() == 1); Object* global = args[0]; diff --git a/src/runtime.h b/src/runtime.h index a55a27135b..c079345ef9 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -210,7 +210,6 @@ namespace internal { F(DateYMDFromTime, 2, 1) \ \ /* Numbers */ \ - F(NumberIsFinite, 1, 1) \ \ /* Globals */ \ F(CompileString, 2, 1) \ diff --git a/src/v8natives.js b/src/v8natives.js index fc787367ee..86d3ad87c9 100644 --- a/src/v8natives.js +++ b/src/v8natives.js @@ -82,7 +82,10 @@ function GlobalIsNaN(number) { // ECMA 262 - 15.1.5 function GlobalIsFinite(number) { - return %NumberIsFinite(ToNumber(number)); + if (!IS_NUMBER(number)) number = ToNumber(number); + + // NaN - NaN == NaN, Infinity - Infinity == NaN, -Infinity - -Infinity == NaN. + return %_IsSmi(number) || number - number == 0; }