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

Side by Side Diff: src/compiler/js-builtin-reducer.cc

Issue 594183004: Extend JSBuiltinReducer to cover Math.fround as well. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Benedikt. Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/compiler/js-builtin-reducer-unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/graph-inl.h" 5 #include "src/compiler/graph-inl.h"
6 #include "src/compiler/js-builtin-reducer.h" 6 #include "src/compiler/js-builtin-reducer.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties-inl.h" 8 #include "src/compiler/node-properties-inl.h"
9 #include "src/types.h" 9 #include "src/types.h"
10 10
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 JSCallReduction r(node); 144 JSCallReduction r(node);
145 if (r.InputsMatchTwo(Type::Integral32(), Type::Integral32())) { 145 if (r.InputsMatchTwo(Type::Integral32(), Type::Integral32())) {
146 // Math.imul(a:int32, b:int32) -> Int32Mul(a, b) 146 // Math.imul(a:int32, b:int32) -> Int32Mul(a, b)
147 Node* value = graph()->NewNode(machine()->Int32Mul(), r.left(), r.right()); 147 Node* value = graph()->NewNode(machine()->Int32Mul(), r.left(), r.right());
148 return Replace(value); 148 return Replace(value);
149 } 149 }
150 return NoChange(); 150 return NoChange();
151 } 151 }
152 152
153 153
154 // ES6 draft 08-24-14, section 20.2.2.17.
155 Reduction JSBuiltinReducer::ReduceMathFround(Node* node) {
156 JSCallReduction r(node);
157 if (r.InputsMatchOne(Type::Number())) {
158 // Math.fround(a:number) -> TruncateFloat64ToFloat32(a)
159 Node* value =
160 graph()->NewNode(machine()->TruncateFloat64ToFloat32(), r.left());
161 return Replace(value);
162 }
163 return NoChange();
164 }
165
166
154 Reduction JSBuiltinReducer::Reduce(Node* node) { 167 Reduction JSBuiltinReducer::Reduce(Node* node) {
155 JSCallReduction r(node); 168 JSCallReduction r(node);
156 169
157 // Dispatch according to the BuiltinFunctionId if present. 170 // Dispatch according to the BuiltinFunctionId if present.
158 if (!r.HasBuiltinFunctionId()) return NoChange(); 171 if (!r.HasBuiltinFunctionId()) return NoChange();
159 switch (r.GetBuiltinFunctionId()) { 172 switch (r.GetBuiltinFunctionId()) {
160 case kMathSqrt: 173 case kMathSqrt:
161 return ReplaceWithPureReduction(node, ReduceMathSqrt(node)); 174 return ReplaceWithPureReduction(node, ReduceMathSqrt(node));
162 case kMathMax: 175 case kMathMax:
163 return ReplaceWithPureReduction(node, ReduceMathMax(node)); 176 return ReplaceWithPureReduction(node, ReduceMathMax(node));
164 case kMathImul: 177 case kMathImul:
165 return ReplaceWithPureReduction(node, ReduceMathImul(node)); 178 return ReplaceWithPureReduction(node, ReduceMathImul(node));
179 case kMathFround:
180 return ReplaceWithPureReduction(node, ReduceMathFround(node));
166 default: 181 default:
167 break; 182 break;
168 } 183 }
169 return NoChange(); 184 return NoChange();
170 } 185 }
171 186
172 } // namespace compiler 187 } // namespace compiler
173 } // namespace internal 188 } // namespace internal
174 } // namespace v8 189 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/compiler/js-builtin-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698