示例#1
0
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->hasLazyType() &&
                    !obj->type()->hasAllFlags(types::OBJECT_FLAG_NON_PACKED) &&
                    obj->getDenseInitializedLength() == obj->as<ArrayObject>().length();

    args.rval().setBoolean(isPacked);
    return true;
}
示例#2
0
void
js::Nursery::collectToFixedPoint(MinorCollectionTracer *trc)
{
    for (RelocationOverlay *p = trc->head; p; p = p->next()) {
        JSObject *obj = static_cast<JSObject*>(p->forwardingAddress());
        traceObject(trc, obj);

        /*
         * Increment tenure count and recompile the script for pre-tenuring if
         * long-lived. Attempt to distinguish between tenuring because the
         * object is long lived and tenuring while the nursery is still
         * smaller than the working set size.
         */
        if (isFullyGrown() && !obj->hasLazyType() && obj->type()->hasNewScript() &&
            obj->type()->incrementTenureCount())
        {
            MaybeInvalidateScriptUsedWithNew(trc->runtime, obj->type());
        }
    }
}