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

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

Issue 2063693002: [builtins] Introduce proper Float64Log2 and Float64Log10 operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: More precise log10. 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/machine-operator.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 d2759b5f5b7809bb5a723356b69cfd50cb2803c2..363ad9db4e8ed946858ce5b89c70338c9b9bdf67 100644
--- a/src/compiler/js-builtin-reducer.cc
+++ b/src/compiler/js-builtin-reducer.cc
@@ -259,6 +259,28 @@ Reduction JSBuiltinReducer::ReduceMathMin(Node* node) {
return NoChange();
}
+// ES6 section 20.2.2.23 Math.log2 ( x )
+Reduction JSBuiltinReducer::ReduceMathLog2(Node* node) {
+ JSCallReduction r(node);
+ if (r.InputsMatchOne(Type::Number())) {
+ // Math.log2(a:number) -> NumberLog(a)
+ Node* value = graph()->NewNode(simplified()->NumberLog2(), r.left());
+ return Replace(value);
+ }
+ return NoChange();
+}
+
+// ES6 section 20.2.2.22 Math.log10 ( x )
+Reduction JSBuiltinReducer::ReduceMathLog10(Node* node) {
+ JSCallReduction r(node);
+ if (r.InputsMatchOne(Type::Number())) {
+ // Math.log10(a:number) -> NumberLog10(a)
+ Node* value = graph()->NewNode(simplified()->NumberLog10(), r.left());
+ return Replace(value);
+ }
+ return NoChange();
+}
+
// ES6 section 20.2.2.28 Math.round ( x )
Reduction JSBuiltinReducer::ReduceMathRound(Node* node) {
JSCallReduction r(node);
@@ -341,6 +363,12 @@ Reduction JSBuiltinReducer::Reduce(Node* node) {
case kMathLog1p:
reduction = ReduceMathLog1p(node);
break;
+ case kMathLog2:
+ reduction = ReduceMathLog2(node);
+ break;
+ case kMathLog10:
+ reduction = ReduceMathLog10(node);
+ break;
case kMathMax:
reduction = ReduceMathMax(node);
break;
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/compiler/machine-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698