OLD | NEW |
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 function_name_ = proxy->name(); | 131 function_name_ = proxy->name(); |
132 // Note that we must not find the function name in the context slot | 132 // Note that we must not find the function name in the context slot |
133 // list - instead it must be handled separately in the | 133 // list - instead it must be handled separately in the |
134 // Contexts::Lookup() function. Thus record an empty symbol here so we | 134 // Contexts::Lookup() function. Thus record an empty symbol here so we |
135 // get the correct number of context slots. | 135 // get the correct number of context slots. |
136 ASSERT(proxy->var()->index() - Context::MIN_CONTEXT_SLOTS == | 136 ASSERT(proxy->var()->index() - Context::MIN_CONTEXT_SLOTS == |
137 context_slots_.length()); | 137 context_slots_.length()); |
138 ASSERT(proxy->var()->index() - Context::MIN_CONTEXT_SLOTS == | 138 ASSERT(proxy->var()->index() - Context::MIN_CONTEXT_SLOTS == |
139 context_modes_.length()); | 139 context_modes_.length()); |
140 context_slots_.Add(FACTORY->empty_symbol()); | 140 context_slots_.Add(FACTORY->empty_symbol()); |
141 context_modes_.Add(INTERNAL); | 141 context_modes_.Add(proxy->var()->mode()); |
142 } | 142 } |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 | 146 |
147 // Encoding format in a FixedArray object: | 147 // Encoding format in a FixedArray object: |
148 // | 148 // |
149 // - function name | 149 // - function name |
150 // | 150 // |
151 // - calls eval boolean flag | 151 // - calls eval boolean flag |
(...skipping 22 matching lines...) Expand all Loading... |
174 // subsequent list | 174 // subsequent list |
175 // - the list entries don't have to be in any particular order, so all the | 175 // - the list entries don't have to be in any particular order, so all the |
176 // current sorting business can go away | 176 // current sorting business can go away |
177 // - the ScopeInfo lookup routines can be reduced to perhaps a single lookup | 177 // - the ScopeInfo lookup routines can be reduced to perhaps a single lookup |
178 // which returns all information at once | 178 // which returns all information at once |
179 // - when gathering the information from a Scope, we only need to iterate | 179 // - when gathering the information from a Scope, we only need to iterate |
180 // through the local variables (parameters and context info is already | 180 // through the local variables (parameters and context info is already |
181 // present) | 181 // present) |
182 | 182 |
183 | 183 |
184 static inline Object** ReadInt(Object** p, int* x) { | 184 template <class T> |
185 *x = (reinterpret_cast<Smi*>(*p++))->value(); | 185 static inline Object** ReadInt(Object** p, T* x) { |
| 186 *x = static_cast<T>((reinterpret_cast<Smi*>(*p++))->value()); |
186 return p; | 187 return p; |
187 } | 188 } |
188 | 189 |
189 | 190 |
190 static inline Object** ReadBool(Object** p, bool* x) { | 191 static inline Object** ReadBool(Object** p, bool* x) { |
191 *x = (reinterpret_cast<Smi*>(*p++))->value() != 0; | 192 *x = (reinterpret_cast<Smi*>(*p++))->value() != 0; |
192 return p; | 193 return p; |
193 } | 194 } |
194 | 195 |
195 | 196 |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 p = p0 + number_of_parameter_slots; | 507 p = p0 + number_of_parameter_slots; |
507 while (p > p0) { | 508 while (p > p0) { |
508 p--; | 509 p--; |
509 if (*p == name) return static_cast<int>(p - p0); | 510 if (*p == name) return static_cast<int>(p - p0); |
510 } | 511 } |
511 } | 512 } |
512 return -1; | 513 return -1; |
513 } | 514 } |
514 | 515 |
515 | 516 |
516 int SerializedScopeInfo::FunctionContextSlotIndex(String* name) { | 517 int SerializedScopeInfo::FunctionContextSlotIndex(String* name, |
| 518 VariableMode* mode) { |
517 ASSERT(name->IsSymbol()); | 519 ASSERT(name->IsSymbol()); |
518 if (length() > 0) { | 520 if (length() > 0) { |
519 Object** p = data_start(); | 521 Object** p = data_start(); |
520 if (*p == name) { | 522 if (*p == name) { |
521 p = ContextEntriesAddr(); | 523 p = ContextEntriesAddr(); |
522 int number_of_context_slots; | 524 int number_of_context_slots; |
523 ReadInt(p, &number_of_context_slots); | 525 p = ReadInt(p, &number_of_context_slots); |
524 ASSERT(number_of_context_slots != 0); | 526 ASSERT(number_of_context_slots != 0); |
525 // The function context slot is the last entry. | 527 // The function context slot is the last entry. |
| 528 if (mode != NULL) { |
| 529 // Seek to context slot entry. |
| 530 p += (number_of_context_slots - 1) * 2; |
| 531 // Seek to mode. |
| 532 ++p; |
| 533 ReadInt(p, mode); |
| 534 } |
526 return number_of_context_slots + Context::MIN_CONTEXT_SLOTS - 1; | 535 return number_of_context_slots + Context::MIN_CONTEXT_SLOTS - 1; |
527 } | 536 } |
528 } | 537 } |
529 return -1; | 538 return -1; |
530 } | 539 } |
531 | 540 |
532 | 541 |
533 int ContextSlotCache::Hash(Object* data, String* name) { | 542 int ContextSlotCache::Hash(Object* data, String* name) { |
534 // Uses only lower 32 bits if pointers are larger. | 543 // Uses only lower 32 bits if pointers are larger. |
535 uintptr_t addr_hash = | 544 uintptr_t addr_hash = |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 641 } |
633 #endif // DEBUG | 642 #endif // DEBUG |
634 | 643 |
635 | 644 |
636 // Make sure the classes get instantiated by the template system. | 645 // Make sure the classes get instantiated by the template system. |
637 template class ScopeInfo<FreeStoreAllocationPolicy>; | 646 template class ScopeInfo<FreeStoreAllocationPolicy>; |
638 template class ScopeInfo<PreallocatedStorage>; | 647 template class ScopeInfo<PreallocatedStorage>; |
639 template class ScopeInfo<ZoneListAllocationPolicy>; | 648 template class ScopeInfo<ZoneListAllocationPolicy>; |
640 | 649 |
641 } } // namespace v8::internal | 650 } } // namespace v8::internal |
OLD | NEW |