tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Opcodes.h (143735B)


      1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * vim: set ts=8 sw=2 et tw=0 ft=c:
      3 *
      4 * This Source Code Form is subject to the terms of the Mozilla Public
      5 * License, v. 2.0. If a copy of the MPL was not distributed with this
      6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      7 
      8 #ifndef vm_Opcodes_h
      9 #define vm_Opcodes_h
     10 
     11 #include <stddef.h>
     12 #include <stdint.h>
     13 
     14 #include "js/TypeDecls.h"
     15 
     16 // clang-format off
     17 /*
     18 * [SMDOC] Bytecode Definitions
     19 *
     20 * SpiderMonkey bytecode instructions.
     21 *
     22 * To use this header, define a macro of the form:
     23 *
     24 *     #define MACRO(op, op_snake, token, length, nuses, ndefs, format) ...
     25 *
     26 * Then `FOR_EACH_OPCODE(MACRO)` invokes `MACRO` for every opcode.
     27 *
     28 * Field        Description
     29 * -----        -----------
     30 * op           UpperCamelCase form of opcode id
     31 * op_snake     snake_case form of opcode id
     32 * token        Pretty-printer string, or null if ugly
     33 * length       Number of bytes including any immediate operands
     34 * nuses        Number of stack slots consumed by bytecode, -1 if variadic
     35 * ndefs        Number of stack slots produced by bytecode
     36 * format       JOF_ flags describing instruction operand layout, etc.
     37 *
     38 * For more about `format`, see the comments on the `JOF_` constants defined in
     39 * BytecodeUtil.h.
     40 *
     41 *
     42 * [SMDOC] Bytecode Invariants
     43 *
     44 * Creating scripts that do not follow the rules can lead to undefined
     45 * behavior. Bytecode has many consumers, not just the interpreter: JITs,
     46 * analyses, the debugger. That's why the rules below apply even to code that
     47 * can't be reached in ordinary execution (such as code after an infinite loop
     48 * or inside an `if (false)` block).
     49 *
     50 * The `code()` of a script must be a packed (not aligned) sequence of valid
     51 * instructions from start to end. Each instruction has a single byte opcode
     52 * followed by a number of operand bytes based on the opcode.
     53 *
     54 * ## Jump instructions
     55 *
     56 * Operands named `offset`, `forwardOffset`, or `defaultOffset` are jump
     57 * offsets, the distance in bytes from the start of the current instruction to
     58 * the start of another instruction in the same script. Operands named
     59 * `forwardOffset` or `defaultOffset` must be positive.
     60 *
     61 * Forward jumps must jump to a `JSOp::JumpTarget` instruction.  Backward jumps,
     62 * indicated by negative offsets, must jump to a `JSOp::LoopHead` instruction.
     63 * Jump offsets can't be zero.
     64 *
     65 * Needless to say, scripts must not contain overlapping instruction sequences
     66 * (in the sense of <https://en.wikipedia.org/wiki/Overlapping_gene>).
     67 *
     68 * A script's `trynotes` and `scopeNotes` impose further constraints. Each try
     69 * note and each scope note marks a region of the bytecode where some invariant
     70 * holds, or some cleanup behavior is needed--that there's a for-in iterator in
     71 * a particular stack slot, for instance, which must be closed on error. All
     72 * paths into the span must establish that invariant. In practice, this means
     73 * other code never jumps into the span: the only way in is to execute the
     74 * bytecode instruction that sets up the invariant (in our example,
     75 * `JSOp::Iter`).
     76 *
     77 * If a script's `trynotes` (see "Try Notes" in JSScript.h) contain a
     78 * `JSTRY_CATCH` or `JSTRY_FINALLY` span, there must be a `JSOp::Try`
     79 * instruction immediately before the span and a `JSOp::JumpTarget immediately
     80 * after it. Instructions must not jump to this `JSOp::JumpTarget`. (The VM puts
     81 * us there on exception.) Furthermore, the instruction sequence immediately
     82 * following a `JSTRY_CATCH` span must read `JumpTarget; Exception` or, in
     83 * non-function scripts, `JumpTarget; Undefined; SetRval; Exception`. (These
     84 * instructions run with an exception pending; other instructions aren't
     85 * designed to handle that.)
     86 *
     87 * Unreachable instructions are allowed, but they have to follow all the rules.
     88 *
     89 * Control must not reach the end of a script. (Currently, the last instruction
     90 * is always JSOp::RetRval.)
     91 *
     92 * ## Other operands
     93 *
     94 * Operands named `nameIndex` or `atomIndex` (which appear on instructions that
     95 * have `JOF_ATOM` in the `format` field) must be valid indexes into
     96 * `script->atoms()`.
     97 *
     98 * Operands named `argc` (`JOF_ARGC`) are argument counts for call
     99 * instructions. `argc` must be small enough that the instruction's nuses is <=
    100 * the current stack depth (see "Stack depth" below).
    101 *
    102 * Operands named `argno` (`JOF_QARG`) refer to an argument of the current
    103 * function. `argno` must be in the range `0..script->function()->nargs()`.
    104 * Instructions with these operands must appear only in function scripts.
    105 *
    106 * Operands named `localno` (`JOF_LOCAL`) refer to a local variable stored in
    107 * the stack frame. `localno` must be in the range `0..script->nfixed()`.
    108 *
    109 * Operands named `resumeIndex` (`JOF_RESUMEINDEX`) refer to a resume point in
    110 * the current script. `resumeIndex` must be a valid index into
    111 * `script->resumeOffsets()`.
    112 *
    113 * Operands named `hops` and `slot` (`JOF_ENVCOORD`) refer a slot in an
    114 * `EnvironmentObject`. At run time, they must point to a fixed slot in an
    115 * object on the current environment chain. See `EnvironmentCoordinates`.
    116 *
    117 * Operands with the following names must be valid indexes into
    118 * `script->gcthings()`, and the pointer in the vector must point to the right
    119 * type of thing:
    120 *
    121 * -   `objectIndex` (`JOF_OBJECT`): `PlainObject*` or `ArrayObject*`
    122 * -   `baseobjIndex` (`JOF_OBJECT`): `PlainObject*`
    123 * -   `funcIndex` (`JOF_OBJECT`): `JSFunction*`
    124 * -   `regexpIndex` (`JOF_REGEXP`): `RegExpObject*`
    125 * -   `shapeIndex` (`JOF_SHAPE`): `Shape*`
    126 * -   `scopeIndex` (`JOF_SCOPE`): `Scope*`
    127 * -   `lexicalScopeIndex` (`JOF_SCOPE`): `LexicalScope*`
    128 * -   `classBodyScopeIndex` (`JOF_SCOPE`): `ClassBodyScope*`
    129 * -   `withScopeIndex` (`JOF_SCOPE`): `WithScope*`
    130 * -   `bigIntIndex` (`JOF_BIGINT`): `BigInt*`
    131 *
    132 * Operands named `icIndex` (`JOF_ICINDEX`) must be exactly the number of
    133 * preceding instructions in the script that have the JOF_IC flag.
    134 * (Rationale: Each JOF_IC instruction has a unique entry in
    135 * `script->jitScript()->icEntries()`.  At run time, in the bytecode
    136 * interpreter, we have to find that entry. We could store the IC index as an
    137 * operand to each JOF_IC instruction, but it's more memory-efficient to use a
    138 * counter and reset the counter to `icIndex` after each jump.)
    139 *
    140 * ## Stack depth
    141 *
    142 * Each instruction has a compile-time stack depth, the number of values on the
    143 * interpreter stack just before executing the instruction. It isn't explicitly
    144 * present in the bytecode itself, but (for reachable instructions, anyway)
    145 * it's a function of the bytecode.
    146 *
    147 * -   The first instruction has stack depth 0.
    148 *
    149 * -   Each successor of an instruction X has a stack depth equal to
    150 *
    151 *         X's stack depth - `js::StackUses(X)` + `js::StackDefs(X)`
    152 *
    153 *     except for `JSOp::Case` (below).
    154 *
    155 *     X's "successors" are: the next instruction in the script, if
    156 *     `js::FlowsIntoNext(op)` is true for X's opcode; one or more
    157 *     `JSOp::JumpTarget`s elsewhere, if X is a forward jump or
    158 *     `JSOp::TableSwitch`; and/or a `JSOp::LoopHead` if it's a backward jump.
    159 *
    160 * -   `JSOp::Case` is a special case because its stack behavior is eccentric.
    161 *     The formula above is correct for the next instruction. The jump target
    162 *     has a stack depth that is 1 less.
    163 *
    164 * -   The `JSOp::JumpTarget` instruction immediately following a `JSTRY_CATCH`
    165 *     or `JSTRY_FINALLY` span has the same stack depth as the `JSOp::Try`
    166 *     instruction that precedes the span.
    167 *
    168 *     Every instruction covered by the `JSTRY_CATCH` or `JSTRY_FINALLY` span
    169 *     must have a stack depth >= that value, so that error recovery is
    170 *     guaranteed to find enough values on the stack to resume there.
    171 *
    172 * -   `script->nslots() - script->nfixed()` must be >= the maximum stack
    173 *     depth of any instruction in `script`.  (The stack frame must be big
    174 *     enough to run the code.)
    175 *
    176 * `BytecodeParser::parse()` computes stack depths for every reachable
    177 * instruction in a script.
    178 *
    179 * ## Scopes and environments
    180 *
    181 * As with stack depth, each instruction has a static scope, which is a
    182 * compile-time characterization of the eventual run-time environment chain
    183 * when that instruction executes. Just as every instruction has a stack budget
    184 * (nuses/ndefs), every instruction either pushes a scope, pops a scope, or
    185 * neither. The same successor relation applies as above.
    186 *
    187 * Every scope used in a script is stored in the `JSScript::gcthings()` vector.
    188 * They can be accessed using `getScope(index)` if you know what `index` to
    189 * pass.
    190 *
    191 * The scope of every instruction (that's reachable via the successor relation)
    192 * is given in two independent ways: by the bytecode itself and by the scope
    193 * notes. The two sources must agree.
    194 *
    195 * ## Further rules
    196 *
    197 * All reachable instructions must be reachable without taking any backward
    198 * edges.
    199 *
    200 * Instructions with the `JOF_CHECKSLOPPY` flag must not be used in strict mode
    201 * code. `JOF_CHECKSTRICT` instructions must not be used in nonstrict code.
    202 *
    203 * Many instructions have their own additional rules. These are documented on
    204 * the various opcodes below (look for the word "must").
    205 */
    206 // clang-format on
    207 
    208 // clang-format off
    209 /*
    210 * SpiderMonkey bytecode categorization (as used in generated documentation):
    211 *
    212 * [Index]
    213 *   [Constants]
    214 *   [Expressions]
    215 *     Unary operators
    216 *     Binary operators
    217 *     Conversions
    218 *     Other expressions
    219 *   [Objects]
    220 *     Creating objects
    221 *     Defining properties
    222 *     Accessing properties
    223 *     Super
    224 *     Enumeration
    225 *     Iteration
    226 *     SetPrototype
    227 *     Array literals
    228 *     RegExp literals
    229 *     Built-in objects
    230 *   [Functions]
    231 *     Creating functions
    232 *     Creating constructors
    233 *     Calls
    234 *     Generators and async functions
    235 *   [Control flow]
    236 *     Jump targets
    237 *     Jumps
    238 *     Return
    239 *     Exceptions
    240 *   [Variables and scopes]
    241 *     Initialization
    242 *     Looking up bindings
    243 *     Getting binding values
    244 *     Setting binding values
    245 *     Entering and leaving environments
    246 *     Creating and deleting bindings
    247 *     Function environment setup
    248 *   [Stack operations]
    249 *   [Other]
    250 */
    251 // clang-format on
    252 
    253 // clang-format off
    254 #define FOR_EACH_OPCODE(MACRO) \
    255    /*
    256     * Push `undefined`.
    257     *
    258     *   Category: Constants
    259     *   Operands:
    260     *   Stack: => undefined
    261     */ \
    262    MACRO(Undefined, undefined, "", 1, 0, 1, JOF_BYTE) \
    263    /*
    264     * Push `null`.
    265     *
    266     *   Category: Constants
    267     *   Operands:
    268     *   Stack: => null
    269     */ \
    270    MACRO(Null, null, "null", 1, 0, 1, JOF_BYTE) \
    271    /*
    272     * Push a boolean constant.
    273     *
    274     *   Category: Constants
    275     *   Operands:
    276     *   Stack: => true/false
    277     */ \
    278    MACRO(False, false_, "false", 1, 0, 1, JOF_BYTE) \
    279    MACRO(True, true_, "true", 1, 0, 1, JOF_BYTE) \
    280    /*
    281     * Push the `int32_t` immediate operand as an `Int32Value`.
    282     *
    283     * `JSOp::Zero`, `JSOp::One`, `JSOp::Int8`, `JSOp::Uint16`, and `JSOp::Uint24`
    284     * are all compact encodings for `JSOp::Int32`.
    285     *
    286     *   Category: Constants
    287     *   Operands: int32_t val
    288     *   Stack: => val
    289     */ \
    290    MACRO(Int32, int32, NULL, 5, 0, 1, JOF_INT32) \
    291    /*
    292     * Push the number `0`.
    293     *
    294     *   Category: Constants
    295     *   Operands:
    296     *   Stack: => 0
    297     */ \
    298    MACRO(Zero, zero, "0", 1, 0, 1, JOF_BYTE) \
    299    /*
    300     * Push the number `1`.
    301     *
    302     *   Category: Constants
    303     *   Operands:
    304     *   Stack: => 1
    305     */ \
    306    MACRO(One, one, "1", 1, 0, 1, JOF_BYTE) \
    307    /*
    308     * Push the `int8_t` immediate operand as an `Int32Value`.
    309     *
    310     *   Category: Constants
    311     *   Operands: int8_t val
    312     *   Stack: => val
    313     */ \
    314    MACRO(Int8, int8, NULL, 2, 0, 1, JOF_INT8) \
    315    /*
    316     * Push the `uint16_t` immediate operand as an `Int32Value`.
    317     *
    318     *   Category: Constants
    319     *   Operands: uint16_t val
    320     *   Stack: => val
    321     */ \
    322    MACRO(Uint16, uint16, NULL, 3, 0, 1, JOF_UINT16) \
    323    /*
    324     * Push the `uint24_t` immediate operand as an `Int32Value`.
    325     *
    326     *   Category: Constants
    327     *   Operands: uint24_t val
    328     *   Stack: => val
    329     */ \
    330    MACRO(Uint24, uint24, NULL, 4, 0, 1, JOF_UINT24) \
    331    /*
    332     * Push the 64-bit floating-point immediate operand as a `DoubleValue`.
    333     *
    334     * If the operand is a NaN, it must be the canonical NaN (see
    335     * `JS::detail::CanonicalizeNaN`).
    336     *
    337     *   Category: Constants
    338     *   Operands: double val
    339     *   Stack: => val
    340     */ \
    341    MACRO(Double, double_, NULL, 9, 0, 1, JOF_DOUBLE) \
    342    /*
    343     * Push the BigInt constant `script->getBigInt(bigIntIndex)`.
    344     *
    345     *   Category: Constants
    346     *   Operands: uint32_t bigIntIndex
    347     *   Stack: => bigint
    348     */ \
    349    MACRO(BigInt, big_int, NULL, 5, 0, 1, JOF_BIGINT) \
    350    /*
    351     * Push the string constant `script->getAtom(atomIndex)`.
    352     *
    353     *   Category: Constants
    354     *   Operands: uint32_t atomIndex
    355     *   Stack: => string
    356     */ \
    357    MACRO(String, string, NULL, 5, 0, 1, JOF_STRING) \
    358    /*
    359     * Push a well-known symbol.
    360     *
    361     * `symbol` must be in range for `JS::SymbolCode`.
    362     *
    363     *   Category: Constants
    364     *   Operands: uint8_t symbol (the JS::SymbolCode of the symbol to use)
    365     *   Stack: => symbol
    366     */ \
    367    MACRO(Symbol, symbol, NULL, 2, 0, 1, JOF_UINT8) \
    368    /*
    369     * Pop the top value on the stack, discard it, and push `undefined`.
    370     *
    371     * Implements: [The `void` operator][1], step 3.
    372     *
    373     * [1]: https://tc39.es/ecma262/#sec-void-operator
    374     *
    375     *   Category: Expressions
    376     *   Type: Unary operators
    377     *   Operands:
    378     *   Stack: val => undefined
    379     */ \
    380    MACRO(Void, void_, NULL, 1, 1, 1, JOF_BYTE) \
    381    /*
    382     * [The `typeof` operator][1].
    383     *
    384     * Infallible. The result is always a string that depends on the [type][2]
    385     * of `val`.
    386     *
    387     * `JSOp::Typeof` and `JSOp::TypeofExpr` are the same except
    388     * that--amazingly--`JSOp::Typeof` affects the behavior of an immediately
    389     * *preceding* `JSOp::GetName` or `JSOp::GetGName` instruction! This is how
    390     * we implement [`typeof`][1] step 2, making `typeof nonExistingVariable`
    391     * return `"undefined"` instead of throwing a ReferenceError.
    392     *
    393     * In a global scope:
    394     *
    395     * -   `typeof x` compiles to `GetGName "x"; Typeof`.
    396     * -   `typeof (0, x)` compiles to `GetGName "x"; TypeofExpr`.
    397     *
    398     * Emitting the same bytecode for these two expressions would be a bug.
    399     * Per spec, the latter throws a ReferenceError if `x` doesn't exist.
    400     *
    401     * [1]: https://tc39.es/ecma262/#sec-typeof-operator
    402     * [2]: https://tc39.es/ecma262/#sec-ecmascript-language-types
    403     *
    404     *   Category: Expressions
    405     *   Type: Unary operators
    406     *   Operands:
    407     *   Stack: val => (typeof val)
    408     */ \
    409    MACRO(Typeof, typeof_, NULL, 1, 1, 1, JOF_BYTE|JOF_IC) \
    410    MACRO(TypeofExpr, typeof_expr, NULL, 1, 1, 1, JOF_BYTE|JOF_IC) \
    411    /*
    412     * A compound opcode for the following, where `val` is single identifier:
    413     *   * typeof val === "type"
    414     *   * typeof val !== "type"
    415     *   * typeof val > "u"      # minified `typeof val === "undefined"`
    416     *   * typeof val < "u"      # minified `typeof val !== "undefined"`
    417     *
    418     * Infallible. The result is always a boolean that depends on the type of
    419     * `val` and `"type"` string, and the comparison operator.
    420     *
    421     *   Category: Expressions
    422     *   Type: Other expressions
    423     *   Operands: TypeofEqOperand operand
    424     *   Stack: val => (typeof val CMP "type")
    425     */ \
    426    MACRO(TypeofEq, typeof_eq, NULL, 2, 1, 1, JOF_UINT8|JOF_IC) \
    427    /*
    428     * [The unary `+` operator][1].
    429     *
    430     * `+val` doesn't do any actual math. It just calls [ToNumber][2](val).
    431     *
    432     * The conversion can call `.toString()`/`.valueOf()` methods and can
    433     * throw. The result on success is always a Number. (Per spec, unary `-`
    434     * supports BigInts, but unary `+` does not.)
    435     *
    436     * [1]: https://tc39.es/ecma262/#sec-unary-plus-operator
    437     * [2]: https://tc39.es/ecma262/#sec-tonumber
    438     *
    439     *   Category: Expressions
    440     *   Type: Unary operators
    441     *   Operands:
    442     *   Stack: val => (+val)
    443     */ \
    444    MACRO(Pos, pos, "+ ", 1, 1, 1, JOF_BYTE|JOF_IC) \
    445    /*
    446     * [The unary `-` operator][1].
    447     *
    448     * Convert `val` to a numeric value, then push `-val`. The conversion can
    449     * call `.toString()`/`.valueOf()` methods and can throw. The result on
    450     * success is always numeric.
    451     *
    452     * [1]: https://tc39.es/ecma262/#sec-unary-minus-operator
    453     *
    454     *   Category: Expressions
    455     *   Type: Unary operators
    456     *   Operands:
    457     *   Stack: val => (-val)
    458     */ \
    459    MACRO(Neg, neg, "- ", 1, 1, 1, JOF_BYTE|JOF_IC) \
    460    /*
    461     * [The bitwise NOT operator][1] (`~`).
    462     *
    463     * `val` is converted to an integer, then bitwise negated. The conversion
    464     * can call `.toString()`/`.valueOf()` methods and can throw. The result on
    465     * success is always an Int32 or BigInt value.
    466     *
    467     * [1]: https://tc39.es/ecma262/#sec-bitwise-not-operator
    468     *
    469     *   Category: Expressions
    470     *   Type: Unary operators
    471     *   Operands:
    472     *   Stack: val => (~val)
    473     */ \
    474    MACRO(BitNot, bit_not, "~", 1, 1, 1, JOF_BYTE|JOF_IC) \
    475    /*
    476     * [The logical NOT operator][1] (`!`).
    477     *
    478     * `val` is first converted with [ToBoolean][2], then logically
    479     * negated. The result is always a boolean value. This does not call
    480     * user-defined methods and can't throw.
    481     *
    482     * [1]: https://tc39.es/ecma262/#sec-logical-not-operator
    483     * [2]: https://tc39.es/ecma262/#sec-toboolean
    484     *
    485     *   Category: Expressions
    486     *   Type: Unary operators
    487     *   Operands:
    488     *   Stack: val => (!val)
    489     */ \
    490    MACRO(Not, not_, "!", 1, 1, 1, JOF_BYTE|JOF_IC) \
    491    /*
    492     * [Binary bitwise operations][1] (`|`, `^`, `&`).
    493     *
    494     * The arguments are converted to integers first. The conversion can call
    495     * `.toString()`/`.valueOf()` methods and can throw. The result on success
    496     * is always an Int32 or BigInt Value.
    497     *
    498     * [1]: https://tc39.es/ecma262/#sec-binary-bitwise-operators
    499     *
    500     *   Category: Expressions
    501     *   Type: Binary operators
    502     *   Operands:
    503     *   Stack: lval, rval => (lval OP rval)
    504     */ \
    505    MACRO(BitOr, bit_or, "|",  1, 2, 1, JOF_BYTE|JOF_IC) \
    506    MACRO(BitXor, bit_xor, "^", 1, 2, 1, JOF_BYTE|JOF_IC) \
    507    MACRO(BitAnd, bit_and, "&", 1, 2, 1, JOF_BYTE|JOF_IC) \
    508    /*
    509     * Loose equality operators (`==` and `!=`).
    510     *
    511     * Pop two values, compare them, and push the boolean result. The
    512     * comparison may perform conversions that call `.toString()`/`.valueOf()`
    513     * methods and can throw.
    514     *
    515     * Implements: [Abstract Equality Comparison][1].
    516     *
    517     * [1]: https://tc39.es/ecma262/#sec-abstract-equality-comparison
    518     *
    519     *   Category: Expressions
    520     *   Type: Binary operators
    521     *   Operands:
    522     *   Stack: lval, rval => (lval OP rval)
    523     */ \
    524    MACRO(Eq, eq, "==", 1, 2, 1, JOF_BYTE|JOF_IC) \
    525    MACRO(Ne, ne, "!=", 1, 2, 1, JOF_BYTE|JOF_IC) \
    526    /*
    527     * Strict equality operators (`===` and `!==`).
    528     *
    529     * Pop two values, check whether they're equal, and push the boolean
    530     * result. This does not call user-defined methods and can't throw
    531     * (except possibly due to OOM while flattening a string).
    532     *
    533     * Implements: [Strict Equality Comparison][1].
    534     *
    535     * [1]: https://tc39.es/ecma262/#sec-strict-equality-comparison
    536     *
    537     *   Category: Expressions
    538     *   Type: Binary operators
    539     *   Operands:
    540     *   Stack: lval, rval => (lval OP rval)
    541     */ \
    542    MACRO(StrictEq, strict_eq, "===", 1, 2, 1, JOF_BYTE|JOF_IC) \
    543    MACRO(StrictNe, strict_ne, "!==", 1, 2, 1, JOF_BYTE|JOF_IC) \
    544    /*
    545     * A compound opcode for strict equality comparisons with constant
    546     * operands. example: `val === null`, `val !== true`. Takes in a single
    547     * operand which encodes the type of the constant and a payload
    548     * if applicable.
    549     *
    550     *   Category: Expressions
    551     *   Type: Other expressions
    552     *   Operands: ConstantCompareOperand operand
    553     *   Stack: val => (val OP constant)
    554     */ \
    555    MACRO(StrictConstantEq, strict_constant_eq, NULL, 3, 1, 1, JOF_UINT16) \
    556    MACRO(StrictConstantNe, strict_constant_ne, NULL, 3, 1, 1, JOF_UINT16) \
    557    /*
    558     * Relative operators (`<`, `>`, `<=`, `>=`).
    559     *
    560     * Pop two values, compare them, and push the boolean result. The
    561     * comparison may perform conversions that call `.toString()`/`.valueOf()`
    562     * methods and can throw.
    563     *
    564     * Implements: [Relational Operators: Evaluation][1].
    565     *
    566     * [1]: https://tc39.es/ecma262/#sec-relational-operators-runtime-semantics-evaluation
    567     *
    568     *   Category: Expressions
    569     *   Type: Binary operators
    570     *   Operands:
    571     *   Stack: lval, rval => (lval OP rval)
    572     */ \
    573    MACRO(Lt, lt, "<",  1, 2, 1, JOF_BYTE|JOF_IC) \
    574    MACRO(Gt, gt, ">",  1, 2, 1, JOF_BYTE|JOF_IC) \
    575    MACRO(Le, le, "<=", 1, 2, 1, JOF_BYTE|JOF_IC) \
    576    MACRO(Ge, ge, ">=", 1, 2, 1, JOF_BYTE|JOF_IC) \
    577    /*
    578     * [The `instanceof` operator][1].
    579     *
    580     * This throws a `TypeError` if `target` is not an object. It calls
    581     * `target[Symbol.hasInstance](value)` if the method exists. On success,
    582     * the result is always a boolean value.
    583     *
    584     * [1]: https://tc39.es/ecma262/#sec-instanceofoperator
    585     *
    586     *   Category: Expressions
    587     *   Type: Binary operators
    588     *   Operands:
    589     *   Stack: value, target => (value instanceof target)
    590     */ \
    591    MACRO(Instanceof, instanceof, "instanceof", 1, 2, 1, JOF_BYTE|JOF_IC) \
    592    /*
    593     * [The `in` operator][1].
    594     *
    595     * Push `true` if `obj` has a property with the key `id`. Otherwise push `false`.
    596     *
    597     * This throws a `TypeError` if `obj` is not an object. This can fire
    598     * proxy hooks and can throw. On success, the result is always a boolean
    599     * value.
    600     *
    601     * [1]: https://tc39.es/ecma262/#sec-relational-operators-runtime-semantics-evaluation
    602     *
    603     *   Category: Expressions
    604     *   Type: Binary operators
    605     *   Operands:
    606     *   Stack: id, obj => (id in obj)
    607     */ \
    608    MACRO(In, in_, "in", 1, 2, 1, JOF_BYTE|JOF_IC) \
    609    /*
    610     * [Bitwise shift operators][1] (`<<`, `>>`, `>>>`).
    611     *
    612     * Pop two values, convert them to integers, perform a bitwise shift, and
    613     * push the result.
    614     *
    615     * Conversion can call `.toString()`/`.valueOf()` methods and can throw.
    616     * The result on success is always an Int32 or BigInt Value.
    617     *
    618     * [1]: https://tc39.es/ecma262/#sec-bitwise-shift-operators
    619     *
    620     *   Category: Expressions
    621     *   Type: Binary operators
    622     *   Operands:
    623     *   Stack: lval, rval => (lval OP rval)
    624     */ \
    625    MACRO(Lsh, lsh, "<<", 1, 2, 1, JOF_BYTE|JOF_IC) \
    626    MACRO(Rsh, rsh, ">>", 1, 2, 1, JOF_BYTE|JOF_IC) \
    627    MACRO(Ursh, ursh, ">>>", 1, 2, 1, JOF_BYTE|JOF_IC) \
    628    /*
    629     * [The binary `+` operator][1].
    630     *
    631     * Pop two values, convert them to primitive values, add them, and push the
    632     * result. If both values are numeric, add them; if either is a
    633     * string, do string concatenation instead.
    634     *
    635     * The conversion can call `.toString()`/`.valueOf()` methods and can throw.
    636     *
    637     * [1]: https://tc39.es/ecma262/#sec-addition-operator-plus-runtime-semantics-evaluation
    638     *
    639     *   Category: Expressions
    640     *   Type: Binary operators
    641     *   Operands:
    642     *   Stack: lval, rval => (lval + rval)
    643     */ \
    644    MACRO(Add, add, "+", 1, 2, 1, JOF_BYTE|JOF_IC) \
    645    /*
    646     * [The binary `-` operator][1].
    647     *
    648     * Pop two values, convert them to numeric values, subtract the top value
    649     * from the other one, and push the result.
    650     *
    651     * The conversion can call `.toString()`/`.valueOf()` methods and can
    652     * throw. On success, the result is always numeric.
    653     *
    654     * [1]: https://tc39.es/ecma262/#sec-subtraction-operator-minus-runtime-semantics-evaluation
    655     *
    656     *   Category: Expressions
    657     *   Type: Binary operators
    658     *   Operands:
    659     *   Stack: lval, rval => (lval - rval)
    660     */ \
    661    MACRO(Sub, sub, "-", 1, 2, 1, JOF_BYTE|JOF_IC) \
    662    /*
    663     * Add or subtract 1.
    664     *
    665     * `val` must already be a numeric value, such as the result of
    666     * `JSOp::ToNumeric`.
    667     *
    668     * Implements: [The `++` and `--` operators][1], step 3 of each algorithm.
    669     *
    670     * [1]: https://tc39.es/ecma262/#sec-postfix-increment-operator
    671     *
    672     *   Category: Expressions
    673     *   Type: Binary operators
    674     *   Operands:
    675     *   Stack: val => (val +/- 1)
    676     */ \
    677    MACRO(Inc, inc, NULL, 1, 1, 1, JOF_BYTE|JOF_IC) \
    678    MACRO(Dec, dec, NULL, 1, 1, 1, JOF_BYTE|JOF_IC) \
    679    /*
    680     * [The multiplicative operators][1] (`*`, `/`, `%`).
    681     *
    682     * Pop two values, convert them to numeric values, do math, and push the
    683     * result.
    684     *
    685     * The conversion can call `.toString()`/`.valueOf()` methods and can
    686     * throw. On success, the result is always numeric.
    687     *
    688     * [1]: https://tc39.es/ecma262/#sec-multiplicative-operators-runtime-semantics-evaluation
    689     *
    690     *   Category: Expressions
    691     *   Type: Binary operators
    692     *   Operands:
    693     *   Stack: lval, rval => (lval OP rval)
    694     */ \
    695    MACRO(Mul, mul, "*", 1, 2, 1, JOF_BYTE|JOF_IC) \
    696    MACRO(Div, div, "/", 1, 2, 1, JOF_BYTE|JOF_IC) \
    697    MACRO(Mod, mod, "%", 1, 2, 1, JOF_BYTE|JOF_IC) \
    698    /*
    699     * [The exponentiation operator][1] (`**`).
    700     *
    701     * Pop two values, convert them to numeric values, do exponentiation, and
    702     * push the result. The top value is the exponent.
    703     *
    704     * The conversion can call `.toString()`/`.valueOf()` methods and can
    705     * throw. This throws a RangeError if both values are BigInts and the
    706     * exponent is negative.
    707     *
    708     * [1]: https://tc39.es/ecma262/#sec-exp-operator
    709     *
    710     *   Category: Expressions
    711     *   Type: Binary operators
    712     *   Operands:
    713     *   Stack: lval, rval => (lval ** rval)
    714     */ \
    715    MACRO(Pow, pow, "**", 1, 2, 1, JOF_BYTE|JOF_IC) \
    716    /*
    717     * No-op instruction for bytecode decompiler to hint that the previous
    718     *  binary operator is compound assignment.
    719     *
    720     *   Category: Expressions
    721     *   Type: Other expressions
    722     *   Operands:
    723     *   Stack:
    724     */ \
    725    MACRO(NopIsAssignOp, nop_is_assign_op, NULL, 1, 0, 0, JOF_BYTE) \
    726    /*
    727     * Convert a value to a property key.
    728     *
    729     * Implements: [ToPropertyKey][1], except that if the result would be the
    730     * string representation of some integer in the range 0..2^31, we push the
    731     * corresponding Int32 value instead. This is because the spec insists that
    732     * array indices are strings, whereas for us they are integers.
    733     *
    734     * This is used for code like `++obj[index]`, which must do both a
    735     * `JSOp::GetElem` and a `JSOp::SetElem` with the same property key. Both
    736     * instructions would convert `index` to a property key for us, but the
    737     * spec says to convert it only once.
    738     *
    739     * The conversion can call `.toString()`/`.valueOf()` methods and can
    740     * throw.
    741     *
    742     * [1]: https://tc39.es/ecma262/#sec-topropertykey
    743     *
    744     *   Category: Expressions
    745     *   Type: Conversions
    746     *   Operands:
    747     *   Stack: propertyNameValue => propertyKey
    748     */ \
    749    MACRO(ToPropertyKey, to_property_key, NULL, 1, 1, 1, JOF_BYTE|JOF_IC) \
    750    /*
    751     * Convert a value to a numeric value (a Number or BigInt).
    752     *
    753     * Implements: [ToNumeric][1](val).
    754     *
    755     * Note: This is used to implement [`++` and `--`][2]. Surprisingly, it's
    756     * not possible to get the right behavior using `JSOp::Add` and `JSOp::Sub`
    757     * alone. For one thing, `JSOp::Add` sometimes does string concatenation,
    758     * while `++` always does numeric addition. More fundamentally, the result
    759     * of evaluating `x--` is ToNumeric(old value of `x`), a value that the
    760     * sequence `GetLocal "x"; One; Sub; SetLocal "x"` does not give us.
    761     *
    762     * [1]: https://tc39.es/ecma262/#sec-tonumeric
    763     * [2]: https://tc39.es/ecma262/#sec-postfix-increment-operator
    764     *
    765     *   Category: Expressions
    766     *   Type: Conversions
    767     *   Operands:
    768     *   Stack: val => ToNumeric(val)
    769     */ \
    770    MACRO(ToNumeric, to_numeric, NULL, 1, 1, 1, JOF_BYTE|JOF_IC) \
    771    /*
    772     * Convert a value to a string.
    773     *
    774     * Implements: [ToString][1](val).
    775     *
    776     * Note: This is used in code for template literals, like `${x}${y}`. Each
    777     * substituted value must be converted using ToString. `JSOp::Add` by itself
    778     * would do a slightly wrong kind of conversion (hint="number" rather than
    779     * hint="string").
    780     *
    781     * [1]: https://tc39.es/ecma262/#sec-tostring
    782     *
    783     *   Category: Expressions
    784     *   Type: Conversions
    785     *   Stack: val => ToString(val)
    786     */ \
    787    MACRO(ToString, to_string, NULL, 1, 1, 1, JOF_BYTE) \
    788    /*
    789     * Test whether the value on top of the stack is `NullValue` or
    790     * `UndefinedValue` and push the boolean result.
    791     *
    792     *   Category: Expressions
    793     *   Type: Other expressions
    794     *   Operands:
    795     *   Stack: val => val, IsNullOrUndefined(val)
    796     */ \
    797    MACRO(IsNullOrUndefined, is_null_or_undefined, NULL, 1, 1, 2, JOF_BYTE) \
    798    /*
    799     * Push the global `this` value. Not to be confused with the `globalThis`
    800     * property on the global.
    801     *
    802     * This must be used only in scopes where `this` refers to the global
    803     * `this`.
    804     *
    805     *   Category: Expressions
    806     *   Type: Other expressions
    807     *   Operands:
    808     *   Stack: => this
    809     */ \
    810    MACRO(GlobalThis, global_this, NULL, 1, 0, 1, JOF_BYTE) \
    811    /*
    812     * Push the global `this` value for non-syntactic scope. Not to be confused
    813     * with the `globalThis` property on the global.
    814     *
    815     * This must be used only in scopes where `this` refers to the global
    816     * `this`.
    817     *
    818     *   Category: Expressions
    819     *   Type: Other expressions
    820     *   Operands:
    821     *   Stack: => this
    822     */ \
    823    MACRO(NonSyntacticGlobalThis, non_syntactic_global_this, NULL, 1, 0, 1, JOF_BYTE) \
    824    /*
    825     * Push the value of `new.target`.
    826     *
    827     * The result is a constructor or `undefined`.
    828     *
    829     * This must be used only in non-arrow function scripts.
    830     *
    831     * Implements: [GetNewTarget][1].
    832     *
    833     * [1]: https://tc39.es/ecma262/#sec-getnewtarget
    834     *
    835     *   Category: Expressions
    836     *   Type: Other expressions
    837     *   Operands:
    838     *   Stack: => new.target
    839     */ \
    840    MACRO(NewTarget, new_target, NULL, 1, 0, 1, JOF_BYTE) \
    841    /*
    842     * Dynamic import of the module specified by the string value on the top of
    843     * the stack.
    844     *
    845     * Implements: [Import Calls][1].
    846     *
    847     * [1]: https://tc39.es/ecma262/#sec-import-calls
    848     *
    849     *   Category: Expressions
    850     *   Type: Other expressions
    851     *   Operands:
    852     *   Stack: moduleId, options => promise
    853     */ \
    854    MACRO(DynamicImport, dynamic_import, NULL, 1, 2, 1, JOF_BYTE) \
    855    /*
    856     * Push the `import.meta` object.
    857     *
    858     * This must be used only in module code.
    859     *
    860     *   Category: Expressions
    861     *   Type: Other expressions
    862     *   Operands:
    863     *   Stack: => import.meta
    864     */ \
    865    MACRO(ImportMeta, import_meta, NULL, 1, 0, 1, JOF_BYTE|JOF_IC) \
    866    /*
    867     * Create and push a new object with no properties.
    868     *
    869     *   Category: Objects
    870     *   Type: Creating objects
    871     *   Operands: uint8_t propertyCount
    872     *   Stack: => obj
    873     */ \
    874    MACRO(NewInit, new_init, NULL, 2, 0, 1, JOF_UINT8|JOF_IC) \
    875    /*
    876     * Create and push a new object of a predetermined shape.
    877     *
    878     * The new object has the shape `script->getShape(shapeIndex)`.
    879     * Subsequent `InitProp` instructions must fill in all slots of the new
    880     * object before it is used in any other way.
    881     *
    882     *   Category: Objects
    883     *   Type: Creating objects
    884     *   Operands: uint32_t shapeIndex
    885     *   Stack: => obj
    886     */ \
    887    MACRO(NewObject, new_object, NULL, 5, 0, 1, JOF_SHAPE|JOF_IC) \
    888    /*
    889     * Push a preconstructed object.
    890     *
    891     * Going one step further than `JSOp::NewObject`, this instruction doesn't
    892     * just reuse the shape--it actually pushes the preconstructed object
    893     * `script->getObject(objectIndex)` right onto the stack. The object must
    894     * be a singleton `PlainObject` or `ArrayObject`.
    895     *
    896     * The spec requires that an *ObjectLiteral* or *ArrayLiteral* creates a
    897     * new object every time it's evaluated, so this instruction must not be
    898     * used anywhere it might be executed more than once.
    899     *
    900     * This may only be used in non-function run-once scripts. Care also must
    901     * be taken to not emit in loops or other constructs where it could run
    902     * more than once.
    903     *
    904     *   Category: Objects
    905     *   Type: Creating objects
    906     *   Operands: uint32_t objectIndex
    907     *   Stack: => obj
    908     */ \
    909    MACRO(Object, object, NULL, 5, 0, 1, JOF_OBJECT) \
    910    /*
    911     * Create and push a new ordinary object with the provided [[Prototype]].
    912     *
    913     * This is used to create the `.prototype` object for derived classes.
    914     *
    915     *   Category: Objects
    916     *   Type: Creating objects
    917     *   Operands:
    918     *   Stack: proto => obj
    919     */ \
    920    MACRO(ObjWithProto, obj_with_proto, NULL, 1, 1, 1, JOF_BYTE) \
    921    /*
    922     * Define a data property on an object.
    923     *
    924     * `obj` must be an object.
    925     *
    926     * Implements: [CreateDataPropertyOrThrow][1] as used in
    927     * [PropertyDefinitionEvaluation][2] of regular and shorthand
    928     * *PropertyDefinition*s.
    929     *
    930     *    [1]: https://tc39.es/ecma262/#sec-createdatapropertyorthrow
    931     *    [2]: https://tc39.es/ecma262/#sec-object-initializer-runtime-semantics-propertydefinitionevaluation
    932     *
    933     *   Category: Objects
    934     *   Type: Defining properties
    935     *   Operands: uint32_t nameIndex
    936     *   Stack: obj, val => obj
    937     */ \
    938    MACRO(InitProp, init_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT|JOF_IC) \
    939    /*
    940     * Like `JSOp::InitProp`, but define a non-enumerable property.
    941     *
    942     * This is used to define class methods.
    943     *
    944     * Implements: [PropertyDefinitionEvaluation][1] for methods, steps 3 and
    945     * 4, when *enumerable* is false.
    946     *
    947     *    [1]: https://tc39.es/ecma262/#sec-method-definitions-runtime-semantics-propertydefinitionevaluation
    948     *
    949     *   Category: Objects
    950     *   Type: Defining properties
    951     *   Operands: uint32_t nameIndex
    952     *   Stack: obj, val => obj
    953     */ \
    954    MACRO(InitHiddenProp, init_hidden_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT|JOF_IC) \
    955    /*
    956     * Like `JSOp::InitProp`, but define a non-enumerable, non-writable,
    957     * non-configurable property.
    958     *
    959     * This is used to define the `.prototype` property on classes.
    960     *
    961     * Implements: [MakeConstructor][1], step 8, when *writablePrototype* is
    962     * false.
    963     *
    964     *    [1]: https://tc39.es/ecma262/#sec-makeconstructor
    965     *
    966     *   Category: Objects
    967     *   Type: Defining properties
    968     *   Operands: uint32_t nameIndex
    969     *   Stack: obj, val => obj
    970     */ \
    971    MACRO(InitLockedProp, init_locked_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT|JOF_IC) \
    972    /*
    973     * Define a data property on `obj` with property key `id` and value `val`.
    974     *
    975     * `obj` must be an object.
    976     *
    977     * Implements: [CreateDataPropertyOrThrow][1]. This instruction is used for
    978     * object literals like `{0: val}` and `{[id]: val}`, and methods like
    979     * `*[Symbol.iterator]() {}`.
    980     *
    981     * `JSOp::InitHiddenElem` is the same but defines a non-enumerable property,
    982     * for class methods and private fields.
    983     * `JSOp::InitLockedElem` is the same but defines a non-enumerable, non-writable, non-configurable property,
    984     * for private class methods.
    985     *
    986     *    [1]: https://tc39.es/ecma262/#sec-createdatapropertyorthrow
    987     *
    988     *   Category: Objects
    989     *   Type: Defining properties
    990     *   Operands:
    991     *   Stack: obj, id, val => obj
    992     */ \
    993    MACRO(InitElem, init_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT|JOF_IC) \
    994    MACRO(InitHiddenElem, init_hidden_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT|JOF_IC) \
    995    MACRO(InitLockedElem, init_locked_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT|JOF_IC) \
    996    /*
    997     * Define an accessor property on `obj` with the given `getter`.
    998     * `nameIndex` gives the property name.
    999     *
   1000     * `obj` must be an object and `getter` must be a function.
   1001     *
   1002     * `JSOp::InitHiddenPropGetter` is the same but defines a non-enumerable
   1003     * property, for getters in classes.
   1004     *
   1005     *   Category: Objects
   1006     *   Type: Defining properties
   1007     *   Operands: uint32_t nameIndex
   1008     *   Stack: obj, getter => obj
   1009     */ \
   1010    MACRO(InitPropGetter, init_prop_getter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT) \
   1011    MACRO(InitHiddenPropGetter, init_hidden_prop_getter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT) \
   1012    /*
   1013     * Define an accessor property on `obj` with property key `id` and the given `getter`.
   1014     *
   1015     * This is used to implement getters like `get [id]() {}` or `get 0() {}`.
   1016     *
   1017     * `obj` must be an object and `getter` must be a function.
   1018     *
   1019     * `JSOp::InitHiddenElemGetter` is the same but defines a non-enumerable
   1020     * property, for getters in classes.
   1021     *
   1022     *   Category: Objects
   1023     *   Type: Defining properties
   1024     *   Operands:
   1025     *   Stack: obj, id, getter => obj
   1026     */ \
   1027    MACRO(InitElemGetter, init_elem_getter, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT) \
   1028    MACRO(InitHiddenElemGetter, init_hidden_elem_getter, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT) \
   1029    /*
   1030     * Define an accessor property on `obj` with the given `setter`.
   1031     *
   1032     * This is used to implement ordinary setters like `set foo(v) {}`.
   1033     *
   1034     * `obj` must be an object and `setter` must be a function.
   1035     *
   1036     * `JSOp::InitHiddenPropSetter` is the same but defines a non-enumerable
   1037     * property, for setters in classes.
   1038     *
   1039     *   Category: Objects
   1040     *   Type: Defining properties
   1041     *   Operands: uint32_t nameIndex
   1042     *   Stack: obj, setter => obj
   1043     */ \
   1044    MACRO(InitPropSetter, init_prop_setter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT) \
   1045    MACRO(InitHiddenPropSetter, init_hidden_prop_setter, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPINIT) \
   1046    /*
   1047     * Define an accesssor property on `obj` with property key `id` and the
   1048     * given `setter`.
   1049     *
   1050     * This is used to implement setters with computed property keys or numeric
   1051     * keys.
   1052     *
   1053     * `JSOp::InitHiddenElemSetter` is the same but defines a non-enumerable
   1054     * property, for setters in classes.
   1055     *
   1056     *   Category: Objects
   1057     *   Type: Defining properties
   1058     *   Operands:
   1059     *   Stack: obj, id, setter => obj
   1060     */ \
   1061    MACRO(InitElemSetter, init_elem_setter, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT) \
   1062    MACRO(InitHiddenElemSetter, init_hidden_elem_setter, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPINIT) \
   1063    /*
   1064     * Get the value of the property `obj.name`. This can call getters and
   1065     * proxy traps.
   1066     *
   1067     * Implements: [GetV][1], [GetValue][2] step 5.
   1068     *
   1069     * [1]: https://tc39.es/ecma262/#sec-getv
   1070     * [2]: https://tc39.es/ecma262/#sec-getvalue
   1071     *
   1072     *   Category: Objects
   1073     *   Type: Accessing properties
   1074     *   Operands: uint32_t nameIndex
   1075     *   Stack: obj => obj[name]
   1076     */ \
   1077    MACRO(GetProp, get_prop, NULL, 5, 1, 1, JOF_ATOM|JOF_IC) \
   1078    /*
   1079     * Get the value of the property `obj[key]`.
   1080     *
   1081     * Implements: [GetV][1], [GetValue][2] step 5.
   1082     *
   1083     * [1]: https://tc39.es/ecma262/#sec-getv
   1084     * [2]: https://tc39.es/ecma262/#sec-getvalue
   1085     *
   1086     *   Category: Objects
   1087     *   Type: Accessing properties
   1088     *   Operands:
   1089     *   Stack: obj, key => obj[key]
   1090     */ \
   1091    MACRO(GetElem, get_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_IC) \
   1092    /*
   1093     * Non-strict assignment to a property, `obj.name = val`.
   1094     *
   1095     * This throws a TypeError if `obj` is null or undefined. If it's a
   1096     * primitive value, the property is set on ToObject(`obj`), typically with
   1097     * no effect.
   1098     *
   1099     * Implements: [PutValue][1] step 6 for non-strict code.
   1100     *
   1101     * [1]: https://tc39.es/ecma262/#sec-putvalue
   1102     *
   1103     *   Category: Objects
   1104     *   Type: Accessing properties
   1105     *   Operands: uint32_t nameIndex
   1106     *   Stack: obj, val => val
   1107     */ \
   1108    MACRO(SetProp, set_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPSET|JOF_CHECKSLOPPY|JOF_IC) \
   1109    /*
   1110     * Like `JSOp::SetProp`, but for strict mode code. Throw a TypeError if
   1111     * `obj[key]` exists but is non-writable, if it's an accessor property with
   1112     * no setter, or if `obj` is a primitive value.
   1113     *
   1114     *   Category: Objects
   1115     *   Type: Accessing properties
   1116     *   Operands: uint32_t nameIndex
   1117     *   Stack: obj, val => val
   1118     */ \
   1119    MACRO(StrictSetProp, strict_set_prop, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC) \
   1120    /*
   1121     * Non-strict assignment to a property, `obj[key] = val`.
   1122     *
   1123     * Implements: [PutValue][1] step 6 for non-strict code.
   1124     *
   1125     * [1]: https://tc39.es/ecma262/#sec-putvalue
   1126     *
   1127     *   Category: Objects
   1128     *   Type: Accessing properties
   1129     *   Operands:
   1130     *   Stack: obj, key, val => val
   1131     */ \
   1132    MACRO(SetElem, set_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPSET|JOF_CHECKSLOPPY|JOF_IC) \
   1133    /*
   1134     * Like `JSOp::SetElem`, but for strict mode code. Throw a TypeError if
   1135     * `obj[key]` exists but is non-writable, if it's an accessor property with
   1136     * no setter, or if `obj` is a primitive value.
   1137     *
   1138     *   Category: Objects
   1139     *   Type: Accessing properties
   1140     *   Operands:
   1141     *   Stack: obj, key, val => val
   1142     */ \
   1143    MACRO(StrictSetElem, strict_set_elem, NULL, 1, 3, 1, JOF_BYTE|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC) \
   1144    /*
   1145     * Delete a property from `obj`. Push true on success, false if the
   1146     * property existed but could not be deleted. This implements `delete
   1147     * obj.name` in non-strict code.
   1148     *
   1149     * Throws if `obj` is null or undefined. Can call proxy traps.
   1150     *
   1151     * Implements: [`delete obj.propname`][1] step 5 in non-strict code.
   1152     *
   1153     * [1]: https://tc39.es/ecma262/#sec-delete-operator-runtime-semantics-evaluation
   1154     *
   1155     *   Category: Objects
   1156     *   Type: Accessing properties
   1157     *   Operands: uint32_t nameIndex
   1158     *   Stack: obj => succeeded
   1159     */ \
   1160    MACRO(DelProp, del_prop, NULL, 5, 1, 1, JOF_ATOM|JOF_CHECKSLOPPY) \
   1161    /*
   1162     * Like `JSOp::DelProp`, but for strict mode code. Push `true` on success,
   1163     * else throw a TypeError.
   1164     *
   1165     *   Category: Objects
   1166     *   Type: Accessing properties
   1167     *   Operands: uint32_t nameIndex
   1168     *   Stack: obj => succeeded
   1169     */ \
   1170    MACRO(StrictDelProp, strict_del_prop, NULL, 5, 1, 1, JOF_ATOM|JOF_CHECKSTRICT) \
   1171    /*
   1172     * Delete the property `obj[key]` and push `true` on success, `false`
   1173     * if the property existed but could not be deleted.
   1174     *
   1175     * This throws if `obj` is null or undefined. Can call proxy traps.
   1176     *
   1177     * Implements: [`delete obj[key]`][1] step 5 in non-strict code.
   1178     *
   1179     * [1]: https://tc39.es/ecma262/#sec-delete-operator-runtime-semantics-evaluation
   1180     *
   1181     *   Category: Objects
   1182     *   Type: Accessing properties
   1183     *   Operands:
   1184     *   Stack: obj, key => succeeded
   1185     */ \
   1186    MACRO(DelElem, del_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_CHECKSLOPPY) \
   1187    /*
   1188     * Like `JSOp::DelElem, but for strict mode code. Push `true` on success,
   1189     * else throw a TypeError.
   1190     *
   1191     *   Category: Objects
   1192     *   Type: Accessing properties
   1193     *   Operands:
   1194     *   Stack: obj, key => succeeded
   1195     */ \
   1196    MACRO(StrictDelElem, strict_del_elem, NULL, 1, 2, 1, JOF_BYTE|JOF_CHECKSTRICT) \
   1197    /*
   1198     * Push true if `obj` has an own property `id`.
   1199     *
   1200     * Note that `obj` is the top value, like `JSOp::In`.
   1201     *
   1202     * This opcode is not used for normal JS. Self-hosted code uses it by
   1203     * calling the intrinsic `hasOwn(id, obj)`. For example,
   1204     * `Object.prototype.hasOwnProperty` is implemented this way (see
   1205     * js/src/builtin/Object.js).
   1206     *
   1207     *   Category: Objects
   1208     *   Type: Accessing properties
   1209     *   Operands:
   1210     *   Stack: id, obj => (obj.hasOwnProperty(id))
   1211     */ \
   1212    MACRO(HasOwn, has_own, NULL, 1, 2, 1, JOF_BYTE|JOF_IC) \
   1213    /*
   1214     * Push a bool representing the presence of private field id on obj.
   1215     * May throw, depending on the ThrowCondition.
   1216     *
   1217     * Two arguments:
   1218     *   - throwCondition: One of the ThrowConditions defined in
   1219     *     ThrowMsgKind.h. Determines why (or if) this op will throw.
   1220     *   - msgKind: One of the ThrowMsgKinds defined in ThrowMsgKind.h, which
   1221     *     maps to one of the messages in js.msg. Note: It's not possible to
   1222     *     pass arguments to the message at the moment.
   1223     *
   1224     *   Category: Objects
   1225     *   Type: Accessing properties
   1226     *   Operands: ThrowCondition throwCondition, ThrowMsgKind msgKind
   1227     *   Stack: obj, key => obj, key, (obj.hasOwnProperty(id))
   1228     */ \
   1229    MACRO(CheckPrivateField, check_private_field, NULL, 3, 2, 3, JOF_TWO_UINT8|JOF_CHECKSTRICT|JOF_IC) \
   1230    /*
   1231     * Push a new private name.
   1232     *
   1233     *   Category: Objects
   1234     *   Type: Accessing properties
   1235     *   Operands: uint32_t nameIndex
   1236     *   Stack: => private_name
   1237     */ \
   1238    MACRO(NewPrivateName, new_private_name, NULL, 5, 0, 1, JOF_ATOM) \
   1239    /*
   1240     * Push the SuperBase of the method `callee`. The SuperBase is
   1241     * `callee.[[HomeObject]].[[GetPrototypeOf]]()`, the object where `super`
   1242     * property lookups should begin.
   1243     *
   1244     * `callee` must be a function that has a HomeObject that's an object,
   1245     * typically produced by `JSOp::Callee` or `JSOp::EnvCallee`.
   1246     *
   1247     * Implements: [GetSuperBase][1], except that instead of the environment,
   1248     * the argument supplies the callee.
   1249     *
   1250     * [1]: https://tc39.es/ecma262/#sec-getsuperbase
   1251     *
   1252     *   Category: Objects
   1253     *   Type: Super
   1254     *   Operands:
   1255     *   Stack: callee => superBase
   1256     */ \
   1257    MACRO(SuperBase, super_base, NULL, 1, 1, 1, JOF_BYTE) \
   1258    /*
   1259     * Get the value of `receiver.name`, starting the property search at `obj`.
   1260     * In spec terms, `obj.[[Get]](name, receiver)`.
   1261     *
   1262     * Implements: [GetValue][1] for references created by [`super.name`][2].
   1263     * The `receiver` is `this` and `obj` is the SuperBase of the enclosing
   1264     * method.
   1265     *
   1266     * [1]: https://tc39.es/ecma262/#sec-getvalue
   1267     * [2]: https://tc39.es/ecma262/#sec-super-keyword-runtime-semantics-evaluation
   1268     *
   1269     *   Category: Objects
   1270     *   Type: Super
   1271     *   Operands: uint32_t nameIndex
   1272     *   Stack: receiver, obj => super.name
   1273     */ \
   1274    MACRO(GetPropSuper, get_prop_super, NULL, 5, 2, 1, JOF_ATOM|JOF_IC) \
   1275    /*
   1276     * Get the value of `receiver[key]`, starting the property search at `obj`.
   1277     * In spec terms, `obj.[[Get]](key, receiver)`.
   1278     *
   1279     * Implements: [GetValue][1] for references created by [`super[key]`][2]
   1280     * (where the `receiver` is `this` and `obj` is the SuperBase of the enclosing
   1281     * method); [`Reflect.get(obj, key, receiver)`][3].
   1282     *
   1283     * [1]: https://tc39.es/ecma262/#sec-getvalue
   1284     * [2]: https://tc39.es/ecma262/#sec-super-keyword-runtime-semantics-evaluation
   1285     * [3]: https://tc39.es/ecma262/#sec-reflect.get
   1286     *
   1287     *   Category: Objects
   1288     *   Type: Super
   1289     *   Operands:
   1290     *   Stack: receiver, key, obj => super[key]
   1291     */ \
   1292    MACRO(GetElemSuper, get_elem_super, NULL, 1, 3, 1, JOF_BYTE|JOF_IC) \
   1293    /*
   1294     * Assign `val` to `receiver.name`, starting the search for an existing
   1295     * property at `obj`. In spec terms, `obj.[[Set]](name, val, receiver)`.
   1296     *
   1297     * Implements: [PutValue][1] for references created by [`super.name`][2] in
   1298     * non-strict code. The `receiver` is `this` and `obj` is the SuperBase of
   1299     * the enclosing method.
   1300     *
   1301     * [1]: https://tc39.es/ecma262/#sec-putvalue
   1302     * [2]: https://tc39.es/ecma262/#sec-super-keyword-runtime-semantics-evaluation
   1303     *
   1304     *   Category: Objects
   1305     *   Type: Super
   1306     *   Operands: uint32_t nameIndex
   1307     *   Stack: receiver, obj, val => val
   1308     */ \
   1309    MACRO(SetPropSuper, set_prop_super, NULL, 5, 3, 1, JOF_ATOM|JOF_PROPSET|JOF_CHECKSLOPPY) \
   1310    /*
   1311     * Like `JSOp::SetPropSuper`, but for strict mode code.
   1312     *
   1313     *   Category: Objects
   1314     *   Type: Super
   1315     *   Operands: uint32_t nameIndex
   1316     *   Stack: receiver, obj, val => val
   1317     */ \
   1318    MACRO(StrictSetPropSuper, strict_set_prop_super, NULL, 5, 3, 1, JOF_ATOM|JOF_PROPSET|JOF_CHECKSTRICT) \
   1319    /*
   1320     * Assign `val` to `receiver[key]`, strating the search for an existing
   1321     * property at `obj`. In spec terms, `obj.[[Set]](key, val, receiver)`.
   1322     *
   1323     * Implements: [PutValue][1] for references created by [`super[key]`][2] in
   1324     * non-strict code. The `receiver` is `this` and `obj` is the SuperBase of
   1325     * the enclosing method.
   1326     *
   1327     * [1]: https://tc39.es/ecma262/#sec-putvalue
   1328     * [2]: https://tc39.es/ecma262/#sec-super-keyword-runtime-semantics-evaluation
   1329     *
   1330     *   Category: Objects
   1331     *   Type: Super
   1332     *   Operands:
   1333     *   Stack: receiver, key, obj, val => val
   1334     */ \
   1335    MACRO(SetElemSuper, set_elem_super, NULL, 1, 4, 1, JOF_BYTE|JOF_PROPSET|JOF_CHECKSLOPPY) \
   1336    /*
   1337     * Like `JSOp::SetElemSuper`, but for strict mode code.
   1338     *
   1339     *   Category: Objects
   1340     *   Type: Super
   1341     *   Operands:
   1342     *   Stack: receiver, key, obj, val => val
   1343     */ \
   1344    MACRO(StrictSetElemSuper, strict_set_elem_super, NULL, 1, 4, 1, JOF_BYTE|JOF_PROPSET|JOF_CHECKSTRICT) \
   1345    /*
   1346     * Set up a for-in loop by pushing a `PropertyIteratorObject` over the
   1347     * enumerable properties of `val`.
   1348     *
   1349     * Implements: [ForIn/OfHeadEvaluation][1] step 6,
   1350     * [EnumerateObjectProperties][1]. (The spec refers to an "Iterator object"
   1351     * with a `next` method, but notes that it "is never directly accessible"
   1352     * to scripts. The object we use for this has no public methods.)
   1353     *
   1354     * If `val` is null or undefined, this pushes an empty iterator.
   1355     *
   1356     * The `iter` object pushed by this instruction must not be used or removed
   1357     * from the stack except by `JSOp::MoreIter` and `JSOp::EndIter`, or by error
   1358     * handling.
   1359     *
   1360     * The script's `JSScript::trynotes()` must mark the body of the `for-in`
   1361     * loop, i.e. exactly those instructions that begin executing with `iter`
   1362     * on the stack, starting with the next instruction (always
   1363     * `JSOp::LoopHead`). Code must not jump into or out of this region: control
   1364     * can enter only by executing `JSOp::Iter` and can exit only by executing a
   1365     * `JSOp::EndIter` or by exception unwinding. (A `JSOp::EndIter` is always
   1366     * emitted at the end of the loop, and extra copies are emitted on "exit
   1367     * slides", where a `break`, `continue`, or `return` statement exits the
   1368     * loop.)
   1369     *
   1370     * Typically a single try note entry marks the contiguous chunk of bytecode
   1371     * from the instruction after `JSOp::Iter` to `JSOp::EndIter` (inclusive);
   1372     * but if that range contains any instructions on exit slides, after a
   1373     * `JSOp::EndIter`, then those must be correctly noted as *outside* the
   1374     * loop.
   1375     *
   1376     * [1]: https://tc39.es/ecma262/#sec-runtime-semantics-forin-div-ofheadevaluation-tdznames-expr-iterationkind
   1377     * [2]: https://tc39.es/ecma262/#sec-enumerate-object-properties
   1378     *
   1379     *   Category: Objects
   1380     *   Type: Enumeration
   1381     *   Operands:
   1382     *   Stack: val => iter
   1383     */ \
   1384    MACRO(Iter, iter, NULL, 1, 1, 1, JOF_BYTE|JOF_IC) \
   1385    /*
   1386     * Get the next property name for a for-in loop.
   1387     *
   1388     * `iter` must be a `PropertyIteratorObject` produced by `JSOp::Iter`.  This
   1389     * pushes the property name for the next loop iteration, or
   1390     * `MagicValue(JS_NO_ITER_VALUE)` if there are no more enumerable
   1391     * properties to iterate over. The magic value must be used only by
   1392     * `JSOp::IsNoIter` and `JSOp::EndIter`.
   1393     *
   1394     *   Category: Objects
   1395     *   Type: Enumeration
   1396     *   Operands:
   1397     *   Stack: iter => iter, name
   1398     */ \
   1399    MACRO(MoreIter, more_iter, NULL, 1, 1, 2, JOF_BYTE) \
   1400    /*
   1401     * Test whether the value on top of the stack is
   1402     * `MagicValue(JS_NO_ITER_VALUE)` and push the boolean result.
   1403     *
   1404     *   Category: Objects
   1405     *   Type: Enumeration
   1406     *   Operands:
   1407     *   Stack: val => val, done
   1408     */ \
   1409    MACRO(IsNoIter, is_no_iter, NULL, 1, 1, 2, JOF_BYTE) \
   1410    /*
   1411     * Exit a for-in loop, closing the iterator.
   1412     *
   1413     * `iter` must be a `PropertyIteratorObject` pushed by `JSOp::Iter`.
   1414     *
   1415     *   Category: Objects
   1416     *   Type: Enumeration
   1417     *   Operands:
   1418     *   Stack: iter, iterval =>
   1419     */ \
   1420    MACRO(EndIter, end_iter, NULL, 1, 2, 0, JOF_BYTE) \
   1421    /*
   1422     * If the iterator object on top of the stack has a `return` method,
   1423     * call that method. If the method exists but does not return an object,
   1424     * and `kind` is not `CompletionKind::Throw`, throw a TypeError. (If
   1425     * `kind` is `Throw`, the error we are already throwing takes precedence.)
   1426     *
   1427     * `iter` must be an object conforming to the [Iterator][1] interface.
   1428     *
   1429     * Implements: [IteratorClose][2]
   1430     *
   1431     * [1]: https://tc39.es/ecma262/#sec-iterator-interface
   1432     * [2]: https://tc39.es/ecma262/#sec-iteratorclose
   1433     *   Category: Objects
   1434     *   Type: Iteration
   1435     *   Operands: CompletionKind kind
   1436     *   Stack: iter =>
   1437     */ \
   1438    MACRO(CloseIter, close_iter, NULL, 2, 1, 0, JOF_UINT8|JOF_IC) \
   1439    /*
   1440     * If we can optimize iteration for `iterable`, meaning that it is a packed
   1441     * array and nothing important has been tampered with, then we replace it
   1442     * with `true`, otherwise we replace it with `false`. This is similar in
   1443     * operation to OptimizeSpreadCall.
   1444     *
   1445     *   Category: Objects
   1446     *   Type: Iteration
   1447     *   Operands:
   1448     *   Stack: iterable => is_optimizable
   1449     */ \
   1450    MACRO(OptimizeGetIterator, optimize_get_iterator, NULL, 1, 1, 1, JOF_BYTE|JOF_IC) \
   1451    /*
   1452     * Check that the top value on the stack is an object, and throw a
   1453     * TypeError if not. `kind` is used only to generate an appropriate error
   1454     * message.
   1455     *
   1456     * Implements: [GetIterator][1] step 5, [IteratorNext][2] step 3. Both
   1457     * operations call a JS method which scripts can define however they want,
   1458     * so they check afterwards that the method returned an object.
   1459     *
   1460     * [1]: https://tc39.es/ecma262/#sec-getiterator
   1461     * [2]: https://tc39.es/ecma262/#sec-iteratornext
   1462     *
   1463     *   Category: Objects
   1464     *   Type: Iteration
   1465     *   Operands: CheckIsObjectKind kind
   1466     *   Stack: result => result
   1467     */ \
   1468    MACRO(CheckIsObj, check_is_obj, NULL, 2, 1, 1, JOF_UINT8) \
   1469    /*
   1470     * Throw a TypeError if `val` is `null` or `undefined`.
   1471     *
   1472     * Implements: [RequireObjectCoercible][1]. But most instructions that
   1473     * require an object will perform this check for us, so of the dozens of
   1474     * calls to RequireObjectCoercible in the spec, we need this instruction
   1475     * only for [destructuring assignment][2] and [initialization][3].
   1476     *
   1477     * [1]: https://tc39.es/ecma262/#sec-requireobjectcoercible
   1478     * [2]: https://tc39.es/ecma262/#sec-runtime-semantics-destructuringassignmentevaluation
   1479     * [3]: https://tc39.es/ecma262/#sec-destructuring-binding-patterns-runtime-semantics-bindinginitialization
   1480     *
   1481     *   Category: Objects
   1482     *   Type: Iteration
   1483     *   Operands:
   1484     *   Stack: val => val
   1485     */ \
   1486    MACRO(CheckObjCoercible, check_obj_coercible, NULL, 1, 1, 1, JOF_BYTE) \
   1487    /*
   1488     * Create and push an async iterator wrapping the sync iterator `iter`.
   1489     * `next` should be `iter`'s `.next` method.
   1490     *
   1491     * Implements: [CreateAsyncToSyncIterator][1]. The spec says this operation
   1492     * takes one argument, but that argument is a Record with two relevant
   1493     * fields, `[[Iterator]]` and `[[NextMethod]]`.
   1494     *
   1495     * Used for `for await` loops.
   1496     *
   1497     * [1]: https://tc39.es/ecma262/#sec-createasyncfromsynciterator
   1498     *
   1499     *   Category: Objects
   1500     *   Type: Iteration
   1501     *   Operands:
   1502     *   Stack: iter, next => asynciter
   1503     */ \
   1504    MACRO(ToAsyncIter, to_async_iter, NULL, 1, 2, 1, JOF_BYTE) \
   1505    /*
   1506     * Set the prototype of `obj`.
   1507     *
   1508     * `obj` must be an object.
   1509     *
   1510     * Implements: [B.3.1 __proto__ Property Names in Object Initializers][1], step 7.a.
   1511     *
   1512     * [1]: https://tc39.es/ecma262/#sec-__proto__-property-names-in-object-initializers
   1513     *
   1514     *   Category: Objects
   1515     *   Type: SetPrototype
   1516     *   Operands:
   1517     *   Stack: obj, protoVal => obj
   1518     */ \
   1519    MACRO(MutateProto, mutate_proto, NULL, 1, 2, 1, JOF_BYTE) \
   1520    /*
   1521     * Create and push a new Array object with the given `length`,
   1522     * preallocating enough memory to hold that many elements.
   1523     *
   1524     *   Category: Objects
   1525     *   Type: Array literals
   1526     *   Operands: uint32_t length
   1527     *   Stack: => array
   1528     */ \
   1529    MACRO(NewArray, new_array, NULL, 5, 0, 1, JOF_UINT32|JOF_IC) \
   1530    /*
   1531     * Initialize an array element `array[index]` with value `val`.
   1532     *
   1533     * `val` may be `MagicValue(JS_ELEMENTS_HOLE)` pushed by `JSOp::Hole`.
   1534     *
   1535     * This never calls setters or proxy traps.
   1536     *
   1537     * `array` must be an Array object created by `JSOp::NewArray` with length >
   1538     * `index`, and never used except by `JSOp::InitElemArray`.
   1539     *
   1540     * Implements: [ArrayAccumulation][1], the third algorithm, step 4, in the
   1541     * common case where *nextIndex* is known.
   1542     *
   1543     * [1]: https://tc39.es/ecma262/#sec-runtime-semantics-arrayaccumulation
   1544     *
   1545     *   Category: Objects
   1546     *   Type: Array literals
   1547     *   Operands: uint32_t index
   1548     *   Stack: array, val => array
   1549     */ \
   1550    MACRO(InitElemArray, init_elem_array, NULL, 5, 2, 1, JOF_UINT32|JOF_PROPINIT) \
   1551    /*
   1552     * Initialize an array element `array[index++]` with value `val`.
   1553     *
   1554     * `val` may be `MagicValue(JS_ELEMENTS_HOLE)` pushed by `JSOp::Hole`. If it
   1555     * is, no element is defined, but the array length and the stack value
   1556     * `index` are still incremented.
   1557     *
   1558     * This never calls setters or proxy traps.
   1559     *
   1560     * `array` must be an Array object created by `JSOp::NewArray` and never used
   1561     * except by `JSOp::InitElemArray` and `JSOp::InitElemInc`.
   1562     *
   1563     * `index` must be an integer, `0 <= index <= INT32_MAX`. If `index` is
   1564     * `INT32_MAX`, this throws a RangeError. Unlike `InitElemArray`, it is not
   1565     * necessary that the `array` length > `index`.
   1566     *
   1567     * This instruction is used when an array literal contains a
   1568     * *SpreadElement*. In `[a, ...b, c]`, `InitElemArray 0` is used to put
   1569     * `a` into the array, but `InitElemInc` is used for the elements of `b`
   1570     * and for `c`.
   1571     *
   1572     * Implements: Several steps in [ArrayAccumulation][1] that call
   1573     * CreateDataProperty, set the array length, and/or increment *nextIndex*.
   1574     *
   1575     * [1]: https://tc39.es/ecma262/#sec-runtime-semantics-arrayaccumulation
   1576     *
   1577     *   Category: Objects
   1578     *   Type: Array literals
   1579     *   Operands:
   1580     *   Stack: array, index, val => array, (index + 1)
   1581     */ \
   1582    MACRO(InitElemInc, init_elem_inc, NULL, 1, 3, 2, JOF_BYTE|JOF_PROPINIT|JOF_IC) \
   1583    /*
   1584     * Push `MagicValue(JS_ELEMENTS_HOLE)`, representing an *Elision* in an
   1585     * array literal (like the missing property 0 in the array `[, 1]`).
   1586     *
   1587     * This magic value must be used only by `JSOp::InitElemArray` or
   1588     * `JSOp::InitElemInc`.
   1589     *
   1590     *   Category: Objects
   1591     *   Type: Array literals
   1592     *   Operands:
   1593     *   Stack: => hole
   1594     */ \
   1595    MACRO(Hole, hole, NULL, 1, 0, 1, JOF_BYTE) \
   1596    /*
   1597     * Clone and push a new RegExp object.
   1598     *
   1599     * Implements: [Evaluation for *RegularExpressionLiteral*][1].
   1600     *
   1601     * [1]: https://tc39.es/ecma262/#sec-regular-expression-literals-runtime-semantics-evaluation
   1602     *
   1603     *   Category: Objects
   1604     *   Type: RegExp literals
   1605     *   Operands: uint32_t regexpIndex
   1606     *   Stack: => regexp
   1607     */ \
   1608    MACRO(RegExp, reg_exp, NULL, 5, 0, 1, JOF_REGEXP) \
   1609    /*
   1610     * Push a new function object.
   1611     *
   1612     * The new function inherits the current environment chain.
   1613     *
   1614     * Used to create most JS functions. Notable exceptions are derived or
   1615     * default class constructors.
   1616     *
   1617     * Implements: [InstantiateFunctionObject][1], [Evaluation for
   1618     * *FunctionExpression*][2], and so on.
   1619     *
   1620     * [1]: https://tc39.es/ecma262/#sec-function-definitions-runtime-semantics-instantiatefunctionobject
   1621     * [2]: https://tc39.es/ecma262/#sec-function-definitions-runtime-semantics-evaluation
   1622     *
   1623     *   Category: Functions
   1624     *   Type: Creating functions
   1625     *   Operands: uint32_t funcIndex
   1626     *   Stack: => fn
   1627     */ \
   1628    MACRO(Lambda, lambda, NULL, 5, 0, 1, JOF_OBJECT|JOF_USES_ENV|JOF_IC) \
   1629    /*
   1630     * Set the name of a function.
   1631     *
   1632     * `fun` must be a function object. `name` must be a string, Int32 value,
   1633     * or symbol (like the result of `JSOp::ToId`).
   1634     *
   1635     * Implements: [SetFunctionName][1], used e.g. to name methods with
   1636     * computed property names.
   1637     *
   1638     * [1]: https://tc39.es/ecma262/#sec-setfunctionname
   1639     *
   1640     *   Category: Functions
   1641     *   Type: Creating functions
   1642     *   Operands: FunctionPrefixKind prefixKind
   1643     *   Stack: fun, name => fun
   1644     */ \
   1645    MACRO(SetFunName, set_fun_name, NULL, 2, 2, 1, JOF_UINT8) \
   1646    /*
   1647     * Initialize the home object for functions with super bindings.
   1648     *
   1649     * `fun` must be a method, getter, or setter, so that it has a
   1650     * [[HomeObject]] slot. `homeObject` must be a plain object or (for static
   1651     * methods) a constructor.
   1652     *
   1653     *   Category: Functions
   1654     *   Type: Creating functions
   1655     *   Operands:
   1656     *   Stack: fun, homeObject => fun
   1657     */ \
   1658    MACRO(InitHomeObject, init_home_object, NULL, 1, 2, 1, JOF_BYTE) \
   1659    /*
   1660     * Throw a TypeError if `baseClass` isn't either `null` or a constructor.
   1661     *
   1662     * Implements: [ClassDefinitionEvaluation][1] step 6.f.
   1663     *
   1664     * [1]: https://tc39.es/ecma262/#sec-runtime-semantics-classdefinitionevaluation
   1665     *
   1666     *   Category: Functions
   1667     *   Type: Creating constructors
   1668     *   Operands:
   1669     *   Stack: baseClass => baseClass
   1670     */ \
   1671    MACRO(CheckClassHeritage, check_class_heritage, NULL, 1, 1, 1, JOF_BYTE) \
   1672    /*
   1673     * Like `JSOp::Lambda`, but using `proto` as the new function's
   1674     * `[[Prototype]]` (or `%FunctionPrototype%` if `proto` is `null`).
   1675     *
   1676     * `proto` must be either a constructor or `null`. We use
   1677     * `JSOp::CheckClassHeritage` to check.
   1678     *
   1679     * This is used to create the constructor for a derived class.
   1680     *
   1681     * Implements: [ClassDefinitionEvaluation][1] steps 6.e.ii, 6.g.iii, and
   1682     * 12 for derived classes.
   1683     *
   1684     * [1]: https://tc39.es/ecma262/#sec-runtime-semantics-classdefinitionevaluation
   1685     *
   1686     *   Category: Functions
   1687     *   Type: Creating constructors
   1688     *   Operands: uint32_t funcIndex
   1689     *   Stack: proto => obj
   1690     */ \
   1691    MACRO(FunWithProto, fun_with_proto, NULL, 5, 1, 1, JOF_OBJECT|JOF_USES_ENV) \
   1692    /*
   1693     * Pushes the current global's %BuiltinObject%.
   1694     *
   1695     * `kind` must be a valid `BuiltinObjectKind` (and must not be
   1696     * `BuiltinObjectKind::None`).
   1697     *
   1698     *   Category: Objects
   1699     *   Type: Built-in objects
   1700     *   Operands: uint8_t kind
   1701     *   Stack: => %BuiltinObject%
   1702     */ \
   1703    MACRO(BuiltinObject, builtin_object, NULL, 2, 0, 1, JOF_UINT8|JOF_IC) \
   1704    /*
   1705     * Invoke `callee` with `this` and `args`, and push the return value. Throw
   1706     * a TypeError if `callee` isn't a function.
   1707     *
   1708     * `JSOp::CallContent` is for `callContentFunction` in self-hosted JS, and
   1709     * this is for handling it differently in debugger's `onNativeCall` hook.
   1710     * `onNativeCall` hook disables all JITs, and `JSOp::CallContent` is
   1711     * treated exactly the same as `JSOP::Call` in JIT.
   1712     *
   1713     * `JSOp::CallIter` is used for implicit calls to @@iterator methods, to
   1714     * ensure error messages are formatted with `JSMSG_NOT_ITERABLE` ("x is not
   1715     * iterable") rather than `JSMSG_NOT_FUNCTION` ("x[Symbol.iterator] is not
   1716     * a function"). The `argc` operand must be 0 for this variation.
   1717     *
   1718     * `JSOp::CallContentIter` is `JSOp::CallContent` variant of
   1719     * `JSOp::CallIter`.
   1720     *
   1721     * `JSOp::CallIgnoresRv` hints to the VM that the return value is ignored.
   1722     * This allows alternate faster implementations to be used that avoid
   1723     * unnecesary allocations.
   1724     *
   1725     * Implements: [EvaluateCall][1] steps 4, 5, and 7.
   1726     *
   1727     * [1]: https://tc39.es/ecma262/#sec-evaluatecall
   1728     *
   1729     *   Category: Functions
   1730     *   Type: Calls
   1731     *   Operands: uint16_t argc
   1732     *   Stack: callee, this, args[0], ..., args[argc-1] => rval
   1733     */ \
   1734    MACRO(Call, call, NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_IC) \
   1735    MACRO(CallContent, call_content, NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_IC) \
   1736    MACRO(CallIter, call_iter, NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_IC) \
   1737    MACRO(CallContentIter, call_content_iter, NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_IC) \
   1738    MACRO(CallIgnoresRv, call_ignores_rv, NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_IC) \
   1739    /*
   1740     * Like `JSOp::Call`, but the arguments are provided in an array rather than
   1741     * a span of stack slots. Used to implement spread-call syntax:
   1742     * `f(...args)`.
   1743     *
   1744     * `args` must be an Array object containing the actual arguments. The
   1745     * array must be packed (dense and free of holes; see IsPackedArray).
   1746     * This can be ensured by creating the array with `JSOp::NewArray` and
   1747     * populating it using `JSOp::InitElemArray`.
   1748     *
   1749     *   Category: Functions
   1750     *   Type: Calls
   1751     *   Operands:
   1752     *   Stack: callee, this, args => rval
   1753     */ \
   1754    MACRO(SpreadCall, spread_call, NULL, 1, 3, 1, JOF_BYTE|JOF_INVOKE|JOF_SPREAD|JOF_IC) \
   1755    /*
   1756     * Push an array object that can be passed directly as the `args` argument
   1757     * to `JSOp::SpreadCall`. If the operation can't be optimized, push
   1758     * `undefined` instead.
   1759     *
   1760     * This instruction and the branch around the iterator loop are emitted
   1761     * only when `iterable` is the sole argument in a call, as in `f(...arr)`.
   1762     *
   1763     * See `js::OptimizeSpreadCall`.
   1764     *
   1765     *   Category: Functions
   1766     *   Type: Calls
   1767     *   Operands:
   1768     *   Stack: iterable => array_or_undefined
   1769     */ \
   1770    MACRO(OptimizeSpreadCall, optimize_spread_call, NULL, 1, 1, 1, JOF_BYTE|JOF_IC) \
   1771    /*
   1772     * Perform a direct eval in the current environment if `callee` is the
   1773     * builtin `eval` function, otherwise follow same behaviour as `JSOp::Call`.
   1774     *
   1775     * All direct evals use one of the JSOp::*Eval instructions here and these
   1776     * opcodes are only used when the syntactic conditions for a direct eval
   1777     * are met. If the builtin `eval` function is called though other means, it
   1778     * becomes an indirect eval.
   1779     *
   1780     * Direct eval causes all bindings in *enclosing* non-global scopes to be
   1781     * marked "aliased". The optimization that puts bindings in stack slots has
   1782     * to prove that the bindings won't need to be captured by closures or
   1783     * accessed using `JSOp::{Get,Bind,Set,Del}Name` instructions. Direct eval
   1784     * makes that analysis impossible.
   1785     *
   1786     * The instruction immediately following any `JSOp::*Eval` instruction must
   1787     * be `JSOp::Lineno`.
   1788     *
   1789     * Implements: [Function Call Evaluation][1], steps 5-7 and 9, when the
   1790     * syntactic critera for direct eval in step 6 are all met.
   1791     *
   1792     * [1]: https://tc39.es/ecma262/#sec-function-calls-runtime-semantics-evaluation
   1793     *
   1794     *   Category: Functions
   1795     *   Type: Calls
   1796     *   Operands: uint16_t argc
   1797     *   Stack: callee, this, args[0], ..., args[argc-1] => rval
   1798     */ \
   1799    MACRO(Eval, eval, NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_CHECKSLOPPY|JOF_IC) \
   1800    /*
   1801     * Spread-call variant of `JSOp::Eval`.
   1802     *
   1803     * See `JSOp::SpreadCall` for restrictions on `args`.
   1804     *
   1805     *   Category: Functions
   1806     *   Type: Calls
   1807     *   Operands:
   1808     *   Stack: callee, this, args => rval
   1809     */ \
   1810    MACRO(SpreadEval, spread_eval, NULL, 1, 3, 1, JOF_BYTE|JOF_INVOKE|JOF_SPREAD|JOF_CHECKSLOPPY|JOF_IC) \
   1811    /*
   1812     * Like `JSOp::Eval`, but for strict mode code.
   1813     *
   1814     *   Category: Functions
   1815     *   Type: Calls
   1816     *   Operands: uint16_t argc
   1817     *   Stack: evalFn, this, args[0], ..., args[argc-1] => rval
   1818     */ \
   1819    MACRO(StrictEval, strict_eval, NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_CHECKSTRICT|JOF_IC) \
   1820    /*
   1821     * Spread-call variant of `JSOp::StrictEval`.
   1822     *
   1823     * See `JSOp::SpreadCall` for restrictions on `args`.
   1824     *
   1825     *   Category: Functions
   1826     *   Type: Calls
   1827     *   Operands:
   1828     *   Stack: callee, this, args => rval
   1829     */ \
   1830    MACRO(StrictSpreadEval, strict_spread_eval, NULL, 1, 3, 1, JOF_BYTE|JOF_INVOKE|JOF_SPREAD|JOF_CHECKSTRICT|JOF_IC) \
   1831    /*
   1832     * Push the implicit `this` value for an unqualified function call, like
   1833     * `foo()`.
   1834     *
   1835     * The result is always `undefined` except when the name refers to a `with`
   1836     * binding.  For example, in `with (date) { getFullYear(); }`, the
   1837     * implicit `this` passed to `getFullYear` is `date`, not `undefined`.
   1838     *
   1839     * Implements: [EvaluateCall][1] step 1.b.
   1840     *
   1841     * [1]: https://tc39.es/ecma262/#sec-evaluatecall
   1842     *
   1843     *   Category: Functions
   1844     *   Type: Calls
   1845     *   Operands:
   1846     *   Stack: env => this
   1847     */ \
   1848    MACRO(ImplicitThis, implicit_this, "", 1, 1, 1, JOF_BYTE) \
   1849    /*
   1850     * Push the call site object for a tagged template call.
   1851     *
   1852     * `script->getObject(objectIndex)` is the call site object.
   1853     *
   1854     * The call site object will already have the `.raw` property defined on it
   1855     * and will be frozen.
   1856     *
   1857     *   Category: Functions
   1858     *   Type: Calls
   1859     *   Operands: uint32_t objectIndex
   1860     *   Stack: => callSiteObj
   1861     */ \
   1862    MACRO(CallSiteObj, call_site_obj, NULL, 5, 0, 1, JOF_OBJECT) \
   1863    /*
   1864     * Push `MagicValue(JS_IS_CONSTRUCTING)`.
   1865     *
   1866     * This magic value is a required argument to the `JSOp::New` and
   1867     * `JSOp::SuperCall` instructions and must not be used any other way.
   1868     *
   1869     *   Category: Functions
   1870     *   Type: Calls
   1871     *   Operands:
   1872     *   Stack: => JS_IS_CONSTRUCTING
   1873     */ \
   1874    MACRO(IsConstructing, is_constructing, NULL, 1, 0, 1, JOF_BYTE) \
   1875    /*
   1876     * Invoke `callee` as a constructor with `args` and `newTarget`, and push
   1877     * the return value. Throw a TypeError if `callee` isn't a constructor.
   1878     *
   1879     * `isConstructing` must be the value pushed by `JSOp::IsConstructing`.
   1880     *
   1881     * `JSOp::SuperCall` behaves exactly like `JSOp::New`, but is used for
   1882     * *SuperCall* expressions, to allow JITs to distinguish them from `new`
   1883     * expressions.
   1884     *
   1885     * `JSOp::NewContent` is for `constructContentFunction` in self-hosted JS.
   1886     * See the comment for `JSOp::CallContent` for more details.
   1887     *
   1888     * Implements: [EvaluateConstruct][1] steps 7 and 8.
   1889     *
   1890     * [1]: https://tc39.es/ecma262/#sec-evaluatenew
   1891     *
   1892     *   Category: Functions
   1893     *   Type: Calls
   1894     *   Operands: uint16_t argc
   1895     *   Stack: callee, isConstructing, args[0], ..., args[argc-1], newTarget => rval
   1896     */ \
   1897    MACRO(New, new_, NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_CONSTRUCT|JOF_IC) \
   1898    MACRO(NewContent, new_content, NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_CONSTRUCT|JOF_IC) \
   1899    MACRO(SuperCall, super_call, NULL, 3, -1, 1, JOF_ARGC|JOF_INVOKE|JOF_CONSTRUCT|JOF_IC) \
   1900    /*
   1901     * Spread-call variant of `JSOp::New`.
   1902     *
   1903     * Invokes `callee` as a constructor with `args` and `newTarget`, and
   1904     * pushes the return value onto the stack.
   1905     *
   1906     * `isConstructing` must be the value pushed by `JSOp::IsConstructing`.
   1907     * See `JSOp::SpreadCall` for restrictions on `args`.
   1908     *
   1909     * `JSOp::SpreadSuperCall` behaves exactly like `JSOp::SpreadNew`, but is
   1910     * used for *SuperCall* expressions.
   1911     *
   1912     *   Category: Functions
   1913     *   Type: Calls
   1914     *   Operands:
   1915     *   Stack: callee, isConstructing, args, newTarget => rval
   1916     */ \
   1917    MACRO(SpreadNew, spread_new, NULL, 1, 4, 1, JOF_BYTE|JOF_INVOKE|JOF_CONSTRUCT|JOF_SPREAD|JOF_IC) \
   1918    MACRO(SpreadSuperCall, spread_super_call, NULL, 1, 4, 1, JOF_BYTE|JOF_INVOKE|JOF_CONSTRUCT|JOF_SPREAD|JOF_IC) \
   1919    /*
   1920     * Push the prototype of `callee` in preparation for calling `super()`.
   1921     *
   1922     * `callee` must be a derived class constructor.
   1923     *
   1924     * Implements: [GetSuperConstructor][1], steps 4-7.
   1925     *
   1926     * [1]: https://tc39.es/ecma262/#sec-getsuperconstructor
   1927     *
   1928     *   Category: Functions
   1929     *   Type: Calls
   1930     *   Operands:
   1931     *   Stack: callee => superFun
   1932     */ \
   1933    MACRO(SuperFun, super_fun, NULL, 1, 1, 1, JOF_BYTE) \
   1934    /*
   1935     * Throw a ReferenceError if `thisval` is not
   1936     * `MagicValue(JS_UNINITIALIZED_LEXICAL)`. Used in derived class
   1937     * constructors to prohibit calling `super` more than once.
   1938     *
   1939     * Implements: [BindThisValue][1], step 3.
   1940     *
   1941     * [1]: https://tc39.es/ecma262/#sec-bindthisvalue
   1942     *
   1943     *   Category: Functions
   1944     *   Type: Calls
   1945     *   Operands:
   1946     *   Stack: thisval => thisval
   1947     */ \
   1948    MACRO(CheckThisReinit, check_this_reinit, NULL, 1, 1, 1, JOF_BYTE) \
   1949    /*
   1950     * Create and push a generator object for the current frame.
   1951     *
   1952     * This instruction must appear only in scripts for generators, async
   1953     * functions, and async generators. There must not already be a generator
   1954     * object for the current frame (that is, this instruction must execute at
   1955     * most once per generator or async call).
   1956     *
   1957     *   Category: Functions
   1958     *   Type: Generators and async functions
   1959     *   Operands:
   1960     *   Stack: => gen
   1961     */ \
   1962    MACRO(Generator, generator, NULL, 1, 0, 1, JOF_BYTE|JOF_USES_ENV) \
   1963    /*
   1964     * Suspend the current generator and return to the caller.
   1965     *
   1966     * When a generator is called, its script starts running, like any other JS
   1967     * function, because [FunctionDeclarationInstantation][1] and other
   1968     * [generator object setup][2] are implemented mostly in bytecode. However,
   1969     * the *FunctionBody* of the generator is not supposed to start running
   1970     * until the first `.next()` call, so after setup the script suspends
   1971     * itself: the "initial yield".
   1972     *
   1973     * Later, when resuming execution, `rval`, `gen` and `resumeKind` will
   1974     * receive the values passed in by `JSOp::Resume`. `resumeKind` is the
   1975     * `GeneratorResumeKind` stored as an Int32 value.
   1976     *
   1977     * This instruction must appear only in scripts for generators and async
   1978     * generators. `gen` must be the generator object for the current frame. It
   1979     * must not have been previously suspended. The resume point indicated by
   1980     * `resumeIndex` must be the next instruction in the script, which must be
   1981     * `AfterYield`.
   1982     *
   1983     * Implements: [GeneratorStart][3], steps 4-7.
   1984     *
   1985     * [1]: https://tc39.es/ecma262/#sec-functiondeclarationinstantiation
   1986     * [2]: https://tc39.es/ecma262/#sec-generator-function-definitions-runtime-semantics-evaluatebody
   1987     * [3]: https://tc39.es/ecma262/#sec-generatorstart
   1988     *
   1989     *   Category: Functions
   1990     *   Type: Generators and async functions
   1991     *   Operands: uint24_t resumeIndex
   1992     *   Stack: gen => rval, gen, resumeKind
   1993     */ \
   1994    MACRO(InitialYield, initial_yield, NULL, 4, 1, 3, JOF_RESUMEINDEX) \
   1995    /*
   1996     * Bytecode emitted after `yield` expressions. This is useful for the
   1997     * Debugger and `AbstractGeneratorObject::isAfterYieldOrAwait`. It's
   1998     * treated as jump target op so that the Baseline Interpreter can
   1999     * efficiently restore the frame's interpreterICEntry when resuming a
   2000     * generator.
   2001     *
   2002     * The preceding instruction in the script must be `Yield`, `InitialYield`,
   2003     * or `Await`.
   2004     *
   2005     *   Category: Functions
   2006     *   Type: Generators and async functions
   2007     *   Operands: uint32_t icIndex
   2008     *   Stack: =>
   2009     */ \
   2010    MACRO(AfterYield, after_yield, NULL, 5, 0, 0, JOF_ICINDEX) \
   2011    /*
   2012     * Suspend and close the current generator, async function, or async
   2013     * generator.
   2014     *
   2015     * `gen` must be the generator object for the current frame.
   2016     *
   2017     * If the current function is a non-async generator, then the value in the
   2018     * frame's return value slot is returned to the caller. It should be an
   2019     * object of the form `{value: returnValue, done: true}`.
   2020     *
   2021     * If the current function is an async function or async generator, the
   2022     * frame's return value slot must contain the current frame's result
   2023     * promise, which must already be resolved or rejected.
   2024     *
   2025     *   Category: Functions
   2026     *   Type: Generators and async functions
   2027     *   Operands:
   2028     *   Stack: gen =>
   2029     */ \
   2030    MACRO(FinalYieldRval, final_yield_rval, NULL, 1, 1, 0, JOF_BYTE) \
   2031    /*
   2032     * Suspend execution of the current generator or async generator, returning
   2033     * `rval1`.
   2034     *
   2035     * For non-async generators, `rval1` should be an object of the form
   2036     * `{value: valueToYield, done: true}`. For async generators, `rval1`
   2037     * should be the value to yield, and the caller is responsible for creating
   2038     * the iterator result object (under `js::AsyncGeneratorYield`).
   2039     *
   2040     * This instruction must appear only in scripts for generators and async
   2041     * generators. `gen` must be the generator object for the current stack
   2042     * frame. The resume point indicated by `resumeIndex` must be the next
   2043     * instruction in the script, which must be `AfterYield`.
   2044     *
   2045     * When resuming execution, `rval2`, `gen` and `resumeKind` receive the
   2046     * values passed in by `JSOp::Resume`.
   2047     *
   2048     * Implements: [GeneratorYield][1] and [AsyncGeneratorYield][2].
   2049     *
   2050     * [1]: https://tc39.es/ecma262/#sec-generatoryield
   2051     * [2]: https://tc39.es/ecma262/#sec-asyncgeneratoryield
   2052     *
   2053     *   Category: Functions
   2054     *   Type: Generators and async functions
   2055     *   Operands: uint24_t resumeIndex
   2056     *   Stack: rval1, gen => rval2, gen, resumeKind
   2057     */ \
   2058    MACRO(Yield, yield, NULL, 4, 2, 3, JOF_RESUMEINDEX) \
   2059    /*
   2060     * Pushes a boolean indicating whether the top of the stack is
   2061     * `MagicValue(JS_GENERATOR_CLOSING)`.
   2062     *
   2063     *   Category: Functions
   2064     *   Type: Generators and async functions
   2065     *   Operands:
   2066     *   Stack: val => val, res
   2067     */ \
   2068    MACRO(IsGenClosing, is_gen_closing, NULL, 1, 1, 2, JOF_BYTE) \
   2069    /*
   2070     * Arrange for this async function to resume asynchronously when `value`
   2071     * becomes resolved.
   2072     *
   2073     * This is the last thing an async function does before suspending for an
   2074     * `await` expression. It coerces the awaited `value` to a promise and
   2075     * effectively calls `.then()` on it, passing handler functions that will
   2076     * resume this async function call later. See `js::AsyncFunctionAwait`.
   2077     *
   2078     * This instruction must appear only in non-generator async function
   2079     * scripts. `gen` must be the internal generator object for the current
   2080     * frame. After this instruction, the script should suspend itself with
   2081     * `Await` (rather than exiting any other way).
   2082     *
   2083     * The result `promise` is the async function's result promise,
   2084     * `gen->as<AsyncFunctionGeneratorObject>().promise()`.
   2085     *
   2086     * Implements: [Await][1], steps 2-9.
   2087     *
   2088     * [1]: https://tc39.github.io/ecma262/#await
   2089     *
   2090     *   Category: Functions
   2091     *   Type: Generators and async functions
   2092     *   Operands:
   2093     *   Stack: value, gen => promise
   2094     */ \
   2095    MACRO(AsyncAwait, async_await, NULL, 1, 2, 1, JOF_BYTE) \
   2096    /*
   2097     * Resolve the current async function's result promise with 'value'.
   2098     *
   2099     * This instruction must appear only in non-generator async function
   2100     * scripts. `gen` must be the internal generator object for the current
   2101     * frame. This instruction must run at most once per async function call,
   2102     * as resolving an already resolved/rejected promise is not permitted.
   2103     *
   2104     * The result `promise` is the async function's result promise,
   2105     * `gen->as<AsyncFunctionGeneratorObject>().promise()`.
   2106     *
   2107     * Implements: [AsyncFunctionStart][1], step 4.d.i. and 4.e.i.
   2108     *
   2109     * [1]: https://tc39.es/ecma262/#sec-async-functions-abstract-operations-async-function-start
   2110     *
   2111     *   Category: Functions
   2112     *   Type: Generators and async functions
   2113     *   Operands:
   2114     *   Stack: value, gen => promise
   2115     */ \
   2116    MACRO(AsyncResolve, async_resolve, NULL, 1, 2, 1, JOF_BYTE) \
   2117    /*
   2118     * Reject the current async function's result promise with 'reason'.
   2119     *
   2120     * This instruction must appear only in non-generator async function
   2121     * scripts. `gen` must be the internal generator object for the current
   2122     * frame. This instruction must run at most once per async function call,
   2123     * as rejecting an already resolved/rejected promise is not permitted.
   2124     *
   2125     * The result `promise` is the async function's result promise,
   2126     * `gen->as<AsyncFunctionGeneratorObject>().promise()`.
   2127     *
   2128     * Implements: [AsyncFunctionStart][1], step 4.d.i. and 4.e.i.
   2129     *
   2130     * [1]: https://tc39.es/ecma262/#sec-async-functions-abstract-operations-async-function-start
   2131     *
   2132     *   Category: Functions
   2133     *   Type: Generators and async functions
   2134     *   Operands:
   2135     *   Stack: reason, stack, gen => promise
   2136     */ \
   2137    MACRO(AsyncReject, async_reject, NULL, 1, 3, 1, JOF_BYTE) \
   2138    /*
   2139     * Suspend the current frame for an `await` expression.
   2140     *
   2141     * This instruction must appear only in scripts for async functions and
   2142     * async generators. `gen` must be the internal generator object for the
   2143     * current frame.
   2144     *
   2145     * This returns `promise` to the caller. Later, when this async call is
   2146     * resumed, `resolved`, `gen` and `resumeKind` receive the values passed in
   2147     * by `JSOp::Resume`, and execution continues at the next instruction,
   2148     * which must be `AfterYield`.
   2149     *
   2150     * This instruction is used in two subtly different ways.
   2151     *
   2152     * 1.  In async functions:
   2153     *
   2154     *         ...                          # valueToAwait
   2155     *         GetAliasedVar ".generator"   # valueToAwait gen
   2156     *         AsyncAwait                   # resultPromise
   2157     *         GetAliasedVar ".generator"   # resultPromise gen
   2158     *         Await                        # resolved gen resumeKind
   2159     *         AfterYield
   2160     *
   2161     *     `AsyncAwait` arranges for this frame to be resumed later and pushes
   2162     *     its result promise. `Await` then suspends the frame and removes it
   2163     *     from the stack, returning the result promise to the caller. (If this
   2164     *     async call hasn't awaited before, the caller may be user code.
   2165     *     Otherwise, the caller is self-hosted code using `resumeGenerator`.)
   2166     *
   2167     * 2.  In async generators:
   2168     *
   2169     *         ...                          # valueToAwait
   2170     *         GetAliasedVar ".generator"   # valueToAwait gen
   2171     *         Await                        # resolved gen resumeKind
   2172     *         AfterYield
   2173     *
   2174     *     `AsyncAwait` is not used, so (1) the value returned to the caller by
   2175     *     `Await` is `valueToAwait`, not `resultPromise`; and (2) the caller
   2176     *     is responsible for doing the async-generator equivalent of
   2177     *     `AsyncAwait` (namely, `js::AsyncGeneratorAwait`, called from
   2178     *     `js::AsyncGeneratorResume` after `js::CallSelfHostedFunction`
   2179     *     returns).
   2180     *
   2181     * Implements: [Await][1], steps 10-12.
   2182     *
   2183     * [1]: https://tc39.es/ecma262/#await
   2184     *
   2185     *   Category: Functions
   2186     *   Type: Generators and async functions
   2187     *   Operands: uint24_t resumeIndex
   2188     *   Stack: promise, gen => resolved, gen, resumeKind
   2189     */ \
   2190    MACRO(Await, await, NULL, 4, 2, 3, JOF_RESUMEINDEX) \
   2191    /*
   2192     * Test if the re-entry to the microtask loop may be skipped.
   2193     *
   2194     * This is part of an optimization for `await` expressions. Programs very
   2195     * often await values that aren't promises, or promises that are already
   2196     * resolved. We can then sometimes skip suspending the current frame and
   2197     * returning to the microtask loop. If the circumstances permit the
   2198     * optimization, `CanSkipAwait` pushes true if the optimization is allowed,
   2199     * and false otherwise.
   2200     *
   2201     *   Category: Functions
   2202     *   Type: Generators and async functions
   2203     *   Operands:
   2204     *   Stack: value => value, can_skip
   2205     */ \
   2206    MACRO(CanSkipAwait, can_skip_await, NULL, 1, 1, 2, JOF_BYTE) \
   2207    /*
   2208     * Potentially extract an awaited value, if the await is skippable
   2209     *
   2210     * If re-entering the microtask loop is skippable (as checked by CanSkipAwait)
   2211     * if can_skip is true,  `MaybeExtractAwaitValue` replaces `value` with the result of the
   2212     * `await` expression (unwrapping the resolved promise, if any). Otherwise, value remains
   2213     * as is.
   2214     *
   2215     * In both cases, can_skip remains the same.
   2216     *
   2217     *   Category: Functions
   2218     *   Type: Generators and async functions
   2219     *   Operands:
   2220     *   Stack: value, can_skip => value_or_resolved, can_skip
   2221     */ \
   2222    MACRO(MaybeExtractAwaitValue, maybe_extract_await_value, NULL, 1, 2, 2, JOF_BYTE) \
   2223    /*
   2224     * Pushes one of the GeneratorResumeKind values as Int32Value.
   2225     *
   2226     *   Category: Functions
   2227     *   Type: Generators and async functions
   2228     *   Operands: GeneratorResumeKind resumeKind (encoded as uint8_t)
   2229     *   Stack: => resumeKind
   2230     */ \
   2231    MACRO(ResumeKind, resume_kind, NULL, 2, 0, 1, JOF_UINT8) \
   2232    /*
   2233     * Handle Throw and Return resumption.
   2234     *
   2235     * `gen` must be the generator object for the current frame. `resumeKind`
   2236     * must be a `GeneratorResumeKind` stored as an `Int32` value. If it is
   2237     * `Next`, continue to the next instruction. If `resumeKind` is `Throw` or
   2238     * `Return`, these completions are handled by throwing an exception. See
   2239     * `GeneratorThrowOrReturn`.
   2240     *
   2241     *   Category: Functions
   2242     *   Type: Generators and async functions
   2243     *   Operands:
   2244     *   Stack: rval, gen, resumeKind => rval
   2245     */ \
   2246    MACRO(CheckResumeKind, check_resume_kind, NULL, 1, 3, 1, JOF_BYTE) \
   2247    /*
   2248     * Resume execution of a generator, async function, or async generator.
   2249     *
   2250     * This behaves something like a call instruction. It pushes a stack frame
   2251     * (the one saved when `gen` was suspended, rather than a fresh one) and
   2252     * runs instructions in it. Once `gen` returns or yields, its return value
   2253     * is pushed to this frame's stack and execution continues in this script.
   2254     *
   2255     * This instruction is emitted only for the `resumeGenerator` self-hosting
   2256     * intrinsic. It is used in the implementation of
   2257     * `%GeneratorPrototype%.next`, `.throw`, and `.return`.
   2258     *
   2259     * `gen` must be a suspended generator object. `resumeKind` must be in
   2260     * range for `GeneratorResumeKind`.
   2261     *
   2262     *   Category: Functions
   2263     *   Type: Generators and async functions
   2264     *   Operands:
   2265     *   Stack: gen, val, resumeKind => rval
   2266     */ \
   2267    MACRO(Resume, resume, NULL, 1, 3, 1, JOF_BYTE|JOF_INVOKE) \
   2268    /*
   2269     * No-op instruction marking the target of a jump instruction.
   2270     *
   2271     * This instruction and a few others (see `js::BytecodeIsJumpTarget`) are
   2272     * jump target instructions. The Baseline Interpreter uses these
   2273     * instructions to sync the frame's `interpreterICEntry` after a jump. Ion
   2274     * uses them to find block boundaries when translating bytecode to MIR.
   2275     *
   2276     *   Category: Control flow
   2277     *   Type: Jump targets
   2278     *   Operands: uint32_t icIndex
   2279     *   Stack: =>
   2280     */ \
   2281    MACRO(JumpTarget, jump_target, NULL, 5, 0, 0, JOF_ICINDEX) \
   2282    /*
   2283     * Marks the target of the backwards jump for some loop.
   2284     *
   2285     * This is a jump target instruction (see `JSOp::JumpTarget`). Additionally,
   2286     * it checks for interrupts and handles JIT tiering.
   2287     *
   2288     * The `depthHint` operand is a loop depth hint for Ion. It starts at 1 and
   2289     * deeply nested loops all have the same value.
   2290     *
   2291     * For the convenience of the JITs, scripts must not start with this
   2292     * instruction. See bug 1602390.
   2293     *
   2294     *   Category: Control flow
   2295     *   Type: Jump targets
   2296     *   Operands: uint32_t icIndex, uint8_t depthHint
   2297     *   Stack: =>
   2298     */ \
   2299    MACRO(LoopHead, loop_head, NULL, 6, 0, 0, JOF_LOOPHEAD) \
   2300    /*
   2301     * Jump to a 32-bit offset from the current bytecode.
   2302     *
   2303     * See "Jump instructions" above for details.
   2304     *
   2305     *   Category: Control flow
   2306     *   Type: Jumps
   2307     *   Operands: int32_t offset
   2308     *   Stack: =>
   2309     */ \
   2310    MACRO(Goto, goto_, NULL, 5, 0, 0, JOF_JUMP) \
   2311    /*
   2312     * If ToBoolean(`cond`) is false, jumps to a 32-bit offset from the current
   2313     * instruction.
   2314     *
   2315     *   Category: Control flow
   2316     *   Type: Jumps
   2317     *   Operands: int32_t forwardOffset
   2318     *   Stack: cond =>
   2319     */ \
   2320    MACRO(JumpIfFalse, jump_if_false, NULL, 5, 1, 0, JOF_JUMP|JOF_IC) \
   2321    /*
   2322     * If ToBoolean(`cond`) is true, jump to a 32-bit offset from the current
   2323     * instruction.
   2324     *
   2325     * `offset` may be positive or negative. This is the instruction used at the
   2326     * end of a do-while loop to jump back to the top.
   2327     *
   2328     *   Category: Control flow
   2329     *   Type: Jumps
   2330     *   Operands: int32_t offset
   2331     *   Stack: cond =>
   2332     */ \
   2333    MACRO(JumpIfTrue, jump_if_true, NULL, 5, 1, 0, JOF_JUMP|JOF_IC) \
   2334    /*
   2335     * Short-circuit for logical AND.
   2336     *
   2337     * If ToBoolean(`cond`) is false, jump to a 32-bit offset from the current
   2338     * instruction. The value remains on the stack.
   2339     *
   2340     *   Category: Control flow
   2341     *   Type: Jumps
   2342     *   Operands: int32_t forwardOffset
   2343     *   Stack: cond => cond
   2344     */ \
   2345    MACRO(And, and_, NULL, 5, 1, 1, JOF_JUMP|JOF_IC) \
   2346    /*
   2347     * Short-circuit for logical OR.
   2348     *
   2349     * If ToBoolean(`cond`) is true, jump to a 32-bit offset from the current
   2350     * instruction. The value remains on the stack.
   2351     *
   2352     *   Category: Control flow
   2353     *   Type: Jumps
   2354     *   Operands: int32_t forwardOffset
   2355     *   Stack: cond => cond
   2356     */ \
   2357    MACRO(Or, or_, NULL, 5, 1, 1, JOF_JUMP|JOF_IC) \
   2358    /*
   2359     * Short-circuiting for nullish coalescing.
   2360     *
   2361     * If `val` is not null or undefined, jump to a 32-bit offset from the
   2362     * current instruction.
   2363     *
   2364     *   Category: Control flow
   2365     *   Type: Jumps
   2366     *   Operands: int32_t forwardOffset
   2367     *   Stack: val => val
   2368     */ \
   2369    MACRO(Coalesce, coalesce, NULL, 5, 1, 1, JOF_JUMP) \
   2370     /*
   2371     * Like `JSOp::JumpIfTrue`, but if the branch is taken, pop and discard an
   2372     * additional stack value.
   2373     *
   2374     * This is used to implement `switch` statements when the
   2375     * `JSOp::TableSwitch` optimization is not possible. The switch statement
   2376     *
   2377     *     switch (expr) {
   2378     *         case A: stmt1;
   2379     *         case B: stmt2;
   2380     *     }
   2381     *
   2382     * compiles to this bytecode:
   2383     *
   2384     *         # dispatch code - evaluate expr, check it against each `case`,
   2385     *         # jump to the right place in the body or to the end.
   2386     *         <expr>
   2387     *         Dup; <A>; StrictEq; Case L1; JumpTarget
   2388     *         Dup; <B>; StrictEq; Case L2; JumpTarget
   2389     *         Default LE
   2390     *
   2391     *         # body code
   2392     *     L1: JumpTarget; <stmt1>
   2393     *     L2: JumpTarget; <stmt2>
   2394     *     LE: JumpTarget
   2395     *
   2396     * This opcode is weird: it's the only one whose ndefs varies depending on
   2397     * which way a conditional branch goes. We could implement switch
   2398     * statements using `JSOp::JumpIfTrue` and `JSOp::Pop`, but that would also
   2399     * be awkward--putting the `JSOp::Pop` inside the `switch` body would
   2400     * complicate fallthrough.
   2401     *
   2402     *   Category: Control flow
   2403     *   Type: Jumps
   2404     *   Operands: int32_t forwardOffset
   2405     *   Stack: val, cond => val (if !cond)
   2406     */ \
   2407    MACRO(Case, case_, NULL, 5, 2, 1, JOF_JUMP) \
   2408    /*
   2409     * Like `JSOp::Goto`, but pop and discard an additional stack value.
   2410     *
   2411     * This appears after all cases for a non-optimized `switch` statement. If
   2412     * there's a `default:` label, it jumps to that point in the body;
   2413     * otherwise it jumps to the next statement.
   2414     *
   2415     *   Category: Control flow
   2416     *   Type: Jumps
   2417     *   Operands: int32_t forwardOffset
   2418     *   Stack: lval =>
   2419     */ \
   2420    MACRO(Default, default_, NULL, 5, 1, 0, JOF_JUMP) \
   2421    /*
   2422     * Optimized switch-statement dispatch, used when all `case` labels are
   2423     * small integer constants.
   2424     *
   2425     * If `low <= i <= high`, jump to the instruction at the offset given by
   2426     * `script->resumeOffsets()[firstResumeIndex + i - low]`, in bytes from the
   2427     * start of the current script's bytecode. Otherwise, jump to the
   2428     * instruction at `defaultOffset` from the current instruction. All of
   2429     * these offsets must be in range for the current script and must point to
   2430     * `JSOp::JumpTarget` instructions.
   2431     *
   2432     * The following inequalities must hold: `low <= high` and
   2433     * `firstResumeIndex + high - low < resumeOffsets().size()`.
   2434     *
   2435     *   Category: Control flow
   2436     *   Type: Jumps
   2437     *   Operands: int32_t defaultOffset, int32_t low, int32_t high,
   2438     *             uint24_t firstResumeIndex
   2439     *   Stack: i =>
   2440     */ \
   2441    MACRO(TableSwitch, table_switch, NULL, 16, 1, 0, JOF_TABLESWITCH) \
   2442    /*
   2443     * Return `rval`.
   2444     *
   2445     * This must not be used in derived class constructors. Instead use
   2446     * `JSOp::SetRval`, `JSOp::CheckReturn`, and `JSOp::RetRval`.
   2447     *
   2448     *   Category: Control flow
   2449     *   Type: Return
   2450     *   Operands:
   2451     *   Stack: rval =>
   2452     */ \
   2453    MACRO(Return, return_, NULL, 1, 1, 0, JOF_BYTE) \
   2454    /*
   2455     * Push the current stack frame's `returnValue`. If no `JSOp::SetRval`
   2456     * instruction has been executed in this stack frame, this is `undefined`.
   2457     *
   2458     * Every stack frame has a `returnValue` slot, used by top-level scripts,
   2459     * generators, async functions, and derived class constructors. Plain
   2460     * functions usually use `JSOp::Return` instead.
   2461     *
   2462     *   Category: Control flow
   2463     *   Type: Return
   2464     *   Operands:
   2465     *   Stack: => rval
   2466     */ \
   2467    MACRO(GetRval, get_rval, NULL, 1, 0, 1, JOF_BYTE) \
   2468    /*
   2469     * Store `rval` in the current stack frame's `returnValue` slot.
   2470     *
   2471     * This instruction must not be used in a toplevel script compiled with the
   2472     * `noScriptRval` option.
   2473     *
   2474     *   Category: Control flow
   2475     *   Type: Return
   2476     *   Operands:
   2477     *   Stack: rval =>
   2478     */ \
   2479    MACRO(SetRval, set_rval, NULL, 1, 1, 0, JOF_BYTE) \
   2480    /*
   2481     * Stop execution and return the current stack frame's `returnValue`. If no
   2482     * `JSOp::SetRval` instruction has been executed in this stack frame, this
   2483     * is `undefined`.
   2484     *
   2485     * Also emitted at end of every script so consumers don't need to worry
   2486     * about running off the end.
   2487     *
   2488     * If the current script is a derived class constructor, `returnValue` must
   2489     * be an object. The script can use `JSOp::CheckReturn` to ensure this.
   2490     *
   2491     *   Category: Control flow
   2492     *   Type: Return
   2493     *   Operands:
   2494     *   Stack: =>
   2495     */ \
   2496    MACRO(RetRval, ret_rval, NULL, 1, 0, 0, JOF_BYTE) \
   2497    /*
   2498     * Check the return value in a derived class constructor.
   2499     *
   2500     * -   If the current stack frame's `returnValue` is an object, push
   2501     *     `returnValue` onto the stack.
   2502     *
   2503     * -   Otherwise, if the `returnValue` is undefined and `thisval` is an
   2504     *     object, push `thisval` onto the stack.
   2505     *
   2506     * -   Otherwise, throw a TypeError.
   2507     *
   2508     * This is exactly what has to happen when a derived class constructor
   2509     * returns. `thisval` should be the current value of `this`, or
   2510     * `MagicValue(JS_UNINITIALIZED_LEXICAL)` if `this` is uninitialized.
   2511     *
   2512     * Implements: [The [[Construct]] internal method of JS functions][1],
   2513     * steps 13 and 15.
   2514     *
   2515     * [1]: https://tc39.es/ecma262/#sec-ecmascript-function-objects-construct-argumentslist-newtarget
   2516     *
   2517     *   Category: Control flow
   2518     *   Type: Return
   2519     *   Operands:
   2520     *   Stack: thisval => rval
   2521     */ \
   2522    MACRO(CheckReturn, check_return, NULL, 1, 1, 1, JOF_BYTE) \
   2523    /*
   2524     * Throw `exc`. (ノಠ益ಠ)ノ彡┴──┴
   2525     *
   2526     * This sets the pending exception to `exc` and jumps to error-handling
   2527     * code. If we're in a `try` block, error handling adjusts the stack and
   2528     * environment chain and resumes execution at the top of the `catch` or
   2529     * `finally` block. Otherwise it starts unwinding the stack.
   2530     *
   2531     * Implements: [*ThrowStatement* Evaluation][1], step 3.
   2532     *
   2533     * [1]: https://tc39.es/ecma262/#sec-throw-statement-runtime-semantics-evaluation
   2534     *
   2535     *   Category: Control flow
   2536     *   Type: Exceptions
   2537     *   Operands:
   2538     *   Stack: exc =>
   2539     */ \
   2540    MACRO(Throw, throw_, NULL, 1, 1, 0, JOF_BYTE) \
   2541    /*
   2542     * Throw `exc`. (ノಠ益ಠ)ノ彡┴──┴
   2543     *
   2544     * This sets the pending exception to `exc`, the pending exception stack
   2545     * to `stack`, and then jumps to error-handling code. If we're in a `try`
   2546     * block, error handling adjusts the stack and environment chain and resumes
   2547     * execution at the top of the `catch` or `finally` block. Otherwise it
   2548     * starts unwinding the stack.
   2549     *
   2550     * This is used in for-of loops. If the body of the loop throws an
   2551     * exception, we catch it, close the iterator, then use
   2552     * `JSOp::ThrowWithStack` to rethrow.
   2553     *
   2554     *   Category: Control flow
   2555     *   Type: Exceptions
   2556     *   Operands:
   2557     *   Stack: exc, stack =>
   2558     */ \
   2559    MACRO(ThrowWithStack, throw_with_stack, NULL, 1, 2, 0, JOF_BYTE) \
   2560    /*
   2561     * Create a suppressed error object and push it on the stack.
   2562     *
   2563     * Implements: [DisposeResources ( disposeCapability, completion )][1], step 3.e.iii.1.a-f.
   2564     *
   2565     * [1] https://arai-a.github.io/ecma262-compare/?pr=3000&id=sec-disposeresources
   2566     *
   2567     *   Category: Control flow
   2568     *   Type: Exceptions
   2569     *   Operands:
   2570     *   Stack: error, suppressed => suppressedError
   2571     */ \
   2572    IF_EXPLICIT_RESOURCE_MANAGEMENT(MACRO(CreateSuppressedError, create_suppressed_error, NULL, 1, 2, 1, JOF_BYTE)) \
   2573    /*
   2574     * Create and throw an Error object.
   2575     *
   2576     * Sometimes we know at emit time that an operation always throws. For
   2577     * example, `delete super.prop;` is allowed in methods, but always throws a
   2578     * ReferenceError.
   2579     *
   2580     * `msgNumber` determines the `.message` and [[Prototype]] of the new Error
   2581     * object.  It must be an error number in js/public/friend/ErrorNumbers.msg.
   2582     * The number of arguments in the error message must be 0.
   2583     *
   2584     *   Category: Control flow
   2585     *   Type: Exceptions
   2586     *   Operands: ThrowMsgKind msgNumber
   2587     *   Stack: =>
   2588     */ \
   2589    MACRO(ThrowMsg, throw_msg, NULL, 2, 0, 0, JOF_UINT8) \
   2590    /*
   2591     * Throws a runtime TypeError for invalid assignment to a `const` binding.
   2592     *
   2593     *   Category: Control flow
   2594     *   Type: Exceptions
   2595     *   Operands: uint32_t nameIndex
   2596     *   Stack:
   2597     */ \
   2598    MACRO(ThrowSetConst, throw_set_const, NULL, 5, 0, 0, JOF_ATOM) \
   2599    /*
   2600     * No-op instruction that marks the top of the bytecode for a
   2601     * *TryStatement*.
   2602     *
   2603     * Location information for catch/finally blocks is stored in a side table,
   2604     * `script->trynotes()`.
   2605     *
   2606     *   Category: Control flow
   2607     *   Type: Exceptions
   2608     *   Operands:
   2609     *   Stack: =>
   2610     */ \
   2611    MACRO(Try, try_, NULL, 1, 0, 0, JOF_BYTE) \
   2612    /*
   2613     * No-op instruction used by the exception unwinder to determine the
   2614     * correct environment to unwind to when performing IteratorClose due to
   2615     * destructuring.
   2616     *
   2617     * This instruction must appear immediately before each
   2618     * `JSTRY_DESTRUCTURING` span in a script's try notes.
   2619     *
   2620     *   Category: Control flow
   2621     *   Type: Exceptions
   2622     *   Operands:
   2623     *   Stack: =>
   2624     */ \
   2625    MACRO(TryDestructuring, try_destructuring, NULL, 1, 0, 0, JOF_BYTE) \
   2626    /*
   2627     * Push and clear the pending exception. ┬──┬◡ノ(° -°ノ)
   2628     *
   2629     * This must be used only in the fixed sequence of instructions following a
   2630     * `JSTRY_CATCH` span (see "Bytecode Invariants" above), as that's the only
   2631     * way instructions would run with an exception pending.
   2632     *
   2633     * Used to implement catch-blocks.
   2634     *
   2635     *   Category: Control flow
   2636     *   Type: Exceptions
   2637     *   Operands:
   2638     *   Stack: => exception
   2639     */ \
   2640    MACRO(Exception, exception, NULL, 1, 0, 1, JOF_BYTE) \
   2641    /*
   2642     * Push and clear the pending exception. ┬──┬◡ノ(° -°ノ)
   2643     *
   2644     * This must be used only in the fixed sequence of instructions following a
   2645     * `JSTRY_CATCH` span (see "Bytecode Invariants" above), as that's the only
   2646     * way instructions would run with an exception pending.
   2647     *
   2648     * Used to implement implicit catch-blocks generated as part of for-of
   2649     * iteration.
   2650     *
   2651     *   Category: Control flow
   2652     *   Type: Exceptions
   2653     *   Operands:
   2654     *   Stack: => exception, stack
   2655     */ \
   2656    MACRO(ExceptionAndStack, exception_and_stack, NULL, 1, 0, 2, JOF_BYTE) \
   2657    /*
   2658     * No-op instruction that marks the start of a `finally` block.
   2659     *
   2660     *   Category: Control flow
   2661     *   Type: Exceptions
   2662     *   Operands:
   2663     *   Stack: =>
   2664     */ \
   2665    MACRO(Finally, finally, NULL, 1, 0, 0, JOF_BYTE) \
   2666    /*
   2667     * Push `MagicValue(JS_UNINITIALIZED_LEXICAL)`, a magic value used to mark
   2668     * a binding as uninitialized.
   2669     *
   2670     * This magic value must be used only by `JSOp::InitLexical`.
   2671     *
   2672     *   Category: Variables and scopes
   2673     *   Type: Initialization
   2674     *   Operands:
   2675     *   Stack: => uninitialized
   2676     */ \
   2677    MACRO(Uninitialized, uninitialized, NULL, 1, 0, 1, JOF_BYTE) \
   2678    /*
   2679     * Initialize an optimized local lexical binding; or mark it as
   2680     * uninitialized.
   2681     *
   2682     * This stores the value `v` in the fixed slot `localno` in the current
   2683     * stack frame. If `v` is the magic value produced by `JSOp::Uninitialized`,
   2684     * this marks the binding as uninitialized. Otherwise this initializes the
   2685     * binding with value `v`.
   2686     *
   2687     * Implements: [CreateMutableBinding][1] step 3, substep "record that it is
   2688     * uninitialized", and [InitializeBinding][2], for optimized locals. (Note:
   2689     * this is how `const` bindings are initialized.)
   2690     *
   2691     * [1]: https://tc39.es/ecma262/#sec-declarative-environment-records-createmutablebinding-n-d
   2692     * [2]: https://tc39.es/ecma262/#sec-declarative-environment-records-initializebinding-n-v
   2693     *
   2694     *   Category: Variables and scopes
   2695     *   Type: Initialization
   2696     *   Operands: uint24_t localno
   2697     *   Stack: v => v
   2698     */ \
   2699    MACRO(InitLexical, init_lexical, NULL, 4, 1, 1, JOF_LOCAL) \
   2700    /*
   2701     * Initialize a global lexical binding.
   2702     *
   2703     * The binding must already have been created by
   2704     * `GlobalOrEvalDeclInstantiation` and must be uninitialized.
   2705     *
   2706     * Like `JSOp::InitLexical` but for global lexicals. Unlike `InitLexical`
   2707     * this can't be used to mark a binding as uninitialized.
   2708     *
   2709     *   Category: Variables and scopes
   2710     *   Type: Initialization
   2711     *   Operands: uint32_t nameIndex
   2712     *   Stack: val => val
   2713     */ \
   2714    MACRO(InitGLexical, init_g_lexical, NULL, 5, 1, 1, JOF_ATOM|JOF_PROPINIT|JOF_GNAME|JOF_IC) \
   2715    /*
   2716     * Initialize an aliased lexical binding; or mark it as uninitialized.
   2717     *
   2718     * Like `JSOp::InitLexical` but for aliased bindings.
   2719     *
   2720     * Note: There is no even-less-optimized `InitName` instruction because JS
   2721     * doesn't need it. We always know statically which binding we're
   2722     * initializing.
   2723     *
   2724     * `hops` is usually 0, but in `function f(a=eval("var b;")) { }`, the
   2725     * argument `a` is initialized from inside a nested scope, so `hops == 1`.
   2726     *
   2727     *   Category: Variables and scopes
   2728     *   Type: Initialization
   2729     *   Operands: uint16_t hops, uint24_t slot
   2730     *   Stack: v => v
   2731     */ \
   2732    MACRO(InitAliasedLexical, init_aliased_lexical, NULL, 6, 1, 1, JOF_ENVCOORD|JOF_PROPINIT) \
   2733    /*
   2734     * Throw a ReferenceError if the value on top of the stack is uninitialized.
   2735     *
   2736     * Typically used after `JSOp::GetLocal` with the same `localno`.
   2737     *
   2738     * Implements: [GetBindingValue][1] step 3 and [SetMutableBinding][2] step
   2739     * 4 for declarative Environment Records.
   2740     *
   2741     * [1]: https://tc39.es/ecma262/#sec-declarative-environment-records-getbindingvalue-n-s
   2742     * [2]: https://tc39.es/ecma262/#sec-declarative-environment-records-setmutablebinding-n-v-s
   2743     *
   2744     *   Category: Variables and scopes
   2745     *   Type: Initialization
   2746     *   Operands: uint24_t localno
   2747     *   Stack: v => v
   2748     */ \
   2749    MACRO(CheckLexical, check_lexical, NULL, 4, 1, 1, JOF_LOCAL) \
   2750    /*
   2751     * Like `JSOp::CheckLexical` but for aliased bindings.
   2752     *
   2753     * Typically used after `JSOp::GetAliasedVar` with the same hops/slot.
   2754     *
   2755     * Note: There are no `CheckName` or `CheckGName` instructions because
   2756     * they're unnecessary. `JSOp::{Get,Set}{Name,GName}` all check for
   2757     * uninitialized lexicals and throw if needed.
   2758     *
   2759     *   Category: Variables and scopes
   2760     *   Type: Initialization
   2761     *   Operands: uint16_t hops, uint24_t slot
   2762     *   Stack: v => v
   2763     */ \
   2764    MACRO(CheckAliasedLexical, check_aliased_lexical, NULL, 6, 1, 1, JOF_ENVCOORD) \
   2765    /*
   2766     * Throw a ReferenceError if the value on top of the stack is
   2767     * `MagicValue(JS_UNINITIALIZED_LEXICAL)`. Used in derived class
   2768     * constructors to check `this` (which needs to be initialized before use,
   2769     * by calling `super()`).
   2770     *
   2771     * Implements: [GetThisBinding][1] step 3.
   2772     *
   2773     * [1]: https://tc39.es/ecma262/#sec-function-environment-records-getthisbinding
   2774     *
   2775     *   Category: Variables and scopes
   2776     *   Type: Initialization
   2777     *   Operands:
   2778     *   Stack: this => this
   2779     */ \
   2780    MACRO(CheckThis, check_this, NULL, 1, 1, 1, JOF_BYTE) \
   2781    /*
   2782     * Look up a name on the global lexical environment's chain and push the
   2783     * environment which contains a binding for that name. If no such binding
   2784     * exists, push the top-most variables object, which is the global object.
   2785     *
   2786     *   Category: Variables and scopes
   2787     *   Type: Looking up bindings
   2788     *   Operands: uint32_t nameIndex
   2789     *   Stack: => global
   2790     */ \
   2791    MACRO(BindUnqualifiedGName, bind_unqualified_g_name, NULL, 5, 0, 1, JOF_ATOM|JOF_GNAME|JOF_IC) \
   2792    /*
   2793     * Look up an unqualified name on the environment chain and push the
   2794     * environment which contains a binding for that name. If no such binding
   2795     * exists, push the first variables object along the environment chain.
   2796     *
   2797     *   Category: Variables and scopes
   2798     *   Type: Looking up bindings
   2799     *   Operands: uint32_t nameIndex
   2800     *   Stack: => env
   2801     */ \
   2802    MACRO(BindUnqualifiedName, bind_unqualified_name, NULL, 5, 0, 1, JOF_ATOM|JOF_IC|JOF_USES_ENV) \
   2803    /*
   2804     * Look up a name on the environment chain and push the environment which
   2805     * contains a binding for that name. If no such binding exists, push the
   2806     * global object.
   2807     *
   2808     *   Category: Variables and scopes
   2809     *   Type: Looking up bindings
   2810     *   Operands: uint32_t nameIndex
   2811     *   Stack: => env
   2812     */ \
   2813    MACRO(BindName, bind_name, NULL, 5, 0, 1, JOF_ATOM|JOF_IC|JOF_USES_ENV) \
   2814    /*
   2815     * Find a binding on the environment chain and push its value.
   2816     *
   2817     * If the binding is an uninitialized lexical, throw a ReferenceError. If
   2818     * no such binding exists, throw a ReferenceError unless the next
   2819     * instruction is `JSOp::Typeof` or `JSOp::TypeofEq` (see IsTypeOfNameOp),
   2820     * in which case push `undefined`.
   2821     *
   2822     * Implements: [ResolveBinding][1] followed by [GetValue][2]
   2823     * (adjusted hackily for `typeof`).
   2824     *
   2825     * This is the fallback `Get` instruction that handles all unoptimized
   2826     * cases. Optimized instructions follow.
   2827     *
   2828     * [1]: https://tc39.es/ecma262/#sec-resolvebinding
   2829     * [2]: https://tc39.es/ecma262/#sec-getvalue
   2830     *
   2831     *   Category: Variables and scopes
   2832     *   Type: Getting binding values
   2833     *   Operands: uint32_t nameIndex
   2834     *   Stack: => val
   2835     */ \
   2836    MACRO(GetName, get_name, NULL, 5, 0, 1, JOF_ATOM|JOF_IC|JOF_USES_ENV) \
   2837    /*
   2838     * Find a global binding and push its value.
   2839     *
   2840     * This searches the global lexical environment and, failing that, the
   2841     * global object. (Unlike most declarative environments, the global lexical
   2842     * environment can gain more bindings after compilation, possibly shadowing
   2843     * global object properties.)
   2844     *
   2845     * This is an optimized version of `JSOp::GetName` that skips all local
   2846     * scopes, for use when the name doesn't refer to any local binding.
   2847     * `NonSyntacticVariablesObject`s break this optimization, so if the
   2848     * current script has a non-syntactic global scope, use `JSOp::GetName`
   2849     * instead.
   2850     *
   2851     * Like `JSOp::GetName`, this throws a ReferenceError if no such binding is
   2852     * found (unless the next instruction is `JSOp::Typeof`) or if the binding
   2853     * is an uninitialized lexical.
   2854     *
   2855     *   Category: Variables and scopes
   2856     *   Type: Getting binding values
   2857     *   Operands: uint32_t nameIndex
   2858     *   Stack: => val
   2859     */ \
   2860    MACRO(GetGName, get_g_name, NULL, 5, 0, 1, JOF_ATOM|JOF_GNAME|JOF_IC) \
   2861    /*
   2862     * Push the value of an argument that is stored in the stack frame
   2863     * or in an `ArgumentsObject`.
   2864     *
   2865     *   Category: Variables and scopes
   2866     *   Type: Getting binding values
   2867     *   Operands: uint16_t argno
   2868     *   Stack: => arguments[argno]
   2869     */ \
   2870    MACRO(GetArg, get_arg, NULL, 3, 0, 1, JOF_QARG) \
   2871    /*
   2872     * Push the value of an argument that is stored in the stack frame. Like
   2873     * `JSOp::GetArg`, but ignores the frame's `ArgumentsObject` and doesn't
   2874     * assert the argument is unaliased.
   2875     *
   2876     *   Category: Variables and scopes
   2877     *   Type: Getting binding values
   2878     *   Operands: uint16_t argno
   2879     *   Stack: => arguments[argno]
   2880     */ \
   2881    MACRO(GetFrameArg, get_frame_arg, NULL, 3, 0, 1, JOF_QARG) \
   2882    /*
   2883     * Push the value of an optimized local variable.
   2884     *
   2885     * If the variable is an uninitialized lexical, push
   2886     * `MagicValue(JS_UNINIITALIZED_LEXICAL)`.
   2887     *
   2888     *   Category: Variables and scopes
   2889     *   Type: Getting binding values
   2890     *   Operands: uint24_t localno
   2891     *   Stack: => val
   2892     */ \
   2893    MACRO(GetLocal, get_local, NULL, 4, 0, 1, JOF_LOCAL) \
   2894    /*
   2895     * Push the number of actual arguments as Int32Value.
   2896     *
   2897     * This is emitted for the ArgumentsLength() intrinsic in self-hosted code,
   2898     * and if the script uses only arguments.length.
   2899     *
   2900     *   Category: Variables and scopes
   2901     *   Type: Getting binding values
   2902     *   Operands:
   2903     *   Stack: => arguments.length
   2904     */ \
   2905    MACRO(ArgumentsLength, arguments_length, NULL, 1, 0, 1, JOF_BYTE) \
   2906    /*
   2907     * Push the value of an argument that is stored in the stack frame. The
   2908     * value on top of the stack must be an Int32Value storing the index. The
   2909     * index must be less than the number of actual arguments.
   2910     *
   2911     * This is emitted for the GetArgument(i) intrinsic in self-hosted code.
   2912     *
   2913     *   Category: Variables and scopes
   2914     *   Type: Getting binding values
   2915     *   Operands:
   2916     *   Stack: index => arguments[index]
   2917     */ \
   2918    MACRO(GetActualArg, get_actual_arg, NULL, 1, 1, 1, JOF_BYTE) \
   2919    /*
   2920     * Push the value of an aliased binding.
   2921     *
   2922     * Local bindings that aren't closed over or dynamically accessed are
   2923     * stored in stack slots. Global and `with` bindings are object properties.
   2924     * All other bindings are called "aliased" and stored in
   2925     * `EnvironmentObject`s.
   2926     *
   2927     * Where possible, `Aliased` instructions are used to access aliased
   2928     * bindings.  (There's no difference in meaning between `AliasedVar` and
   2929     * `AliasedLexical`.) Each of these instructions has operands `hops` and
   2930     * `slot` that encode an [`EnvironmentCoordinate`][1], directions to the
   2931     * binding from the current environment object.
   2932     *
   2933     * `Aliased` instructions can't be used when there's a dynamic scope (due
   2934     * to non-strict `eval` or `with`) that might shadow the aliased binding.
   2935     *
   2936     * [1]: https://searchfox.org/mozilla-central/search?q=symbol:T_js%3A%3AEnvironmentCoordinate
   2937     *
   2938     *   Category: Variables and scopes
   2939     *   Type: Getting binding values
   2940     *   Operands: uint16_t hops, uint24_t slot
   2941     *   Stack: => aliasedVar
   2942     */ \
   2943    MACRO(GetAliasedVar, get_aliased_var, NULL, 6, 0, 1, JOF_ENVCOORD|JOF_USES_ENV) \
   2944    /*
   2945     * Push the value of an aliased binding, which may have to bypass a DebugEnvironmentProxy
   2946     * on the environment chain.
   2947     *
   2948     *   Category: Variables and scopes
   2949     *   Type: Getting binding values
   2950     *   Operands: uint16_t hops, uint24_t slot
   2951     *   Stack: => aliasedVar
   2952     */ \
   2953    MACRO(GetAliasedDebugVar, get_aliased_debug_var, NULL, 6, 0, 1, JOF_DEBUGCOORD) \
   2954    /*
   2955     * Get the value of a module import by name and pushes it onto the stack.
   2956     *
   2957     *   Category: Variables and scopes
   2958     *   Type: Getting binding values
   2959     *   Operands: uint32_t nameIndex
   2960     *   Stack: => val
   2961     */ \
   2962    MACRO(GetImport, get_import, NULL, 5, 0, 1, JOF_ATOM|JOF_IC) \
   2963    /*
   2964     * Get the value of a binding from the environment `env`. If the name is
   2965     * not bound in `env`, throw a ReferenceError.
   2966     *
   2967     * `env` must be an environment currently on the environment chain, pushed
   2968     * by `JSOp::BindName`, `JSOp::BindUnqualifiedName`, or `JSOp::BindVar`.
   2969     *
   2970     * Note: `JSOp::Bind(Unqualified)Name` and `JSOp::GetBoundName` are the two
   2971     * halves of the `JSOp::GetName` operation: finding and reading a variable.
   2972     * This decomposed version is needed to implement:
   2973     * 1. The call operator, which gets a variable and its this-environment.
   2974     * 2. The compound assignment and increment/decrement operators, which get
   2975     *    and then set a variable.
   2976     * The spec says the variable lookup is done only once. If we did the lookup
   2977     * twice, there would be observable bugs, thanks to dynamic scoping. We
   2978     * could get the wrong this-environment resp. variable or call proxy traps
   2979     * incorrectly.
   2980     *
   2981     * Implements: [GetValue][1] steps 4 and 6.
   2982     *
   2983     * [1]: https://tc39.es/ecma262/#sec-getvalue
   2984     *
   2985     *   Category: Variables and scopes
   2986     *   Type: Getting binding values
   2987     *   Operands: uint32_t nameIndex
   2988     *   Stack: env => v
   2989     */ \
   2990    MACRO(GetBoundName, get_bound_name, NULL, 5, 1, 1, JOF_ATOM|JOF_IC) \
   2991    /*
   2992     * Push the value of an intrinsic onto the stack.
   2993     *
   2994     * Non-standard. Intrinsics are slots in the intrinsics holder object (see
   2995     * `GlobalObject::getIntrinsicsHolder`), which is used in lieu of global
   2996     * bindings in self-hosting code.
   2997     *
   2998     *   Category: Variables and scopes
   2999     *   Type: Getting binding values
   3000     *   Operands: uint32_t nameIndex
   3001     *   Stack: => intrinsic[name]
   3002     */ \
   3003    MACRO(GetIntrinsic, get_intrinsic, NULL, 5, 0, 1, JOF_ATOM|JOF_IC) \
   3004    /*
   3005     * Pushes the currently executing function onto the stack.
   3006     *
   3007     * The current script must be a function script.
   3008     *
   3009     * Used to implement `super`. This is also used sometimes as a minor
   3010     * optimization when a named function expression refers to itself by name:
   3011     *
   3012     *     f = function fac(n) {  ... fac(n - 1) ... };
   3013     *
   3014     * This lets us optimize away a lexical environment that contains only the
   3015     * binding for `fac`, unless it's otherwise observable (via `with`, `eval`,
   3016     * or a nested closure).
   3017     *
   3018     *   Category: Variables and scopes
   3019     *   Type: Getting binding values
   3020     *   Operands:
   3021     *   Stack: => callee
   3022     */ \
   3023    MACRO(Callee, callee, NULL, 1, 0, 1, JOF_BYTE) \
   3024    /*
   3025     * Load the callee stored in a CallObject on the environment chain. The
   3026     * `numHops` operand is the number of environment objects to skip on the
   3027     * environment chain. The environment chain element indicated by `numHops`
   3028     * must be a CallObject.
   3029     *
   3030     *   Category: Variables and scopes
   3031     *   Type: Getting binding values
   3032     *   Operands: uint16_t numHops
   3033     *   Stack: => callee
   3034     */ \
   3035    MACRO(EnvCallee, env_callee, NULL, 3, 0, 1, JOF_UINT16) \
   3036    /*
   3037     * Assign `val` to the binding in `env` with the name given by `nameIndex`.
   3038     * Throw a ReferenceError if the binding is an uninitialized lexical.
   3039     * This can call setters and/or proxy traps.
   3040     *
   3041     * `env` must be an environment currently on the environment chain,
   3042     * pushed by `JSOp::BindUnqualifiedName` or `JSOp::BindVar`.
   3043     *
   3044     * This is the fallback `Set` instruction that handles all unoptimized
   3045     * cases. Optimized instructions follow.
   3046     *
   3047     * Implements: [PutValue][1] steps 5 and 7 for unoptimized bindings.
   3048     *
   3049     * Note: `JSOp::BindUnqualifiedName` and `JSOp::SetName` are the two halves
   3050     * of simple assignment: finding and setting a variable. They are two
   3051     * separate instructions because, per spec, the "finding" part happens
   3052     * before evaluating the right-hand side of the assignment, and the
   3053     * "setting" part after. Optimized cases don't need a `Bind` instruction
   3054     * because the "finding" is done statically.
   3055     *
   3056     * [1]: https://tc39.es/ecma262/#sec-putvalue
   3057     *
   3058     *   Category: Variables and scopes
   3059     *   Type: Setting binding values
   3060     *   Operands: uint32_t nameIndex
   3061     *   Stack: env, val => val
   3062     */ \
   3063    MACRO(SetName, set_name, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPSET|JOF_CHECKSLOPPY|JOF_IC|JOF_USES_ENV) \
   3064    /*
   3065     * Like `JSOp::SetName`, but throw a TypeError if there is no binding for
   3066     * the specified name in `env`, or if the binding is immutable (a `const`
   3067     * or read-only property).
   3068     *
   3069     * Implements: [PutValue][1] steps 5 and 7 for strict mode code.
   3070     *
   3071     * [1]: https://tc39.es/ecma262/#sec-putvalue
   3072     *
   3073     *   Category: Variables and scopes
   3074     *   Type: Setting binding values
   3075     *   Operands: uint32_t nameIndex
   3076     *   Stack: env, val => val
   3077     */ \
   3078    MACRO(StrictSetName, strict_set_name, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPSET|JOF_CHECKSTRICT|JOF_IC|JOF_USES_ENV) \
   3079    /*
   3080     * Like `JSOp::SetName`, but for assigning to globals. `env` must be an
   3081     * environment pushed by `JSOp::BindUnqualifiedGName`.
   3082     *
   3083     *   Category: Variables and scopes
   3084     *   Type: Setting binding values
   3085     *   Operands: uint32_t nameIndex
   3086     *   Stack: env, val => val
   3087     */ \
   3088    MACRO(SetGName, set_g_name, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPSET|JOF_GNAME|JOF_CHECKSLOPPY|JOF_IC) \
   3089    /*
   3090     * Like `JSOp::StrictSetGName`, but for assigning to globals. `env` must be
   3091     * an environment pushed by `JSOp::BindUnqualifiedGName`.
   3092     *
   3093     *   Category: Variables and scopes
   3094     *   Type: Setting binding values
   3095     *   Operands: uint32_t nameIndex
   3096     *   Stack: env, val => val
   3097     */ \
   3098    MACRO(StrictSetGName, strict_set_g_name, NULL, 5, 2, 1, JOF_ATOM|JOF_PROPSET|JOF_GNAME|JOF_CHECKSTRICT|JOF_IC) \
   3099    /*
   3100     * Assign `val` to an argument binding that's stored in the stack frame or
   3101     * in an `ArgumentsObject`.
   3102     *
   3103     *   Category: Variables and scopes
   3104     *   Type: Setting binding values
   3105     *   Operands: uint16_t argno
   3106     *   Stack: val => val
   3107     */ \
   3108    MACRO(SetArg, set_arg, NULL, 3, 1, 1, JOF_QARG) \
   3109    /*
   3110     * Assign to an optimized local binding.
   3111     *
   3112     *   Category: Variables and scopes
   3113     *   Type: Setting binding values
   3114     *   Operands: uint24_t localno
   3115     *   Stack: v => v
   3116     */ \
   3117    MACRO(SetLocal, set_local, NULL, 4, 1, 1, JOF_LOCAL) \
   3118    /*
   3119     * Assign to an aliased binding.
   3120     *
   3121     * Implements: [SetMutableBinding for declarative Environment Records][1],
   3122     * in certain cases where it's known that the binding exists, is mutable,
   3123     * and has been initialized.
   3124     *
   3125     * [1]: https://tc39.es/ecma262/#sec-declarative-environment-records-setmutablebinding-n-v-s
   3126     *
   3127     *   Category: Variables and scopes
   3128     *   Type: Setting binding values
   3129     *   Operands: uint16_t hops, uint24_t slot
   3130     *   Stack: val => val
   3131     */ \
   3132    MACRO(SetAliasedVar, set_aliased_var, NULL, 6, 1, 1, JOF_ENVCOORD|JOF_PROPSET|JOF_USES_ENV) \
   3133    /*
   3134     * Assign to an intrinsic.
   3135     *
   3136     * Nonstandard. Intrinsics are used in lieu of global bindings in self-
   3137     * hosted code. The value is actually stored in the intrinsics holder
   3138     * object, `GlobalObject::getIntrinsicsHolder`. (Self-hosted code doesn't
   3139     * have many global `var`s, but it has many `function`s.)
   3140     *
   3141     *   Category: Variables and scopes
   3142     *   Type: Setting binding values
   3143     *   Operands: uint32_t nameIndex
   3144     *   Stack: val => val
   3145     */ \
   3146    MACRO(SetIntrinsic, set_intrinsic, NULL, 5, 1, 1, JOF_ATOM) \
   3147    /*
   3148     * Push a lexical environment onto the environment chain.
   3149     *
   3150     * The `LexicalScope` indicated by `lexicalScopeIndex` determines the shape
   3151     * of the new `BlockLexicalEnvironmentObject`. All bindings in the new
   3152     * environment are marked as uninitialized.
   3153     *
   3154     * Implements: [Evaluation of *Block*][1], steps 1-4.
   3155     *
   3156     * #### Fine print for environment chain instructions
   3157     *
   3158     * The following rules for `JSOp::{Push,Pop}LexicalEnv` also apply to
   3159     * `JSOp::PushClassBodyEnv`, `JSOp::PushVarEnv`, and
   3160     * `JSOp::{Enter,Leave}With`.
   3161     *
   3162     * Each `JSOp::PopLexicalEnv` instruction matches a particular
   3163     * `JSOp::PushLexicalEnv` instruction in the same script and must have the
   3164     * same scope and stack depth as the instruction immediately after that
   3165     * `PushLexicalEnv`.
   3166     *
   3167     * `JSOp::PushLexicalEnv` enters a scope that extends to some set of
   3168     * instructions in the script. Code must not jump into or out of this
   3169     * region: control can enter only by executing `PushLexicalEnv` and can
   3170     * exit only by executing a `PopLexicalEnv` or by exception unwinding. (A
   3171     * `JSOp::PopLexicalEnv` is always emitted at the end of the block, and
   3172     * extra copies are emitted on "exit slides", where a `break`, `continue`,
   3173     * or `return` statement exits the scope.)
   3174     *
   3175     * The script's `JSScript::scopeNotes()` must identify exactly which
   3176     * instructions begin executing in this scope. Typically this means a
   3177     * single entry marking the contiguous chunk of bytecode from the
   3178     * instruction after `JSOp::PushLexicalEnv` to `JSOp::PopLexicalEnv`
   3179     * (inclusive); but if that range contains any instructions on exit slides,
   3180     * after a `JSOp::PopLexicalEnv`, then those must be correctly noted as
   3181     * *outside* the scope.
   3182     *
   3183     * [1]: https://tc39.es/ecma262/#sec-block-runtime-semantics-evaluation
   3184     *
   3185     *   Category: Variables and scopes
   3186     *   Type: Entering and leaving environments
   3187     *   Operands: uint32_t lexicalScopeIndex
   3188     *   Stack: =>
   3189     */ \
   3190    MACRO(PushLexicalEnv, push_lexical_env, NULL, 5, 0, 0, JOF_SCOPE|JOF_USES_ENV) \
   3191    /*
   3192     * Pop a lexical or class-body environment from the environment chain.
   3193     *
   3194     * See `JSOp::PushLexicalEnv` for the fine print.
   3195     *
   3196     *   Category: Variables and scopes
   3197     *   Type: Entering and leaving environments
   3198     *   Operands:
   3199     *   Stack: =>
   3200     */ \
   3201    MACRO(PopLexicalEnv, pop_lexical_env, NULL, 1, 0, 0, JOF_BYTE|JOF_USES_ENV) \
   3202    /*
   3203     * No-op instruction that indicates leaving an optimized lexical scope.
   3204     *
   3205     * If all bindings in a lexical scope are optimized into stack slots, then
   3206     * the runtime environment objects for that scope are optimized away. No
   3207     * `JSOp::{Push,Pop}LexicalEnv` instructions are emitted. However, the
   3208     * debugger still needs to be notified when control exits a scope; that's
   3209     * what this instruction does.
   3210     *
   3211     * The last instruction in a lexical or class-body scope, as indicated by
   3212     * scope notes, must be either this instruction (if the scope is optimized)
   3213     * or `JSOp::PopLexicalEnv` (if not).
   3214     *
   3215     *   Category: Variables and scopes
   3216     *   Type: Entering and leaving environments
   3217     *   Operands:
   3218     *   Stack: =>
   3219     */ \
   3220    MACRO(DebugLeaveLexicalEnv, debug_leave_lexical_env, NULL, 1, 0, 0, JOF_BYTE) \
   3221    /*
   3222     * Replace the current block on the environment chain with a fresh block
   3223     * with uninitialized bindings. This implements the behavior of inducing a
   3224     * fresh lexical environment for every iteration of a for-in/of loop whose
   3225     * loop-head declares lexical variables that may be captured.
   3226     *
   3227     * The current environment must be a BlockLexicalEnvironmentObject.
   3228     *
   3229     *   Category: Variables and scopes
   3230     *   Type: Entering and leaving environments
   3231     *   Operands: uint32_t lexicalScopeIndex
   3232     *   Stack: =>
   3233     */ \
   3234    MACRO(RecreateLexicalEnv, recreate_lexical_env, NULL, 5, 0, 0, JOF_SCOPE) \
   3235    /*
   3236     * Like `JSOp::RecreateLexicalEnv`, but the values of all the bindings are
   3237     * copied from the old block to the new one. This is used for C-style
   3238     * `for(let ...; ...; ...)` loops.
   3239     *
   3240     *   Category: Variables and scopes
   3241     *   Type: Entering and leaving environments
   3242     *   Operands: uint32_t lexicalScopeIndex
   3243     *   Stack: =>
   3244     */ \
   3245    MACRO(FreshenLexicalEnv, freshen_lexical_env, NULL, 5, 0, 0, JOF_SCOPE) \
   3246    /*
   3247     * Push a ClassBody environment onto the environment chain.
   3248     *
   3249     * Like `JSOp::PushLexicalEnv`, but pushes a `ClassBodyEnvironmentObject`
   3250     * rather than a `BlockLexicalEnvironmentObject`.  `JSOp::PopLexicalEnv` is
   3251     * used to pop class-body environments as well as lexical environments.
   3252     *
   3253     * See `JSOp::PushLexicalEnv` for the fine print.
   3254     *
   3255     *   Category: Variables and scopes
   3256     *   Type: Entering and leaving environments
   3257     *   Operands: uint32_t lexicalScopeIndex
   3258     *   Stack: =>
   3259     */ \
   3260    MACRO(PushClassBodyEnv, push_class_body_env, NULL, 5, 0, 0, JOF_SCOPE) \
   3261    /*
   3262     * Push a var environment onto the environment chain.
   3263     *
   3264     * Like `JSOp::PushLexicalEnv`, but pushes a `VarEnvironmentObject` rather
   3265     * than a `BlockLexicalEnvironmentObject`. The difference is that
   3266     * non-strict direct `eval` can add bindings to a var environment; see
   3267     * `VarScope` in Scope.h.
   3268     *
   3269     * See `JSOp::PushLexicalEnv` for the fine print.
   3270     *
   3271     * There is no corresponding `JSOp::PopVarEnv` operation, because a
   3272     * `VarEnvironmentObject` is never popped from the environment chain.
   3273     *
   3274     * Implements: Places in the spec where the VariableEnvironment is set:
   3275     *
   3276     * -   The bit in [PerformEval][1] where, in strict direct eval, the new
   3277     *     eval scope is taken as *varEnv* and becomes "*runningContext*'s
   3278     *     VariableEnvironment".
   3279     *
   3280     * -   The weird scoping rules for functions with default parameter
   3281     *     expressions, as specified in [FunctionDeclarationInstantiation][2]
   3282     *     step 28 ("NOTE: A separate Environment Record is needed...").
   3283     *
   3284     * Note: The spec also pushes a new VariableEnvironment on entry to every
   3285     * function, but the VM takes care of that as part of pushing the stack
   3286     * frame, before the function script starts to run, so `JSOp::PushVarEnv` is
   3287     * not needed.
   3288     *
   3289     * [1]: https://tc39.es/ecma262/#sec-performeval
   3290     * [2]: https://tc39.es/ecma262/#sec-functiondeclarationinstantiation
   3291     *
   3292     *   Category: Variables and scopes
   3293     *   Type: Entering and leaving environments
   3294     *   Operands: uint32_t scopeIndex
   3295     *   Stack: =>
   3296     */ \
   3297    MACRO(PushVarEnv, push_var_env, NULL, 5, 0, 0, JOF_SCOPE|JOF_USES_ENV) \
   3298    /*
   3299     * Push a `WithEnvironmentObject` wrapping ToObject(`val`) to the
   3300     * environment chain.
   3301     *
   3302     * Implements: [Evaluation of `with` statements][1], steps 2-6.
   3303     *
   3304     * Operations that may need to consult a WithEnvironment can't be correctly
   3305     * implemented using optimized instructions like `JSOp::GetLocal`. A script
   3306     * must use the deoptimized `JSOp::GetName`, `BindUnqualifiedName`,
   3307     * `BindName`,`SetName`, and `DelName` instead. Since those instructions
   3308     * don't work correctly with optimized locals and arguments, all bindings in
   3309     * scopes enclosing a `with` statement are marked as "aliased" and
   3310     * deoptimized too.
   3311     *
   3312     * See `JSOp::PushLexicalEnv` for the fine print.
   3313     *
   3314     * [1]: https://tc39.es/ecma262/#sec-with-statement-runtime-semantics-evaluation
   3315     *
   3316     *   Category: Variables and scopes
   3317     *   Type: Entering and leaving environments
   3318     *   Operands: uint32_t staticWithIndex
   3319     *   Stack: val =>
   3320     */ \
   3321    MACRO(EnterWith, enter_with, NULL, 5, 1, 0, JOF_SCOPE) \
   3322    /*
   3323     * Pop a `WithEnvironmentObject` from the environment chain.
   3324     *
   3325     * See `JSOp::PushLexicalEnv` for the fine print.
   3326     *
   3327     * Implements: [Evaluation of `with` statements][1], step 8.
   3328     *
   3329     * [1]: https://tc39.es/ecma262/#sec-with-statement-runtime-semantics-evaluation
   3330     *
   3331     *   Category: Variables and scopes
   3332     *   Type: Entering and leaving environments
   3333     *   Operands:
   3334     *   Stack: =>
   3335     */ \
   3336    MACRO(LeaveWith, leave_with, NULL, 1, 0, 0, JOF_BYTE) \
   3337    /*
   3338     * Append the object and method on the stack as a disposable to be disposed on
   3339     * to the current lexical environment object.
   3340     *
   3341     * Implements: [AddDisposableResource ( disposeCapability, V, hint [ , method ] )][1], steps 3-4.
   3342     *
   3343     * [1] https://arai-a.github.io/ecma262-compare/?pr=3000&id=sec-adddisposableresource
   3344     *
   3345     *   Category: Variables and scopes
   3346     *   Type: Entering and leaving environments
   3347     *   Operands: UsingHint hint
   3348     *   Stack: v, method, needsClosure =>
   3349     */ \
   3350    IF_EXPLICIT_RESOURCE_MANAGEMENT(MACRO(AddDisposable, add_disposable, NULL, 2, 3, 0, JOF_UINT8|JOF_USES_ENV)) \
   3351    /*
   3352     * Get the dispose capability of the present environment object.
   3353     * In case the dispose capability of the environment
   3354     * has already been cleared or if no disposables have been
   3355     * pushed to the capability, it shall push undefined as the dispose
   3356     * capability. After extracting a non-empty dispose
   3357     * capability, the dispose capability is cleared from the present
   3358     * environment object by setting it to undefined value.
   3359     *
   3360     *   Category: Variables and scopes
   3361     *   Type: Entering and leaving environments
   3362     *   Operands:
   3363     *   Stack: => disposeCapability
   3364     */ \
   3365    IF_EXPLICIT_RESOURCE_MANAGEMENT(MACRO(TakeDisposeCapability, take_dispose_capability, NULL, 1, 0, 1, JOF_BYTE|JOF_USES_ENV)) \
   3366    /*
   3367     * Push the current VariableEnvironment (the environment on the environment
   3368     * chain designated to receive new variables).
   3369     *
   3370     * Implements: [Annex B.3.3.1, changes to FunctionDeclarationInstantiation
   3371     * for block-level functions][1], step 1.a.ii.3.a, and similar steps in
   3372     * other Annex B.3.3 algorithms, when setting the function's second binding
   3373     * can't be optimized.
   3374     *
   3375     * [1]: https://tc39.es/ecma262/#sec-web-compat-functiondeclarationinstantiation
   3376     *
   3377     *   Category: Variables and scopes
   3378     *   Type: Creating and deleting bindings
   3379     *   Operands:
   3380     *   Stack: => env
   3381     */ \
   3382    MACRO(BindVar, bind_var, NULL, 1, 0, 1, JOF_BYTE|JOF_USES_ENV) \
   3383    /*
   3384     * Check for conflicting bindings and then initialize them in global or
   3385     * sloppy eval scripts. This is required for global scripts with any
   3386     * top-level bindings, or any sloppy-eval scripts with any non-lexical
   3387     * top-level bindings.
   3388     *
   3389     * Implements: [GlobalDeclarationInstantiation][1] and
   3390     *             [EvalDeclarationInstantiation][2] (except step 12).
   3391     *
   3392     * The `lastFun` argument is a GCThingIndex of the last hoisted top-level
   3393     * function that is part of top-level script initialization. The gcthings
   3394     * from index `0` thru `lastFun` contain only scopes and hoisted functions.
   3395     *
   3396     * [1]: https://tc39.es/ecma262/#sec-globaldeclarationinstantiation
   3397     * [2]: https://tc39.es/ecma262/#sec-evaldeclarationinstantiation
   3398     *
   3399     *   Category: Variables and scopes
   3400     *   Type: Creating and deleting bindings
   3401     *   Operands: uint32_t lastFun
   3402     *   Stack: =>
   3403     */ \
   3404    MACRO(GlobalOrEvalDeclInstantiation, global_or_eval_decl_instantiation, NULL, 5, 0, 0, JOF_GCTHING|JOF_USES_ENV) \
   3405    /*
   3406     * Look up a variable on the environment chain and delete it. Push `true`
   3407     * on success (if a binding was deleted, or if no such binding existed in
   3408     * the first place), `false` otherwise (most kinds of bindings can't be
   3409     * deleted).
   3410     *
   3411     * Implements: [`delete` *Identifier*][1], which [is a SyntaxError][2] in
   3412     * strict mode code.
   3413     *
   3414     *    [1]: https://tc39.es/ecma262/#sec-delete-operator-runtime-semantics-evaluation
   3415     *    [2]: https://tc39.es/ecma262/#sec-delete-operator-static-semantics-early-errors
   3416     *
   3417     *   Category: Variables and scopes
   3418     *   Type: Creating and deleting bindings
   3419     *   Operands: uint32_t nameIndex
   3420     *   Stack: => succeeded
   3421     */ \
   3422    MACRO(DelName, del_name, NULL, 5, 0, 1, JOF_ATOM|JOF_CHECKSLOPPY|JOF_USES_ENV) \
   3423    /*
   3424     * Create and push the `arguments` object for the current function activation.
   3425     *
   3426     * When it exists, `arguments` is stored in an ordinary local variable.
   3427     * `JSOp::Arguments` is used in function preludes, to populate that variable
   3428     * before the function body runs, *not* each time `arguments` appears in a
   3429     * function.
   3430     *
   3431     * If a function clearly doesn't use `arguments`, we optimize it away when
   3432     * emitting bytecode. The function's script won't use `JSOp::Arguments` at
   3433     * all.
   3434     *
   3435     * The current script must be a function script. This instruction must
   3436     * execute at most once per function activation.
   3437     *
   3438     *   Category: Variables and scopes
   3439     *   Type: Function environment setup
   3440     *   Operands:
   3441     *   Stack: => arguments
   3442     */ \
   3443    MACRO(Arguments, arguments, NULL, 1, 0, 1, JOF_BYTE|JOF_USES_ENV) \
   3444    /*
   3445     * Create and push the rest parameter array for current function call.
   3446     *
   3447     * This must appear only in a script for a function that has a rest
   3448     * parameter.
   3449     *
   3450     *   Category: Variables and scopes
   3451     *   Type: Function environment setup
   3452     *   Operands:
   3453     *   Stack: => rest
   3454     */ \
   3455    MACRO(Rest, rest, NULL, 1, 0, 1, JOF_BYTE|JOF_IC) \
   3456    /*
   3457     * Determines the `this` value for current function frame and pushes it
   3458     * onto the stack.
   3459     *
   3460     * In functions, `this` is stored in a local variable. This instruction is
   3461     * used in the function prologue to get the value to initialize that
   3462     * variable.  (This doesn't apply to arrow functions, becauses they don't
   3463     * have a `this` binding; also, `this` is optimized away if it's unused.)
   3464     *
   3465     * Functions that have a `this` binding have a local variable named
   3466     * `".this"`, which is initialized using this instruction in the function
   3467     * prologue.
   3468     *
   3469     * In non-strict functions, `this` is always an object. Undefined/null
   3470     * `this` is converted into the global `this` value. Other primitive values
   3471     * are boxed. See `js::BoxNonStrictThis`.
   3472     *
   3473     *   Category: Variables and scopes
   3474     *   Type: Function environment setup
   3475     *   Operands:
   3476     *   Stack: => this
   3477     */ \
   3478    MACRO(FunctionThis, function_this, NULL, 1, 0, 1, JOF_BYTE) \
   3479    /*
   3480     * Pop the top value from the stack and discard it.
   3481     *
   3482     *   Category: Stack operations
   3483     *   Operands:
   3484     *   Stack: v =>
   3485     */ \
   3486    MACRO(Pop, pop, NULL, 1, 1, 0, JOF_BYTE) \
   3487    /*
   3488     * Pop the top `n` values from the stack. `n` must be <= the current stack
   3489     * depth.
   3490     *
   3491     *   Category: Stack operations
   3492     *   Operands: uint16_t n
   3493     *   Stack: v[n-1], ..., v[1], v[0] =>
   3494     */ \
   3495    MACRO(PopN, pop_n, NULL, 3, -1, 0, JOF_UINT16) \
   3496    /*
   3497     * Push a copy of the top value on the stack.
   3498     *
   3499     *   Category: Stack operations
   3500     *   Operands:
   3501     *   Stack: v => v, v
   3502     */ \
   3503    MACRO(Dup, dup, NULL, 1, 1, 2, JOF_BYTE) \
   3504    /*
   3505     * Duplicate the top two values on the stack.
   3506     *
   3507     *   Category: Stack operations
   3508     *   Operands:
   3509     *   Stack: v1, v2 => v1, v2, v1, v2
   3510     */ \
   3511    MACRO(Dup2, dup2, NULL, 1, 2, 4, JOF_BYTE) \
   3512    /*
   3513     * Push a copy of the nth value from the top of the stack.
   3514     *
   3515     * `n` must be less than the current stack depth.
   3516     *
   3517     *   Category: Stack operations
   3518     *   Operands: uint24_t n
   3519     *   Stack: v[n], v[n-1], ..., v[1], v[0] =>
   3520     *          v[n], v[n-1], ..., v[1], v[0], v[n]
   3521     */ \
   3522    MACRO(DupAt, dup_at, NULL, 4, 0, 1, JOF_UINT24) \
   3523    /*
   3524     * Swap the top two values on the stack.
   3525     *
   3526     *   Category: Stack operations
   3527     *   Operands:
   3528     *   Stack: v1, v2 => v2, v1
   3529     */ \
   3530    MACRO(Swap, swap, NULL, 1, 2, 2, JOF_BYTE) \
   3531    /*
   3532     * Pick the nth element from the stack and move it to the top of the stack.
   3533     *
   3534     *   Category: Stack operations
   3535     *   Operands: uint8_t n
   3536     *   Stack: v[n], v[n-1], ..., v[1], v[0] => v[n-1], ..., v[1], v[0], v[n]
   3537     */ \
   3538    MACRO(Pick, pick, NULL, 2, 0, 0, JOF_UINT8) \
   3539    /*
   3540     * Move the top of the stack value under the `n`th element of the stack.
   3541     * `n` must not be 0.
   3542     *
   3543     *   Category: Stack operations
   3544     *   Operands: uint8_t n
   3545     *   Stack: v[n], v[n-1], ..., v[1], v[0] => v[0], v[n], v[n-1], ..., v[1]
   3546     */ \
   3547    MACRO(Unpick, unpick, NULL, 2, 0, 0, JOF_UINT8) \
   3548    /*
   3549     * Do nothing. This is used when we need distinct bytecode locations for
   3550     * various mechanisms.
   3551     *
   3552     *   Category: Other
   3553     *   Operands:
   3554     *   Stack: =>
   3555     */ \
   3556    MACRO(Nop, nop, NULL, 1, 0, 0, JOF_BYTE) \
   3557    /*
   3558     * No-op instruction emitted immediately after `JSOp::*Eval` so that direct
   3559     * eval does not have to do slow pc-to-line mapping.
   3560     *
   3561     * The `lineno` operand should agree with this script's source notes about
   3562     * the line number of the preceding `*Eval` instruction.
   3563     *
   3564     *   Category: Other
   3565     *   Operands: uint32_t lineno
   3566     *   Stack: =>
   3567     */ \
   3568    MACRO(Lineno, lineno, NULL, 5, 0, 0, JOF_UINT32) \
   3569    /*
   3570     * No-op instruction to hint that the top stack value is uninteresting.
   3571     *
   3572     * This affects only debug output and some error messages.
   3573     * In array destructuring, we emit bytecode that is roughly equivalent to
   3574     * `result.done ? undefined : result.value`.
   3575     * `NopDestructuring` is emitted after the `undefined`, so that the
   3576     * expression decompiler and disassembler know to casually ignore the
   3577     * possibility of `undefined`, and render the result of the conditional
   3578     * expression simply as "`result.value`".
   3579     *
   3580     *   Category: Other
   3581     *   Operands:
   3582     *   Stack: =>
   3583     */ \
   3584    MACRO(NopDestructuring, nop_destructuring, NULL, 1, 0, 0, JOF_BYTE) \
   3585    /*
   3586     * No-op instruction only emitted in some self-hosted functions. Not
   3587     * handled by the JITs or Baseline Interpreter so the script always runs in
   3588     * the C++ interpreter.
   3589     *
   3590     *   Category: Other
   3591     *   Operands:
   3592     *   Stack: =>
   3593     */ \
   3594    MACRO(ForceInterpreter, force_interpreter, NULL, 1, 0, 0, JOF_BYTE) \
   3595    /*
   3596     * Examine the top stack value, asserting that it's either a self-hosted
   3597     * function or a self-hosted intrinsic. This does nothing in a non-debug
   3598     * build.
   3599     *
   3600     *   Category: Other
   3601     *   Operands:
   3602     *   Stack: checkVal => checkVal
   3603     */ \
   3604    MACRO(DebugCheckSelfHosted, debug_check_self_hosted, NULL, 1, 1, 1, JOF_BYTE) \
   3605    /*
   3606     * Break in the debugger, if one is attached. Otherwise this is a no-op.
   3607     *
   3608     * The [`Debugger` API][1] offers a way to hook into this instruction.
   3609     *
   3610     * Implements: [Evaluation for *DebuggerStatement*][2].
   3611     *
   3612     * [1]: https://developer.mozilla.org/en-US/docs/Tools/Debugger-API/Debugger
   3613     * [2]: https://tc39.es/ecma262/#sec-debugger-statement-runtime-semantics-evaluation
   3614     *
   3615     *   Category: Other
   3616     *   Operands:
   3617     *   Stack: =>
   3618     */ \
   3619    MACRO(Debugger, debugger, NULL, 1, 0, 0, JOF_BYTE)
   3620 
   3621 // clang-format on
   3622 
   3623 /*
   3624 * In certain circumstances it may be useful to "pad out" the opcode space to
   3625 * a power of two.  Use this macro to do so.
   3626 */
   3627 
   3628 #ifdef ENABLE_EXPLICIT_RESOURCE_MANAGEMENT
   3629 #  define FOR_EACH_TRAILING_UNUSED_OPCODE(MACRO) \
   3630    MACRO(242)                                   \
   3631    MACRO(243)                                   \
   3632    MACRO(244)                                   \
   3633    MACRO(245)                                   \
   3634    MACRO(246)                                   \
   3635    MACRO(247)                                   \
   3636    MACRO(248)                                   \
   3637    MACRO(249)                                   \
   3638    MACRO(250)                                   \
   3639    MACRO(251)                                   \
   3640    MACRO(252)                                   \
   3641    MACRO(253)                                   \
   3642    MACRO(254)                                   \
   3643    MACRO(255)
   3644 #else
   3645 #  define FOR_EACH_TRAILING_UNUSED_OPCODE(MACRO) \
   3646    MACRO(239)                                   \
   3647    MACRO(240)                                   \
   3648    MACRO(241)                                   \
   3649    MACRO(242)                                   \
   3650    MACRO(243)                                   \
   3651    MACRO(244)                                   \
   3652    MACRO(245)                                   \
   3653    MACRO(246)                                   \
   3654    MACRO(247)                                   \
   3655    MACRO(248)                                   \
   3656    MACRO(249)                                   \
   3657    MACRO(250)                                   \
   3658    MACRO(251)                                   \
   3659    MACRO(252)                                   \
   3660    MACRO(253)                                   \
   3661    MACRO(254)                                   \
   3662    MACRO(255)
   3663 #endif
   3664 
   3665 namespace js {
   3666 
   3667 // Sanity check that opcode values and trailing unused opcodes completely cover
   3668 // the [0, 256) range.  Avert your eyes!  You don't want to know how the
   3669 // sausage gets made.
   3670 
   3671 // clang-format off
   3672 #define PLUS_ONE(...) \
   3673    + 1
   3674 constexpr int JSOP_LIMIT = 0 FOR_EACH_OPCODE(PLUS_ONE);
   3675 #undef PLUS_ONE
   3676 
   3677 #define TRAILING_VALUE_AND_VALUE_PLUS_ONE(val) \
   3678    val) && (val + 1 ==
   3679 static_assert((JSOP_LIMIT ==
   3680               FOR_EACH_TRAILING_UNUSED_OPCODE(TRAILING_VALUE_AND_VALUE_PLUS_ONE)
   3681               256),
   3682              "trailing unused opcode values monotonically increase "
   3683              "from JSOP_LIMIT to 255");
   3684 #undef TRAILING_VALUE_AND_VALUE_PLUS_ONE
   3685 // clang-format on
   3686 
   3687 // Define JSOpLength_* constants for all ops.
   3688 #define DEFINE_LENGTH_CONSTANT(op, op_snake, image, len, ...) \
   3689  constexpr size_t JSOpLength_##op = len;
   3690 FOR_EACH_OPCODE(DEFINE_LENGTH_CONSTANT)
   3691 #undef DEFINE_LENGTH_CONSTANT
   3692 
   3693 }  // namespace js
   3694 
   3695 /*
   3696 * JS operation bytecodes.
   3697 */
   3698 enum class JSOp : uint8_t {
   3699 #define ENUMERATE_OPCODE(op, ...) op,
   3700  FOR_EACH_OPCODE(ENUMERATE_OPCODE)
   3701 #undef ENUMERATE_OPCODE
   3702 };
   3703 
   3704 #endif  // vm_Opcodes_h