summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/src/jsopcodeinlines.h1
-rw-r--r--js/src/vm/Interpreter.cpp10
-rw-r--r--js/src/vm/Opcodes.h16
3 files changed, 23 insertions, 4 deletions
diff --git a/js/src/jsopcodeinlines.h b/js/src/jsopcodeinlines.h
index b7c1011079..a516df3a69 100644
--- a/js/src/jsopcodeinlines.h
+++ b/js/src/jsopcodeinlines.h
@@ -22,6 +22,7 @@ GetDefCount(JSScript* script, unsigned offset)
* in the pushed array of stack values for type inference.
*/
switch (JSOp(*pc)) {
+ case JSOP_COALESCE:
case JSOP_OR:
case JSOP_AND:
return 1;
diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp
index 93542e4d7d..56f715e2be 100644
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -2128,6 +2128,16 @@ CASE(JSOP_IFNE)
}
END_CASE(JSOP_IFNE)
+CASE(JSOP_COALESCE)
+{
+ MutableHandleValue res = REGS.stackHandleAt(-1);
+ bool cond = !res.isNullOrUndefined();
+ if (cond) {
+ ADVANCE_AND_DISPATCH(GET_JUMP_OFFSET(REGS.pc));
+ }
+}
+END_CASE(JSOP_COALESCE)
+
CASE(JSOP_OR)
{
bool cond = ToBoolean(REGS.stackHandleAt(-1));
diff --git a/js/src/vm/Opcodes.h b/js/src/vm/Opcodes.h
index 58b5d75776..8328dfc994 100644
--- a/js/src/vm/Opcodes.h
+++ b/js/src/vm/Opcodes.h
@@ -2315,7 +2315,7 @@
* Operands:
* Stack: =>
*/ \
- macro(JSOP_JUMPTARGET, 230, "jumptarget", NULL, 1, 0, 0, JOF_BYTE)\
+ macro(JSOP_JUMPTARGET, 230, "jumptarget", NULL, 1, 0, 0, JOF_BYTE) \
/*
* Like JSOP_CALL, but tells the function that the return value is ignored.
* stack.
@@ -2325,14 +2325,22 @@
* Stack: callee, this, args[0], ..., args[argc-1] => rval
* nuses: (argc+2)
*/ \
- macro(JSOP_CALL_IGNORES_RV, 231, "call-ignores-rv", NULL, 3, -1, 1, JOF_UINT16|JOF_INVOKE|JOF_TYPESET)
-
+ macro(JSOP_CALL_IGNORES_RV, 231, "call-ignores-rv", NULL, 3, -1, 1, JOF_UINT16|JOF_INVOKE|JOF_TYPESET) \
+ /*
+ * If the value on top of the stack is not null or undefined, jumps to a 32-bit offset from the
+ * current bytecode.
+ *
+ * Category: Statements
+ * Type: Jumps
+ * Operands: int32_t offset
+ * Stack: cond => cond
+ */ \
+ macro(JSOP_COALESCE, 232, "coalesce", NULL, 5, 1, 1, JOF_JUMP|JOF_DETECTING)
/*
* In certain circumstances it may be useful to "pad out" the opcode space to
* a power of two. Use this macro to do so.
*/
#define FOR_EACH_TRAILING_UNUSED_OPCODE(macro) \
- macro(232) \
macro(233) \
macro(234) \
macro(235) \