Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: remove deprecated FinalizationRegistry hooks #33373

Merged
merged 1 commit into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions src/api/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ using errors::TryCatchScope;
using v8::Array;
using v8::Context;
using v8::EscapableHandleScope;
using v8::FinalizationGroup;
using v8::Function;
using v8::FunctionCallbackInfo;
using v8::HandleScope;
Expand Down Expand Up @@ -82,15 +81,6 @@ static MaybeLocal<Value> PrepareStackTraceCallback(Local<Context> context,
return result;
}

static void HostCleanupFinalizationGroupCallback(
Local<Context> context, Local<FinalizationGroup> group) {
Environment* env = Environment::GetCurrent(context);
if (env == nullptr) {
return;
}
env->RegisterFinalizationGroupForCleanup(group);
}

void* NodeArrayBufferAllocator::Allocate(size_t size) {
void* ret;
if (zero_fill_field_ || per_process::cli_options->zero_fill_all_buffers)
Expand Down Expand Up @@ -259,11 +249,6 @@ void SetIsolateMiscHandlers(v8::Isolate* isolate, const IsolateSettings& s) {
s.promise_reject_callback : task_queue::PromiseRejectCallback;
isolate->SetPromiseRejectCallback(promise_reject_cb);

auto* host_cleanup_cb = s.host_cleanup_finalization_group_callback ?
s.host_cleanup_finalization_group_callback :
HostCleanupFinalizationGroupCallback;
isolate->SetHostCleanupFinalizationGroupCallback(host_cleanup_cb);

if (s.flags & DETAILED_SOURCE_POSITIONS_FOR_PROFILING)
v8::CpuProfiler::UseDetailedSourcePositionsForProfiling(isolate);
}
Expand Down
7 changes: 0 additions & 7 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1120,13 +1120,6 @@ void Environment::RemoveCleanupHook(void (*fn)(void*), void* arg) {
cleanup_hooks_.erase(search);
}

inline void Environment::RegisterFinalizationGroupForCleanup(
v8::Local<v8::FinalizationGroup> group) {
cleanup_finalization_groups_.emplace_back(isolate(), group);
DCHECK(task_queues_async_initialized_);
uv_async_send(&task_queues_async_);
}

size_t CleanupHookCallback::Hash::operator()(
const CleanupHookCallback& cb) const {
return std::hash<void*>()(cb.arg_);
Expand Down
22 changes: 0 additions & 22 deletions src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ using v8::ArrayBuffer;
using v8::Boolean;
using v8::Context;
using v8::EmbedderGraph;
using v8::FinalizationGroup;
using v8::Function;
using v8::FunctionTemplate;
using v8::HandleScope;
Expand Down Expand Up @@ -523,7 +522,6 @@ void Environment::InitializeLibuv(bool start_profiler_idle_notifier) {
[](uv_async_t* async) {
Environment* env = ContainerOf(
&Environment::task_queues_async_, async);
env->CleanupFinalizationGroups();
env->RunAndClearNativeImmediates();
});
uv_unref(reinterpret_cast<uv_handle_t*>(&idle_prepare_handle_));
Expand Down Expand Up @@ -1158,26 +1156,6 @@ void Environment::RunWeakRefCleanup() {
isolate()->ClearKeptObjects();
}

void Environment::CleanupFinalizationGroups() {
HandleScope handle_scope(isolate());
Context::Scope context_scope(context());
TryCatchScope try_catch(this);

while (!cleanup_finalization_groups_.empty() && can_call_into_js()) {
Local<FinalizationGroup> fg =
cleanup_finalization_groups_.front().Get(isolate());
cleanup_finalization_groups_.pop_front();
if (!FinalizationGroup::Cleanup(fg).FromMaybe(false)) {
if (try_catch.HasCaught() && !try_catch.HasTerminated())
errors::TriggerUncaughtException(isolate(), try_catch);
// Re-schedule the execution of the remainder of the queue.
CHECK(task_queues_async_initialized_);
uv_async_send(&task_queues_async_);
return;
}
}
}

// Not really any better place than env.cc at this moment.
void BaseObject::DeleteMe(void* data) {
BaseObject* self = static_cast<BaseObject*>(data);
Expand Down
4 changes: 0 additions & 4 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -1107,9 +1107,7 @@ class Environment : public MemoryRetainer {
void AtExit(void (*cb)(void* arg), void* arg);
void RunAtExitCallbacks();

void RegisterFinalizationGroupForCleanup(v8::Local<v8::FinalizationGroup> fg);
void RunWeakRefCleanup();
void CleanupFinalizationGroups();

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

std::deque<v8::Global<v8::FinalizationGroup>> cleanup_finalization_groups_;

static void* const kNodeContextTagPtr;
static int const kNodeContextTag;

Expand Down
2 changes: 0 additions & 2 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ struct IsolateSettings {
v8::PromiseRejectCallback promise_reject_callback = nullptr;
v8::AllowWasmCodeGenerationCallback
allow_wasm_code_generation_callback = nullptr;
v8::HostCleanupFinalizationGroupCallback
host_cleanup_finalization_group_callback = nullptr;
};

// Overriding IsolateSettings may produce unexpected behavior
Expand Down
27 changes: 0 additions & 27 deletions test/parallel/test-finalization-group-error.js

This file was deleted.

25 changes: 0 additions & 25 deletions test/parallel/test-finalization-group-regular-gc.js

This file was deleted.

13 changes: 0 additions & 13 deletions test/parallel/test-finalization-group.js

This file was deleted.