diff --git a/src/async_wrap.cc b/src/async_wrap.cc index f8e0992ee511b4..cd9f26d7782d46 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -426,8 +426,6 @@ void AsyncWrap::WeakCallback(const v8::WeakCallbackInfo& info) { if (val->IsFalse()) { AsyncWrap::EmitDestroy(env, p->asyncId); } - p->target.Reset(); - p->propBag.Reset(); delete p; } diff --git a/src/base_object-inl.h b/src/base_object-inl.h index 6720bd6d886e1b..51ef46599667df 100644 --- a/src/base_object-inl.h +++ b/src/base_object-inl.h @@ -42,11 +42,6 @@ inline BaseObject::BaseObject(Environment* env, v8::Local handle) } -inline BaseObject::~BaseObject() { - CHECK(persistent_handle_.IsEmpty()); -} - - inline Persistent& BaseObject::persistent() { return persistent_handle_; } @@ -65,8 +60,7 @@ inline Environment* BaseObject::env() const { template inline void BaseObject::WeakCallback( const v8::WeakCallbackInfo& data) { - std::unique_ptr self(data.GetParameter()); - self->persistent().Reset(); + delete data.GetParameter(); } diff --git a/src/base_object.h b/src/base_object.h index 0640f91cbf5b88..478499bbfeb5b2 100644 --- a/src/base_object.h +++ b/src/base_object.h @@ -34,7 +34,7 @@ class Environment; class BaseObject { public: inline BaseObject(Environment* env, v8::Local handle); - inline virtual ~BaseObject(); + virtual ~BaseObject() = default; // Returns the wrapped object. Returns an empty handle when // persistent.IsEmpty() is true. diff --git a/src/cares_wrap.cc b/src/cares_wrap.cc index 165a8cda20618b..b8da20346692c3 100644 --- a/src/cares_wrap.cc +++ b/src/cares_wrap.cc @@ -598,7 +598,6 @@ class QueryWrap : public AsyncWrap { ~QueryWrap() override { CHECK_EQ(false, persistent().IsEmpty()); ClearWrap(object()); - persistent().Reset(); } // Subclasses should implement the appropriate Send method. diff --git a/src/env-inl.h b/src/env-inl.h index 5c0ff282f52829..f647f428c324ff 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -357,9 +357,6 @@ inline Environment::~Environment() { context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex, nullptr); -#define V(PropertyName, TypeName) PropertyName ## _.Reset(); - ENVIRONMENT_STRONG_PERSISTENT_PROPERTIES(V) -#undef V delete[] heap_statistics_buffer_; delete[] heap_space_statistics_buffer_; diff --git a/src/env.cc b/src/env.cc index 50038b73160db7..455f5980731f3f 100644 --- a/src/env.cc +++ b/src/env.cc @@ -300,8 +300,6 @@ void Environment::RunAndClearNativeImmediates() { v8::TryCatch try_catch(isolate()); for (auto it = list.begin(); it != list.end(); ++it) { it->cb_(this, it->data_); - if (it->keep_alive_) - it->keep_alive_->Reset(); if (it->refed_) ref_count++; if (UNLIKELY(try_catch.HasCaught())) { diff --git a/src/handle_wrap.cc b/src/handle_wrap.cc index 7dcafa2ce6e842..a3b0209eb3121f 100644 --- a/src/handle_wrap.cc +++ b/src/handle_wrap.cc @@ -98,11 +98,6 @@ HandleWrap::HandleWrap(Environment* env, } -HandleWrap::~HandleWrap() { - CHECK(persistent().IsEmpty()); -} - - void HandleWrap::OnClose(uv_handle_t* handle) { HandleWrap* wrap = static_cast(handle->data); Environment* env = wrap->env(); @@ -120,7 +115,6 @@ void HandleWrap::OnClose(uv_handle_t* handle) { wrap->MakeCallback(env->onclose_string(), 0, nullptr); ClearWrap(wrap->object()); - wrap->persistent().Reset(); delete wrap; } diff --git a/src/handle_wrap.h b/src/handle_wrap.h index 19fd36891a2fed..e7a335f5140253 100644 --- a/src/handle_wrap.h +++ b/src/handle_wrap.h @@ -75,7 +75,6 @@ class HandleWrap : public AsyncWrap { v8::Local object, uv_handle_t* handle, AsyncWrap::ProviderType provider); - ~HandleWrap() override; private: friend class Environment; diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index 9a4857f1a10cab..1cced9420aea6c 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -84,10 +84,6 @@ class JSBindingsConnection : public AsyncWrap { inspector->Connect(&delegate_); } - ~JSBindingsConnection() override { - callback_.Reset(); - } - void OnMessage(Local value) { MakeCallback(callback_.Get(env()->isolate()), 1, &value); } @@ -111,7 +107,6 @@ class JSBindingsConnection : public AsyncWrap { delegate_.Disconnect(); if (!persistent().IsEmpty()) { ClearWrap(object()); - persistent().Reset(); } delete this; } diff --git a/src/module_wrap.cc b/src/module_wrap.cc index 24e73cc3e101c6..6393b4600940a9 100644 --- a/src/module_wrap.cc +++ b/src/module_wrap.cc @@ -59,9 +59,6 @@ ModuleWrap::~ModuleWrap() { break; } } - - module_.Reset(); - context_.Reset(); } void ModuleWrap::New(const FunctionCallbackInfo& args) { @@ -215,8 +212,6 @@ void ModuleWrap::Instantiate(const FunctionCallbackInfo& args) { module->InstantiateModule(context, ModuleWrap::ResolveCallback); // clear resolve cache on instantiate - for (auto& entry : obj->resolve_cache_) - entry.second.Reset(); obj->resolve_cache_.clear(); if (!ok.FromMaybe(false)) { diff --git a/src/node_api.cc b/src/node_api.cc index 7b0e110579b65b..63ce1d8e86955e 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -31,12 +31,6 @@ struct napi_env__ { : isolate(_isolate), last_error(), loop(_loop) {} - ~napi_env__() { - last_exception.Reset(); - wrap_template.Reset(); - function_data_template.Reset(); - accessor_data_template.Reset(); - } v8::Isolate* isolate; node::Persistent last_exception; node::Persistent wrap_template; @@ -381,16 +375,6 @@ class Reference : private Finalizer { } } - ~Reference() { - // The V8 Persistent class currently does not reset in its destructor: - // see NonCopyablePersistentTraits::kResetInDestructor = false. - // (Comments there claim that might change in the future.) - // To avoid memory leaks, it is better to reset at this time, however - // care must be taken to avoid attempting this after the Isolate has - // shut down, for example via a static (atexit) destructor. - _persistent.Reset(); - } - public: void* Data() { return _finalize_data; @@ -857,7 +841,6 @@ napi_status ConcludeDeferred(napi_env env, v8_resolver->Resolve(context, v8impl::V8LocalValueFromJsValue(result)) : v8_resolver->Reject(context, v8impl::V8LocalValueFromJsValue(result)); - deferred_ref->Reset(); delete deferred_ref; RETURN_STATUS_IF_FALSE(env, success.FromMaybe(false), napi_generic_failure); diff --git a/src/node_buffer.cc b/src/node_buffer.cc index d1983bde5ee354..f9a807602f612c 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -102,7 +102,6 @@ class CallbackInfo { FreeCallback callback, char* data, void* hint); - ~CallbackInfo(); Persistent persistent_; FreeCallback const callback_; char* const data_; @@ -146,11 +145,6 @@ CallbackInfo::CallbackInfo(Isolate* isolate, } -CallbackInfo::~CallbackInfo() { - persistent_.Reset(); -} - - void CallbackInfo::WeakCallback( const WeakCallbackInfo& data) { CallbackInfo* self = data.GetParameter(); diff --git a/src/node_contextify.cc b/src/node_contextify.cc index d6b77c6145b2cb..f49a2362769bc2 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -109,11 +109,6 @@ ContextifyContext::ContextifyContext( } -ContextifyContext::~ContextifyContext() { - context_.Reset(); -} - - // This is an object that just keeps an internal pointer to this // ContextifyContext. It's passed to the NamedPropertyHandler. If we // pass the main JavaScript context object we're embedded in, then the @@ -1157,11 +1152,6 @@ class ContextifyScript : public BaseObject { : BaseObject(env, object) { MakeWeak(this); } - - - ~ContextifyScript() override { - script_.Reset(); - } }; diff --git a/src/node_contextify.h b/src/node_contextify.h index 33252e39abc378..e6b7e0a9e080f2 100644 --- a/src/node_contextify.h +++ b/src/node_contextify.h @@ -21,7 +21,6 @@ class ContextifyContext { ContextifyContext(Environment* env, v8::Local sandbox_obj, v8::Local options_obj); - ~ContextifyContext(); v8::Local CreateDataWrapper(Environment* env); v8::Local CreateV8Context(Environment* env, diff --git a/src/node_crypto.cc b/src/node_crypto.cc index eb7d3fdf7aa545..3e630926b5547a 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -2826,7 +2826,6 @@ void SSLWrap::CertCbDone(const FunctionCallbackInfo& args) { if (cons->HasInstance(ctx)) { SecureContext* sc; ASSIGN_OR_RETURN_UNWRAP(&sc, ctx.As()); - w->sni_context_.Reset(); w->sni_context_.Reset(env->isolate(), ctx); int rv; @@ -5580,7 +5579,6 @@ class PBKDF2Request : public AsyncWrap { keylen_ = 0; ClearWrap(object()); - persistent().Reset(); } uv_work_t* work_req() { @@ -5747,7 +5745,6 @@ class RandomBytesRequest : public AsyncWrap { ~RandomBytesRequest() override { ClearWrap(object()); - persistent().Reset(); } uv_work_t* work_req() { diff --git a/src/node_crypto.h b/src/node_crypto.h index 2f831b6812c282..f1efa811985681 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -225,14 +225,6 @@ class SSLWrap { SSL_SESSION_free(next_sess_); next_sess_ = nullptr; } - -#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB - sni_context_.Reset(); -#endif - -#ifdef NODE__HAVE_TLSEXT_STATUS_CB - ocsp_response_.Reset(); -#endif // NODE__HAVE_TLSEXT_STATUS_CB } inline SSL* ssl() const { return ssl_; } diff --git a/src/node_http2.cc b/src/node_http2.cc index 5240ea8b5ca864..ed6bdec7bb896c 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -278,8 +278,6 @@ Http2Session::Http2Settings::Http2Settings( Http2Session::Http2Settings::~Http2Settings() { if (!object().IsEmpty()) ClearWrap(object()); - persistent().Reset(); - CHECK(persistent().IsEmpty()); } // Generates a Buffer that contains the serialized payload of a SETTINGS @@ -535,8 +533,6 @@ Http2Session::~Http2Session() { CHECK_EQ(flags_ & SESSION_STATE_HAS_SCOPE, 0); if (!object().IsEmpty()) ClearWrap(object()); - persistent().Reset(); - CHECK(persistent().IsEmpty()); DEBUG_HTTP2SESSION(this, "freeing nghttp2 session"); nghttp2_session_del(session_); } @@ -1766,8 +1762,6 @@ Http2Stream::~Http2Stream() { if (!object().IsEmpty()) ClearWrap(object()); - persistent().Reset(); - CHECK(persistent().IsEmpty()); } // Notify the Http2Stream that a new block of HEADERS is being processed. @@ -2784,8 +2778,6 @@ Http2Session::Http2Ping::Http2Ping( Http2Session::Http2Ping::~Http2Ping() { if (!object().IsEmpty()) ClearWrap(object()); - persistent().Reset(); - CHECK(persistent().IsEmpty()); } void Http2Session::Http2Ping::Send(uint8_t* payload) { diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index d4044f8bbeea7b..207310f4068f43 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -157,7 +157,6 @@ class Parser : public AsyncWrap, public StreamListener { ~Parser() override { ClearWrap(object()); - persistent().Reset(); } diff --git a/src/req_wrap-inl.h b/src/req_wrap-inl.h index 4a7984e649c733..11b1389fa0e771 100644 --- a/src/req_wrap-inl.h +++ b/src/req_wrap-inl.h @@ -25,7 +25,6 @@ template ReqWrap::~ReqWrap() { CHECK_EQ(req_.data, this); // Assert that someone has called Dispatched(). CHECK_EQ(false, persistent().IsEmpty()); - persistent().Reset(); } template diff --git a/src/tcp_wrap.cc b/src/tcp_wrap.cc index a0a58fb1b5cc8d..61b08217b8f129 100644 --- a/src/tcp_wrap.cc +++ b/src/tcp_wrap.cc @@ -174,11 +174,6 @@ TCPWrap::TCPWrap(Environment* env, Local object, ProviderType provider) } -TCPWrap::~TCPWrap() { - CHECK(persistent().IsEmpty()); -} - - void TCPWrap::SetNoDelay(const FunctionCallbackInfo& args) { TCPWrap* wrap; ASSIGN_OR_RETURN_UNWRAP(&wrap, diff --git a/src/tcp_wrap.h b/src/tcp_wrap.h index a7f6b1901981f6..2ab50f1fdcdfab 100644 --- a/src/tcp_wrap.h +++ b/src/tcp_wrap.h @@ -55,7 +55,6 @@ class TCPWrap : public ConnectionWrap { TCPWrap(Environment* env, v8::Local object, ProviderType provider); - ~TCPWrap(); static void New(const v8::FunctionCallbackInfo& args); static void SetNoDelay(const v8::FunctionCallbackInfo& args); diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 18b56afece9e09..7ff49522438d65 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -86,12 +86,7 @@ TLSWrap::TLSWrap(Environment* env, TLSWrap::~TLSWrap() { enc_in_ = nullptr; enc_out_ = nullptr; - sc_ = nullptr; - -#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB - sni_context_.Reset(); -#endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB } @@ -852,7 +847,6 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) { return SSL_TLSEXT_ERR_NOACK; } - p->sni_context_.Reset(); p->sni_context_.Reset(env->isolate(), ctx); SecureContext* sc = Unwrap(ctx.As());