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

Side by Side Diff: src/usage-analyzer.cc

Issue 269049: Split the AST LoopStatement type into separate types for do/while,... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 for (int i = cases->length(); i-- > 0;) { 152 for (int i = cases->length(); i-- > 0;) {
153 WeightScaler ws(this, static_cast<float>(1.0 / cases->length())); 153 WeightScaler ws(this, static_cast<float>(1.0 / cases->length()));
154 CaseClause* clause = cases->at(i); 154 CaseClause* clause = cases->at(i);
155 if (!clause->is_default()) 155 if (!clause->is_default())
156 Read(clause->label()); 156 Read(clause->label());
157 VisitStatements(clause->statements()); 157 VisitStatements(clause->statements());
158 } 158 }
159 } 159 }
160 160
161 161
162 void UsageComputer::VisitLoopStatement(LoopStatement* node) { 162 void UsageComputer::VisitDoWhileStatement(DoWhileStatement* node) {
163 if (node->init() != NULL) 163 WeightScaler ws(this, 10.0);
164 Visit(node->init()); 164 Read(node->cond());
165 Visit(node->body());
166 }
167
168
169 void UsageComputer::VisitWhileStatement(WhileStatement* node) {
170 WeightScaler ws(this, 10.0);
171 Read(node->cond());
172 Visit(node->body());
173 }
174
175
176 void UsageComputer::VisitForStatement(ForStatement* node) {
177 if (node->init() != NULL) Visit(node->init());
165 { WeightScaler ws(this, 10.0); // executed in each iteration 178 { WeightScaler ws(this, 10.0); // executed in each iteration
166 if (node->cond() != NULL) 179 if (node->cond() != NULL) Read(node->cond());
167 Read(node->cond()); 180 if (node->next() != NULL) Visit(node->next());
168 if (node->next() != NULL)
169 Visit(node->next());
170 Visit(node->body()); 181 Visit(node->body());
171 } 182 }
172 } 183 }
173 184
174 185
175 void UsageComputer::VisitForInStatement(ForInStatement* node) { 186 void UsageComputer::VisitForInStatement(ForInStatement* node) {
176 WeightScaler ws(this, 10.0); 187 WeightScaler ws(this, 10.0);
177 Write(node->each()); 188 Write(node->each());
178 Read(node->enumerable()); 189 Read(node->enumerable());
179 Visit(node->body()); 190 Visit(node->body());
180 } 191 }
181 192
182 193
183 void UsageComputer::VisitTryCatch(TryCatch* node) { 194 void UsageComputer::VisitTryCatchStatement(TryCatchStatement* node) {
184 Visit(node->try_block()); 195 Visit(node->try_block());
185 { WeightScaler ws(this, 0.25); 196 { WeightScaler ws(this, 0.25);
186 Write(node->catch_var()); 197 Write(node->catch_var());
187 Visit(node->catch_block()); 198 Visit(node->catch_block());
188 } 199 }
189 } 200 }
190 201
191 202
192 void UsageComputer::VisitTryFinally(TryFinally* node) { 203 void UsageComputer::VisitTryFinallyStatement(TryFinallyStatement* node) {
193 Visit(node->try_block()); 204 Visit(node->try_block());
194 Visit(node->finally_block()); 205 Visit(node->finally_block());
195 } 206 }
196 207
197 208
198 void UsageComputer::VisitDebuggerStatement(DebuggerStatement* node) { 209 void UsageComputer::VisitDebuggerStatement(DebuggerStatement* node) {
199 } 210 }
200 211
201 212
202 void UsageComputer::VisitFunctionLiteral(FunctionLiteral* node) { 213 void UsageComputer::VisitFunctionLiteral(FunctionLiteral* node) {
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 // ---------------------------------------------------------------------------- 417 // ----------------------------------------------------------------------------
407 // Interface to variable usage analysis 418 // Interface to variable usage analysis
408 419
409 bool AnalyzeVariableUsage(FunctionLiteral* lit) { 420 bool AnalyzeVariableUsage(FunctionLiteral* lit) {
410 if (!FLAG_usage_computation) return true; 421 if (!FLAG_usage_computation) return true;
411 HistogramTimerScope timer(&Counters::usage_analysis); 422 HistogramTimerScope timer(&Counters::usage_analysis);
412 return UsageComputer::Traverse(lit); 423 return UsageComputer::Traverse(lit);
413 } 424 }
414 425
415 } } // namespace v8::internal 426 } } // namespace v8::internal
OLDNEW
« src/prettyprinter.cc ('K') | « src/rewriter.cc ('k') | src/x64/codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698