Bug 938470 - Part 2: IPC actor should clone actors created on the parent side for the Nuwa process. r=bent, a=1.3+
authorCervantes Yu <cyu@mozilla.com>
Thu, 05 Dec 2013 20:10:04 +0800
changeset 175543 dd5dae1493c42cebfe0df44f85663e41f7a66ab9
parent 175542 4ff735ca9563c4e5a6910d953c0bcad16ee5dd42
child 175544 fefdc280c829d4e025c817b3de40e191774a6d2b
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent, 1
bugs938470
milestone28.0a2
Bug 938470 - Part 2: IPC actor should clone actors created on the parent side for the Nuwa process. r=bent, a=1.3+
ipc/ipdl/ipdl/lower.py
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -3807,31 +3807,53 @@ class _GenerateProtocolActorCode(ipdl.as
         if len(p.managesStmts):
             otherstmt = StmtDecl(Decl(managertype,
                                       othervar.name),
                                  init=ExprCast(sourcevar,
                                                managertype,
                                                static=1))
             clonemanagees.addstmt(otherstmt)
 
+        # Keep track of types created with an INOUT ctor. We need to call
+        # Register() or RegisterID() for them depending on the side the managee
+        # is created.
+        inoutCtorTypes = []
+        for msg in p.messageDecls:
+            msgtype = msg.decl.type
+            if msgtype.isCtor() and msgtype.isInout():
+                inoutCtorTypes.append(msgtype.constructedType())
+
         actorvar = ExprVar('actor')
         for managee in p.managesStmts:
             block = StmtBlock()
             manageeipdltype = managee.decl.type
             actortype = ipdl.type.ActorType(manageeipdltype)
             manageecxxtype = _cxxBareType(actortype, self.side)
             manageearray = p.managedVar(manageeipdltype, self.side)
             abortstmt = StmtIf(ExprBinary(actorvar, '==', ExprLiteral.NULL))
             abortstmt.addifstmts([
                 _runtimeAbort('can not clone an ' + actortype.name() + ' actor'),
                 StmtReturn()])
             forstmt = StmtFor(
                 init=Param(Type.UINT32, ivar.name, ExprLiteral.ZERO),
                 cond=ExprBinary(ivar, '<', _callCxxArrayLength(kidsvar)),
                 update=ExprPrefixUnop(ivar, '++'))
+
+            registerstmt = StmtExpr(ExprCall(p.registerIDMethod(),
+                                    args=[actorvar, _actorId(actorvar)]))
+            # Implement if (actor id > 0) then Register() else RegisterID()
+            if manageeipdltype in inoutCtorTypes:
+                registerif = StmtIf(ExprBinary(_actorId(actorvar),
+                                               '>',
+                                               ExprLiteral.ZERO))
+                registerif.addifstmt(StmtExpr(ExprCall(p.registerMethod(),
+                                                       args=[actorvar])))
+                registerif.addelsestmt(registerstmt)
+                registerstmt = registerif
+
             forstmt.addstmts([
                 StmtExpr(ExprAssn(
                     actorvar,
                     ExprCast(
                         ExprCall(
                             ExprSelect(ithkid,
                                        '->',
                                        p.cloneProtocol().name),
@@ -3842,18 +3864,17 @@ class _GenerateProtocolActorCode(ipdl.as
                 abortstmt,
                 StmtExpr(ExprAssn(_actorId(actorvar), _actorId(ithkid))),
                 StmtExpr(ExprAssn(_actorManager(actorvar), ExprVar.THIS)),
                 StmtExpr(ExprAssn(
                     _actorChannel(actorvar),
                     p.channelForSubactor())),
                 StmtExpr(ExprAssn(_actorState(actorvar), _actorState(ithkid))),
                 StmtExpr(_callCxxArrayInsertSorted(manageearray, actorvar)),
-                StmtExpr(ExprCall(p.registerIDMethod(),
-                                  args=[actorvar, _actorId(actorvar)])),
+                registerstmt,
                 StmtExpr(ExprCall(
                     ExprSelect(actorvar,
                                '->',
                                p.cloneManagees().name),
                     args=[ ithkid, clonecontextvar ]))
                 ])
             block.addstmts([
                 StmtDecl(Decl(_cxxArrayType(manageecxxtype, ref=0),