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

Side by Side Diff: src/modules.cc

Issue 1078903002: Collect list of requested modules in ModuleDescriptor while parsing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « src/modules.h ('k') | src/parser.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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/modules.h" 7 #include "src/modules.h"
8 8
9 #include "src/ast-value-factory.h" 9 #include "src/ast-value-factory.h"
10 10
(...skipping 17 matching lines...) Expand all
28 ZoneHashMap::Entry* p = 28 ZoneHashMap::Entry* p =
29 exports_->Lookup(key, export_name->hash(), !IsFrozen(), allocator); 29 exports_->Lookup(key, export_name->hash(), !IsFrozen(), allocator);
30 if (p == nullptr || p->value != nullptr) { 30 if (p == nullptr || p->value != nullptr) {
31 *ok = false; 31 *ok = false;
32 } 32 }
33 33
34 p->value = const_cast<AstRawString*>(local_name); 34 p->value = const_cast<AstRawString*>(local_name);
35 } 35 }
36 36
37 37
38 void ModuleDescriptor::AddModuleRequest(const AstRawString* module_specifier,
39 Zone* zone) {
40 // TODO(adamk): Avoid this O(N) operation on each insert by storing
41 // a HashMap, or by de-duping after parsing.
42 if (requested_modules_.Contains(module_specifier)) return;
43 requested_modules_.Add(module_specifier, zone);
44 }
45
46
38 const AstRawString* ModuleDescriptor::LookupLocalExport( 47 const AstRawString* ModuleDescriptor::LookupLocalExport(
39 const AstRawString* export_name, Zone* zone) { 48 const AstRawString* export_name, Zone* zone) {
40 if (exports_ == nullptr) return nullptr; 49 if (exports_ == nullptr) return nullptr;
41 ZoneAllocationPolicy allocator(zone); 50 ZoneAllocationPolicy allocator(zone);
42 ZoneHashMap::Entry* entry = 51 ZoneHashMap::Entry* entry =
43 exports_->Lookup(const_cast<AstRawString*>(export_name), 52 exports_->Lookup(const_cast<AstRawString*>(export_name),
44 export_name->hash(), false, allocator); 53 export_name->hash(), false, allocator);
45 if (entry == nullptr) return nullptr; 54 if (entry == nullptr) return nullptr;
46 DCHECK_NOT_NULL(entry->value); 55 DCHECK_NOT_NULL(entry->value);
47 return static_cast<const AstRawString*>(entry->value); 56 return static_cast<const AstRawString*>(entry->value);
48 } 57 }
49 } 58 }
50 } // namespace v8::internal 59 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/modules.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698