The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | /* |
Dan Bornstein | 11a4a79 | 2010-11-16 13:09:45 -0800 | [diff] [blame] | 18 | * Dalvik opcode information. |
| 19 | * |
| 20 | * IMPORTANT NOTE: The contents of this file are mostly generated |
| 21 | * automatically by the opcode-gen tool. Any edits to the generated |
| 22 | * sections will get wiped out the next time the tool is run. |
Dan Bornstein | 758a673 | 2010-11-30 10:45:02 -0800 | [diff] [blame] | 23 | * |
| 24 | * See the file opcode-gen/README.txt for information about updating |
| 25 | * opcodes and instruction formats. |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 26 | */ |
Dan Bornstein | 11a4a79 | 2010-11-16 13:09:45 -0800 | [diff] [blame] | 27 | |
Dan Bornstein | df4daaf | 2010-12-01 14:23:44 -0800 | [diff] [blame] | 28 | #ifndef _LIBDEX_DEXOPCODES |
| 29 | #define _LIBDEX_DEXOPCODES |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 30 | |
Dan Bornstein | 1112216 | 2010-12-01 12:30:21 -0800 | [diff] [blame] | 31 | #include "DexFile.h" |
| 32 | |
| 33 | /* |
| 34 | * the highest possible packed opcode value of a valid Dalvik opcode, plus one |
| 35 | * |
| 36 | * TODO: Change this once the rest of the code is prepared to deal with |
| 37 | * extended opcodes. |
| 38 | */ |
Dan Bornstein | 11a4a79 | 2010-11-16 13:09:45 -0800 | [diff] [blame] | 39 | #define kNumDalvikInstructions 256 |
| 40 | |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 41 | /* |
Dan Bornstein | 11a4a79 | 2010-11-16 13:09:45 -0800 | [diff] [blame] | 42 | * Switch-statement signatures are a "NOP" followed by a code. (A true NOP |
| 43 | * is 0x0000.) |
| 44 | */ |
| 45 | #define kPackedSwitchSignature 0x0100 |
| 46 | #define kSparseSwitchSignature 0x0200 |
| 47 | #define kArrayDataSignature 0x0300 |
| 48 | |
| 49 | /* |
| 50 | * Enumeration of all Dalvik opcodes, where the enumeration value |
Dan Bornstein | 1112216 | 2010-12-01 12:30:21 -0800 | [diff] [blame] | 51 | * associated with each is the corresponding packed opcode number. |
| 52 | * This is different than the opcode value from the Dalvik bytecode |
Dan Bornstein | 9a1f816 | 2010-12-01 17:02:26 -0800 | [diff] [blame] | 53 | * spec for opcode values >= 0xff; see dexOpcodeFromCodeUnit() below. |
Dan Bornstein | 11a4a79 | 2010-11-16 13:09:45 -0800 | [diff] [blame] | 54 | * |
| 55 | * A note about the "breakpoint" opcode. This instruction is special, |
| 56 | * in that it should never be seen by anything but the debug |
| 57 | * interpreter. During debugging it takes the place of an arbitrary |
| 58 | * opcode, which means operations like "tell me the opcode width so I |
| 59 | * can find the next instruction" aren't possible. (This is |
| 60 | * correctable, but probably not useful.) |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 61 | */ |
Dan Bornstein | 9a1f816 | 2010-12-01 17:02:26 -0800 | [diff] [blame] | 62 | typedef enum Opcode { |
Dan Bornstein | 11a4a79 | 2010-11-16 13:09:45 -0800 | [diff] [blame] | 63 | // BEGIN(libdex-opcode-enum); GENERATED AUTOMATICALLY BY opcode-gen |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 64 | OP_NOP = 0x00, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 65 | OP_MOVE = 0x01, |
| 66 | OP_MOVE_FROM16 = 0x02, |
| 67 | OP_MOVE_16 = 0x03, |
| 68 | OP_MOVE_WIDE = 0x04, |
| 69 | OP_MOVE_WIDE_FROM16 = 0x05, |
| 70 | OP_MOVE_WIDE_16 = 0x06, |
| 71 | OP_MOVE_OBJECT = 0x07, |
| 72 | OP_MOVE_OBJECT_FROM16 = 0x08, |
| 73 | OP_MOVE_OBJECT_16 = 0x09, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 74 | OP_MOVE_RESULT = 0x0a, |
| 75 | OP_MOVE_RESULT_WIDE = 0x0b, |
| 76 | OP_MOVE_RESULT_OBJECT = 0x0c, |
| 77 | OP_MOVE_EXCEPTION = 0x0d, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 78 | OP_RETURN_VOID = 0x0e, |
| 79 | OP_RETURN = 0x0f, |
| 80 | OP_RETURN_WIDE = 0x10, |
| 81 | OP_RETURN_OBJECT = 0x11, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 82 | OP_CONST_4 = 0x12, |
| 83 | OP_CONST_16 = 0x13, |
| 84 | OP_CONST = 0x14, |
| 85 | OP_CONST_HIGH16 = 0x15, |
| 86 | OP_CONST_WIDE_16 = 0x16, |
| 87 | OP_CONST_WIDE_32 = 0x17, |
| 88 | OP_CONST_WIDE = 0x18, |
| 89 | OP_CONST_WIDE_HIGH16 = 0x19, |
| 90 | OP_CONST_STRING = 0x1a, |
| 91 | OP_CONST_STRING_JUMBO = 0x1b, |
| 92 | OP_CONST_CLASS = 0x1c, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 93 | OP_MONITOR_ENTER = 0x1d, |
| 94 | OP_MONITOR_EXIT = 0x1e, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 95 | OP_CHECK_CAST = 0x1f, |
| 96 | OP_INSTANCE_OF = 0x20, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 97 | OP_ARRAY_LENGTH = 0x21, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 98 | OP_NEW_INSTANCE = 0x22, |
| 99 | OP_NEW_ARRAY = 0x23, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 100 | OP_FILLED_NEW_ARRAY = 0x24, |
| 101 | OP_FILLED_NEW_ARRAY_RANGE = 0x25, |
| 102 | OP_FILL_ARRAY_DATA = 0x26, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 103 | OP_THROW = 0x27, |
| 104 | OP_GOTO = 0x28, |
| 105 | OP_GOTO_16 = 0x29, |
| 106 | OP_GOTO_32 = 0x2a, |
| 107 | OP_PACKED_SWITCH = 0x2b, |
| 108 | OP_SPARSE_SWITCH = 0x2c, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 109 | OP_CMPL_FLOAT = 0x2d, |
| 110 | OP_CMPG_FLOAT = 0x2e, |
| 111 | OP_CMPL_DOUBLE = 0x2f, |
| 112 | OP_CMPG_DOUBLE = 0x30, |
| 113 | OP_CMP_LONG = 0x31, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 114 | OP_IF_EQ = 0x32, |
| 115 | OP_IF_NE = 0x33, |
| 116 | OP_IF_LT = 0x34, |
| 117 | OP_IF_GE = 0x35, |
| 118 | OP_IF_GT = 0x36, |
| 119 | OP_IF_LE = 0x37, |
| 120 | OP_IF_EQZ = 0x38, |
| 121 | OP_IF_NEZ = 0x39, |
| 122 | OP_IF_LTZ = 0x3a, |
| 123 | OP_IF_GEZ = 0x3b, |
| 124 | OP_IF_GTZ = 0x3c, |
| 125 | OP_IF_LEZ = 0x3d, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 126 | OP_UNUSED_3E = 0x3e, |
| 127 | OP_UNUSED_3F = 0x3f, |
| 128 | OP_UNUSED_40 = 0x40, |
| 129 | OP_UNUSED_41 = 0x41, |
| 130 | OP_UNUSED_42 = 0x42, |
| 131 | OP_UNUSED_43 = 0x43, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 132 | OP_AGET = 0x44, |
| 133 | OP_AGET_WIDE = 0x45, |
| 134 | OP_AGET_OBJECT = 0x46, |
| 135 | OP_AGET_BOOLEAN = 0x47, |
| 136 | OP_AGET_BYTE = 0x48, |
| 137 | OP_AGET_CHAR = 0x49, |
| 138 | OP_AGET_SHORT = 0x4a, |
| 139 | OP_APUT = 0x4b, |
| 140 | OP_APUT_WIDE = 0x4c, |
| 141 | OP_APUT_OBJECT = 0x4d, |
| 142 | OP_APUT_BOOLEAN = 0x4e, |
| 143 | OP_APUT_BYTE = 0x4f, |
| 144 | OP_APUT_CHAR = 0x50, |
| 145 | OP_APUT_SHORT = 0x51, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 146 | OP_IGET = 0x52, |
| 147 | OP_IGET_WIDE = 0x53, |
| 148 | OP_IGET_OBJECT = 0x54, |
| 149 | OP_IGET_BOOLEAN = 0x55, |
| 150 | OP_IGET_BYTE = 0x56, |
| 151 | OP_IGET_CHAR = 0x57, |
| 152 | OP_IGET_SHORT = 0x58, |
| 153 | OP_IPUT = 0x59, |
| 154 | OP_IPUT_WIDE = 0x5a, |
| 155 | OP_IPUT_OBJECT = 0x5b, |
| 156 | OP_IPUT_BOOLEAN = 0x5c, |
| 157 | OP_IPUT_BYTE = 0x5d, |
| 158 | OP_IPUT_CHAR = 0x5e, |
| 159 | OP_IPUT_SHORT = 0x5f, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 160 | OP_SGET = 0x60, |
| 161 | OP_SGET_WIDE = 0x61, |
| 162 | OP_SGET_OBJECT = 0x62, |
| 163 | OP_SGET_BOOLEAN = 0x63, |
| 164 | OP_SGET_BYTE = 0x64, |
| 165 | OP_SGET_CHAR = 0x65, |
| 166 | OP_SGET_SHORT = 0x66, |
| 167 | OP_SPUT = 0x67, |
| 168 | OP_SPUT_WIDE = 0x68, |
| 169 | OP_SPUT_OBJECT = 0x69, |
| 170 | OP_SPUT_BOOLEAN = 0x6a, |
| 171 | OP_SPUT_BYTE = 0x6b, |
| 172 | OP_SPUT_CHAR = 0x6c, |
| 173 | OP_SPUT_SHORT = 0x6d, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 174 | OP_INVOKE_VIRTUAL = 0x6e, |
| 175 | OP_INVOKE_SUPER = 0x6f, |
| 176 | OP_INVOKE_DIRECT = 0x70, |
| 177 | OP_INVOKE_STATIC = 0x71, |
| 178 | OP_INVOKE_INTERFACE = 0x72, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 179 | OP_UNUSED_73 = 0x73, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 180 | OP_INVOKE_VIRTUAL_RANGE = 0x74, |
| 181 | OP_INVOKE_SUPER_RANGE = 0x75, |
| 182 | OP_INVOKE_DIRECT_RANGE = 0x76, |
| 183 | OP_INVOKE_STATIC_RANGE = 0x77, |
| 184 | OP_INVOKE_INTERFACE_RANGE = 0x78, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 185 | OP_UNUSED_79 = 0x79, |
| 186 | OP_UNUSED_7A = 0x7a, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 187 | OP_NEG_INT = 0x7b, |
| 188 | OP_NOT_INT = 0x7c, |
| 189 | OP_NEG_LONG = 0x7d, |
| 190 | OP_NOT_LONG = 0x7e, |
| 191 | OP_NEG_FLOAT = 0x7f, |
| 192 | OP_NEG_DOUBLE = 0x80, |
| 193 | OP_INT_TO_LONG = 0x81, |
| 194 | OP_INT_TO_FLOAT = 0x82, |
| 195 | OP_INT_TO_DOUBLE = 0x83, |
| 196 | OP_LONG_TO_INT = 0x84, |
| 197 | OP_LONG_TO_FLOAT = 0x85, |
| 198 | OP_LONG_TO_DOUBLE = 0x86, |
| 199 | OP_FLOAT_TO_INT = 0x87, |
| 200 | OP_FLOAT_TO_LONG = 0x88, |
| 201 | OP_FLOAT_TO_DOUBLE = 0x89, |
| 202 | OP_DOUBLE_TO_INT = 0x8a, |
| 203 | OP_DOUBLE_TO_LONG = 0x8b, |
| 204 | OP_DOUBLE_TO_FLOAT = 0x8c, |
| 205 | OP_INT_TO_BYTE = 0x8d, |
| 206 | OP_INT_TO_CHAR = 0x8e, |
| 207 | OP_INT_TO_SHORT = 0x8f, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 208 | OP_ADD_INT = 0x90, |
| 209 | OP_SUB_INT = 0x91, |
| 210 | OP_MUL_INT = 0x92, |
| 211 | OP_DIV_INT = 0x93, |
| 212 | OP_REM_INT = 0x94, |
| 213 | OP_AND_INT = 0x95, |
| 214 | OP_OR_INT = 0x96, |
| 215 | OP_XOR_INT = 0x97, |
| 216 | OP_SHL_INT = 0x98, |
| 217 | OP_SHR_INT = 0x99, |
| 218 | OP_USHR_INT = 0x9a, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 219 | OP_ADD_LONG = 0x9b, |
| 220 | OP_SUB_LONG = 0x9c, |
| 221 | OP_MUL_LONG = 0x9d, |
| 222 | OP_DIV_LONG = 0x9e, |
| 223 | OP_REM_LONG = 0x9f, |
| 224 | OP_AND_LONG = 0xa0, |
| 225 | OP_OR_LONG = 0xa1, |
| 226 | OP_XOR_LONG = 0xa2, |
| 227 | OP_SHL_LONG = 0xa3, |
| 228 | OP_SHR_LONG = 0xa4, |
| 229 | OP_USHR_LONG = 0xa5, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 230 | OP_ADD_FLOAT = 0xa6, |
| 231 | OP_SUB_FLOAT = 0xa7, |
| 232 | OP_MUL_FLOAT = 0xa8, |
| 233 | OP_DIV_FLOAT = 0xa9, |
| 234 | OP_REM_FLOAT = 0xaa, |
| 235 | OP_ADD_DOUBLE = 0xab, |
| 236 | OP_SUB_DOUBLE = 0xac, |
| 237 | OP_MUL_DOUBLE = 0xad, |
| 238 | OP_DIV_DOUBLE = 0xae, |
| 239 | OP_REM_DOUBLE = 0xaf, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 240 | OP_ADD_INT_2ADDR = 0xb0, |
| 241 | OP_SUB_INT_2ADDR = 0xb1, |
| 242 | OP_MUL_INT_2ADDR = 0xb2, |
| 243 | OP_DIV_INT_2ADDR = 0xb3, |
| 244 | OP_REM_INT_2ADDR = 0xb4, |
| 245 | OP_AND_INT_2ADDR = 0xb5, |
| 246 | OP_OR_INT_2ADDR = 0xb6, |
| 247 | OP_XOR_INT_2ADDR = 0xb7, |
| 248 | OP_SHL_INT_2ADDR = 0xb8, |
| 249 | OP_SHR_INT_2ADDR = 0xb9, |
| 250 | OP_USHR_INT_2ADDR = 0xba, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 251 | OP_ADD_LONG_2ADDR = 0xbb, |
| 252 | OP_SUB_LONG_2ADDR = 0xbc, |
| 253 | OP_MUL_LONG_2ADDR = 0xbd, |
| 254 | OP_DIV_LONG_2ADDR = 0xbe, |
| 255 | OP_REM_LONG_2ADDR = 0xbf, |
| 256 | OP_AND_LONG_2ADDR = 0xc0, |
| 257 | OP_OR_LONG_2ADDR = 0xc1, |
| 258 | OP_XOR_LONG_2ADDR = 0xc2, |
| 259 | OP_SHL_LONG_2ADDR = 0xc3, |
| 260 | OP_SHR_LONG_2ADDR = 0xc4, |
| 261 | OP_USHR_LONG_2ADDR = 0xc5, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 262 | OP_ADD_FLOAT_2ADDR = 0xc6, |
| 263 | OP_SUB_FLOAT_2ADDR = 0xc7, |
| 264 | OP_MUL_FLOAT_2ADDR = 0xc8, |
| 265 | OP_DIV_FLOAT_2ADDR = 0xc9, |
| 266 | OP_REM_FLOAT_2ADDR = 0xca, |
| 267 | OP_ADD_DOUBLE_2ADDR = 0xcb, |
| 268 | OP_SUB_DOUBLE_2ADDR = 0xcc, |
| 269 | OP_MUL_DOUBLE_2ADDR = 0xcd, |
| 270 | OP_DIV_DOUBLE_2ADDR = 0xce, |
| 271 | OP_REM_DOUBLE_2ADDR = 0xcf, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 272 | OP_ADD_INT_LIT16 = 0xd0, |
Dan Bornstein | 11a4a79 | 2010-11-16 13:09:45 -0800 | [diff] [blame] | 273 | OP_RSUB_INT = 0xd1, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 274 | OP_MUL_INT_LIT16 = 0xd2, |
| 275 | OP_DIV_INT_LIT16 = 0xd3, |
| 276 | OP_REM_INT_LIT16 = 0xd4, |
| 277 | OP_AND_INT_LIT16 = 0xd5, |
| 278 | OP_OR_INT_LIT16 = 0xd6, |
| 279 | OP_XOR_INT_LIT16 = 0xd7, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 280 | OP_ADD_INT_LIT8 = 0xd8, |
| 281 | OP_RSUB_INT_LIT8 = 0xd9, |
| 282 | OP_MUL_INT_LIT8 = 0xda, |
| 283 | OP_DIV_INT_LIT8 = 0xdb, |
| 284 | OP_REM_INT_LIT8 = 0xdc, |
| 285 | OP_AND_INT_LIT8 = 0xdd, |
| 286 | OP_OR_INT_LIT8 = 0xde, |
| 287 | OP_XOR_INT_LIT8 = 0xdf, |
| 288 | OP_SHL_INT_LIT8 = 0xe0, |
| 289 | OP_SHR_INT_LIT8 = 0xe1, |
| 290 | OP_USHR_INT_LIT8 = 0xe2, |
Andy McFadden | c35a2ef | 2010-06-17 12:36:00 -0700 | [diff] [blame] | 291 | OP_IGET_VOLATILE = 0xe3, |
| 292 | OP_IPUT_VOLATILE = 0xe4, |
| 293 | OP_SGET_VOLATILE = 0xe5, |
| 294 | OP_SPUT_VOLATILE = 0xe6, |
| 295 | OP_IGET_OBJECT_VOLATILE = 0xe7, |
Andy McFadden | 5387824 | 2010-03-05 07:24:27 -0800 | [diff] [blame] | 296 | OP_IGET_WIDE_VOLATILE = 0xe8, |
| 297 | OP_IPUT_WIDE_VOLATILE = 0xe9, |
| 298 | OP_SGET_WIDE_VOLATILE = 0xea, |
| 299 | OP_SPUT_WIDE_VOLATILE = 0xeb, |
Andy McFadden | 9651693 | 2009-10-28 17:39:02 -0700 | [diff] [blame] | 300 | OP_BREAKPOINT = 0xec, |
Andy McFadden | 3a1aedb | 2009-05-07 13:30:23 -0700 | [diff] [blame] | 301 | OP_THROW_VERIFICATION_ERROR = 0xed, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 302 | OP_EXECUTE_INLINE = 0xee, |
Andy McFadden | b0a0541 | 2009-11-19 10:23:41 -0800 | [diff] [blame] | 303 | OP_EXECUTE_INLINE_RANGE = 0xef, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 304 | OP_INVOKE_DIRECT_EMPTY = 0xf0, |
Andy McFadden | 291758c | 2010-09-10 08:04:52 -0700 | [diff] [blame] | 305 | OP_RETURN_VOID_BARRIER = 0xf1, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 306 | OP_IGET_QUICK = 0xf2, |
| 307 | OP_IGET_WIDE_QUICK = 0xf3, |
| 308 | OP_IGET_OBJECT_QUICK = 0xf4, |
| 309 | OP_IPUT_QUICK = 0xf5, |
| 310 | OP_IPUT_WIDE_QUICK = 0xf6, |
| 311 | OP_IPUT_OBJECT_QUICK = 0xf7, |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 312 | OP_INVOKE_VIRTUAL_QUICK = 0xf8, |
| 313 | OP_INVOKE_VIRTUAL_QUICK_RANGE = 0xf9, |
| 314 | OP_INVOKE_SUPER_QUICK = 0xfa, |
| 315 | OP_INVOKE_SUPER_QUICK_RANGE = 0xfb, |
Andy McFadden | c35a2ef | 2010-06-17 12:36:00 -0700 | [diff] [blame] | 316 | OP_IPUT_OBJECT_VOLATILE = 0xfc, |
| 317 | OP_SGET_OBJECT_VOLATILE = 0xfd, |
| 318 | OP_SPUT_OBJECT_VOLATILE = 0xfe, |
Dan Bornstein | 11a4a79 | 2010-11-16 13:09:45 -0800 | [diff] [blame] | 319 | OP_UNUSED_FF = 0xff, |
| 320 | // END(libdex-opcode-enum) |
Dan Bornstein | 9a1f816 | 2010-12-01 17:02:26 -0800 | [diff] [blame] | 321 | } Opcode; |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 322 | |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 323 | /* |
Dan Bornstein | 11a4a79 | 2010-11-16 13:09:45 -0800 | [diff] [blame] | 324 | * Macro used to generate a computed goto table for use in implementing |
| 325 | * an interpreter in C. |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 326 | */ |
| 327 | #define DEFINE_GOTO_TABLE(_name) \ |
Dan Bornstein | 11a4a79 | 2010-11-16 13:09:45 -0800 | [diff] [blame] | 328 | static const void* _name[kNumDalvikInstructions] = { \ |
| 329 | /* BEGIN(libdex-goto-table); GENERATED AUTOMATICALLY BY opcode-gen */ \ |
| 330 | H(OP_NOP), \ |
| 331 | H(OP_MOVE), \ |
| 332 | H(OP_MOVE_FROM16), \ |
| 333 | H(OP_MOVE_16), \ |
| 334 | H(OP_MOVE_WIDE), \ |
| 335 | H(OP_MOVE_WIDE_FROM16), \ |
| 336 | H(OP_MOVE_WIDE_16), \ |
| 337 | H(OP_MOVE_OBJECT), \ |
| 338 | H(OP_MOVE_OBJECT_FROM16), \ |
| 339 | H(OP_MOVE_OBJECT_16), \ |
| 340 | H(OP_MOVE_RESULT), \ |
| 341 | H(OP_MOVE_RESULT_WIDE), \ |
| 342 | H(OP_MOVE_RESULT_OBJECT), \ |
| 343 | H(OP_MOVE_EXCEPTION), \ |
| 344 | H(OP_RETURN_VOID), \ |
| 345 | H(OP_RETURN), \ |
| 346 | H(OP_RETURN_WIDE), \ |
| 347 | H(OP_RETURN_OBJECT), \ |
| 348 | H(OP_CONST_4), \ |
| 349 | H(OP_CONST_16), \ |
| 350 | H(OP_CONST), \ |
| 351 | H(OP_CONST_HIGH16), \ |
| 352 | H(OP_CONST_WIDE_16), \ |
| 353 | H(OP_CONST_WIDE_32), \ |
| 354 | H(OP_CONST_WIDE), \ |
| 355 | H(OP_CONST_WIDE_HIGH16), \ |
| 356 | H(OP_CONST_STRING), \ |
| 357 | H(OP_CONST_STRING_JUMBO), \ |
| 358 | H(OP_CONST_CLASS), \ |
| 359 | H(OP_MONITOR_ENTER), \ |
| 360 | H(OP_MONITOR_EXIT), \ |
| 361 | H(OP_CHECK_CAST), \ |
| 362 | H(OP_INSTANCE_OF), \ |
| 363 | H(OP_ARRAY_LENGTH), \ |
| 364 | H(OP_NEW_INSTANCE), \ |
| 365 | H(OP_NEW_ARRAY), \ |
| 366 | H(OP_FILLED_NEW_ARRAY), \ |
| 367 | H(OP_FILLED_NEW_ARRAY_RANGE), \ |
| 368 | H(OP_FILL_ARRAY_DATA), \ |
| 369 | H(OP_THROW), \ |
| 370 | H(OP_GOTO), \ |
| 371 | H(OP_GOTO_16), \ |
| 372 | H(OP_GOTO_32), \ |
| 373 | H(OP_PACKED_SWITCH), \ |
| 374 | H(OP_SPARSE_SWITCH), \ |
| 375 | H(OP_CMPL_FLOAT), \ |
| 376 | H(OP_CMPG_FLOAT), \ |
| 377 | H(OP_CMPL_DOUBLE), \ |
| 378 | H(OP_CMPG_DOUBLE), \ |
| 379 | H(OP_CMP_LONG), \ |
| 380 | H(OP_IF_EQ), \ |
| 381 | H(OP_IF_NE), \ |
| 382 | H(OP_IF_LT), \ |
| 383 | H(OP_IF_GE), \ |
| 384 | H(OP_IF_GT), \ |
| 385 | H(OP_IF_LE), \ |
| 386 | H(OP_IF_EQZ), \ |
| 387 | H(OP_IF_NEZ), \ |
| 388 | H(OP_IF_LTZ), \ |
| 389 | H(OP_IF_GEZ), \ |
| 390 | H(OP_IF_GTZ), \ |
| 391 | H(OP_IF_LEZ), \ |
| 392 | H(OP_UNUSED_3E), \ |
| 393 | H(OP_UNUSED_3F), \ |
| 394 | H(OP_UNUSED_40), \ |
| 395 | H(OP_UNUSED_41), \ |
| 396 | H(OP_UNUSED_42), \ |
| 397 | H(OP_UNUSED_43), \ |
| 398 | H(OP_AGET), \ |
| 399 | H(OP_AGET_WIDE), \ |
| 400 | H(OP_AGET_OBJECT), \ |
| 401 | H(OP_AGET_BOOLEAN), \ |
| 402 | H(OP_AGET_BYTE), \ |
| 403 | H(OP_AGET_CHAR), \ |
| 404 | H(OP_AGET_SHORT), \ |
| 405 | H(OP_APUT), \ |
| 406 | H(OP_APUT_WIDE), \ |
| 407 | H(OP_APUT_OBJECT), \ |
| 408 | H(OP_APUT_BOOLEAN), \ |
| 409 | H(OP_APUT_BYTE), \ |
| 410 | H(OP_APUT_CHAR), \ |
| 411 | H(OP_APUT_SHORT), \ |
| 412 | H(OP_IGET), \ |
| 413 | H(OP_IGET_WIDE), \ |
| 414 | H(OP_IGET_OBJECT), \ |
| 415 | H(OP_IGET_BOOLEAN), \ |
| 416 | H(OP_IGET_BYTE), \ |
| 417 | H(OP_IGET_CHAR), \ |
| 418 | H(OP_IGET_SHORT), \ |
| 419 | H(OP_IPUT), \ |
| 420 | H(OP_IPUT_WIDE), \ |
| 421 | H(OP_IPUT_OBJECT), \ |
| 422 | H(OP_IPUT_BOOLEAN), \ |
| 423 | H(OP_IPUT_BYTE), \ |
| 424 | H(OP_IPUT_CHAR), \ |
| 425 | H(OP_IPUT_SHORT), \ |
| 426 | H(OP_SGET), \ |
| 427 | H(OP_SGET_WIDE), \ |
| 428 | H(OP_SGET_OBJECT), \ |
| 429 | H(OP_SGET_BOOLEAN), \ |
| 430 | H(OP_SGET_BYTE), \ |
| 431 | H(OP_SGET_CHAR), \ |
| 432 | H(OP_SGET_SHORT), \ |
| 433 | H(OP_SPUT), \ |
| 434 | H(OP_SPUT_WIDE), \ |
| 435 | H(OP_SPUT_OBJECT), \ |
| 436 | H(OP_SPUT_BOOLEAN), \ |
| 437 | H(OP_SPUT_BYTE), \ |
| 438 | H(OP_SPUT_CHAR), \ |
| 439 | H(OP_SPUT_SHORT), \ |
| 440 | H(OP_INVOKE_VIRTUAL), \ |
| 441 | H(OP_INVOKE_SUPER), \ |
| 442 | H(OP_INVOKE_DIRECT), \ |
| 443 | H(OP_INVOKE_STATIC), \ |
| 444 | H(OP_INVOKE_INTERFACE), \ |
| 445 | H(OP_UNUSED_73), \ |
| 446 | H(OP_INVOKE_VIRTUAL_RANGE), \ |
| 447 | H(OP_INVOKE_SUPER_RANGE), \ |
| 448 | H(OP_INVOKE_DIRECT_RANGE), \ |
| 449 | H(OP_INVOKE_STATIC_RANGE), \ |
| 450 | H(OP_INVOKE_INTERFACE_RANGE), \ |
| 451 | H(OP_UNUSED_79), \ |
| 452 | H(OP_UNUSED_7A), \ |
| 453 | H(OP_NEG_INT), \ |
| 454 | H(OP_NOT_INT), \ |
| 455 | H(OP_NEG_LONG), \ |
| 456 | H(OP_NOT_LONG), \ |
| 457 | H(OP_NEG_FLOAT), \ |
| 458 | H(OP_NEG_DOUBLE), \ |
| 459 | H(OP_INT_TO_LONG), \ |
| 460 | H(OP_INT_TO_FLOAT), \ |
| 461 | H(OP_INT_TO_DOUBLE), \ |
| 462 | H(OP_LONG_TO_INT), \ |
| 463 | H(OP_LONG_TO_FLOAT), \ |
| 464 | H(OP_LONG_TO_DOUBLE), \ |
| 465 | H(OP_FLOAT_TO_INT), \ |
| 466 | H(OP_FLOAT_TO_LONG), \ |
| 467 | H(OP_FLOAT_TO_DOUBLE), \ |
| 468 | H(OP_DOUBLE_TO_INT), \ |
| 469 | H(OP_DOUBLE_TO_LONG), \ |
| 470 | H(OP_DOUBLE_TO_FLOAT), \ |
| 471 | H(OP_INT_TO_BYTE), \ |
| 472 | H(OP_INT_TO_CHAR), \ |
| 473 | H(OP_INT_TO_SHORT), \ |
| 474 | H(OP_ADD_INT), \ |
| 475 | H(OP_SUB_INT), \ |
| 476 | H(OP_MUL_INT), \ |
| 477 | H(OP_DIV_INT), \ |
| 478 | H(OP_REM_INT), \ |
| 479 | H(OP_AND_INT), \ |
| 480 | H(OP_OR_INT), \ |
| 481 | H(OP_XOR_INT), \ |
| 482 | H(OP_SHL_INT), \ |
| 483 | H(OP_SHR_INT), \ |
| 484 | H(OP_USHR_INT), \ |
| 485 | H(OP_ADD_LONG), \ |
| 486 | H(OP_SUB_LONG), \ |
| 487 | H(OP_MUL_LONG), \ |
| 488 | H(OP_DIV_LONG), \ |
| 489 | H(OP_REM_LONG), \ |
| 490 | H(OP_AND_LONG), \ |
| 491 | H(OP_OR_LONG), \ |
| 492 | H(OP_XOR_LONG), \ |
| 493 | H(OP_SHL_LONG), \ |
| 494 | H(OP_SHR_LONG), \ |
| 495 | H(OP_USHR_LONG), \ |
| 496 | H(OP_ADD_FLOAT), \ |
| 497 | H(OP_SUB_FLOAT), \ |
| 498 | H(OP_MUL_FLOAT), \ |
| 499 | H(OP_DIV_FLOAT), \ |
| 500 | H(OP_REM_FLOAT), \ |
| 501 | H(OP_ADD_DOUBLE), \ |
| 502 | H(OP_SUB_DOUBLE), \ |
| 503 | H(OP_MUL_DOUBLE), \ |
| 504 | H(OP_DIV_DOUBLE), \ |
| 505 | H(OP_REM_DOUBLE), \ |
| 506 | H(OP_ADD_INT_2ADDR), \ |
| 507 | H(OP_SUB_INT_2ADDR), \ |
| 508 | H(OP_MUL_INT_2ADDR), \ |
| 509 | H(OP_DIV_INT_2ADDR), \ |
| 510 | H(OP_REM_INT_2ADDR), \ |
| 511 | H(OP_AND_INT_2ADDR), \ |
| 512 | H(OP_OR_INT_2ADDR), \ |
| 513 | H(OP_XOR_INT_2ADDR), \ |
| 514 | H(OP_SHL_INT_2ADDR), \ |
| 515 | H(OP_SHR_INT_2ADDR), \ |
| 516 | H(OP_USHR_INT_2ADDR), \ |
| 517 | H(OP_ADD_LONG_2ADDR), \ |
| 518 | H(OP_SUB_LONG_2ADDR), \ |
| 519 | H(OP_MUL_LONG_2ADDR), \ |
| 520 | H(OP_DIV_LONG_2ADDR), \ |
| 521 | H(OP_REM_LONG_2ADDR), \ |
| 522 | H(OP_AND_LONG_2ADDR), \ |
| 523 | H(OP_OR_LONG_2ADDR), \ |
| 524 | H(OP_XOR_LONG_2ADDR), \ |
| 525 | H(OP_SHL_LONG_2ADDR), \ |
| 526 | H(OP_SHR_LONG_2ADDR), \ |
| 527 | H(OP_USHR_LONG_2ADDR), \ |
| 528 | H(OP_ADD_FLOAT_2ADDR), \ |
| 529 | H(OP_SUB_FLOAT_2ADDR), \ |
| 530 | H(OP_MUL_FLOAT_2ADDR), \ |
| 531 | H(OP_DIV_FLOAT_2ADDR), \ |
| 532 | H(OP_REM_FLOAT_2ADDR), \ |
| 533 | H(OP_ADD_DOUBLE_2ADDR), \ |
| 534 | H(OP_SUB_DOUBLE_2ADDR), \ |
| 535 | H(OP_MUL_DOUBLE_2ADDR), \ |
| 536 | H(OP_DIV_DOUBLE_2ADDR), \ |
| 537 | H(OP_REM_DOUBLE_2ADDR), \ |
| 538 | H(OP_ADD_INT_LIT16), \ |
| 539 | H(OP_RSUB_INT), \ |
| 540 | H(OP_MUL_INT_LIT16), \ |
| 541 | H(OP_DIV_INT_LIT16), \ |
| 542 | H(OP_REM_INT_LIT16), \ |
| 543 | H(OP_AND_INT_LIT16), \ |
| 544 | H(OP_OR_INT_LIT16), \ |
| 545 | H(OP_XOR_INT_LIT16), \ |
| 546 | H(OP_ADD_INT_LIT8), \ |
| 547 | H(OP_RSUB_INT_LIT8), \ |
| 548 | H(OP_MUL_INT_LIT8), \ |
| 549 | H(OP_DIV_INT_LIT8), \ |
| 550 | H(OP_REM_INT_LIT8), \ |
| 551 | H(OP_AND_INT_LIT8), \ |
| 552 | H(OP_OR_INT_LIT8), \ |
| 553 | H(OP_XOR_INT_LIT8), \ |
| 554 | H(OP_SHL_INT_LIT8), \ |
| 555 | H(OP_SHR_INT_LIT8), \ |
| 556 | H(OP_USHR_INT_LIT8), \ |
| 557 | H(OP_IGET_VOLATILE), \ |
| 558 | H(OP_IPUT_VOLATILE), \ |
| 559 | H(OP_SGET_VOLATILE), \ |
| 560 | H(OP_SPUT_VOLATILE), \ |
| 561 | H(OP_IGET_OBJECT_VOLATILE), \ |
| 562 | H(OP_IGET_WIDE_VOLATILE), \ |
| 563 | H(OP_IPUT_WIDE_VOLATILE), \ |
| 564 | H(OP_SGET_WIDE_VOLATILE), \ |
| 565 | H(OP_SPUT_WIDE_VOLATILE), \ |
| 566 | H(OP_BREAKPOINT), \ |
| 567 | H(OP_THROW_VERIFICATION_ERROR), \ |
| 568 | H(OP_EXECUTE_INLINE), \ |
| 569 | H(OP_EXECUTE_INLINE_RANGE), \ |
| 570 | H(OP_INVOKE_DIRECT_EMPTY), \ |
| 571 | H(OP_RETURN_VOID_BARRIER), \ |
| 572 | H(OP_IGET_QUICK), \ |
| 573 | H(OP_IGET_WIDE_QUICK), \ |
| 574 | H(OP_IGET_OBJECT_QUICK), \ |
| 575 | H(OP_IPUT_QUICK), \ |
| 576 | H(OP_IPUT_WIDE_QUICK), \ |
| 577 | H(OP_IPUT_OBJECT_QUICK), \ |
| 578 | H(OP_INVOKE_VIRTUAL_QUICK), \ |
| 579 | H(OP_INVOKE_VIRTUAL_QUICK_RANGE), \ |
| 580 | H(OP_INVOKE_SUPER_QUICK), \ |
| 581 | H(OP_INVOKE_SUPER_QUICK_RANGE), \ |
| 582 | H(OP_IPUT_OBJECT_VOLATILE), \ |
| 583 | H(OP_SGET_OBJECT_VOLATILE), \ |
| 584 | H(OP_SPUT_OBJECT_VOLATILE), \ |
| 585 | H(OP_UNUSED_FF), \ |
| 586 | /* END(libdex-goto-table) */ \ |
The Android Open Source Project | f6c3871 | 2009-03-03 19:28:47 -0800 | [diff] [blame] | 587 | }; |
| 588 | |
Dan Bornstein | 1112216 | 2010-12-01 12:30:21 -0800 | [diff] [blame] | 589 | /* |
Dan Bornstein | 9a1f816 | 2010-12-01 17:02:26 -0800 | [diff] [blame] | 590 | * Return the Opcode for a given raw opcode code unit (which may |
Dan Bornstein | 1112216 | 2010-12-01 12:30:21 -0800 | [diff] [blame] | 591 | * include data payload). The packed index is a zero-based index which |
| 592 | * can be used to point into various opcode-related tables. The Dalvik |
| 593 | * opcode space is inherently sparse, in that the opcode unit is 16 |
| 594 | * bits wide, but for most opcodes, eight of those bits are for data. |
| 595 | */ |
Dan Bornstein | 9a1f816 | 2010-12-01 17:02:26 -0800 | [diff] [blame] | 596 | DEX_INLINE Opcode dexOpcodeFromCodeUnit(u2 codeUnit) { |
Dan Bornstein | 1112216 | 2010-12-01 12:30:21 -0800 | [diff] [blame] | 597 | /* |
| 598 | * This will want to become table-driven should the opcode layout |
| 599 | * get more complicated. |
| 600 | * |
| 601 | * Note: This has to match the corresponding code in opcode-gen, so |
| 602 | * that data tables get generated in a consistent way. |
| 603 | */ |
| 604 | int lowByte = codeUnit & 0xff; |
| 605 | if (lowByte != 0xff) { |
Dan Bornstein | 9a1f816 | 2010-12-01 17:02:26 -0800 | [diff] [blame] | 606 | return (Opcode) lowByte; |
Dan Bornstein | 1112216 | 2010-12-01 12:30:21 -0800 | [diff] [blame] | 607 | } else { |
Dan Bornstein | 9a1f816 | 2010-12-01 17:02:26 -0800 | [diff] [blame] | 608 | return (Opcode) ((codeUnit >> 8) | 0x100); |
Dan Bornstein | 1112216 | 2010-12-01 12:30:21 -0800 | [diff] [blame] | 609 | } |
| 610 | } |
| 611 | |
Dan Bornstein | df4daaf | 2010-12-01 14:23:44 -0800 | [diff] [blame] | 612 | /* |
| 613 | * Return the name of an opcode. |
| 614 | */ |
Dan Bornstein | 9a1f816 | 2010-12-01 17:02:26 -0800 | [diff] [blame] | 615 | const char* dexGetOpcodeName(Opcode op); |
Dan Bornstein | df4daaf | 2010-12-01 14:23:44 -0800 | [diff] [blame] | 616 | |
| 617 | #endif /*_LIBDEX_DEXOPCODES*/ |