mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1262463 - part 3 - out-of-line NS_RUNTIMEABORT calls in IPDL-generated code; r=jld
We do this for the same reasons outlined in part 1: calls to NS_RUNTIMEABORT are rather large and we generate a lot of them (~1000 left after part 1). This patch reduces .text size by ~20K on x86-64 Linux.
This commit is contained in:
parent
a21ccf2f8e
commit
8d0d4b9bbd
@ -371,5 +371,11 @@ FatalError(const char* aProtocolName, const char* aMsg, bool aIsParent)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LogicError(const char* aMsg)
|
||||
{
|
||||
NS_RUNTIMEABORT(aMsg);
|
||||
}
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
@ -310,9 +310,19 @@ LogMessageForProtocol(const char* aTopLevelProtocol, base::ProcessId aOtherPid,
|
||||
MOZ_NEVER_INLINE void
|
||||
ProtocolErrorBreakpoint(const char* aMsg);
|
||||
|
||||
// The code generator calls this function for errors which come from the
|
||||
// methods of protocols. Doing this saves codesize by making the error
|
||||
// cases significantly smaller.
|
||||
MOZ_NEVER_INLINE void
|
||||
FatalError(const char* aProtocolName, const char* aMsg, bool aIsParent);
|
||||
|
||||
// The code generator calls this function for errors which are not
|
||||
// protocol-specific: errors in generated struct methods or errors in
|
||||
// transition functions, for instance. Doing this saves codesize by
|
||||
// by making the error cases significantly smaller.
|
||||
MOZ_NEVER_INLINE void
|
||||
LogicError(const char* aMsg);
|
||||
|
||||
struct PrivateIPDLInterface {};
|
||||
|
||||
nsresult
|
||||
|
@ -314,12 +314,6 @@ def _abortIfFalse(cond, msg):
|
||||
ExprVar('MOZ_DIAGNOSTIC_ASSERT'),
|
||||
[ cond, ExprLiteral.String(msg) ]))
|
||||
|
||||
def _runtimeAbort(msg):
|
||||
if isinstance(msg, str):
|
||||
msg = ExprLiteral.String(msg)
|
||||
return StmtExpr(
|
||||
ExprCall(ExprVar('NS_RUNTIMEABORT'), args=[ msg ]))
|
||||
|
||||
def _refptr(T):
|
||||
return Type('RefPtr', T=T)
|
||||
|
||||
@ -417,6 +411,10 @@ def _fatalError(msg):
|
||||
return StmtExpr(
|
||||
ExprCall(ExprVar('FatalError'), args=[ ExprLiteral.String(msg) ]))
|
||||
|
||||
def _logicError(msg):
|
||||
return StmtExpr(
|
||||
ExprCall(ExprVar('mozilla::ipc::LogicError'), args=[ ExprLiteral.String(msg) ]))
|
||||
|
||||
def _killProcess(pid):
|
||||
return ExprCall(
|
||||
ExprVar('base::KillProcess'),
|
||||
@ -1846,7 +1844,7 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
|
||||
# special case for Dead
|
||||
deadblock = Block()
|
||||
deadblock.addstmts([
|
||||
_runtimeAbort('__delete__()d actor'),
|
||||
_logicError('__delete__()d actor'),
|
||||
StmtReturn(ExprLiteral.FALSE) ])
|
||||
fromswitch.addcase(CaseLabel(_deadState().name), deadblock)
|
||||
|
||||
@ -1861,13 +1859,13 @@ class _GenerateProtocolCode(ipdl.ast.Visitor):
|
||||
StmtReturn(ExprLiteral.TRUE))
|
||||
else:
|
||||
dyingblock.addstmts([
|
||||
_runtimeAbort('__delete__()d (and unexpectedly dying) actor'),
|
||||
_logicError('__delete__()d (and unexpectedly dying) actor'),
|
||||
StmtReturn(ExprLiteral.FALSE) ])
|
||||
fromswitch.addcase(CaseLabel(_dyingState().name), dyingblock)
|
||||
|
||||
unreachedblock = Block()
|
||||
unreachedblock.addstmts([
|
||||
_runtimeAbort('corrupted actor state'),
|
||||
_logicError('corrupted actor state'),
|
||||
StmtReturn(ExprLiteral.FALSE) ])
|
||||
fromswitch.addcase(DefaultLabel(), unreachedblock)
|
||||
|
||||
@ -2284,7 +2282,7 @@ def _generateCxxUnion(ud):
|
||||
StmtBreak() ]))
|
||||
dtorswitch.addcase(
|
||||
DefaultLabel(),
|
||||
StmtBlock([ _runtimeAbort("not reached"), StmtBreak() ]))
|
||||
StmtBlock([ _logicError("not reached"), StmtBreak() ]))
|
||||
maybedtor.addstmts([
|
||||
ifnone,
|
||||
ifnochange,
|
||||
@ -2355,7 +2353,7 @@ def _generateCxxUnion(ud):
|
||||
StmtBlock([ StmtBreak() ]))
|
||||
copyswitch.addcase(
|
||||
DefaultLabel(),
|
||||
StmtBlock([ _runtimeAbort('unreached'), StmtReturn() ]))
|
||||
StmtBlock([ _logicError('unreached'), StmtReturn() ]))
|
||||
copyctor.addstmts([
|
||||
StmtExpr(callAssertSanity(uvar=othervar)),
|
||||
copyswitch,
|
||||
@ -2411,7 +2409,7 @@ def _generateCxxUnion(ud):
|
||||
StmtBreak() ]))
|
||||
opeqswitch.addcase(
|
||||
DefaultLabel(),
|
||||
StmtBlock([ _runtimeAbort('unreached'), StmtBreak() ]))
|
||||
StmtBlock([ _logicError('unreached'), StmtBreak() ]))
|
||||
opeq.addstmts([
|
||||
StmtExpr(callAssertSanity(uvar=rhsvar)),
|
||||
StmtDecl(Decl(typetype, rhstypevar.name), init=ud.callType(rhsvar)),
|
||||
@ -2452,7 +2450,7 @@ def _generateCxxUnion(ud):
|
||||
opeqeqswitch.addcase(CaseLabel(c.enum()), case)
|
||||
opeqeqswitch.addcase(
|
||||
DefaultLabel(),
|
||||
StmtBlock([ _runtimeAbort('unreached'),
|
||||
StmtBlock([ _logicError('unreached'),
|
||||
StmtReturn.FALSE ]))
|
||||
opeqeq.addstmt(opeqeqswitch)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user