Address bug 699446 review comments, r=luke.

This commit is contained in:
Brian Hackett
2011-11-18 14:40:14 -08:00
parent f6bd0c21f7
commit b6dffe3f24
7 changed files with 148 additions and 68 deletions

View File

@@ -3876,11 +3876,13 @@ NewArray(JSContext *cx, jsuint length, JSObject *proto)
kind = GetBackgroundAllocKind(kind);
#endif
JSObject *parent = GetCurrentGlobal(cx);
GlobalObject *parent = GetCurrentGlobal(cx);
NewObjectCache::Entry *entry = NULL;
if (cx->compartment->newObjectCache.lookup(&ArrayClass, parent, kind, &entry)) {
JSObject *obj = NewObjectFromCacheHit(cx, entry);
NewObjectCache &cache = cx->compartment->newObjectCache;
NewObjectCache::EntryIndex entry = -1;
if (cache.lookupGlobal(&ArrayClass, parent, kind, &entry)) {
JSObject *obj = cache.newObjectFromHit(cx, entry);
if (!obj)
return NULL;
/* Fixup the elements pointer and length, which may be incorrect. */
@@ -3909,8 +3911,8 @@ NewArray(JSContext *cx, jsuint length, JSObject *proto)
obj->initializeDenseArray(shape, type, length);
if (entry)
entry->fill(&ArrayClass, parent, kind, obj);
if (entry != -1)
cache.fillGlobal(entry, &ArrayClass, parent, kind, obj);
if (allocateCapacity && !EnsureNewArrayElements(cx, obj, length))
return NULL;