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

Side by Side Diff: src/compiler/jump-threading.cc

Issue 1642823002: [turbofan] Jump threading awareness of frame elision. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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
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/jump-threading.h" 5 #include "src/compiler/jump-threading.h"
6 #include "src/compiler/code-generator-impl.h" 6 #include "src/compiler/code-generator-impl.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 namespace compiler { 10 namespace compiler {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 TRACE(" fw %d -> %d (forward)\n", from.ToInt(), to.ToInt()); 46 TRACE(" fw %d -> %d (forward)\n", from.ToInt(), to.ToInt());
47 result[from.ToInt()] = to_to; // forward the block. 47 result[from.ToInt()] = to_to; // forward the block.
48 forwarded = true; 48 forwarded = true;
49 } 49 }
50 if (pop) stack.pop(); 50 if (pop) stack.pop();
51 } 51 }
52 RpoNumber unvisited() { return RpoNumber::FromInt(-1); } 52 RpoNumber unvisited() { return RpoNumber::FromInt(-1); }
53 RpoNumber onstack() { return RpoNumber::FromInt(-2); } 53 RpoNumber onstack() { return RpoNumber::FromInt(-2); }
54 }; 54 };
55 55
56
57 bool JumpThreading::ComputeForwarding(Zone* local_zone, 56 bool JumpThreading::ComputeForwarding(Zone* local_zone,
58 ZoneVector<RpoNumber>& result, 57 ZoneVector<RpoNumber>& result,
59 InstructionSequence* code) { 58 InstructionSequence* code,
59 bool frame_at_start) {
60 ZoneStack<RpoNumber> stack(local_zone); 60 ZoneStack<RpoNumber> stack(local_zone);
61 JumpThreadingState state = {false, result, stack}; 61 JumpThreadingState state = {false, result, stack};
62 state.Clear(code->InstructionBlockCount()); 62 state.Clear(code->InstructionBlockCount());
63 63
64 // Iterate over the blocks forward, pushing the blocks onto the stack. 64 // Iterate over the blocks forward, pushing the blocks onto the stack.
65 for (auto const block : code->instruction_blocks()) { 65 for (auto const block : code->instruction_blocks()) {
66 RpoNumber current = block->rpo_number(); 66 RpoNumber current = block->rpo_number();
67 state.PushIfUnvisited(current); 67 state.PushIfUnvisited(current);
68 68
69 // Process the stack, which implements DFS through empty blocks. 69 // Process the stack, which implements DFS through empty blocks.
(...skipping 14 matching lines...) Expand all
84 // can't skip instructions with flags continuations. 84 // can't skip instructions with flags continuations.
85 TRACE(" flags\n"); 85 TRACE(" flags\n");
86 fallthru = false; 86 fallthru = false;
87 } else if (instr->IsNop()) { 87 } else if (instr->IsNop()) {
88 // skip nops. 88 // skip nops.
89 TRACE(" nop\n"); 89 TRACE(" nop\n");
90 continue; 90 continue;
91 } else if (instr->arch_opcode() == kArchJmp) { 91 } else if (instr->arch_opcode() == kArchJmp) {
92 // try to forward the jump instruction. 92 // try to forward the jump instruction.
93 TRACE(" jmp\n"); 93 TRACE(" jmp\n");
94 fw = code->InputRpo(instr, 0); 94 // if this block deconstructs the frame, we can't forward it.
95 // TODO(mtrofin): we can still forward if we end up building
96 // the frame at start. So we should move the decision of whether
97 // to build a frame or not in the register allocator, and trickle it
98 // here and to the code generator.
99 if (frame_at_start || !block->must_deconstruct_frame()) {
100 fw = code->InputRpo(instr, 0);
101 }
95 fallthru = false; 102 fallthru = false;
96 } else { 103 } else {
97 // can't skip other instructions. 104 // can't skip other instructions.
98 TRACE(" other\n"); 105 TRACE(" other\n");
99 fallthru = false; 106 fallthru = false;
100 } 107 }
101 break; 108 break;
102 } 109 }
103 if (fallthru) { 110 if (fallthru) {
104 int next = 1 + block->rpo_number().ToInt(); 111 int next = 1 + block->rpo_number().ToInt();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (block->IsDeferred()) { 190 if (block->IsDeferred()) {
184 block->set_ao_number(RpoNumber::FromInt(ao)); 191 block->set_ao_number(RpoNumber::FromInt(ao));
185 if (!skip[block->rpo_number().ToInt()]) ao++; 192 if (!skip[block->rpo_number().ToInt()]) ao++;
186 } 193 }
187 } 194 }
188 } 195 }
189 196
190 } // namespace compiler 197 } // namespace compiler
191 } // namespace internal 198 } // namespace internal
192 } // namespace v8 199 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698