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

Side by Side Diff: src/api.cc

Issue 2355033002: [modules] Add a requested_modules field to Module (Closed)
Patch Set: Created 4 years, 3 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 | « no previous file | src/factory.h » ('j') | src/objects.h » ('J')
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/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after
2041 2041
2042 MaybeLocal<Module> ScriptCompiler::CompileModule(Isolate* isolate, 2042 MaybeLocal<Module> ScriptCompiler::CompileModule(Isolate* isolate,
2043 Source* source) { 2043 Source* source) {
2044 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 2044 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
2045 2045
2046 auto maybe = CompileUnboundInternal(isolate, source, kNoCompileOptions, true); 2046 auto maybe = CompileUnboundInternal(isolate, source, kNoCompileOptions, true);
2047 Local<UnboundScript> unbound; 2047 Local<UnboundScript> unbound;
2048 if (!maybe.ToLocal(&unbound)) return MaybeLocal<Module>(); 2048 if (!maybe.ToLocal(&unbound)) return MaybeLocal<Module>();
2049 2049
2050 i::Handle<i::SharedFunctionInfo> shared = Utils::OpenHandle(*unbound); 2050 i::Handle<i::SharedFunctionInfo> shared = Utils::OpenHandle(*unbound);
2051 i::Handle<i::FixedArray> regular_exports = 2051 i::Handle<i::Module> module = i_isolate->factory()->NewModule(shared);
2052 i::handle(shared->scope_info()->ModuleDescriptorInfo()->regular_exports(),
2053 i_isolate);
2054 int regular_exports_length = regular_exports->length();
2055
2056 i::Handle<i::Module> module =
2057 i_isolate->factory()->NewModule(shared, regular_exports_length);
2058 2052
2059 // TODO(neis): This will create multiple cells for the same local variable if 2053 // TODO(neis): This will create multiple cells for the same local variable if
2060 // exported under multiple names, which is wrong but cannot be observed at the 2054 // exported under multiple names, which is wrong but cannot be observed at the
2061 // moment. This will be fixed by doing the full-fledged linking here once we 2055 // moment. This will be fixed by doing the full-fledged linking here once we
2062 // get there. 2056 // get there.
2057 i::Handle<i::FixedArray> regular_exports =
2058 i::handle(shared->scope_info()->ModuleDescriptorInfo()->regular_exports(),
2059 i_isolate);
2060 int regular_exports_length = regular_exports->length();
neis 2016/09/20 18:07:20 Since the length now isn't used elsewhere, I would
adamk 2016/09/20 18:16:16 Done.
2063 for (int i = 0; i < regular_exports_length; ++i) { 2061 for (int i = 0; i < regular_exports_length; ++i) {
2064 i::Handle<i::ModuleInfoEntry> entry = 2062 i::Handle<i::ModuleInfoEntry> entry =
2065 i::handle(i::ModuleInfoEntry::cast(regular_exports->get(i)), i_isolate); 2063 i::handle(i::ModuleInfoEntry::cast(regular_exports->get(i)), i_isolate);
2066 DCHECK(entry->import_name()->IsUndefined(i_isolate)); 2064 DCHECK(entry->import_name()->IsUndefined(i_isolate));
2067 i::Handle<i::String> export_name = 2065 i::Handle<i::String> export_name =
2068 handle(i::String::cast(entry->export_name()), i_isolate); 2066 handle(i::String::cast(entry->export_name()), i_isolate);
2069 i::Module::CreateExport(module, export_name); 2067 i::Module::CreateExport(module, export_name);
2070 } 2068 }
2071 2069
2072 return ToApiHandle<Module>(module); 2070 return ToApiHandle<Module>(module);
(...skipping 7299 matching lines...) Expand 10 before | Expand all | Expand 10 after
9372 Address callback_address = 9370 Address callback_address =
9373 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 9371 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
9374 VMState<EXTERNAL> state(isolate); 9372 VMState<EXTERNAL> state(isolate);
9375 ExternalCallbackScope call_scope(isolate, callback_address); 9373 ExternalCallbackScope call_scope(isolate, callback_address);
9376 callback(info); 9374 callback(info);
9377 } 9375 }
9378 9376
9379 9377
9380 } // namespace internal 9378 } // namespace internal
9381 } // namespace v8 9379 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/factory.h » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698