v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
runtime-module.cc
Go to the documentation of this file.
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
8
9namespace v8 {
10namespace internal {
11
12RUNTIME_FUNCTION(Runtime_DynamicImportCall) {
13 HandleScope scope(isolate);
14 DCHECK_LE(3, args.length());
15 DCHECK_GE(4, args.length());
17 Handle<Object> specifier = args.at(1);
18 ModuleImportPhase phase =
19 static_cast<ModuleImportPhase>(args.smi_value_at(2));
20
21 MaybeDirectHandle<Object> import_options;
22 if (args.length() == 4) {
23 import_options = args.at<Object>(3);
24 }
25
26 DirectHandle<Script> referrer_script(
27 Cast<Script>(function->shared()->script())->GetEvalOrigin(), isolate);
29 isolate, isolate->RunHostImportModuleDynamicallyCallback(
30 referrer_script, specifier, phase, import_options));
31}
32
33RUNTIME_FUNCTION(Runtime_GetModuleNamespace) {
34 HandleScope scope(isolate);
35 DCHECK_EQ(1, args.length());
36 int module_request = args.smi_value_at(0);
37 DirectHandle<SourceTextModule> module(isolate->context()->module(), isolate);
38 return *SourceTextModule::GetModuleNamespace(isolate, module, module_request);
39}
40
41RUNTIME_FUNCTION(Runtime_GetImportMetaObject) {
42 HandleScope scope(isolate);
43 DCHECK_EQ(0, args.length());
44 DirectHandle<SourceTextModule> module(isolate->context()->module(), isolate);
46 SourceTextModule::GetImportMeta(isolate, module));
47}
48
49RUNTIME_FUNCTION(Runtime_GetModuleNamespaceExport) {
50 HandleScope scope(isolate);
51 DCHECK_EQ(2, args.length());
52 DirectHandle<JSModuleNamespace> module_namespace =
54 Handle<String> name = args.at<String>(1);
55 if (!module_namespace->HasExport(isolate, name)) {
57 isolate, NewReferenceError(MessageTemplate::kNotDefined, name));
58 }
59 RETURN_RESULT_OR_FAILURE(isolate, module_namespace->GetExport(isolate, name));
60}
61
62} // namespace internal
63} // namespace v8
static V8_EXPORT_PRIVATE MaybeHandle< JSObject > GetImportMeta(Isolate *isolate, DirectHandle< SourceTextModule > module)
static DirectHandle< JSModuleNamespace > GetModuleNamespace(Isolate *isolate, DirectHandle< SourceTextModule > module, int module_request)
#define RUNTIME_FUNCTION(Name)
Definition arguments.h:162
#define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call)
Definition isolate.h:294
#define RETURN_RESULT_OR_FAILURE(isolate, call)
Definition isolate.h:264
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
ModuleImportPhase
#define DCHECK_LE(v1, v2)
Definition logging.h:490
#define DCHECK_GE(v1, v2)
Definition logging.h:488
#define DCHECK_EQ(v1, v2)
Definition logging.h:485