зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1303678. r=arai
--HG-- extra : rebase_source : d30077db8a0b524243a41e667de22ba0b963b2de
This commit is contained in:
Родитель
bc403f8efa
Коммит
5d99b819c6
|
@ -115,7 +115,7 @@ Instance::callImport(JSContext* cx, uint32_t funcImportIndex, unsigned argc, con
|
||||||
const FuncImport& fi = metadata().funcImports[funcImportIndex];
|
const FuncImport& fi = metadata().funcImports[funcImportIndex];
|
||||||
|
|
||||||
InvokeArgs args(cx);
|
InvokeArgs args(cx);
|
||||||
if (!args.init(argc))
|
if (!args.init(cx, argc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool hasI64Arg = false;
|
bool hasI64Arg = false;
|
||||||
|
|
|
@ -39,11 +39,7 @@ InitArgsFromArrayLike(JSContext* cx, HandleValue v, InvokeArgs* args)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Allocate space for the arguments.
|
// Allocate space for the arguments.
|
||||||
if (len > ARGS_LENGTH_MAX) {
|
if (!args->init(cx, len))
|
||||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TOO_MANY_FUN_APPLY_ARGS);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!args->init(len))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Steps 6-8.
|
// Steps 6-8.
|
||||||
|
|
|
@ -338,7 +338,7 @@ class NodeBuilder
|
||||||
template <typename... Arguments>
|
template <typename... Arguments>
|
||||||
MOZ_MUST_USE bool callback(HandleValue fun, Arguments&&... args) {
|
MOZ_MUST_USE bool callback(HandleValue fun, Arguments&&... args) {
|
||||||
InvokeArgs iargs(cx);
|
InvokeArgs iargs(cx);
|
||||||
if (!iargs.init(sizeof...(args) - 2 + size_t(saveLoc)))
|
if (!iargs.init(cx, sizeof...(args) - 2 + size_t(saveLoc)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return callbackHelper(fun, iargs, 0, Forward<Arguments>(args)...);
|
return callbackHelper(fun, iargs, 0, Forward<Arguments>(args)...);
|
||||||
|
|
|
@ -71,7 +71,7 @@ InvokeFunction(JSContext* cx, HandleObject obj, bool constructing, uint32_t argc
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstructArgs cargs(cx);
|
ConstructArgs cargs(cx);
|
||||||
if (!cargs.init(argc))
|
if (!cargs.init(cx, argc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < argc; i++)
|
for (uint32_t i = 0; i < argc; i++)
|
||||||
|
@ -102,7 +102,7 @@ InvokeFunction(JSContext* cx, HandleObject obj, bool constructing, uint32_t argc
|
||||||
}
|
}
|
||||||
|
|
||||||
InvokeArgs args(cx);
|
InvokeArgs args(cx);
|
||||||
if (!args.init(argc))
|
if (!args.init(cx, argc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (size_t i = 0; i < argc; i++)
|
for (size_t i = 0; i < argc; i++)
|
||||||
|
|
|
@ -143,7 +143,7 @@ MSG_DEF(JSMSG_DEPRECATED_USAGE, 1, JSEXN_REFERENCEERR, "deprecated {0} us
|
||||||
MSG_DEF(JSMSG_NOT_SCRIPTED_FUNCTION, 1, JSEXN_TYPEERR, "{0} is not a scripted function")
|
MSG_DEF(JSMSG_NOT_SCRIPTED_FUNCTION, 1, JSEXN_TYPEERR, "{0} is not a scripted function")
|
||||||
MSG_DEF(JSMSG_NO_REST_NAME, 0, JSEXN_SYNTAXERR, "no parameter name after ...")
|
MSG_DEF(JSMSG_NO_REST_NAME, 0, JSEXN_SYNTAXERR, "no parameter name after ...")
|
||||||
MSG_DEF(JSMSG_PARAMETER_AFTER_REST, 0, JSEXN_SYNTAXERR, "parameter after rest parameter")
|
MSG_DEF(JSMSG_PARAMETER_AFTER_REST, 0, JSEXN_SYNTAXERR, "parameter after rest parameter")
|
||||||
MSG_DEF(JSMSG_TOO_MANY_FUN_APPLY_ARGS, 0, JSEXN_RANGEERR, "arguments array passed to Function.prototype.apply is too large")
|
MSG_DEF(JSMSG_TOO_MANY_ARGUMENTS, 0, JSEXN_RANGEERR, "too many arguments provided for a function call")
|
||||||
|
|
||||||
// CSP
|
// CSP
|
||||||
MSG_DEF(JSMSG_CSP_BLOCKED_EVAL, 0, JSEXN_ERR, "call to eval() blocked by CSP")
|
MSG_DEF(JSMSG_CSP_BLOCKED_EVAL, 0, JSEXN_ERR, "call to eval() blocked by CSP")
|
||||||
|
|
|
@ -1239,7 +1239,7 @@ js::fun_call(JSContext* cx, unsigned argc, Value* vp)
|
||||||
argCount--; // strip off provided |this|
|
argCount--; // strip off provided |this|
|
||||||
|
|
||||||
InvokeArgs iargs(cx);
|
InvokeArgs iargs(cx);
|
||||||
if (!iargs.init(argCount))
|
if (!iargs.init(cx, argCount))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (size_t i = 0; i < argCount; i++)
|
for (size_t i = 0; i < argCount; i++)
|
||||||
|
@ -1279,7 +1279,7 @@ js::fun_apply(JSContext* cx, unsigned argc, Value* vp)
|
||||||
// Step 3-6.
|
// Step 3-6.
|
||||||
ScriptFrameIter iter(cx);
|
ScriptFrameIter iter(cx);
|
||||||
MOZ_ASSERT(iter.numActualArgs() <= ARGS_LENGTH_MAX);
|
MOZ_ASSERT(iter.numActualArgs() <= ARGS_LENGTH_MAX);
|
||||||
if (!args2.init(iter.numActualArgs()))
|
if (!args2.init(cx, iter.numActualArgs()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Steps 7-8.
|
// Steps 7-8.
|
||||||
|
@ -1300,13 +1300,10 @@ js::fun_apply(JSContext* cx, unsigned argc, Value* vp)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Step 6.
|
// Step 6.
|
||||||
if (length > ARGS_LENGTH_MAX) {
|
if (!args2.init(cx, length))
|
||||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TOO_MANY_FUN_APPLY_ARGS);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (!args2.init(length))
|
MOZ_ASSERT(length <= ARGS_LENGTH_MAX);
|
||||||
return false;
|
|
||||||
|
|
||||||
// Steps 7-8.
|
// Steps 7-8.
|
||||||
if (!GetElements(cx, aobj, length, args2.array()))
|
if (!GetElements(cx, aobj, length, args2.array()))
|
||||||
|
|
|
@ -368,7 +368,7 @@ CrossCompartmentWrapper::nativeCall(JSContext* cx, IsAcceptableThis test, Native
|
||||||
{
|
{
|
||||||
AutoCompartment call(cx, wrapped);
|
AutoCompartment call(cx, wrapped);
|
||||||
InvokeArgs dstArgs(cx);
|
InvokeArgs dstArgs(cx);
|
||||||
if (!dstArgs.init(srcArgs.length()))
|
if (!dstArgs.init(cx, srcArgs.length()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Value* src = srcArgs.base();
|
Value* src = srcArgs.base();
|
||||||
|
|
|
@ -1702,7 +1702,7 @@ CallMethodIfPresent(JSContext* cx, HandleObject obj, const char* name, size_t ar
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
InvokeArgs args(cx);
|
InvokeArgs args(cx);
|
||||||
if (!args.init(argc))
|
if (!args.init(cx, argc))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (size_t i = 0; i < argc; i++)
|
for (size_t i = 0; i < argc; i++)
|
||||||
|
@ -9954,7 +9954,7 @@ DebuggerObject::call(JSContext* cx, HandleDebuggerObject object, HandleValue thi
|
||||||
{
|
{
|
||||||
InvokeArgs invokeArgs(cx);
|
InvokeArgs invokeArgs(cx);
|
||||||
|
|
||||||
ok = invokeArgs.init(args2.length());
|
ok = invokeArgs.init(cx, args2.length());
|
||||||
if (ok) {
|
if (ok) {
|
||||||
for (size_t i = 0; i < args2.length(); ++i)
|
for (size_t i = 0; i < args2.length(); ++i)
|
||||||
invokeArgs[i].set(args2[i]);
|
invokeArgs[i].set(args2[i]);
|
||||||
|
|
|
@ -4735,6 +4735,8 @@ js::SpreadCallOperation(JSContext* cx, HandleScript script, jsbytecode* pc, Hand
|
||||||
JSOp op = JSOp(*pc);
|
JSOp op = JSOp(*pc);
|
||||||
bool constructing = op == JSOP_SPREADNEW || op == JSOP_SPREADSUPERCALL;
|
bool constructing = op == JSOP_SPREADNEW || op == JSOP_SPREADSUPERCALL;
|
||||||
|
|
||||||
|
// {Construct,Invoke}Args::init does this too, but this gives us a better
|
||||||
|
// error message.
|
||||||
if (length > ARGS_LENGTH_MAX) {
|
if (length > ARGS_LENGTH_MAX) {
|
||||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
|
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
|
||||||
constructing ? JSMSG_TOO_MANY_CON_SPREADARGS
|
constructing ? JSMSG_TOO_MANY_CON_SPREADARGS
|
||||||
|
@ -4770,7 +4772,7 @@ js::SpreadCallOperation(JSContext* cx, HandleScript script, jsbytecode* pc, Hand
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ConstructArgs cargs(cx);
|
ConstructArgs cargs(cx);
|
||||||
if (!cargs.init(length))
|
if (!cargs.init(cx, length))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!GetElements(cx, aobj, length, cargs.array()))
|
if (!GetElements(cx, aobj, length, cargs.array()))
|
||||||
|
@ -4782,7 +4784,7 @@ js::SpreadCallOperation(JSContext* cx, HandleScript script, jsbytecode* pc, Hand
|
||||||
res.setObject(*obj);
|
res.setObject(*obj);
|
||||||
} else {
|
} else {
|
||||||
InvokeArgs args(cx);
|
InvokeArgs args(cx);
|
||||||
if (!args.init(length))
|
if (!args.init(cx, length))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!GetElements(cx, aobj, length, args.array()))
|
if (!GetElements(cx, aobj, length, args.array()))
|
||||||
|
|
|
@ -214,7 +214,7 @@ intrinsic_UnsafeCallWrappedFunction(JSContext* cx, unsigned argc, Value* vp)
|
||||||
MOZ_RELEASE_ASSERT(fun->as<JSFunction>().isSelfHostedOrIntrinsic());
|
MOZ_RELEASE_ASSERT(fun->as<JSFunction>().isSelfHostedOrIntrinsic());
|
||||||
|
|
||||||
InvokeArgs args2(cx);
|
InvokeArgs args2(cx);
|
||||||
if (!args2.init(args.length() - 2))
|
if (!args2.init(cx, args.length() - 2))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
args2.setThis(args[1]);
|
args2.setThis(args[1]);
|
||||||
|
@ -1715,7 +1715,7 @@ CallSelfHostedNonGenericMethod(JSContext* cx, const CallArgs& args)
|
||||||
MOZ_ASSERT(selfHostedFun.toObject().is<JSFunction>());
|
MOZ_ASSERT(selfHostedFun.toObject().is<JSFunction>());
|
||||||
|
|
||||||
InvokeArgs args2(cx);
|
InvokeArgs args2(cx);
|
||||||
if (!args2.init(args.length() - 1))
|
if (!args2.init(cx, args.length() - 1))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (size_t i = 0; i < args.length() - 1; i++)
|
for (size_t i = 0; i < args.length() - 1; i++)
|
||||||
|
@ -1914,7 +1914,7 @@ intrinsic_ConstructFunction(JSContext* cx, unsigned argc, Value* vp)
|
||||||
RootedArrayObject argsList(cx, &args[2].toObject().as<ArrayObject>());
|
RootedArrayObject argsList(cx, &args[2].toObject().as<ArrayObject>());
|
||||||
uint32_t len = argsList->length();
|
uint32_t len = argsList->length();
|
||||||
ConstructArgs constructArgs(cx);
|
ConstructArgs constructArgs(cx);
|
||||||
if (!constructArgs.init(len))
|
if (!constructArgs.init(cx, len))
|
||||||
return false;
|
return false;
|
||||||
for (uint32_t index = 0; index < len; index++)
|
for (uint32_t index = 0; index < len; index++)
|
||||||
constructArgs[index].set(argsList->getDenseElement(index));
|
constructArgs[index].set(argsList->getDenseElement(index));
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "jit/Registers.h" // for RegisterDump
|
#include "jit/Registers.h" // for RegisterDump
|
||||||
#endif
|
#endif
|
||||||
#include "js/RootingAPI.h"
|
#include "js/RootingAPI.h"
|
||||||
|
#include "vm/ArgumentsObject.h"
|
||||||
#include "vm/SavedFrame.h"
|
#include "vm/SavedFrame.h"
|
||||||
|
|
||||||
struct JSCompartment;
|
struct JSCompartment;
|
||||||
|
@ -35,7 +36,6 @@ class AutoEntryMonitor;
|
||||||
|
|
||||||
namespace js {
|
namespace js {
|
||||||
|
|
||||||
class ArgumentsObject;
|
|
||||||
class InterpreterRegs;
|
class InterpreterRegs;
|
||||||
class CallObject;
|
class CallObject;
|
||||||
class FrameIter;
|
class FrameIter;
|
||||||
|
@ -948,7 +948,12 @@ class GenericArgsBase
|
||||||
explicit GenericArgsBase(JSContext* cx) : v_(cx) {}
|
explicit GenericArgsBase(JSContext* cx) : v_(cx) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool init(unsigned argc) {
|
bool init(JSContext* cx, unsigned argc) {
|
||||||
|
if (argc > ARGS_LENGTH_MAX) {
|
||||||
|
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_TOO_MANY_ARGUMENTS);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// callee, this, arguments[, new.target iff constructing]
|
// callee, this, arguments[, new.target iff constructing]
|
||||||
size_t len = 2 + argc + uint32_t(Construct);
|
size_t len = 2 + argc + uint32_t(Construct);
|
||||||
MOZ_ASSERT(len > argc); // no overflow
|
MOZ_ASSERT(len > argc); // no overflow
|
||||||
|
@ -968,6 +973,8 @@ template <MaybeConstruct Construct, size_t N>
|
||||||
class FixedArgsBase
|
class FixedArgsBase
|
||||||
: public mozilla::Conditional<Construct, AnyConstructArgs, AnyInvokeArgs>::Type
|
: public mozilla::Conditional<Construct, AnyConstructArgs, AnyInvokeArgs>::Type
|
||||||
{
|
{
|
||||||
|
static_assert(N <= ARGS_LENGTH_MAX, "o/~ too many args o/~");
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
JS::AutoValueArray<2 + N + uint32_t(Construct)> v_;
|
JS::AutoValueArray<2 + N + uint32_t(Construct)> v_;
|
||||||
|
|
||||||
|
@ -1024,7 +1031,7 @@ inline bool
|
||||||
FillArgumentsFromArraylike(JSContext* cx, Args& args, const Arraylike& arraylike)
|
FillArgumentsFromArraylike(JSContext* cx, Args& args, const Arraylike& arraylike)
|
||||||
{
|
{
|
||||||
uint32_t len = arraylike.length();
|
uint32_t len = arraylike.length();
|
||||||
if (!args.init(len))
|
if (!args.init(cx, len))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < len; i++)
|
for (uint32_t i = 0; i < len; i++)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче