Skip to content

Commit c2176e1

Browse files
addaleaxMylesBorins
authored andcommitted
src: move MemoryInfo() for worker code to .cc files
This is a) the right thing to do anyway because these functions can not be inlined by the compiler and b) avoids compilation warnings in the following commit. Backport-PR-URL: #32301 PR-URL: #31386 Refs: openjs-foundation/summit#240 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 22bf867 commit c2176e1

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

src/node_messaging.cc

+4
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,10 @@ void MessagePort::Entangle(MessagePort* a, MessagePortData* b) {
927927
MessagePortData::Entangle(a->data_.get(), b);
928928
}
929929

930+
void MessagePort::MemoryInfo(MemoryTracker* tracker) const {
931+
tracker->TrackField("data", data_);
932+
}
933+
930934
Local<FunctionTemplate> GetMessagePortConstructorTemplate(Environment* env) {
931935
// Factor generating the MessagePort JS constructor into its own piece
932936
// of code, because it is needed early on in the child environment setup.

src/node_messaging.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,7 @@ class MessagePort : public HandleWrap {
192192
// NULL pointer to the C++ MessagePort object is also detached.
193193
inline bool IsDetached() const;
194194

195-
void MemoryInfo(MemoryTracker* tracker) const override {
196-
tracker->TrackField("data", data_);
197-
}
198-
195+
void MemoryInfo(MemoryTracker* tracker) const override;
199196
SET_MEMORY_INFO_NAME(MessagePort)
200197
SET_SELF_SIZE(MessagePort)
201198

src/node_worker.cc

+4
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,10 @@ void Worker::Exit(int code) {
709709
}
710710
}
711711

712+
void Worker::MemoryInfo(MemoryTracker* tracker) const {
713+
tracker->TrackField("parent_port", parent_port_);
714+
}
715+
712716
namespace {
713717

714718
// Return the MessagePort that is global for this Environment and communicates

src/node_worker.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,10 @@ class Worker : public AsyncWrap {
4040
// Wait for the worker thread to stop (in a blocking manner).
4141
void JoinThread();
4242

43-
void MemoryInfo(MemoryTracker* tracker) const override {
44-
tracker->TrackField("parent_port", parent_port_);
45-
}
46-
4743
template <typename Fn>
4844
inline bool RequestInterrupt(Fn&& cb);
4945

46+
void MemoryInfo(MemoryTracker* tracker) const override;
5047
SET_MEMORY_INFO_NAME(Worker)
5148
SET_SELF_SIZE(Worker)
5249

0 commit comments

Comments
 (0)