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

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 1848243002: [turbofan] Introduce JSToInteger and JSToLength operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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-typed-lowering.h ('k') | src/compiler/opcodes.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/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compilation-dependencies.h" 6 #include "src/compilation-dependencies.h"
7 #include "src/compiler/access-builder.h" 7 #include "src/compiler/access-builder.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 ReplaceWithValue(node, node, length); 637 ReplaceWithValue(node, node, length);
638 node->ReplaceInput(0, jsgraph()->ZeroConstant()); 638 node->ReplaceInput(0, jsgraph()->ZeroConstant());
639 node->ReplaceInput(1, length); 639 node->ReplaceInput(1, length);
640 node->TrimInputCount(2); 640 node->TrimInputCount(2);
641 NodeProperties::ChangeOp(node, simplified()->NumberLessThan()); 641 NodeProperties::ChangeOp(node, simplified()->NumberLessThan());
642 return Changed(node); 642 return Changed(node);
643 } 643 }
644 return NoChange(); 644 return NoChange();
645 } 645 }
646 646
647 Reduction JSTypedLowering::ReduceJSToInteger(Node* node) {
648 Node* const input = NodeProperties::GetValueInput(node, 0);
649 Type* const input_type = NodeProperties::GetType(input);
650 if (input_type->Is(type_cache_.kIntegerOrMinusZero)) {
651 // JSToInteger(x:integer) => x
652 ReplaceWithValue(node, input);
653 return Replace(input);
654 }
655 return NoChange();
656 }
657
658 Reduction JSTypedLowering::ReduceJSToLength(Node* node) {
659 Node* input = NodeProperties::GetValueInput(node, 0);
660 Type* input_type = NodeProperties::GetType(input);
661 if (input_type->Is(type_cache_.kIntegerOrMinusZero)) {
662 if (input_type->Max() <= 0.0) {
663 input = jsgraph()->ZeroConstant();
664 } else if (input_type->Min() >= kMaxSafeInteger) {
665 input = jsgraph()->Constant(kMaxSafeInteger);
666 } else {
667 if (input_type->Min() <= 0.0) {
668 input = graph()->NewNode(
669 common()->Select(MachineRepresentation::kTagged),
670 graph()->NewNode(simplified()->NumberLessThanOrEqual(), input,
671 jsgraph()->ZeroConstant()),
672 jsgraph()->ZeroConstant(), input);
673 input_type = Type::Range(0.0, input_type->Max(), graph()->zone());
674 NodeProperties::SetType(input, input_type);
675 }
676 if (input_type->Max() > kMaxSafeInteger) {
677 input = graph()->NewNode(
678 common()->Select(MachineRepresentation::kTagged),
679 graph()->NewNode(simplified()->NumberLessThanOrEqual(),
680 jsgraph()->Constant(kMaxSafeInteger), input),
681 jsgraph()->Constant(kMaxSafeInteger), input);
682 input_type =
683 Type::Range(input_type->Min(), kMaxSafeInteger, graph()->zone());
684 NodeProperties::SetType(input, input_type);
685 }
686 }
687 ReplaceWithValue(node, input);
688 return Replace(input);
689 }
690 return NoChange();
691 }
647 692
648 Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) { 693 Reduction JSTypedLowering::ReduceJSToNumberInput(Node* input) {
649 if (input->opcode() == IrOpcode::kJSToNumber) { 694 if (input->opcode() == IrOpcode::kJSToNumber) {
650 // Recursively try to reduce the input first. 695 // Recursively try to reduce the input first.
651 Reduction result = ReduceJSToNumber(input); 696 Reduction result = ReduceJSToNumber(input);
652 if (result.Changed()) return result; 697 if (result.Changed()) return result;
653 return Changed(input); // JSToNumber(JSToNumber(x)) => JSToNumber(x) 698 return Changed(input); // JSToNumber(JSToNumber(x)) => JSToNumber(x)
654 } 699 }
655 // Check for ToNumber truncation of signaling NaN to undefined mapping. 700 // Check for ToNumber truncation of signaling NaN to undefined mapping.
656 if (input->opcode() == IrOpcode::kSelect) { 701 if (input->opcode() == IrOpcode::kSelect) {
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 case IrOpcode::kJSSubtract: 1721 case IrOpcode::kJSSubtract:
1677 return ReduceNumberBinop(node, simplified()->NumberSubtract()); 1722 return ReduceNumberBinop(node, simplified()->NumberSubtract());
1678 case IrOpcode::kJSMultiply: 1723 case IrOpcode::kJSMultiply:
1679 return ReduceNumberBinop(node, simplified()->NumberMultiply()); 1724 return ReduceNumberBinop(node, simplified()->NumberMultiply());
1680 case IrOpcode::kJSDivide: 1725 case IrOpcode::kJSDivide:
1681 return ReduceNumberBinop(node, simplified()->NumberDivide()); 1726 return ReduceNumberBinop(node, simplified()->NumberDivide());
1682 case IrOpcode::kJSModulus: 1727 case IrOpcode::kJSModulus:
1683 return ReduceJSModulus(node); 1728 return ReduceJSModulus(node);
1684 case IrOpcode::kJSToBoolean: 1729 case IrOpcode::kJSToBoolean:
1685 return ReduceJSToBoolean(node); 1730 return ReduceJSToBoolean(node);
1731 case IrOpcode::kJSToInteger:
1732 return ReduceJSToInteger(node);
1733 case IrOpcode::kJSToLength:
1734 return ReduceJSToLength(node);
1686 case IrOpcode::kJSToNumber: 1735 case IrOpcode::kJSToNumber:
1687 return ReduceJSToNumber(node); 1736 return ReduceJSToNumber(node);
1688 case IrOpcode::kJSToString: 1737 case IrOpcode::kJSToString:
1689 return ReduceJSToString(node); 1738 return ReduceJSToString(node);
1690 case IrOpcode::kJSToObject: 1739 case IrOpcode::kJSToObject:
1691 return ReduceJSToObject(node); 1740 return ReduceJSToObject(node);
1692 case IrOpcode::kJSLoadNamed: 1741 case IrOpcode::kJSLoadNamed:
1693 return ReduceJSLoadNamed(node); 1742 return ReduceJSLoadNamed(node);
1694 case IrOpcode::kJSLoadProperty: 1743 case IrOpcode::kJSLoadProperty:
1695 return ReduceJSLoadProperty(node); 1744 return ReduceJSLoadProperty(node);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 } 1807 }
1759 1808
1760 1809
1761 CompilationDependencies* JSTypedLowering::dependencies() const { 1810 CompilationDependencies* JSTypedLowering::dependencies() const {
1762 return dependencies_; 1811 return dependencies_;
1763 } 1812 }
1764 1813
1765 } // namespace compiler 1814 } // namespace compiler
1766 } // namespace internal 1815 } // namespace internal
1767 } // namespace v8 1816 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698