mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 01:08:39 +09:00
Issue #1240 - Part 5e - BigInt bitwise operators. https://bugzilla.mozilla.org/show_bug.cgi?id=1490387
This commit is contained in:
parent
20b52c9e2e
commit
03734326e8
8 changed files with 197 additions and 130 deletions
|
|
@ -10306,7 +10306,7 @@ CodeGenerator::visitThrow(LThrow* lir)
|
|||
callVM(ThrowInfoCodeGen, lir);
|
||||
}
|
||||
|
||||
typedef bool (*BitNotFn)(JSContext*, HandleValue, int* p);
|
||||
typedef bool (*BitNotFn)(JSContext*, MutableHandleValue, MutableHandleValue);
|
||||
static const VMFunction BitNotInfo = FunctionInfo<BitNotFn>(BitNot, "BitNot");
|
||||
|
||||
void
|
||||
|
|
@ -10316,7 +10316,7 @@ CodeGenerator::visitBitNotV(LBitNotV* lir)
|
|||
callVM(BitNotInfo, lir);
|
||||
}
|
||||
|
||||
typedef bool (*BitopFn)(JSContext*, HandleValue, HandleValue, int* p);
|
||||
typedef bool (*BitopFn)(JSContext*, MutableHandleValue, MutableHandleValue, MutableHandleValue);
|
||||
static const VMFunction BitAndInfo = FunctionInfo<BitopFn>(BitAnd, "BitAnd");
|
||||
static const VMFunction BitOrInfo = FunctionInfo<BitopFn>(BitOr, "BitOr");
|
||||
static const VMFunction BitXorInfo = FunctionInfo<BitopFn>(BitXor, "BitXor");
|
||||
|
|
|
|||
|
|
@ -2849,6 +2849,7 @@ MBinaryBitwiseInstruction::infer(BaselineInspector*, jsbytecode*)
|
|||
getOperand(1)->mightBeType(MIRType::Object) || getOperand(1)->mightBeType(MIRType::Symbol))
|
||||
{
|
||||
specialization_ = MIRType::None;
|
||||
setResultType(MIRType::Value);
|
||||
} else {
|
||||
specializeAs(MIRType::Int32);
|
||||
}
|
||||
|
|
@ -2858,9 +2859,10 @@ void
|
|||
MBinaryBitwiseInstruction::specializeAs(MIRType type)
|
||||
{
|
||||
MOZ_ASSERT(type == MIRType::Int32 || type == MIRType::Int64);
|
||||
MOZ_ASSERT(this->type() == type);
|
||||
MOZ_ASSERT(this->type() == MIRType::Value || this->type() == type);
|
||||
|
||||
specialization_ = type;
|
||||
setResultType(type);
|
||||
|
||||
if (isBitOr() || isBitAnd() || isBitXor())
|
||||
setCommutative();
|
||||
|
|
@ -2871,9 +2873,13 @@ MShiftInstruction::infer(BaselineInspector*, jsbytecode*)
|
|||
{
|
||||
if (getOperand(0)->mightBeType(MIRType::Object) || getOperand(1)->mightBeType(MIRType::Object) ||
|
||||
getOperand(0)->mightBeType(MIRType::Symbol) || getOperand(1)->mightBeType(MIRType::Symbol))
|
||||
{
|
||||
specialization_ = MIRType::None;
|
||||
else
|
||||
setResultType(MIRType::Value);
|
||||
} else {
|
||||
specialization_ = MIRType::Int32;
|
||||
setResultType(MIRType::Int32);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -3828,7 +3834,7 @@ MBitNot::NewInt32(TempAllocator& alloc, MDefinition* input)
|
|||
{
|
||||
MBitNot* ins = new(alloc) MBitNot(input);
|
||||
ins->specialization_ = MIRType::Int32;
|
||||
MOZ_ASSERT(ins->type() == MIRType::Int32);
|
||||
ins->setResultType(MIRType::Int32);
|
||||
return ins;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5701,7 +5701,7 @@ class MBitNot
|
|||
: MUnaryInstruction(input)
|
||||
{
|
||||
specialization_ = MIRType::None;
|
||||
setResultType(MIRType::Int32);
|
||||
setResultType(MIRType::Value);
|
||||
setMovable();
|
||||
}
|
||||
|
||||
|
|
@ -5861,7 +5861,7 @@ class MBinaryBitwiseInstruction
|
|||
maskMatchesRightRange(false)
|
||||
{
|
||||
MOZ_ASSERT(type == MIRType::Int32 || type == MIRType::Int64);
|
||||
setResultType(type);
|
||||
setResultType(MIRType::Value);
|
||||
setMovable();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,13 +164,13 @@ bool
|
|||
RBitNot::recover(JSContext* cx, SnapshotIterator& iter) const
|
||||
{
|
||||
RootedValue operand(cx, iter.read());
|
||||
RootedValue result(cx);
|
||||
|
||||
int32_t result;
|
||||
if (!js::BitNot(cx, operand, &result))
|
||||
if (!js::BitNot(cx, &operand, &result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedValue rootedResult(cx, js::Int32Value(result));
|
||||
iter.storeInstructionResult(rootedResult);
|
||||
iter.storeInstructionResult(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -190,14 +190,14 @@ RBitAnd::recover(JSContext* cx, SnapshotIterator& iter) const
|
|||
{
|
||||
RootedValue lhs(cx, iter.read());
|
||||
RootedValue rhs(cx, iter.read());
|
||||
int32_t result;
|
||||
RootedValue result(cx);
|
||||
MOZ_ASSERT(!lhs.isObject() && !rhs.isObject());
|
||||
|
||||
if (!js::BitAnd(cx, lhs, rhs, &result))
|
||||
if (!js::BitAnd(cx, &lhs, &rhs, &result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedValue rootedResult(cx, js::Int32Value(result));
|
||||
iter.storeInstructionResult(rootedResult);
|
||||
iter.storeInstructionResult(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -217,14 +217,14 @@ RBitOr::recover(JSContext* cx, SnapshotIterator& iter) const
|
|||
{
|
||||
RootedValue lhs(cx, iter.read());
|
||||
RootedValue rhs(cx, iter.read());
|
||||
int32_t result;
|
||||
RootedValue result(cx);
|
||||
MOZ_ASSERT(!lhs.isObject() && !rhs.isObject());
|
||||
|
||||
if (!js::BitOr(cx, lhs, rhs, &result))
|
||||
if (!js::BitOr(cx, &lhs, &rhs, &result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedValue asValue(cx, js::Int32Value(result));
|
||||
iter.storeInstructionResult(asValue);
|
||||
iter.storeInstructionResult(result);;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -244,13 +244,13 @@ RBitXor::recover(JSContext* cx, SnapshotIterator& iter) const
|
|||
{
|
||||
RootedValue lhs(cx, iter.read());
|
||||
RootedValue rhs(cx, iter.read());
|
||||
RootedValue result(cx);
|
||||
|
||||
int32_t result;
|
||||
if (!js::BitXor(cx, lhs, rhs, &result))
|
||||
if (!js::BitXor(cx, &lhs, &rhs, &result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedValue rootedResult(cx, js::Int32Value(result));
|
||||
iter.storeInstructionResult(rootedResult);
|
||||
iter.storeInstructionResult(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -270,14 +270,14 @@ RLsh::recover(JSContext* cx, SnapshotIterator& iter) const
|
|||
{
|
||||
RootedValue lhs(cx, iter.read());
|
||||
RootedValue rhs(cx, iter.read());
|
||||
int32_t result;
|
||||
RootedValue result(cx);
|
||||
MOZ_ASSERT(!lhs.isObject() && !rhs.isObject());
|
||||
|
||||
if (!js::BitLsh(cx, lhs, rhs, &result))
|
||||
if (!js::BitLsh(cx, &lhs, &rhs, &result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedValue asValue(cx, js::Int32Value(result));
|
||||
iter.storeInstructionResult(asValue);
|
||||
iter.storeInstructionResult(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -297,14 +297,14 @@ RRsh::recover(JSContext* cx, SnapshotIterator& iter) const
|
|||
{
|
||||
RootedValue lhs(cx, iter.read());
|
||||
RootedValue rhs(cx, iter.read());
|
||||
RootedValue result(cx);
|
||||
MOZ_ASSERT(!lhs.isObject() && !rhs.isObject());
|
||||
|
||||
int32_t result;
|
||||
if (!js::BitRsh(cx, lhs, rhs, &result))
|
||||
if (!js::BitRsh(cx, &lhs, &rhs, &result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedValue rootedResult(cx, js::Int32Value(result));
|
||||
iter.storeInstructionResult(rootedResult);
|
||||
iter.storeInstructionResult(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -327,8 +327,9 @@ RUrsh::recover(JSContext* cx, SnapshotIterator& iter) const
|
|||
MOZ_ASSERT(!lhs.isObject() && !rhs.isObject());
|
||||
|
||||
RootedValue result(cx);
|
||||
if (!js::UrshOperation(cx, lhs, rhs, &result))
|
||||
if (!js::UrshOperation(cx, &lhs, &rhs, &result)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
iter.storeInstructionResult(result);
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -946,43 +946,39 @@ DoBinaryArithFallback(JSContext* cx, void* payload, ICBinaryArith_Fallback* stub
|
|||
return false;
|
||||
break;
|
||||
case JSOP_BITOR: {
|
||||
int32_t result;
|
||||
if (!BitOr(cx, lhs, rhs, &result))
|
||||
if (!BitOr(cx, &lhsCopy, &rhsCopy, ret)) {
|
||||
return false;
|
||||
ret.setInt32(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JSOP_BITXOR: {
|
||||
int32_t result;
|
||||
if (!BitXor(cx, lhs, rhs, &result))
|
||||
if (!BitXor(cx, &lhsCopy, &rhsCopy, ret)) {
|
||||
return false;
|
||||
ret.setInt32(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JSOP_BITAND: {
|
||||
int32_t result;
|
||||
if (!BitAnd(cx, lhs, rhs, &result))
|
||||
if (!BitAnd(cx, &lhsCopy, &rhsCopy, ret)) {
|
||||
return false;
|
||||
ret.setInt32(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JSOP_LSH: {
|
||||
int32_t result;
|
||||
if (!BitLsh(cx, lhs, rhs, &result))
|
||||
if (!BitLsh(cx, &lhsCopy, &rhsCopy, ret)) {
|
||||
return false;
|
||||
ret.setInt32(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JSOP_RSH: {
|
||||
int32_t result;
|
||||
if (!BitRsh(cx, lhs, rhs, &result))
|
||||
if (!BitRsh(cx, &lhsCopy, &rhsCopy, ret)) {
|
||||
return false;
|
||||
ret.setInt32(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JSOP_URSH: {
|
||||
if (!UrshOperation(cx, lhs, rhs, ret))
|
||||
if (!UrshOperation(cx, &lhsCopy, &rhsCopy, ret)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
@ -1475,10 +1471,10 @@ DoUnaryArithFallback(JSContext* cx, void* payload, ICUnaryArith_Fallback* stub_,
|
|||
|
||||
switch (op) {
|
||||
case JSOP_BITNOT: {
|
||||
int32_t result;
|
||||
if (!BitNot(cx, val, &result))
|
||||
RootedValue valCopy(cx, val);
|
||||
if (!BitNot(cx, &valCopy, res)) {
|
||||
return false;
|
||||
res.setInt32(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case JSOP_NEG: {
|
||||
|
|
|
|||
|
|
@ -3211,7 +3211,7 @@ class LBitNotI : public LInstructionHelper<1, 1, 0>
|
|||
};
|
||||
|
||||
// Call a VM function to perform a BITNOT operation.
|
||||
class LBitNotV : public LCallInstructionHelper<1, BOX_PIECES, 0>
|
||||
class LBitNotV : public LCallInstructionHelper<BOX_PIECES, BOX_PIECES, 0>
|
||||
{
|
||||
public:
|
||||
LIR_HEADER(BitNotV)
|
||||
|
|
@ -3271,7 +3271,7 @@ class LBitOpI64 : public LInstructionHelper<INT64_PIECES, 2 * INT64_PIECES, 0>
|
|||
};
|
||||
|
||||
// Call a VM function to perform a bitwise operation.
|
||||
class LBitOpV : public LCallInstructionHelper<1, 2 * BOX_PIECES, 0>
|
||||
class LBitOpV : public LCallInstructionHelper<BOX_PIECES, 2 * BOX_PIECES, 0>
|
||||
{
|
||||
JSOp jsop_;
|
||||
|
||||
|
|
|
|||
|
|
@ -708,72 +708,113 @@ GreaterThanOrEqualOperation(JSContext* cx, MutableHandleValue lhs, MutableHandle
|
|||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
BitNot(JSContext* cx, HandleValue in, int* out)
|
||||
BitNot(JSContext* cx, MutableHandleValue in, MutableHandleValue out)
|
||||
{
|
||||
int i;
|
||||
if (!ToInt32(cx, in, &i))
|
||||
if (!ToInt32OrBigInt(cx, in)) {
|
||||
return false;
|
||||
*out = ~i;
|
||||
}
|
||||
|
||||
if (in.isBigInt()) {
|
||||
return BigInt::bitNot(cx, in, out);
|
||||
}
|
||||
|
||||
out.setInt32(~in.toInt32());
|
||||
return true;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
BitXor(JSContext* cx, HandleValue lhs, HandleValue rhs, int* out)
|
||||
BitXor(JSContext* cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue out)
|
||||
{
|
||||
int left, right;
|
||||
if (!ToInt32(cx, lhs, &left) || !ToInt32(cx, rhs, &right))
|
||||
if (!ToInt32OrBigInt(cx, lhs) || !ToInt32OrBigInt(cx, rhs)) {
|
||||
return false;
|
||||
*out = left ^ right;
|
||||
}
|
||||
|
||||
if (lhs.isBigInt() || rhs.isBigInt()) {
|
||||
return BigInt::bitXor(cx, lhs, rhs, out);
|
||||
}
|
||||
|
||||
out.setInt32(lhs.toInt32() ^ rhs.toInt32());
|
||||
return true;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
BitOr(JSContext* cx, HandleValue lhs, HandleValue rhs, int* out)
|
||||
BitOr(JSContext* cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue out)
|
||||
{
|
||||
int left, right;
|
||||
if (!ToInt32(cx, lhs, &left) || !ToInt32(cx, rhs, &right))
|
||||
if (!ToInt32OrBigInt(cx, lhs) || !ToInt32OrBigInt(cx, rhs)) {
|
||||
return false;
|
||||
*out = left | right;
|
||||
}
|
||||
|
||||
if (lhs.isBigInt() || rhs.isBigInt()) {
|
||||
return BigInt::bitOr(cx, lhs, rhs, out);
|
||||
}
|
||||
|
||||
out.setInt32(lhs.toInt32() | rhs.toInt32());
|
||||
return true;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
BitAnd(JSContext* cx, HandleValue lhs, HandleValue rhs, int* out)
|
||||
BitAnd(JSContext* cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue out)
|
||||
{
|
||||
int left, right;
|
||||
if (!ToInt32(cx, lhs, &left) || !ToInt32(cx, rhs, &right))
|
||||
if (!ToInt32OrBigInt(cx, lhs) || !ToInt32OrBigInt(cx, rhs)) {
|
||||
return false;
|
||||
*out = left & right;
|
||||
}
|
||||
|
||||
if (lhs.isBigInt() || rhs.isBigInt()) {
|
||||
return BigInt::bitAnd(cx, lhs, rhs, out);
|
||||
}
|
||||
|
||||
out.setInt32(lhs.toInt32() & rhs.toInt32());
|
||||
return true;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
BitLsh(JSContext* cx, HandleValue lhs, HandleValue rhs, int* out)
|
||||
BitLsh(JSContext* cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue out)
|
||||
{
|
||||
int32_t left, right;
|
||||
if (!ToInt32(cx, lhs, &left) || !ToInt32(cx, rhs, &right))
|
||||
if (!ToInt32OrBigInt(cx, lhs) || !ToInt32OrBigInt(cx, rhs)) {
|
||||
return false;
|
||||
*out = uint32_t(left) << (right & 31);
|
||||
}
|
||||
|
||||
if (lhs.isBigInt() || rhs.isBigInt()) {
|
||||
return BigInt::lsh(cx, lhs, rhs, out);
|
||||
}
|
||||
|
||||
out.setInt32(lhs.toInt32() << (rhs.toInt32() & 31));
|
||||
return true;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
BitRsh(JSContext* cx, HandleValue lhs, HandleValue rhs, int* out)
|
||||
BitRsh(JSContext* cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue out)
|
||||
{
|
||||
int32_t left, right;
|
||||
if (!ToInt32(cx, lhs, &left) || !ToInt32(cx, rhs, &right))
|
||||
if (!ToInt32OrBigInt(cx, lhs) || !ToInt32OrBigInt(cx, rhs)) {
|
||||
return false;
|
||||
*out = left >> (right & 31);
|
||||
}
|
||||
|
||||
if (lhs.isBigInt() || rhs.isBigInt()) {
|
||||
return BigInt::rsh(cx, lhs, rhs, out);
|
||||
}
|
||||
|
||||
out.setInt32(lhs.toInt32() >> (rhs.toInt32() & 31));
|
||||
return true;
|
||||
}
|
||||
|
||||
static MOZ_ALWAYS_INLINE bool
|
||||
UrshOperation(JSContext* cx, HandleValue lhs, HandleValue rhs, MutableHandleValue out)
|
||||
UrshOperation(JSContext* cx, MutableHandleValue lhs, MutableHandleValue rhs, MutableHandleValue out)
|
||||
{
|
||||
if (!ToNumeric(cx, lhs) || !ToNumeric(cx, rhs)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lhs.isBigInt() || rhs.isBigInt()) {
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
|
||||
JSMSG_BIGINT_TO_NUMBER);
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t left;
|
||||
int32_t right;
|
||||
if (!ToUint32(cx, lhs, &left) || !ToInt32(cx, rhs, &right))
|
||||
int32_t right;
|
||||
if (!ToUint32(cx, lhs, &left) || !ToInt32(cx, rhs, &right)) {
|
||||
return false;
|
||||
}
|
||||
left >>= right & 31;
|
||||
out.setNumber(uint32_t(left));
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -2178,32 +2178,42 @@ CASE(JSOP_BINDVAR)
|
|||
}
|
||||
END_CASE(JSOP_BINDVAR)
|
||||
|
||||
#define BITWISE_OP(OP) \
|
||||
JS_BEGIN_MACRO \
|
||||
int32_t i, j; \
|
||||
if (!ToInt32(cx, REGS.stackHandleAt(-2), &i)) \
|
||||
goto error; \
|
||||
if (!ToInt32(cx, REGS.stackHandleAt(-1), &j)) \
|
||||
goto error; \
|
||||
i = i OP j; \
|
||||
REGS.sp--; \
|
||||
REGS.sp[-1].setInt32(i); \
|
||||
JS_END_MACRO
|
||||
|
||||
CASE(JSOP_BITOR)
|
||||
BITWISE_OP(|);
|
||||
{
|
||||
MutableHandleValue lhs = REGS.stackHandleAt(-2);
|
||||
MutableHandleValue rhs = REGS.stackHandleAt(-1);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-2);
|
||||
if (!BitOr(cx, lhs, rhs, res)) {
|
||||
goto error;
|
||||
}
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_BITOR)
|
||||
|
||||
CASE(JSOP_BITXOR)
|
||||
BITWISE_OP(^);
|
||||
{
|
||||
MutableHandleValue lhs = REGS.stackHandleAt(-2);
|
||||
MutableHandleValue rhs = REGS.stackHandleAt(-1);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-2);
|
||||
if (!BitXor(cx, lhs, rhs, res)) {
|
||||
goto error;
|
||||
}
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_BITXOR)
|
||||
|
||||
CASE(JSOP_BITAND)
|
||||
BITWISE_OP(&);
|
||||
{
|
||||
MutableHandleValue lhs = REGS.stackHandleAt(-2);
|
||||
MutableHandleValue rhs = REGS.stackHandleAt(-1);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-2);
|
||||
if (!BitAnd(cx, lhs, rhs, res)) {
|
||||
goto error;
|
||||
}
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_BITAND)
|
||||
|
||||
#undef BITWISE_OP
|
||||
|
||||
CASE(JSOP_EQ)
|
||||
if (!LooseEqualityOp<true>(cx, REGS))
|
||||
goto error;
|
||||
|
|
@ -2259,8 +2269,9 @@ CASE(JSOP_LT)
|
|||
bool cond;
|
||||
MutableHandleValue lval = REGS.stackHandleAt(-2);
|
||||
MutableHandleValue rval = REGS.stackHandleAt(-1);
|
||||
if (!LessThanOperation(cx, lval, rval, &cond))
|
||||
if (!LessThanOperation(cx, lval, rval, &cond)) {
|
||||
goto error;
|
||||
}
|
||||
TRY_BRANCH_AFTER_COND(cond, 2);
|
||||
REGS.sp[-2].setBoolean(cond);
|
||||
REGS.sp--;
|
||||
|
|
@ -2272,8 +2283,9 @@ CASE(JSOP_LE)
|
|||
bool cond;
|
||||
MutableHandleValue lval = REGS.stackHandleAt(-2);
|
||||
MutableHandleValue rval = REGS.stackHandleAt(-1);
|
||||
if (!LessThanOrEqualOperation(cx, lval, rval, &cond))
|
||||
if (!LessThanOrEqualOperation(cx, lval, rval, &cond)) {
|
||||
goto error;
|
||||
}
|
||||
TRY_BRANCH_AFTER_COND(cond, 2);
|
||||
REGS.sp[-2].setBoolean(cond);
|
||||
REGS.sp--;
|
||||
|
|
@ -2285,8 +2297,9 @@ CASE(JSOP_GT)
|
|||
bool cond;
|
||||
MutableHandleValue lval = REGS.stackHandleAt(-2);
|
||||
MutableHandleValue rval = REGS.stackHandleAt(-1);
|
||||
if (!GreaterThanOperation(cx, lval, rval, &cond))
|
||||
if (!GreaterThanOperation(cx, lval, rval, &cond)) {
|
||||
goto error;
|
||||
}
|
||||
TRY_BRANCH_AFTER_COND(cond, 2);
|
||||
REGS.sp[-2].setBoolean(cond);
|
||||
REGS.sp--;
|
||||
|
|
@ -2298,43 +2311,47 @@ CASE(JSOP_GE)
|
|||
bool cond;
|
||||
MutableHandleValue lval = REGS.stackHandleAt(-2);
|
||||
MutableHandleValue rval = REGS.stackHandleAt(-1);
|
||||
if (!GreaterThanOrEqualOperation(cx, lval, rval, &cond))
|
||||
if (!GreaterThanOrEqualOperation(cx, lval, rval, &cond)) {
|
||||
goto error;
|
||||
}
|
||||
TRY_BRANCH_AFTER_COND(cond, 2);
|
||||
REGS.sp[-2].setBoolean(cond);
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_GE)
|
||||
|
||||
#define SIGNED_SHIFT_OP(OP) \
|
||||
JS_BEGIN_MACRO \
|
||||
int32_t i, j; \
|
||||
if (!ToInt32(cx, REGS.stackHandleAt(-2), &i)) \
|
||||
goto error; \
|
||||
if (!ToInt32(cx, REGS.stackHandleAt(-1), &j)) \
|
||||
goto error; \
|
||||
i = i OP (j & 31); \
|
||||
REGS.sp--; \
|
||||
REGS.sp[-1].setInt32(i); \
|
||||
JS_END_MACRO
|
||||
|
||||
CASE(JSOP_LSH)
|
||||
SIGNED_SHIFT_OP(<<);
|
||||
{
|
||||
MutableHandleValue lhs = REGS.stackHandleAt(-2);
|
||||
MutableHandleValue rhs = REGS.stackHandleAt(-1);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-2);
|
||||
if (!BitLsh(cx, lhs, rhs, res)) {
|
||||
goto error;
|
||||
}
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_LSH)
|
||||
|
||||
CASE(JSOP_RSH)
|
||||
SIGNED_SHIFT_OP(>>);
|
||||
{
|
||||
MutableHandleValue lhs = REGS.stackHandleAt(-2);
|
||||
MutableHandleValue rhs = REGS.stackHandleAt(-1);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-2);
|
||||
if (!BitRsh(cx, lhs, rhs, res)) {
|
||||
goto error;
|
||||
}
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_RSH)
|
||||
|
||||
#undef SIGNED_SHIFT_OP
|
||||
|
||||
CASE(JSOP_URSH)
|
||||
{
|
||||
HandleValue lval = REGS.stackHandleAt(-2);
|
||||
HandleValue rval = REGS.stackHandleAt(-1);
|
||||
MutableHandleValue lhs = REGS.stackHandleAt(-2);
|
||||
MutableHandleValue rhs = REGS.stackHandleAt(-1);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-2);
|
||||
if (!UrshOperation(cx, lval, rval, res))
|
||||
if (!UrshOperation(cx, lhs, rhs, res)) {
|
||||
goto error;
|
||||
}
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_URSH)
|
||||
|
|
@ -2344,8 +2361,9 @@ CASE(JSOP_ADD)
|
|||
MutableHandleValue lval = REGS.stackHandleAt(-2);
|
||||
MutableHandleValue rval = REGS.stackHandleAt(-1);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-2);
|
||||
if (!AddOperation(cx, lval, rval, res))
|
||||
if (!AddOperation(cx, lval, rval, res)) {
|
||||
goto error;
|
||||
}
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_ADD)
|
||||
|
|
@ -2355,8 +2373,9 @@ CASE(JSOP_SUB)
|
|||
ReservedRooted<Value> lval(&rootValue0, REGS.sp[-2]);
|
||||
ReservedRooted<Value> rval(&rootValue1, REGS.sp[-1]);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-2);
|
||||
if (!SubOperation(cx, &lval, &rval, res))
|
||||
if (!SubOperation(cx, &lval, &rval, res)) {
|
||||
goto error;
|
||||
}
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_SUB)
|
||||
|
|
@ -2366,8 +2385,9 @@ CASE(JSOP_MUL)
|
|||
ReservedRooted<Value> lval(&rootValue0, REGS.sp[-2]);
|
||||
ReservedRooted<Value> rval(&rootValue1, REGS.sp[-1]);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-2);
|
||||
if (!MulOperation(cx, &lval, &rval, res))
|
||||
if (!MulOperation(cx, &lval, &rval, res)) {
|
||||
goto error;
|
||||
}
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_MUL)
|
||||
|
|
@ -2377,8 +2397,9 @@ CASE(JSOP_DIV)
|
|||
ReservedRooted<Value> lval(&rootValue0, REGS.sp[-2]);
|
||||
ReservedRooted<Value> rval(&rootValue1, REGS.sp[-1]);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-2);
|
||||
if (!DivOperation(cx, &lval, &rval, res))
|
||||
if (!DivOperation(cx, &lval, &rval, res)) {
|
||||
goto error;
|
||||
}
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_DIV)
|
||||
|
|
@ -2388,8 +2409,9 @@ CASE(JSOP_MOD)
|
|||
ReservedRooted<Value> lval(&rootValue0, REGS.sp[-2]);
|
||||
ReservedRooted<Value> rval(&rootValue1, REGS.sp[-1]);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-2);
|
||||
if (!ModOperation(cx, &lval, &rval, res))
|
||||
if (!ModOperation(cx, &lval, &rval, res)) {
|
||||
goto error;
|
||||
}
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_MOD)
|
||||
|
|
@ -2399,8 +2421,9 @@ CASE(JSOP_POW)
|
|||
ReservedRooted<Value> lval(&rootValue0, REGS.sp[-2]);
|
||||
ReservedRooted<Value> rval(&rootValue1, REGS.sp[-1]);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-2);
|
||||
if (!PowOperation(cx, &lval, &rval, res))
|
||||
if (!PowOperation(cx, &lval, &rval, res)) {
|
||||
goto error;
|
||||
}
|
||||
REGS.sp--;
|
||||
}
|
||||
END_CASE(JSOP_POW)
|
||||
|
|
@ -2415,11 +2438,11 @@ END_CASE(JSOP_NOT)
|
|||
|
||||
CASE(JSOP_BITNOT)
|
||||
{
|
||||
int32_t i;
|
||||
HandleValue value = REGS.stackHandleAt(-1);
|
||||
if (!BitNot(cx, value, &i))
|
||||
MutableHandleValue value = REGS.stackHandleAt(-1);
|
||||
MutableHandleValue res = REGS.stackHandleAt(-1);
|
||||
if (!BitNot(cx, value, res)) {
|
||||
goto error;
|
||||
REGS.sp[-1].setInt32(i);
|
||||
}
|
||||
}
|
||||
END_CASE(JSOP_BITNOT)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue