V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
runtime-module.cc
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 RUNTIME_FUNCTION(Runtime_DynamicImportCall) {
16  HandleScope scope(isolate);
17  DCHECK_EQ(2, args.length());
18  CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
19  CONVERT_ARG_HANDLE_CHECKED(Object, specifier, 1);
20 
21  Handle<Script> script(Script::cast(function->shared()->script()), isolate);
22 
23  while (script->has_eval_from_shared()) {
24  script =
25  handle(Script::cast(script->eval_from_shared()->script()), isolate);
26  }
27 
28  RETURN_RESULT_OR_FAILURE(
29  isolate,
30  isolate->RunHostImportModuleDynamicallyCallback(script, specifier));
31 }
32 
33 RUNTIME_FUNCTION(Runtime_GetModuleNamespace) {
34  HandleScope scope(isolate);
35  DCHECK_EQ(1, args.length());
36  CONVERT_SMI_ARG_CHECKED(module_request, 0);
37  Handle<Module> module(isolate->context()->module(), isolate);
38  return *Module::GetModuleNamespace(isolate, module, module_request);
39 }
40 
41 RUNTIME_FUNCTION(Runtime_GetImportMetaObject) {
42  HandleScope scope(isolate);
43  DCHECK_EQ(0, args.length());
44  Handle<Module> module(isolate->context()->module(), isolate);
45  return *isolate->RunHostInitializeImportMetaObjectCallback(module);
46 }
47 
48 } // namespace internal
49 } // namespace v8
Definition: libplatform.h:13