зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1259428 - part 1 - don't call Log methods of generated method classes; r=jld
The first step to eliminating all the generated Message subclasses the IPDL compiler spits out is to move the functionality of their Log methods someplace else. In addition to eliminating the need for the Log methods, this change has the welcome effect of moving a bunch of code that would be generated hundreds of times into a single place, which should reduce code size a bit (debug builds only). We don't actually remove the generation of the Log methods; that change will be done for a future patch.
This commit is contained in:
Родитель
af75ceece1
Коммит
63fe89bd2e
|
@ -315,6 +315,24 @@ void AnnotateSystemError()
|
|||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
LogMessageForProtocol(const char* aTopLevelProtocol, base::ProcessId aOtherPid,
|
||||
const char* aContextDescription,
|
||||
const char* aMessageDescription,
|
||||
MessageDirection aDirection)
|
||||
{
|
||||
nsPrintfCString logMessage("[time: %" PRId64 "][%d%s%d] [%s] %s %s\n",
|
||||
PR_Now(), base::GetCurrentProcId(),
|
||||
aDirection == MessageDirection::eReceiving ? "<-" : "->",
|
||||
aOtherPid, aTopLevelProtocol,
|
||||
aContextDescription,
|
||||
aMessageDescription);
|
||||
#ifdef ANDROID
|
||||
__android_log_write(ANDROID_LOG_INFO, "GeckoIPC", logMessage.get());
|
||||
#endif
|
||||
fputs(logMessage.get(), stderr);
|
||||
}
|
||||
|
||||
void
|
||||
ProtocolErrorBreakpoint(const char* aMsg)
|
||||
{
|
||||
|
|
|
@ -296,6 +296,17 @@ LoggingEnabledFor(const char *aTopLevelProtocol)
|
|||
#endif
|
||||
}
|
||||
|
||||
enum class MessageDirection {
|
||||
eSending,
|
||||
eReceiving,
|
||||
};
|
||||
|
||||
MOZ_NEVER_INLINE void
|
||||
LogMessageForProtocol(const char* aTopLevelProtocol, base::ProcessId aOtherPid,
|
||||
const char* aContextDescription,
|
||||
const char* aMessageDescription,
|
||||
MessageDirection aDirection);
|
||||
|
||||
MOZ_NEVER_INLINE void
|
||||
ProtocolErrorBreakpoint(const char* aMsg);
|
||||
|
||||
|
|
|
@ -5380,12 +5380,16 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
|
|||
def logMessage(self, md, msgptr, pfx, actor=None, receiving=False):
|
||||
actorname = _actorName(self.protocol.name, self.side)
|
||||
|
||||
topLevel = self.protocol.decl.type.toplevel().name()
|
||||
return _ifLogging(ExprLiteral.String(topLevel), [ StmtExpr(ExprCall(
|
||||
ExprSelect(msgptr, '->', 'Log'),
|
||||
args=[ ExprLiteral.String('['+ actorname +'] '+ pfx),
|
||||
self.protocol.callOtherPid(actor),
|
||||
ExprLiteral.TRUE if receiving else ExprLiteral.FALSE ])) ])
|
||||
return _ifLogging(ExprLiteral.String(actorname),
|
||||
[ StmtExpr(ExprCall(
|
||||
ExprVar('mozilla::ipc::LogMessageForProtocol'),
|
||||
args=[ ExprLiteral.String(actorname),
|
||||
self.protocol.callOtherPid(actor),
|
||||
ExprLiteral.String(pfx),
|
||||
ExprCall(ExprSelect(msgptr, '->', 'name')),
|
||||
ExprVar('mozilla::ipc::MessageDirection::eReceiving'
|
||||
if receiving
|
||||
else 'mozilla::ipc::MessageDirection::eSending') ])) ])
|
||||
|
||||
def profilerLabel(self, tag, msgname):
|
||||
return StmtExpr(ExprCall(ExprVar('PROFILER_LABEL'),
|
||||
|
|
Загрузка…
Ссылка в новой задаче