Bug 932320 - Use JS_DefineProperty for replaceable properties. r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Tue, 08 Oct 2013 17:51:03 +0200
changeset 153019 392ee11b1ff6467d055ea5cf69d86bb54f2302eb
parent 153018 e790b3c30e1a62e05079cd99c5caa002218d87b6
child 153020 e697e7dcc32113e0207be62e7cf78ed218f9fc28
push id25566
push userryanvm@gmail.com
push dateFri, 01 Nov 2013 18:40:05 +0000
treeherdermozilla-central@5bb07c1ae9f5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs932320
milestone28.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 932320 - Use JS_DefineProperty for replaceable properties. r=bz.
dom/bindings/Codegen.py
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -5896,28 +5896,19 @@ class CGSpecializedReplaceableSetter(CGS
     A class for generating the code for a specialized attribute setter with
     Replaceable that the JIT can call with lower overhead.
     """
     def __init__(self, descriptor, attr):
         CGSpecializedSetter.__init__(self, descriptor, attr)
 
     def definition_body(self):
         attrName = self.attr.identifier.name
-        return CGIndenter(CGGeneric("""JS::Rooted<JSPropertyDescriptor> desc(cx);
-desc.object().set(obj);
-desc.setEnumerable();
-desc.value().set(args[0]);
-
-JS::Rooted<jsid> id(cx);
-if (!InternJSString(cx, id.get(), "%s")) {
-  return false;
-}
-
-bool b;
-return js_DefineOwnProperty(cx, obj, id, desc, &b);""" % attrName)).define()
+        # JS_DefineProperty can only deal with ASCII
+        assert all(ord(c) < 128 for c in attrName)
+        return CGIndenter(CGGeneric("""return JS_DefineProperty(cx, obj, "%s", args[0], nullptr, nullptr, JSPROP_ENUMERATE);""" % attrName)).define()
 
 def memberReturnsNewObject(member):
     return member.getExtendedAttribute("NewObject") is not None
 
 class CGMemberJITInfo(CGThing):
     """
     A class for generating the JITInfo for a property that points to
     our specialized getter and setter.