| Index: src/runtime/runtime-module.cc
|
| diff --git a/src/runtime/runtime-module.cc b/src/runtime/runtime-module.cc
|
| index f36a09b410bf00a8658882f021f0918bd6aff2c3..92bbed4f1e22d7a632306fb929e31d4a4344ebd0 100644
|
| --- a/src/runtime/runtime-module.cc
|
| +++ b/src/runtime/runtime-module.cc
|
| @@ -13,9 +13,39 @@ 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;
|
| + v8::TryCatch catcher(reinterpret_cast<v8::Isolate*>(isolate));
|
| + MaybeHandle<String> maybe_specifier = Object::ToString(isolate, specifier);
|
| + if (!maybe_specifier.ToHandle(&specifier_str)) {
|
| + DCHECK(catcher.HasCaught());
|
| + MaybeHandle<Object> reason = v8::Utils::OpenHandle(*catcher.Exception());
|
| + isolate->OptionalRescheduleException(true);
|
| +
|
| + Handle<Object> argv[] = {promise, reason.ToHandleChecked(),
|
| + 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;
|
| + }
|
| +
|
| + Handle<String> source_url = isolate->factory()->empty_string();
|
| + Handle<Script> script(Script::cast(function->shared()->script()));
|
| + if (script->name()->IsString()) {
|
| + source_url = handle(String::cast(script->name()), isolate);
|
| + }
|
| +
|
| + isolate->RunHostImportModuleDynamicallyCallback(source_url, specifier_str,
|
| + promise);
|
| + return *promise;
|
| }
|
|
|
| RUNTIME_FUNCTION(Runtime_GetModuleNamespace) {
|
|
|