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