Bug 1479930 - std::move() almost all arguments to Recv/Answer methods in IPC; r=froydnj
authorAlex Gaynor <agaynor@mozilla.com>
Wed, 13 Feb 2019 17:49:17 +0000
changeset 459039 943193dd891e
parent 458953 08f794a4928e
child 459040 53354f120211
push id111913
push usershindli@mozilla.com
push dateThu, 14 Feb 2019 05:01:59 +0000
treeherdermozilla-inbound@a0752d7e8073 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1479930
milestone67.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 1479930 - std::move() almost all arguments to Recv/Answer methods in IPC; r=froydnj The one exception is refcounted types, because std::move(RefPtr<T>) does not coerce to T*, which is what the current IPC methods accept. This does not rewrite all Recv/Answer methods to take advantage of move semantics. Differential Revision: https://phabricator.services.mozilla.com/D19669
ipc/ipdl/ipdl/lower.py
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -641,27 +641,19 @@ def _deallocMethod(ptype, side):
 class _HybridDecl:
     """A hybrid decl stores both an IPDL type and all the C++ type
 info needed by later passes, along with a basic name for the decl."""
 
     def __init__(self, ipdltype, name):
         self.ipdltype = ipdltype
         self.name = name
 
-    def isCopyable(self):
-        return not _cxxTypeNeedsMove(self.ipdltype)
-
     def var(self):
         return ExprVar(self.name)
 
-    def mayMoveExpr(self):
-        if self.isCopyable():
-            return self.var()
-        return ExprMove(self.var())
-
     def bareType(self, side, fq=False):
         """Return this decl's unqualified C++ type."""
         return _cxxBareType(self.ipdltype, side, fq=fq)
 
     def refType(self, side):
         """Return this decl's C++ type as a 'reference' type, which is not
 necessarily a C++ reference."""
         return _cxxRefType(self.ipdltype, side)
@@ -1066,17 +1058,23 @@ class MessageDecl(ipdl.ast.MessageDecl):
         return cxxparams
 
     def makeCxxArgs(self, paramsems='in', retsems='out', retcallsems='out',
                     implicit=True):
         assert not retcallsems or retsems  # retcallsems => returnsems
         cxxargs = []
 
         if paramsems == 'move':
-            cxxargs.extend([p.mayMoveExpr() for p in self.params])
+            # We don't std::move() RefPtr<T> types because current Recv*()
+            # implementors take these parameters as T*, and
+            # std::move(RefPtr<T>) doesn't coerce to T*.
+            cxxargs.extend([
+                p.var() if p.ipdltype.isCxx() and p.ipdltype.isRefcounted() else ExprMove(p.var())
+                for p in self.params
+            ])
         elif paramsems == 'in':
             cxxargs.extend([p.var() for p in self.params])
         else:
             assert False
 
         for ret in self.returns:
             if retsems == 'in':
                 if retcallsems == 'in':