1.1 --- a/jitcraft/Opcodes.tbl Tue Jul 17 21:40:44 2012 -0700
1.2 +++ b/jitcraft/Opcodes.tbl Tue Jul 17 23:05:38 2012 -0700
1.3 @@ -86,40 +86,41 @@
1.4 OPDEF(OP_NE, 31, "ne", 1, 2, 1)
1.5
1.6 OPDEF(OP_NOT, 32, "not", 1, 1, 1)
1.7 +OPDEF(OP_NEG, 33, "neg", 1, 1, 1)
1.8
1.9 -OPDEF(OP_POP, 33, "pop", 1, 1, 0)
1.10 +OPDEF(OP_POP, 34, "pop", 1, 1, 0)
1.11
1.12 // Unconditional terminator placed at the end of code. If a function returns
1.13 // void, this acts as a RETURNVOID. Otherwise, it must be unreachable.
1.14 -OPDEF(OP_STOP, 34, "stop", 1, 0, 0)
1.15 +OPDEF(OP_STOP, 35, "stop", 1, 0, 0)
1.16
1.17 // Call a function with N arguments. The target function must be the last item
1.18 // on the stack.
1.19 -OPDEF(OP_CALL, 35, "call", 1, -1, 1)
1.20 +OPDEF(OP_CALL, 36, "call", 1, -1, 1)
1.21
1.22 // Similar to GET/LOCAL, except for arguments.
1.23 -OPDEF(OP_GETARG, 36, "getarg", 5, 0, 1)
1.24 -OPDEF(OP_SETARG, 37, "setarg", 5, 1, 1)
1.25 +OPDEF(OP_GETARG, 37, "getarg", 5, 0, 1)
1.26 +OPDEF(OP_SETARG, 38, "setarg", 5, 1, 1)
1.27
1.28 // Reads or writes an integer element to an unsafe array.
1.29 // index = pop()
1.30 // ref = pop()
1.31 // ref[index]
1.32 //
1.33 -OPDEF(OP_GETARRAY_I, 38, "getarray.i", 1, 2, 1)
1.34 -OPDEF(OP_SETARRAY_I, 39, "setarray.i", 1, 3, 1)
1.35 -OPDEF(OP_GETARRAY_F, 40, "getarray.f", 1, 2, 1)
1.36 -OPDEF(OP_SETARRAY_F, 41, "setarray.f", 1, 3, 1)
1.37 -OPDEF(OP_GETARRAY_C, 42, "getarray.c", 1, 2, 1)
1.38 -OPDEF(OP_SETARRAY_C, 43, "setarray.c", 1, 3, 1)
1.39 -OPDEF(OP_GETARRAY_O, 44, "getarray.o", 1, 2, 1)
1.40 +OPDEF(OP_GETARRAY_I, 39, "getarray.i", 1, 2, 1)
1.41 +OPDEF(OP_SETARRAY_I, 40, "setarray.i", 1, 3, 1)
1.42 +OPDEF(OP_GETARRAY_F, 41, "getarray.f", 1, 2, 1)
1.43 +OPDEF(OP_SETARRAY_F, 42, "setarray.f", 1, 3, 1)
1.44 +OPDEF(OP_GETARRAY_C, 43, "getarray.c", 1, 2, 1)
1.45 +OPDEF(OP_SETARRAY_C, 44, "setarray.c", 1, 3, 1)
1.46 +OPDEF(OP_GETARRAY_O, 45, "getarray.o", 1, 2, 1)
1.47
1.48 // Allocate an array, info LIFO space if possible. The ArrayMap to use is
1.49 // specified as an index into the script's Map table.
1.50 //
1.51 // Format:
1.52 // [u8 op] [u32 index]
1.53 -OPDEF(OP_NEWARRAY_LIFO, 45, "newarray.lifo", 5, 0, 1)
1.54 +OPDEF(OP_NEWARRAY_LIFO, 46, "newarray.lifo", 5, 0, 1)
1.55
1.56 // Performs a bounds check on an unsafe array.
1.57 //
1.58 @@ -127,73 +128,74 @@
1.59 // array = pop()
1.60 // push(array)
1.61 // push(index)
1.62 -OPDEF(OP_BOUNDS, 46, "bounds", 1, 2, 2)
1.63 +OPDEF(OP_BOUNDS, 47, "bounds", 1, 2, 2)
1.64
1.65 // Pushes a 32-bit IEEE-754 floating point immediate onto the stack.
1.66 -OPDEF(OP_FLOAT, 47, "float", 5, 0, 1)
1.67 +OPDEF(OP_FLOAT, 48, "float", 5, 0, 1)
1.68
1.69 // Converts an integer to a 32-bit IEEE-754 floating point immediate.
1.70 -OPDEF(OP_CVT_I2F, 48, "cvt.i2f", 1, 1, 1)
1.71 +OPDEF(OP_CVT_I2F, 49, "cvt.i2f", 1, 1, 1)
1.72
1.73 // Stack transitions for these binary operators:
1.74 // rhs = pop()
1.75 // lhs = pop()
1.76 // push(lhs OP rhs)
1.77 -OPDEF(OP_ADD_F, 49, "add.f", 1, 2, 1)
1.78 -OPDEF(OP_SUB_F, 50, "sub.f", 1, 2, 1)
1.79 -OPDEF(OP_MUL_F, 51, "mul.f", 1, 2, 1)
1.80 -OPDEF(OP_DIV_F, 52, "div.f", 1, 2, 1)
1.81 +OPDEF(OP_ADD_F, 50, "add.f", 1, 2, 1)
1.82 +OPDEF(OP_SUB_F, 51, "sub.f", 1, 2, 1)
1.83 +OPDEF(OP_MUL_F, 52, "mul.f", 1, 2, 1)
1.84 +OPDEF(OP_DIV_F, 53, "div.f", 1, 2, 1)
1.85
1.86 -OPDEF(OP_LT_F, 53, "lt.f", 1, 2, 1)
1.87 -OPDEF(OP_LE_F, 54, "le.f", 1, 2, 1)
1.88 -OPDEF(OP_GE_F, 55, "ge.f", 1, 2, 1)
1.89 -OPDEF(OP_GT_F, 56, "gt.f", 1, 2, 1)
1.90 -OPDEF(OP_EQ_F, 57, "eq.f", 1, 2, 1)
1.91 -OPDEF(OP_NE_F, 58, "ne.f", 1, 2, 1)
1.92 +OPDEF(OP_LT_F, 54, "lt.f", 1, 2, 1)
1.93 +OPDEF(OP_LE_F, 55, "le.f", 1, 2, 1)
1.94 +OPDEF(OP_GE_F, 56, "ge.f", 1, 2, 1)
1.95 +OPDEF(OP_GT_F, 57, "gt.f", 1, 2, 1)
1.96 +OPDEF(OP_EQ_F, 58, "eq.f", 1, 2, 1)
1.97 +OPDEF(OP_NE_F, 59, "ne.f", 1, 2, 1)
1.98
1.99 -OPDEF(OP_NOT_F, 59, "not.f", 1, 1, 1)
1.100 +OPDEF(OP_NOT_F, 60, "not.f", 1, 1, 1)
1.101 +OPDEF(OP_NEG_F, 61, "neg.f", 1, 1, 1)
1.102
1.103 // Bitwise operators.
1.104 -OPDEF(OP_SHL, 60, "shl", 1, 2, 1)
1.105 -OPDEF(OP_SHR, 61, "shr", 1, 2, 1)
1.106 -OPDEF(OP_USHR, 62, "ushr", 1, 2, 1)
1.107 -OPDEF(OP_BITAND, 63, "bitand", 1, 2, 1)
1.108 -OPDEF(OP_BITOR, 64, "bitor", 1, 2, 1)
1.109 -OPDEF(OP_BITXOR, 65, "bitxor", 1, 2, 1)
1.110 -OPDEF(OP_BITNOT, 66, "bitnot", 1, 1, 1)
1.111 +OPDEF(OP_SHL, 62, "shl", 1, 2, 1)
1.112 +OPDEF(OP_SHR, 63, "shr", 1, 2, 1)
1.113 +OPDEF(OP_USHR, 64, "ushr", 1, 2, 1)
1.114 +OPDEF(OP_BITAND, 65, "bitand", 1, 2, 1)
1.115 +OPDEF(OP_BITOR, 66, "bitor", 1, 2, 1)
1.116 +OPDEF(OP_BITXOR, 67, "bitxor", 1, 2, 1)
1.117 +OPDEF(OP_BITNOT, 68, "bitnot", 1, 1, 1)
1.118
1.119 // Saves or restores the position of the LIFO heap to/from a local slot.
1.120 -OPDEF(OP_SAVELIFO, 67, "savelifo", 5, 0, 0)
1.121 -OPDEF(OP_UNWINDLIFO, 68, "unwindlifo", 5, 0, 0)
1.122 +OPDEF(OP_SAVELIFO, 69, "savelifo", 5, 0, 0)
1.123 +OPDEF(OP_UNWINDLIFO, 70, "unwindlifo", 5, 0, 0)
1.124
1.125 // Composes a variable reference to a stack slot or argument.
1.126 -OPDEF(OP_VARREF_LIFO, 69, "varref.lifo", 5, 0, 1)
1.127 -OPDEF(OP_ARGREF_LIFO, 70, "argref.lifo", 5, 0, 1)
1.128 -OPDEF(OP_SLOTREF_LIFO, 71, "slotref.lifo", 1, 1, 1)
1.129 -OPDEF(OP_ARRAYREF_LIFO, 72, "arrayref.lifo",1, 2, 1)
1.130 -OPDEF(OP_GETREF_I, 73, "getref.i", 1, 1, 1)
1.131 -OPDEF(OP_SETREF_I, 74, "setref.i", 1, 2, 1)
1.132 -OPDEF(OP_GETREF_F, 75, "getref.f", 1, 1, 1)
1.133 -OPDEF(OP_SETREF_F, 76, "setref.f", 1, 2, 1)
1.134 +OPDEF(OP_VARREF_LIFO, 71, "varref.lifo", 5, 0, 1)
1.135 +OPDEF(OP_ARGREF_LIFO, 72, "argref.lifo", 5, 0, 1)
1.136 +OPDEF(OP_SLOTREF_LIFO, 73, "slotref.lifo", 1, 1, 1)
1.137 +OPDEF(OP_ARRAYREF_LIFO, 74, "arrayref.lifo",1, 2, 1)
1.138 +OPDEF(OP_GETREF_I, 75, "getref.i", 1, 1, 1)
1.139 +OPDEF(OP_SETREF_I, 76, "setref.i", 1, 2, 1)
1.140 +OPDEF(OP_GETREF_F, 77, "getref.f", 1, 1, 1)
1.141 +OPDEF(OP_SETREF_F, 78, "setref.f", 1, 2, 1)
1.142
1.143 // Pushes an object reference onto the stack.
1.144 -OPDEF(OP_OBJECT, 77, "object", 5, 0, 1)
1.145 +OPDEF(OP_OBJECT, 79, "object", 5, 0, 1)
1.146
1.147 // Performs an array-to-array assignment.
1.148 // Left = pop()
1.149 // Right = pop()
1.150 // copy(Left, Right)
1.151 // push(Left)
1.152 -OPDEF(OP_ARRAYCOPY, 78, "arraycopy", 1, 2, 1)
1.153 +OPDEF(OP_ARRAYCOPY, 80, "arraycopy", 1, 2, 1)
1.154
1.155 // Duplicates the top item on the stack.
1.156 -OPDEF(OP_DUP, 79, "dup", 1, 1, 2)
1.157 +OPDEF(OP_DUP, 81, "dup", 1, 1, 2)
1.158
1.159 // Duplicates the top two items on the stack.
1.160 -OPDEF(OP_DUP2, 80, "dup2", 1, 2, 4)
1.161 +OPDEF(OP_DUP2, 82, "dup2", 1, 2, 4)
1.162
1.163 // Swaps the two items at the top of the stack.
1.164 -OPDEF(OP_SWAP, 81, "swap", 1, 2, 2)
1.165 +OPDEF(OP_SWAP, 83, "swap", 1, 2, 2)
1.166
1.167 // Roll operation is the same as Forth. It steals a value on the stack,
1.168 // shifting all stack values down, and then places the stolen value back at
1.169 @@ -203,14 +205,14 @@
1.170 // sp[-3] = sp[-2]
1.171 // sp[-2] = sp[-1]
1.172 // sp[-1] = p
1.173 -OPDEF(OP_ROLL3, 82, "roll3", 1, 3, 3)
1.174 +OPDEF(OP_ROLL3, 84, "roll3", 1, 3, 3)
1.175
1.176 // Pick operation is the same as Forth. It pushes a copy of a slot at a
1.177 // specific depth.
1.178 //
1.179 // push(sp[-n])
1.180 -OPDEF(OP_PICK2, 83, "pick2", 1, 2, 3)
1.181 -OPDEF(OP_PICK3, 84, "pick3", 1, 3, 4)
1.182 +OPDEF(OP_PICK2, 85, "pick2", 1, 2, 3)
1.183 +OPDEF(OP_PICK3, 86, "pick3", 1, 3, 4)
1.184
1.185 // Calls a native function. During the course of calling a native, arguments
1.186 // on the stack are re-pushed to match the cell-based native calling
1.187 @@ -221,14 +223,14 @@
1.188 //
1.189 // [u8 Opcode] [u32 Index] [u32 ArgCount]
1.190 //
1.191 -OPDEF(OP_CALLNATIVE, 85, "callnative", 9, -1, 1)
1.192 +OPDEF(OP_CALLNATIVE, 87, "callnative", 9, -1, 1)
1.193
1.194 // Returns from a function that does return a value.
1.195 -OPDEF(OP_RETURNVOID, 86, "returnvoid", 1, 0, 0)
1.196 +OPDEF(OP_RETURNVOID, 88, "returnvoid", 1, 0, 0)
1.197
1.198 // Loads the module of the running function.
1.199 -OPDEF(OP_MODULE, 87, "module", 1, 0, 1)
1.200 +OPDEF(OP_MODULE, 89, "module", 1, 0, 1)
1.201
1.202 // Loads a function from a module object. The operand is the slot number
1.203 // in the module.
1.204 -OPDEF(OP_GETMODULE_FN, 88, "getmodule.fn", 5, 1, 1)
1.205 +OPDEF(OP_GETMODULE_FN, 90, "getmodule.fn", 5, 1, 1)