Bug 753642. Rip out the codegen for the Xray-related bits of worker bindings, since we don't have Xrays in workers. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 23 May 2012 12:44:48 -0400
changeset 94706 6223b41be383471939628731f9a955149968d138
parent 94705 afb26ea68c7f042309b4a4dc5dc7261f716dc6f5
child 94707 7e85b068db34f63b8eed7ef8138302cf81fda72a
push id9756
push userbzbarsky@mozilla.com
push dateWed, 23 May 2012 16:45:40 +0000
treeherdermozilla-inbound@a4240610972e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs753642
milestone15.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 753642. Rip out the codegen for the Xray-related bits of worker bindings, since we don't have Xrays in workers. r=peterv
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -59,18 +59,22 @@ class CGThing():
 class CGNativePropertyHooks(CGThing):
     """
     Generate a NativePropertyHooks for a given descriptor
     """
     def __init__(self, descriptor):
         CGThing.__init__(self)
         self.descriptor = descriptor
     def declare(self):
+        if self.descriptor.workers:
+            return ""
         return "  extern const NativePropertyHooks NativeHooks;\n"
     def define(self):
+        if self.descriptor.workers:
+            return ""
         parent = self.descriptor.interface.parent
         parentHooks = ("&" + toBindingNamespace(parent.identifier.name) + "::NativeHooks"
                        if parent else 'NULL')
         return """
 const NativePropertyHooks NativeHooks = { ResolveProperty, EnumerateProperties, %s };
 """ % parentHooks
 
 class CGDOMJSClass(CGThing):
@@ -87,16 +91,17 @@ class CGDOMJSClass(CGThing):
         protoList = ['prototypes::id::' + proto for proto in self.descriptor.prototypeChain]
         # Pad out the list to the right length with _ID_Count so we
         # guarantee that all the lists are the same length.  _ID_Count
         # is never the ID of any prototype, so it's safe to use as
         # padding.
         while len(protoList) < self.descriptor.config.maxProtoChainLength:
             protoList.append('prototypes::id::_ID_Count')
         prototypeChainString = ', '.join(protoList)
+        nativeHooks = "NULL" if self.descriptor.workers else "&NativeHooks"
         return """
 DOMJSClass Class = {
   { "%s",
     JSCLASS_IS_DOMJSCLASS | JSCLASS_HAS_RESERVED_SLOTS(1),
     %s, /* addProperty */
     JS_PropertyStub,       /* delProperty */
     JS_PropertyStub,       /* getProperty */
     JS_StrictPropertyStub, /* setProperty */
@@ -108,22 +113,23 @@ DOMJSClass Class = {
     NULL,                  /* call */
     NULL,                  /* hasInstance */
     NULL,                  /* construct */
     %s, /* trace */
     JSCLASS_NO_INTERNAL_MEMBERS
   },
   { %s },
   -1, %s, DOM_OBJECT_SLOT,
-  &NativeHooks
+  %s
 };
 """ % (self.descriptor.interface.identifier.name,
        ADDPROPERTY_HOOK_NAME if self.descriptor.concrete and not self.descriptor.workers else 'JS_PropertyStub',
        FINALIZE_HOOK_NAME, traceHook, prototypeChainString,
-       str(self.descriptor.nativeIsISupports).lower())
+       str(self.descriptor.nativeIsISupports).lower(),
+       nativeHooks)
 
 class CGPrototypeJSClass(CGThing):
     def __init__(self, descriptor):
         CGThing.__init__(self)
         self.descriptor = descriptor
     def declare(self):
         # We're purely for internal consumption
         return ""
@@ -652,24 +658,22 @@ class PropertyDefiner:
     def variableName(self, chrome):
         if chrome and self.hasChromeOnly():
             return "sChrome" + self.name
         if self.hasNonChromeOnly():
             return "s" + self.name
         return "NULL"
     def usedForXrays(self, chrome):
         # We only need Xrays for methods and attributes.  And we only need them
-        # for the non-chrome ones if we have no chromeonly things or if we're a
-        # worker descriptor.  Otherwise (we're non-worker and have chromeonly
-        # attributes) we need Xrays for the chrome methods/attributes.
+        # for the non-chrome ones if we have no chromeonly things.  Otherwise
+        # (we have chromeonly attributes) we need Xrays for the chrome
+        # methods/attributes.  Finally, in workers there are no Xrays.
         return ((self.name is "Methods" or self.name is "Attributes") and
-                # XXXbz workers init the normal array but then use the chrome
-                # one, for Xrays, so we need to treat both as relevant.  See
-                # bug 753642.
-                (self.descriptor.workers or chrome == self.hasChromeOnly()))
+                chrome == self.hasChromeOnly() and
+                not self.descriptor.workers)
 
     def __str__(self):
         # We only need to generate id arrays for things that will end
         # up used via ResolveProperty or EnumerateProperties.
         str = self.generateArray(self.regular, self.variableName(False),
                                  self.usedForXrays(False))
         if self.hasChromeOnly():
             str += self.generateArray(self.chrome, self.variableName(True),
@@ -939,27 +943,26 @@ class CGCreateInterfaceObjectsMethod(CGA
 
         needInterfaceObject = self.descriptor.interface.hasInterfaceObject()
         needInterfacePrototypeObject = self.descriptor.interface.hasInterfacePrototypeObject()
 
         # if we don't need to create anything, why are we generating this?
         assert needInterfaceObject or needInterfacePrototypeObject
 
         idsToInit = []
-        for var in self.properties.xrayRelevantArrayNames():
-            props = getattr(self.properties, var)
-            # We only have non-chrome ids to init if we're workers or if we
-            # have no chrome ids.
-            # XXXbz workers init the normal array but then use the chrome
-            # one, for Xrays.  See bug 753642.  Hence the weird worker check.
-            if (props.hasNonChromeOnly() and
-                (self.descriptor.workers or not props.hasChromeOnly())):
-                idsToInit.append(props.variableName(False))
-            if props.hasChromeOnly() and not self.descriptor.workers:
-                idsToInit.append(props.variableName(True))
+        # There is no need to init any IDs in workers, because worker bindings
+        # don't have Xrays.
+        if not self.descriptor.workers:
+            for var in self.properties.xrayRelevantArrayNames():
+                props = getattr(self.properties, var)
+                # We only have non-chrome ids to init if we have no chrome ids.
+                if props.hasChromeOnly():
+                    idsToInit.append(props.variableName(True))
+                elif props.hasNonChromeOnly():
+                    idsToInit.append(props.variableName(False))
         if len(idsToInit) > 0:
             initIds = CGList(
                 [CGGeneric("!InitIds(aCx, %s, %s_ids)" % (varname, varname)) for
                  varname in idsToInit], ' ||\n')
             if len(idsToInit) > 1:
                 initIds = CGWrapper(initIds, pre="(", post=")", reindent=True)
             initIds = CGList(
                 [CGGeneric("%s_ids[0] == JSID_VOID &&" % idsToInit[0]), initIds],
@@ -3166,17 +3169,21 @@ class CGDescriptor(CGThing):
         properties = PropertyArrays(descriptor)
         cgThings.append(CGGeneric(define=str(properties)))
         cgThings.append(CGCreateInterfaceObjectsMethod(descriptor, properties))
         if descriptor.interface.hasInterfacePrototypeObject():
             cgThings.append(CGIndenter(CGGetProtoObjectMethod(descriptor)))
         else:
             cgThings.append(CGIndenter(CGGetConstructorObjectMethod(descriptor)))
 
-        if descriptor.concrete or descriptor.interface.hasInterfacePrototypeObject():
+        # Set up our Xray callbacks as needed.  Note that we don't need to do
+        # it in workers.
+        if ((descriptor.concrete or
+             descriptor.interface.hasInterfacePrototypeObject()) and
+            not descriptor.workers):
             cgThings.append(CGResolveProperty(descriptor, properties))
             cgThings.append(CGEnumerateProperties(descriptor, properties))
 
         if descriptor.interface.hasInterfaceObject():
             cgThings.append(CGDefineDOMInterfaceMethod(descriptor))
 
         if descriptor.concrete:
             cgThings.append(CGWrapMethod(descriptor))