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

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

Issue 2068743002: [builtins] Unify Atanh, Cbrt and Expm1 as exports from flibm. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed type warning. 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 unified diff | 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 »
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/js-builtin-reducer.h" 5 #include "src/compiler/js-builtin-reducer.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 #include "src/compiler/simplified-operator.h" 9 #include "src/compiler/simplified-operator.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // b:plain-primitive) -> NumberAtan2(ToNumber(a), 111 // b:plain-primitive) -> NumberAtan2(ToNumber(a),
112 // ToNumber(b)) 112 // ToNumber(b))
113 Node* left = ToNumber(r.left()); 113 Node* left = ToNumber(r.left());
114 Node* right = ToNumber(r.right()); 114 Node* right = ToNumber(r.right());
115 Node* value = graph()->NewNode(simplified()->NumberAtan2(), left, right); 115 Node* value = graph()->NewNode(simplified()->NumberAtan2(), left, right);
116 return Replace(value); 116 return Replace(value);
117 } 117 }
118 return NoChange(); 118 return NoChange();
119 } 119 }
120 120
121 // ES6 section 20.2.2.7 Math.atanh ( x )
122 Reduction JSBuiltinReducer::ReduceMathAtanh(Node* node) {
123 JSCallReduction r(node);
124 if (r.InputsMatchOne(Type::Number())) {
125 // Math.atanh(a:number) -> NumberAtanh(a)
126 Node* value = graph()->NewNode(simplified()->NumberAtanh(), r.left());
127 return Replace(value);
128 }
129 return NoChange();
130 }
131
121 // ES6 section 20.2.2.10 Math.ceil ( x ) 132 // ES6 section 20.2.2.10 Math.ceil ( x )
122 Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) { 133 Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) {
123 JSCallReduction r(node); 134 JSCallReduction r(node);
124 if (r.InputsMatchOne(Type::PlainPrimitive())) { 135 if (r.InputsMatchOne(Type::PlainPrimitive())) {
125 // Math.ceil(a:plain-primitive) -> NumberCeil(ToNumber(a)) 136 // Math.ceil(a:plain-primitive) -> NumberCeil(ToNumber(a))
126 Node* input = ToNumber(r.GetJSCallInput(0)); 137 Node* input = ToNumber(r.GetJSCallInput(0));
127 Node* value = graph()->NewNode(simplified()->NumberCeil(), input); 138 Node* value = graph()->NewNode(simplified()->NumberCeil(), input);
128 return Replace(value); 139 return Replace(value);
129 } 140 }
130 return NoChange(); 141 return NoChange();
(...skipping 16 matching lines...) Expand all
147 JSCallReduction r(node); 158 JSCallReduction r(node);
148 if (r.InputsMatchOne(Type::PlainPrimitive())) { 159 if (r.InputsMatchOne(Type::PlainPrimitive())) {
149 // Math.exp(a:plain-primitive) -> NumberExp(ToNumber(a)) 160 // Math.exp(a:plain-primitive) -> NumberExp(ToNumber(a))
150 Node* input = ToNumber(r.GetJSCallInput(0)); 161 Node* input = ToNumber(r.GetJSCallInput(0));
151 Node* value = graph()->NewNode(simplified()->NumberExp(), input); 162 Node* value = graph()->NewNode(simplified()->NumberExp(), input);
152 return Replace(value); 163 return Replace(value);
153 } 164 }
154 return NoChange(); 165 return NoChange();
155 } 166 }
156 167
168 // ES6 section 20.2.2.15 Math.expm1 ( x )
169 Reduction JSBuiltinReducer::ReduceMathExpm1(Node* node) {
170 JSCallReduction r(node);
171 if (r.InputsMatchOne(Type::Number())) {
172 // Math.expm1(a:number) -> NumberExpm1(a)
173 Node* value = graph()->NewNode(simplified()->NumberExpm1(), r.left());
174 return Replace(value);
175 }
176 return NoChange();
177 }
178
157 // ES6 section 20.2.2.16 Math.floor ( x ) 179 // ES6 section 20.2.2.16 Math.floor ( x )
158 Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) { 180 Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) {
159 JSCallReduction r(node); 181 JSCallReduction r(node);
160 if (r.InputsMatchOne(Type::PlainPrimitive())) { 182 if (r.InputsMatchOne(Type::PlainPrimitive())) {
161 // Math.floor(a:plain-primitive) -> NumberFloor(ToNumber(a)) 183 // Math.floor(a:plain-primitive) -> NumberFloor(ToNumber(a))
162 Node* input = ToNumber(r.GetJSCallInput(0)); 184 Node* input = ToNumber(r.GetJSCallInput(0));
163 Node* value = graph()->NewNode(simplified()->NumberFloor(), input); 185 Node* value = graph()->NewNode(simplified()->NumberFloor(), input);
164 return Replace(value); 186 return Replace(value);
165 } 187 }
166 return NoChange(); 188 return NoChange();
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 Reduction JSBuiltinReducer::ReduceMathLog10(Node* node) { 308 Reduction JSBuiltinReducer::ReduceMathLog10(Node* node) {
287 JSCallReduction r(node); 309 JSCallReduction r(node);
288 if (r.InputsMatchOne(Type::Number())) { 310 if (r.InputsMatchOne(Type::Number())) {
289 // Math.log10(a:number) -> NumberLog10(a) 311 // Math.log10(a:number) -> NumberLog10(a)
290 Node* value = graph()->NewNode(simplified()->NumberLog10(), r.left()); 312 Node* value = graph()->NewNode(simplified()->NumberLog10(), r.left());
291 return Replace(value); 313 return Replace(value);
292 } 314 }
293 return NoChange(); 315 return NoChange();
294 } 316 }
295 317
318 // ES6 section 20.2.2.9 Math.cbrt ( x )
319 Reduction JSBuiltinReducer::ReduceMathCbrt(Node* node) {
320 JSCallReduction r(node);
321 if (r.InputsMatchOne(Type::Number())) {
322 // Math.cbrt(a:number) -> NumberCbrt(a)
323 Node* value = graph()->NewNode(simplified()->NumberCbrt(), r.left());
324 return Replace(value);
325 }
326 return NoChange();
327 }
328
296 // ES6 section 20.2.2.28 Math.round ( x ) 329 // ES6 section 20.2.2.28 Math.round ( x )
297 Reduction JSBuiltinReducer::ReduceMathRound(Node* node) { 330 Reduction JSBuiltinReducer::ReduceMathRound(Node* node) {
298 JSCallReduction r(node); 331 JSCallReduction r(node);
299 if (r.InputsMatchOne(Type::PlainPrimitive())) { 332 if (r.InputsMatchOne(Type::PlainPrimitive())) {
300 // Math.round(a:plain-primitive) -> NumberRound(ToNumber(a)) 333 // Math.round(a:plain-primitive) -> NumberRound(ToNumber(a))
301 Node* input = ToNumber(r.GetJSCallInput(0)); 334 Node* input = ToNumber(r.GetJSCallInput(0));
302 Node* value = graph()->NewNode(simplified()->NumberRound(), input); 335 Node* value = graph()->NewNode(simplified()->NumberRound(), input);
303 return Replace(value); 336 return Replace(value);
304 } 337 }
305 return NoChange(); 338 return NoChange();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 380
348 // Dispatch according to the BuiltinFunctionId if present. 381 // Dispatch according to the BuiltinFunctionId if present.
349 if (!r.HasBuiltinFunctionId()) return NoChange(); 382 if (!r.HasBuiltinFunctionId()) return NoChange();
350 switch (r.GetBuiltinFunctionId()) { 383 switch (r.GetBuiltinFunctionId()) {
351 case kMathAtan: 384 case kMathAtan:
352 reduction = ReduceMathAtan(node); 385 reduction = ReduceMathAtan(node);
353 break; 386 break;
354 case kMathAtan2: 387 case kMathAtan2:
355 reduction = ReduceMathAtan2(node); 388 reduction = ReduceMathAtan2(node);
356 break; 389 break;
390 case kMathAtanh:
391 reduction = ReduceMathAtanh(node);
392 break;
357 case kMathClz32: 393 case kMathClz32:
358 reduction = ReduceMathClz32(node); 394 reduction = ReduceMathClz32(node);
359 break; 395 break;
360 case kMathCeil: 396 case kMathCeil:
361 reduction = ReduceMathCeil(node); 397 reduction = ReduceMathCeil(node);
362 break; 398 break;
363 case kMathExp: 399 case kMathExp:
364 reduction = ReduceMathExp(node); 400 reduction = ReduceMathExp(node);
365 break; 401 break;
402 case kMathExpm1:
403 reduction = ReduceMathExpm1(node);
404 break;
366 case kMathFloor: 405 case kMathFloor:
367 reduction = ReduceMathFloor(node); 406 reduction = ReduceMathFloor(node);
368 break; 407 break;
369 case kMathFround: 408 case kMathFround:
370 reduction = ReduceMathFround(node); 409 reduction = ReduceMathFround(node);
371 break; 410 break;
372 case kMathImul: 411 case kMathImul:
373 reduction = ReduceMathImul(node); 412 reduction = ReduceMathImul(node);
374 break; 413 break;
375 case kMathLog: 414 case kMathLog:
376 reduction = ReduceMathLog(node); 415 reduction = ReduceMathLog(node);
377 break; 416 break;
378 case kMathLog1p: 417 case kMathLog1p:
379 reduction = ReduceMathLog1p(node); 418 reduction = ReduceMathLog1p(node);
380 break; 419 break;
381 case kMathLog2: 420 case kMathLog2:
382 reduction = ReduceMathLog2(node); 421 reduction = ReduceMathLog2(node);
383 break; 422 break;
384 case kMathLog10: 423 case kMathLog10:
385 reduction = ReduceMathLog10(node); 424 reduction = ReduceMathLog10(node);
386 break; 425 break;
387 case kMathMax: 426 case kMathMax:
388 reduction = ReduceMathMax(node); 427 reduction = ReduceMathMax(node);
389 break; 428 break;
390 case kMathMin: 429 case kMathMin:
391 reduction = ReduceMathMin(node); 430 reduction = ReduceMathMin(node);
392 break; 431 break;
432 case kMathCbrt:
433 reduction = ReduceMathCbrt(node);
434 break;
393 case kMathRound: 435 case kMathRound:
394 reduction = ReduceMathRound(node); 436 reduction = ReduceMathRound(node);
395 break; 437 break;
396 case kMathSqrt: 438 case kMathSqrt:
397 reduction = ReduceMathSqrt(node); 439 reduction = ReduceMathSqrt(node);
398 break; 440 break;
399 case kMathTrunc: 441 case kMathTrunc:
400 reduction = ReduceMathTrunc(node); 442 reduction = ReduceMathTrunc(node);
401 break; 443 break;
402 case kStringFromCharCode: 444 case kStringFromCharCode:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 479 }
438 480
439 481
440 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { 482 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const {
441 return jsgraph()->simplified(); 483 return jsgraph()->simplified();
442 } 484 }
443 485
444 } // namespace compiler 486 } // namespace compiler
445 } // namespace internal 487 } // namespace internal
446 } // namespace v8 488 } // namespace v8
OLDNEW
« 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