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

Unified Diff: src/scopeinfo.cc

Issue 8438071: Clean up Scope::CollectUsedVariables. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« src/liveedit.cc ('K') | « src/liveedit.cc ('k') | src/scopes.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scopeinfo.cc
diff --git a/src/scopeinfo.cc b/src/scopeinfo.cc
index 5b652e13d4d102f6c6ec99d7b0690d7b1078ff47..15ad63f8886ee5db70fc34062e906021637b7212 100644
--- a/src/scopeinfo.cc
+++ b/src/scopeinfo.cc
@@ -47,36 +47,15 @@ static int CompareLocal(Variable* const* v, Variable* const* w) {
Handle<ScopeInfo> ScopeInfo::Create(Scope* scope) {
- ZoneList<Variable*> variables(32); // 32 is a wild guess
- ASSERT(variables.is_empty());
- scope->CollectUsedVariables(&variables);
-
- ZoneList<Variable*> stack_locals(scope->num_stack_slots());
- ZoneList<Variable*> context_locals(scope->num_heap_slots());
-
// Collect stack and context locals.
- for (int i = 0; i < variables.length(); i++) {
- Variable* var = variables[i];
- ASSERT(var->is_used());
- switch (var->location()) {
- case Variable::UNALLOCATED:
- case Variable::PARAMETER:
- break;
-
- case Variable::LOCAL:
- stack_locals.Add(var);
- break;
-
- case Variable::CONTEXT:
- context_locals.Add(var);
- break;
-
- case Variable::LOOKUP:
- // We don't expect lookup variables in the locals list.
- UNREACHABLE();
- break;
- }
- }
+ const int stack_local_count = scope->StackLocalCount();
+ const int context_local_count = scope->ContextLocalCount();
+ ZoneList<Variable*> stack_locals(stack_local_count);
+ ZoneList<Variable*> context_locals(context_local_count);
+ scope->CollectStackAndContextLocals(&stack_locals, &context_locals);
+ // Make sure we allocate the correct amount.
+ ASSERT(stack_locals.length() == stack_local_count);
+ ASSERT(context_locals.length() == context_local_count);
Kevin Millikin (Chromium) 2011/11/03 13:12:20 Are these asserts true for the case where some var
Steven 2011/11/03 14:55:59 Yep. Those counts actually reflect how many times
// Determine use and location of the function variable if it is present.
FunctionVariableInfo function_name_info;
@@ -99,8 +78,6 @@ Handle<ScopeInfo> ScopeInfo::Create(Scope* scope) {
const bool has_function_name = function_name_info != NONE;
const int parameter_count = scope->num_parameters();
- const int stack_local_count = stack_locals.length();
- const int context_local_count = context_locals.length();
const int length = kVariablePartIndex
+ parameter_count + stack_local_count + 2 * context_local_count
+ (has_function_name ? 2 : 0);
« src/liveedit.cc ('K') | « src/liveedit.cc ('k') | src/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698