Bug 975373 - IonMonkey: Use MutableHandleValue for out-parameter in vm calls, r=h4writer

This commit is contained in:
Romain Perier 2014-02-24 16:39:28 +01:00
parent 04f515d1c1
commit 5d175cd7e5
9 changed files with 54 additions and 49 deletions

View File

@ -636,10 +636,9 @@ js::regexp_exec(JSContext *cx, unsigned argc, Value *vp)
/* Separate interface for use by IonMonkey. */
bool
js::regexp_exec_raw(JSContext *cx, HandleObject regexp, HandleString input, Value *vp)
js::regexp_exec_raw(JSContext *cx, HandleObject regexp, HandleString input, MutableHandleValue output)
{
MutableHandleValue vpHandle = MutableHandleValue::fromMarkedLocation(vp);
return regexp_exec_impl(cx, regexp, input, UpdateRegExpStatics, vpHandle);
return regexp_exec_impl(cx, regexp, input, UpdateRegExpStatics, output);
}
bool

View File

@ -45,7 +45,7 @@ CreateRegExpMatchResult(JSContext *cx, HandleString input, const MatchPairs &mat
MutableHandleValue rval);
extern bool
regexp_exec_raw(JSContext *cx, HandleObject regexp, HandleString input, Value *vp);
regexp_exec_raw(JSContext *cx, HandleObject regexp, HandleString input, MutableHandleValue output);
extern bool
regexp_exec(JSContext *cx, unsigned argc, Value *vp);

View File

@ -2481,23 +2481,23 @@ DoBinaryArithFallback(JSContext *cx, BaselineFrame *frame, ICBinaryArith_Fallbac
switch(op) {
case JSOP_ADD:
// Do an add.
if (!AddValues(cx, &lhsCopy, &rhsCopy, ret.address()))
if (!AddValues(cx, &lhsCopy, &rhsCopy, ret))
return false;
break;
case JSOP_SUB:
if (!SubValues(cx, &lhsCopy, &rhsCopy, ret.address()))
if (!SubValues(cx, &lhsCopy, &rhsCopy, ret))
return false;
break;
case JSOP_MUL:
if (!MulValues(cx, &lhsCopy, &rhsCopy, ret.address()))
if (!MulValues(cx, &lhsCopy, &rhsCopy, ret))
return false;
break;
case JSOP_DIV:
if (!DivValues(cx, &lhsCopy, &rhsCopy, ret.address()))
if (!DivValues(cx, &lhsCopy, &rhsCopy, ret))
return false;
break;
case JSOP_MOD:
if (!ModValues(cx, &lhsCopy, &rhsCopy, ret.address()))
if (!ModValues(cx, &lhsCopy, &rhsCopy, ret))
return false;
break;
case JSOP_BITOR: {
@ -2536,7 +2536,7 @@ DoBinaryArithFallback(JSContext *cx, BaselineFrame *frame, ICBinaryArith_Fallbac
break;
}
case JSOP_URSH: {
if (!UrshOperation(cx, lhs, rhs, ret.address()))
if (!UrshOperation(cx, lhs, rhs, ret))
return false;
break;
}

View File

@ -877,7 +877,7 @@ CodeGenerator::visitRegExp(LRegExp *lir)
}
typedef bool (*RegExpExecRawFn)(JSContext *cx, HandleObject regexp,
HandleString input, Value *vp);
HandleString input, MutableHandleValue output);
static const VMFunction RegExpExecRawInfo = FunctionInfo<RegExpExecRawFn>(regexp_exec_raw);
bool
@ -4366,8 +4366,8 @@ CodeGenerator::visitModD(LModD *ins)
return true;
}
typedef bool (*BinaryFn)(JSContext *, MutableHandleValue, MutableHandleValue, Value *);
typedef bool (*BinaryParFn)(ForkJoinContext *, HandleValue, HandleValue, Value *);
typedef bool (*BinaryFn)(JSContext *, MutableHandleValue, MutableHandleValue, MutableHandleValue);
typedef bool (*BinaryParFn)(ForkJoinContext *, HandleValue, HandleValue, MutableHandleValue);
static const VMFunction AddInfo = FunctionInfo<BinaryFn>(js::AddValues);
static const VMFunction SubInfo = FunctionInfo<BinaryFn>(js::SubValues);

View File

@ -541,7 +541,7 @@ jit::BitRshPar(ForkJoinContext *cx, HandleValue lhs, HandleValue rhs, int32_t *o
bool
jit::UrshValuesPar(ForkJoinContext *cx, HandleValue lhs, HandleValue rhs,
Value *out)
MutableHandleValue out)
{
uint32_t left;
int32_t right;
@ -550,7 +550,7 @@ jit::UrshValuesPar(ForkJoinContext *cx, HandleValue lhs, HandleValue rhs,
if (!NonObjectToUint32(cx, lhs, &left) || !NonObjectToInt32(cx, rhs, &right))
return false;
left >>= right & 31;
out->setNumber(uint32_t(left));
out.setNumber(uint32_t(left));
return true;
}

View File

@ -63,7 +63,7 @@ bool BitAndPar(ForkJoinContext *cx, HandleValue lhs, HandleValue rhs, int32_t *o
bool BitLshPar(ForkJoinContext *cx, HandleValue lhs, HandleValue rhs, int32_t *out);
bool BitRshPar(ForkJoinContext *cx, HandleValue lhs, HandleValue rhs, int32_t *out);
bool UrshValuesPar(ForkJoinContext *cx, HandleValue lhs, HandleValue rhs, Value *out);
bool UrshValuesPar(ForkJoinContext *cx, HandleValue lhs, HandleValue rhs, MutableHandleValue out);
// Make a new rest parameter in parallel.
JSObject *InitRestParameterPar(ForkJoinContext *cx, uint32_t length, Value *rest,

View File

@ -622,14 +622,14 @@ BitRsh(JSContext *cx, HandleValue lhs, HandleValue rhs, int *out)
}
static MOZ_ALWAYS_INLINE bool
UrshOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, Value *out)
UrshOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, MutableHandleValue out)
{
uint32_t left;
int32_t right;
if (!ToUint32(cx, lhs, &left) || !ToInt32(cx, rhs, &right))
return false;
left >>= right & 31;
out->setNumber(uint32_t(left));
out.setNumber(uint32_t(left));
return true;
}

View File

@ -1204,13 +1204,13 @@ ComputeImplicitThis(JSContext *cx, HandleObject obj, MutableHandleValue vp)
}
static MOZ_ALWAYS_INLINE bool
AddOperation(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res)
AddOperation(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res)
{
if (lhs.isInt32() && rhs.isInt32()) {
int32_t l = lhs.toInt32(), r = rhs.toInt32();
int32_t t;
if (MOZ_LIKELY(SafeAdd(l, r, &t))) {
res->setInt32(t);
res.setInt32(t);
return true;
}
}
@ -1247,55 +1247,55 @@ AddOperation(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Valu
if (!str)
return false;
}
res->setString(str);
res.setString(str);
} else {
double l, r;
if (!ToNumber(cx, lhs, &l) || !ToNumber(cx, rhs, &r))
return false;
res->setNumber(l + r);
res.setNumber(l + r);
}
return true;
}
static MOZ_ALWAYS_INLINE bool
SubOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, Value *res)
SubOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, MutableHandleValue res)
{
double d1, d2;
if (!ToNumber(cx, lhs, &d1) || !ToNumber(cx, rhs, &d2))
return false;
res->setNumber(d1 - d2);
res.setNumber(d1 - d2);
return true;
}
static MOZ_ALWAYS_INLINE bool
MulOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, Value *res)
MulOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, MutableHandleValue res)
{
double d1, d2;
if (!ToNumber(cx, lhs, &d1) || !ToNumber(cx, rhs, &d2))
return false;
res->setNumber(d1 * d2);
res.setNumber(d1 * d2);
return true;
}
static MOZ_ALWAYS_INLINE bool
DivOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, Value *res)
DivOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, MutableHandleValue res)
{
double d1, d2;
if (!ToNumber(cx, lhs, &d1) || !ToNumber(cx, rhs, &d2))
return false;
res->setNumber(NumberDiv(d1, d2));
res.setNumber(NumberDiv(d1, d2));
return true;
}
static MOZ_ALWAYS_INLINE bool
ModOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, Value *res)
ModOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, MutableHandleValue res)
{
int32_t l, r;
if (lhs.isInt32() && rhs.isInt32() &&
(l = lhs.toInt32()) >= 0 && (r = rhs.toInt32()) > 0) {
int32_t mod = l % r;
res->setInt32(mod);
res.setInt32(mod);
return true;
}
@ -1303,7 +1303,7 @@ ModOperation(JSContext *cx, HandleValue lhs, HandleValue rhs, Value *res)
if (!ToNumber(cx, lhs, &d1) || !ToNumber(cx, rhs, &d2))
return false;
res->setNumber(NumberMod(d1, d2));
res.setNumber(NumberMod(d1, d2));
return true;
}
@ -2199,7 +2199,8 @@ CASE(JSOP_URSH)
{
HandleValue lval = REGS.stackHandleAt(-2);
HandleValue rval = REGS.stackHandleAt(-1);
if (!UrshOperation(cx, lval, rval, &REGS.sp[-2]))
MutableHandleValue res = REGS.stackHandleAt(-2);
if (!UrshOperation(cx, lval, rval, res))
goto error;
REGS.sp--;
}
@ -2209,7 +2210,8 @@ CASE(JSOP_ADD)
{
MutableHandleValue lval = REGS.stackHandleAt(-2);
MutableHandleValue rval = REGS.stackHandleAt(-1);
if (!AddOperation(cx, lval, rval, &REGS.sp[-2]))
MutableHandleValue res = REGS.stackHandleAt(-2);
if (!AddOperation(cx, lval, rval, res))
goto error;
REGS.sp--;
}
@ -2220,7 +2222,8 @@ CASE(JSOP_SUB)
RootedValue &lval = rootValue0, &rval = rootValue1;
lval = REGS.sp[-2];
rval = REGS.sp[-1];
if (!SubOperation(cx, lval, rval, &REGS.sp[-2]))
MutableHandleValue res = REGS.stackHandleAt(-2);
if (!SubOperation(cx, lval, rval, res))
goto error;
REGS.sp--;
}
@ -2231,7 +2234,8 @@ CASE(JSOP_MUL)
RootedValue &lval = rootValue0, &rval = rootValue1;
lval = REGS.sp[-2];
rval = REGS.sp[-1];
if (!MulOperation(cx, lval, rval, &REGS.sp[-2]))
MutableHandleValue res = REGS.stackHandleAt(-2);
if (!MulOperation(cx, lval, rval, res))
goto error;
REGS.sp--;
}
@ -2242,7 +2246,8 @@ CASE(JSOP_DIV)
RootedValue &lval = rootValue0, &rval = rootValue1;
lval = REGS.sp[-2];
rval = REGS.sp[-1];
if (!DivOperation(cx, lval, rval, &REGS.sp[-2]))
MutableHandleValue res = REGS.stackHandleAt(-2);
if (!DivOperation(cx, lval, rval, res))
goto error;
REGS.sp--;
}
@ -2253,7 +2258,8 @@ CASE(JSOP_MOD)
RootedValue &lval = rootValue0, &rval = rootValue1;
lval = REGS.sp[-2];
rval = REGS.sp[-1];
if (!ModOperation(cx, lval, rval, &REGS.sp[-2]))
MutableHandleValue res = REGS.stackHandleAt(-2);
if (!ModOperation(cx, lval, rval, res))
goto error;
REGS.sp--;
}
@ -3826,37 +3832,37 @@ js::InitElementArray(JSContext *cx, jsbytecode *pc, HandleObject obj, uint32_t i
}
bool
js::AddValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res)
js::AddValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res)
{
return AddOperation(cx, lhs, rhs, res);
}
bool
js::SubValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res)
js::SubValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res)
{
return SubOperation(cx, lhs, rhs, res);
}
bool
js::MulValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res)
js::MulValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res)
{
return MulOperation(cx, lhs, rhs, res);
}
bool
js::DivValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res)
js::DivValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res)
{
return DivOperation(cx, lhs, rhs, res);
}
bool
js::ModValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res)
js::ModValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res)
{
return ModOperation(cx, lhs, rhs, res);
}
bool
js::UrshValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res)
js::UrshValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res)
{
return UrshOperation(cx, lhs, rhs, res);
}

View File

@ -388,22 +388,22 @@ InitElementArray(JSContext *cx, jsbytecode *pc,
HandleObject obj, uint32_t index, HandleValue value);
bool
AddValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res);
AddValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res);
bool
SubValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res);
SubValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res);
bool
MulValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res);
MulValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res);
bool
DivValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res);
DivValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res);
bool
ModValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res);
ModValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res);
bool
UrshValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, Value *res);
UrshValues(JSContext *cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue res);
template <bool strict>
bool