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
This commit is contained in:
serya@chromium.org 2010-04-06 10:40:25 +00:00
parent 889f6cce74
commit eb04a6a95f
3 changed files with 4 additions and 17 deletions

View File

@ -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];

View File

@ -210,7 +210,6 @@ namespace internal {
F(DateYMDFromTime, 2, 1) \
\
/* Numbers */ \
F(NumberIsFinite, 1, 1) \
\
/* Globals */ \
F(CompileString, 2, 1) \

View File

@ -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;
}