Chromium Code Reviews

Side by Side Diff: src/compiler/osr.cc

Issue 930003003: [turbofan] Transfer types from loop phis to OSR values. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | src/compiler/typer.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.h" 5 #include "src/compiler.h"
6 #include "src/compiler/all-nodes.h" 6 #include "src/compiler/all-nodes.h"
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/control-reducer.h" 8 #include "src/compiler/control-reducer.h"
9 #include "src/compiler/frame.h" 9 #include "src/compiler/frame.h"
10 #include "src/compiler/graph.h" 10 #include "src/compiler/graph.h"
(...skipping 156 matching lines...)
167 end->ReplaceInput(0, merge); 167 end->ReplaceInput(0, merge);
168 168
169 if (FLAG_trace_turbo_graph) { // Simple textual RPO. 169 if (FLAG_trace_turbo_graph) { // Simple textual RPO.
170 OFStream os(stdout); 170 OFStream os(stdout);
171 os << "-- Graph after OSR duplication -- " << std::endl; 171 os << "-- Graph after OSR duplication -- " << std::endl;
172 os << AsRPO(*graph); 172 os << AsRPO(*graph);
173 } 173 }
174 } 174 }
175 175
176 176
177 static void TransferOsrValueTypesFromLoopPhis(Zone* zone, Node* osr_loop_entry,
178 Node* osr_loop) {
179 // Find the index of the osr loop entry into the loop.
180 int index = 0;
181 for (index = 0; index < osr_loop->InputCount(); index++) {
182 if (osr_loop->InputAt(index) == osr_loop_entry) break;
183 }
184 if (index == osr_loop->InputCount()) return;
185
186 for (Node* osr_value : osr_loop_entry->uses()) {
187 if (osr_value->opcode() != IrOpcode::kOsrValue) continue;
188 bool unknown = true;
189 for (Node* phi : osr_value->uses()) {
190 if (phi->opcode() != IrOpcode::kPhi) continue;
191 if (NodeProperties::GetControlInput(phi) != osr_loop) continue;
192 if (phi->InputAt(index) != osr_value) continue;
193 if (NodeProperties::IsTyped(phi)) {
194 // Transfer the type from the phi to the OSR value itself.
195 Bounds phi_bounds = NodeProperties::GetBounds(phi);
196 if (NodeProperties::IsTyped(osr_value)) {
197 Bounds osr_bounds = NodeProperties::GetBounds(osr_value);
198 NodeProperties::SetBounds(osr_value,
199 Bounds::Both(phi_bounds, osr_bounds, zone));
200 } else {
201 NodeProperties::SetBounds(osr_value, phi_bounds);
202 }
203 unknown = false;
204 }
205 }
206 if (unknown) NodeProperties::SetBounds(osr_value, Bounds::Unbounded(zone));
Benedikt Meurer 2015/02/18 09:18:10 I'd suggest to use NodeProperties::SetBounds(osr
207 }
208 }
209
210
177 bool OsrHelper::Deconstruct(JSGraph* jsgraph, CommonOperatorBuilder* common, 211 bool OsrHelper::Deconstruct(JSGraph* jsgraph, CommonOperatorBuilder* common,
178 Zone* tmp_zone) { 212 Zone* tmp_zone) {
179 Graph* graph = jsgraph->graph(); 213 Graph* graph = jsgraph->graph();
180 Node* osr_normal_entry = nullptr; 214 Node* osr_normal_entry = nullptr;
181 Node* osr_loop_entry = nullptr; 215 Node* osr_loop_entry = nullptr;
182 Node* osr_loop = nullptr; 216 Node* osr_loop = nullptr;
183 217
184 for (Node* node : graph->start()->uses()) { 218 for (Node* node : graph->start()->uses()) {
185 if (node->opcode() == IrOpcode::kOsrLoopEntry) { 219 if (node->opcode() == IrOpcode::kOsrLoopEntry) {
186 osr_loop_entry = node; // found the OSR loop entry 220 osr_loop_entry = node; // found the OSR loop entry
(...skipping 10 matching lines...)
197 231
198 for (Node* use : osr_loop_entry->uses()) { 232 for (Node* use : osr_loop_entry->uses()) {
199 if (use->opcode() == IrOpcode::kLoop) { 233 if (use->opcode() == IrOpcode::kLoop) {
200 CHECK(!osr_loop); // should be only one OSR loop. 234 CHECK(!osr_loop); // should be only one OSR loop.
201 osr_loop = use; // found the OSR loop. 235 osr_loop = use; // found the OSR loop.
202 } 236 }
203 } 237 }
204 238
205 CHECK(osr_loop); // Should have found the OSR loop. 239 CHECK(osr_loop); // Should have found the OSR loop.
206 240
241 // Transfer the types from loop phis to the OSR values which flow into them.
242 TransferOsrValueTypesFromLoopPhis(graph->zone(), osr_loop_entry, osr_loop);
243
207 // Analyze the graph to determine how deeply nested the OSR loop is. 244 // Analyze the graph to determine how deeply nested the OSR loop is.
208 LoopTree* loop_tree = LoopFinder::BuildLoopTree(graph, tmp_zone); 245 LoopTree* loop_tree = LoopFinder::BuildLoopTree(graph, tmp_zone);
209 246
210 Node* dead = graph->NewNode(common->Dead()); 247 Node* dead = graph->NewNode(common->Dead());
211 LoopTree::Loop* loop = loop_tree->ContainingLoop(osr_loop); 248 LoopTree::Loop* loop = loop_tree->ContainingLoop(osr_loop);
212 if (loop->depth() > 0) { 249 if (loop->depth() > 0) {
213 PeelOuterLoopsForOsr(graph, common, tmp_zone, dead, loop_tree, loop, 250 PeelOuterLoopsForOsr(graph, common, tmp_zone, dead, loop_tree, loop,
214 osr_normal_entry, osr_loop_entry); 251 osr_normal_entry, osr_loop_entry);
215 } 252 }
216 253
(...skipping 12 matching lines...)
229 // the first spill slots. 266 // the first spill slots.
230 frame->ReserveSpillSlots(UnoptimizedFrameSlots()); 267 frame->ReserveSpillSlots(UnoptimizedFrameSlots());
231 // The frame needs to be adjusted by the number of unoptimized frame slots. 268 // The frame needs to be adjusted by the number of unoptimized frame slots.
232 frame->SetOsrStackSlotCount(static_cast<int>(UnoptimizedFrameSlots())); 269 frame->SetOsrStackSlotCount(static_cast<int>(UnoptimizedFrameSlots()));
233 } 270 }
234 271
235 272
236 } // namespace compiler 273 } // namespace compiler
237 } // namespace internal 274 } // namespace internal
238 } // namespace v8 275 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine