Chromium Code Reviews| 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 stack_.pop(); |
|
titzer
2016/03/14 14:14:13
You can move the pop into the true branch and drop
ahaas
2016/03/14 14:25:18
Done.
| |
| 44 stack_.pop(); | 44 if (top.input_index == top.node->InputCount()) { |
| 45 state_.Set(top, State::kVisited); | 45 // if (state_.Get(top) == State::kInputsPushed) { |
| 46 state_.Set(top.node, State::kVisited); | |
| 46 // All inputs of top have already been reduced, now reduce top. | 47 // All inputs of top have already been reduced, now reduce top. |
| 47 LowerNode(top); | 48 LowerNode(top.node); |
| 48 } else { | 49 } else { |
| 49 // Push all children onto the stack. | 50 // Push all children onto the stack. |
|
titzer
2016/03/14 14:14:13
Update comment.
ahaas
2016/03/14 14:25:18
Done.
| |
| 50 for (Node* input : top->inputs()) { | 51 Node* input = top.node->InputAt(top.input_index); |
|
titzer
2016/03/14 14:14:13
It's ok to through the ++ inside here, too.
ahaas
2016/03/14 14:25:18
Done.
| |
| 51 if (state_.Get(input) == State::kUnvisited) { | 52 top.input_index++; |
| 52 stack_.push(input); | 53 stack_.push(top); |
| 53 state_.Set(input, State::kOnStack); | 54 if (state_.Get(input) == State::kUnvisited) { |
| 54 } | 55 stack_.push({input, 0}); |
| 56 state_.Set(input, State::kOnStack); | |
| 55 } | 57 } |
| 56 state_.Set(top, State::kInputsPushed); | |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 } | 60 } |
| 60 | 61 |
| 61 static int GetParameterIndexAfterLowering( | 62 static int GetParameterIndexAfterLowering( |
| 62 Signature<MachineRepresentation>* signature, int old_index) { | 63 Signature<MachineRepresentation>* signature, int old_index) { |
| 63 int result = old_index; | 64 int result = old_index; |
| 64 for (int i = 0; i < old_index; i++) { | 65 for (int i = 0; i < old_index; i++) { |
| 65 if (signature->GetParam(i) == MachineRepresentation::kWord64) { | 66 if (signature->GetParam(i) == MachineRepresentation::kWord64) { |
| 66 result++; | 67 result++; |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 } | 494 } |
| 494 | 495 |
| 495 Node* Int64Lowering::GetReplacementHigh(Node* node) { | 496 Node* Int64Lowering::GetReplacementHigh(Node* node) { |
| 496 Node* result = replacements_[node->id()].high; | 497 Node* result = replacements_[node->id()].high; |
| 497 DCHECK(result); | 498 DCHECK(result); |
| 498 return result; | 499 return result; |
| 499 } | 500 } |
| 500 } // namespace compiler | 501 } // namespace compiler |
| 501 } // namespace internal | 502 } // namespace internal |
| 502 } // namespace v8 | 503 } // namespace v8 |
| OLD | NEW |