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

Side by Side Diff: src/ast/scopeinfo.cc

Issue 2460233003: [modules] Assign cell indices at validation time. (Closed)
Patch Set: Rebase Created 4 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 unified diff | Download patch
« no previous file with comments | « src/ast/modules.cc ('k') | src/ast/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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "src/ast/context-slot-cache.h" 7 #include "src/ast/context-slot-cache.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/ast/variables.h" 9 #include "src/ast/variables.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 int entry = ModuleVariablesIndex(); 644 int entry = ModuleVariablesIndex();
645 for (int i = 0; i < module_vars_count; ++i) { 645 for (int i = 0; i < module_vars_count; ++i) {
646 if (*name == get(entry + kModuleVariableNameOffset)) { 646 if (*name == get(entry + kModuleVariableNameOffset)) {
647 int index; 647 int index;
648 ModuleVariable(i, nullptr, &index, mode, init_flag, maybe_assigned_flag); 648 ModuleVariable(i, nullptr, &index, mode, init_flag, maybe_assigned_flag);
649 return index; 649 return index;
650 } 650 }
651 entry += kModuleVariableEntryLength; 651 entry += kModuleVariableEntryLength;
652 } 652 }
653 653
654 return -1; 654 return 0;
655 } 655 }
656 656
657 int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info, 657 int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info,
658 Handle<String> name, VariableMode* mode, 658 Handle<String> name, VariableMode* mode,
659 InitializationFlag* init_flag, 659 InitializationFlag* init_flag,
660 MaybeAssignedFlag* maybe_assigned_flag) { 660 MaybeAssignedFlag* maybe_assigned_flag) {
661 DCHECK(name->IsInternalizedString()); 661 DCHECK(name->IsInternalizedString());
662 DCHECK_NOT_NULL(mode); 662 DCHECK_NOT_NULL(mode);
663 DCHECK_NOT_NULL(init_flag); 663 DCHECK_NOT_NULL(init_flag);
664 DCHECK_NOT_NULL(maybe_assigned_flag); 664 DCHECK_NOT_NULL(maybe_assigned_flag);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 796
797 int entry = ModuleVariablesIndex() + i * kModuleVariableEntryLength; 797 int entry = ModuleVariablesIndex() + i * kModuleVariableEntryLength;
798 int properties = 798 int properties =
799 Smi::cast(get(entry + kModuleVariablePropertiesOffset))->value(); 799 Smi::cast(get(entry + kModuleVariablePropertiesOffset))->value();
800 800
801 if (name != nullptr) { 801 if (name != nullptr) {
802 *name = String::cast(get(entry + kModuleVariableNameOffset)); 802 *name = String::cast(get(entry + kModuleVariableNameOffset));
803 } 803 }
804 if (index != nullptr) { 804 if (index != nullptr) {
805 *index = Smi::cast(get(entry + kModuleVariableIndexOffset))->value(); 805 *index = Smi::cast(get(entry + kModuleVariableIndexOffset))->value();
806 DCHECK_NE(*index, 0);
806 } 807 }
807 if (mode != nullptr) { 808 if (mode != nullptr) {
808 *mode = VariableModeField::decode(properties); 809 *mode = VariableModeField::decode(properties);
809 } 810 }
810 if (init_flag != nullptr) { 811 if (init_flag != nullptr) {
811 *init_flag = InitFlagField::decode(properties); 812 *init_flag = InitFlagField::decode(properties);
812 } 813 }
813 if (maybe_assigned_flag != nullptr) { 814 if (maybe_assigned_flag != nullptr) {
814 *maybe_assigned_flag = MaybeAssignedFlagField::decode(properties); 815 *maybe_assigned_flag = MaybeAssignedFlagField::decode(properties);
815 } 816 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 } 858 }
858 859
859 PrintF("}\n"); 860 PrintF("}\n");
860 } 861 }
861 #endif // DEBUG 862 #endif // DEBUG
862 863
863 Handle<ModuleInfoEntry> ModuleInfoEntry::New(Isolate* isolate, 864 Handle<ModuleInfoEntry> ModuleInfoEntry::New(Isolate* isolate,
864 Handle<Object> export_name, 865 Handle<Object> export_name,
865 Handle<Object> local_name, 866 Handle<Object> local_name,
866 Handle<Object> import_name, 867 Handle<Object> import_name,
867 Handle<Object> module_request, 868 int module_request, int cell_index,
868 int beg_pos, int end_pos) { 869 int beg_pos, int end_pos) {
869 Handle<ModuleInfoEntry> result = isolate->factory()->NewModuleInfoEntry(); 870 Handle<ModuleInfoEntry> result = isolate->factory()->NewModuleInfoEntry();
870 result->set(kExportNameIndex, *export_name); 871 result->set(kExportNameIndex, *export_name);
871 result->set(kLocalNameIndex, *local_name); 872 result->set(kLocalNameIndex, *local_name);
872 result->set(kImportNameIndex, *import_name); 873 result->set(kImportNameIndex, *import_name);
873 result->set(kModuleRequestIndex, *module_request); 874 result->set(kModuleRequestIndex, Smi::FromInt(module_request));
875 result->set(kCellIndexIndex, Smi::FromInt(cell_index));
874 result->set(kBegPosIndex, Smi::FromInt(beg_pos)); 876 result->set(kBegPosIndex, Smi::FromInt(beg_pos));
875 result->set(kEndPosIndex, Smi::FromInt(end_pos)); 877 result->set(kEndPosIndex, Smi::FromInt(end_pos));
876 return result; 878 return result;
877 } 879 }
878 880
879 Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, Zone* zone, 881 Handle<ModuleInfo> ModuleInfo::New(Isolate* isolate, Zone* zone,
880 ModuleDescriptor* descr) { 882 ModuleDescriptor* descr) {
881 // Serialize module requests. 883 // Serialize module requests.
882 Handle<FixedArray> module_requests = isolate->factory()->NewFixedArray( 884 Handle<FixedArray> module_requests = isolate->factory()->NewFixedArray(
883 static_cast<int>(descr->module_requests().size())); 885 static_cast<int>(descr->module_requests().size()));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 if (String::cast(entry->local_name())->Equals(*local_name)) { 944 if (String::cast(entry->local_name())->Equals(*local_name)) {
943 return entry; 945 return entry;
944 } 946 }
945 } 947 }
946 UNREACHABLE(); 948 UNREACHABLE();
947 return Handle<ModuleInfoEntry>(); 949 return Handle<ModuleInfoEntry>();
948 } 950 }
949 951
950 } // namespace internal 952 } // namespace internal
951 } // namespace v8 953 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/modules.cc ('k') | src/ast/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698