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

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

Issue 2473993002: [modules] Make handling of module info's regular exports more robust. (Closed)
Patch Set: cast size_t 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/scopeinfo.cc ('k') | src/factory.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 "src/ast/scopes.h" 5 #include "src/ast/scopes.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 Zone* zone = ast_value_factory->zone(); 157 Zone* zone = ast_value_factory->zone();
158 module_descriptor_ = new (zone) ModuleDescriptor(zone); 158 module_descriptor_ = new (zone) ModuleDescriptor(zone);
159 set_language_mode(STRICT); 159 set_language_mode(STRICT);
160 DeclareThis(ast_value_factory); 160 DeclareThis(ast_value_factory);
161 } 161 }
162 162
163 ModuleScope::ModuleScope(Isolate* isolate, Handle<ScopeInfo> scope_info, 163 ModuleScope::ModuleScope(Isolate* isolate, Handle<ScopeInfo> scope_info,
164 AstValueFactory* avfactory) 164 AstValueFactory* avfactory)
165 : DeclarationScope(avfactory->zone(), MODULE_SCOPE, scope_info) { 165 : DeclarationScope(avfactory->zone(), MODULE_SCOPE, scope_info) {
166 Zone* zone = avfactory->zone(); 166 Zone* zone = avfactory->zone();
167 ModuleInfo* module_info = scope_info->ModuleDescriptorInfo(); 167 Handle<ModuleInfo> module_info(scope_info->ModuleDescriptorInfo(), isolate);
168 168
169 set_language_mode(STRICT); 169 set_language_mode(STRICT);
170 module_descriptor_ = new (zone) ModuleDescriptor(zone); 170 module_descriptor_ = new (zone) ModuleDescriptor(zone);
171 171
172 // Deserialize special exports. 172 // Deserialize special exports.
173 Handle<FixedArray> special_exports(module_info->special_exports(), isolate); 173 Handle<FixedArray> special_exports(module_info->special_exports(), isolate);
174 for (int i = 0, n = special_exports->length(); i < n; ++i) { 174 for (int i = 0, n = special_exports->length(); i < n; ++i) {
175 Handle<ModuleInfoEntry> serialized_entry( 175 Handle<ModuleInfoEntry> serialized_entry(
176 ModuleInfoEntry::cast(special_exports->get(i)), isolate); 176 ModuleInfoEntry::cast(special_exports->get(i)), isolate);
177 module_descriptor_->AddSpecialExport( 177 module_descriptor_->AddSpecialExport(
178 ModuleDescriptor::Entry::Deserialize(isolate, avfactory, 178 ModuleDescriptor::Entry::Deserialize(isolate, avfactory,
179 serialized_entry), 179 serialized_entry),
180 avfactory->zone()); 180 avfactory->zone());
181 } 181 }
182 182
183 // Deserialize regular exports. 183 // Deserialize regular exports.
184 Handle<FixedArray> regular_exports(module_info->regular_exports(), isolate);
185 module_descriptor_->DeserializeRegularExports(isolate, avfactory, 184 module_descriptor_->DeserializeRegularExports(isolate, avfactory,
186 regular_exports); 185 module_info);
187 186
188 // Deserialize namespace imports. 187 // Deserialize namespace imports.
189 Handle<FixedArray> namespace_imports(module_info->namespace_imports(), 188 Handle<FixedArray> namespace_imports(module_info->namespace_imports(),
190 isolate); 189 isolate);
191 for (int i = 0, n = namespace_imports->length(); i < n; ++i) { 190 for (int i = 0, n = namespace_imports->length(); i < n; ++i) {
192 Handle<ModuleInfoEntry> serialized_entry( 191 Handle<ModuleInfoEntry> serialized_entry(
193 ModuleInfoEntry::cast(namespace_imports->get(i)), isolate); 192 ModuleInfoEntry::cast(namespace_imports->get(i)), isolate);
194 module_descriptor_->AddNamespaceImport( 193 module_descriptor_->AddNamespaceImport(
195 ModuleDescriptor::Entry::Deserialize(isolate, avfactory, 194 ModuleDescriptor::Entry::Deserialize(isolate, avfactory,
196 serialized_entry), 195 serialized_entry),
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 Variable* function = 2035 Variable* function =
2037 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr; 2036 is_function_scope() ? AsDeclarationScope()->function_var() : nullptr;
2038 bool is_function_var_in_context = 2037 bool is_function_var_in_context =
2039 function != nullptr && function->IsContextSlot(); 2038 function != nullptr && function->IsContextSlot();
2040 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS - 2039 return num_heap_slots() - Context::MIN_CONTEXT_SLOTS -
2041 (is_function_var_in_context ? 1 : 0); 2040 (is_function_var_in_context ? 1 : 0);
2042 } 2041 }
2043 2042
2044 } // namespace internal 2043 } // namespace internal
2045 } // namespace v8 2044 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast/scopeinfo.cc ('k') | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698