Bug 986317 - Stop exposing urgent semantics in IPDL files (r=bent)
authorBill McCloskey <wmccloskey@mozilla.com>
Thu, 03 Apr 2014 13:29:11 -0700
changeset 176978 0eec23f41606f270aae7e1fbcb7f7de7a639d6b7
parent 176977 07eb968c0c5a34cf4154d08c2a1fcd48a94925a7
child 176979 90f74b01a4a59ba4b091fb1741958e08b4627198
push id41882
push userwmccloskey@mozilla.com
push dateThu, 03 Apr 2014 20:29:50 +0000
treeherdermozilla-inbound@0eec23f41606 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbent
bugs986317
milestone31.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 986317 - Stop exposing urgent semantics in IPDL files (r=bent)
ipc/ipdl/ipdl/ast.py
ipc/ipdl/ipdl/cgen.py
ipc/ipdl/ipdl/lower.py
ipc/ipdl/ipdl/parser.py
ipc/ipdl/ipdl/type.py
ipc/ipdl/test/cxx/PTestRPC.ipdl
ipc/ipdl/test/cxx/PTestUrgency.ipdl
ipc/ipdl/test/ipdl/error/tooWeakRpcSync.ipdl
ipc/ipdl/test/ipdl/error/urgentChildToParent.ipdl
js/ipc/PJavaScript.ipdl
--- a/ipc/ipdl/ipdl/ast.py
+++ b/ipc/ipdl/ipdl/ast.py
@@ -209,45 +209,25 @@ class PrettyPrinted:
     def __str__(cls):  return cls.pretty
     
 class ASYNC(PrettyPrinted):
     pretty = 'async'
 class INTR(PrettyPrinted):
     pretty = 'intr'
 class SYNC(PrettyPrinted):
     pretty = 'sync'
-class URGENT(PrettyPrinted):
-    pretty = 'urgent'
 class RPC(PrettyPrinted):
     pretty = 'rpc'
 
 class INOUT(PrettyPrinted):
     pretty = 'inout'
 class IN(PrettyPrinted):
     pretty = 'in'
-    @staticmethod
-    def prettySS(cls, ss): return _prettyTable['in'][ss.pretty]
 class OUT(PrettyPrinted):
     pretty = 'out'
-    @staticmethod
-    def prettySS(ss): return _prettyTable['out'][ss.pretty]
-
-_prettyTable = {
-    IN  : { 'async': 'AsyncRecv',
-            'sync': 'SyncRecv',
-            'intr': 'IntrAnswer',
-            'rpc': 'RPCAnswer',
-            'urgent': 'UrgentAnswer' },
-    OUT : { 'async': 'AsyncSend',
-            'sync': 'SyncSend',
-            'intr': 'IntrCall',
-            'rpc': 'RPCCall',
-            'urgent': 'UrgentCall' }
-    # inout doesn't make sense here
-}
 
 
 class Namespace(Node):
     def __init__(self, loc, namespace):
         Node.__init__(self, loc)
         self.name = namespace
 
 class Protocol(NamespacedNode):
--- a/ipc/ipdl/ipdl/cgen.py
+++ b/ipc/ipdl/ipdl/cgen.py
@@ -1,16 +1,16 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os, sys
 
 from ipdl.ast import Visitor
-from ipdl.ast import IN, OUT, INOUT, ASYNC, SYNC, INTR, URGENT
+from ipdl.ast import IN, OUT, INOUT, ASYNC, SYNC, INTR
 
 class CodePrinter:
     def __init__(self, outf=sys.stdout, indentCols=4):
         self.outf = outf
         self.col = 0
         self.indentCols = indentCols
 
     def write(self, str):
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -272,23 +272,23 @@ def _putInNamespaces(cxxthing, namespace
         newns = Namespace(ns.name)
         innerns.addstmt(newns)
         innerns = newns
     innerns.addstmt(cxxthing)
     return outerns
 
 def _sendPrefix(msgtype):
     """Prefix of the name of the C++ method that sends |msgtype|."""
-    if msgtype.isInterrupt() or msgtype.isUrgent() or msgtype.isRpc():
+    if msgtype.isInterrupt() or msgtype.isRpc():
         return 'Call'
     return 'Send'
 
 def _recvPrefix(msgtype):
     """Prefix of the name of the C++ method that handles |msgtype|."""
-    if msgtype.isInterrupt() or msgtype.isUrgent() or msgtype.isRpc():
+    if msgtype.isInterrupt() or msgtype.isRpc():
         return 'Answer'
     return 'Recv'
 
 def _flatTypeName(ipdltype):
     """Return a 'flattened' IPDL type name that can be used as an
 identifier.
 E.g., |Foo[]| --> |ArrayOfFoo|."""
     # NB: this logic depends heavily on what IPDL types are allowed to
@@ -4771,17 +4771,17 @@ class _GenerateProtocolActorCode(ipdl.as
         helpermethod = None
         recvlbl, recvcase = None, None
 
         def addRecvCase(lbl, case):
             if sems is ipdl.ast.ASYNC:
                 self.asyncSwitch.addcase(lbl, case)
             elif sems is ipdl.ast.SYNC:
                 self.syncSwitch.addcase(lbl, case)
-            elif sems is ipdl.ast.INTR or sems is ipdl.ast.URGENT or sems is ipdl.ast.RPC:
+            elif sems is ipdl.ast.INTR or sems is ipdl.ast.RPC:
                 self.interruptSwitch.addcase(lbl, case)
             else: assert 0
 
         if self.sendsMessage(md):
             isasync = (sems is ipdl.ast.ASYNC)
 
             if isctor:
                 self.cls.addstmts([ self.genHelperCtor(md), Whitespace.NL ])
@@ -5166,25 +5166,30 @@ class _GenerateProtocolActorCode(ipdl.as
         
         stmts = [ StmtExpr(ExprCall(
             ExprSelect(var, '->', 'set_routing_id'),
             args=[ routingId ])) ]
 
         if md.decl.type.isSync():
             stmts.append(StmtExpr(ExprCall(
                 ExprSelect(var, '->', 'set_sync'))))
-        elif md.decl.type.isUrgent():
-            stmts.append(StmtExpr(ExprCall(
-                ExprSelect(var, '->', 'set_urgent'))))
+        elif md.decl.type.isRpc():
+            # We use urgent messages from the parent to the child and
+            # RPC messages from the child to the parent. However,
+            # replies should always be sent using the same semantics
+            # as the original message, so we need to flip.
+            if (self.side == 'parent') ^ reply:
+                stmts.append(StmtExpr(ExprCall(
+                    ExprSelect(var, '->', 'set_urgent'))))
+            else:
+                stmts.append(StmtExpr(ExprCall(
+                    ExprSelect(var, '->', 'set_rpc'))))
         elif md.decl.type.isInterrupt():
             stmts.append(StmtExpr(ExprCall(
                 ExprSelect(var, '->', 'set_interrupt'))))
-        elif md.decl.type.isRpc():
-            stmts.append(StmtExpr(ExprCall(
-                ExprSelect(var, '->', 'set_rpc'))))
 
         if reply:
             stmts.append(StmtExpr(ExprCall(
                 ExprSelect(var, '->', 'set_reply'))))
 
         return stmts + [ Whitespace.NL ]
 
 
--- a/ipc/ipdl/ipdl/parser.py
+++ b/ipc/ipdl/ipdl/parser.py
@@ -142,17 +142,16 @@ reserved = set((
         'rpc',
         'send',
         'spawns',
         'start',
         'state',
         'struct',
         'sync',
         'union',
-        'urgent',
         'using'))
 tokens = [
     'COLONCOLON', 'ID', 'STRING'
 ] + [ r.upper() for r in reserved ]
 
 t_COLONCOLON = '::'
 
 literals = '(){}[]<>;:,~'
@@ -621,23 +620,21 @@ def p_OptionalSendSemanticsQual(p):
                                  | """
     if 2 == len(p): p[0] = p[1]
     else:           p[0] = ASYNC
 
 def p_SendSemanticsQual(p):
     """SendSemanticsQual : ASYNC
                          | INTR
                          | RPC
-                         | URGENT
                          | SYNC"""
     s = p[1]
     if 'async' == s: p[0] =    ASYNC
     elif 'intr' == s: p[0] =   INTR
     elif 'sync' == s: p[0] =   SYNC
-    elif 'urgent' == s: p[0] = URGENT
     elif 'rpc' == s: p[0] =    RPC
     else:
         assert 0
 
 def p_ParamList(p):
     """ParamList : ParamList ',' Param
                  | Param
                  | """
--- a/ipc/ipdl/ipdl/type.py
+++ b/ipc/ipdl/ipdl/type.py
@@ -2,17 +2,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os, sys
 
 from ipdl.ast import CxxInclude, Decl, Loc, QualifiedId, State, StructDecl, TransitionStmt
 from ipdl.ast import TypeSpec, UnionDecl, UsingStmt, Visitor, ASYNC, SYNC, INTR
-from ipdl.ast import IN, OUT, INOUT, ANSWER, CALL, RECV, SEND, URGENT, RPC
+from ipdl.ast import IN, OUT, INOUT, ANSWER, CALL, RECV, SEND, RPC
 import ipdl.builtin as builtin
 
 _DELETE_MSG = '__delete__'
 
 
 def _otherside(side):
     if side == 'parent':  return 'child'
     elif side == 'child': return 'parent'
@@ -202,33 +202,31 @@ class IPDLType(Type):
     def isCompound(self): return False
     def isShmem(self): return False
     def isChmod(self): return False
     def isFD(self): return False
 
     def isAsync(self): return self.sendSemantics is ASYNC
     def isSync(self): return self.sendSemantics is SYNC
     def isInterrupt(self): return self.sendSemantics is INTR
-    def isUrgent(self): return self.sendSemantics is URGENT
     def isRpc(self): return self.sendSemantics is RPC
 
     def talksAsync(self): return True
     def talksSync(self): return self.isSync() or self.isRpc() or self.isInterrupt()
     def talksRpc(self): return self.isRpc() or self.isInterrupt()
     def talksInterrupt(self): return self.isInterrupt()
 
     def hasReply(self):  return (self.isSync()
                                  or self.isInterrupt()
-                                 or self.isUrgent()
                                  or self.isRpc())
 
     def needsMoreJuiceThan(self, o):
         return (o.isAsync() and not self.isAsync()
-                or o.isSync() and (self.isUrgent() or self.isRpc())
-                or (o.isUrgent() or o.isRpc()) and self.isInterrupt())
+                or o.isSync() and self.isRpc()
+                or o.isRpc() and self.isInterrupt())
 
 class StateType(IPDLType):
     def __init__(self, protocol, name, start=False):
         self.protocol = protocol
         self.name = name
         self.start = start
     def isState(self): return True
     def name(self):
@@ -1460,28 +1458,16 @@ class CheckTypes(TcheckVisitor):
         loc = md.decl.loc
 
         if mtype.isSync() and (mtype.isOut() or mtype.isInout()):
             self.error(
                 loc,
                 "sync parent-to-child messages are verboten (here, message `%s' in protocol `%s')",
                 mname, pname)
 
-        if mtype.isUrgent() and (mtype.isIn() or mtype.isInout()):
-            self.error(
-                loc,
-                "urgent child-to-parent messages are verboten (here, message `%s' in protocol `%s')",
-                mname, pname)
-
-        if mtype.isRpc() and (mtype.isOut() or mtype.isInout()):
-            self.error(
-                loc,
-                "rpc parent-to-child messages are verboten (here, message' `%s' in protocol `%s')",
-                mname, pname)
-
         if mtype.needsMoreJuiceThan(ptype):
             self.error(
                 loc,
                 "message `%s' requires more powerful send semantics than its protocol `%s' provides",
                 mname, pname)
 
         if mtype.isAsync() and len(mtype.returns):
             # XXX/cjones could modify grammar to disallow this ...
--- a/ipc/ipdl/test/cxx/PTestRPC.ipdl
+++ b/ipc/ipdl/test/cxx/PTestRPC.ipdl
@@ -10,18 +10,18 @@ parent:
     rpc Test2_OutOfOrder();
     sync Test3_Start() returns (uint32_t result);
     rpc Test3_InnerEvent() returns (uint32_t result);
     intr Test4_Start() returns (uint32_t result);
     rpc Test4_Inner() returns (uint32_t result);
 
 child:
     async Start();
-    urgent Test1_InnerQuery() returns (uint32_t result);
-    urgent Test1_NoReenter() returns (uint32_t result);
-    urgent Test2_FirstUrgent();
-    urgent Test2_SecondUrgent();
-    urgent Test3_WakeUp() returns (uint32_t result);
-    urgent Test4_WakeUp() returns (uint32_t result);
+    rpc Test1_InnerQuery() returns (uint32_t result);
+    rpc Test1_NoReenter() returns (uint32_t result);
+    rpc Test2_FirstUrgent();
+    rpc Test2_SecondUrgent();
+    rpc Test3_WakeUp() returns (uint32_t result);
+    rpc Test4_WakeUp() returns (uint32_t result);
 };
 
 } // namespace _ipdltest
 } // namespace mozilla
--- a/ipc/ipdl/test/cxx/PTestUrgency.ipdl
+++ b/ipc/ipdl/test/cxx/PTestUrgency.ipdl
@@ -6,15 +6,15 @@ intr protocol PTestUrgency
 parent:
     sync Test1() returns (uint32_t result);
     async Test2();
     sync Test3() returns (uint32_t result);
     sync FinalTest_Begin();
 
 child:
     async Start();
-    urgent Reply1() returns (uint32_t result);
-    urgent Reply2() returns (uint32_t result);
-    urgent FinalTest_Hang();
+    rpc Reply1() returns (uint32_t result);
+    rpc Reply2() returns (uint32_t result);
+    rpc FinalTest_Hang();
 };
 
 } // namespace _ipdltest
 } // namespace mozilla
--- a/ipc/ipdl/test/ipdl/error/tooWeakRpcSync.ipdl
+++ b/ipc/ipdl/test/ipdl/error/tooWeakRpcSync.ipdl
@@ -1,8 +1,6 @@
 sync protocol tooWeakRpcSync {
 
-    // it's an error to declare a sync protocol with an rpc or urgent message
+    // it's an error to declare a sync protocol with an rpc message
 parent:
   rpc Msg();
-child:
-  urgent Msg2();
 };
deleted file mode 100644
--- a/ipc/ipdl/test/ipdl/error/urgentChildToParent.ipdl
+++ /dev/null
@@ -1,6 +0,0 @@
-intr protocol urgentChildToParent {
-
-    // can't declare urgent child-to-parent messages
-parent: ugrent Msg();
-
-};
--- a/js/ipc/PJavaScript.ipdl
+++ b/js/ipc/PJavaScript.ipdl
@@ -18,34 +18,34 @@ intr protocol PJavaScript
 {
     manager PContent;
 
 child:
     // The parent process no longer holds any references to the child object.
     async DropObject(uint64_t objId);
 
     // These roughly map to the ProxyHandler hooks that CPOWs need.
-    urgent PreventExtensions(uint64_t objId) returns (ReturnStatus rs);
-    urgent GetPropertyDescriptor(uint64_t objId, nsString id, uint32_t flags) returns (ReturnStatus rs, PPropertyDescriptor result);
-    urgent GetOwnPropertyDescriptor(uint64_t objId, nsString id, uint32_t flags) returns (ReturnStatus rs, PPropertyDescriptor result);
-    urgent DefineProperty(uint64_t objId, nsString id, PPropertyDescriptor descriptor) returns (ReturnStatus rs);
-    urgent Delete(uint64_t objId, nsString id) returns (ReturnStatus rs, bool successful);
+    rpc PreventExtensions(uint64_t objId) returns (ReturnStatus rs);
+    rpc GetPropertyDescriptor(uint64_t objId, nsString id, uint32_t flags) returns (ReturnStatus rs, PPropertyDescriptor result);
+    rpc GetOwnPropertyDescriptor(uint64_t objId, nsString id, uint32_t flags) returns (ReturnStatus rs, PPropertyDescriptor result);
+    rpc DefineProperty(uint64_t objId, nsString id, PPropertyDescriptor descriptor) returns (ReturnStatus rs);
+    rpc Delete(uint64_t objId, nsString id) returns (ReturnStatus rs, bool successful);
 
-    urgent Has(uint64_t objId, nsString id) returns (ReturnStatus rs, bool has);
-    urgent HasOwn(uint64_t objId, nsString id) returns (ReturnStatus rs, bool has);
-    urgent Get(uint64_t objId, uint64_t receiverId, nsString id) returns (ReturnStatus rs, JSVariant result);
-    urgent Set(uint64_t objId, uint64_t receiverId, nsString id, bool strict, JSVariant value) returns (ReturnStatus rs, JSVariant result);
+    rpc Has(uint64_t objId, nsString id) returns (ReturnStatus rs, bool has);
+    rpc HasOwn(uint64_t objId, nsString id) returns (ReturnStatus rs, bool has);
+    rpc Get(uint64_t objId, uint64_t receiverId, nsString id) returns (ReturnStatus rs, JSVariant result);
+    rpc Set(uint64_t objId, uint64_t receiverId, nsString id, bool strict, JSVariant value) returns (ReturnStatus rs, JSVariant result);
 
-    urgent IsExtensible(uint64_t objId) returns (ReturnStatus rs, bool result);
-    urgent Call(uint64_t objId, JSParam[] argv) returns (ReturnStatus rs, JSVariant result, JSParam[] outparams);
-    urgent ObjectClassIs(uint64_t objId, uint32_t classValue) returns (bool result);
-    urgent ClassName(uint64_t objId) returns (nsString name);
+    rpc IsExtensible(uint64_t objId) returns (ReturnStatus rs, bool result);
+    rpc Call(uint64_t objId, JSParam[] argv) returns (ReturnStatus rs, JSVariant result, JSParam[] outparams);
+    rpc ObjectClassIs(uint64_t objId, uint32_t classValue) returns (bool result);
+    rpc ClassName(uint64_t objId) returns (nsString name);
 
-    urgent GetPropertyNames(uint64_t objId, uint32_t flags) returns (ReturnStatus rs, nsString[] names);
-    urgent InstanceOf(uint64_t objId, JSIID iid) returns (ReturnStatus rs, bool instanceof);
-    urgent DOMInstanceOf(uint64_t objId, int prototypeID, int depth) returns (ReturnStatus rs, bool instanceof);
+    rpc GetPropertyNames(uint64_t objId, uint32_t flags) returns (ReturnStatus rs, nsString[] names);
+    rpc InstanceOf(uint64_t objId, JSIID iid) returns (ReturnStatus rs, bool instanceof);
+    rpc DOMInstanceOf(uint64_t objId, int prototypeID, int depth) returns (ReturnStatus rs, bool instanceof);
 
 parent:
     async __delete__();
 };
 
 }
 }