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

Side by Side Diff: src/compiler/simplified-lowering.cc

Issue 897883002: [turbofan]: Improved source position information (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review feedback Created 5 years, 10 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/simplified-lowering.h ('k') | src/compiler/source-position.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/simplified-lowering.h" 5 #include "src/compiler/simplified-lowering.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
11 #include "src/compiler/common-operator.h" 11 #include "src/compiler/common-operator.h"
12 #include "src/compiler/diamond.h" 12 #include "src/compiler/diamond.h"
13 #include "src/compiler/linkage.h" 13 #include "src/compiler/linkage.h"
14 #include "src/compiler/node-matchers.h" 14 #include "src/compiler/node-matchers.h"
15 #include "src/compiler/node-properties.h" 15 #include "src/compiler/node-properties.h"
16 #include "src/compiler/operator-properties.h" 16 #include "src/compiler/operator-properties.h"
17 #include "src/compiler/representation-change.h" 17 #include "src/compiler/representation-change.h"
18 #include "src/compiler/simplified-lowering.h" 18 #include "src/compiler/simplified-lowering.h"
19 #include "src/compiler/simplified-operator.h" 19 #include "src/compiler/simplified-operator.h"
20 #include "src/compiler/source-position.h"
20 #include "src/objects.h" 21 #include "src/objects.h"
21 22
22 namespace v8 { 23 namespace v8 {
23 namespace internal { 24 namespace internal {
24 namespace compiler { 25 namespace compiler {
25 26
26 // Macro for outputting trace information from representation inference. 27 // Macro for outputting trace information from representation inference.
27 #define TRACE(x) \ 28 #define TRACE(x) \
28 if (FLAG_trace_representation) PrintF x 29 if (FLAG_trace_representation) PrintF x
29 30
(...skipping 28 matching lines...) Expand all
58 public: 59 public:
59 // Information for each node tracked during the fixpoint. 60 // Information for each node tracked during the fixpoint.
60 struct NodeInfo { 61 struct NodeInfo {
61 MachineTypeUnion use : 15; // Union of all usages for the node. 62 MachineTypeUnion use : 15; // Union of all usages for the node.
62 bool queued : 1; // Bookkeeping for the traversal. 63 bool queued : 1; // Bookkeeping for the traversal.
63 bool visited : 1; // Bookkeeping for the traversal. 64 bool visited : 1; // Bookkeeping for the traversal.
64 MachineTypeUnion output : 15; // Output type of the node. 65 MachineTypeUnion output : 15; // Output type of the node.
65 }; 66 };
66 67
67 RepresentationSelector(JSGraph* jsgraph, Zone* zone, 68 RepresentationSelector(JSGraph* jsgraph, Zone* zone,
68 RepresentationChanger* changer) 69 RepresentationChanger* changer,
70 SourcePositionTable* source_positions)
69 : jsgraph_(jsgraph), 71 : jsgraph_(jsgraph),
70 count_(jsgraph->graph()->NodeCount()), 72 count_(jsgraph->graph()->NodeCount()),
71 info_(zone->NewArray<NodeInfo>(count_)), 73 info_(zone->NewArray<NodeInfo>(count_)),
72 nodes_(zone), 74 nodes_(zone),
73 replacements_(zone), 75 replacements_(zone),
74 phase_(PROPAGATE), 76 phase_(PROPAGATE),
75 changer_(changer), 77 changer_(changer),
76 queue_(zone) { 78 queue_(zone),
79 source_positions_(source_positions) {
77 memset(info_, 0, sizeof(NodeInfo) * count_); 80 memset(info_, 0, sizeof(NodeInfo) * count_);
78 81
79 safe_int_additive_range_ = 82 safe_int_additive_range_ =
80 Type::Range(-std::pow(2.0, 52.0), std::pow(2.0, 52.0), zone); 83 Type::Range(-std::pow(2.0, 52.0), std::pow(2.0, 52.0), zone);
81 } 84 }
82 85
83 void Run(SimplifiedLowering* lowering) { 86 void Run(SimplifiedLowering* lowering) {
84 // Run propagation phase to a fixpoint. 87 // Run propagation phase to a fixpoint.
85 TRACE(("--{Propagation phase}--\n")); 88 TRACE(("--{Propagation phase}--\n"));
86 phase_ = PROPAGATE; 89 phase_ = PROPAGATE;
(...skipping 12 matching lines...) Expand all
99 } 102 }
100 103
101 // Run lowering and change insertion phase. 104 // Run lowering and change insertion phase.
102 TRACE(("--{Simplified lowering phase}--\n")); 105 TRACE(("--{Simplified lowering phase}--\n"));
103 phase_ = LOWER; 106 phase_ = LOWER;
104 // Process nodes from the collected {nodes_} vector. 107 // Process nodes from the collected {nodes_} vector.
105 for (NodeVector::iterator i = nodes_.begin(); i != nodes_.end(); ++i) { 108 for (NodeVector::iterator i = nodes_.begin(); i != nodes_.end(); ++i) {
106 Node* node = *i; 109 Node* node = *i;
107 TRACE((" visit #%d: %s\n", node->id(), node->op()->mnemonic())); 110 TRACE((" visit #%d: %s\n", node->id(), node->op()->mnemonic()));
108 // Reuse {VisitNode()} so the representation rules are in one place. 111 // Reuse {VisitNode()} so the representation rules are in one place.
109 VisitNode(node, GetUseInfo(node), lowering); 112 if (FLAG_turbo_source_positions) {
113 SourcePositionTable::Scope scope(
114 source_positions_, source_positions_->GetSourcePosition(node));
115 VisitNode(node, GetUseInfo(node), lowering);
116 } else {
117 VisitNode(node, GetUseInfo(node), lowering);
118 }
110 } 119 }
111 120
112 // Perform the final replacements. 121 // Perform the final replacements.
113 for (NodeVector::iterator i = replacements_.begin(); 122 for (NodeVector::iterator i = replacements_.begin();
114 i != replacements_.end(); ++i) { 123 i != replacements_.end(); ++i) {
115 Node* node = *i; 124 Node* node = *i;
116 Node* replacement = *(++i); 125 Node* replacement = *(++i);
117 node->ReplaceUses(replacement); 126 node->ReplaceUses(replacement);
118 } 127 }
119 } 128 }
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 1073
1065 private: 1074 private:
1066 JSGraph* jsgraph_; 1075 JSGraph* jsgraph_;
1067 int count_; // number of nodes in the graph 1076 int count_; // number of nodes in the graph
1068 NodeInfo* info_; // node id -> usage information 1077 NodeInfo* info_; // node id -> usage information
1069 NodeVector nodes_; // collected nodes 1078 NodeVector nodes_; // collected nodes
1070 NodeVector replacements_; // replacements to be done after lowering 1079 NodeVector replacements_; // replacements to be done after lowering
1071 Phase phase_; // current phase of algorithm 1080 Phase phase_; // current phase of algorithm
1072 RepresentationChanger* changer_; // for inserting representation changes 1081 RepresentationChanger* changer_; // for inserting representation changes
1073 ZoneQueue<Node*> queue_; // queue for traversing the graph 1082 ZoneQueue<Node*> queue_; // queue for traversing the graph
1083 // TODO(danno): RepresentationSelector shouldn't know anything about the
1084 // source positions table, but must for now since there currently is no other
1085 // way to pass down source position information to nodes created during
1086 // lowering. Once this phase becomes a vanilla reducer, it should get source
1087 // position information via the SourcePositionWrapper like all other reducers.
1088 SourcePositionTable* source_positions_;
1074 Type* safe_int_additive_range_; 1089 Type* safe_int_additive_range_;
1075 1090
1076 NodeInfo* GetInfo(Node* node) { 1091 NodeInfo* GetInfo(Node* node) {
1077 DCHECK(node->id() >= 0); 1092 DCHECK(node->id() >= 0);
1078 DCHECK(node->id() < count_); 1093 DCHECK(node->id() < count_);
1079 return &info_[node->id()]; 1094 return &info_[node->id()];
1080 } 1095 }
1081 1096
1082 MachineTypeUnion GetUseInfo(Node* node) { return GetInfo(node)->use; } 1097 MachineTypeUnion GetUseInfo(Node* node) { return GetInfo(node)->use; }
1083 }; 1098 };
1084 1099
1085 1100
1086 Node* SimplifiedLowering::IsTagged(Node* node) { 1101 Node* SimplifiedLowering::IsTagged(Node* node) {
1087 // TODO(titzer): factor this out to a TaggingScheme abstraction. 1102 // TODO(titzer): factor this out to a TaggingScheme abstraction.
1088 STATIC_ASSERT(kSmiTagMask == 1); // Only works if tag is the low bit. 1103 STATIC_ASSERT(kSmiTagMask == 1); // Only works if tag is the low bit.
1089 return graph()->NewNode(machine()->WordAnd(), node, 1104 return graph()->NewNode(machine()->WordAnd(), node,
1090 jsgraph()->Int32Constant(kSmiTagMask)); 1105 jsgraph()->Int32Constant(kSmiTagMask));
1091 } 1106 }
1092 1107
1093 1108
1094 void SimplifiedLowering::LowerAllNodes() { 1109 void SimplifiedLowering::LowerAllNodes() {
1095 SimplifiedOperatorBuilder simplified(graph()->zone()); 1110 SimplifiedOperatorBuilder simplified(graph()->zone());
1096 RepresentationChanger changer(jsgraph(), &simplified, jsgraph()->isolate()); 1111 RepresentationChanger changer(jsgraph(), &simplified, jsgraph()->isolate());
1097 RepresentationSelector selector(jsgraph(), zone_, &changer); 1112 RepresentationSelector selector(jsgraph(), zone_, &changer,
1113 source_positions_);
1098 selector.Run(this); 1114 selector.Run(this);
1099 } 1115 }
1100 1116
1101 1117
1102 Node* SimplifiedLowering::Untag(Node* node) { 1118 Node* SimplifiedLowering::Untag(Node* node) {
1103 // TODO(titzer): factor this out to a TaggingScheme abstraction. 1119 // TODO(titzer): factor this out to a TaggingScheme abstraction.
1104 Node* shift_amount = jsgraph()->Int32Constant(kSmiTagSize + kSmiShiftSize); 1120 Node* shift_amount = jsgraph()->Int32Constant(kSmiTagSize + kSmiShiftSize);
1105 return graph()->NewNode(machine()->WordSar(), node, shift_amount); 1121 return graph()->NewNode(machine()->WordSar(), node, shift_amount);
1106 } 1122 }
1107 1123
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 1530
1515 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { 1531 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) {
1516 node->set_op(machine()->IntLessThanOrEqual()); 1532 node->set_op(machine()->IntLessThanOrEqual());
1517 node->ReplaceInput(0, StringComparison(node, true)); 1533 node->ReplaceInput(0, StringComparison(node, true));
1518 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); 1534 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL));
1519 } 1535 }
1520 1536
1521 } // namespace compiler 1537 } // namespace compiler
1522 } // namespace internal 1538 } // namespace internal
1523 } // namespace v8 1539 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-lowering.h ('k') | src/compiler/source-position.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698