Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: src/v8natives.js

Issue 1608003: JS implementation of isFinite. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 75
76 // ECMA 262 - 15.1.4 76 // ECMA 262 - 15.1.4
77 function GlobalIsNaN(number) { 77 function GlobalIsNaN(number) {
78 var n = ToNumber(number); 78 var n = ToNumber(number);
79 return NUMBER_IS_NAN(n); 79 return NUMBER_IS_NAN(n);
80 } 80 }
81 81
82 82
83 // ECMA 262 - 15.1.5 83 // ECMA 262 - 15.1.5
84 function GlobalIsFinite(number) { 84 function GlobalIsFinite(number) {
85 return %NumberIsFinite(ToNumber(number)); 85 if (!IS_NUMBER(number)) number = ToNumber(number);
86
87 // NaN - NaN == NaN, Infinity - Infinity == NaN, -Infinity - -Infinity == NaN.
88 return %_IsSmi(number) || number - number == 0;
86 } 89 }
87 90
88 91
89 // ECMA-262 - 15.1.2.2 92 // ECMA-262 - 15.1.2.2
90 function GlobalParseInt(string, radix) { 93 function GlobalParseInt(string, radix) {
91 if (IS_UNDEFINED(radix)) { 94 if (IS_UNDEFINED(radix)) {
92 // Some people use parseInt instead of Math.floor. This 95 // Some people use parseInt instead of Math.floor. This
93 // optimization makes parseInt on a Smi 12 times faster (60ns 96 // optimization makes parseInt on a Smi 12 times faster (60ns
94 // vs 800ns). The following optimization makes parseInt on a 97 // vs 800ns). The following optimization makes parseInt on a
95 // non-Smi number 9 times faster (230ns vs 2070ns). Together 98 // non-Smi number 9 times faster (230ns vs 2070ns). Together
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 1001
999 // ---------------------------------------------------------------------------- 1002 // ----------------------------------------------------------------------------
1000 1003
1001 function SetupFunction() { 1004 function SetupFunction() {
1002 InstallFunctions($Function.prototype, DONT_ENUM, $Array( 1005 InstallFunctions($Function.prototype, DONT_ENUM, $Array(
1003 "toString", FunctionToString 1006 "toString", FunctionToString
1004 )); 1007 ));
1005 } 1008 }
1006 1009
1007 SetupFunction(); 1010 SetupFunction();
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698