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

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

Issue 1798993002: [wasm] Int64Lowering: changing to DFS. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed wrong dependency Created 4 years, 9 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/int64-lowering.h ('k') | test/cctest/wasm/test-run-wasm-64.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/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 // All inputs of top have already been lowered, now lower top.
44 stack_.pop(); 45 stack_.pop();
45 state_.Set(top, State::kVisited); 46 state_.Set(top.node, State::kVisited);
46 // All inputs of top have already been reduced, now reduce top. 47 LowerNode(top.node);
47 LowerNode(top);
48 } else { 48 } else {
49 // Push all children onto the stack. 49 // Push the next input onto the stack.
50 for (Node* input : top->inputs()) { 50 Node* input = top.node->InputAt(top.input_index++);
51 if (state_.Get(input) == State::kUnvisited) { 51 if (state_.Get(input) == State::kUnvisited) {
52 stack_.push(input); 52 stack_.push({input, 0});
53 state_.Set(input, State::kOnStack); 53 state_.Set(input, State::kOnStack);
54 }
55 } 54 }
56 state_.Set(top, State::kInputsPushed);
57 } 55 }
58 } 56 }
59 } 57 }
60 58
61 static int GetParameterIndexAfterLowering( 59 static int GetParameterIndexAfterLowering(
62 Signature<MachineRepresentation>* signature, int old_index) { 60 Signature<MachineRepresentation>* signature, int old_index) {
63 int result = old_index; 61 int result = old_index;
64 for (int i = 0; i < old_index; i++) { 62 for (int i = 0; i < old_index; i++) {
65 if (signature->GetParam(i) == MachineRepresentation::kWord64) { 63 if (signature->GetParam(i) == MachineRepresentation::kWord64) {
66 result++; 64 result++;
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 } 510 }
513 511
514 Node* Int64Lowering::GetReplacementHigh(Node* node) { 512 Node* Int64Lowering::GetReplacementHigh(Node* node) {
515 Node* result = replacements_[node->id()].high; 513 Node* result = replacements_[node->id()].high;
516 DCHECK(result); 514 DCHECK(result);
517 return result; 515 return result;
518 } 516 }
519 } // namespace compiler 517 } // namespace compiler
520 } // namespace internal 518 } // namespace internal
521 } // namespace v8 519 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/int64-lowering.h ('k') | test/cctest/wasm/test-run-wasm-64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698