Bug 911578 - Introduce self-hosting intrinsic isPackedArray. r=jandem

--HG--
extra : rebase_source : de128118f4a52553efa77f70bb4699dfb94d97c4
This commit is contained in:
Till Schneidereit 2013-11-29 17:54:31 +01:00
parent fa682b166a
commit 49cb91346e
2 changed files with 18 additions and 0 deletions

View File

@ -1012,6 +1012,7 @@ bool intrinsic_UnsafePutElements(JSContext *cx, unsigned argc, Value *vp);
bool intrinsic_UnsafeSetReservedSlot(JSContext *cx, unsigned argc, Value *vp);
bool intrinsic_UnsafeGetReservedSlot(JSContext *cx, unsigned argc, Value *vp);
bool intrinsic_HaveSameClass(JSContext *cx, unsigned argc, Value *vp);
bool intrinsic_IsPackedArray(JSContext *cx, unsigned argc, Value *vp);
bool intrinsic_ShouldForceSequential(JSContext *cx, unsigned argc, Value *vp);
bool intrinsic_NewParallelArray(JSContext *cx, unsigned argc, Value *vp);

View File

@ -463,6 +463,22 @@ js::intrinsic_HaveSameClass(JSContext *cx, unsigned argc, Value *vp)
return true;
}
bool
js::intrinsic_IsPackedArray(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
JS_ASSERT(args.length() == 1);
JS_ASSERT(args[0].isObject());
JSObject *obj = &args[0].toObject();
bool isPacked = obj->is<ArrayObject>() &&
!obj->type()->hasAllFlags(types::OBJECT_FLAG_NON_PACKED) &&
obj->getDenseInitializedLength() == obj->as<ArrayObject>().length();
args.rval().setBoolean(isPacked);
return true;
}
static bool
intrinsic_GetIteratorPrototype(JSContext *cx, unsigned argc, Value *vp)
{
@ -612,6 +628,7 @@ static const JSFunctionSpec intrinsic_functions[] = {
JS_FN("UnsafeSetReservedSlot", intrinsic_UnsafeSetReservedSlot, 3,0),
JS_FN("UnsafeGetReservedSlot", intrinsic_UnsafeGetReservedSlot, 2,0),
JS_FN("HaveSameClass", intrinsic_HaveSameClass, 2,0),
JS_FN("IsPackedArray", intrinsic_IsPackedArray, 1,0),
JS_FN("GetIteratorPrototype", intrinsic_GetIteratorPrototype, 0,0),