Skip to content

Commit eaa16cd

Browse files
committed
src: remove deprecated FinalizationRegistry hooks
PR-URL: #33373 Fixes: #33389 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent fcc183c commit eaa16cd

8 files changed

+0
-115
lines changed

src/api/environment.cc

-15
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ using errors::TryCatchScope;
1616
using v8::Array;
1717
using v8::Context;
1818
using v8::EscapableHandleScope;
19-
using v8::FinalizationGroup;
2019
using v8::Function;
2120
using v8::FunctionCallbackInfo;
2221
using v8::HandleScope;
@@ -82,15 +81,6 @@ static MaybeLocal<Value> PrepareStackTraceCallback(Local<Context> context,
8281
return result;
8382
}
8483

85-
static void HostCleanupFinalizationGroupCallback(
86-
Local<Context> context, Local<FinalizationGroup> group) {
87-
Environment* env = Environment::GetCurrent(context);
88-
if (env == nullptr) {
89-
return;
90-
}
91-
env->RegisterFinalizationGroupForCleanup(group);
92-
}
93-
9484
void* NodeArrayBufferAllocator::Allocate(size_t size) {
9585
void* ret;
9686
if (zero_fill_field_ || per_process::cli_options->zero_fill_all_buffers)
@@ -259,11 +249,6 @@ void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) {
259249
s.promise_reject_callback : task_queue::PromiseRejectCallback;
260250
isolate->SetPromiseRejectCallback(promise_reject_cb);
261251

262-
auto* host_cleanup_cb = s.host_cleanup_finalization_group_callback ?
263-
s.host_cleanup_finalization_group_callback :
264-
HostCleanupFinalizationGroupCallback;
265-
isolate->SetHostCleanupFinalizationGroupCallback(host_cleanup_cb);
266-
267252
if (s.flags & DETAILED_SOURCE_POSITIONS_FOR_PROFILING)
268253
v8::CpuProfiler::UseDetailedSourcePositionsForProfiling(isolate);
269254
}

src/env-inl.h

-7
Original file line numberDiff line numberDiff line change
@@ -1120,13 +1120,6 @@ void Environment::RemoveCleanupHook(void (*fn)(void*), void* arg) {
11201120
cleanup_hooks_.erase(search);
11211121
}
11221122

1123-
inline void Environment::RegisterFinalizationGroupForCleanup(
1124-
v8::Local<v8::FinalizationGroup> group) {
1125-
cleanup_finalization_groups_.emplace_back(isolate(), group);
1126-
DCHECK(task_queues_async_initialized_);
1127-
uv_async_send(&task_queues_async_);
1128-
}
1129-
11301123
size_t CleanupHookCallback::Hash::operator()(
11311124
const CleanupHookCallback& cb) const {
11321125
return std::hash<void*>()(cb.arg_);

src/env.cc

-22
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ using v8::ArrayBuffer;
3131
using v8::Boolean;
3232
using v8::Context;
3333
using v8::EmbedderGraph;
34-
using v8::FinalizationGroup;
3534
using v8::Function;
3635
using v8::FunctionTemplate;
3736
using v8::HandleScope;
@@ -523,7 +522,6 @@ void Environment::InitializeLibuv(bool start_profiler_idle_notifier) {
523522
[](uv_async_t* async) {
524523
Environment* env = ContainerOf(
525524
&Environment::task_queues_async_, async);
526-
env->CleanupFinalizationGroups();
527525
env->RunAndClearNativeImmediates();
528526
});
529527
uv_unref(reinterpret_cast<uv_handle_t*>(&idle_prepare_handle_));
@@ -1158,26 +1156,6 @@ void Environment::RunWeakRefCleanup() {
11581156
isolate()->ClearKeptObjects();
11591157
}
11601158

1161-
void Environment::CleanupFinalizationGroups() {
1162-
HandleScope handle_scope(isolate());
1163-
Context::Scope context_scope(context());
1164-
TryCatchScope try_catch(this);
1165-
1166-
while (!cleanup_finalization_groups_.empty() && can_call_into_js()) {
1167-
Local<FinalizationGroup> fg =
1168-
cleanup_finalization_groups_.front().Get(isolate());
1169-
cleanup_finalization_groups_.pop_front();
1170-
if (!FinalizationGroup::Cleanup(fg).FromMaybe(false)) {
1171-
if (try_catch.HasCaught() && !try_catch.HasTerminated())
1172-
errors::TriggerUncaughtException(isolate(), try_catch);
1173-
// Re-schedule the execution of the remainder of the queue.
1174-
CHECK(task_queues_async_initialized_);
1175-
uv_async_send(&task_queues_async_);
1176-
return;
1177-
}
1178-
}
1179-
}
1180-
11811159
// Not really any better place than env.cc at this moment.
11821160
void BaseObject::DeleteMe(void* data) {
11831161
BaseObject* self = static_cast<BaseObject*>(data);

src/env.h

-4
Original file line numberDiff line numberDiff line change
@@ -1107,9 +1107,7 @@ class Environment : public MemoryRetainer {
11071107
void AtExit(void (*cb)(void* arg), void* arg);
11081108
void RunAtExitCallbacks();
11091109

1110-
void RegisterFinalizationGroupForCleanup(v8::Local<v8::FinalizationGroup> fg);
11111110
void RunWeakRefCleanup();
1112-
void CleanupFinalizationGroups();
11131111

11141112
// Strings and private symbols are shared across shared contexts
11151113
// The getters simply proxy to the per-isolate primitive.
@@ -1334,8 +1332,6 @@ class Environment : public MemoryRetainer {
13341332
uint64_t thread_id_;
13351333
std::unordered_set<worker::Worker*> sub_worker_contexts_;
13361334

1337-
std::deque<v8::Global<v8::FinalizationGroup>> cleanup_finalization_groups_;
1338-
13391335
static void* const kNodeContextTagPtr;
13401336
static int const kNodeContextTag;
13411337

src/node.h

-2
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,6 @@ struct IsolateSettings {
346346
v8::PromiseRejectCallback promise_reject_callback = nullptr;
347347
v8::AllowWasmCodeGenerationCallback
348348
allow_wasm_code_generation_callback = nullptr;
349-
v8::HostCleanupFinalizationGroupCallback
350-
host_cleanup_finalization_group_callback = nullptr;
351349
};
352350

353351
// Overriding IsolateSettings may produce unexpected behavior

test/parallel/test-finalization-group-error.js

-27
This file was deleted.

test/parallel/test-finalization-group-regular-gc.js

-25
This file was deleted.

test/parallel/test-finalization-group.js

-13
This file was deleted.

0 commit comments

Comments
 (0)