Remove StreamBase templating#25142
Remove StreamBase templating#25142maclover7 wants to merge 8 commits intonodejs:masterfrom maclover7:jm-streambase
Conversation
src/stream_base-inl.h
Outdated
There was a problem hiding this comment.
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.
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 |
|
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
StreamBasemethods. This approach casts directly toStreamBasevia 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:Details
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes