mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 981053: Always pass CallArgs by reference. r=nbp
Differential Revision: https://phabricator.services.mozilla.com/D204745
This commit is contained in:
parent
38c0d95f10
commit
04ffa03589
@ -112,7 +112,7 @@ class MOZ_STACK_CLASS NoUsedRval {
|
||||
};
|
||||
|
||||
template <class WantUsedRval>
|
||||
class MOZ_STACK_CLASS CallArgsBase {
|
||||
class MOZ_STACK_CLASS MOZ_NON_PARAM CallArgsBase {
|
||||
static_assert(std::is_same_v<WantUsedRval, IncludeUsedRval> ||
|
||||
std::is_same_v<WantUsedRval, NoUsedRval>,
|
||||
"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<detail::IncludeUsedRval> {
|
||||
private:
|
||||
friend CallArgs CallArgsFromVp(unsigned argc, Value* vp);
|
||||
|
@ -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;
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define js_experimental_JitInfo_h
|
||||
|
||||
#include "mozilla/Assertions.h" // MOZ_ASSERT
|
||||
#include "mozilla/Attributes.h" // MOZ_NON_PARAM
|
||||
|
||||
#include <stddef.h> // size_t
|
||||
#include <stdint.h> // 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<JS::detail::NoUsedRval> {
|
||||
private:
|
||||
using Base = JS::detail::CallArgsBase<JS::detail::NoUsedRval>;
|
||||
|
@ -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,
|
||||
|
@ -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 */
|
||||
|
@ -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<WasmInstanceObject*> 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;
|
||||
|
||||
|
@ -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_);
|
||||
|
@ -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
|
||||
|
@ -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<JSFunction>()
|
||||
.getExtendedSlot(0)
|
||||
|
Loading…
Reference in New Issue
Block a user