mirror of
https://github.com/electron/electron.git
synced 2026-02-08 14:15:28 -05:00
* fix: use Node.js isolate setup logic in bindings * Flags should be more process-specific * Remove redundant isolate function setting * Remove old SetFatalErrorHandler call
146 lines
5.5 KiB
Diff
146 lines
5.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Samuel Attard <samuel.r.attard@gmail.com>
|
|
Date: Mon, 4 May 2020 16:57:05 -0700
|
|
Subject: chore: SetHostCleanupFinalizationGroupCallback has been removed from
|
|
V8
|
|
|
|
diff --git a/src/api/environment.cc b/src/api/environment.cc
|
|
index 60d30b7eff7329c4235024c31525107216d70d7a..21980987644c6e83029157785dea463070456c77 100644
|
|
--- a/src/api/environment.cc
|
|
+++ b/src/api/environment.cc
|
|
@@ -12,7 +12,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;
|
|
@@ -78,15 +77,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)
|
|
@@ -255,11 +245,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);
|
|
}
|
|
diff --git a/src/env-inl.h b/src/env-inl.h
|
|
index c6ef9dc13ab6f1d1a778871a62a0a98a01d84ec6..222555831aa1bf0b7b29b4b46e235c98a5dd4ac5 100644
|
|
--- a/src/env-inl.h
|
|
+++ b/src/env-inl.h
|
|
@@ -1123,12 +1123,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);
|
|
- uv_async_send(&task_queues_async_);
|
|
-}
|
|
-
|
|
size_t CleanupHookCallback::Hash::operator()(
|
|
const CleanupHookCallback& cb) const {
|
|
return std::hash<void*>()(cb.arg_);
|
|
diff --git a/src/env.cc b/src/env.cc
|
|
index 657d711e539d81bfd03166bbaaae7f0b5db91a5f..02c5ba259c94bb160972005998007d66731d9dde 100644
|
|
--- a/src/env.cc
|
|
+++ b/src/env.cc
|
|
@@ -30,7 +30,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;
|
|
@@ -494,7 +493,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_));
|
|
@@ -1121,25 +1119,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.
|
|
- 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);
|
|
diff --git a/src/env.h b/src/env.h
|
|
index b6e02a2910cd8fe5ff3a17d6e1a98b937323ae3a..c1966a9f55126bdd65d8c9d529d934977bb4ad65 100644
|
|
--- a/src/env.h
|
|
+++ b/src/env.h
|
|
@@ -1132,9 +1132,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.
|
|
@@ -1357,8 +1355,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;
|
|
|
|
diff --git a/src/node.h b/src/node.h
|
|
index 638a1a85b046ce4db303d532f7cf36cca2271db5..b9b11b4331bd3ae4a87f65758ee09af25222e19a 100644
|
|
--- a/src/node.h
|
|
+++ b/src/node.h
|
|
@@ -322,8 +322,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
|