Bug 1212027 - part 1 - rename ipdl lowering helpers to reflect intent, not function; r=jld
authorNathan Froyd <froydnj@mozilla.com>
Tue, 06 Oct 2015 21:20:07 -0400
changeset 301484 6bbd5af4df15330d119e25627c001a16e7cb2ea4
parent 301483 d922e18b6dc14b44bc3775e14905f319dc35f7be
child 301485 184d0872bf883ed1c651651e5e3fb1947a8ecb64
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjld
bugs1212027
milestone44.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 1212027 - part 1 - rename ipdl lowering helpers to reflect intent, not function; r=jld The functions: - _callCxxArrayInsertSorted - _callCxxArrayRemoveSorted - _callCxxArrayClear - _cxxArrayHasElementSorted are only ever used to touch the managed sub-protocol arrays of a protocol. It would be better if they reflected the *intent* of what they were doing, rather than what C++ function they were calling, since we're about to change that.
ipc/ipdl/ipdl/lower.py
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -347,31 +347,31 @@ def _callCxxCheckedArraySetLength(arr, l
     ifbad.addifstmt(_fatalError('Error setting the array length'))
     ifbad.addifstmt(StmtReturn.FALSE)
     return ifbad
 
 def _callCxxSwapArrayElements(arr1, arr2, sel='.'):
     return ExprCall(ExprSelect(arr1, sel, 'SwapElements'),
                     args=[ arr2 ])
 
-def _callCxxArrayInsertSorted(arr, elt):
-    return ExprCall(ExprSelect(arr, '.', 'InsertElementSorted'),
-                    args=[ elt ])
-
-def _callCxxArrayRemoveSorted(arr, elt):
-    return ExprCall(ExprSelect(arr, '.', 'RemoveElementSorted'),
-                    args=[ elt ])
-
-def _callCxxArrayClear(arr):
-    return ExprCall(ExprSelect(arr, '.', 'Clear'))
-
-def _cxxArrayHasElementSorted(arr, elt):
+def _callInsertManagedActor(managees, actor):
+    return ExprCall(ExprSelect(managees, '.', 'InsertElementSorted'),
+                    args=[ actor ])
+
+def _callRemoveManagedActor(managees, actor):
+    return ExprCall(ExprSelect(managees, '.', 'RemoveElementSorted'),
+                    args=[ actor ])
+
+def _callClearManagedActors(managees):
+    return ExprCall(ExprSelect(managees, '.', 'Clear'))
+
+def _callHasManagedActor(managees, actor):
     return ExprBinary(
-        ExprSelect(arr, '.', 'NoIndex'), '!=',
-        ExprCall(ExprSelect(arr, '.', 'BinaryIndexOf'), args=[ elt ]))
+        ExprSelect(managees, '.', 'NoIndex'), '!=',
+        ExprCall(ExprSelect(managees, '.', 'BinaryIndexOf'), args=[ actor ]))
 
 def _otherSide(side):
     if side == 'child':  return 'parent'
     if side == 'parent':  return 'child'
     assert 0
 
 def _sideToTransportMode(side):
     if side == 'parent':  mode = 'SERVER'
@@ -3492,17 +3492,17 @@ class _GenerateProtocolActorCode(ipdl.as
                          kidsvar.name),
                     init=p.managedVar(managed, self.side)),
                 foreachrecurse,
                 Whitespace.NL,
                 # no need to copy |kids| here; we're the ones deleting
                 # stragglers, no outside C++ is being invoked (except
                 # Dealloc(subactor))
                 foreachdealloc,
-                StmtExpr(_callCxxArrayClear(p.managedVar(managed, self.side))),
+                StmtExpr(_callClearManagedActors(p.managedVar(managed, self.side))),
 
             ])
             deallocsubtree.addstmt(block)
         # don't delete outselves: either the manager will do it, or
         # we're toplevel
         self.cls.addstmts([ deallocsubtree, Whitespace.NL ])
 
         if ptype.isToplevel():
@@ -3953,17 +3953,17 @@ class _GenerateProtocolActorCode(ipdl.as
                         static=1))),
                 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(_callInsertManagedActor(manageearray, actorvar)),
                 registerstmt,
                 StmtExpr(ExprCall(
                     ExprSelect(actorvar,
                                '->',
                                p.cloneManagees().name),
                     args=[ ithkid, clonecontextvar ]))
                 ])
             block.addstmts([
@@ -3997,20 +3997,20 @@ class _GenerateProtocolActorCode(ipdl.as
                 manageecxxtype = _cxxBareType(ipdl.type.ActorType(manageeipdltype),
                                               self.side)
                 manageearray = p.managedVar(manageeipdltype, self.side)
 
                 case.addstmts([
                     StmtDecl(Decl(manageecxxtype, actorvar.name),
                              ExprCast(listenervar, manageecxxtype, static=1)),
                     _abortIfFalse(
-                        _cxxArrayHasElementSorted(manageearray, actorvar),
+                        _callHasManagedActor(manageearray, actorvar),
                         "actor not managed by this!"),
                     Whitespace.NL,
-                    StmtExpr(_callCxxArrayRemoveSorted(manageearray, actorvar)),
+                    StmtExpr(_callRemoveManagedActor(manageearray, actorvar)),
                     StmtExpr(ExprCall(_deallocMethod(manageeipdltype, self.side),
                                       args=[ actorvar ])),
                     StmtReturn()
                 ])
                 switchontype.addcase(CaseLabel(_protocolId(manageeipdltype).name),
                                      case)
             default = StmtBlock()
             default.addstmts([ _runtimeAbort('unreached'), StmtReturn() ])
@@ -4940,17 +4940,17 @@ class _GenerateProtocolActorCode(ipdl.as
                               args=[ actorvar, idexpr ])
 
         return [
             self.failIfNullActor(actorvar, errfn, msg="Error constructing actor %s" % actortype.name() + self.side.capitalize()),
             StmtExpr(ExprAssn(_actorId(actorvar), idexpr)),
             StmtExpr(ExprAssn(_actorManager(actorvar), ExprVar.THIS)),
             StmtExpr(ExprAssn(_actorChannel(actorvar),
                               self.protocol.channelForSubactor())),
-            StmtExpr(_callCxxArrayInsertSorted(
+            StmtExpr(_callInsertManagedActor(
                 self.protocol.managedVar(md.decl.type.constructedType(),
                                          self.side),
                 actorvar)),
             StmtExpr(ExprAssn(_actorState(actorvar),
                               _startState(actorproto, fq=1)))
         ]
 
     def failCtorIf(self, md, cond):