Merge TM -> JM
This commit is contained in:
@@ -122,9 +122,6 @@ using namespace js::types;
|
||||
#define MAXINDEX 4294967295u
|
||||
#define MAXSTR "4294967295"
|
||||
|
||||
/* Small arrays are dense, no matter what. */
|
||||
#define MIN_SPARSE_INDEX 256
|
||||
|
||||
/*
|
||||
* Use the limit on number of object slots for sanity and consistency (see the
|
||||
* assertion in JSObject::makeDenseArraySlow).
|
||||
@@ -1086,12 +1083,10 @@ JSObject::makeDenseArraySlow(JSContext *cx)
|
||||
*/
|
||||
JSObjectMap *oldMap = map;
|
||||
|
||||
/*
|
||||
* Create a native scope. All slow arrays other than Array.prototype get
|
||||
* the same initial shape.
|
||||
*/
|
||||
/* Create a native scope. */
|
||||
JSObject *arrayProto = getProto();
|
||||
if (!InitScopeForObject(cx, this, &js_SlowArrayClass, arrayProto, FINALIZE_OBJECT0))
|
||||
js::gc::FinalizeKind kind = js::gc::FinalizeKind(arena()->header()->thingKind);
|
||||
if (!InitScopeForObject(cx, this, &js_SlowArrayClass, arrayProto, kind))
|
||||
return false;
|
||||
|
||||
uint32 initlen = getDenseArrayInitializedLength();
|
||||
@@ -1107,7 +1102,11 @@ JSObject::makeDenseArraySlow(JSContext *cx)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Create new properties pointing to existing elements. */
|
||||
/*
|
||||
* Create new properties pointing to existing elements. Pack the array to
|
||||
* remove holes, so that shapes use successive slots (as for other objects).
|
||||
*/
|
||||
uint32 next = 0;
|
||||
for (uint32 i = 0; i < initlen; i++) {
|
||||
jsid id;
|
||||
if (!ValueToId(cx, Int32Value(i), &id)) {
|
||||
@@ -1115,24 +1114,32 @@ JSObject::makeDenseArraySlow(JSContext *cx)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (getDenseArrayElement(i).isMagic(JS_ARRAY_HOLE)) {
|
||||
setDenseArrayElement(i, UndefinedValue());
|
||||
if (getDenseArrayElement(i).isMagic(JS_ARRAY_HOLE))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!addDataProperty(cx, id, i, JSPROP_ENUMERATE)) {
|
||||
setDenseArrayElement(next, getDenseArrayElement(i));
|
||||
|
||||
if (!addDataProperty(cx, id, next, JSPROP_ENUMERATE)) {
|
||||
setMap(oldMap);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Clear values out to the capacity with undefined. */
|
||||
ClearValueRange(getDenseArrayElements() + initlen, getDenseArrayCapacity() - initlen, false);
|
||||
next++;
|
||||
}
|
||||
|
||||
/* initialized length is not used anymore. */
|
||||
initializedLength = 0;
|
||||
JS_ASSERT(emptyShapes == NULL);
|
||||
|
||||
/*
|
||||
* Dense arrays with different numbers of slots but the same number of fixed
|
||||
* slots and the same non-hole indexes must use their fixed slots consistently.
|
||||
*/
|
||||
if (hasSlotsArray() && next <= numFixedSlots())
|
||||
revertToFixedSlots(cx);
|
||||
|
||||
ClearValueRange(slots + next, this->capacity - next, false);
|
||||
|
||||
/*
|
||||
* Finally, update class. If |this| is Array.prototype, then js_InitClass
|
||||
* will create an emptyShape whose class is &js_SlowArrayClass, to ensure
|
||||
@@ -3378,18 +3385,6 @@ static void array_TypeNew(JSContext *cx, JSTypeFunction *jsfun, JSTypeCallsite *
|
||||
#endif
|
||||
}
|
||||
|
||||
JSObject* JS_FASTCALL
|
||||
js_InitializerArray(JSContext* cx, int32 count)
|
||||
{
|
||||
TypeObject *type = cx->getFixedTypeObject(TYPE_OBJECT_UNKNOWN_ARRAY);
|
||||
gc::FinalizeKind kind = GuessObjectGCKind(count, true);
|
||||
return NewArrayWithKind(cx, type, kind);
|
||||
}
|
||||
#ifdef JS_TRACER
|
||||
JS_DEFINE_CALLINFO_2(extern, OBJECT, js_InitializerArray, CONTEXT, INT32, 0,
|
||||
nanojit::ACCSET_STORE_ANY)
|
||||
#endif
|
||||
|
||||
JSObject *
|
||||
js_InitArrayClass(JSContext *cx, JSObject *obj)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user