Closed Bug 545455 Opened 15 years ago Closed 15 years ago

IPDL: Add hooks for when RPCChannel code is first pushed on and finally popped from the C++ stack

Categories

(Core :: IPC, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.3a2

People

(Reporter: cjones, Assigned: cjones)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

Two uses so far

 (1) Enable/disable nested glib event loop detection, for better power efficiency
 (2) Defer Dealloc*() in IPDL until IPDL code is off the stack (mostly)

I really only care about hooking RPCChannel because that's all we've used so far, but a similar hook could be useful for SyncChannel.
Comment on attachment 426608 [details] [diff] [review]
Part 1: Track when RPCChannel code is first pushed on the C++ stack and last popped

>+    void ExitedCxxStack();
>+    class NS_STACK_CLASS CxxStackFrame {

Nit: Newline between those

>+        CxxStackFrame(RPCChannel& that) : mThat(that) {

How about also AssertWorkerThread'ing here and in the dtor
Attachment #426608 - Flags: review?(bent.mozilla) → review+
Comment on attachment 426609 [details] [diff] [review]
Part 2: Expose override-able hooks for top-level IPDL actors to be notified on stack entrance/exit

> RPCChannel::EnteredCxxStack()
> RPCChannel::ExitedCxxStack()

Looks like these can be moved to the header (inlined)

>+        virtual void OnEnteredCxxStack() = 0;
>+        virtual void OnExitedCxxStack() = 0;

I think you should have a default impl that aborts here rather than make each non-toplevel actor implement their own.
Ooh, ooh! Can we also make these RPCStack helpers record message name?! Maybe only in debug builds?!
(In reply to comment #5)
> (From update of attachment 426609 [details] [diff] [review])
> > RPCChannel::EnteredCxxStack()
> > RPCChannel::ExitedCxxStack()
> 
> Looks like these can be moved to the header (inlined)
> 
> >+        virtual void OnEnteredCxxStack() = 0;
> >+        virtual void OnExitedCxxStack() = 0;
> 
> I think you should have a default impl that aborts here rather than make each
> non-toplevel actor implement their own.

Did you mean to leave the review status as "?"?  Do you want to see the updated patch?
(In reply to comment #6)
> Ooh, ooh! Can we also make these RPCStack helpers record message name?! Maybe
> only in debug builds?!

I have plans to add a Message::name() interface (in opt builds too).  Would that suit your needs?
Comment on attachment 426609 [details] [diff] [review]
Part 2: Expose override-able hooks for top-level IPDL actors to be notified on stack entrance/exit

Oops
Attachment #426609 - Flags: review?(bent.mozilla) → review+
(In reply to comment #8)
> I have plans to add a Message::name() interface (in opt builds too).  Would
> that suit your needs?

I just want to be able to look at some variable in the debugger that has a stack of message names. I don't want to have to call any functions (can't do that in record+replay) to do it either. Just a simple const char* for each rpcframe would do it i think. And only in DEBUG builds.
OIC.  Like storing a std::stack<const char*> as a member of RPCChannel, and having CxxStackFrame push Message::name() onto that as part of the ctor?  That's certainly doable.
http://hg.mozilla.org/mozilla-central/rev/dbfb36b8b381
http://hg.mozilla.org/mozilla-central/rev/d0f27565024d
http://hg.mozilla.org/mozilla-central/rev/569dede83071
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Whiteboard: [land m-c]
Target Milestone: --- → mozilla1.9.3a2
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: