Merge MC -> JM.
This commit is contained in:
@@ -300,7 +300,7 @@ JSObject::willBeSparseDenseArray(uintN requiredCapacity, uintN newElementsHint)
|
||||
return true;
|
||||
|
||||
uintN len = getDenseArrayInitializedLength();
|
||||
Value *elems = getDenseArrayElements();
|
||||
const Value *elems = getDenseArrayElements();
|
||||
for (uintN i = 0; i < len; i++) {
|
||||
if (!elems[i].isMagic(JS_ARRAY_HOLE) && !--minimalDenseCount)
|
||||
return false;
|
||||
@@ -400,9 +400,10 @@ GetElements(JSContext *cx, JSObject *aobj, jsuint length, Value *vp)
|
||||
if (aobj->isDenseArray() && length <= aobj->getDenseArrayInitializedLength() &&
|
||||
!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;
|
||||
}
|
||||
@@ -790,7 +791,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))
|
||||
@@ -814,7 +815,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
|
||||
@@ -1330,9 +1331,9 @@ array_toString_sub(JSContext *cx, JSObject *obj, JSBool locale,
|
||||
|
||||
if (!locale && !seplen && obj->isDenseArray() && !js_PrototypeHasIndexedProperties(cx, obj)) {
|
||||
/* Elements beyond the initialized length are 'undefined' and thus can be ignored. */
|
||||
Value *beg = obj->getDenseArrayElements();
|
||||
Value *end = beg + Min(length, obj->getDenseArrayInitializedLength());
|
||||
for (Value *vp = beg; vp != end; ++vp) {
|
||||
const Value *beg = obj->getDenseArrayElements();
|
||||
const Value *end = beg + Min(length, obj->getDenseArrayInitializedLength());
|
||||
for (const Value *vp = beg; vp != end; ++vp) {
|
||||
if (!JS_CHECK_OPERATION_LIMIT(cx))
|
||||
return false;
|
||||
|
||||
@@ -1483,7 +1484,7 @@ InitArrayElements(JSContext *cx, JSObject *obj, jsuint start, jsuint count, Valu
|
||||
obj->setDenseArrayLength(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);
|
||||
@@ -2303,14 +2304,13 @@ 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);
|
||||
if (cx->typeInferenceEnabled())
|
||||
obj->setDenseArrayInitializedLength(obj->getDenseArrayInitializedLength() - 1);
|
||||
else
|
||||
obj->setDenseArrayElement(length, MagicValue(JS_ARRAY_HOLE));
|
||||
obj->setArrayLength(cx, length);
|
||||
if (!js_SuppressDeletedIndexProperties(cx, obj, length, length + 1))
|
||||
if (!js_SuppressDeletedProperty(cx, obj, INT_TO_JSID(length)))
|
||||
return JS_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
@@ -2370,9 +2370,9 @@ 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));
|
||||
ClearValueRange(obj->getDenseArrayElements(), argc, false);
|
||||
obj->moveDenseArrayElements(argc, 0, length);
|
||||
for (uint32 i = 0; i < argc; i++)
|
||||
obj->setDenseArrayElement(i, MagicValue(JS_ARRAY_HOLE));
|
||||
optimized = true;
|
||||
} while (false);
|
||||
|
||||
@@ -2522,12 +2522,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(cx, obj->getArrayLength() + delta);
|
||||
optimized = true;
|
||||
@@ -2549,12 +2544,7 @@ array_splice(JSContext *cx, uintN argc, Value *vp)
|
||||
if (obj->isDenseArray() && !js_PrototypeHasIndexedProperties(cx, obj) &&
|
||||
length <= obj->getDenseArrayInitializedLength()) {
|
||||
|
||||
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) ||
|
||||
@@ -2596,7 +2586,7 @@ array_concat(JSContext *cx, uintN argc, Value *vp)
|
||||
jsuint length;
|
||||
if (aobj->isDenseArray()) {
|
||||
length = aobj->getArrayLength();
|
||||
Value *vector = aobj->getDenseArrayElements();
|
||||
const Value *vector = aobj->getDenseArrayElements();
|
||||
jsuint initlen = aobj->getDenseArrayInitializedLength();
|
||||
nobj = NewDenseCopiedArray(cx, initlen, vector);
|
||||
if (!nobj)
|
||||
@@ -3284,7 +3274,7 @@ mjit::stubs::NewDenseUnallocatedArray(VMFrame &f, uint32 length)
|
||||
#endif
|
||||
|
||||
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)
|
||||
@@ -3292,16 +3282,11 @@ NewDenseCopiedArray(JSContext *cx, uintN length, Value *vp, JSObject *proto)
|
||||
|
||||
JS_ASSERT(obj->getDenseArrayCapacity() >= length);
|
||||
|
||||
if (cx->typeInferenceEnabled()) {
|
||||
if (vp) {
|
||||
memcpy(obj->getDenseArrayElements(), vp, length * sizeof(Value));
|
||||
obj->setDenseArrayInitializedLength(length);
|
||||
} else {
|
||||
obj->setDenseArrayInitializedLength(0);
|
||||
}
|
||||
} else if (vp) {
|
||||
memcpy(obj->getDenseArrayElements(), vp, length * sizeof(Value));
|
||||
}
|
||||
if (cx->typeInferenceEnabled())
|
||||
obj->setDenseArrayInitializedLength(vp ? length : 0);
|
||||
|
||||
if (vp)
|
||||
obj->copyDenseArrayElements(0, vp, length);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user