Commit 7b6b1b1d authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[modules] Add CHECK to dynamic import

https://crrev.com/c/3110611 has landed, thus we can revert the temporary
workaround.

Bug: chromium:1237730
Change-Id: Ieb39ff07baddd03dc41c716d921496eb4d539fae
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3114137
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76449}
parent 88893c9e
......@@ -4252,18 +4252,16 @@ MaybeHandle<JSPromise> NewRejectedPromise(Isolate* isolate,
} // namespace
MaybeHandle<JSPromise> Isolate::RunHostImportModuleDynamicallyCallback(
MaybeHandle<Script> maybe_referrer, Handle<Object> specifier,
Handle<Script> referrer, Handle<Object> specifier,
MaybeHandle<Object> maybe_import_assertions_argument) {
v8::Local<v8::Context> api_context =
v8::Utils::ToLocal(Handle<Context>(native_context()));
DCHECK(host_import_module_dynamically_callback_ == nullptr ||
host_import_module_dynamically_with_import_assertions_callback_ ==
nullptr);
Handle<Script> referrer;
if (!maybe_referrer.ToHandle(&referrer) ||
(host_import_module_dynamically_callback_ == nullptr &&
host_import_module_dynamically_with_import_assertions_callback_ ==
nullptr)) {
if (host_import_module_dynamically_callback_ == nullptr &&
host_import_module_dynamically_with_import_assertions_callback_ ==
nullptr) {
Handle<Object> exception =
factory()->NewError(error_function(), MessageTemplate::kUnsupported);
return NewRejectedPromise(this, api_context, exception);
......
......@@ -1666,7 +1666,7 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
void SetHostImportModuleDynamicallyCallback(
HostImportModuleDynamicallyWithImportAssertionsCallback callback);
MaybeHandle<JSPromise> RunHostImportModuleDynamicallyCallback(
MaybeHandle<Script> referrer, Handle<Object> specifier,
Handle<Script> referrer, Handle<Object> specifier,
MaybeHandle<Object> maybe_import_assertions_argument);
void SetHostInitializeImportMetaObjectCallback(
......
......@@ -13,11 +13,11 @@ namespace v8 {
namespace internal {
namespace {
MaybeHandle<Script> GetEvalOrigin(Isolate* isolate, Script origin_script) {
Handle<Script> GetEvalOrigin(Isolate* isolate, Script origin_script) {
DisallowGarbageCollection no_gc;
while (origin_script.has_eval_from_shared()) {
HeapObject maybe_script = origin_script.eval_from_shared().script();
if (V8_UNLIKELY(!maybe_script.IsScript())) return kNullMaybeHandle;
CHECK(maybe_script.IsScript());
origin_script = Script::cast(maybe_script);
}
return handle(origin_script, isolate);
......@@ -37,9 +37,8 @@ RUNTIME_FUNCTION(Runtime_DynamicImportCall) {
import_assertions = args.at<Object>(2);
}
MaybeHandle<Script> referrer_script =
Handle<Script> referrer_script =
GetEvalOrigin(isolate, Script::cast(function->shared().script()));
RETURN_RESULT_OR_FAILURE(isolate,
isolate->RunHostImportModuleDynamicallyCallback(
referrer_script, specifier, import_assertions));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment