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

Side by Side Diff: src/objects.cc

Issue 2406973003: Revert of [modules] Store Module metadata in per-Context EmbedderData (Closed)
Patch Set: Created 4 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
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 19833 matching lines...) Expand 10 before | Expand all | Expand 10 after
19844 // Unresolvable. 19844 // Unresolvable.
19845 if (must_resolve) { 19845 if (must_resolve) {
19846 THROW_NEW_ERROR(isolate, 19846 THROW_NEW_ERROR(isolate,
19847 NewSyntaxError(MessageTemplate::kUnresolvableExport, name), 19847 NewSyntaxError(MessageTemplate::kUnresolvableExport, name),
19848 Cell); 19848 Cell);
19849 } 19849 }
19850 return MaybeHandle<Cell>(); 19850 return MaybeHandle<Cell>();
19851 } 19851 }
19852 19852
19853 bool Module::Instantiate(Handle<Module> module, v8::Local<v8::Context> context, 19853 bool Module::Instantiate(Handle<Module> module, v8::Local<v8::Context> context,
19854 v8::Module::ResolveCallback callback) { 19854 v8::Module::ResolveCallback callback,
19855 v8::Local<v8::Value> callback_data) {
19855 // Already instantiated. 19856 // Already instantiated.
19856 if (module->code()->IsJSFunction()) return true; 19857 if (module->code()->IsJSFunction()) return true;
19857 19858
19858 Isolate* isolate = module->GetIsolate(); 19859 Isolate* isolate = module->GetIsolate();
19859 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(module->code()), 19860 Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(module->code()),
19860 isolate); 19861 isolate);
19861 Handle<JSFunction> function = 19862 Handle<JSFunction> function =
19862 isolate->factory()->NewFunctionFromSharedFunctionInfo( 19863 isolate->factory()->NewFunctionFromSharedFunctionInfo(
19863 shared, 19864 shared,
19864 handle(Utils::OpenHandle(*context)->native_context(), isolate)); 19865 handle(Utils::OpenHandle(*context)->native_context(), isolate));
(...skipping 25 matching lines...) Expand all
19890 } 19891 }
19891 19892
19892 Handle<FixedArray> module_requests(module_info->module_requests(), isolate); 19893 Handle<FixedArray> module_requests(module_info->module_requests(), isolate);
19893 for (int i = 0, length = module_requests->length(); i < length; ++i) { 19894 for (int i = 0, length = module_requests->length(); i < length; ++i) {
19894 Handle<String> specifier(String::cast(module_requests->get(i)), isolate); 19895 Handle<String> specifier(String::cast(module_requests->get(i)), isolate);
19895 v8::Local<v8::Module> api_requested_module; 19896 v8::Local<v8::Module> api_requested_module;
19896 // TODO(adamk): Revisit these failure cases once d8 knows how to 19897 // TODO(adamk): Revisit these failure cases once d8 knows how to
19897 // persist a module_map across multiple top-level module loads, as 19898 // persist a module_map across multiple top-level module loads, as
19898 // the current module is left in a "half-instantiated" state. 19899 // the current module is left in a "half-instantiated" state.
19899 if (!callback(context, v8::Utils::ToLocal(specifier), 19900 if (!callback(context, v8::Utils::ToLocal(specifier),
19900 v8::Utils::ToLocal(module)) 19901 v8::Utils::ToLocal(module), callback_data)
19901 .ToLocal(&api_requested_module)) { 19902 .ToLocal(&api_requested_module)) {
19902 // TODO(adamk): Give this a better error message. But this is a 19903 // TODO(adamk): Give this a better error message. But this is a
19903 // misuse of the API anyway. 19904 // misuse of the API anyway.
19904 isolate->ThrowIllegalOperation(); 19905 isolate->ThrowIllegalOperation();
19905 return false; 19906 return false;
19906 } 19907 }
19907 Handle<Module> requested_module = Utils::OpenHandle(*api_requested_module); 19908 Handle<Module> requested_module = Utils::OpenHandle(*api_requested_module);
19908 module->requested_modules()->set(i, *requested_module); 19909 module->requested_modules()->set(i, *requested_module);
19909 if (!Instantiate(requested_module, context, callback)) { 19910 if (!Instantiate(requested_module, context, callback, callback_data)) {
19910 return false; 19911 return false;
19911 } 19912 }
19912 } 19913 }
19913 19914
19914 Zone zone(isolate->allocator()); 19915 Zone zone(isolate->allocator());
19915 19916
19916 // Resolve imports. 19917 // Resolve imports.
19917 Handle<FixedArray> regular_imports(module_info->regular_imports(), isolate); 19918 Handle<FixedArray> regular_imports(module_info->regular_imports(), isolate);
19918 for (int i = 0, n = regular_imports->length(); i < n; ++i) { 19919 for (int i = 0, n = regular_imports->length(); i < n; ++i) {
19919 Handle<ModuleInfoEntry> entry( 19920 Handle<ModuleInfoEntry> entry(
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
20104 ns, Accessors::ModuleNamespaceEntryInfo(isolate, name, attr)) 20105 ns, Accessors::ModuleNamespaceEntryInfo(isolate, name, attr))
20105 .Check(); 20106 .Check();
20106 } 20107 }
20107 JSObject::PreventExtensions(ns, THROW_ON_ERROR).ToChecked(); 20108 JSObject::PreventExtensions(ns, THROW_ON_ERROR).ToChecked();
20108 20109
20109 return ns; 20110 return ns;
20110 } 20111 }
20111 20112
20112 } // namespace internal 20113 } // namespace internal
20113 } // namespace v8 20114 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698