Line data Source code
1 : // Copyright 2016 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #include "src/arguments-inl.h"
6 : #include "src/counters.h"
7 : #include "src/objects-inl.h"
8 : #include "src/objects/js-promise.h"
9 : #include "src/objects/module.h"
10 : #include "src/runtime/runtime-utils.h"
11 :
12 : namespace v8 {
13 : namespace internal {
14 :
15 954 : RUNTIME_FUNCTION(Runtime_DynamicImportCall) {
16 : HandleScope scope(isolate);
17 : DCHECK_EQ(2, args.length());
18 477 : CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
19 : CONVERT_ARG_HANDLE_CHECKED(Object, specifier, 1);
20 :
21 954 : Handle<Script> script(Script::cast(function->shared()->script()), isolate);
22 :
23 535 : while (script->has_eval_from_shared()) {
24 : script =
25 116 : handle(Script::cast(script->eval_from_shared()->script()), isolate);
26 : }
27 :
28 954 : RETURN_RESULT_OR_FAILURE(
29 : isolate,
30 : isolate->RunHostImportModuleDynamicallyCallback(script, specifier));
31 : }
32 :
33 478 : RUNTIME_FUNCTION(Runtime_GetModuleNamespace) {
34 : HandleScope scope(isolate);
35 : DCHECK_EQ(1, args.length());
36 239 : CONVERT_SMI_ARG_CHECKED(module_request, 0);
37 478 : Handle<Module> module(isolate->context()->module(), isolate);
38 478 : return *Module::GetModuleNamespace(isolate, module, module_request);
39 : }
40 :
41 68 : RUNTIME_FUNCTION(Runtime_GetImportMetaObject) {
42 : HandleScope scope(isolate);
43 : DCHECK_EQ(0, args.length());
44 68 : Handle<Module> module(isolate->context()->module(), isolate);
45 68 : return *isolate->RunHostInitializeImportMetaObjectCallback(module);
46 : }
47 :
48 : } // namespace internal
49 122036 : } // namespace v8
|