From 773e6699c5d79330c89e699261565ff2312dfe71 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 8 May 2020 05:56:31 +0200 Subject: [PATCH 1/2] src: remove unnecessary Isolate::GetCurrent() calls These calls are unnecessary in Release mode but would still have been included, so move them to the `DebugSealHandleScope` constructor. --- src/node_internals.h | 2 +- src/stream_base-inl.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/node_internals.h b/src/node_internals.h index fa3ba022fe7e23..751eb5889e5ff3 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -245,7 +245,7 @@ class DebugSealHandleScope { public: explicit inline DebugSealHandleScope(v8::Isolate* isolate) #ifdef DEBUG - : actual_scope_(isolate) + : actual_scope_(isolate != nullptr ? isolate : v8::Isolate::GetCurrent()) #endif {} diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h index 9660cc386cef82..c3cfaa701aeb64 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -92,29 +92,29 @@ void StreamResource::RemoveStreamListener(StreamListener* listener) { } uv_buf_t StreamResource::EmitAlloc(size_t suggested_size) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope handle_scope(nullptr); return listener_->OnStreamAlloc(suggested_size); } void StreamResource::EmitRead(ssize_t nread, const uv_buf_t& buf) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope handle_scope(nullptr); if (nread > 0) bytes_read_ += static_cast(nread); listener_->OnStreamRead(nread, buf); } void StreamResource::EmitAfterWrite(WriteWrap* w, int status) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope handle_scope(nullptr); listener_->OnStreamAfterWrite(w, status); } void StreamResource::EmitAfterShutdown(ShutdownWrap* w, int status) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope handle_scope(nullptr); listener_->OnStreamAfterShutdown(w, status); } void StreamResource::EmitWantsWrite(size_t suggested_size) { - DebugSealHandleScope handle_scope(v8::Isolate::GetCurrent()); + DebugSealHandleScope handle_scope(nullptr); listener_->OnStreamWantsWrite(suggested_size); } From 08d076d18934c112ae94ef98c9733dccfc2dbea5 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 8 May 2020 19:40:07 +0200 Subject: [PATCH 2/2] fixup! src: remove unnecessary Isolate::GetCurrent() calls --- src/node_internals.h | 2 +- src/stream_base-inl.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/node_internals.h b/src/node_internals.h index 751eb5889e5ff3..70750cc87179ca 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -243,7 +243,7 @@ class InternalCallbackScope { class DebugSealHandleScope { public: - explicit inline DebugSealHandleScope(v8::Isolate* isolate) + explicit inline DebugSealHandleScope(v8::Isolate* isolate = nullptr) #ifdef DEBUG : actual_scope_(isolate != nullptr ? isolate : v8::Isolate::GetCurrent()) #endif diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h index c3cfaa701aeb64..149f542d841607 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -92,29 +92,29 @@ void StreamResource::RemoveStreamListener(StreamListener* listener) { } uv_buf_t StreamResource::EmitAlloc(size_t suggested_size) { - DebugSealHandleScope handle_scope(nullptr); + DebugSealHandleScope seal_handle_scope; return listener_->OnStreamAlloc(suggested_size); } void StreamResource::EmitRead(ssize_t nread, const uv_buf_t& buf) { - DebugSealHandleScope handle_scope(nullptr); + DebugSealHandleScope seal_handle_scope; if (nread > 0) bytes_read_ += static_cast(nread); listener_->OnStreamRead(nread, buf); } void StreamResource::EmitAfterWrite(WriteWrap* w, int status) { - DebugSealHandleScope handle_scope(nullptr); + DebugSealHandleScope seal_handle_scope; listener_->OnStreamAfterWrite(w, status); } void StreamResource::EmitAfterShutdown(ShutdownWrap* w, int status) { - DebugSealHandleScope handle_scope(nullptr); + DebugSealHandleScope seal_handle_scope; listener_->OnStreamAfterShutdown(w, status); } void StreamResource::EmitWantsWrite(size_t suggested_size) { - DebugSealHandleScope handle_scope(nullptr); + DebugSealHandleScope seal_handle_scope; listener_->OnStreamWantsWrite(suggested_size); }