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

Side by Side Diff: src/scopeinfo.cc

Issue 669270: Remove unneeded variable usage analysis. (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/parser.cc ('k') | src/scopes.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 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 // sort them by context slot index before adding them to the 75 // sort them by context slot index before adding them to the
76 // ScopeInfo list. 76 // ScopeInfo list.
77 List<Variable*, Allocator> locals(32); // 32 is a wild guess 77 List<Variable*, Allocator> locals(32); // 32 is a wild guess
78 ASSERT(locals.is_empty()); 78 ASSERT(locals.is_empty());
79 scope->CollectUsedVariables(&locals); 79 scope->CollectUsedVariables(&locals);
80 locals.Sort(&CompareLocal); 80 locals.Sort(&CompareLocal);
81 81
82 List<Variable*, Allocator> heap_locals(locals.length()); 82 List<Variable*, Allocator> heap_locals(locals.length());
83 for (int i = 0; i < locals.length(); i++) { 83 for (int i = 0; i < locals.length(); i++) {
84 Variable* var = locals[i]; 84 Variable* var = locals[i];
85 if (var->var_uses()->is_used()) { 85 if (var->is_used()) {
86 Slot* slot = var->slot(); 86 Slot* slot = var->slot();
87 if (slot != NULL) { 87 if (slot != NULL) {
88 switch (slot->type()) { 88 switch (slot->type()) {
89 case Slot::PARAMETER: 89 case Slot::PARAMETER:
90 // explicitly added to parameters_ above - ignore 90 // explicitly added to parameters_ above - ignore
91 break; 91 break;
92 92
93 case Slot::LOCAL: 93 case Slot::LOCAL:
94 ASSERT(stack_slots_.length() == slot->index()); 94 ASSERT(stack_slots_.length() == slot->index());
95 stack_slots_.Add(var->name()); 95 stack_slots_.Add(var->name());
(...skipping 27 matching lines...) Expand all
123 } else { 123 } else {
124 ASSERT(heap_locals.length() == 0); 124 ASSERT(heap_locals.length() == 0);
125 } 125 }
126 126
127 // Add the function context slot, if present. 127 // Add the function context slot, if present.
128 // For now, this must happen at the very end because of the 128 // For now, this must happen at the very end because of the
129 // ordering of the scope info slots and the respective slot indices. 129 // ordering of the scope info slots and the respective slot indices.
130 if (scope->is_function_scope()) { 130 if (scope->is_function_scope()) {
131 Variable* var = scope->function(); 131 Variable* var = scope->function();
132 if (var != NULL && 132 if (var != NULL &&
133 var->var_uses()->is_used() && 133 var->is_used() &&
134 var->slot()->type() == Slot::CONTEXT) { 134 var->slot()->type() == Slot::CONTEXT) {
135 function_name_ = var->name(); 135 function_name_ = var->name();
136 // Note that we must not find the function name in the context slot 136 // Note that we must not find the function name in the context slot
137 // list - instead it must be handled separately in the 137 // list - instead it must be handled separately in the
138 // Contexts::Lookup() function. Thus record an empty symbol here so we 138 // Contexts::Lookup() function. Thus record an empty symbol here so we
139 // get the correct number of context slots. 139 // get the correct number of context slots.
140 ASSERT(var->slot()->index() - Context::MIN_CONTEXT_SLOTS == 140 ASSERT(var->slot()->index() - Context::MIN_CONTEXT_SLOTS ==
141 context_slots_.length()); 141 context_slots_.length());
142 ASSERT(var->slot()->index() - Context::MIN_CONTEXT_SLOTS == 142 ASSERT(var->slot()->index() - Context::MIN_CONTEXT_SLOTS ==
143 context_modes_.length()); 143 context_modes_.length());
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 } 640 }
641 #endif // DEBUG 641 #endif // DEBUG
642 642
643 643
644 // Make sure the classes get instantiated by the template system. 644 // Make sure the classes get instantiated by the template system.
645 template class ScopeInfo<FreeStoreAllocationPolicy>; 645 template class ScopeInfo<FreeStoreAllocationPolicy>;
646 template class ScopeInfo<PreallocatedStorage>; 646 template class ScopeInfo<PreallocatedStorage>;
647 template class ScopeInfo<ZoneListAllocationPolicy>; 647 template class ScopeInfo<ZoneListAllocationPolicy>;
648 648
649 } } // namespace v8::internal 649 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.cc ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698