Fix for bug 833518 (New HTMLElement bindings caused ~20MB regression in peak memory consumption on areweslimyet). r=bz/njn, a=lsblakk.
authorPeter Van der Beken <peterv@propagandism.org>
Fri, 25 Jan 2013 11:59:01 +0100
changeset 123846 6f2c8a3ad078
parent 123845 a728a1f234a0
child 123847 be4da114d75f
push id3287
push userpvanderbeken@mozilla.com
push dateThu, 31 Jan 2013 13:44:11 +0000
treeherdermozilla-aurora@6f2c8a3ad078 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, njn, lsblakk
bugs833518
milestone20.0a2
Fix for bug 833518 (New HTMLElement bindings caused ~20MB regression in peak memory consumption on areweslimyet). r=bz/njn, a=lsblakk.
dom/bindings/BindingUtils.cpp
js/src/jsapi.cpp
js/src/jsfriendapi.h
js/xpconnect/src/dom_quickstubs.qsconf
--- a/dom/bindings/BindingUtils.cpp
+++ b/dom/bindings/BindingUtils.cpp
@@ -338,19 +338,33 @@ CreateInterfaceObject(JSContext* cx, JSO
 bool
 DefineWebIDLBindingPropertiesOnXPCProto(JSContext* cx, JSObject* proto, const NativeProperties* properties)
 {
   if (properties->methods &&
       !DefinePrefable(cx, proto, properties->methods)) {
     return false;
   }
 
-  if (properties->attributes &&
-      !DefinePrefable(cx, proto, properties->attributes)) {
-    return false;
+  if (properties->attributes) {
+    Prefable<JSPropertySpec>* props = properties->attributes;
+    MOZ_ASSERT(props);
+    MOZ_ASSERT(props->specs);
+    do {
+      // Define if enabled
+      if (props->enabled) {
+        for (JSPropertySpec* ps = props->specs; ps->name; ++ps) {
+          if (ps->name[0] == 'o' && ps->name[1] == 'n') {
+            continue;
+          }
+          if (!js::DefineProperty(cx, proto, *ps)) {
+            return false;
+          }
+        }
+      }
+    } while ((++props)->specs);
   }
 
   return true;
 }
 
 static JSObject*
 CreateInterfacePrototypeObject(JSContext* cx, JSObject* global,
                                JSObject* parentProto, JSClass* protoClass,
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -4022,16 +4022,28 @@ JS_DefineProperties(JSContext *cx, JSObj
         ok = DefineProperty(cx, obj, ps->name, UndefinedValue(), ps->getter, ps->setter,
                             ps->flags, Shape::HAS_SHORTID, ps->tinyid);
         if (!ok)
             break;
     }
     return ok;
 }
 
+namespace js {
+
+JS_FRIEND_API(bool)
+DefineProperty(JSContext *cx, JSObject *objArg, JSPropertySpec &ps)
+{
+    RootedObject obj(cx, objArg);
+    return DefineProperty(cx, obj, ps.name, UndefinedValue(), ps.getter,
+                          ps.setter, ps.flags, Shape::HAS_SHORTID, ps.tinyid);
+}
+
+} /* namespace js */
+
 static JSBool
 GetPropertyDescriptorById(JSContext *cx, HandleObject obj, HandleId id, unsigned flags,
                           JSBool own, PropertyDescriptor *desc)
 {
     RootedObject obj2(cx);
     RootedShape shape(cx);
 
     if (!LookupPropertyById(cx, obj, id, flags, &obj2, &shape))
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -439,16 +439,19 @@ NewFunctionByIdWithReserved(JSContext *c
                             JSObject *parent, jsid id);
 
 JS_FRIEND_API(JSObject *)
 InitClassWithReserved(JSContext *cx, JSObject *obj, JSObject *parent_proto,
                       JSClass *clasp, JSNative constructor, unsigned nargs,
                       JSPropertySpec *ps, JSFunctionSpec *fs,
                       JSPropertySpec *static_ps, JSFunctionSpec *static_fs);
 
+JS_FRIEND_API(bool)
+DefineProperty(JSContext *cx, JSObject *obj, JSPropertySpec &ps);
+
 JS_FRIEND_API(const Value &)
 GetFunctionNativeReserved(RawObject fun, size_t which);
 
 JS_FRIEND_API(void)
 SetFunctionNativeReserved(RawObject fun, size_t which, const Value &val);
 
 inline bool
 GetObjectProto(JSContext *cx, JSObject *obj, JSObject **proto)
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -61,16 +61,21 @@ members = [
     # canvas friends
     'nsIDOMTextMetrics.*',
     'nsIDOMCanvasGradient.*',
     'nsIDOMCanvasPattern.*',
 
     # dom/interfaces/core
     'nsIDOMCharacterData.data',
     'nsIDOMCharacterData.length',
+    'nsIDOMDocument.onreadystatechange',
+    'nsIDOMDocument.onmouseenter',
+    'nsIDOMDocument.onmouseleave',
+    'nsIDOMElement.onmouseenter',
+    'nsIDOMElement.onmouseleave',
     'nsIDOMNamedNodeMap.item',
     'nsIDOMNamedNodeMap.length',
     'nsIDOMText.splitText',
     'nsIDOMDOMStringList.*',
     'nsIDOMXULDocument.getBoxObjectFor',
 
     # dom/interfaces/css
     'nsIDOMElementCSSInlineStyle.*',
@@ -379,16 +384,56 @@ customMethodCalls = {
         'thisType' : 'nsIDOMWindow',
         'unwrapThisFailureFatal' : False
         },
     'nsIDOMWindowPerformance_GetPerformance' : {
         'thisType': 'nsPIDOMWindow',
         'code' : '    nsPerformance* result = self->GetPerformance();\n',
         'canFail': False,
         },
+    'nsIDOMDocument_GetOnreadystatechange' : {
+        'thisType' : 'nsDocument',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMDocument_SetOnreadystatechange' : {
+        'thisType' : 'nsDocument',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMDocument_GetOnmouseenter' : {
+        'thisType' : 'nsDocument',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMDocument_SetOnmouseenter' : {
+        'thisType' : 'nsDocument',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMDocument_GetOnmouseleave' : {
+        'thisType' : 'nsDocument',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMDocument_SetOnmouseleave' : {
+        'thisType' : 'nsDocument',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMElement_GetOnmouseenter' : {
+        'thisType' : 'mozilla::dom::Element',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMElement_SetOnmouseenter' : {
+        'thisType' : 'mozilla::dom::Element',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMElement_GetOnmouseleave' : {
+        'thisType' : 'mozilla::dom::Element',
+        'unwrapThisFailureFatal' : False
+        },
+    'nsIDOMElement_SetOnmouseleave' : {
+        'thisType' : 'mozilla::dom::Element',
+        'unwrapThisFailureFatal' : False
+        },
     }
 
 newBindingProperties = {
     'nsIDOMNode': 'mozilla::dom::NodeBinding::sNativePropertyHooks.mNativeProperties.regular',
     'nsIDOMElement': 'mozilla::dom::ElementBinding::sNativePropertyHooks.mNativeProperties.regular',
     'nsIDOMHTMLElement': 'mozilla::dom::HTMLElementBinding::sNativePropertyHooks.mNativeProperties.regular',
     'nsIDOMDocument': 'mozilla::dom::DocumentBinding::sNativePropertyHooks.mNativeProperties.regular',
     'nsIDOMSVGElement': 'mozilla::dom::SVGElementBinding::sNativePropertyHooks.mNativeProperties.regular',