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

Unified Diff: src/runtime/runtime-module.cc

Issue 2703563002: [ESNext] Implement DynamicImportCall (Closed)
Patch Set: rebase Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-module.cc
diff --git a/src/runtime/runtime-module.cc b/src/runtime/runtime-module.cc
index f36a09b410bf00a8658882f021f0918bd6aff2c3..3c896d8c5668aa0f7ee60e2f5d735e0f8a02ec50 100644
--- a/src/runtime/runtime-module.cc
+++ b/src/runtime/runtime-module.cc
@@ -13,9 +13,36 @@ namespace internal {
RUNTIME_FUNCTION(Runtime_DynamicImportCall) {
HandleScope scope(isolate);
- DCHECK_EQ(1, args.length());
- // TODO(gsathya): Implement ImportCall.
- return isolate->heap()->undefined_value();
+ DCHECK_EQ(2, args.length());
+ CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
+ CONVERT_ARG_HANDLE_CHECKED(Object, specifier, 1);
+
+ Handle<JSPromise> promise = isolate->factory()->NewJSPromise();
+
+ Handle<String> specifier_str;
+ MaybeHandle<String> maybe_specifier = Object::ToString(isolate, specifier);
+ if (!maybe_specifier.ToHandle(&specifier_str)) {
+ DCHECK(isolate->has_pending_exception());
+ Handle<Object> reason(isolate->pending_exception(), isolate);
+ isolate->clear_pending_exception();
+
+ Handle<Object> argv[] = {promise, reason,
+ isolate->factory()->ToBoolean(false)};
+
+ RETURN_FAILURE_ON_EXCEPTION(
+ isolate, Execution::Call(isolate, isolate->promise_internal_reject(),
+ isolate->factory()->undefined_value(),
+ arraysize(argv), argv))
+ return *promise;
+ }
+ DCHECK(!isolate->has_pending_exception());
+
+ Handle<Script> script(Script::cast(function->shared()->script()));
+ Handle<String> source_url(String::cast(script->name()));
+
+ isolate->RunHostImportModuleDynamicallyCallback(source_url, specifier_str,
+ promise);
+ return *promise;
}
RUNTIME_FUNCTION(Runtime_GetModuleNamespace) {
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698