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

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

Issue 1366753003: [turbofan] Make Node::set_op safer via wrapper. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 5 years, 2 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/node-properties.cc ('k') | src/compiler/select-lowering.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/common-operator-reducer.h" 8 #include "src/compiler/common-operator-reducer.h"
9 #include "src/compiler/dead-code-elimination.h" 9 #include "src/compiler/dead-code-elimination.h"
10 #include "src/compiler/frame.h" 10 #include "src/compiler/frame.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 TRACE(" ---- #%d:%s\n", loop_header->id(), loop_header->op()->mnemonic()); 230 TRACE(" ---- #%d:%s\n", loop_header->id(), loop_header->op()->mnemonic());
231 } 231 }
232 232
233 // Merge the ends of the graph copies. 233 // Merge the ends of the graph copies.
234 Node* const end = graph->end(); 234 Node* const end = graph->end();
235 int const input_count = end->InputCount(); 235 int const input_count = end->InputCount();
236 for (int i = 0; i < input_count; ++i) { 236 for (int i = 0; i < input_count; ++i) {
237 NodeId const id = end->InputAt(i)->id(); 237 NodeId const id = end->InputAt(i)->id();
238 for (NodeVector* const copy : copies) { 238 for (NodeVector* const copy : copies) {
239 end->AppendInput(graph->zone(), copy->at(id)); 239 end->AppendInput(graph->zone(), copy->at(id));
240 end->set_op(common->End(end->InputCount())); 240 NodeProperties::ChangeOp(end, common->End(end->InputCount()));
241 } 241 }
242 } 242 }
243 243
244 if (FLAG_trace_turbo_graph) { // Simple textual RPO. 244 if (FLAG_trace_turbo_graph) { // Simple textual RPO.
245 OFStream os(stdout); 245 OFStream os(stdout);
246 os << "-- Graph after OSR duplication -- " << std::endl; 246 os << "-- Graph after OSR duplication -- " << std::endl;
247 os << AsRPO(*graph); 247 os << AsRPO(*graph);
248 } 248 }
249 } 249 }
250 250
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 osr_normal_entry->ReplaceUses(dead); 294 osr_normal_entry->ReplaceUses(dead);
295 osr_normal_entry->Kill(); 295 osr_normal_entry->Kill();
296 osr_loop_entry->ReplaceUses(graph->start()); 296 osr_loop_entry->ReplaceUses(graph->start());
297 osr_loop_entry->Kill(); 297 osr_loop_entry->Kill();
298 298
299 // Remove the first input to the {osr_loop}. 299 // Remove the first input to the {osr_loop}.
300 int const live_input_count = osr_loop->InputCount() - 1; 300 int const live_input_count = osr_loop->InputCount() - 1;
301 CHECK_NE(0, live_input_count); 301 CHECK_NE(0, live_input_count);
302 for (Node* const use : osr_loop->uses()) { 302 for (Node* const use : osr_loop->uses()) {
303 if (NodeProperties::IsPhi(use)) { 303 if (NodeProperties::IsPhi(use)) {
304 use->set_op(common->ResizeMergeOrPhi(use->op(), live_input_count));
305 use->RemoveInput(0); 304 use->RemoveInput(0);
305 NodeProperties::ChangeOp(
306 use, common->ResizeMergeOrPhi(use->op(), live_input_count));
306 } 307 }
307 } 308 }
308 osr_loop->set_op(common->ResizeMergeOrPhi(osr_loop->op(), live_input_count));
309 osr_loop->RemoveInput(0); 309 osr_loop->RemoveInput(0);
310 NodeProperties::ChangeOp(
311 osr_loop, common->ResizeMergeOrPhi(osr_loop->op(), live_input_count));
310 312
311 // Run control reduction and graph trimming. 313 // Run control reduction and graph trimming.
312 // TODO(bmeurer): The OSR deconstruction could be a regular reducer and play 314 // TODO(bmeurer): The OSR deconstruction could be a regular reducer and play
313 // nice together with the rest, instead of having this custom stuff here. 315 // nice together with the rest, instead of having this custom stuff here.
314 GraphReducer graph_reducer(tmp_zone, graph); 316 GraphReducer graph_reducer(tmp_zone, graph);
315 DeadCodeElimination dce(&graph_reducer, graph, common); 317 DeadCodeElimination dce(&graph_reducer, graph, common);
316 CommonOperatorReducer cor(&graph_reducer, graph, common, jsgraph->machine()); 318 CommonOperatorReducer cor(&graph_reducer, graph, common, jsgraph->machine());
317 graph_reducer.AddReducer(&dce); 319 graph_reducer.AddReducer(&dce);
318 graph_reducer.AddReducer(&cor); 320 graph_reducer.AddReducer(&cor);
319 graph_reducer.ReduceGraph(); 321 graph_reducer.ReduceGraph();
320 GraphTrimmer trimmer(tmp_zone, graph); 322 GraphTrimmer trimmer(tmp_zone, graph);
321 NodeVector roots(tmp_zone); 323 NodeVector roots(tmp_zone);
322 jsgraph->GetCachedNodes(&roots); 324 jsgraph->GetCachedNodes(&roots);
323 trimmer.TrimGraph(roots.begin(), roots.end()); 325 trimmer.TrimGraph(roots.begin(), roots.end());
324 } 326 }
325 327
326 328
327 void OsrHelper::SetupFrame(Frame* frame) { 329 void OsrHelper::SetupFrame(Frame* frame) {
328 // The optimized frame will subsume the unoptimized frame. Do so by reserving 330 // The optimized frame will subsume the unoptimized frame. Do so by reserving
329 // the first spill slots. 331 // the first spill slots.
330 frame->ReserveSpillSlots(UnoptimizedFrameSlots()); 332 frame->ReserveSpillSlots(UnoptimizedFrameSlots());
331 } 333 }
332 334
333 } // namespace compiler 335 } // namespace compiler
334 } // namespace internal 336 } // namespace internal
335 } // namespace v8 337 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/node-properties.cc ('k') | src/compiler/select-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698