Bug 973238 Part 9 -- Move kind to `type` namespace, insert some const qualifiers r=sfink
authorNicholas D. Matsakis <nmatsakis@mozilla.com>
Wed, 26 Mar 2014 20:16:00 -0400
changeset 187391 731411eebd0ada53b7d7a6329dde5bd5f7be3019
parent 187390 880fd861075fb7d434080053bd5863dc1fe5a720
child 187392 0ea62f66f109388f7ba55ccdf7953ef95ac61629
push id7176
push userryanvm@gmail.com
push dateSat, 07 Jun 2014 18:15:31 +0000
treeherderfx-team@a2f0e0619332 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs973238
milestone32.0a1
Bug 973238 Part 9 -- Move kind to `type` namespace, insert some const qualifiers r=sfink
CLOBBER
js/src/builtin/SIMD.cpp
js/src/builtin/TypedObject.cpp
js/src/builtin/TypedObject.h
js/src/jit/IonBuilder.cpp
js/src/jit/MCallOptimize.cpp
js/src/jit/TypeDescrSet.cpp
js/src/jit/TypeDescrSet.h
--- a/CLOBBER
+++ b/CLOBBER
@@ -17,9 +17,9 @@
 #
 # Modifying this file will now automatically clobber the buildbot machines \o/
 #
 
 # Are you updating CLOBBER because you think it's needed for your WebIDL
 # changes to stick? As of bug 928195, this shouldn't be necessary! Please
 # don't change CLOBBER for WebIDL changes any more.
 
-Bug 973238 part 8 needs clobber due to self-hosted code (bug 1019955).
+Bug 973238 part 9 needs clobber due to self-hosted code (bug 1019955).
--- a/js/src/builtin/SIMD.cpp
+++ b/js/src/builtin/SIMD.cpp
@@ -46,17 +46,17 @@ static bool GetX4Lane(JSContext *cx, uns
         JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
                              X4TypeDescr::class_.name, laneNames[lane],
                              InformalValueTypeName(args.thisv()));
         return false;
     }
 
     TypedObject &typedObj = args.thisv().toObject().as<TypedObject>();
     TypeDescr &descr = typedObj.typeDescr();
-    if (descr.kind() != TypeDescr::X4 || descr.as<X4TypeDescr>().type() != Type32x4::type) {
+    if (descr.kind() != type::X4 || descr.as<X4TypeDescr>().type() != Type32x4::type) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
                              X4TypeDescr::class_.name, laneNames[lane],
                              InformalValueTypeName(args.thisv()));
         return false;
     }
 
     MOZ_ASSERT(!typedObj.owner().isNeutered());
     Elem *data = reinterpret_cast<Elem *>(typedObj.typedMem());
@@ -89,17 +89,17 @@ static bool SignMask(JSContext *cx, unsi
         JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
                              X4TypeDescr::class_.name, "signMask",
                              InformalValueTypeName(args.thisv()));
         return false;
     }
 
     TypedObject &typedObj = args.thisv().toObject().as<TypedObject>();
     TypeDescr &descr = typedObj.typeDescr();
-    if (descr.kind() != TypeDescr::X4 || descr.as<X4TypeDescr>().type() != Type32x4::type) {
+    if (descr.kind() != type::X4 || descr.as<X4TypeDescr>().type() != Type32x4::type) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
                              X4TypeDescr::class_.name, "signMask",
                              InformalValueTypeName(args.thisv()));
         return false;
     }
 
     MOZ_ASSERT(!typedObj.owner().isNeutered());
     Elem *data = reinterpret_cast<Elem *>(typedObj.typedMem());
@@ -211,17 +211,17 @@ CreateX4Class(JSContext *cx,
 
     // Create type constructor itself and initialize its reserved slots.
 
     Rooted<X4TypeDescr*> x4(cx);
     x4 = NewObjectWithProto<X4TypeDescr>(cx, funcProto, global, TenuredObject);
     if (!x4)
         return nullptr;
 
-    x4->initReservedSlot(JS_DESCR_SLOT_KIND, Int32Value(TypeDescr::X4));
+    x4->initReservedSlot(JS_DESCR_SLOT_KIND, Int32Value(type::X4));
     x4->initReservedSlot(JS_DESCR_SLOT_STRING_REPR, StringValue(stringRepr));
     x4->initReservedSlot(JS_DESCR_SLOT_ALIGNMENT, Int32Value(X4TypeDescr::size(type)));
     x4->initReservedSlot(JS_DESCR_SLOT_SIZE, Int32Value(X4TypeDescr::alignment(type)));
     x4->initReservedSlot(JS_DESCR_SLOT_OPAQUE, BooleanValue(false));
     x4->initReservedSlot(JS_DESCR_SLOT_TYPE, Int32Value(T::type));
 
     if (!CreateUserSizeAndAlignmentProperties(cx, x4))
         return nullptr;
@@ -394,17 +394,17 @@ IsVectorObject(HandleValue v)
     if (!v.isObject())
         return false;
 
     JSObject &obj = v.toObject();
     if (!obj.is<TypedObject>())
         return false;
 
     TypeDescr &typeRepr = obj.as<TypedObject>().typeDescr();
-    if (typeRepr.kind() != TypeDescr::X4)
+    if (typeRepr.kind() != type::X4)
         return false;
 
     return typeRepr.as<X4TypeDescr>().type() == V::type;
 }
 
 template<typename Elem>
 static Elem
 TypedObjectMemory(HandleValue v)
--- a/js/src/builtin/TypedObject.cpp
+++ b/js/src/builtin/TypedObject.cpp
@@ -1010,17 +1010,17 @@ StructMetaTypeDescr::create(JSContext *c
         return nullptr;
 
     Rooted<StructTypeDescr*> descr(cx);
     descr = NewObjectWithProto<StructTypeDescr>(cx, structTypePrototype, nullptr,
                                                 TenuredObject);
     if (!descr)
         return nullptr;
 
-    descr->initReservedSlot(JS_DESCR_SLOT_KIND, Int32Value(TypeDescr::Struct));
+    descr->initReservedSlot(JS_DESCR_SLOT_KIND, Int32Value(type::Struct));
     descr->initReservedSlot(JS_DESCR_SLOT_STRING_REPR, StringValue(stringRepr));
     descr->initReservedSlot(JS_DESCR_SLOT_ALIGNMENT, Int32Value(alignment));
     descr->initReservedSlot(JS_DESCR_SLOT_SIZE, Int32Value(totalSize.value()));
     descr->initReservedSlot(JS_DESCR_SLOT_OPAQUE, BooleanValue(opaque));
 
     // Construct for internal use an array with the name for each field.
     {
         RootedObject fieldNamesVec(cx);
@@ -1115,54 +1115,54 @@ StructMetaTypeDescr::construct(JSContext
     }
 
     JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
                          JSMSG_TYPEDOBJECT_STRUCTTYPE_BAD_ARGS);
     return false;
 }
 
 size_t
-StructTypeDescr::fieldCount()
+StructTypeDescr::fieldCount() const
 {
     return getReservedSlot(JS_DESCR_SLOT_STRUCT_FIELD_NAMES).toObject().getDenseInitializedLength();
 }
 
 bool
-StructTypeDescr::fieldIndex(jsid id, size_t *out)
+StructTypeDescr::fieldIndex(jsid id, size_t *out) const
 {
     JSObject &fieldNames = getReservedSlot(JS_DESCR_SLOT_STRUCT_FIELD_NAMES).toObject();
     size_t l = fieldNames.getDenseInitializedLength();
     for (size_t i = 0; i < l; i++) {
         JSAtom &a = fieldNames.getDenseElement(i).toString()->asAtom();
         if (JSID_IS_ATOM(id, &a)) {
             *out = i;
             return true;
         }
     }
     return false;
 }
 
 JSAtom &
-StructTypeDescr::fieldName(size_t index)
+StructTypeDescr::fieldName(size_t index) const
 {
     JSObject &fieldNames = getReservedSlot(JS_DESCR_SLOT_STRUCT_FIELD_NAMES).toObject();
     return fieldNames.getDenseElement(index).toString()->asAtom();
 }
 
 int32_t
-StructTypeDescr::fieldOffset(size_t index)
+StructTypeDescr::fieldOffset(size_t index) const
 {
     JSObject &fieldOffsets =
         getReservedSlot(JS_DESCR_SLOT_STRUCT_FIELD_OFFSETS).toObject();
     JS_ASSERT(index < fieldOffsets.getDenseInitializedLength());
     return fieldOffsets.getDenseElement(index).toInt32();
 }
 
 SizedTypeDescr&
-StructTypeDescr::fieldDescr(size_t index)
+StructTypeDescr::fieldDescr(size_t index) const
 {
     JSObject &fieldDescrs =
         getReservedSlot(JS_DESCR_SLOT_STRUCT_FIELD_TYPES).toObject();
     JS_ASSERT(index < fieldDescrs.getDenseInitializedLength());
     return fieldDescrs.getDenseElement(index).toObject().as<SizedTypeDescr>();
 }
 
 /******************************************************************************
@@ -1508,26 +1508,26 @@ TypedObject::attach(TypedObject &typedOb
 }
 
 // Returns a suitable JS_TYPEDOBJ_SLOT_LENGTH value for an instance of
 // the type `type`. `type` must not be an unsized array.
 static int32_t
 TypedObjLengthFromType(TypeDescr &descr)
 {
     switch (descr.kind()) {
-      case TypeDescr::Scalar:
-      case TypeDescr::Reference:
-      case TypeDescr::Struct:
-      case TypeDescr::X4:
+      case type::Scalar:
+      case type::Reference:
+      case type::Struct:
+      case type::X4:
         return 0;
 
-      case TypeDescr::SizedArray:
+      case type::SizedArray:
         return descr.as<SizedArrayTypeDescr>().length();
 
-      case TypeDescr::UnsizedArray:
+      case type::UnsizedArray:
         MOZ_ASSUME_UNREACHABLE("TypedObjLengthFromType() invoked on unsized type");
     }
     MOZ_ASSUME_UNREACHABLE("Invalid kind");
 }
 
 /*static*/ TypedObject *
 TypedObject::createDerived(JSContext *cx, HandleSizedTypeDescr type,
                            HandleTypedObject typedObj, int32_t offset)
@@ -1557,33 +1557,33 @@ TypedObject::createZeroed(JSContext *cx,
     // Create unattached wrapper object.
     Rooted<TypedObject*> obj(cx, createUnattached(cx, descr, length));
     if (!obj)
         return nullptr;
 
     // Allocate and initialize the memory for this instance.
     // Also initialize the JS_TYPEDOBJ_SLOT_LENGTH slot.
     switch (descr->kind()) {
-      case TypeDescr::Scalar:
-      case TypeDescr::Reference:
-      case TypeDescr::Struct:
-      case TypeDescr::X4:
-      case TypeDescr::SizedArray:
+      case type::Scalar:
+      case type::Reference:
+      case type::Struct:
+      case type::X4:
+      case type::SizedArray:
       {
         size_t totalSize = descr->as<SizedTypeDescr>().size();
         Rooted<ArrayBufferObject*> buffer(cx);
         buffer = ArrayBufferObject::create(cx, totalSize);
         if (!buffer)
             return nullptr;
         descr->as<SizedTypeDescr>().initInstances(cx->runtime(), buffer->dataPointer(), 1);
         obj->attach(*buffer, 0);
         return obj;
       }
 
-      case TypeDescr::UnsizedArray:
+      case type::UnsizedArray:
       {
         Rooted<SizedTypeDescr*> elementTypeRepr(cx);
         elementTypeRepr = &descr->as<UnsizedArrayTypeDescr>().elementType();
 
         CheckedInt32 totalSize = CheckedInt32(elementTypeRepr->size()) * length;
         if (!totalSize.isValid()) {
             JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr,
                                  JSMSG_TYPEDOBJECT_TOO_BIG);
@@ -1634,60 +1634,60 @@ TypedObject::obj_trace(JSTracer *trace, 
         uint8_t *mem = typedObj.typedMem();
         if (!mem)
             return; // partially constructed
 
         if (typedObj.owner().isNeutered())
             return;
 
         switch (descr.kind()) {
-          case TypeDescr::Scalar:
-          case TypeDescr::Reference:
-          case TypeDescr::Struct:
-          case TypeDescr::SizedArray:
-          case TypeDescr::X4:
+          case type::Scalar:
+          case type::Reference:
+          case type::Struct:
+          case type::SizedArray:
+          case type::X4:
             descr.as<SizedTypeDescr>().traceInstances(trace, mem, 1);
             break;
 
-          case TypeDescr::UnsizedArray:
+          case type::UnsizedArray:
             descr.as<UnsizedArrayTypeDescr>().elementType().traceInstances(trace, mem, typedObj.length());
             break;
         }
     }
 }
 
 bool
 TypedObject::obj_lookupGeneric(JSContext *cx, HandleObject obj, HandleId id,
                               MutableHandleObject objp, MutableHandleShape propp)
 {
     JS_ASSERT(obj->is<TypedObject>());
 
     Rooted<TypeDescr*> descr(cx, &obj->as<TypedObject>().typeDescr());
     switch (descr->kind()) {
-      case TypeDescr::Scalar:
-      case TypeDescr::Reference:
-      case TypeDescr::X4:
+      case type::Scalar:
+      case type::Reference:
+      case type::X4:
         break;
 
-      case TypeDescr::SizedArray:
-      case TypeDescr::UnsizedArray:
+      case type::SizedArray:
+      case type::UnsizedArray:
       {
         uint32_t index;
         if (js_IdIsIndex(id, &index))
             return obj_lookupElement(cx, obj, index, objp, propp);
 
         if (JSID_IS_ATOM(id, cx->names().length)) {
             MarkNonNativePropertyFound(propp);
             objp.set(obj);
             return true;
         }
         break;
       }
 
-      case TypeDescr::Struct:
+      case type::Struct:
       {
         StructTypeDescr &structDescr = descr->as<StructTypeDescr>();
         size_t index;
         if (structDescr.fieldIndex(id, &index)) {
             MarkNonNativePropertyFound(propp);
             objp.set(obj);
             return true;
         }
@@ -1783,39 +1783,39 @@ TypedObject::obj_getGeneric(JSContext *c
     // Dispatch elements to obj_getElement:
     uint32_t index;
     if (js_IdIsIndex(id, &index))
         return obj_getElement(cx, obj, receiver, index, vp);
 
     // Handle everything else here:
 
     switch (typedObj->typeDescr().kind()) {
-      case TypeDescr::Scalar:
-      case TypeDescr::Reference:
+      case type::Scalar:
+      case type::Reference:
         break;
 
-      case TypeDescr::X4:
+      case type::X4:
         break;
 
-      case TypeDescr::SizedArray:
-      case TypeDescr::UnsizedArray:
+      case type::SizedArray:
+      case type::UnsizedArray:
         if (JSID_IS_ATOM(id, cx->names().length)) {
             if (typedObj->owner().isNeutered() || !typedObj->typedMem()) { // unattached
                 JS_ReportErrorNumber(
                     cx, js_GetErrorMessage,
                     nullptr, JSMSG_TYPEDOBJECT_HANDLE_UNATTACHED);
                 return false;
             }
 
             vp.setInt32(typedObj->length());
             return true;
         }
         break;
 
-      case TypeDescr::Struct: {
+      case type::Struct: {
         Rooted<StructTypeDescr*> descr(cx, &typedObj->typeDescr().as<StructTypeDescr>());
 
         size_t fieldIndex;
         if (!descr->fieldIndex(id, &fieldIndex))
             break;
 
         size_t offset = descr->fieldOffset(fieldIndex);
         Rooted<SizedTypeDescr*> fieldType(cx, &descr->fieldDescr(fieldIndex));
@@ -1844,27 +1844,27 @@ bool
 TypedObject::obj_getElement(JSContext *cx, HandleObject obj, HandleObject receiver,
                              uint32_t index, MutableHandleValue vp)
 {
     JS_ASSERT(obj->is<TypedObject>());
     Rooted<TypedObject *> typedObj(cx, &obj->as<TypedObject>());
     Rooted<TypeDescr *> descr(cx, &typedObj->typeDescr());
 
     switch (descr->kind()) {
-      case TypeDescr::Scalar:
-      case TypeDescr::Reference:
-      case TypeDescr::X4:
-      case TypeDescr::Struct:
+      case type::Scalar:
+      case type::Reference:
+      case type::X4:
+      case type::Struct:
         break;
 
-      case TypeDescr::SizedArray:
+      case type::SizedArray:
         return obj_getArrayElement<SizedArrayTypeDescr>(cx, typedObj, descr,
                                                         index, vp);
 
-      case TypeDescr::UnsizedArray:
+      case type::UnsizedArray:
         return obj_getArrayElement<UnsizedArrayTypeDescr>(cx, typedObj, descr,
                                                           index, vp);
     }
 
     RootedObject proto(cx, obj->getProto());
     if (!proto) {
         vp.setUndefined();
         return true;
@@ -1900,33 +1900,33 @@ TypedObject::obj_setGeneric(JSContext *c
     JS_ASSERT(obj->is<TypedObject>());
     Rooted<TypedObject *> typedObj(cx, &obj->as<TypedObject>());
 
     uint32_t index;
     if (js_IdIsIndex(id, &index))
         return obj_setElement(cx, obj, index, vp, strict);
 
     switch (typedObj->typeDescr().kind()) {
-      case ScalarTypeDescr::Scalar:
-      case TypeDescr::Reference:
+      case type::Scalar:
+      case type::Reference:
         break;
 
-      case ScalarTypeDescr::X4:
+      case type::X4:
         break;
 
-      case ScalarTypeDescr::SizedArray:
-      case ScalarTypeDescr::UnsizedArray:
+      case type::SizedArray:
+      case type::UnsizedArray:
         if (JSID_IS_ATOM(id, cx->names().length)) {
             JS_ReportErrorNumber(cx, js_GetErrorMessage,
                                  nullptr, JSMSG_CANT_REDEFINE_ARRAY_LENGTH);
             return false;
         }
         break;
 
-      case ScalarTypeDescr::Struct: {
+      case type::Struct: {
         Rooted<StructTypeDescr*> descr(cx, &typedObj->typeDescr().as<StructTypeDescr>());
 
         size_t fieldIndex;
         if (!descr->fieldIndex(id, &fieldIndex))
             break;
 
         size_t offset = descr->fieldOffset(fieldIndex);
         Rooted<SizedTypeDescr*> fieldType(cx, &descr->fieldDescr(fieldIndex));
@@ -1950,26 +1950,26 @@ bool
 TypedObject::obj_setElement(JSContext *cx, HandleObject obj, uint32_t index,
                            MutableHandleValue vp, bool strict)
 {
     JS_ASSERT(obj->is<TypedObject>());
     Rooted<TypedObject *> typedObj(cx, &obj->as<TypedObject>());
     Rooted<TypeDescr *> descr(cx, &typedObj->typeDescr());
 
     switch (descr->kind()) {
-      case TypeDescr::Scalar:
-      case TypeDescr::Reference:
-      case TypeDescr::X4:
-      case TypeDescr::Struct:
+      case type::Scalar:
+      case type::Reference:
+      case type::X4:
+      case type::Struct:
         break;
 
-      case TypeDescr::SizedArray:
+      case type::SizedArray:
         return obj_setArrayElement<SizedArrayTypeDescr>(cx, typedObj, descr, index, vp);
 
-      case TypeDescr::UnsizedArray:
+      case type::UnsizedArray:
         return obj_setArrayElement<UnsizedArrayTypeDescr>(cx, typedObj, descr, index, vp);
     }
 
     return ReportTypedObjTypeError(cx, JSMSG_OBJECT_NOT_EXTENSIBLE, typedObj);
 }
 
 template<class T>
 /*static*/ bool
@@ -1995,36 +1995,36 @@ TypedObject::obj_setArrayElement(JSConte
 
 bool
 TypedObject::obj_getGenericAttributes(JSContext *cx, HandleObject obj,
                                      HandleId id, unsigned *attrsp)
 {
     uint32_t index;
     Rooted<TypedObject *> typedObj(cx, &obj->as<TypedObject>());
     switch (typedObj->typeDescr().kind()) {
-      case TypeDescr::Scalar:
-      case TypeDescr::Reference:
+      case type::Scalar:
+      case type::Reference:
         break;
 
-      case TypeDescr::X4:
+      case type::X4:
         break;
 
-      case TypeDescr::SizedArray:
-      case TypeDescr::UnsizedArray:
+      case type::SizedArray:
+      case type::UnsizedArray:
         if (js_IdIsIndex(id, &index)) {
             *attrsp = JSPROP_ENUMERATE | JSPROP_PERMANENT;
             return true;
         }
         if (JSID_IS_ATOM(id, cx->names().length)) {
             *attrsp = JSPROP_READONLY | JSPROP_PERMANENT;
             return true;
         }
         break;
 
-      case TypeDescr::Struct:
+      case type::Struct:
         size_t index;
         if (typedObj->typeDescr().as<StructTypeDescr>().fieldIndex(id, &index)) {
             *attrsp = JSPROP_ENUMERATE | JSPROP_PERMANENT;
             return true;
         }
         break;
     }
 
@@ -2038,26 +2038,26 @@ TypedObject::obj_getGenericAttributes(JS
 }
 
 static bool
 IsOwnId(JSContext *cx, HandleObject obj, HandleId id)
 {
     uint32_t index;
     Rooted<TypedObject *> typedObj(cx, &obj->as<TypedObject>());
     switch (typedObj->typeDescr().kind()) {
-      case TypeDescr::Scalar:
-      case TypeDescr::Reference:
-      case TypeDescr::X4:
+      case type::Scalar:
+      case type::Reference:
+      case type::X4:
         return false;
 
-      case TypeDescr::SizedArray:
-      case TypeDescr::UnsizedArray:
+      case type::SizedArray:
+      case type::UnsizedArray:
         return js_IdIsIndex(id, &index) || JSID_IS_ATOM(id, cx->names().length);
 
-      case TypeDescr::Struct:
+      case type::Struct:
         size_t index;
         if (typedObj->typeDescr().as<StructTypeDescr>().fieldIndex(id, &index))
             return true;
     }
 
     return false;
 }
 
@@ -2097,34 +2097,34 @@ TypedObject::obj_enumerate(JSContext *cx
                            MutableHandleValue statep, MutableHandleId idp)
 {
     int32_t index;
 
     JS_ASSERT(obj->is<TypedObject>());
     Rooted<TypedObject *> typedObj(cx, &obj->as<TypedObject>());
     Rooted<TypeDescr *> descr(cx, &typedObj->typeDescr());
     switch (descr->kind()) {
-      case TypeDescr::Scalar:
-      case TypeDescr::Reference:
-      case TypeDescr::X4:
+      case type::Scalar:
+      case type::Reference:
+      case type::X4:
         switch (enum_op) {
           case JSENUMERATE_INIT_ALL:
           case JSENUMERATE_INIT:
             statep.setInt32(0);
             idp.set(INT_TO_JSID(0));
 
           case JSENUMERATE_NEXT:
           case JSENUMERATE_DESTROY:
             statep.setNull();
             break;
         }
         break;
 
-      case TypeDescr::SizedArray:
-      case TypeDescr::UnsizedArray:
+      case type::SizedArray:
+      case type::UnsizedArray:
         switch (enum_op) {
           case JSENUMERATE_INIT_ALL:
           case JSENUMERATE_INIT:
             statep.setInt32(0);
             idp.set(INT_TO_JSID(typedObj->length()));
             break;
 
           case JSENUMERATE_NEXT:
@@ -2141,17 +2141,17 @@ TypedObject::obj_enumerate(JSContext *cx
             break;
 
           case JSENUMERATE_DESTROY:
             statep.setNull();
             break;
         }
         break;
 
-      case TypeDescr::Struct:
+      case type::Struct:
         switch (enum_op) {
           case JSENUMERATE_INIT_ALL:
           case JSENUMERATE_INIT:
             statep.setInt32(0);
             idp.set(INT_TO_JSID(descr->as<StructTypeDescr>().fieldCount()));
             break;
 
           case JSENUMERATE_NEXT:
@@ -2257,26 +2257,26 @@ const Class TransparentTypedObject::clas
         nullptr, /* thisObject */
     }
 };
 
 static int32_t
 LengthForType(TypeDescr &descr)
 {
     switch (descr.kind()) {
-      case TypeDescr::Scalar:
-      case TypeDescr::Reference:
-      case TypeDescr::Struct:
-      case TypeDescr::X4:
+      case type::Scalar:
+      case type::Reference:
+      case type::Struct:
+      case type::X4:
         return 0;
 
-      case TypeDescr::SizedArray:
+      case type::SizedArray:
         return descr.as<SizedArrayTypeDescr>().length();
 
-      case TypeDescr::UnsizedArray:
+      case type::UnsizedArray:
         return 0;
     }
 
     MOZ_ASSUME_UNREACHABLE("Invalid kind");
 }
 
 static bool
 CheckOffset(int32_t offset,
@@ -3075,41 +3075,41 @@ static void
 visitReferences(SizedTypeDescr &descr,
                 uint8_t *mem,
                 V& visitor)
 {
     if (descr.transparent())
         return;
 
     switch (descr.kind()) {
-      case TypeDescr::Scalar:
-      case TypeDescr::X4:
+      case type::Scalar:
+      case type::X4:
         return;
 
-      case TypeDescr::Reference:
+      case type::Reference:
         visitor.visitReference(descr.as<ReferenceTypeDescr>(), mem);
         return;
 
-      case TypeDescr::SizedArray:
+      case type::SizedArray:
       {
         SizedArrayTypeDescr &arrayDescr = descr.as<SizedArrayTypeDescr>();
         SizedTypeDescr &elementDescr = arrayDescr.elementType();
         for (int32_t i = 0; i < arrayDescr.length(); i++) {
             visitReferences(elementDescr, mem, visitor);
             mem += elementDescr.size();
         }
         return;
       }
 
-      case TypeDescr::UnsizedArray:
+      case type::UnsizedArray:
       {
         MOZ_ASSUME_UNREACHABLE("Only Sized Type representations");
       }
 
-      case TypeDescr::Struct:
+      case type::Struct:
       {
         StructTypeDescr &structDescr = descr.as<StructTypeDescr>();
         for (size_t i = 0; i < structDescr.fieldCount(); i++) {
             SizedTypeDescr &descr = structDescr.fieldDescr(i);
             size_t offset = structDescr.fieldOffset(i);
             visitReferences(descr, mem + offset, visitor);
         }
         return;
--- a/js/src/builtin/TypedObject.h
+++ b/js/src/builtin/TypedObject.h
@@ -121,16 +121,43 @@ static T ConvertScalar(double d)
         uint32_t n = ToUint32(d);
         return T(n);
     } else {
         int32_t n = ToInt32(d);
         return T(n);
     }
 }
 
+namespace type {
+
+enum Kind {
+    Scalar = JS_TYPEREPR_SCALAR_KIND,
+    Reference = JS_TYPEREPR_REFERENCE_KIND,
+    X4 = JS_TYPEREPR_X4_KIND,
+    Struct = JS_TYPEREPR_STRUCT_KIND,
+    SizedArray = JS_TYPEREPR_SIZED_ARRAY_KIND,
+    UnsizedArray = JS_TYPEREPR_UNSIZED_ARRAY_KIND,
+};
+
+static inline bool isSized(type::Kind kind) {
+    return kind > JS_TYPEREPR_MAX_UNSIZED_KIND;
+}
+
+}
+
+///////////////////////////////////////////////////////////////////////////
+// Typed Prototypes
+
+class SizedTypeDescr;
+class SimpleTypeDescr;
+class ComplexTypeDescr;
+class X4TypeDescr;
+class StructTypeDescr;
+class SizedTypedProto;
+
 /*
  * The prototype for a typed object. Currently, carries a link to the
  * type descriptor. Eventually will carry most of the type information
  * we want.
  */
 class TypedProto : public JSObject
 {
   public:
@@ -149,56 +176,52 @@ class TypeDescr : public JSObject
     // This is *intentionally* not defined so as to produce link
     // errors if a is<FooTypeDescr>() etc goes wrong. Otherwise, the
     // default implementation resolves this to a reference to
     // FooTypeDescr::class_ which resolves to
     // JSObject::class_. Debugging the resulting errors leads to much
     // fun and rejoicing.
     static const Class class_;
 
-    enum Kind {
-        Scalar = JS_TYPEREPR_SCALAR_KIND,
-        Reference = JS_TYPEREPR_REFERENCE_KIND,
-        X4 = JS_TYPEREPR_X4_KIND,
-        Struct = JS_TYPEREPR_STRUCT_KIND,
-        SizedArray = JS_TYPEREPR_SIZED_ARRAY_KIND,
-        UnsizedArray = JS_TYPEREPR_UNSIZED_ARRAY_KIND,
-    };
+  public:
+    static bool isSized(type::Kind kind) {
+        return kind > JS_TYPEREPR_MAX_UNSIZED_KIND;
+    }
 
-    static bool isSized(Kind kind) {
-        return kind > JS_TYPEREPR_MAX_UNSIZED_KIND;
+    TypedProto &typedProto() const {
+        return getReservedSlot(JS_DESCR_SLOT_TYPROTO).toObject().as<TypedProto>();
     }
 
     JSAtom &stringRepr() const {
         return getReservedSlot(JS_DESCR_SLOT_STRING_REPR).toString()->asAtom();
     }
 
-    TypeDescr::Kind kind() const {
-        return (TypeDescr::Kind) getReservedSlot(JS_DESCR_SLOT_KIND).toInt32();
+    type::Kind kind() const {
+        return (type::Kind) getReservedSlot(JS_DESCR_SLOT_KIND).toInt32();
     }
 
     bool opaque() const {
         return getReservedSlot(JS_DESCR_SLOT_OPAQUE).toBoolean();
     }
 
     bool transparent() const {
         return !opaque();
     }
 
-    int32_t alignment() {
+    int32_t alignment() const {
         return getReservedSlot(JS_DESCR_SLOT_ALIGNMENT).toInt32();
     }
 };
 
 typedef Handle<TypeDescr*> HandleTypeDescr;
 
 class SizedTypeDescr : public TypeDescr
 {
   public:
-    int32_t size() {
+    int32_t size() const {
         return getReservedSlot(JS_DESCR_SLOT_SIZE).toInt32();
     }
 
     void initInstances(const JSRuntime *rt, uint8_t *mem, size_t length);
     void traceInstances(JSTracer *trace, uint8_t *mem, size_t length);
 };
 
 typedef Handle<SizedTypeDescr*> HandleSizedTypeDescr;
@@ -228,17 +251,17 @@ class ScalarTypeDescr : public SimpleTyp
         /*
          * Special type that's a uint8_t, but assignments are clamped to 0 .. 255.
          * Treat the raw data type as a uint8_t.
          */
         TYPE_UINT8_CLAMPED = JS_SCALARTYPEREPR_UINT8_CLAMPED,
     };
     static const int32_t TYPE_MAX = TYPE_UINT8_CLAMPED + 1;
 
-    static const TypeDescr::Kind Kind = TypeDescr::Scalar;
+    static const type::Kind Kind = type::Scalar;
     static const bool Opaque = false;
     static int32_t size(Type t);
     static int32_t alignment(Type t);
     static const char *typeName(Type type);
 
     static const Class class_;
     static const JSFunctionSpec typeObjectMethods[];
 
@@ -277,17 +300,17 @@ class ReferenceTypeDescr : public Simple
     enum Type {
         TYPE_ANY = JS_REFERENCETYPEREPR_ANY,
         TYPE_OBJECT = JS_REFERENCETYPEREPR_OBJECT,
         TYPE_STRING = JS_REFERENCETYPEREPR_STRING,
     };
     static const int32_t TYPE_MAX = TYPE_STRING + 1;
     static const char *typeName(Type type);
 
-    static const TypeDescr::Kind Kind = TypeDescr::Reference;
+    static const type::Kind Kind = type::Reference;
     static const bool Opaque = true;
     static const Class class_;
     static int32_t size(Type t);
     static int32_t alignment(Type t);
     static const JSFunctionSpec typeObjectMethods[];
 
     ReferenceTypeDescr::Type type() const {
         return (ReferenceTypeDescr::Type) getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32();
@@ -323,17 +346,17 @@ class ComplexTypeDescr : public SizedTyp
 class X4TypeDescr : public ComplexTypeDescr
 {
   public:
     enum Type {
         TYPE_INT32 = JS_X4TYPEREPR_INT32,
         TYPE_FLOAT32 = JS_X4TYPEREPR_FLOAT32,
     };
 
-    static const TypeDescr::Kind Kind = TypeDescr::X4;
+    static const type::Kind Kind = type::X4;
     static const bool Opaque = false;
     static const Class class_;
     static int32_t size(Type t);
     static int32_t alignment(Type t);
 
     X4TypeDescr::Type type() const {
         return (X4TypeDescr::Type) getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32();
     }
@@ -402,41 +425,41 @@ class ArrayMetaTypeDescr : public JSObje
  * `ComplexTypeDescr`, but it would require some reshuffling of the
  * hierarchy, and it's not worth the trouble since they will be going
  * away as part of bug 973238.
  */
 class UnsizedArrayTypeDescr : public TypeDescr
 {
   public:
     static const Class class_;
-    static const TypeDescr::Kind Kind = TypeDescr::UnsizedArray;
+    static const type::Kind Kind = type::UnsizedArray;
 
     // This is the sized method on unsized array type objects.  It
     // produces a sized variant.
     static bool dimension(JSContext *cx, unsigned int argc, jsval *vp);
 
-    SizedTypeDescr &elementType() {
+    SizedTypeDescr &elementType() const {
         return getReservedSlot(JS_DESCR_SLOT_ARRAY_ELEM_TYPE).toObject().as<SizedTypeDescr>();
     }
 };
 
 /*
  * Type descriptor created by `unsizedArrayTypeObj.dimension()`
  */
 class SizedArrayTypeDescr : public ComplexTypeDescr
 {
   public:
     static const Class class_;
-    static const TypeDescr::Kind Kind = TypeDescr::SizedArray;
+    static const type::Kind Kind = type::SizedArray;
 
-    SizedTypeDescr &elementType() {
+    SizedTypeDescr &elementType() const {
         return getReservedSlot(JS_DESCR_SLOT_ARRAY_ELEM_TYPE).toObject().as<SizedTypeDescr>();
     }
 
-    int32_t length() {
+    int32_t length() const {
         return getReservedSlot(JS_DESCR_SLOT_SIZED_ARRAY_LENGTH).toInt32();
     }
 };
 
 /*
  * Properties and methods of the `StructType` meta type object. There
  * is no `class_` field because `StructType` is just a native
  * constructor function.
@@ -464,30 +487,30 @@ class StructMetaTypeDescr : public JSObj
 };
 
 class StructTypeDescr : public ComplexTypeDescr
 {
   public:
     static const Class class_;
 
     // Returns the number of fields defined in this struct.
-    size_t fieldCount();
+    size_t fieldCount() const;
 
     // Set `*out` to the index of the field named `id` and returns true,
     // or return false if no such field exists.
-    bool fieldIndex(jsid id, size_t *out);
+    bool fieldIndex(jsid id, size_t *out) const;
 
     // Return the name of the field at index `index`.
-    JSAtom &fieldName(size_t index);
+    JSAtom &fieldName(size_t index) const;
 
     // Return the type descr of the field at index `index`.
-    SizedTypeDescr &fieldDescr(size_t index);
+    SizedTypeDescr &fieldDescr(size_t index) const;
 
     // Return the offset of the field at index `index`.
-    int32_t fieldOffset(size_t index);
+    int32_t fieldOffset(size_t index) const;
 };
 
 typedef Handle<StructTypeDescr*> HandleStructTypeDescr;
 
 /*
  * This object exists in order to encapsulate the typed object types
  * somewhat, rather than sticking them all into the global object.
  * Eventually it will go away and become a module.
@@ -665,24 +688,24 @@ class TypedObject : public ArrayBufferVi
     }
 
     int32_t length() const {
         return getReservedSlot(JS_BUFVIEW_SLOT_LENGTH).toInt32();
     }
 
     int32_t size() const {
         switch (typeDescr().kind()) {
-          case TypeDescr::Scalar:
-          case TypeDescr::X4:
-          case TypeDescr::Reference:
-          case TypeDescr::Struct:
-          case TypeDescr::SizedArray:
+          case type::Scalar:
+          case type::X4:
+          case type::Reference:
+          case type::Struct:
+          case type::SizedArray:
             return typeDescr().as<SizedTypeDescr>().size();
 
-          case TypeDescr::UnsizedArray: {
+          case type::UnsizedArray: {
             SizedTypeDescr &elementType = typeDescr().as<UnsizedArrayTypeDescr>().elementType();
             return elementType.size() * length();
           }
         }
         MOZ_ASSUME_UNREACHABLE("unhandled typerepresentation kind");
     }
 
     uint8_t *typedMem(size_t offset) const {
--- a/js/src/jit/IonBuilder.cpp
+++ b/js/src/jit/IonBuilder.cpp
@@ -6765,40 +6765,40 @@ IonBuilder::getElemTryTypedObject(bool *
 
     JS_ASSERT(TypeDescr::isSized(elemDescrs.kind()));
 
     int32_t elemSize;
     if (!elemDescrs.allHaveSameSize(&elemSize))
         return true;
 
     switch (elemDescrs.kind()) {
-      case TypeDescr::X4:
+      case type::X4:
         // FIXME (bug 894105): load into a MIRType_float32x4 etc
         return true;
 
-      case TypeDescr::Struct:
-      case TypeDescr::SizedArray:
+      case type::Struct:
+      case type::SizedArray:
         return getElemTryComplexElemOfTypedObject(emitted,
                                                   obj,
                                                   index,
                                                   objDescrs,
                                                   elemDescrs,
                                                   elemSize);
-      case TypeDescr::Scalar:
+      case type::Scalar:
         return getElemTryScalarElemOfTypedObject(emitted,
                                                  obj,
                                                  index,
                                                  objDescrs,
                                                  elemDescrs,
                                                  elemSize);
 
-      case TypeDescr::Reference:
-        return true;
-
-      case TypeDescr::UnsizedArray:
+      case type::Reference:
+        return true;
+
+      case type::UnsizedArray:
         MOZ_ASSUME_UNREACHABLE("Unsized arrays cannot be element types");
     }
 
     MOZ_ASSUME_UNREACHABLE("Bad kind");
 }
 
 static MIRType
 MIRTypeForTypedArrayRead(ScalarTypeDescr::Type arrayType,
@@ -7678,28 +7678,28 @@ IonBuilder::setElemTryTypedObject(bool *
 
     JS_ASSERT(TypeDescr::isSized(elemTypeDescrs.kind()));
 
     int32_t elemSize;
     if (!elemTypeDescrs.allHaveSameSize(&elemSize))
         return true;
 
     switch (elemTypeDescrs.kind()) {
-      case TypeDescr::X4:
+      case type::X4:
         // FIXME (bug 894105): store a MIRType_float32x4 etc
         return true;
 
-      case TypeDescr::Reference:
-      case TypeDescr::Struct:
-      case TypeDescr::SizedArray:
-      case TypeDescr::UnsizedArray:
+      case type::Reference:
+      case type::Struct:
+      case type::SizedArray:
+      case type::UnsizedArray:
         // For now, only optimize storing scalars.
         return true;
 
-      case TypeDescr::Scalar:
+      case type::Scalar:
         return setElemTryScalarElemOfTypedObject(emitted,
                                                  obj,
                                                  index,
                                                  objTypeDescrs,
                                                  value,
                                                  elemTypeDescrs,
                                                  elemSize);
     }
@@ -8703,40 +8703,40 @@ IonBuilder::getPropTryTypedObject(bool *
     int32_t fieldOffset;
     size_t fieldIndex;
     if (!lookupTypedObjectField(obj, name, &fieldOffset, &fieldDescrs, &fieldIndex))
         return false;
     if (fieldDescrs.empty())
         return true;
 
     switch (fieldDescrs.kind()) {
-      case TypeDescr::Reference:
-        return true;
-
-      case TypeDescr::X4:
+      case type::Reference:
+        return true;
+
+      case type::X4:
         // FIXME (bug 894104): load into a MIRType_float32x4 etc
         return true;
 
-      case TypeDescr::Struct:
-      case TypeDescr::SizedArray:
+      case type::Struct:
+      case type::SizedArray:
         return getPropTryComplexPropOfTypedObject(emitted,
                                                   obj,
                                                   fieldOffset,
                                                   fieldDescrs,
                                                   fieldIndex,
                                                   resultTypes);
 
-      case TypeDescr::Scalar:
+      case type::Scalar:
         return getPropTryScalarPropOfTypedObject(emitted,
                                                  obj,
                                                  fieldOffset,
                                                  fieldDescrs,
                                                  resultTypes);
 
-      case TypeDescr::UnsizedArray:
+      case type::UnsizedArray:
         MOZ_ASSUME_UNREACHABLE("Field of unsized array type");
     }
 
     MOZ_ASSUME_UNREACHABLE("Bad kind");
 }
 
 bool
 IonBuilder::getPropTryScalarPropOfTypedObject(bool *emitted, MDefinition *typedObj,
@@ -9357,28 +9357,28 @@ IonBuilder::setPropTryTypedObject(bool *
     size_t fieldIndex;
     if (!lookupTypedObjectField(obj, name, &fieldOffset, &fieldDescrs,
                                 &fieldIndex))
         return false;
     if (fieldDescrs.empty())
         return true;
 
     switch (fieldDescrs.kind()) {
-      case TypeDescr::X4:
+      case type::X4:
         // FIXME (bug 894104): store into a MIRType_float32x4 etc
         return true;
 
-      case TypeDescr::Reference:
-      case TypeDescr::Struct:
-      case TypeDescr::SizedArray:
-      case TypeDescr::UnsizedArray:
+      case type::Reference:
+      case type::Struct:
+      case type::SizedArray:
+      case type::UnsizedArray:
         // For now, only optimize storing scalars.
         return true;
 
-      case TypeDescr::Scalar:
+      case type::Scalar:
         return setPropTryScalarPropOfTypedObject(emitted, obj, fieldOffset,
                                                  value, fieldDescrs);
     }
 
     MOZ_ASSUME_UNREACHABLE("Unknown kind");
 }
 
 bool
@@ -10397,17 +10397,17 @@ IonBuilder::lookupTypedObjectField(MDefi
                                    TypeDescrSet *fieldDescrs,
                                    size_t *fieldIndex)
 {
     TypeDescrSet objDescrs;
     if (!lookupTypeDescrSet(typedObj, &objDescrs))
         return false;
 
     // Must be accessing a struct.
-    if (!objDescrs.allOfKind(TypeDescr::Struct))
+    if (!objDescrs.allOfKind(type::Struct))
         return true;
 
     // Determine the type/offset of the field `name`, if any.
     int32_t offset;
     if (!objDescrs.fieldNamed(*this, NameToId(name), &offset,
                               fieldDescrs, fieldIndex))
         return false;
     if (fieldDescrs->empty())
--- a/js/src/jit/MCallOptimize.cpp
+++ b/js/src/jit/MCallOptimize.cpp
@@ -1455,17 +1455,17 @@ IonBuilder::elementAccessIsTypedObjectAr
 
     if (!objDescrs.allOfArrayKind())
         return false;
 
     TypeDescrSet elemDescrs;
     if (!objDescrs.arrayElementType(*this, &elemDescrs))
         return false;
 
-    if (elemDescrs.empty() || elemDescrs.kind() != TypeDescr::Scalar)
+    if (elemDescrs.empty() || elemDescrs.kind() != type::Scalar)
         return false;
 
     JS_ASSERT(TypeDescr::isSized(elemDescrs.kind()));
 
     return elemDescrs.scalarType(arrayType);
 }
 
 bool
--- a/js/src/jit/TypeDescrSet.cpp
+++ b/js/src/jit/TypeDescrSet.cpp
@@ -171,32 +171,32 @@ TypeDescrSet::empty() const
 
 bool
 TypeDescrSet::allOfArrayKind()
 {
     if (empty())
         return false;
 
     switch (kind()) {
-      case TypeDescr::SizedArray:
-      case TypeDescr::UnsizedArray:
+      case type::SizedArray:
+      case type::UnsizedArray:
         return true;
 
-      case TypeDescr::X4:
-      case TypeDescr::Reference:
-      case TypeDescr::Scalar:
-      case TypeDescr::Struct:
+      case type::X4:
+      case type::Reference:
+      case type::Scalar:
+      case type::Struct:
         return false;
     }
 
     MOZ_ASSUME_UNREACHABLE("Invalid kind() in TypeDescrSet");
 }
 
 bool
-TypeDescrSet::allOfKind(TypeDescr::Kind aKind)
+TypeDescrSet::allOfKind(type::Kind aKind)
 {
     if (empty())
         return false;
 
     return kind() == aKind;
 }
 
 bool
@@ -221,28 +221,28 @@ JSObject *
 TypeDescrSet::knownPrototype() const
 {
     JS_ASSERT(!empty());
     if (length() > 1 || !get(0)->is<ComplexTypeDescr>())
         return nullptr;
     return &get(0)->as<ComplexTypeDescr>().instancePrototype();
 }
 
-TypeDescr::Kind
+type::Kind
 TypeDescrSet::kind()
 {
     JS_ASSERT(!empty());
     return get(0)->kind();
 }
 
 template<typename T>
 bool
 TypeDescrSet::genericType(typename T::Type *out)
 {
-    JS_ASSERT(allOfKind(TypeDescr::Scalar));
+    JS_ASSERT(allOfKind(type::Scalar));
 
     typename T::Type type = get(0)->as<T>().type();
     for (size_t i = 1; i < length(); i++) {
         if (get(i)->as<T>().type() != type)
             return false;
     }
 
     *out = type;
@@ -266,20 +266,20 @@ TypeDescrSet::x4Type(X4TypeDescr::Type *
 {
     return genericType<X4TypeDescr>(out);
 }
 
 bool
 TypeDescrSet::hasKnownArrayLength(int32_t *l)
 {
     switch (kind()) {
-      case TypeDescr::UnsizedArray:
+      case type::UnsizedArray:
         return false;
 
-      case TypeDescr::SizedArray:
+      case type::SizedArray:
       {
         const size_t result = get(0)->as<SizedArrayTypeDescr>().length();
         for (size_t i = 1; i < length(); i++) {
             size_t l = get(i)->as<SizedArrayTypeDescr>().length();
             if (l != result)
                 return false;
         }
         *l = result;
@@ -292,22 +292,22 @@ TypeDescrSet::hasKnownArrayLength(int32_
 }
 
 bool
 TypeDescrSet::arrayElementType(IonBuilder &builder, TypeDescrSet *out)
 {
     TypeDescrSetBuilder elementTypes;
     for (size_t i = 0; i < length(); i++) {
         switch (kind()) {
-          case TypeDescr::UnsizedArray:
+          case type::UnsizedArray:
             if (!elementTypes.insert(&get(i)->as<UnsizedArrayTypeDescr>().elementType()))
                 return false;
             break;
 
-          case TypeDescr::SizedArray:
+          case type::SizedArray:
             if (!elementTypes.insert(&get(i)->as<SizedArrayTypeDescr>().elementType()))
                 return false;
             break;
 
           default:
             MOZ_ASSUME_UNREACHABLE("Invalid kind for arrayElementType()");
         }
     }
@@ -316,17 +316,17 @@ TypeDescrSet::arrayElementType(IonBuilde
 
 bool
 TypeDescrSet::fieldNamed(IonBuilder &builder,
                          jsid id,
                          int32_t *offset,
                          TypeDescrSet *out,
                          size_t *index)
 {
-    JS_ASSERT(kind() == TypeDescr::Struct);
+    JS_ASSERT(kind() == type::Struct);
 
     // Initialize `*offset` and `*out` for the case where incompatible
     // or absent fields are found.
     *offset = -1;
     *index = SIZE_MAX;
     *out = TypeDescrSet();
 
     // Remember offset of the first field.
--- a/js/src/jit/TypeDescrSet.h
+++ b/js/src/jit/TypeDescrSet.h
@@ -81,17 +81,17 @@ class TypeDescrSet {
 
     TypeDescrSet(const TypeDescrSet &c);
     TypeDescrSet(); // empty set
 
     //////////////////////////////////////////////////////////////////////
     // Query the set
 
     bool empty() const;
-    bool allOfKind(TypeDescr::Kind kind);
+    bool allOfKind(type::Kind kind);
 
     // Returns true only when non-empty and `kind()` is
     // `TypeDescr::Array`
     bool allOfArrayKind();
 
     // Returns true only if (1) non-empty, (2) for all types t in this
     // set, t is sized, and (3) there is some size S such that for all
     // types t in this set, `t.size() == S`.  When the above holds,
@@ -103,69 +103,69 @@ class TypeDescrSet {
     bool allHaveSameSize(int32_t *out);
 
     types::TemporaryTypeSet *suitableTypeSet(IonBuilder &builder,
                                              const Class *knownClass);
 
     //////////////////////////////////////////////////////////////////////
     // The following operations are only valid on a non-empty set:
 
-    TypeDescr::Kind kind();
+    type::Kind kind();
 
     // Returns the prototype that a typed object whose type is within
     // this TypeDescrSet would have. Returns `null` if this cannot be
     // predicted or instances of the type are not objects (e.g., uint8).
     JSObject *knownPrototype() const;
 
     //////////////////////////////////////////////////////////////////////
     // Scalar operations
     //
-    // Only valid when `kind() == TypeDescr::Scalar`
+    // Only valid when `kind() == type::Scalar`
 
     // If all type descrs in this set have a single type, returns true
     // and sets *out. Else returns false.
     bool scalarType(ScalarTypeDescr::Type *out);
 
     //////////////////////////////////////////////////////////////////////
     // Reference operations
     //
-    // Only valid when `kind() == TypeDescr::Reference`
+    // Only valid when `kind() == type::Reference`
 
     // If all type descrs in this set have a single type, returns true
     // and sets *out. Else returns false.
     bool referenceType(ReferenceTypeDescr::Type *out);
 
     //////////////////////////////////////////////////////////////////////
     // Reference operations
     //
-    // Only valid when `kind() == TypeDescr::X4`
+    // Only valid when `kind() == type::X4`
 
     // If all type descrs in this set have a single type, returns true
     // and sets *out. Else returns false.
     bool x4Type(X4TypeDescr::Type *out);
 
     //////////////////////////////////////////////////////////////////////
     // SizedArray operations
     //
-    // Only valid when `kind() == TypeDescr::SizedArray`
+    // Only valid when `kind() == type::SizedArray`
 
     // Determines whether all arrays in this set have the same,
     // statically known, array length and return that length
     // (via `*length`) if so. Otherwise returns false.
     bool hasKnownArrayLength(int32_t *length);
 
     // Returns a `TypeDescrSet` representing the element
     // types of the various array types in this set. The returned set
     // may be the empty set.
     bool arrayElementType(IonBuilder &builder, TypeDescrSet *out);
 
     //////////////////////////////////////////////////////////////////////
     // Struct operations
     //
-    // Only valid when `kind() == TypeDescr::Struct`
+    // Only valid when `kind() == type::Struct`
 
     // Searches the type in the set for a field named `id`. All
     // possible types must agree on the offset of the field within the
     // structure and the possible types of the field must be
     // compatible. If any pair of types disagree on the offset or have
     // incompatible types for the field, then `*out` will be set to
     // the empty set.
     //