Skip to content

Commit 0257386

Browse files
devsnekcodebytere
authored andcommitted
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 0ffa040 commit 0257386

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
@@ -1112,13 +1112,6 @@ void Environment::RemoveCleanupHook(void (*fn)(void*), void* arg) {
11121112
cleanup_hooks_.erase(search);
11131113
}
11141114

1115-
inline void Environment::RegisterFinalizationGroupForCleanup(
1116-
v8::Local<v8::FinalizationGroup> group) {
1117-
cleanup_finalization_groups_.emplace_back(isolate(), group);
1118-
DCHECK(task_queues_async_initialized_);
1119-
uv_async_send(&task_queues_async_);
1120-
}
1121-
11221115
size_t CleanupHookCallback::Hash::operator()(
11231116
const CleanupHookCallback& cb) const {
11241117
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
@@ -1105,9 +1105,7 @@ class Environment : public MemoryRetainer {
11051105
void AtExit(void (*cb)(void* arg), void* arg);
11061106
void RunAtExitCallbacks();
11071107

1108-
void RegisterFinalizationGroupForCleanup(v8::Local<v8::FinalizationGroup> fg);
11091108
void RunWeakRefCleanup();
1110-
void CleanupFinalizationGroups();
11111109

11121110
// Strings and private symbols are shared across shared contexts
11131111
// The getters simply proxy to the per-isolate primitive.
@@ -1331,8 +1329,6 @@ class Environment : public MemoryRetainer {
13311329
uint64_t thread_id_;
13321330
std::unordered_set<worker::Worker*> sub_worker_contexts_;
13331331

1334-
std::deque<v8::Global<v8::FinalizationGroup>> cleanup_finalization_groups_;
1335-
13361332
static void* const kNodeContextTagPtr;
13371333
static int const kNodeContextTag;
13381334

src/node.h

-2
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,6 @@ struct IsolateSettings {
351351
v8::PromiseRejectCallback promise_reject_callback = nullptr;
352352
v8::AllowWasmCodeGenerationCallback
353353
allow_wasm_code_generation_callback = nullptr;
354-
v8::HostCleanupFinalizationGroupCallback
355-
host_cleanup_finalization_group_callback = nullptr;
356354
};
357355

358356
// 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)