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

Side by Side Diff: src/scopeinfo.cc

Issue 7992005: Block scoped const variables. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments, function variable mode, preparser. Created 9 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
« no previous file with comments | « src/runtime.cc ('k') | src/scopes.h » ('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 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 function_name_ = proxy->name(); 132 function_name_ = proxy->name();
133 // Note that we must not find the function name in the context slot 133 // Note that we must not find the function name in the context slot
134 // list - instead it must be handled separately in the 134 // list - instead it must be handled separately in the
135 // Contexts::Lookup() function. Thus record an empty symbol here so we 135 // Contexts::Lookup() function. Thus record an empty symbol here so we
136 // get the correct number of context slots. 136 // get the correct number of context slots.
137 ASSERT(proxy->var()->index() - Context::MIN_CONTEXT_SLOTS == 137 ASSERT(proxy->var()->index() - Context::MIN_CONTEXT_SLOTS ==
138 context_slots_.length()); 138 context_slots_.length());
139 ASSERT(proxy->var()->index() - Context::MIN_CONTEXT_SLOTS == 139 ASSERT(proxy->var()->index() - Context::MIN_CONTEXT_SLOTS ==
140 context_modes_.length()); 140 context_modes_.length());
141 context_slots_.Add(FACTORY->empty_symbol()); 141 context_slots_.Add(FACTORY->empty_symbol());
142 context_modes_.Add(INTERNAL); 142 context_modes_.Add(proxy->var()->mode());
143 } 143 }
144 } 144 }
145 } 145 }
146 146
147 147
148 // Encoding format in a FixedArray object: 148 // Encoding format in a FixedArray object:
149 // 149 //
150 // - function name 150 // - function name
151 // 151 //
152 // - calls eval boolean flag 152 // - calls eval boolean flag
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 p = p0 + number_of_parameter_slots; 533 p = p0 + number_of_parameter_slots;
534 while (p > p0) { 534 while (p > p0) {
535 p--; 535 p--;
536 if (*p == name) return static_cast<int>(p - p0); 536 if (*p == name) return static_cast<int>(p - p0);
537 } 537 }
538 } 538 }
539 return -1; 539 return -1;
540 } 540 }
541 541
542 542
543 int SerializedScopeInfo::FunctionContextSlotIndex(String* name) { 543 int SerializedScopeInfo::FunctionContextSlotIndex(String* name,
544 VariableMode* mode) {
544 ASSERT(name->IsSymbol()); 545 ASSERT(name->IsSymbol());
545 if (length() > 0) { 546 if (length() > 0) {
546 Object** p = data_start(); 547 Object** p = data_start();
547 if (*p == name) { 548 if (*p == name) {
548 p = ContextEntriesAddr(); 549 p = ContextEntriesAddr();
549 int number_of_context_slots; 550 int number_of_context_slots;
550 ReadInt(p, &number_of_context_slots); 551 p = ReadInt(p, &number_of_context_slots);
551 ASSERT(number_of_context_slots != 0); 552 ASSERT(number_of_context_slots != 0);
552 // The function context slot is the last entry. 553 // The function context slot is the last entry.
554 if (mode != NULL) {
555 // Seek to context slot entry.
556 p += (number_of_context_slots - 1) * 2;
557 // Seek to mode.
558 ++p;
559 ReadInt(p, mode);
560 }
553 return number_of_context_slots + Context::MIN_CONTEXT_SLOTS - 1; 561 return number_of_context_slots + Context::MIN_CONTEXT_SLOTS - 1;
554 } 562 }
555 } 563 }
556 return -1; 564 return -1;
557 } 565 }
558 566
559 567
560 int ContextSlotCache::Hash(Object* data, String* name) { 568 int ContextSlotCache::Hash(Object* data, String* name) {
561 // Uses only lower 32 bits if pointers are larger. 569 // Uses only lower 32 bits if pointers are larger.
562 uintptr_t addr_hash = 570 uintptr_t addr_hash =
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 } 667 }
660 #endif // DEBUG 668 #endif // DEBUG
661 669
662 670
663 // Make sure the classes get instantiated by the template system. 671 // Make sure the classes get instantiated by the template system.
664 template class ScopeInfo<FreeStoreAllocationPolicy>; 672 template class ScopeInfo<FreeStoreAllocationPolicy>;
665 template class ScopeInfo<PreallocatedStorage>; 673 template class ScopeInfo<PreallocatedStorage>;
666 template class ScopeInfo<ZoneListAllocationPolicy>; 674 template class ScopeInfo<ZoneListAllocationPolicy>;
667 675
668 } } // namespace v8::internal 676 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698