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