OLD | NEW |
---|---|
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/int64-lowering.h" | 5 #include "src/compiler/int64-lowering.h" |
6 #include "src/compiler/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
7 #include "src/compiler/graph.h" | 7 #include "src/compiler/graph.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/machine-operator.h" | 9 #include "src/compiler/machine-operator.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
11 | 11 |
12 #include "src/compiler/node.h" | 12 #include "src/compiler/node.h" |
13 #include "src/wasm/wasm-module.h" | 13 #include "src/wasm/wasm-module.h" |
14 #include "src/zone.h" | 14 #include "src/zone.h" |
15 | 15 |
16 namespace v8 { | 16 namespace v8 { |
17 namespace internal { | 17 namespace internal { |
18 namespace compiler { | 18 namespace compiler { |
19 | 19 |
20 Int64Lowering::Int64Lowering(Graph* graph, MachineOperatorBuilder* machine, | 20 Int64Lowering::Int64Lowering(Graph* graph, MachineOperatorBuilder* machine, |
21 CommonOperatorBuilder* common, Zone* zone, | 21 CommonOperatorBuilder* common, Zone* zone, |
22 Signature<MachineRepresentation>* signature) | 22 Signature<MachineRepresentation>* signature) |
23 : zone_(zone), | 23 : zone_(zone), |
24 graph_(graph), | 24 graph_(graph), |
25 machine_(machine), | 25 machine_(machine), |
26 common_(common), | 26 common_(common), |
27 state_(graph, 4), | 27 state_(graph, 3), |
28 stack_(zone), | 28 stack_(zone), |
29 replacements_(zone->NewArray<Replacement>(graph->NodeCount())), | 29 replacements_(zone->NewArray<Replacement>(graph->NodeCount())), |
30 signature_(signature) { | 30 signature_(signature) { |
31 memset(replacements_, 0, sizeof(Replacement) * graph->NodeCount()); | 31 memset(replacements_, 0, sizeof(Replacement) * graph->NodeCount()); |
32 } | 32 } |
33 | 33 |
34 void Int64Lowering::LowerGraph() { | 34 void Int64Lowering::LowerGraph() { |
35 if (!machine()->Is32()) { | 35 if (!machine()->Is32()) { |
36 return; | 36 return; |
37 } | 37 } |
38 stack_.push(graph()->end()); | 38 stack_.push({graph()->end(), 0}); |
39 state_.Set(graph()->end(), State::kOnStack); | 39 state_.Set(graph()->end(), State::kOnStack); |
40 | 40 |
41 while (!stack_.empty()) { | 41 while (!stack_.empty()) { |
42 Node* top = stack_.top(); | 42 NodeState& top = stack_.top(); |
43 if (state_.Get(top) == State::kInputsPushed) { | 43 if (top.input_index == top.node->InputCount()) { |
44 stack_.pop(); | 44 stack_.pop(); |
45 state_.Set(top, State::kVisited); | 45 // if (state_.Get(top) == State::kInputsPushed) { |
titzer
2016/03/14 14:28:17
Why is this line of code commented out?
ahaas
2016/03/14 14:41:50
Deleted.
| |
46 // All inputs of top have already been reduced, now reduce top. | 46 state_.Set(top.node, State::kVisited); |
47 LowerNode(top); | 47 // All inputs of top have already been lowered, now lower top. |
48 LowerNode(top.node); | |
48 } else { | 49 } else { |
49 // Push all children onto the stack. | 50 // Push the next input onto the stack. |
50 for (Node* input : top->inputs()) { | 51 Node* input = top.node->InputAt(top.input_index++); |
51 if (state_.Get(input) == State::kUnvisited) { | 52 if (state_.Get(input) == State::kUnvisited) { |
52 stack_.push(input); | 53 stack_.push({input, 0}); |
53 state_.Set(input, State::kOnStack); | 54 state_.Set(input, State::kOnStack); |
54 } | |
55 } | 55 } |
56 state_.Set(top, State::kInputsPushed); | |
57 } | 56 } |
58 } | 57 } |
59 } | 58 } |
60 | 59 |
61 static int GetParameterIndexAfterLowering( | 60 static int GetParameterIndexAfterLowering( |
62 Signature<MachineRepresentation>* signature, int old_index) { | 61 Signature<MachineRepresentation>* signature, int old_index) { |
63 int result = old_index; | 62 int result = old_index; |
64 for (int i = 0; i < old_index; i++) { | 63 for (int i = 0; i < old_index; i++) { |
65 if (signature->GetParam(i) == MachineRepresentation::kWord64) { | 64 if (signature->GetParam(i) == MachineRepresentation::kWord64) { |
66 result++; | 65 result++; |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 } | 492 } |
494 | 493 |
495 Node* Int64Lowering::GetReplacementHigh(Node* node) { | 494 Node* Int64Lowering::GetReplacementHigh(Node* node) { |
496 Node* result = replacements_[node->id()].high; | 495 Node* result = replacements_[node->id()].high; |
497 DCHECK(result); | 496 DCHECK(result); |
498 return result; | 497 return result; |
499 } | 498 } |
500 } // namespace compiler | 499 } // namespace compiler |
501 } // namespace internal | 500 } // namespace internal |
502 } // namespace v8 | 501 } // namespace v8 |
OLD | NEW |