| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |