diff --git a/js/public/CallArgs.h b/js/public/CallArgs.h index 16f8d6f904c1..b06fc21397c9 100644 --- a/js/public/CallArgs.h +++ b/js/public/CallArgs.h @@ -112,7 +112,7 @@ class MOZ_STACK_CLASS NoUsedRval { }; template -class MOZ_STACK_CLASS CallArgsBase { +class MOZ_STACK_CLASS MOZ_NON_PARAM CallArgsBase { static_assert(std::is_same_v || std::is_same_v, "WantUsedRval can only be IncludeUsedRval or NoUsedRval"); @@ -294,7 +294,7 @@ class MOZ_STACK_CLASS CallArgsBase { } // namespace detail -class MOZ_STACK_CLASS CallArgs +class MOZ_STACK_CLASS MOZ_NON_PARAM CallArgs : public detail::CallArgsBase { private: friend CallArgs CallArgsFromVp(unsigned argc, Value* vp); diff --git a/js/public/CallNonGenericMethod.h b/js/public/CallNonGenericMethod.h index 80359f7a6ffe..73613260b9dc 100644 --- a/js/public/CallNonGenericMethod.h +++ b/js/public/CallNonGenericMethod.h @@ -60,7 +60,7 @@ extern JS_PUBLIC_API bool CallMethodIfWrapped(JSContext* cx, // its interface is the same as that of JSNative. // // static bool -// answer_getAnswer_impl(JSContext* cx, JS::CallArgs args) +// answer_getAnswer_impl(JSContext* cx, const JS::CallArgs& args) // { // args.rval().setInt32(42); // return true; diff --git a/js/public/experimental/JitInfo.h b/js/public/experimental/JitInfo.h index 1b070021bd12..9e64e3b807c9 100644 --- a/js/public/experimental/JitInfo.h +++ b/js/public/experimental/JitInfo.h @@ -8,6 +8,7 @@ #define js_experimental_JitInfo_h #include "mozilla/Assertions.h" // MOZ_ASSERT +#include "mozilla/Attributes.h" // MOZ_NON_PARAM #include // size_t #include // uint16_t, uint32_t @@ -72,7 +73,7 @@ struct JSJitMethodCallArgsTraits; * A class, expected to be passed by reference, which represents the CallArgs * for a JSJitMethodOp. */ -class JSJitMethodCallArgs +class MOZ_NON_PARAM JSJitMethodCallArgs : protected JS::detail::CallArgsBase { private: using Base = JS::detail::CallArgsBase; diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 77c3ae5f0968..a4d0c1507499 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -1602,7 +1602,8 @@ JS_PUBLIC_API bool JS::ToPrimitive(JSContext* cx, HandleObject obj, JSType hint, return ToPrimitiveSlow(cx, hint, vp); } -JS_PUBLIC_API bool JS::GetFirstArgumentAsTypeHint(JSContext* cx, CallArgs args, +JS_PUBLIC_API bool JS::GetFirstArgumentAsTypeHint(JSContext* cx, + const CallArgs& args, JSType* result) { if (!args.get(0).isString()) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 3597e5258240..7fe58c250fb9 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -303,7 +303,7 @@ extern JS_PUBLIC_API bool ToPrimitive(JSContext* cx, JS::HandleObject obj, * This can be useful in implementing a @@toPrimitive method. */ extern JS_PUBLIC_API bool GetFirstArgumentAsTypeHint(JSContext* cx, - CallArgs args, + const CallArgs& args, JSType* result); } /* namespace JS */ diff --git a/js/src/wasm/AsmJS.cpp b/js/src/wasm/AsmJS.cpp index 11a0c2b23d24..1e79880360c6 100644 --- a/js/src/wasm/AsmJS.cpp +++ b/js/src/wasm/AsmJS.cpp @@ -6914,8 +6914,8 @@ static bool GetImports(JSContext* cx, const AsmJSMetadata& metadata, return true; } -static bool TryInstantiate(JSContext* cx, CallArgs args, const Module& module, - const AsmJSMetadata& metadata, +static bool TryInstantiate(JSContext* cx, const CallArgs& args, + const Module& module, const AsmJSMetadata& metadata, MutableHandle instanceObj, MutableHandleObject exportObj) { HandleValue globalVal = args.get(0); @@ -6956,7 +6956,7 @@ static bool TryInstantiate(JSContext* cx, CallArgs args, const Module& module, return true; } -static bool HandleInstantiationFailure(JSContext* cx, CallArgs args, +static bool HandleInstantiationFailure(JSContext* cx, const CallArgs& args, const AsmJSMetadata& metadata) { using js::frontend::FunctionSyntaxKind; diff --git a/js/src/wasm/WasmInstance.cpp b/js/src/wasm/WasmInstance.cpp index 6fd624f1b3f4..b5b361ee501f 100644 --- a/js/src/wasm/WasmInstance.cpp +++ b/js/src/wasm/WasmInstance.cpp @@ -2938,7 +2938,8 @@ static bool EnsureEntryStubs(const Instance& instance, uint32_t funcIndex, } static bool GetInterpEntryAndEnsureStubs(JSContext* cx, Instance& instance, - uint32_t funcIndex, CallArgs args, + uint32_t funcIndex, + const CallArgs& args, void** interpEntry, const FuncType** funcType) { const FuncExport* funcExport; @@ -3100,8 +3101,8 @@ class MOZ_RAII ReturnToJSResultCollector { } }; -bool Instance::callExport(JSContext* cx, uint32_t funcIndex, CallArgs args, - CoercionLevel level) { +bool Instance::callExport(JSContext* cx, uint32_t funcIndex, + const CallArgs& args, CoercionLevel level) { if (memory0Base_) { // If there has been a moving grow, this Instance should have been notified. MOZ_RELEASE_ASSERT(memoryBase(0).unwrap() == memory0Base_); diff --git a/js/src/wasm/WasmInstance.h b/js/src/wasm/WasmInstance.h index 074c6212df68..0e4f9745b7c2 100644 --- a/js/src/wasm/WasmInstance.h +++ b/js/src/wasm/WasmInstance.h @@ -364,7 +364,7 @@ class alignas(16) Instance { // value in args.rval. [[nodiscard]] bool callExport(JSContext* cx, uint32_t funcIndex, - CallArgs args, + const CallArgs& args, CoercionLevel level = CoercionLevel::Spec); // Exception handling support diff --git a/js/src/wasm/WasmJS.cpp b/js/src/wasm/WasmJS.cpp index 1601fadd1b93..e1a6656d68dd 100644 --- a/js/src/wasm/WasmJS.cpp +++ b/js/src/wasm/WasmJS.cpp @@ -1005,8 +1005,9 @@ static bool IsModuleObject(JSObject* obj, const Module** module) { return true; } -static bool GetModuleArg(JSContext* cx, CallArgs args, uint32_t numRequired, - const char* name, const Module** module) { +static bool GetModuleArg(JSContext* cx, const CallArgs& args, + uint32_t numRequired, const char* name, + const Module** module) { if (!args.requireAtLeast(cx, name, numRequired)) { return false; } @@ -4499,8 +4500,8 @@ static bool EnsurePromiseSupport(JSContext* cx) { return true; } -static bool GetBufferSource(JSContext* cx, CallArgs callArgs, const char* name, - MutableBytes* bytecode) { +static bool GetBufferSource(JSContext* cx, const CallArgs& callArgs, + const char* name, MutableBytes* bytecode) { if (!callArgs.requireAtLeast(cx, name, 1)) { return false; } @@ -4561,7 +4562,7 @@ static bool WebAssembly_compile(JSContext* cx, unsigned argc, Value* vp) { return true; } -static bool GetInstantiateArgs(JSContext* cx, CallArgs callArgs, +static bool GetInstantiateArgs(JSContext* cx, const CallArgs& callArgs, MutableHandleObject firstArg, MutableHandleObject importObj, MutableHandleValue featureOptions) { @@ -5074,7 +5075,7 @@ const JSClass ResolveResponseClosure::class_ = { &ResolveResponseClosure::classOps_, }; -static ResolveResponseClosure* ToResolveResponseClosure(CallArgs args) { +static ResolveResponseClosure* ToResolveResponseClosure(const CallArgs& args) { return &args.callee() .as() .getExtendedSlot(0)