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

Unified Diff: src/compiler/js-builtin-reducer.cc

Issue 1852553003: [builtins] Migrate Math.clz32 to a TurboFan builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 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/compiler/js-builtin-reducer.h ('k') | src/compiler/js-intrinsic-lowering.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-builtin-reducer.cc
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc
index c7a2326254fcde55a150d552746b747c887152ef..b5caf9f1fe6ecc3824a487de3359f76bc038d6a4 100644
--- a/src/compiler/js-builtin-reducer.cc
+++ b/src/compiler/js-builtin-reducer.cc
@@ -129,7 +129,7 @@ Reduction JSBuiltinReducer::ReduceMathImul(Node* node) {
return NoChange();
}
-// ES6 draft 08-24-14, section 20.2.2.16.
+// ES6 section 20.2.2.10 Math.ceil ( x )
Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) {
JSCallReduction r(node);
if (r.InputsMatchOne(Type::Number())) {
@@ -140,6 +140,24 @@ Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) {
return NoChange();
}
+// ES6 section 20.2.2.11 Math.clz32 ( x )
+Reduction JSBuiltinReducer::ReduceMathClz32(Node* node) {
+ JSCallReduction r(node);
+ if (r.InputsMatchOne(Type::Unsigned32())) {
+ // Math.clz32(a:unsigned32) -> NumberClz32(a)
+ Node* value = graph()->NewNode(simplified()->NumberClz32(), r.left());
+ return Replace(value);
+ }
+ if (r.InputsMatchOne(Type::Number())) {
+ // Math.clz32(a:number) -> NumberClz32(NumberToUint32(a))
+ Node* value = graph()->NewNode(
+ simplified()->NumberClz32(),
+ graph()->NewNode(simplified()->NumberToUint32(), r.left()));
+ return Replace(value);
+ }
+ return NoChange();
+}
+
// ES6 draft 08-24-14, section 20.2.2.16.
Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) {
JSCallReduction r(node);
@@ -209,6 +227,9 @@ Reduction JSBuiltinReducer::Reduce(Node* node) {
case kMathImul:
reduction = ReduceMathImul(node);
break;
+ case kMathClz32:
+ reduction = ReduceMathClz32(node);
+ break;
case kMathCeil:
reduction = ReduceMathCeil(node);
break;
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/compiler/js-intrinsic-lowering.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698