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

Side by Side Diff: src/compiler.cc

Issue 1530003: Rework flow graph construction. (Closed)
Patch Set: Created 10 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.h ('k') | src/data-flow.h » ('j') | src/data-flow.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 if (function->scope()->num_parameters() > 0 || 83 if (function->scope()->num_parameters() > 0 ||
84 function->scope()->num_stack_slots()) { 84 function->scope()->num_stack_slots()) {
85 AssignedVariablesAnalyzer ava(function); 85 AssignedVariablesAnalyzer ava(function);
86 ava.Analyze(); 86 ava.Analyze();
87 if (ava.HasStackOverflow()) { 87 if (ava.HasStackOverflow()) {
88 return Handle<Code>::null(); 88 return Handle<Code>::null();
89 } 89 }
90 } 90 }
91 91
92 if (FLAG_use_flow_graph) { 92 if (FLAG_use_flow_graph) {
93 int variable_count = 93 FlowGraphBuilder builder;
94 function->num_parameters() + function->scope()->num_stack_slots(); 94 FlowGraph* graph = builder.Build(function);
95 FlowGraphBuilder builder(variable_count); 95 USE(graph);
96 builder.Build(function);
97
98 if (!builder.HasStackOverflow()) {
99 if (variable_count > 0) {
100 ReachingDefinitions rd(builder.postorder(),
101 builder.body_definitions(),
102 variable_count);
103 rd.Compute();
104
105 TypeAnalyzer ta(builder.postorder(),
106 builder.body_definitions(),
107 variable_count,
108 function->num_parameters());
109 ta.Compute();
110
111 MarkLiveCode(builder.preorder(),
112 builder.body_definitions(),
113 variable_count);
114 }
115 }
116 96
117 #ifdef DEBUG 97 #ifdef DEBUG
118 if (FLAG_print_graph_text && !builder.HasStackOverflow()) { 98 if (FLAG_print_graph_text && !builder.HasStackOverflow()) {
119 builder.graph()->PrintText(function, builder.postorder()); 99 graph->PrintAsText(function->name());
120 } 100 }
121 #endif 101 #endif
122 } 102 }
123 103
124 // Generate code and return it. Code generator selection is governed by 104 // Generate code and return it. Code generator selection is governed by
125 // which backends are enabled and whether the function is considered 105 // which backends are enabled and whether the function is considered
126 // run-once code or not: 106 // run-once code or not:
127 // 107 //
128 // --full-compiler enables the dedicated backend for code we expect to be 108 // --full-compiler enables the dedicated backend for code we expect to be
129 // run once 109 // run once
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 if (literal->scope()->num_parameters() > 0 || 472 if (literal->scope()->num_parameters() > 0 ||
493 literal->scope()->num_stack_slots()) { 473 literal->scope()->num_stack_slots()) {
494 AssignedVariablesAnalyzer ava(literal); 474 AssignedVariablesAnalyzer ava(literal);
495 ava.Analyze(); 475 ava.Analyze();
496 if (ava.HasStackOverflow()) { 476 if (ava.HasStackOverflow()) {
497 return Handle<SharedFunctionInfo>::null(); 477 return Handle<SharedFunctionInfo>::null();
498 } 478 }
499 } 479 }
500 480
501 if (FLAG_use_flow_graph) { 481 if (FLAG_use_flow_graph) {
502 int variable_count = 482 FlowGraphBuilder builder;
503 literal->num_parameters() + literal->scope()->num_stack_slots(); 483 FlowGraph* graph = builder.Build(literal);
504 FlowGraphBuilder builder(variable_count); 484 USE(graph);
505 builder.Build(literal);
506
507 if (!builder.HasStackOverflow()) {
508 if (variable_count > 0) {
509 ReachingDefinitions rd(builder.postorder(),
510 builder.body_definitions(),
511 variable_count);
512 rd.Compute();
513
514 TypeAnalyzer ta(builder.postorder(),
515 builder.body_definitions(),
516 variable_count,
517 literal->num_parameters());
518 ta.Compute();
519
520 MarkLiveCode(builder.preorder(),
521 builder.body_definitions(),
522 variable_count);
523 }
524 }
525 485
526 #ifdef DEBUG 486 #ifdef DEBUG
527 if (FLAG_print_graph_text && !builder.HasStackOverflow()) { 487 if (FLAG_print_graph_text && !builder.HasStackOverflow()) {
528 builder.graph()->PrintText(literal, builder.postorder()); 488 graph->PrintAsText(literal->name());
529 } 489 }
530 #endif 490 #endif
531 } 491 }
532 492
533 // Generate code and return it. The way that the compilation mode 493 // Generate code and return it. The way that the compilation mode
534 // is controlled by the command-line flags is described in 494 // is controlled by the command-line flags is described in
535 // the static helper function MakeCode. 495 // the static helper function MakeCode.
536 CompilationInfo info(literal, script, false); 496 CompilationInfo info(literal, script, false);
537 497
538 CHECK(!FLAG_always_full_compiler || !FLAG_always_fast_compiler); 498 CHECK(!FLAG_always_full_compiler || !FLAG_always_fast_compiler);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 } else { 600 } else {
641 LOG(CodeCreateEvent(tag, *code, *func_name)); 601 LOG(CodeCreateEvent(tag, *code, *func_name));
642 OPROFILE(CreateNativeCodeRegion(*func_name, 602 OPROFILE(CreateNativeCodeRegion(*func_name,
643 code->instruction_start(), 603 code->instruction_start(),
644 code->instruction_size())); 604 code->instruction_size()));
645 } 605 }
646 } 606 }
647 } 607 }
648 608
649 } } // namespace v8::internal 609 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/compiler.h ('k') | src/data-flow.h » ('j') | src/data-flow.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698