Bug 1128768: Part 1 - Modify IPC to allow retrieval of topmost routing id on the stack; r=dvander
authorAaron Klotz <aklotz@mozilla.com>
Wed, 18 Feb 2015 23:05:54 -0700
changeset 232672 613ea27a306e068e3343b5f45f5e7e026d6b6e0c
parent 232671 3b0e8c6dab68e874b52a8cc5dc28a726408fb56f
child 232673 13eb8592325c6886fd8f02b7b0390120f08ac503
push id28390
push usercbook@mozilla.com
push dateTue, 10 Mar 2015 12:54:55 +0000
treeherdermozilla-central@c42e7e3bb0a0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1128768
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1128768: Part 1 - Modify IPC to allow retrieval of topmost routing id on the stack; r=dvander
ipc/glue/MessageChannel.cpp
ipc/glue/MessageChannel.h
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -188,16 +188,21 @@ public:
         *id = mMessageRoutingId;
         *dir = (IN_MESSAGE == mDirection) ? "in" : "out";
         *sems = (INTR_SEMS == mMesageSemantics) ? "intr" :
                 (SYNC_SEMS == mMesageSemantics) ? "sync" :
                 "async";
         *name = mMessageName;
     }
 
+    int32_t GetRoutingId() const
+    {
+        return mMessageRoutingId;
+    }
+
 private:
     const char* mMessageName;
     int32_t mMessageRoutingId;
     Semantics mMesageSemantics;
     Direction mDirection;
     DebugOnly<bool> mMoved;
 
     // Disable harmful methods.
@@ -1821,16 +1826,27 @@ MessageChannel::DumpInterruptStack(const
         const char* name;
         mCxxStackFrames[i].Describe(&id, &dir, &sems, &name);
 
         printf_stderr("%s[(%u) %s %s %s(actor=%d) ]\n", pfx,
                       i, dir, sems, name, id);
     }
 }
 
+int32_t
+MessageChannel::GetTopmostMessageRoutingId() const
+{
+    MOZ_ASSERT(MessageLoop::current() == mWorkerLoop);
+    if (mCxxStackFrames.empty()) {
+        return MSG_ROUTING_NONE;
+    }
+    const InterruptFrame& frame = mCxxStackFrames.back();
+    return frame.GetRoutingId();
+}
+
 bool
 ParentProcessIsBlocked()
 {
     return gParentIsBlocked;
 }
 
 } // ipc
 } // mozilla
--- a/ipc/glue/MessageChannel.h
+++ b/ipc/glue/MessageChannel.h
@@ -130,16 +130,24 @@ class MessageChannel : HasResultCodes
     bool CanSend() const;
 
     void SetReplyTimeoutMs(int32_t aTimeoutMs);
 
     bool IsOnCxxStack() const {
         return !mCxxStackFrames.empty();
     }
 
+    /**
+     * This function is used by hang annotation code to determine which IPDL
+     * actor is highest in the call stack at the time of the hang. It should
+     * be called from the main thread when a sync or intr message is about to
+     * be sent.
+     */
+    int32_t GetTopmostMessageRoutingId() const;
+
     void FlushPendingInterruptQueue();
 
     // Unsound_IsClosed and Unsound_NumQueuedMessages are safe to call from any
     // thread, but they make no guarantees about whether you'll get an
     // up-to-date value; the values are written on one thread and read without
     // locking, on potentially different threads.  Thus you should only use
     // them when you don't particularly care about getting a recent value (e.g.
     // in a memory report).