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

Side by Side Diff: src/math.js

Issue 509007: Optimize implementation of Math.floor a little by special casing... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years 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
« src/ia32/codegen-ia32.cc ('K') | « src/macros.py ('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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 function MathExp(x) { 91 function MathExp(x) {
92 if (!IS_NUMBER(x)) x = ToNumber(x); 92 if (!IS_NUMBER(x)) x = ToNumber(x);
93 return %Math_exp(x); 93 return %Math_exp(x);
94 } 94 }
95 95
96 // ECMA 262 - 15.8.2.9 96 // ECMA 262 - 15.8.2.9
97 function MathFloor(x) { 97 function MathFloor(x) {
98 if (!IS_NUMBER(x)) x = ToNumber(x); 98 if (!IS_NUMBER(x)) x = ToNumber(x);
99 // It's more common to call this with a positive number that's out 99 // It's more common to call this with a positive number that's out
100 // of range than negative numbers; check the upper bound first. 100 // of range than negative numbers; check the upper bound first.
101 if (x <= 0x7FFFFFFF && x > 0) { 101 if (x < 0x80000000 && x > 0) {
102 // Numbers in the range [0, 2^31) can be floored by converting 102 // Numbers in the range [0, 2^31) can be floored by converting
103 // them to an unsigned 32-bit value using the shift operator. 103 // them to an unsigned 32-bit value using the shift operator.
104 // We avoid doing so for -0, because the result of Math.floor(-0) 104 // We avoid doing so for -0, because the result of Math.floor(-0)
105 // has to be -0, which wouldn't be the case with the shift. 105 // has to be -0, which wouldn't be the case with the shift.
106 return x << 0; 106 return x << 0;
107 } else { 107 } else {
108 return %Math_floor(x); 108 return %Math_floor(x);
109 } 109 }
110 } 110 }
111 111
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 "tan", MathTan, 254 "tan", MathTan,
255 "atan2", MathAtan2, 255 "atan2", MathAtan2,
256 "pow", MathPow, 256 "pow", MathPow,
257 "max", MathMax, 257 "max", MathMax,
258 "min", MathMin 258 "min", MathMin
259 )); 259 ));
260 }; 260 };
261 261
262 262
263 SetupMath(); 263 SetupMath();
OLDNEW
« src/ia32/codegen-ia32.cc ('K') | « src/macros.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698