Skip to content

Commit

Permalink
[api] Remove deprecated HostImportModuleDynamicallyCallback
Browse files Browse the repository at this point in the history
Deprecation happend in v9.4

Bug: v8:11165
Change-Id: I7a28a9c50c25dbaad91cf254b9153154065108b9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3173678
Auto-Submit: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77002}
  • Loading branch information
camillobruni authored and V8 LUCI CQ committed Sep 23, 2021
1 parent d5b48f1 commit ab83685
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 90 deletions.
26 changes: 0 additions & 26 deletions include/v8-callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,32 +210,6 @@ using CreateHistogramCallback = void* (*)(const char* name, int min, int max,

using AddHistogramSampleCallback = void (*)(void* histogram, int sample);

/**
* HostImportModuleDynamicallyCallback is called when we require the
* embedder to load a module. This is used as part of the dynamic
* import syntax.
*
* The referrer contains metadata about the script/module that calls
* import.
*
* The specifier is the name of the module that should be imported.
*
* The embedder must compile, instantiate, evaluate the Module, and
* obtain its namespace object.
*
* The Promise returned from this function is forwarded to userland
* JavaScript. The embedder must resolve this promise with the module
* namespace object. In case of an exception, the embedder must reject
* this promise with the exception. If the promise creation itself
* fails (e.g. due to stack overflow), the embedder must propagate
* that exception by returning an empty MaybeLocal.
*/
using HostImportModuleDynamicallyCallback V8_DEPRECATED(
"Use HostImportModuleDynamicallyWithImportAssertionsCallback instead") =
MaybeLocal<Promise> (*)(Local<Context> context,
Local<ScriptOrModule> referrer,
Local<String> specifier);

// --- Exceptions ---

using FatalErrorCallback = void (*)(const char* location, const char* message);
Expand Down
10 changes: 0 additions & 10 deletions include/v8-isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,16 +613,6 @@ class V8_EXPORT Isolate {
void SetAbortOnUncaughtExceptionCallback(
AbortOnUncaughtExceptionCallback callback);

/**
* This specifies the callback called by the upcoming dynamic
* import() language feature to load modules.
*/
V8_DEPRECATED(
"Use the version of SetHostImportModuleDynamicallyCallback that takes a "
"HostImportModuleDynamicallyWithImportAssertionsCallback instead")
void SetHostImportModuleDynamicallyCallback(
HostImportModuleDynamicallyCallback callback);

/**
* This specifies the callback called by the upcoming dynamic
* import() language feature to load modules.
Expand Down
6 changes: 0 additions & 6 deletions src/api/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8561,12 +8561,6 @@ void Isolate::SetAbortOnUncaughtExceptionCallback(
isolate->SetAbortOnUncaughtExceptionCallback(callback);
}

void Isolate::SetHostImportModuleDynamicallyCallback(
i::Isolate::DeprecatedHostImportModuleDynamicallyCallback callback) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
isolate->SetHostImportModuleDynamicallyCallback(callback);
}

void Isolate::SetHostImportModuleDynamicallyCallback(
HostImportModuleDynamicallyWithImportAssertionsCallback callback) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
Expand Down
46 changes: 12 additions & 34 deletions src/execution/isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4272,12 +4272,8 @@ MaybeHandle<JSPromise> Isolate::RunHostImportModuleDynamicallyCallback(
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);
if (host_import_module_dynamically_callback_ == nullptr &&
host_import_module_dynamically_with_import_assertions_callback_ ==
nullptr) {
if (host_import_module_dynamically_with_import_assertions_callback_ ==
nullptr) {
Handle<Object> exception =
factory()->NewError(error_function(), MessageTemplate::kUnsupported);
return NewRejectedPromise(this, api_context, exception);
Expand All @@ -4293,34 +4289,21 @@ MaybeHandle<JSPromise> Isolate::RunHostImportModuleDynamicallyCallback(
DCHECK(!has_pending_exception());

v8::Local<v8::Promise> promise;

if (host_import_module_dynamically_with_import_assertions_callback_) {
Handle<FixedArray> import_assertions_array;
if (GetImportAssertionsFromArgument(maybe_import_assertions_argument)
.ToHandle(&import_assertions_array)) {
ASSIGN_RETURN_ON_SCHEDULED_EXCEPTION_VALUE(
this, promise,
host_import_module_dynamically_with_import_assertions_callback_(
api_context, v8::Utils::ScriptOrModuleToLocal(referrer),
v8::Utils::ToLocal(specifier_str),
ToApiHandle<v8::FixedArray>(import_assertions_array)),
MaybeHandle<JSPromise>());
return v8::Utils::OpenHandle(*promise);
} else {
Handle<Object> exception(pending_exception(), this);
clear_pending_exception();
return NewRejectedPromise(this, api_context, exception);
}

} else {
DCHECK_NOT_NULL(host_import_module_dynamically_callback_);
Handle<FixedArray> import_assertions_array;
if (GetImportAssertionsFromArgument(maybe_import_assertions_argument)
.ToHandle(&import_assertions_array)) {
ASSIGN_RETURN_ON_SCHEDULED_EXCEPTION_VALUE(
this, promise,
host_import_module_dynamically_callback_(
host_import_module_dynamically_with_import_assertions_callback_(
api_context, v8::Utils::ScriptOrModuleToLocal(referrer),
v8::Utils::ToLocal(specifier_str)),
v8::Utils::ToLocal(specifier_str),
ToApiHandle<v8::FixedArray>(import_assertions_array)),
MaybeHandle<JSPromise>());
return v8::Utils::OpenHandle(*promise);
} else {
Handle<Object> exception(pending_exception(), this);
clear_pending_exception();
return NewRejectedPromise(this, api_context, exception);
}
}

Expand Down Expand Up @@ -4411,11 +4394,6 @@ MaybeHandle<FixedArray> Isolate::GetImportAssertionsFromArgument(

void Isolate::ClearKeptObjects() { heap()->ClearKeptObjects(); }

void Isolate::SetHostImportModuleDynamicallyCallback(
DeprecatedHostImportModuleDynamicallyCallback callback) {
host_import_module_dynamically_callback_ = callback;
}

void Isolate::SetHostImportModuleDynamicallyCallback(
HostImportModuleDynamicallyWithImportAssertionsCallback callback) {
host_import_module_dynamically_with_import_assertions_callback_ = callback;
Expand Down
14 changes: 0 additions & 14 deletions src/execution/isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -1647,18 +1647,6 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {

void ClearKeptObjects();

// While deprecating v8::HostImportModuleDynamicallyCallback in v8.h we still
// need to support the version of the API that uses it, but we can't directly
// reference the deprecated version because of the enusing build warnings. So,
// we declare this matching type for temporary internal use.
// TODO(v8:10958) Delete this declaration and all references to it once
// v8::HostImportModuleDynamicallyCallback is removed.
typedef MaybeLocal<Promise> (*DeprecatedHostImportModuleDynamicallyCallback)(
v8::Local<v8::Context> context, v8::Local<v8::ScriptOrModule> referrer,
v8::Local<v8::String> specifier);

void SetHostImportModuleDynamicallyCallback(
DeprecatedHostImportModuleDynamicallyCallback callback);
void SetHostImportModuleDynamicallyCallback(
HostImportModuleDynamicallyWithImportAssertionsCallback callback);
MaybeHandle<JSPromise> RunHostImportModuleDynamicallyCallback(
Expand Down Expand Up @@ -2025,8 +2013,6 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
v8::Isolate::AtomicsWaitCallback atomics_wait_callback_ = nullptr;
void* atomics_wait_callback_data_ = nullptr;
PromiseHook promise_hook_ = nullptr;
DeprecatedHostImportModuleDynamicallyCallback
host_import_module_dynamically_callback_ = nullptr;
HostImportModuleDynamicallyWithImportAssertionsCallback
host_import_module_dynamically_with_import_assertions_callback_ = nullptr;
std::atomic<debug::CoverageMode> code_coverage_mode_{
Expand Down

0 comments on commit ab83685

Please sign in to comment.