Bug 962449 - Don't call initIteratorClasses directly, and use ensureConstructor. r=luke
authorBobby Holley <bobbyholley@gmail.com>
Fri, 31 Jan 2014 14:51:41 -0800
changeset 166310 8c206e77eb64ed7671ced59ddf599c4af79351ed
parent 166309 91e3fce5bb56dfa4096dab66cb0288da07f82ef8
child 166311 290a8f35944160917f1fb03a19bb7e09ac5f5667
push id39174
push userbobbyholley@gmail.com
push dateFri, 31 Jan 2014 22:51:52 +0000
treeherdermozilla-inbound@290a8f359441 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs962449
milestone29.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 962449 - Don't call initIteratorClasses directly, and use ensureConstructor. r=luke This isn't strictly necessary at this point. The basic issue is that there are a few new classes (iterator stuff, intl stuff, and typed objects) that use this kind of constructor bootstrap scheme, and each of them will need something like this to move to ClassSpecs. But that doesn't actually need to happen until we convert them. I wrote this patch before I realized this, and I believe it's correct, so I figured I'd get it landed along with everything. But I'm also ok to skip it for now.
js/src/vm/GlobalObject.h
--- a/js/src/vm/GlobalObject.h
+++ b/js/src/vm/GlobalObject.h
@@ -469,44 +469,55 @@ class GlobalObject : public JSObject
         AutoThreadSafeAccess ts(this);
         if (slot < fixed)
             return fixedSlots()[slot];
         return slots[slot - fixed];
     }
 
   public:
     JSObject *getOrCreateIteratorPrototype(JSContext *cx) {
-        return getOrCreateObject(cx, APPLICATION_SLOTS + JSProto_LIMIT + JSProto_Iterator,
-                                 initIteratorClasses);
+        if (!ensureConstructor(cx, JSProto_Iterator))
+            return nullptr;
+        return &getSlot(APPLICATION_SLOTS + JSProto_LIMIT + JSProto_Iterator).toObject();
     }
 
     JSObject *getOrCreateArrayIteratorPrototype(JSContext *cx) {
-        return getOrCreateObject(cx, ARRAY_ITERATOR_PROTO, initIteratorClasses);
+        if (!ensureConstructor(cx, JSProto_Iterator))
+            return nullptr;
+        return &getSlot(ARRAY_ITERATOR_PROTO).toObject();
     }
 
     JSObject *getOrCreateStringIteratorPrototype(JSContext *cx) {
-        return getOrCreateObject(cx, STRING_ITERATOR_PROTO, initIteratorClasses);
+        if (!ensureConstructor(cx, JSProto_Iterator))
+            return nullptr;
+        return &getSlot(STRING_ITERATOR_PROTO).toObject();
     }
 
     JSObject *getOrCreateLegacyGeneratorObjectPrototype(JSContext *cx) {
-        return getOrCreateObject(cx, LEGACY_GENERATOR_OBJECT_PROTO, initIteratorClasses);
+        if (!ensureConstructor(cx, JSProto_Iterator))
+            return nullptr;
+        return &getSlot(LEGACY_GENERATOR_OBJECT_PROTO).toObject();
     }
 
     JSObject *getOrCreateStarGeneratorObjectPrototype(JSContext *cx) {
-        return getOrCreateObject(cx, STAR_GENERATOR_OBJECT_PROTO, initIteratorClasses);
+        if (!ensureConstructor(cx, JSProto_Iterator))
+            return nullptr;
+        return &getSlot(STAR_GENERATOR_OBJECT_PROTO).toObject();
     }
 
     JSObject *getOrCreateStarGeneratorFunctionPrototype(JSContext *cx) {
-        return getOrCreateObject(cx, APPLICATION_SLOTS + JSProto_LIMIT + JSProto_GeneratorFunction,
-                                 initIteratorClasses);
+        if (!ensureConstructor(cx, JSProto_Iterator))
+            return nullptr;
+        return &getSlot(APPLICATION_SLOTS + JSProto_LIMIT + JSProto_GeneratorFunction).toObject();
     }
 
     JSObject *getOrCreateStarGeneratorFunction(JSContext *cx) {
-        return getOrCreateObject(cx, APPLICATION_SLOTS + JSProto_GeneratorFunction,
-                                 initIteratorClasses);
+        if (!ensureConstructor(cx, JSProto_Iterator))
+            return nullptr;
+        return &getSlot(APPLICATION_SLOTS + JSProto_GeneratorFunction).toObject();
     }
 
     JSObject *getOrCreateMapIteratorPrototype(JSContext *cx) {
         return getOrCreateObject(cx, MAP_ITERATOR_PROTO, initMapIteratorProto);
     }
 
     JSObject *getOrCreateSetIteratorPrototype(JSContext *cx) {
         return getOrCreateObject(cx, SET_ITERATOR_PROTO, initSetIteratorProto);