-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Remove StreamBase templating #25142
Remove StreamBase templating #25142
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
… Nice!
src/stream_base-inl.h
Outdated
#define STREAM_BASE_METHOD(func, str) \ | ||
do { \ | ||
Local<FunctionTemplate> func_templ = \ | ||
env->NewFunctionTemplate(func, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, we use 4 spaces of indentation here – and maybe it makes sense to turn this macro into a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tips: use CLANG_FORMAT_START=master make format-cpp
to auto format, or replace master
with some other commit that you are branching from
updated @addaleax @joyeecheung, PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM :)
Looks like there is an intermittent timeout issue on some platforms with |
@maclover7 It looks like the issue is that some streams, in particular libuv streams, delete the associated C++ object before the JS object is garbage collected. They set the first internal field to This would be a (but maybe not the best?) fix: diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h
index 1842962192db..d672fc5a0dae 100644
--- a/src/stream_base-inl.h
+++ b/src/stream_base-inl.h
@@ -274,6 +274,9 @@ inline void StreamBase::AttachToObject(v8::Local<v8::Object> obj) {
}
inline StreamBase* StreamBase::FromObject(v8::Local<v8::Object> obj) {
+ if (obj->GetAlignedPointerFromInternalField(0) == nullptr)
+ return nullptr;
+
return static_cast<StreamBase*>(
obj->GetAlignedPointerFromInternalField(kStreamBaseField));
} |
Ping @maclover7 – barring better ideas, I can also apply the patch above and push to this PR for you? |
Hm … ping @maclover7 again? :) |
I’ve rebased + pushed the suggested change… @jasnell Can you confirm your approval? |
Landed in 4697e1b 🎉 |
PR-URL: #25142 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Since 4697e1b, it is no longer necessary to use `v8::External`s to pass `StreamBase` instances to native functions. Refs: nodejs#25142
Since 4697e1b, it is no longer necessary to use `v8::External`s to pass `StreamBase` instances to native functions. PR-URL: #26510 Refs: #25142 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: nodejs#25142 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Since 4697e1b, it is no longer necessary to use `v8::External`s to pass `StreamBase` instances to native functions. PR-URL: #26510 Refs: #25142 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
PR-URL: #25142 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
Since 4697e1b, it is no longer necessary to use `v8::External`s to pass `StreamBase` instances to native functions. PR-URL: #26510 Refs: #25142 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
First attempt at trying to remove the templating in shared
StreamBase
methods. This approach casts directly toStreamBase
via an internal field.Unfortunately, I keep hitting linker errors when trying to run
make -j8
, and would appreciate any help in figuring out where they're coming from:Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes