diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 23137fffcb27..7b97952889d3 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -1260,9 +1260,11 @@ NewObjectGCKind(const js::Class *clasp) } static inline JSObject * -NewObject(ExclusiveContext *cx, const Class *clasp, types::TypeObject *type_, JSObject *parent, - gc::AllocKind kind, NewObjectKind newKind) +NewObject(ExclusiveContext *cx, types::TypeObject *type_, JSObject *parent, gc::AllocKind kind, + NewObjectKind newKind) { + const Class *clasp = type_->clasp(); + JS_ASSERT(clasp != &ArrayObject::class_); JS_ASSERT_IF(clasp == &JSFunction::class_, kind == JSFunction::FinalizeKind || kind == JSFunction::ExtendedFinalizeKind); @@ -1365,7 +1367,7 @@ js::NewObjectWithGivenProto(ExclusiveContext *cxArg, const js::Class *clasp, if (!parent && proto.isObject()) parent = proto.toObject()->getParent(); - RootedObject obj(cxArg, NewObject(cxArg, clasp, type, parent, allocKind, newKind)); + RootedObject obj(cxArg, NewObject(cxArg, type, parent, allocKind, newKind)); if (!obj) return nullptr; @@ -1428,7 +1430,7 @@ js::NewObjectWithClassProtoCommon(ExclusiveContext *cxArg, if (!type) return nullptr; - JSObject *obj = NewObject(cxArg, clasp, type, parent, allocKind, newKind); + JSObject *obj = NewObject(cxArg, type, parent, allocKind, newKind); if (!obj) return nullptr; @@ -1462,19 +1464,19 @@ js::NewObjectWithType(JSContext *cx, HandleTypeObject type, JSObject *parent, gc newKind == GenericObject && !cx->compartment()->hasObjectMetadataCallback()) { - if (cache.lookupType(type->clasp(), type, allocKind, &entry)) { + if (cache.lookupType(type, allocKind, &entry)) { JSObject *obj = cache.newObjectFromHit(cx, entry, GetInitialHeap(newKind, type->clasp())); if (obj) return obj; } } - JSObject *obj = NewObject(cx, type->clasp(), type, parent, allocKind, newKind); + JSObject *obj = NewObject(cx, type, parent, allocKind, newKind); if (!obj) return nullptr; if (entry != -1 && !obj->hasDynamicSlots()) - cache.fillType(entry, type->clasp(), type, allocKind, obj); + cache.fillType(entry, type, allocKind, obj); return obj; } diff --git a/js/src/vm/Runtime.h b/js/src/vm/Runtime.h index d7bf5ffd137a..22267979426c 100644 --- a/js/src/vm/Runtime.h +++ b/js/src/vm/Runtime.h @@ -340,10 +340,8 @@ class NewObjectCache inline bool lookupGlobal(const Class *clasp, js::GlobalObject *global, gc::AllocKind kind, EntryIndex *pentry); - bool lookupType(const Class *clasp, js::types::TypeObject *type, gc::AllocKind kind, - EntryIndex *pentry) - { - return lookup(clasp, type, kind, pentry); + bool lookupType(js::types::TypeObject *type, gc::AllocKind kind, EntryIndex *pentry) { + return lookup(type->clasp(), type, kind, pentry); } /* @@ -359,11 +357,11 @@ class NewObjectCache inline void fillGlobal(EntryIndex entry, const Class *clasp, js::GlobalObject *global, gc::AllocKind kind, JSObject *obj); - void fillType(EntryIndex entry, const Class *clasp, js::types::TypeObject *type, gc::AllocKind kind, + void fillType(EntryIndex entry, js::types::TypeObject *type, gc::AllocKind kind, JSObject *obj) { JS_ASSERT(obj->type() == type); - return fill(entry, clasp, type, kind, obj); + return fill(entry, type->clasp(), type, kind, obj); } /* Invalidate any entries which might produce an object with shape/proto. */ diff --git a/js/src/vm/Shape.cpp b/js/src/vm/Shape.cpp index 840bafdac07e..0b313cffaebe 100644 --- a/js/src/vm/Shape.cpp +++ b/js/src/vm/Shape.cpp @@ -1658,7 +1658,7 @@ NewObjectCache::invalidateEntriesForShape(JSContext *cx, HandleShape shape, Hand PodZero(&entries[entry]); if (!proto->is() && lookupProto(clasp, proto, kind, &entry)) PodZero(&entries[entry]); - if (lookupType(clasp, type, kind, &entry)) + if (lookupType(type, kind, &entry)) PodZero(&entries[entry]); }