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

Side by Side Diff: src/hydrogen.cc

Issue 6647018: Remove class HSubgraph. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « src/hydrogen.h ('k') | src/x64/lithium-codegen-x64.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 } 550 }
551 551
552 552
553 void HBasicBlock::FinishExit(HControlInstruction* instruction) { 553 void HBasicBlock::FinishExit(HControlInstruction* instruction) {
554 Finish(instruction); 554 Finish(instruction);
555 ClearEnvironment(); 555 ClearEnvironment();
556 } 556 }
557 557
558 558
559 HGraph::HGraph(CompilationInfo* info) 559 HGraph::HGraph(CompilationInfo* info)
560 : HSubgraph(this), 560 : next_block_id_(0),
561 next_block_id_(0), 561 entry_block_(NULL),
562 blocks_(8), 562 blocks_(8),
563 values_(16), 563 values_(16),
564 phi_list_(NULL) { 564 phi_list_(NULL) {
565 start_environment_ = new HEnvironment(NULL, info->scope(), info->closure()); 565 start_environment_ = new HEnvironment(NULL, info->scope(), info->closure());
566 start_environment_->set_ast_id(info->function()->id()); 566 start_environment_->set_ast_id(info->function()->id());
567 entry_block_ = CreateBasicBlock();
568 entry_block_->SetInitialEnvironment(start_environment_);
567 } 569 }
568 570
569 571
570 Handle<Code> HGraph::Compile(CompilationInfo* info) { 572 Handle<Code> HGraph::Compile(CompilationInfo* info) {
571 int values = GetMaximumValueID(); 573 int values = GetMaximumValueID();
572 if (values > LAllocator::max_initial_value_ids()) { 574 if (values > LAllocator::max_initial_value_ids()) {
573 if (FLAG_trace_bailout) PrintF("Function is too big\n"); 575 if (FLAG_trace_bailout) PrintF("Function is too big\n");
574 return Handle<Code>::null(); 576 return Handle<Code>::null();
575 } 577 }
576 578
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 if (!phi->is_live()) { 780 if (!phi->is_live()) {
779 HBasicBlock* block = phi->block(); 781 HBasicBlock* block = phi->block();
780 block->RemovePhi(phi); 782 block->RemovePhi(phi);
781 block->RecordDeletedPhi(phi->merged_index()); 783 block->RecordDeletedPhi(phi->merged_index());
782 } 784 }
783 } 785 }
784 } 786 }
785 787
786 788
787 bool HGraph::CollectPhis() { 789 bool HGraph::CollectPhis() {
788 const ZoneList<HBasicBlock*>* blocks = graph_->blocks(); 790 int block_count = blocks_.length();
789 phi_list_ = new ZoneList<HPhi*>(blocks->length()); 791 phi_list_ = new ZoneList<HPhi*>(block_count);
790 for (int i = 0; i < blocks->length(); ++i) { 792 for (int i = 0; i < block_count; ++i) {
791 for (int j = 0; j < blocks->at(i)->phis()->length(); j++) { 793 for (int j = 0; j < blocks_[i]->phis()->length(); ++j) {
792 HPhi* phi = blocks->at(i)->phis()->at(j); 794 HPhi* phi = blocks_[i]->phis()->at(j);
793 phi_list_->Add(phi); 795 phi_list_->Add(phi);
794 // We don't support phi uses of arguments for now. 796 // We don't support phi uses of arguments for now.
795 if (phi->CheckFlag(HValue::kIsArguments)) return false; 797 if (phi->CheckFlag(HValue::kIsArguments)) return false;
796 } 798 }
797 } 799 }
798 return true; 800 return true;
799 } 801 }
800 802
801 803
802 void HGraph::InferTypes(ZoneList<HValue*>* worklist) { 804 void HGraph::InferTypes(ZoneList<HValue*>* worklist) {
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 } while (false) 2075 } while (false)
2074 2076
2075 2077
2076 #define VISIT_FOR_CONTROL(expr, true_block, false_block) \ 2078 #define VISIT_FOR_CONTROL(expr, true_block, false_block) \
2077 do { \ 2079 do { \
2078 VisitForControl(expr, true_block, false_block); \ 2080 VisitForControl(expr, true_block, false_block); \
2079 if (HasStackOverflow()) return; \ 2081 if (HasStackOverflow()) return; \
2080 } while (false) 2082 } while (false)
2081 2083
2082 2084
2083 // 'thing' could be an expression, statement, or list of statements.
2084 #define ADD_TO_SUBGRAPH(graph, thing) \
2085 do { \
2086 AddToSubgraph(graph, thing); \
2087 if (HasStackOverflow()) return; \
2088 } while (false)
2089
2090
2091 class HGraphBuilder::SubgraphScope BASE_EMBEDDED {
2092 public:
2093 SubgraphScope(HGraphBuilder* builder, HSubgraph* new_subgraph)
2094 : builder_(builder) {
2095 old_subgraph_ = builder_->current_subgraph_;
2096 subgraph_ = new_subgraph;
2097 builder_->current_subgraph_ = subgraph_;
2098 }
2099
2100 ~SubgraphScope() {
2101 builder_->current_subgraph_ = old_subgraph_;
2102 }
2103
2104 HSubgraph* subgraph() const { return subgraph_; }
2105
2106 private:
2107 HGraphBuilder* builder_;
2108 HSubgraph* old_subgraph_;
2109 HSubgraph* subgraph_;
2110 };
2111
2112
2113 void HGraphBuilder::Bailout(const char* reason) { 2085 void HGraphBuilder::Bailout(const char* reason) {
2114 if (FLAG_trace_bailout) { 2086 if (FLAG_trace_bailout) {
2115 SmartPointer<char> name(info()->shared_info()->DebugName()->ToCString()); 2087 SmartPointer<char> name(info()->shared_info()->DebugName()->ToCString());
2116 PrintF("Bailout in HGraphBuilder: @\"%s\": %s\n", *name, reason); 2088 PrintF("Bailout in HGraphBuilder: @\"%s\": %s\n", *name, reason);
2117 } 2089 }
2118 SetStackOverflow(); 2090 SetStackOverflow();
2119 } 2091 }
2120 2092
2121 2093
2122 void HGraphBuilder::VisitForEffect(Expression* expr) { 2094 void HGraphBuilder::VisitForEffect(Expression* expr) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 2126
2155 2127
2156 void HGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs) { 2128 void HGraphBuilder::VisitExpressions(ZoneList<Expression*>* exprs) {
2157 for (int i = 0; i < exprs->length(); ++i) { 2129 for (int i = 0; i < exprs->length(); ++i) {
2158 VISIT_FOR_VALUE(exprs->at(i)); 2130 VISIT_FOR_VALUE(exprs->at(i));
2159 } 2131 }
2160 } 2132 }
2161 2133
2162 2134
2163 HGraph* HGraphBuilder::CreateGraph() { 2135 HGraph* HGraphBuilder::CreateGraph() {
2164 ASSERT(subgraph() == NULL);
2165 graph_ = new HGraph(info()); 2136 graph_ = new HGraph(info());
2166
2167 { 2137 {
2168 HPhase phase("Block building"); 2138 HPhase phase("Block building");
2169 graph()->Initialize(CreateBasicBlock(graph()->start_environment())); 2139 current_block_ = graph()->entry_block();
2170 current_subgraph_ = graph();
2171 2140
2172 Scope* scope = info()->scope(); 2141 Scope* scope = info()->scope();
2173 if (scope->HasIllegalRedeclaration()) { 2142 if (scope->HasIllegalRedeclaration()) {
2174 Bailout("function with illegal redeclaration"); 2143 Bailout("function with illegal redeclaration");
2175 return NULL; 2144 return NULL;
2176 } 2145 }
2177 SetupScope(scope); 2146 SetupScope(scope);
2178 VisitDeclarations(scope->declarations()); 2147 VisitDeclarations(scope->declarations());
2179 AddInstruction(new HStackCheck()); 2148 AddInstruction(new HStackCheck());
2180 2149
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2238 if (FLAG_use_gvn) { 2207 if (FLAG_use_gvn) {
2239 HPhase phase("Global value numbering", graph()); 2208 HPhase phase("Global value numbering", graph());
2240 HGlobalValueNumberer gvn(graph(), info()); 2209 HGlobalValueNumberer gvn(graph(), info());
2241 gvn.Analyze(); 2210 gvn.Analyze();
2242 } 2211 }
2243 2212
2244 return graph(); 2213 return graph();
2245 } 2214 }
2246 2215
2247 2216
2248 void HGraphBuilder::AddToSubgraph(HSubgraph* graph, Statement* stmt) {
2249 SubgraphScope scope(this, graph);
2250 Visit(stmt);
2251 }
2252
2253
2254 void HGraphBuilder::AddToSubgraph(HSubgraph* graph, Expression* expr) {
2255 SubgraphScope scope(this, graph);
2256 VisitForValue(expr);
2257 }
2258
2259
2260 void HGraphBuilder::AddToSubgraph(HSubgraph* graph,
2261 ZoneList<Statement*>* stmts) {
2262 SubgraphScope scope(this, graph);
2263 VisitStatements(stmts);
2264 }
2265
2266
2267 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { 2217 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) {
2268 ASSERT(current_block() != NULL); 2218 ASSERT(current_block() != NULL);
2269 current_block()->AddInstruction(instr); 2219 current_block()->AddInstruction(instr);
2270 return instr; 2220 return instr;
2271 } 2221 }
2272 2222
2273 2223
2274 void HGraphBuilder::AddSimulate(int id) { 2224 void HGraphBuilder::AddSimulate(int id) {
2275 ASSERT(current_block() != NULL); 2225 ASSERT(current_block() != NULL);
2276 current_block()->AddSimulate(id); 2226 current_block()->AddSimulate(id);
(...skipping 3663 matching lines...) Expand 10 before | Expand all | Expand 10 after
5940 } 5890 }
5941 } 5891 }
5942 5892
5943 #ifdef DEBUG 5893 #ifdef DEBUG
5944 if (graph_ != NULL) graph_->Verify(); 5894 if (graph_ != NULL) graph_->Verify();
5945 if (allocator_ != NULL) allocator_->Verify(); 5895 if (allocator_ != NULL) allocator_->Verify();
5946 #endif 5896 #endif
5947 } 5897 }
5948 5898
5949 } } // namespace v8::internal 5899 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/x64/lithium-codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698