Merge from mozilla-central to jsdbg2.
This commit is contained in:
@@ -273,7 +273,7 @@ JSObject::willBeSparseDenseArray(uintN requiredCapacity, uintN newElementsHint)
|
||||
if (minimalDenseCount > cap)
|
||||
return true;
|
||||
|
||||
Value *elems = getDenseArrayElements();
|
||||
const Value *elems = getDenseArrayElements();
|
||||
for (uintN i = 0; i < cap; i++) {
|
||||
if (!elems[i].isMagic(JS_ARRAY_HOLE) && !--minimalDenseCount)
|
||||
return false;
|
||||
@@ -399,9 +399,10 @@ GetElements(JSContext *cx, JSObject *aobj, jsuint length, Value *vp)
|
||||
if (aobj->isDenseArray() && length <= aobj->getDenseArrayCapacity() &&
|
||||
!js_PrototypeHasIndexedProperties(cx, aobj)) {
|
||||
/* The prototype does not have indexed properties so hole = undefined */
|
||||
Value *srcbeg = aobj->getDenseArrayElements();
|
||||
Value *srcend = srcbeg + length;
|
||||
for (Value *dst = vp, *src = srcbeg; src < srcend; ++dst, ++src)
|
||||
const Value *srcbeg = aobj->getDenseArrayElements();
|
||||
const Value *srcend = srcbeg + length;
|
||||
const Value *src = srcbeg;
|
||||
for (Value *dst = vp; src < srcend; ++dst, ++src)
|
||||
*dst = src->isMagic(JS_ARRAY_HOLE) ? UndefinedValue() : *src;
|
||||
return true;
|
||||
}
|
||||
@@ -786,7 +787,7 @@ array_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool stric
|
||||
return array_length_setter(cx, obj, id, strict, vp);
|
||||
|
||||
if (!obj->isDenseArray())
|
||||
return js_SetProperty(cx, obj, id, vp, strict);
|
||||
return js_SetPropertyHelper(cx, obj, id, 0, vp, strict);
|
||||
|
||||
do {
|
||||
if (!js_IdIsIndex(id, &i))
|
||||
@@ -810,7 +811,7 @@ array_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool stric
|
||||
|
||||
if (!obj->makeDenseArraySlow(cx))
|
||||
return false;
|
||||
return js_SetProperty(cx, obj, id, vp, strict);
|
||||
return js_SetPropertyHelper(cx, obj, id, 0, vp, strict);
|
||||
}
|
||||
|
||||
JSBool
|
||||
@@ -923,7 +924,7 @@ array_trace(JSTracer *trc, JSObject *obj)
|
||||
JS_ASSERT(obj->isDenseArray());
|
||||
|
||||
uint32 capacity = obj->getDenseArrayCapacity();
|
||||
MarkValueRange(trc, capacity, obj->slots, "element");
|
||||
MarkValueRange(trc, capacity, obj->getSlotsPtr(), "element");
|
||||
}
|
||||
|
||||
static JSBool
|
||||
@@ -1295,9 +1296,9 @@ array_toString_sub(JSContext *cx, JSObject *obj, JSBool locale,
|
||||
|
||||
if (!locale && !seplen && obj->isDenseArray() && !js_PrototypeHasIndexedProperties(cx, obj)) {
|
||||
/* Elements beyond 'capacity' are 'undefined' and thus can be ignored. */
|
||||
Value *beg = obj->getDenseArrayElements();
|
||||
Value *end = beg + Min(length, obj->getDenseArrayCapacity());
|
||||
for (Value *vp = beg; vp != end; ++vp) {
|
||||
const Value *beg = obj->getDenseArrayElements();
|
||||
const Value *end = beg + Min(length, obj->getDenseArrayCapacity());
|
||||
for (const Value *vp = beg; vp != end; ++vp) {
|
||||
if (!JS_CHECK_OPERATION_LIMIT(cx))
|
||||
return false;
|
||||
|
||||
@@ -1422,7 +1423,7 @@ InitArrayElements(JSContext *cx, JSObject *obj, jsuint start, jsuint count, Valu
|
||||
obj->setArrayLength(newlen);
|
||||
|
||||
JS_ASSERT(count < uint32(-1) / sizeof(Value));
|
||||
memcpy(obj->getDenseArrayElements() + start, vector, sizeof(jsval) * count);
|
||||
obj->copyDenseArrayElements(start, vector, count);
|
||||
JS_ASSERT_IF(count != 0, !obj->getDenseArrayElement(newlen - 1).isMagic(JS_ARRAY_HOLE));
|
||||
return true;
|
||||
} while (false);
|
||||
@@ -1471,7 +1472,7 @@ InitArrayObject(JSContext *cx, JSObject *obj, jsuint length, const Value *vector
|
||||
/* Avoid ensureDenseArrayElements to skip sparse array checks there. */
|
||||
if (!obj->ensureSlots(cx, length))
|
||||
return false;
|
||||
memcpy(obj->getDenseArrayElements(), vector, length * sizeof(Value));
|
||||
obj->copyDenseArrayElements(0, vector, length);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2219,8 +2220,7 @@ array_shift(JSContext *cx, uintN argc, Value *vp)
|
||||
*vp = obj->getDenseArrayElement(0);
|
||||
if (vp->isMagic(JS_ARRAY_HOLE))
|
||||
vp->setUndefined();
|
||||
Value *elems = obj->getDenseArrayElements();
|
||||
memmove(elems, elems + 1, length * sizeof(jsval));
|
||||
obj->moveDenseArrayElements(0, 1, length);
|
||||
obj->setDenseArrayElement(length, MagicValue(JS_ARRAY_HOLE));
|
||||
obj->setArrayLength(length);
|
||||
if (!js_SuppressDeletedProperty(cx, obj, INT_TO_JSID(length)))
|
||||
@@ -2282,8 +2282,7 @@ array_unshift(JSContext *cx, uintN argc, Value *vp)
|
||||
JS_ASSERT(result == JSObject::ED_SPARSE);
|
||||
break;
|
||||
}
|
||||
Value *elems = obj->getDenseArrayElements();
|
||||
memmove(elems + argc, elems, length * sizeof(jsval));
|
||||
obj->moveDenseArrayElements(argc, 0, length);
|
||||
for (uint32 i = 0; i < argc; i++)
|
||||
obj->setDenseArrayElement(i, MagicValue(JS_ARRAY_HOLE));
|
||||
optimized = true;
|
||||
@@ -2421,12 +2420,7 @@ array_splice(JSContext *cx, uintN argc, Value *vp)
|
||||
JS_ASSERT(result == JSObject::ED_SPARSE);
|
||||
break;
|
||||
}
|
||||
Value *arraybeg = obj->getDenseArrayElements();
|
||||
Value *srcbeg = arraybeg + last - 1;
|
||||
Value *srcend = arraybeg + end - 1;
|
||||
Value *dstbeg = srcbeg + delta;
|
||||
for (Value *src = srcbeg, *dst = dstbeg; src > srcend; --src, --dst)
|
||||
*dst = *src;
|
||||
obj->moveDenseArrayElements(end + delta, end, last - end);
|
||||
|
||||
obj->setArrayLength(obj->getArrayLength() + delta);
|
||||
optimized = true;
|
||||
@@ -2448,12 +2442,7 @@ array_splice(JSContext *cx, uintN argc, Value *vp)
|
||||
if (obj->isDenseArray() && !js_PrototypeHasIndexedProperties(cx, obj) &&
|
||||
length <= obj->getDenseArrayCapacity()) {
|
||||
|
||||
Value *arraybeg = obj->getDenseArrayElements();
|
||||
Value *srcbeg = arraybeg + end;
|
||||
Value *srcend = arraybeg + length;
|
||||
Value *dstbeg = srcbeg - delta;
|
||||
for (Value *src = srcbeg, *dst = dstbeg; src < srcend; ++src, ++dst)
|
||||
*dst = *src;
|
||||
obj->moveDenseArrayElements(end - delta, end, length - end);
|
||||
} else {
|
||||
for (last = end; last < length; last++) {
|
||||
if (!JS_CHECK_OPERATION_LIMIT(cx) ||
|
||||
@@ -3117,7 +3106,7 @@ NewDenseUnallocatedArray(JSContext *cx, uint32 length, JSObject *proto)
|
||||
}
|
||||
|
||||
JSObject *
|
||||
NewDenseCopiedArray(JSContext *cx, uintN length, Value *vp, JSObject *proto)
|
||||
NewDenseCopiedArray(JSContext *cx, uintN length, const Value *vp, JSObject *proto)
|
||||
{
|
||||
JSObject* obj = NewArray<true>(cx, length, proto);
|
||||
if (!obj)
|
||||
@@ -3126,7 +3115,7 @@ NewDenseCopiedArray(JSContext *cx, uintN length, Value *vp, JSObject *proto)
|
||||
JS_ASSERT(obj->getDenseArrayCapacity() >= length);
|
||||
|
||||
if (vp)
|
||||
memcpy(obj->getDenseArrayElements(), vp, length * sizeof(Value));
|
||||
obj->copyDenseArrayElements(0, vp, length);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user