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

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

Issue 2125583002: [turbofan] Recognize fast path for Number.parseInt. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/objects.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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 JSCallReduction r(node); 514 JSCallReduction r(node);
515 if (r.InputsMatchOne(Type::PlainPrimitive())) { 515 if (r.InputsMatchOne(Type::PlainPrimitive())) {
516 // Math.trunc(a:plain-primitive) -> NumberTrunc(ToNumber(a)) 516 // Math.trunc(a:plain-primitive) -> NumberTrunc(ToNumber(a))
517 Node* input = ToNumber(r.GetJSCallInput(0)); 517 Node* input = ToNumber(r.GetJSCallInput(0));
518 Node* value = graph()->NewNode(simplified()->NumberTrunc(), input); 518 Node* value = graph()->NewNode(simplified()->NumberTrunc(), input);
519 return Replace(value); 519 return Replace(value);
520 } 520 }
521 return NoChange(); 521 return NoChange();
522 } 522 }
523 523
524 // ES6 section 20.1.2.13 Number.parseInt ( string, radix )
525 Reduction JSBuiltinReducer::ReduceNumberParseInt(Node* node) {
526 JSCallReduction r(node);
527 if (r.InputsMatchOne(type_cache_.kSafeInteger) ||
528 r.InputsMatchTwo(type_cache_.kSafeInteger,
529 type_cache_.kZeroOrUndefined) ||
530 r.InputsMatchTwo(type_cache_.kSafeInteger, type_cache_.kTenOrUndefined)) {
531 // Number.parseInt(a:safe-integer) -> NumberToInt32(a)
532 // Number.parseInt(a:safe-integer,b:#0\/undefined) -> NumberToInt32(a)
533 // Number.parseInt(a:safe-integer,b:#10\/undefined) -> NumberToInt32(a)
534 Node* input = r.GetJSCallInput(0);
535 Node* value = graph()->NewNode(simplified()->NumberToInt32(), input);
536 return Replace(value);
537 }
538 return NoChange();
539 }
540
524 // ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits ) 541 // ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits )
525 Reduction JSBuiltinReducer::ReduceStringFromCharCode(Node* node) { 542 Reduction JSBuiltinReducer::ReduceStringFromCharCode(Node* node) {
526 JSCallReduction r(node); 543 JSCallReduction r(node);
527 if (r.InputsMatchOne(Type::PlainPrimitive())) { 544 if (r.InputsMatchOne(Type::PlainPrimitive())) {
528 // String.fromCharCode(a:plain-primitive) -> StringFromCharCode(a) 545 // String.fromCharCode(a:plain-primitive) -> StringFromCharCode(a)
529 Node* input = ToNumber(r.GetJSCallInput(0)); 546 Node* input = ToNumber(r.GetJSCallInput(0));
530 Node* value = graph()->NewNode(simplified()->StringFromCharCode(), input); 547 Node* value = graph()->NewNode(simplified()->StringFromCharCode(), input);
531 return Replace(value); 548 return Replace(value);
532 } 549 }
533 return NoChange(); 550 return NoChange();
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 break; 649 break;
633 case kMathTan: 650 case kMathTan:
634 reduction = ReduceMathTan(node); 651 reduction = ReduceMathTan(node);
635 break; 652 break;
636 case kMathTanh: 653 case kMathTanh:
637 reduction = ReduceMathTanh(node); 654 reduction = ReduceMathTanh(node);
638 break; 655 break;
639 case kMathTrunc: 656 case kMathTrunc:
640 reduction = ReduceMathTrunc(node); 657 reduction = ReduceMathTrunc(node);
641 break; 658 break;
659 case kNumberParseInt:
660 reduction = ReduceNumberParseInt(node);
661 break;
642 case kStringFromCharCode: 662 case kStringFromCharCode:
643 reduction = ReduceStringFromCharCode(node); 663 reduction = ReduceStringFromCharCode(node);
644 break; 664 break;
645 default: 665 default:
646 break; 666 break;
647 } 667 }
648 668
649 // Replace builtin call assuming replacement nodes are pure values that don't 669 // Replace builtin call assuming replacement nodes are pure values that don't
650 // produce an effect. Replaces {node} with {reduction} and relaxes effects. 670 // produce an effect. Replaces {node} with {reduction} and relaxes effects.
651 if (reduction.Changed()) ReplaceWithValue(node, reduction.replacement()); 671 if (reduction.Changed()) ReplaceWithValue(node, reduction.replacement());
(...skipping 25 matching lines...) Expand all
677 } 697 }
678 698
679 699
680 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { 700 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const {
681 return jsgraph()->simplified(); 701 return jsgraph()->simplified();
682 } 702 }
683 703
684 } // namespace compiler 704 } // namespace compiler
685 } // namespace internal 705 } // namespace internal
686 } // namespace v8 706 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-builtin-reducer.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698