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

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

Issue 990963003: [turbofan] Unify Math.floor / Math.ceil optimization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 unified diff | 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 »
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/diamond.h" 5 #include "src/compiler/diamond.h"
6 #include "src/compiler/js-builtin-reducer.h" 6 #include "src/compiler/js-builtin-reducer.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 #include "src/types.h" 10 #include "src/types.h"
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 Node* value = 179 Node* value =
180 graph()->NewNode(machine()->TruncateFloat64ToFloat32(), r.left()); 180 graph()->NewNode(machine()->TruncateFloat64ToFloat32(), r.left());
181 return Replace(value); 181 return Replace(value);
182 } 182 }
183 return NoChange(); 183 return NoChange();
184 } 184 }
185 185
186 186
187 // ES6 draft 10-14-14, section 20.2.2.16. 187 // ES6 draft 10-14-14, section 20.2.2.16.
188 Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) { 188 Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) {
189 if (!machine()->HasFloat64Floor()) return NoChange(); 189 if (!machine()->HasFloat64RoundDown()) return NoChange();
190 JSCallReduction r(node); 190 JSCallReduction r(node);
191 if (r.InputsMatchOne(Type::Number())) { 191 if (r.InputsMatchOne(Type::Number())) {
192 // Math.floor(a:number) -> Float64Floor(a) 192 // Math.floor(a:number) -> Float64RoundDown(a)
193 Node* value = graph()->NewNode(machine()->Float64Floor(), r.left()); 193 Node* value = graph()->NewNode(machine()->Float64RoundDown(), r.left());
194 return Replace(value); 194 return Replace(value);
195 } 195 }
196 return NoChange(); 196 return NoChange();
197 }
198
199
200 // ES6 draft 10-14-14, section 20.2.2.10.
201 Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) {
202 if (!machine()->HasFloat64Ceil()) return NoChange();
203 JSCallReduction r(node);
204 if (r.InputsMatchOne(Type::Number())) {
205 // Math.ceil(a:number) -> Float64Ceil(a)
206 Node* value = graph()->NewNode(machine()->Float64Ceil(), r.left());
207 return Replace(value);
208 }
209 return NoChange();
210 } 197 }
211 198
212 199
213 Reduction JSBuiltinReducer::Reduce(Node* node) { 200 Reduction JSBuiltinReducer::Reduce(Node* node) {
214 JSCallReduction r(node); 201 JSCallReduction r(node);
215 202
216 // Dispatch according to the BuiltinFunctionId if present. 203 // Dispatch according to the BuiltinFunctionId if present.
217 if (!r.HasBuiltinFunctionId()) return NoChange(); 204 if (!r.HasBuiltinFunctionId()) return NoChange();
218 switch (r.GetBuiltinFunctionId()) { 205 switch (r.GetBuiltinFunctionId()) {
219 case kMathAbs: 206 case kMathAbs:
220 return ReplaceWithPureReduction(node, ReduceMathAbs(node)); 207 return ReplaceWithPureReduction(node, ReduceMathAbs(node));
221 case kMathSqrt: 208 case kMathSqrt:
222 return ReplaceWithPureReduction(node, ReduceMathSqrt(node)); 209 return ReplaceWithPureReduction(node, ReduceMathSqrt(node));
223 case kMathMax: 210 case kMathMax:
224 return ReplaceWithPureReduction(node, ReduceMathMax(node)); 211 return ReplaceWithPureReduction(node, ReduceMathMax(node));
225 case kMathImul: 212 case kMathImul:
226 return ReplaceWithPureReduction(node, ReduceMathImul(node)); 213 return ReplaceWithPureReduction(node, ReduceMathImul(node));
227 case kMathFround: 214 case kMathFround:
228 return ReplaceWithPureReduction(node, ReduceMathFround(node)); 215 return ReplaceWithPureReduction(node, ReduceMathFround(node));
229 case kMathFloor: 216 case kMathFloor:
230 return ReplaceWithPureReduction(node, ReduceMathFloor(node)); 217 return ReplaceWithPureReduction(node, ReduceMathFloor(node));
231 case kMathCeil:
232 return ReplaceWithPureReduction(node, ReduceMathCeil(node));
233 default: 218 default:
234 break; 219 break;
235 } 220 }
236 return NoChange(); 221 return NoChange();
237 } 222 }
238 223
239 224
240 Graph* JSBuiltinReducer::graph() const { return jsgraph()->graph(); } 225 Graph* JSBuiltinReducer::graph() const { return jsgraph()->graph(); }
241 226
242 227
243 CommonOperatorBuilder* JSBuiltinReducer::common() const { 228 CommonOperatorBuilder* JSBuiltinReducer::common() const {
244 return jsgraph()->common(); 229 return jsgraph()->common();
245 } 230 }
246 231
247 232
248 MachineOperatorBuilder* JSBuiltinReducer::machine() const { 233 MachineOperatorBuilder* JSBuiltinReducer::machine() const {
249 return jsgraph()->machine(); 234 return jsgraph()->machine();
250 } 235 }
251 236
252 } // namespace compiler 237 } // namespace compiler
253 } // namespace internal 238 } // namespace internal
254 } // namespace v8 239 } // namespace v8
OLDNEW
« 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