diff --git a/js/src/builtin/Object.cpp b/js/src/builtin/Object.cpp index a1ad70279734..09f9caab9d6a 100644 --- a/js/src/builtin/Object.cpp +++ b/js/src/builtin/Object.cpp @@ -703,13 +703,13 @@ obj_isPrototypeOf(JSContext *cx, unsigned argc, Value *vp) static bool obj_create(JSContext *cx, unsigned argc, Value *vp) { - if (argc == 0) { + CallArgs args = CallArgsFromVp(argc, vp); + if (args.length() == 0) { JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED, "Object.create", "0", "s"); return false; } - CallArgs args = CallArgsFromVp(argc, vp); RootedValue v(cx, args[0]); if (!v.isObjectOrNull()) { char *bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, NullPtr()); diff --git a/js/src/builtin/SIMD.cpp b/js/src/builtin/SIMD.cpp index ec6248e06ef0..ff8d2faa654f 100644 --- a/js/src/builtin/SIMD.cpp +++ b/js/src/builtin/SIMD.cpp @@ -527,7 +527,7 @@ Func(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc == 1) { + if (args.length() == 1) { if((!args[0].isObject() || !ObjectIsVector(args[0].toObject()))) { JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return false; @@ -546,7 +546,7 @@ Func(JSContext *cx, unsigned argc, Value *vp) args.rval().setObject(*obj); return true; - } else if (argc == 2) { + } else if (args.length() == 2) { if((!args[0].isObject() || !ObjectIsVector(args[0].toObject())) || (!args[1].isObject() || !ObjectIsVector(args[1].toObject()))) { @@ -583,7 +583,7 @@ FuncWith(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if ((argc != 2) || + if ((args.length() != 2) || (!args[0].isObject() || !ObjectIsVector(args[0].toObject())) || (!args[1].isNumber() && !args[1].isBoolean())) { @@ -619,7 +619,7 @@ FuncShuffle(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if(argc == 2){ + if (args.length() == 2) { if ((!args[0].isObject() || !ObjectIsVector(args[0].toObject())) || (!args[1].isNumber())) { @@ -642,7 +642,7 @@ FuncShuffle(JSContext *cx, unsigned argc, Value *vp) args.rval().setObject(*obj); return true; - } else if (argc == 3){ + } else if (args.length() == 3) { if ((!args[0].isObject() || !ObjectIsVector(args[0].toObject())) || (!args[1].isObject() || !ObjectIsVector(args[1].toObject())) || (!args[2].isNumber())) @@ -684,7 +684,7 @@ FuncConvert(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if ((argc != 1) || + if ((args.length() != 1) || (!args[0].isObject() || !ObjectIsVector(args[0].toObject()))) { JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); @@ -711,7 +711,7 @@ FuncConvertBits(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if ((argc != 1) || + if ((args.length() != 1) || (!args[0].isObject() || !ObjectIsVector(args[0].toObject()))) { JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); @@ -735,7 +735,7 @@ FuncZero(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc != 0) { + if (args.length() != 0) { JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return false; } @@ -757,7 +757,7 @@ FuncSplat(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if ((argc != 1) || (!args[0].isNumber())) { + if ((args.length() != 1) || (!args[0].isNumber())) { JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_TYPED_ARRAY_BAD_ARGS); return false; } @@ -781,7 +781,7 @@ Int32x4Bool(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if ((argc != 4) || + if ((args.length() != 4) || (!args[0].isBoolean()) || !args[1].isBoolean() || (!args[2].isBoolean()) || !args[3].isBoolean()) { @@ -805,7 +805,7 @@ Float32x4Clamp(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if ((argc != 3) || + if ((args.length() != 3) || (!args[0].isObject() || !ObjectIsVector(args[0].toObject())) || (!args[1].isObject() || !ObjectIsVector(args[1].toObject())) || (!args[2].isObject() || !ObjectIsVector(args[2].toObject()))) @@ -842,7 +842,7 @@ Int32x4Select(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if ((argc != 3) || + if ((args.length() != 3) || (!args[0].isObject() || !ObjectIsVector(args[0].toObject())) || (!args[1].isObject() || !ObjectIsVector(args[1].toObject())) || (!args[2].isObject() || !ObjectIsVector(args[2].toObject()))) diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index f4ac295aced2..3ef1b7a3d49c 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -203,6 +203,8 @@ GetBuildConfiguration(JSContext *cx, unsigned argc, jsval *vp) static bool GC(JSContext *cx, unsigned argc, jsval *vp) { + CallArgs args = CallArgsFromVp(argc, vp); + /* * If the first argument is 'compartment', we collect any compartments * previously scheduled for GC via schedulegc. If the first argument is an @@ -210,7 +212,7 @@ GC(JSContext *cx, unsigned argc, jsval *vp) * scheduled for GC). Otherwise, we collect all compartments. */ bool compartment = false; - if (argc == 1) { + if (args.length() == 1) { Value arg = vp[2]; if (arg.isString()) { if (!JS_StringEqualsAscii(cx, arg.toString(), "compartment", &compartment)) @@ -345,7 +347,7 @@ static bool IsProxy(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc != 1) { + if (args.length() != 1) { JS_ReportError(cx, "the function takes exactly one argument"); return false; } @@ -361,7 +363,7 @@ static bool IsLazyFunction(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc != 1) { + if (args.length() != 1) { JS_ReportError(cx, "The function takes exactly one argument."); return false; } @@ -377,7 +379,7 @@ static bool IsRelazifiableFunction(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc != 1) { + if (args.length() != 1) { JS_ReportError(cx, "The function takes exactly one argument."); return false; } @@ -423,7 +425,7 @@ GCPreserveCode(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc != 0) { + if (args.length() != 0) { RootedObject callee(cx, &args.callee()); ReportUsageError(cx, callee, "Wrong number of arguments"); return false; @@ -467,7 +469,7 @@ ScheduleGC(JSContext *cx, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc != 1) { + if (args.length() != 1) { RootedObject callee(cx, &args.callee()); ReportUsageError(cx, callee, "Wrong number of arguments"); return false; @@ -526,7 +528,7 @@ static bool VerifyPostBarriers(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc) { + if (args.length()) { RootedObject callee(cx, &args.callee()); ReportUsageError(cx, callee, "Too many arguments"); return false; @@ -541,7 +543,7 @@ GCState(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc != 0) { + if (args.length() != 0) { RootedObject callee(cx, &args.callee()); ReportUsageError(cx, callee, "Too many arguments"); return false; @@ -644,7 +646,7 @@ NondeterministicGetWeakMapKeys(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc != 1) { + if (args.length() != 1) { RootedObject callee(cx, &args.callee()); ReportUsageError(cx, callee, "Wrong number of arguments"); return false; @@ -902,7 +904,7 @@ DumpHeapComplete(JSContext *cx, unsigned argc, jsval *vp) FILE *dumpFile = nullptr; unsigned i = 0; - if (argc > i) { + if (args.length() > i) { Value v = args[i]; if (v.isString()) { JSString *str = v.toString(); @@ -916,7 +918,7 @@ DumpHeapComplete(JSContext *cx, unsigned argc, jsval *vp) } } - if (argc > i) { + if (args.length() > i) { Value v = args[i]; if (v.isString()) { if (!fuzzingSafe) { @@ -935,7 +937,7 @@ DumpHeapComplete(JSContext *cx, unsigned argc, jsval *vp) } } - if (i != argc) { + if (i != args.length()) { JS_ReportError(cx, "bad arguments passed to dumpHeapComplete"); return false; } @@ -966,7 +968,7 @@ static bool EnableSPSProfilingAssertions(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc == 0 || !args[0].isBoolean()) { + if (!args.get(0).isBoolean()) { RootedObject arg(cx, &args.callee()); ReportUsageError(cx, arg, "Must have one boolean argument"); return false; @@ -1006,7 +1008,7 @@ static bool DisplayName(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc == 0 || !args[0].isObject() || !args[0].toObject().is()) { + if (!args.get(0).isObject() || !args[0].toObject().is()) { RootedObject arg(cx, &args.callee()); ReportUsageError(cx, arg, "Must have one function argument"); return false; @@ -1077,7 +1079,7 @@ SetObjectMetadataCallback(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - bool enabled = argc ? ToBoolean(args[0]) : false; + bool enabled = args.length() ? ToBoolean(args[0]) : false; SetObjectMetadataCallback(cx, enabled ? ShellObjectMetadataCallback : nullptr); args.rval().setUndefined(); @@ -1088,7 +1090,7 @@ static bool SetObjectMetadata(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc != 2 || !args[0].isObject() || !args[1].isObject()) { + if (args.length() != 2 || !args[0].isObject() || !args[1].isObject()) { JS_ReportError(cx, "Both arguments must be objects"); return false; } @@ -1104,7 +1106,7 @@ static bool GetObjectMetadata(JSContext *cx, unsigned argc, jsval *vp) { CallArgs args = CallArgsFromVp(argc, vp); - if (argc != 1 || !args[0].isObject()) { + if (args.length() != 1 || !args[0].isObject()) { JS_ReportError(cx, "Argument must be an object"); return false; } diff --git a/js/src/builtin/TypedObject.cpp b/js/src/builtin/TypedObject.cpp index 646a9561793d..76c84174f3e3 100644 --- a/js/src/builtin/TypedObject.cpp +++ b/js/src/builtin/TypedObject.cpp @@ -2651,7 +2651,7 @@ bool js::SetTypedObjectOffset(ThreadSafeContext *, unsigned argc, Value *vp) { CallArgs args = CallArgsFromVp(argc, vp); - JS_ASSERT(argc == 2); + JS_ASSERT(args.length() == 2); JS_ASSERT(args[0].isObject() && args[0].toObject().is()); JS_ASSERT(args[1].isInt32());