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/compiler/js-builtin-reducer.cc

Issue 2073123002: [builtins] Introduce proper Float64Cos and Float64Sin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix missing breaks 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 c1fb41d0d35afcdda986d50397e37f0b086aa71e..36c6cb40dbed8ade69bb2dbd5276ec4c63d963ac 100644
--- a/src/compiler/js-builtin-reducer.cc
+++ b/src/compiler/js-builtin-reducer.cc
@@ -153,6 +153,18 @@ Reduction JSBuiltinReducer::ReduceMathClz32(Node* node) {
return NoChange();
}
+// ES6 section 20.2.2.12 Math.cos ( x )
+Reduction JSBuiltinReducer::ReduceMathCos(Node* node) {
+ JSCallReduction r(node);
+ if (r.InputsMatchOne(Type::PlainPrimitive())) {
+ // Math.cos(a:plain-primitive) -> NumberCos(ToNumber(a))
+ Node* input = ToNumber(r.GetJSCallInput(0));
+ Node* value = graph()->NewNode(simplified()->NumberCos(), input);
+ return Replace(value);
+ }
+ return NoChange();
+}
+
// ES6 section 20.2.2.14 Math.exp ( x )
Reduction JSBuiltinReducer::ReduceMathExp(Node* node) {
JSCallReduction r(node);
@@ -239,6 +251,28 @@ Reduction JSBuiltinReducer::ReduceMathLog1p(Node* node) {
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.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.24 Math.max ( value1, value2, ...values )
Reduction JSBuiltinReducer::ReduceMathMax(Node* node) {
JSCallReduction r(node);
@@ -293,23 +327,13 @@ 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) {
+// ES6 section 20.2.2.28 Math.round ( x )
+Reduction JSBuiltinReducer::ReduceMathRound(Node* node) {
JSCallReduction r(node);
- if (r.InputsMatchOne(Type::Number())) {
- // Math.log10(a:number) -> NumberLog10(a)
- Node* value = graph()->NewNode(simplified()->NumberLog10(), r.left());
+ if (r.InputsMatchOne(Type::PlainPrimitive())) {
+ // Math.round(a:plain-primitive) -> NumberRound(ToNumber(a))
+ Node* input = ToNumber(r.GetJSCallInput(0));
+ Node* value = graph()->NewNode(simplified()->NumberRound(), input);
return Replace(value);
}
return NoChange();
@@ -326,13 +350,13 @@ Reduction JSBuiltinReducer::ReduceMathCbrt(Node* node) {
return NoChange();
}
-// ES6 section 20.2.2.28 Math.round ( x )
-Reduction JSBuiltinReducer::ReduceMathRound(Node* node) {
+// ES6 section 20.2.2.30 Math.sin ( x )
+Reduction JSBuiltinReducer::ReduceMathSin(Node* node) {
JSCallReduction r(node);
if (r.InputsMatchOne(Type::PlainPrimitive())) {
- // Math.round(a:plain-primitive) -> NumberRound(ToNumber(a))
+ // Math.sin(a:plain-primitive) -> NumberSin(ToNumber(a))
Node* input = ToNumber(r.GetJSCallInput(0));
- Node* value = graph()->NewNode(simplified()->NumberRound(), input);
+ Node* value = graph()->NewNode(simplified()->NumberSin(), input);
return Replace(value);
}
return NoChange();
@@ -396,6 +420,9 @@ Reduction JSBuiltinReducer::Reduce(Node* node) {
case kMathCeil:
reduction = ReduceMathCeil(node);
break;
+ case kMathCos:
+ reduction = ReduceMathCos(node);
+ break;
case kMathExp:
reduction = ReduceMathExp(node);
break;
@@ -417,12 +444,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 kMathLog2:
+ reduction = ReduceMathLog2(node);
+ break;
case kMathMax:
reduction = ReduceMathMax(node);
break;
@@ -435,6 +462,9 @@ Reduction JSBuiltinReducer::Reduce(Node* node) {
case kMathRound:
reduction = ReduceMathRound(node);
break;
+ case kMathSin:
+ reduction = ReduceMathSin(node);
+ break;
case kMathSqrt:
reduction = ReduceMathSqrt(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