diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index 35a4d74755c..2daf9afccff 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -6148,7 +6148,7 @@ BytecodeEmitter::emitCallOrNew(ParseNode* pn) return false; } if (pn->pn_xflags & PNX_SETCALL) { - if (!emit1(JSOP_SETCALL)) + if (!emitUint16Operand(JSOP_THROWMSG, JSMSG_BAD_LEFTSIDE_OF_ASS)) return false; } return true; diff --git a/js/src/jit/BaselineCompiler.cpp b/js/src/jit/BaselineCompiler.cpp index 9d7d59362cc..13baa43c20c 100644 --- a/js/src/jit/BaselineCompiler.cpp +++ b/js/src/jit/BaselineCompiler.cpp @@ -2901,14 +2901,15 @@ BaselineCompiler::emit_JSOP_TYPEOFEXPR() return emit_JSOP_TYPEOF(); } -typedef bool (*SetCallFn)(JSContext*); -static const VMFunction SetCallInfo = FunctionInfo(js::SetCallOperation); +typedef bool (*ThrowMsgFn)(JSContext*, const unsigned); +static const VMFunction ThrowMsgInfo = FunctionInfo(js::ThrowMsgOperation); bool -BaselineCompiler::emit_JSOP_SETCALL() +BaselineCompiler::emit_JSOP_THROWMSG() { prepareVMCall(); - return callVM(SetCallInfo); + pushArg(Imm32(GET_UINT16(pc))); + return callVM(ThrowMsgInfo); } typedef bool (*ThrowFn)(JSContext*, HandleValue); diff --git a/js/src/jit/BaselineCompiler.h b/js/src/jit/BaselineCompiler.h index 0cbf37ef204..ddc9646d428 100644 --- a/js/src/jit/BaselineCompiler.h +++ b/js/src/jit/BaselineCompiler.h @@ -163,7 +163,7 @@ namespace jit { _(JSOP_INSTANCEOF) \ _(JSOP_TYPEOF) \ _(JSOP_TYPEOFEXPR) \ - _(JSOP_SETCALL) \ + _(JSOP_THROWMSG) \ _(JSOP_THROW) \ _(JSOP_THROWING) \ _(JSOP_TRY) \ diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 13b31416feb..e48dfb37b1f 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -2923,12 +2923,12 @@ CASE(JSOP_FUNCALL) ADVANCE_AND_DISPATCH(0); } -CASE(JSOP_SETCALL) +CASE(JSOP_THROWMSG) { - JS_ALWAYS_FALSE(SetCallOperation(cx)); + JS_ALWAYS_FALSE(ThrowMsgOperation(cx, GET_UINT16(REGS.pc))); goto error; } -END_CASE(JSOP_SETCALL) +END_CASE(JSOP_THROWMSG) CASE(JSOP_IMPLICITTHIS) CASE(JSOP_GIMPLICITTHIS) @@ -4133,9 +4133,9 @@ js::DefFunOperation(JSContext* cx, HandleScript script, HandleObject scopeChain, } bool -js::SetCallOperation(JSContext* cx) +js::ThrowMsgOperation(JSContext* cx, const unsigned errorNum) { - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_BAD_LEFTSIDE_OF_ASS); + JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, errorNum); return false; } diff --git a/js/src/vm/Interpreter.h b/js/src/vm/Interpreter.h index a436e043d02..b5e54b19a62 100644 --- a/js/src/vm/Interpreter.h +++ b/js/src/vm/Interpreter.h @@ -399,7 +399,7 @@ bool DefFunOperation(JSContext* cx, HandleScript script, HandleObject scopeChain, HandleFunction funArg); bool -SetCallOperation(JSContext* cx); +ThrowMsgOperation(JSContext* cx, const unsigned errorNum); bool GetAndClearException(JSContext* cx, MutableHandleValue res); diff --git a/js/src/vm/Opcodes.h b/js/src/vm/Opcodes.h index 54f87f0bc4e..ab078b940d7 100644 --- a/js/src/vm/Opcodes.h +++ b/js/src/vm/Opcodes.h @@ -677,15 +677,16 @@ macro(JSOP_STRICTNE, 73, "strictne", "!==", 1, 2, 1, JOF_BYTE|JOF_DETECTING|JOF_LEFTASSOC|JOF_ARITH) \ \ /* - * Sometimes web pages do 'o.Item(i) = j'. This is not an early SyntaxError, - * for web compatibility. Instead we emit JSOP_SETCALL after the function - * call, an opcode that always throws. + * Sometimes we know when emitting that an operation will always throw. + * + * Throws the indicated JSMSG. + * * Category: Statements - * Type: Function - * Operands: + * Type: Exceptions + * Operands: uint16_t msgNumber * Stack: => */ \ - macro(JSOP_SETCALL, 74, "setcall", NULL, 1, 0, 0, JOF_BYTE) \ + macro(JSOP_THROWMSG, 74, "throwmsg", NULL, 3, 0, 0, JOF_UINT16) \ \ /* * Sets up a for-in or for-each-in loop using the JSITER_* flag bits in diff --git a/js/src/vm/Xdr.h b/js/src/vm/Xdr.h index 964ed8d83a7..c8585dc3c80 100644 --- a/js/src/vm/Xdr.h +++ b/js/src/vm/Xdr.h @@ -29,7 +29,7 @@ namespace js { * * https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode */ -static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 272; +static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 273; static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND);