Skip to content

Commit de4c004

Browse files
sygCommit Bot
authored and
Commit Bot
committed
[weakrefs] Remove deprecated FinalizationGroup V8 API
Bug: v8:8179 Change-Id: I16170a197028beb35309b15613004b29a956896c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2171696 Reviewed-by: Ulan Degenbaev <ulan@chromium.org> Reviewed-by: Ross 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}
1 parent 0e2e00f commit de4c004

File tree

10 files changed

+1
-129
lines changed

10 files changed

+1
-129
lines changed

include/v8.h

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5933,37 +5933,6 @@ class V8_EXPORT RegExp : public Object {
59335933
static void CheckCast(Value* obj);
59345934
};
59355935

5936-
/**
5937-
* An instance of the built-in FinalizationRegistry constructor.
5938-
*
5939-
* The C++ name is FinalizationGroup for backwards compatibility. This API is
5940-
* experimental and deprecated.
5941-
*/
5942-
class V8_EXPORT FinalizationGroup : public Object {
5943-
public:
5944-
/**
5945-
* Runs the cleanup callback of the given FinalizationRegistry.
5946-
*
5947-
* V8 will inform the embedder that there are finalizer callbacks be
5948-
* called through HostCleanupFinalizationGroupCallback.
5949-
*
5950-
* HostCleanupFinalizationGroupCallback should schedule a task to
5951-
* call FinalizationGroup::Cleanup() at some point in the
5952-
* future. It's the embedders responsiblity to make this call at a
5953-
* time which does not interrupt synchronous ECMAScript code
5954-
* execution.
5955-
*
5956-
* If the result is Nothing<bool> then an exception has
5957-
* occurred. Otherwise the result is |true| if the cleanup callback
5958-
* was called successfully. The result is never |false|.
5959-
*/
5960-
V8_DEPRECATED(
5961-
"FinalizationGroup cleanup is automatic if "
5962-
"HostCleanupFinalizationGroupCallback is not set")
5963-
static V8_WARN_UNUSED_RESULT Maybe<bool> Cleanup(
5964-
Local<FinalizationGroup> finalization_group);
5965-
};
5966-
59675936
/**
59685937
* A JavaScript value that wraps a C++ void*. This type of value is mainly used
59695938
* to associate C++ data structures with JavaScript objects.
@@ -7216,20 +7185,6 @@ typedef void (*AddCrashKeyCallback)(CrashKeyId id, const std::string& value);
72167185
typedef void (*BeforeCallEnteredCallback)(Isolate*);
72177186
typedef void (*CallCompletedCallback)(Isolate*);
72187187

7219-
/**
7220-
* HostCleanupFinalizationGroupCallback is called when we require the
7221-
* embedder to enqueue a task that would call
7222-
* FinalizationGroup::Cleanup().
7223-
*
7224-
* The FinalizationGroup is the one for which the embedder needs to
7225-
* call FinalizationGroup::Cleanup() on.
7226-
*
7227-
* The context provided is the one in which the FinalizationGroup was
7228-
* created in.
7229-
*/
7230-
typedef void (*HostCleanupFinalizationGroupCallback)(
7231-
Local<Context> context, Local<FinalizationGroup> fg);
7232-
72337188
/**
72347189
* HostImportModuleDynamicallyCallback is called when we require the
72357190
* embedder to load a module. This is used as part of the dynamic
@@ -8567,17 +8522,6 @@ class V8_EXPORT Isolate {
85678522
void SetAbortOnUncaughtExceptionCallback(
85688523
AbortOnUncaughtExceptionCallback callback);
85698524

8570-
/**
8571-
* This specifies the callback to be called when FinalizationRegistries
8572-
* are ready to be cleaned up and require FinalizationGroup::Cleanup()
8573-
* to be called in a future task.
8574-
*/
8575-
V8_DEPRECATED(
8576-
"FinalizationRegistry cleanup is automatic if "
8577-
"HostCleanupFinalizationGroupCallback is not set")
8578-
void SetHostCleanupFinalizationGroupCallback(
8579-
HostCleanupFinalizationGroupCallback callback);
8580-
85818525
/**
85828526
* This specifies the callback called by the upcoming dynamic
85838527
* import() language feature to load modules.

src/api/api-inl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ MAKE_TO_LOCAL(ToLocal, JSArrayBufferView, ArrayBufferView)
8686
MAKE_TO_LOCAL(ToLocal, JSDataView, DataView)
8787
MAKE_TO_LOCAL(ToLocal, JSTypedArray, TypedArray)
8888
MAKE_TO_LOCAL(ToLocalShared, JSArrayBuffer, SharedArrayBuffer)
89-
MAKE_TO_LOCAL(ToLocal, JSFinalizationRegistry, FinalizationGroup)
9089

9190
TYPED_ARRAYS(MAKE_TO_LOCAL_TYPED_ARRAY)
9291

src/api/api.cc

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8346,33 +8346,6 @@ void Isolate::SetAbortOnUncaughtExceptionCallback(
83468346
isolate->SetAbortOnUncaughtExceptionCallback(callback);
83478347
}
83488348

8349-
void Isolate::SetHostCleanupFinalizationGroupCallback(
8350-
HostCleanupFinalizationGroupCallback callback) {
8351-
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
8352-
isolate->SetHostCleanupFinalizationGroupCallback(callback);
8353-
}
8354-
8355-
Maybe<bool> FinalizationGroup::Cleanup(
8356-
Local<FinalizationGroup> finalization_group) {
8357-
i::Handle<i::JSFinalizationRegistry> fr =
8358-
Utils::OpenHandle(*finalization_group);
8359-
i::Isolate* isolate = fr->native_context().GetIsolate();
8360-
i::Handle<i::Context> i_context(fr->native_context(), isolate);
8361-
Local<Context> context = Utils::ToLocal(i_context);
8362-
ENTER_V8(isolate, context, FinalizationGroup, Cleanup, Nothing<bool>(),
8363-
i::HandleScope);
8364-
i::Handle<i::Object> callback(fr->cleanup(), isolate);
8365-
i::Handle<i::Object> argv[] = {callback};
8366-
fr->set_scheduled_for_cleanup(false);
8367-
has_pending_exception =
8368-
i::Execution::CallBuiltin(isolate,
8369-
isolate->finalization_registry_cleanup_some(),
8370-
fr, arraysize(argv), argv)
8371-
.is_null();
8372-
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(bool);
8373-
return Just(true);
8374-
}
8375-
83768349
void Isolate::SetHostImportModuleDynamicallyCallback(
83778350
HostImportModuleDynamicallyCallback callback) {
83788351
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);

src/api/api.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ class RegisteredExtension {
9494
V(Data, Object) \
9595
V(RegExp, JSRegExp) \
9696
V(Object, JSReceiver) \
97-
V(FinalizationGroup, JSFinalizationRegistry) \
9897
V(Array, JSArray) \
9998
V(Map, JSMap) \
10099
V(Set, JSSet) \
@@ -207,8 +206,6 @@ class Utils {
207206
v8::internal::Handle<v8::internal::JSTypedArray> obj);
208207
static inline Local<BigUint64Array> ToLocalBigUint64Array(
209208
v8::internal::Handle<v8::internal::JSTypedArray> obj);
210-
static inline Local<FinalizationGroup> ToLocal(
211-
v8::internal::Handle<v8::internal::JSFinalizationRegistry> obj);
212209

213210
static inline Local<SharedArrayBuffer> ToLocalShared(
214211
v8::internal::Handle<v8::internal::JSArrayBuffer> obj);

src/execution/isolate.cc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4028,21 +4028,6 @@ MaybeHandle<JSPromise> Isolate::RunHostImportModuleDynamicallyCallback(
40284028

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

4031-
void Isolate::SetHostCleanupFinalizationGroupCallback(
4032-
HostCleanupFinalizationGroupCallback callback) {
4033-
host_cleanup_finalization_group_callback_ = callback;
4034-
}
4035-
4036-
void Isolate::RunHostCleanupFinalizationGroupCallback(
4037-
Handle<JSFinalizationRegistry> fr) {
4038-
if (host_cleanup_finalization_group_callback_ != nullptr) {
4039-
v8::Local<v8::Context> api_context =
4040-
v8::Utils::ToLocal(handle(Context::cast(fr->native_context()), this));
4041-
host_cleanup_finalization_group_callback_(api_context,
4042-
v8::Utils::ToLocal(fr));
4043-
}
4044-
}
4045-
40464031
void Isolate::SetHostImportModuleDynamicallyCallback(
40474032
HostImportModuleDynamicallyCallback callback) {
40484033
host_import_module_dynamically_callback_ = callback;

src/execution/isolate.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,14 +1416,6 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
14161416
bool IsInAnyContext(Object object, uint32_t index);
14171417

14181418
void ClearKeptObjects();
1419-
void SetHostCleanupFinalizationGroupCallback(
1420-
HostCleanupFinalizationGroupCallback callback);
1421-
HostCleanupFinalizationGroupCallback
1422-
host_cleanup_finalization_group_callback() const {
1423-
return host_cleanup_finalization_group_callback_;
1424-
}
1425-
void RunHostCleanupFinalizationGroupCallback(
1426-
Handle<JSFinalizationRegistry> fr);
14271419

14281420
void SetHostImportModuleDynamicallyCallback(
14291421
HostImportModuleDynamicallyCallback callback);
@@ -1680,8 +1672,6 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
16801672
v8::Isolate::AtomicsWaitCallback atomics_wait_callback_ = nullptr;
16811673
void* atomics_wait_callback_data_ = nullptr;
16821674
PromiseHook promise_hook_ = nullptr;
1683-
HostCleanupFinalizationGroupCallback
1684-
host_cleanup_finalization_group_callback_ = nullptr;
16851675
HostImportModuleDynamicallyCallback host_import_module_dynamically_callback_ =
16861676
nullptr;
16871677
HostInitializeImportMetaObjectCallback

src/heap/finalization-registry-cleanup-task.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ void FinalizationRegistryCleanupTask::SlowAssertNoActiveJavaScript() {
3737

3838
void FinalizationRegistryCleanupTask::RunInternal() {
3939
Isolate* isolate = heap_->isolate();
40-
DCHECK(!isolate->host_cleanup_finalization_group_callback());
4140
SlowAssertNoActiveJavaScript();
4241

4342
TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8",

src/heap/heap.cc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,16 +1198,6 @@ void Heap::GarbageCollectionEpilogue() {
11981198
TRACE_GC(tracer(), GCTracer::Scope::HEAP_EPILOGUE_REDUCE_NEW_SPACE);
11991199
ReduceNewSpaceSize();
12001200
}
1201-
1202-
if (FLAG_harmony_weak_refs &&
1203-
isolate()->host_cleanup_finalization_group_callback()) {
1204-
HandleScope handle_scope(isolate());
1205-
Handle<JSFinalizationRegistry> finalization_registry;
1206-
while (
1207-
DequeueDirtyJSFinalizationRegistry().ToHandle(&finalization_registry)) {
1208-
isolate()->RunHostCleanupFinalizationGroupCallback(finalization_registry);
1209-
}
1210-
}
12111201
}
12121202

12131203
class GCCallbacksScope {
@@ -6141,7 +6131,6 @@ void Heap::SetInterpreterEntryTrampolineForProfiling(Code code) {
61416131
}
61426132

61436133
void Heap::PostFinalizationRegistryCleanupTaskIfNeeded() {
6144-
DCHECK(!isolate()->host_cleanup_finalization_group_callback());
61456134
// Only one cleanup task is posted at a time.
61466135
if (!HasDirtyJSFinalizationRegistries() ||
61476136
is_finalization_registry_cleanup_task_posted_) {
@@ -6201,7 +6190,6 @@ MaybeHandle<JSFinalizationRegistry> Heap::DequeueDirtyJSFinalizationRegistry() {
62016190

62026191
void Heap::RemoveDirtyFinalizationRegistriesOnContext(NativeContext context) {
62036192
if (!FLAG_harmony_weak_refs) return;
6204-
if (isolate()->host_cleanup_finalization_group_callback()) return;
62056193

62066194
DisallowHeapAllocation no_gc;
62076195

src/heap/mark-compact.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,9 +2536,7 @@ void MarkCompactCollector::ClearJSWeakRefs() {
25362536
RecordSlot(weak_cell, slot, HeapObject::cast(*slot));
25372537
}
25382538
}
2539-
if (!isolate()->host_cleanup_finalization_group_callback()) {
2540-
heap()->PostFinalizationRegistryCleanupTaskIfNeeded();
2541-
}
2539+
heap()->PostFinalizationRegistryCleanupTaskIfNeeded();
25422540
}
25432541

25442542
void MarkCompactCollector::AbortWeakObjects() {

src/logging/counters.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,6 @@ class RuntimeCallTimer final {
772772
V(Int8Array_New) \
773773
V(Isolate_DateTimeConfigurationChangeNotification) \
774774
V(Isolate_LocaleConfigurationChangeNotification) \
775-
V(FinalizationGroup_Cleanup) \
776775
V(JSON_Parse) \
777776
V(JSON_Stringify) \
778777
V(Map_AsArray) \

0 commit comments

Comments
 (0)