1.1 --- a/src/Opcodes.tbl Sun Aug 05 00:49:31 2012 -0700
1.2 +++ b/src/Opcodes.tbl Sun Aug 05 01:10:49 2012 -0700
1.3 @@ -103,25 +103,27 @@
1.4 OPDEF(OP_GETARG, 38, "getarg", 5, 0, 1)
1.5 OPDEF(OP_SETARG, 39, "setarg", 5, 1, 1)
1.6
1.7 +// Allocate an array. The HeapTenure is stored as a byte following pc. The
1.8 +// ArrayMap to use is specified as an index into the script's Map table.
1.9 +//
1.10 +// Format:
1.11 +// [u8 op] [u32 index]
1.12 +OPDEF(OP_NEWARRAY, 40, "newarray", 6, 0, 1)
1.13 +
1.14 +// Performs an array-to-array assignment.
1.15 +// Left = pop()
1.16 +// Right = pop()
1.17 +// copy(Left, Right)
1.18 +// push(Left)
1.19 +OPDEF(OP_COPYARRAY, 41, "arraycopy", 1, 2, 1)
1.20 +
1.21 // Reads or writes an integer element to an unsafe array.
1.22 // index = pop()
1.23 // ref = pop()
1.24 // ref[index]
1.25 //
1.26 -OPDEF(OP_GETARRAY_I, 40, "getarray.i", 1, 2, 1)
1.27 -OPDEF(OP_SETARRAY_I, 41, "setarray.i", 1, 3, 1)
1.28 -OPDEF(OP_GETARRAY_F, 42, "getarray.f", 1, 2, 1)
1.29 -OPDEF(OP_SETARRAY_F, 43, "setarray.f", 1, 3, 1)
1.30 -OPDEF(OP_GETARRAY_C, 44, "getarray.c", 1, 2, 1)
1.31 -OPDEF(OP_SETARRAY_C, 45, "setarray.c", 1, 3, 1)
1.32 -OPDEF(OP_GETARRAY_O, 46, "getarray.o", 1, 2, 1)
1.33 -
1.34 -// Allocate an array. The HeapTenure is stored as a byte following pc. The
1.35 -// ArrayMap to use is specified as an index into the script's Map table.
1.36 -//
1.37 -// Format:
1.38 -// [u8 op] [u32 index]
1.39 -OPDEF(OP_NEWARRAY, 47, "newarray", 6, 0, 1)
1.40 +OPDEF(OP_GETELEM, 42, "getelem", 1, 2, 1)
1.41 +OPDEF(OP_SETELEM, 43, "setelem", 1, 3, 1)
1.42
1.43 // Performs a bounds check on an unsafe array.
1.44 //
1.45 @@ -129,75 +131,67 @@
1.46 // array = pop()
1.47 // push(array)
1.48 // push(index)
1.49 -OPDEF(OP_BOUNDS, 48, "bounds", 1, 2, 2)
1.50 +OPDEF(OP_BOUNDS, 44, "bounds", 1, 2, 2)
1.51
1.52 // Pushes a 32-bit IEEE-754 floating point immediate onto the stack.
1.53 -OPDEF(OP_FLOAT, 49, "float", 5, 0, 1)
1.54 +OPDEF(OP_FLOAT, 45, "float", 5, 0, 1)
1.55
1.56 // Converts an integer to a 32-bit IEEE-754 floating point immediate.
1.57 -OPDEF(OP_CVT_I2F, 50, "cvt.i2f", 1, 1, 1)
1.58 +OPDEF(OP_CVT_I2F, 46, "cvt.i2f", 1, 1, 1)
1.59
1.60 // Stack transitions for these binary operators:
1.61 // rhs = pop()
1.62 // lhs = pop()
1.63 // push(lhs OP rhs)
1.64 -OPDEF(OP_ADD_F, 51, "add.f", 1, 2, 1)
1.65 -OPDEF(OP_SUB_F, 52, "sub.f", 1, 2, 1)
1.66 -OPDEF(OP_MUL_F, 53, "mul.f", 1, 2, 1)
1.67 -OPDEF(OP_DIV_F, 54, "div.f", 1, 2, 1)
1.68 -OPDEF(OP_UNUSED1, 55, "unused0", 1, 0, 0)
1.69 +OPDEF(OP_ADD_F, 47, "add.f", 1, 2, 1)
1.70 +OPDEF(OP_SUB_F, 48, "sub.f", 1, 2, 1)
1.71 +OPDEF(OP_MUL_F, 49, "mul.f", 1, 2, 1)
1.72 +OPDEF(OP_DIV_F, 50, "div.f", 1, 2, 1)
1.73
1.74 -OPDEF(OP_LT_F, 56, "lt.f", 1, 2, 1)
1.75 -OPDEF(OP_LE_F, 57, "le.f", 1, 2, 1)
1.76 -OPDEF(OP_GE_F, 58, "ge.f", 1, 2, 1)
1.77 -OPDEF(OP_GT_F, 59, "gt.f", 1, 2, 1)
1.78 -OPDEF(OP_EQ_F, 60, "eq.f", 1, 2, 1)
1.79 -OPDEF(OP_NE_F, 61, "ne.f", 1, 2, 1)
1.80 +OPDEF(OP_LT_F, 51, "lt.f", 1, 2, 1)
1.81 +OPDEF(OP_LE_F, 52, "le.f", 1, 2, 1)
1.82 +OPDEF(OP_GE_F, 53, "ge.f", 1, 2, 1)
1.83 +OPDEF(OP_GT_F, 54, "gt.f", 1, 2, 1)
1.84 +OPDEF(OP_EQ_F, 55, "eq.f", 1, 2, 1)
1.85 +OPDEF(OP_NE_F, 56, "ne.f", 1, 2, 1)
1.86
1.87 -OPDEF(OP_NOT_F, 62, "not.f", 1, 1, 1)
1.88 -OPDEF(OP_NEG_F, 63, "neg.f", 1, 1, 1)
1.89 +OPDEF(OP_NOT_F, 57, "not.f", 1, 1, 1)
1.90 +OPDEF(OP_NEG_F, 58, "neg.f", 1, 1, 1)
1.91
1.92 // Bitwise operators.
1.93 -OPDEF(OP_SHL, 64, "shl", 1, 2, 1)
1.94 -OPDEF(OP_SHR, 65, "shr", 1, 2, 1)
1.95 -OPDEF(OP_USHR, 66, "ushr", 1, 2, 1)
1.96 -OPDEF(OP_BITAND, 67, "bitand", 1, 2, 1)
1.97 -OPDEF(OP_BITOR, 68, "bitor", 1, 2, 1)
1.98 -OPDEF(OP_BITXOR, 69, "bitxor", 1, 2, 1)
1.99 -OPDEF(OP_BITNOT, 70, "bitnot", 1, 1, 1)
1.100 +OPDEF(OP_SHL, 59, "shl", 1, 2, 1)
1.101 +OPDEF(OP_SHR, 60, "shr", 1, 2, 1)
1.102 +OPDEF(OP_USHR, 61, "ushr", 1, 2, 1)
1.103 +OPDEF(OP_BITAND, 62, "bitand", 1, 2, 1)
1.104 +OPDEF(OP_BITOR, 63, "bitor", 1, 2, 1)
1.105 +OPDEF(OP_BITXOR, 64, "bitxor", 1, 2, 1)
1.106 +OPDEF(OP_BITNOT, 65, "bitnot", 1, 1, 1)
1.107
1.108 // Saves or restores the position of the LIFO heap to/from a local slot.
1.109 -OPDEF(OP_SAVELIFO, 71, "savelifo", 5, 0, 0)
1.110 -OPDEF(OP_UNWINDLIFO, 72, "unwindlifo", 5, 0, 0)
1.111 +OPDEF(OP_SAVELIFO, 66, "savelifo", 5, 0, 0)
1.112 +OPDEF(OP_UNWINDLIFO, 67, "unwindlifo", 5, 0, 0)
1.113
1.114 // Composes a variable reference to a stack slot or argument.
1.115 -OPDEF(OP_VARREF_LIFO, 73, "varref.lifo", 5, 0, 1)
1.116 -OPDEF(OP_ARGREF_LIFO, 74, "argref.lifo", 5, 0, 1)
1.117 -OPDEF(OP_SLOTREF_LIFO, 75, "slotref.lifo", 1, 1, 1)
1.118 -OPDEF(OP_ARRAYREF_LIFO, 76, "arrayref.lifo",1, 2, 1)
1.119 -OPDEF(OP_GETREF_I, 77, "getref.i", 1, 1, 1)
1.120 -OPDEF(OP_SETREF_I, 78, "setref.i", 1, 2, 1)
1.121 -OPDEF(OP_GETREF_F, 79, "getref.f", 1, 1, 1)
1.122 -OPDEF(OP_SETREF_F, 80, "setref.f", 1, 2, 1)
1.123 +OPDEF(OP_VARREF_LIFO, 68, "varref.lifo", 5, 0, 1)
1.124 +OPDEF(OP_ARGREF_LIFO, 69, "argref.lifo", 5, 0, 1)
1.125 +OPDEF(OP_SLOTREF_LIFO, 70, "slotref.lifo", 1, 1, 1)
1.126 +OPDEF(OP_ARRAYREF_LIFO, 71, "arrayref.lifo",1, 2, 1)
1.127 +OPDEF(OP_GETREF_I, 72, "getref.i", 1, 1, 1)
1.128 +OPDEF(OP_SETREF_I, 73, "setref.i", 1, 2, 1)
1.129 +OPDEF(OP_GETREF_F, 74, "getref.f", 1, 1, 1)
1.130 +OPDEF(OP_SETREF_F, 75, "setref.f", 1, 2, 1)
1.131
1.132 // Pushes an object reference onto the stack.
1.133 -OPDEF(OP_OBJECT, 81, "object", 5, 0, 1)
1.134 -
1.135 -// Performs an array-to-array assignment.
1.136 -// Left = pop()
1.137 -// Right = pop()
1.138 -// copy(Left, Right)
1.139 -// push(Left)
1.140 -OPDEF(OP_COPYARRAY, 82, "arraycopy", 1, 2, 1)
1.141 +OPDEF(OP_OBJECT, 76, "object", 5, 0, 1)
1.142
1.143 // Duplicates the top item on the stack.
1.144 -OPDEF(OP_DUP, 83, "dup", 1, 1, 2)
1.145 +OPDEF(OP_DUP, 77, "dup", 1, 1, 2)
1.146
1.147 // Duplicates the top two items on the stack.
1.148 -OPDEF(OP_DUP2, 84, "dup2", 1, 2, 4)
1.149 +OPDEF(OP_DUP2, 78, "dup2", 1, 2, 4)
1.150
1.151 // Swaps the two items at the top of the stack.
1.152 -OPDEF(OP_SWAP, 85, "swap", 1, 2, 2)
1.153 +OPDEF(OP_SWAP, 79, "swap", 1, 2, 2)
1.154
1.155 // Roll operation is the same as Forth. It steals a value on the stack,
1.156 // shifting all stack values down, and then places the stolen value back at
1.157 @@ -207,14 +201,14 @@
1.158 // sp[-3] = sp[-2]
1.159 // sp[-2] = sp[-1]
1.160 // sp[-1] = p
1.161 -OPDEF(OP_ROLL3, 86, "roll3", 1, 3, 3)
1.162 +OPDEF(OP_ROLL3, 80, "roll3", 1, 3, 3)
1.163
1.164 // Pick operation is the same as Forth. It pushes a copy of a slot at a
1.165 // specific depth.
1.166 //
1.167 // push(sp[-n])
1.168 -OPDEF(OP_PICK2, 87, "pick2", 1, 2, 3)
1.169 -OPDEF(OP_PICK3, 88, "pick3", 1, 3, 4)
1.170 +OPDEF(OP_PICK2, 81, "pick2", 1, 2, 3)
1.171 +OPDEF(OP_PICK3, 82, "pick3", 1, 3, 4)
1.172
1.173 // Calls a native function. During the course of calling a native, arguments
1.174 // on the stack are re-pushed to match the cell-based native calling
1.175 @@ -225,51 +219,51 @@
1.176 //
1.177 // [u8 Opcode] [u32 Index] [u32 ArgCount]
1.178 //
1.179 -OPDEF(OP_CALLNATIVE, 89, "callnative", 9, -1, 1)
1.180 +OPDEF(OP_CALLNATIVE, 83, "callnative", 9, -1, 1)
1.181
1.182 // Returns from a function that does return a value.
1.183 -OPDEF(OP_RETURNVOID, 90, "returnvoid", 1, 0, 0)
1.184 +OPDEF(OP_RETURNVOID, 84, "returnvoid", 1, 0, 0)
1.185
1.186 // Loads the module of the running function.
1.187 -OPDEF(OP_MODULE, 91, "module", 1, 0, 1)
1.188 +OPDEF(OP_MODULE, 85, "module", 1, 0, 1)
1.189
1.190 // Loads a function from a module object. The operand is the slot number
1.191 // in the module.
1.192 -OPDEF(OP_GETMODULE_FN, 92, "getmodule.fn", 5, 1, 1)
1.193 +OPDEF(OP_GETMODULE_FN, 86, "getmodule.fn", 5, 1, 1)
1.194
1.195 // Opcodes for accessing an environment slot in the global scope.
1.196 -OPDEF(OP_SETGLOBAL_I, 93, "setglobal.i", 5, 1, 1)
1.197 -OPDEF(OP_SETGLOBAL_F, 94, "setglobal.f", 5, 1, 1)
1.198 -OPDEF(OP_SETGLOBAL_O, 95, "setglobal.o", 5, 1, 1)
1.199 -OPDEF(OP_GETGLOBAL_I, 96, "getglobal.i", 5, 0, 1)
1.200 -OPDEF(OP_GETGLOBAL_F, 97, "getglobal.f", 5, 0, 1)
1.201 -OPDEF(OP_GETGLOBAL_O, 98, "getglobal.o", 5, 0, 1)
1.202 +OPDEF(OP_SETGLOBAL_I, 87, "setglobal.i", 5, 1, 1)
1.203 +OPDEF(OP_SETGLOBAL_F, 88, "setglobal.f", 5, 1, 1)
1.204 +OPDEF(OP_SETGLOBAL_O, 89, "setglobal.o", 5, 1, 1)
1.205 +OPDEF(OP_GETGLOBAL_I, 90, "getglobal.i", 5, 0, 1)
1.206 +OPDEF(OP_GETGLOBAL_F, 91, "getglobal.f", 5, 0, 1)
1.207 +OPDEF(OP_GETGLOBAL_O, 92, "getglobal.o", 5, 0, 1)
1.208
1.209 // Reinterprets a 32-bit integer as a float, or vice-versa.
1.210 -OPDEF(OP_BITS_I2F, 99, "bits.i2f", 1, 1, 1)
1.211 -OPDEF(OP_BITS_F2I, 100, "bits.f2i", 1, 1, 1)
1.212 +OPDEF(OP_BITS_I2F, 93, "bits.i2f", 1, 1, 1)
1.213 +OPDEF(OP_BITS_F2I, 94, "bits.f2i", 1, 1, 1)
1.214
1.215 // Pushes a boolean value.
1.216 -OPDEF(OP_TRUE, 101, "true", 1, 0, 1)
1.217 -OPDEF(OP_FALSE, 102, "false", 1, 0, 1)
1.218 +OPDEF(OP_TRUE, 95, "true", 1, 0, 1)
1.219 +OPDEF(OP_FALSE, 96, "false", 1, 0, 1)
1.220
1.221 // Allocate a struct. The HeapTenure is stored as a byte following pc. The
1.222 // StructMap to use is specified as an index into the script's Map table.
1.223 //
1.224 // Format:
1.225 // [u8 op] [u32 index]
1.226 -OPDEF(OP_NEWSTRUCT, 103, "newstruct", 6, 0, 1)
1.227 -
1.228 -// Sets or gets a property in a struct. The index of the field is specified as
1.229 -// a 32-bit integer. Note that these opcodes follow a new style of deriving
1.230 -// their types at runtime.
1.231 -OPDEF(OP_GETFIELD, 104, "getfield", 5, 1, 1)
1.232 -OPDEF(OP_SETFIELD, 105, "setfield", 5, 2, 1)
1.233 +OPDEF(OP_NEWSTRUCT, 97, "newstruct", 6, 0, 1)
1.234
1.235 // Performs a struct-to-struct assignment.
1.236 // Left = pop()
1.237 // Right = pop()
1.238 // copy(Left, Right)
1.239 // push(Left)
1.240 -OPDEF(OP_COPYSTRUCT, 106, "structcopy", 1, 2, 1)
1.241 +OPDEF(OP_COPYSTRUCT, 98, "structcopy", 1, 2, 1)
1.242
1.243 +// Sets or gets a property in a struct. The index of the field is specified as
1.244 +// a 32-bit integer. Note that these opcodes follow a new style of deriving
1.245 +// their types at runtime.
1.246 +OPDEF(OP_GETFIELD, 99, "getfield", 5, 1, 1)
1.247 +OPDEF(OP_SETFIELD, 100, "setfield", 5, 2, 1)
1.248 +