Bug 1320833 - Only generate State enum case for PFoo::State::__Dying when hasReentrantDelete(). r=kanru
authorAndrew McCreight <continuation@gmail.com>
Mon, 28 Nov 2016 15:49:26 -0800
changeset 324675 de1a1ae3cab63677724436d98f8d166b5557fac5
parent 324674 69842f0e5150f11849fe37773e8a15abc9a496e6
child 324676 cbde1c9e78d55907934892db41c6d2d5ac32a5e5
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerskanru
bugs1320833
milestone53.0a1
Bug 1320833 - Only generate State enum case for PFoo::State::__Dying when hasReentrantDelete(). r=kanru MozReview-Commit-ID: DpxXD7y8GpD
ipc/ipdl/ipdl/lower.py
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -1543,17 +1543,18 @@ class _GenerateProtocolCode(ipdl.ast.Vis
 
         # state information
         stateenum = TypeEnum('State')
         # NB: __Dead is the first state on purpose, so that it has
         # value '0'
         stateenum.addId(_deadState().name)
         stateenum.addId(_nullState().name)
         stateenum.addId(_errorState().name)
-        stateenum.addId(_dyingState().name)
+        if self.protocol.decl.type.hasReentrantDelete:
+            stateenum.addId(_dyingState().name)
         for ts in p.transitionStmts:
             stateenum.addId(ts.state.decl.cxxname)
         if len(p.transitionStmts):
             startstate = p.transitionStmts[0].state.decl.cxxname
         else:
             startstate = _nullState().name
         stateenum.addId(_startState().name, startstate)
 
@@ -1764,29 +1765,25 @@ class _GenerateProtocolCode(ipdl.ast.Vis
         # special case for Dead
         deadblock = Block()
         deadblock.addstmts([
             _logicError('__delete__()d actor'),
             StmtReturn(ExprLiteral.FALSE) ])
         fromswitch.addcase(CaseLabel(_deadState().name), deadblock)
 
         # special case for Dying
-        dyingblock = Block()
         if ptype.hasReentrantDelete:
+            dyingblock = Block()
             ifdelete = StmtIf(ExprBinary(_deleteReplyId(), '==', msgexpr))
             ifdelete.addifstmt(
                 StmtExpr(ExprAssn(ExprDeref(nextvar), _deadState())))
             dyingblock.addstmt(ifdelete)
             dyingblock.addstmt(
                 StmtReturn(ExprLiteral.TRUE))
-        else:
-            dyingblock.addstmts([
-                _logicError('__delete__()d (and unexpectedly dying) actor'),
-                StmtReturn(ExprLiteral.FALSE) ])
-        fromswitch.addcase(CaseLabel(_dyingState().name), dyingblock)
+            fromswitch.addcase(CaseLabel(_dyingState().name), dyingblock)
 
         unreachedblock = Block()
         unreachedblock.addstmts([
             _logicError('corrupted actor state'),
             StmtReturn(ExprLiteral.FALSE) ])
         fromswitch.addcase(DefaultLabel(), unreachedblock)
 
         if usesend: