Commit de4c0042 authored by Shu-yu Guo's avatar Shu-yu Guo Committed by Commit Bot

[weakrefs] Remove deprecated FinalizationGroup V8 API

Bug: v8:8179
Change-Id: I16170a197028beb35309b15613004b29a956896c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2171696Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Auto-Submit: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67492}
parent 0e2e00f4
......@@ -5933,37 +5933,6 @@ class V8_EXPORT RegExp : public Object {
static void CheckCast(Value* obj);
};
/**
* An instance of the built-in FinalizationRegistry constructor.
*
* The C++ name is FinalizationGroup for backwards compatibility. This API is
* experimental and deprecated.
*/
class V8_EXPORT FinalizationGroup : public Object {
public:
/**
* Runs the cleanup callback of the given FinalizationRegistry.
*
* V8 will inform the embedder that there are finalizer callbacks be
* called through HostCleanupFinalizationGroupCallback.
*
* HostCleanupFinalizationGroupCallback should schedule a task to
* call FinalizationGroup::Cleanup() at some point in the
* future. It's the embedders responsiblity to make this call at a
* time which does not interrupt synchronous ECMAScript code
* execution.
*
* If the result is Nothing<bool> then an exception has
* occurred. Otherwise the result is |true| if the cleanup callback
* was called successfully. The result is never |false|.
*/
V8_DEPRECATED(
"FinalizationGroup cleanup is automatic if "
"HostCleanupFinalizationGroupCallback is not set")
static V8_WARN_UNUSED_RESULT Maybe<bool> Cleanup(
Local<FinalizationGroup> finalization_group);
};
/**
* A JavaScript value that wraps a C++ void*. This type of value is mainly used
* to associate C++ data structures with JavaScript objects.
......@@ -7216,20 +7185,6 @@ typedef void (*AddCrashKeyCallback)(CrashKeyId id, const std::string& value);
typedef void (*BeforeCallEnteredCallback)(Isolate*);
typedef void (*CallCompletedCallback)(Isolate*);
/**
* HostCleanupFinalizationGroupCallback is called when we require the
* embedder to enqueue a task that would call
* FinalizationGroup::Cleanup().
*
* The FinalizationGroup is the one for which the embedder needs to
* call FinalizationGroup::Cleanup() on.
*
* The context provided is the one in which the FinalizationGroup was
* created in.
*/
typedef void (*HostCleanupFinalizationGroupCallback)(
Local<Context> context, Local<FinalizationGroup> fg);
/**
* HostImportModuleDynamicallyCallback is called when we require the
* embedder to load a module. This is used as part of the dynamic
......@@ -8567,17 +8522,6 @@ class V8_EXPORT Isolate {
void SetAbortOnUncaughtExceptionCallback(
AbortOnUncaughtExceptionCallback callback);
/**
* This specifies the callback to be called when FinalizationRegistries
* are ready to be cleaned up and require FinalizationGroup::Cleanup()
* to be called in a future task.
*/
V8_DEPRECATED(
"FinalizationRegistry cleanup is automatic if "
"HostCleanupFinalizationGroupCallback is not set")
void SetHostCleanupFinalizationGroupCallback(
HostCleanupFinalizationGroupCallback callback);
/**
* This specifies the callback called by the upcoming dynamic
* import() language feature to load modules.
......
......@@ -86,7 +86,6 @@ MAKE_TO_LOCAL(ToLocal, JSArrayBufferView, ArrayBufferView)
MAKE_TO_LOCAL(ToLocal, JSDataView, DataView)
MAKE_TO_LOCAL(ToLocal, JSTypedArray, TypedArray)
MAKE_TO_LOCAL(ToLocalShared, JSArrayBuffer, SharedArrayBuffer)
MAKE_TO_LOCAL(ToLocal, JSFinalizationRegistry, FinalizationGroup)
TYPED_ARRAYS(MAKE_TO_LOCAL_TYPED_ARRAY)
......
......@@ -8346,33 +8346,6 @@ void Isolate::SetAbortOnUncaughtExceptionCallback(
isolate->SetAbortOnUncaughtExceptionCallback(callback);
}
void Isolate::SetHostCleanupFinalizationGroupCallback(
HostCleanupFinalizationGroupCallback callback) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
isolate->SetHostCleanupFinalizationGroupCallback(callback);
}
Maybe<bool> FinalizationGroup::Cleanup(
Local<FinalizationGroup> finalization_group) {
i::Handle<i::JSFinalizationRegistry> fr =
Utils::OpenHandle(*finalization_group);
i::Isolate* isolate = fr->native_context().GetIsolate();
i::Handle<i::Context> i_context(fr->native_context(), isolate);
Local<Context> context = Utils::ToLocal(i_context);
ENTER_V8(isolate, context, FinalizationGroup, Cleanup, Nothing<bool>(),
i::HandleScope);
i::Handle<i::Object> callback(fr->cleanup(), isolate);
i::Handle<i::Object> argv[] = {callback};
fr->set_scheduled_for_cleanup(false);
has_pending_exception =
i::Execution::CallBuiltin(isolate,
isolate->finalization_registry_cleanup_some(),
fr, arraysize(argv), argv)
.is_null();
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
return Just(true);
}
void Isolate::SetHostImportModuleDynamicallyCallback(
HostImportModuleDynamicallyCallback callback) {
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
......
......@@ -94,7 +94,6 @@ class RegisteredExtension {
V(Data, Object) \
V(RegExp, JSRegExp) \
V(Object, JSReceiver) \
V(FinalizationGroup, JSFinalizationRegistry) \
V(Array, JSArray) \
V(Map, JSMap) \
V(Set, JSSet) \
......@@ -207,8 +206,6 @@ class Utils {
v8::internal::Handle<v8::internal::JSTypedArray> obj);
static inline Local<BigUint64Array> ToLocalBigUint64Array(
v8::internal::Handle<v8::internal::JSTypedArray> obj);
static inline Local<FinalizationGroup> ToLocal(
v8::internal::Handle<v8::internal::JSFinalizationRegistry> obj);
static inline Local<SharedArrayBuffer> ToLocalShared(
v8::internal::Handle<v8::internal::JSArrayBuffer> obj);
......
......@@ -4028,21 +4028,6 @@ MaybeHandle<JSPromise> Isolate::RunHostImportModuleDynamicallyCallback(
void Isolate::ClearKeptObjects() { heap()->ClearKeptObjects(); }
void Isolate::SetHostCleanupFinalizationGroupCallback(
HostCleanupFinalizationGroupCallback callback) {
host_cleanup_finalization_group_callback_ = callback;
}
void Isolate::RunHostCleanupFinalizationGroupCallback(
Handle<JSFinalizationRegistry> fr) {
if (host_cleanup_finalization_group_callback_ != nullptr) {
v8::Local<v8::Context> api_context =
v8::Utils::ToLocal(handle(Context::cast(fr->native_context()), this));
host_cleanup_finalization_group_callback_(api_context,
v8::Utils::ToLocal(fr));
}
}
void Isolate::SetHostImportModuleDynamicallyCallback(
HostImportModuleDynamicallyCallback callback) {
host_import_module_dynamically_callback_ = callback;
......
......@@ -1416,14 +1416,6 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
bool IsInAnyContext(Object object, uint32_t index);
void ClearKeptObjects();
void SetHostCleanupFinalizationGroupCallback(
HostCleanupFinalizationGroupCallback callback);
HostCleanupFinalizationGroupCallback
host_cleanup_finalization_group_callback() const {
return host_cleanup_finalization_group_callback_;
}
void RunHostCleanupFinalizationGroupCallback(
Handle<JSFinalizationRegistry> fr);
void SetHostImportModuleDynamicallyCallback(
HostImportModuleDynamicallyCallback callback);
......@@ -1680,8 +1672,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;
HostCleanupFinalizationGroupCallback
host_cleanup_finalization_group_callback_ = nullptr;
HostImportModuleDynamicallyCallback host_import_module_dynamically_callback_ =
nullptr;
HostInitializeImportMetaObjectCallback
......
......@@ -37,7 +37,6 @@ void FinalizationRegistryCleanupTask::SlowAssertNoActiveJavaScript() {
void FinalizationRegistryCleanupTask::RunInternal() {
Isolate* isolate = heap_->isolate();
DCHECK(!isolate->host_cleanup_finalization_group_callback());
SlowAssertNoActiveJavaScript();
TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8",
......
......@@ -1198,16 +1198,6 @@ void Heap::GarbageCollectionEpilogue() {
TRACE_GC(tracer(), GCTracer::Scope::HEAP_EPILOGUE_REDUCE_NEW_SPACE);
ReduceNewSpaceSize();
}
if (FLAG_harmony_weak_refs &&
isolate()->host_cleanup_finalization_group_callback()) {
HandleScope handle_scope(isolate());
Handle<JSFinalizationRegistry> finalization_registry;
while (
DequeueDirtyJSFinalizationRegistry().ToHandle(&finalization_registry)) {
isolate()->RunHostCleanupFinalizationGroupCallback(finalization_registry);
}
}
}
class GCCallbacksScope {
......@@ -6141,7 +6131,6 @@ void Heap::SetInterpreterEntryTrampolineForProfiling(Code code) {
}
void Heap::PostFinalizationRegistryCleanupTaskIfNeeded() {
DCHECK(!isolate()->host_cleanup_finalization_group_callback());
// Only one cleanup task is posted at a time.
if (!HasDirtyJSFinalizationRegistries() ||
is_finalization_registry_cleanup_task_posted_) {
......@@ -6201,7 +6190,6 @@ MaybeHandle<JSFinalizationRegistry> Heap::DequeueDirtyJSFinalizationRegistry() {
void Heap::RemoveDirtyFinalizationRegistriesOnContext(NativeContext context) {
if (!FLAG_harmony_weak_refs) return;
if (isolate()->host_cleanup_finalization_group_callback()) return;
DisallowHeapAllocation no_gc;
......
......@@ -2536,9 +2536,7 @@ void MarkCompactCollector::ClearJSWeakRefs() {
RecordSlot(weak_cell, slot, HeapObject::cast(*slot));
}
}
if (!isolate()->host_cleanup_finalization_group_callback()) {
heap()->PostFinalizationRegistryCleanupTaskIfNeeded();
}
heap()->PostFinalizationRegistryCleanupTaskIfNeeded();
}
void MarkCompactCollector::AbortWeakObjects() {
......
......@@ -772,7 +772,6 @@ class RuntimeCallTimer final {
V(Int8Array_New) \
V(Isolate_DateTimeConfigurationChangeNotification) \
V(Isolate_LocaleConfigurationChangeNotification) \
V(FinalizationGroup_Cleanup) \
V(JSON_Parse) \
V(JSON_Stringify) \
V(Map_AsArray) \
......
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