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

Unified Diff: src/math.js

Issue 1021183002: [turbofan] Turn Math.clz32 into an inlinable builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/math.js
diff --git a/src/math.js b/src/math.js
index dff9390dee6b62e3a6c0191aa53eb9c672f7df94..f2eaa14bf9bd547817497651e859f045b57276cc 100644
--- a/src/math.js
+++ b/src/math.js
@@ -252,17 +252,8 @@ function MathFroundJS(x) {
}
// ES6 draft 07-18-14, section 20.2.2.11
-function MathClz32(x) {
- x = ToUint32(TO_NUMBER_INLINE(x));
- if (x == 0) return 32;
- var result = 0;
- // Binary search.
- if ((x & 0xFFFF0000) === 0) { x <<= 16; result += 16; };
- if ((x & 0xFF000000) === 0) { x <<= 8; result += 8; };
- if ((x & 0xF0000000) === 0) { x <<= 4; result += 4; };
- if ((x & 0xC0000000) === 0) { x <<= 2; result += 2; };
- if ((x & 0x80000000) === 0) { x <<= 1; result += 1; };
- return result;
+function MathClz32JS(x) {
+ return %_MathClz32(x >>> 0);
}
// ES6 draft 09-27-13, section 20.2.2.9.
@@ -345,12 +336,13 @@ InstallFunctions(Math, DONT_ENUM, GlobalArray(
"atanh", MathAtanh,
"hypot", MathHypot,
"fround", MathFroundJS,
- "clz32", MathClz32,
+ "clz32", MathClz32JS,
"cbrt", MathCbrt
));
%SetInlineBuiltinFlag(MathAbs);
%SetInlineBuiltinFlag(MathCeil);
+%SetInlineBuiltinFlag(MathClz32JS);
%SetInlineBuiltinFlag(MathFloorJS);
%SetInlineBuiltinFlag(MathRandom);
%SetInlineBuiltinFlag(MathSqrtJS);
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698