Example #1
0
bool
js::IsAsmJSModuleLoadedFromCache(JSContext *cx, unsigned argc, Value *vp)
{
    CallArgs args = CallArgsFromVp(argc, vp);

    JSFunction *fun;
    if (!args.hasDefined(0) || !IsMaybeWrappedNativeFunction(args[0], LinkAsmJS, &fun)) {
        JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_USE_ASM_TYPE_FAIL,
                             "argument passed to isAsmJSModuleLoadedFromCache is not a "
                             "validated asm.js module");
        return false;
    }

    JSObject &moduleObj = fun->getExtendedSlot(MODULE_FUN_SLOT).toObject();
    bool loadedFromCache = moduleObj.as<AsmJSModuleObject>().module().loadedFromCache();

    args.rval().set(BooleanValue(loadedFromCache));
    return true;
}