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

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

Issue 2096403002: [turbofan] Introduce simplified operator NumberAbs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: This time fix the compile error for realz Created 4 years, 6 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/opcodes.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 6d175780aa5485c1864187545d89b9f35703b73a..81d63924e1c4db8e0e63efa779a3def1d536c82f 100644
--- a/src/compiler/js-builtin-reducer.cc
+++ b/src/compiler/js-builtin-reducer.cc
@@ -91,6 +91,18 @@ JSBuiltinReducer::JSBuiltinReducer(Editor* editor, JSGraph* jsgraph)
jsgraph_(jsgraph),
type_cache_(TypeCache::Get()) {}
+// ES6 section 20.2.2.1 Math.abs ( x )
+Reduction JSBuiltinReducer::ReduceMathAbs(Node* node) {
+ JSCallReduction r(node);
+ if (r.InputsMatchOne(Type::PlainPrimitive())) {
+ // Math.abs(a:plain-primitive) -> NumberAbs(ToNumber(a))
+ Node* input = ToNumber(r.GetJSCallInput(0));
+ Node* value = graph()->NewNode(simplified()->NumberAbs(), input);
+ return Replace(value);
+ }
+ return NoChange();
+}
+
// ES6 section 20.2.2.6 Math.atan ( x )
Reduction JSBuiltinReducer::ReduceMathAtan(Node* node) {
JSCallReduction r(node);
@@ -417,6 +429,9 @@ Reduction JSBuiltinReducer::Reduce(Node* node) {
// Dispatch according to the BuiltinFunctionId if present.
if (!r.HasBuiltinFunctionId()) return NoChange();
switch (r.GetBuiltinFunctionId()) {
+ case kMathAbs:
+ reduction = ReduceMathAbs(node);
+ break;
case kMathAtan:
reduction = ReduceMathAtan(node);
break;
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698