Bug 880041 (part 5) - Use JSObject::{is,as} for ElementIteratorObject. r=sfink.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 16 Jun 2013 17:24:34 -0700
changeset 135234 a9ad3842177c708592801f9d7b3ce2105b0c7e77
parent 135233 23c5c0ae167d95ee83208306105c1952a7400458
child 135235 5a5ff76c69ae8c2b0218dae4077213ec38e6763a
push id29584
push usernnethercote@mozilla.com
push dateMon, 17 Jun 2013 05:34:23 +0000
treeherdermozilla-inbound@90b688861270 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs880041
milestone24.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 880041 (part 5) - Use JSObject::{is,as} for ElementIteratorObject. r=sfink.
js/src/jsiter.cpp
js/src/jsiter.h
js/src/jsobj.h
--- a/js/src/jsiter.cpp
+++ b/js/src/jsiter.cpp
@@ -858,28 +858,28 @@ Class PropertyIteratorObject::class_ = {
 const uint32_t CLOSED_INDEX = UINT32_MAX;
 
 JSObject *
 ElementIteratorObject::create(JSContext *cx, Handle<Value> target)
 {
     RootedObject proto(cx, cx->global()->getOrCreateElementIteratorPrototype(cx));
     if (!proto)
         return NULL;
-    RootedObject iterobj(cx, NewObjectWithGivenProto(cx, &ElementIteratorClass, proto, cx->global()));
+    RootedObject iterobj(cx, NewObjectWithGivenProto(cx, &class_, proto, cx->global()));
     if (iterobj) {
         iterobj->setReservedSlot(TargetSlot, target);
         iterobj->setReservedSlot(IndexSlot, Int32Value(0));
     }
     return iterobj;
 }
 
 static bool
 IsElementIterator(const Value &v)
 {
-    return v.isObject() && v.toObject().isElementIterator();
+    return v.isObject() && v.toObject().is<ElementIteratorObject>();
 }
 
 JSBool
 ElementIteratorObject::next(JSContext *cx, unsigned argc, Value *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     return CallNonGenericMethod(cx, IsElementIterator, next_impl, args);
 }
@@ -929,17 +929,17 @@ ElementIteratorObject::next_impl(JSConte
   close:
     // Close the iterator. The TargetSlot will never be used again, so don't keep a
     // reference to it.
     iterobj->setReservedSlot(TargetSlot, UndefinedValue());
     iterobj->setReservedSlot(IndexSlot, Int32Value(int32_t(CLOSED_INDEX)));
     return false;
 }
 
-Class js::ElementIteratorClass = {
+Class ElementIteratorObject::class_ = {
     "Array Iterator",
     JSCLASS_IMPLEMENTS_BARRIERS |
     JSCLASS_HAS_RESERVED_SLOTS(ElementIteratorObject::NumSlots),
     JS_PropertyStub,         /* addProperty */
     JS_DeletePropertyStub,   /* delProperty */
     JS_PropertyStub,         /* getProperty */
     JS_StrictPropertyStub,   /* setProperty */
     JS_EnumerateStub,
@@ -1780,17 +1780,17 @@ GlobalObject::initIteratorClasses(JSCont
         if (!DefinePropertiesAndBrand(cx, iteratorProto, NULL, iterator_methods))
             return false;
         if (!DefineConstructorAndPrototype(cx, global, JSProto_Iterator, ctor, iteratorProto))
             return false;
     }
 
     RootedObject proto(cx);
     if (global->getSlot(ELEMENT_ITERATOR_PROTO).isUndefined()) {
-        Class *cls = &ElementIteratorClass;
+        Class *cls = &ElementIteratorObject::class_;
         proto = global->createBlankPrototypeInheriting(cx, cls, *iteratorProto);
         if (!proto || !DefinePropertiesAndBrand(cx, proto, NULL, ElementIteratorObject::methods))
             return false;
         global->setReservedSlot(ELEMENT_ITERATOR_PROTO, ObjectValue(*proto));
     }
 
 #if JS_HAS_GENERATORS
     if (global->getSlot(GENERATOR_PROTO).isUndefined()) {
--- a/js/src/jsiter.h
+++ b/js/src/jsiter.h
@@ -138,16 +138,18 @@ class PropertyIteratorObject : public JS
  *   }
  *
  * However they are not generators. They are a different class. The semantics
  * of Array iterators will be given in the eventual ES6 spec in full detail.
  */
 class ElementIteratorObject : public JSObject
 {
   public:
+    static Class class_;
+
     static JSObject *create(JSContext *cx, Handle<Value> target);
     static const JSFunctionSpec methods[];
 
     enum {
         TargetSlot,
         IndexSlot,
         NumSlots
     };
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -204,17 +204,16 @@ DeleteGeneric(JSContext *cx, HandleObjec
 } /* namespace js::baseops */
 
 extern Class ArrayClass;
 extern Class BlockClass;
 extern Class BooleanClass;
 extern Class CallableObjectClass;
 extern Class DateClass;
 extern Class ErrorClass;
-extern Class ElementIteratorClass;
 extern Class GeneratorClass;
 extern Class IntlClass;
 extern Class JSONClass;
 extern Class MapIteratorClass;
 extern Class MathClass;
 extern Class NumberClass;
 extern Class ObjectClass;
 extern Class ProxyClass;
@@ -228,17 +227,16 @@ extern Class WeakMapClass;
 extern Class WithClass;
 
 class ArrayBufferObject;
 class BlockObject;
 class BooleanObject;
 class ClonedBlockObject;
 class DebugScopeObject;
 class DeclEnvObject;
-class ElementIteratorObject;
 class GlobalObject;
 class MapObject;
 class MapIteratorObject;
 class NestedScopeObject;
 class NewObjectCache;
 class NormalArgumentsObject;
 class NumberObject;
 class PropertyIteratorObject;
@@ -972,17 +970,16 @@ class JSObject : public js::ObjectImpl
     const T &as() const {
         JS_ASSERT(is<T>());
         return *static_cast<const T *>(this);
     }
 
     /* Direct subtypes of JSObject: */
     inline bool isArray()            const { return hasClass(&js::ArrayClass); }
     inline bool isDate()             const { return hasClass(&js::DateClass); }
-    inline bool isElementIterator()  const { return hasClass(&js::ElementIteratorClass); }
     inline bool isError()            const { return hasClass(&js::ErrorClass); }
     inline bool isFunction()         const { return hasClass(&js::FunctionClass); }
     inline bool isGenerator()        const { return hasClass(&js::GeneratorClass); }
     inline bool isGlobal()           const;
     inline bool isMapIterator()      const { return hasClass(&js::MapIteratorClass); }
     inline bool isObject()           const { return hasClass(&js::ObjectClass); }
     inline bool isPrimitive()        const { return isNumber() || isString() || isBoolean(); }
     inline bool isPropertyIterator() const;