bytecode.txt revision 0759f52f2dd8497cc489b889a25e91d48ea10751
1# Copyright (C) 2007 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15#
16# Bytecode definition file
17#
18
19# One line per instruction format family. Each line consists of a
20# series of instruction formats that all take (potentially) compatible
21# arguments. The order is the preferred order (most to least
22# preferable) of formats, when more than one opcode could be used for
23# a given instruction's arguments.
24#
25# Note: The family that starts with 12x has a mix of both two- and
26# three- register formats. This is because some of the two-register
27# opcodes effectively take three, with a destination and two sources
28# where the destination and one of the sources have to be the same.
29
30# Regular formats
31format 10t 20t 30t
32format 10x
33format 11n 21s 21h 31i 51l
34format 11x
35format 12x 22x 23x 32x 33x  # See note, above.
36format 21c 31c 41c
37format 21t 31t
38format 22b 22s 32s
39format 22c 52c
40format 22t
41format 35c 3rc 5rc
42
43# Optimized formats
44format 00x  # not in spec; used for undefined opcodes and breakpoint
45format 20bc # not in spec; used for throw-verification-error
46format 22cs
47format 35mi
48format 35ms
49format 3rmi
50format 3rms
51
52# One line per opcode. Columns are:
53#   hex for opcode
54#   opcode name
55#   format
56#   has result register; one of:
57#     y
58#     n
59#   index type; one of:
60#     unknown -- used for undefined opcodes and breakpoint
61#     none
62#     varies
63#     type-ref
64#     string-ref
65#     method-ref
66#     field-ref
67#     inline-method
68#     vtable-offset
69#     field-offset
70#   flags; pipe-combined combo of one or more of:
71#     optimized     -- optimized; not to be included in unoptimized dex files
72#     branch        -- might branch to an address
73#     continue      -- might continue to the next address in sequence
74#     switch        -- is a switch
75#     throw         -- might throw an exception
76#     return        -- is a return from method
77#     invoke        -- is a method invoke; this is only used for true
78#                      method invokes and notably *not* vm-implemented
79#                      execute-inline nor the nop-equivalent
80#                      invoke-direct-empty
81
82# Regular opcodes (with a couple holes)
83op   00 nop                         10x  n none          continue
84op   01 move                        12x  y none          continue
85op   02 move/from16                 22x  y none          continue
86op   03 move/16                     32x  y none          continue
87op   04 move-wide                   12x  y none          continue
88op   05 move-wide/from16            22x  y none          continue
89op   06 move-wide/16                32x  y none          continue
90op   07 move-object                 12x  y none          continue
91op   08 move-object/from16          22x  y none          continue
92op   09 move-object/16              32x  y none          continue
93op   0a move-result                 11x  y none          continue
94op   0b move-result-wide            11x  y none          continue
95op   0c move-result-object          11x  y none          continue
96op   0d move-exception              11x  y none          continue
97op   0e return-void                 10x  n none          return
98op   0f return                      11x  n none          return
99op   10 return-wide                 11x  n none          return
100op   11 return-object               11x  n none          return
101op   12 const/4                     11n  y none          continue
102op   13 const/16                    21s  y none          continue
103op   14 const                       31i  y none          continue
104op   15 const/high16                21h  y none          continue
105op   16 const-wide/16               21s  y none          continue
106op   17 const-wide/32               31i  y none          continue
107op   18 const-wide                  51l  y none          continue
108op   19 const-wide/high16           21h  y none          continue
109op   1a const-string                21c  y string-ref    continue|throw
110op   1b const-string/jumbo          31c  y string-ref    continue|throw
111op   1c const-class                 21c  y type-ref      continue|throw
112op   1d monitor-enter               11x  n none          continue|throw
113op   1e monitor-exit                11x  n none          continue|throw
114op   1f check-cast                  21c  y type-ref      continue|throw
115op   20 instance-of                 22c  y type-ref      continue|throw
116op   21 array-length                12x  y none          continue|throw
117op   22 new-instance                21c  y type-ref      continue|throw
118op   23 new-array                   22c  y type-ref      continue|throw
119op   24 filled-new-array            35c  n type-ref      continue|throw
120op   25 filled-new-array/range      3rc  n type-ref      continue|throw
121op   26 fill-array-data             31t  n none          continue
122op   27 throw                       11x  n none          throw
123op   28 goto                        10t  n none          branch
124op   29 goto/16                     20t  n none          branch
125op   2a goto/32                     30t  n none          branch
126op   2b packed-switch               31t  n none          continue|switch
127op   2c sparse-switch               31t  n none          continue|switch
128op   2d cmpl-float                  23x  y none          continue
129op   2e cmpg-float                  23x  y none          continue
130op   2f cmpl-double                 23x  y none          continue
131op   30 cmpg-double                 23x  y none          continue
132op   31 cmp-long                    23x  y none          continue
133op   32 if-eq                       22t  n none          continue|branch
134op   33 if-ne                       22t  n none          continue|branch
135op   34 if-lt                       22t  n none          continue|branch
136op   35 if-ge                       22t  n none          continue|branch
137op   36 if-gt                       22t  n none          continue|branch
138op   37 if-le                       22t  n none          continue|branch
139op   38 if-eqz                      21t  n none          continue|branch
140op   39 if-nez                      21t  n none          continue|branch
141op   3a if-ltz                      21t  n none          continue|branch
142op   3b if-gez                      21t  n none          continue|branch
143op   3c if-gtz                      21t  n none          continue|branch
144op   3d if-lez                      21t  n none          continue|branch
145# unused: op 3e..43
146op   44 aget                        23x  y none          continue|throw
147op   45 aget-wide                   23x  y none          continue|throw
148op   46 aget-object                 23x  y none          continue|throw
149op   47 aget-boolean                23x  y none          continue|throw
150op   48 aget-byte                   23x  y none          continue|throw
151op   49 aget-char                   23x  y none          continue|throw
152op   4a aget-short                  23x  y none          continue|throw
153op   4b aput                        23x  n none          continue|throw
154op   4c aput-wide                   23x  n none          continue|throw
155op   4d aput-object                 23x  n none          continue|throw
156op   4e aput-boolean                23x  n none          continue|throw
157op   4f aput-byte                   23x  n none          continue|throw
158op   50 aput-char                   23x  n none          continue|throw
159op   51 aput-short                  23x  n none          continue|throw
160op   52 iget                        22c  y field-ref     continue|throw
161op   53 iget-wide                   22c  y field-ref     continue|throw
162op   54 iget-object                 22c  y field-ref     continue|throw
163op   55 iget-boolean                22c  y field-ref     continue|throw
164op   56 iget-byte                   22c  y field-ref     continue|throw
165op   57 iget-char                   22c  y field-ref     continue|throw
166op   58 iget-short                  22c  y field-ref     continue|throw
167op   59 iput                        22c  n field-ref     continue|throw
168op   5a iput-wide                   22c  n field-ref     continue|throw
169op   5b iput-object                 22c  n field-ref     continue|throw
170op   5c iput-boolean                22c  n field-ref     continue|throw
171op   5d iput-byte                   22c  n field-ref     continue|throw
172op   5e iput-char                   22c  n field-ref     continue|throw
173op   5f iput-short                  22c  n field-ref     continue|throw
174op   60 sget                        21c  y field-ref     continue|throw
175op   61 sget-wide                   21c  y field-ref     continue|throw
176op   62 sget-object                 21c  y field-ref     continue|throw
177op   63 sget-boolean                21c  y field-ref     continue|throw
178op   64 sget-byte                   21c  y field-ref     continue|throw
179op   65 sget-char                   21c  y field-ref     continue|throw
180op   66 sget-short                  21c  y field-ref     continue|throw
181op   67 sput                        21c  n field-ref     continue|throw
182op   68 sput-wide                   21c  n field-ref     continue|throw
183op   69 sput-object                 21c  n field-ref     continue|throw
184op   6a sput-boolean                21c  n field-ref     continue|throw
185op   6b sput-byte                   21c  n field-ref     continue|throw
186op   6c sput-char                   21c  n field-ref     continue|throw
187op   6d sput-short                  21c  n field-ref     continue|throw
188op   6e invoke-virtual              35c  n method-ref    continue|throw|invoke
189op   6f invoke-super                35c  n method-ref    continue|throw|invoke
190op   70 invoke-direct               35c  n method-ref    continue|throw|invoke
191op   71 invoke-static               35c  n method-ref    continue|throw|invoke
192op   72 invoke-interface            35c  n method-ref    continue|throw|invoke
193# unused: op 73
194op   74 invoke-virtual/range        3rc  n method-ref    continue|throw|invoke
195op   75 invoke-super/range          3rc  n method-ref    continue|throw|invoke
196op   76 invoke-direct/range         3rc  n method-ref    continue|throw|invoke
197op   77 invoke-static/range         3rc  n method-ref    continue|throw|invoke
198op   78 invoke-interface/range      3rc  n method-ref    continue|throw|invoke
199# unused: op 79..7a
200op   7b neg-int                     12x  y none          continue
201op   7c not-int                     12x  y none          continue
202op   7d neg-long                    12x  y none          continue
203op   7e not-long                    12x  y none          continue
204op   7f neg-float                   12x  y none          continue
205op   80 neg-double                  12x  y none          continue
206op   81 int-to-long                 12x  y none          continue
207op   82 int-to-float                12x  y none          continue
208op   83 int-to-double               12x  y none          continue
209op   84 long-to-int                 12x  y none          continue
210op   85 long-to-float               12x  y none          continue
211op   86 long-to-double              12x  y none          continue
212op   87 float-to-int                12x  y none          continue
213op   88 float-to-long               12x  y none          continue
214op   89 float-to-double             12x  y none          continue
215op   8a double-to-int               12x  y none          continue
216op   8b double-to-long              12x  y none          continue
217op   8c double-to-float             12x  y none          continue
218op   8d int-to-byte                 12x  y none          continue
219op   8e int-to-char                 12x  y none          continue
220op   8f int-to-short                12x  y none          continue
221op   90 add-int                     23x  y none          continue
222op   91 sub-int                     23x  y none          continue
223op   92 mul-int                     23x  y none          continue
224op   93 div-int                     23x  y none          continue|throw
225op   94 rem-int                     23x  y none          continue|throw
226op   95 and-int                     23x  y none          continue
227op   96 or-int                      23x  y none          continue
228op   97 xor-int                     23x  y none          continue
229op   98 shl-int                     23x  y none          continue
230op   99 shr-int                     23x  y none          continue
231op   9a ushr-int                    23x  y none          continue
232op   9b add-long                    23x  y none          continue
233op   9c sub-long                    23x  y none          continue
234op   9d mul-long                    23x  y none          continue
235op   9e div-long                    23x  y none          continue|throw
236op   9f rem-long                    23x  y none          continue|throw
237op   a0 and-long                    23x  y none          continue
238op   a1 or-long                     23x  y none          continue
239op   a2 xor-long                    23x  y none          continue
240op   a3 shl-long                    23x  y none          continue
241op   a4 shr-long                    23x  y none          continue
242op   a5 ushr-long                   23x  y none          continue
243op   a6 add-float                   23x  y none          continue
244op   a7 sub-float                   23x  y none          continue
245op   a8 mul-float                   23x  y none          continue
246op   a9 div-float                   23x  y none          continue
247op   aa rem-float                   23x  y none          continue
248op   ab add-double                  23x  y none          continue
249op   ac sub-double                  23x  y none          continue
250op   ad mul-double                  23x  y none          continue
251op   ae div-double                  23x  y none          continue
252op   af rem-double                  23x  y none          continue
253op   b0 add-int/2addr               12x  y none          continue
254op   b1 sub-int/2addr               12x  y none          continue
255op   b2 mul-int/2addr               12x  y none          continue
256op   b3 div-int/2addr               12x  y none          continue|throw
257op   b4 rem-int/2addr               12x  y none          continue|throw
258op   b5 and-int/2addr               12x  y none          continue
259op   b6 or-int/2addr                12x  y none          continue
260op   b7 xor-int/2addr               12x  y none          continue
261op   b8 shl-int/2addr               12x  y none          continue
262op   b9 shr-int/2addr               12x  y none          continue
263op   ba ushr-int/2addr              12x  y none          continue
264op   bb add-long/2addr              12x  y none          continue
265op   bc sub-long/2addr              12x  y none          continue
266op   bd mul-long/2addr              12x  y none          continue
267op   be div-long/2addr              12x  y none          continue|throw
268op   bf rem-long/2addr              12x  y none          continue|throw
269op   c0 and-long/2addr              12x  y none          continue
270op   c1 or-long/2addr               12x  y none          continue
271op   c2 xor-long/2addr              12x  y none          continue
272op   c3 shl-long/2addr              12x  y none          continue
273op   c4 shr-long/2addr              12x  y none          continue
274op   c5 ushr-long/2addr             12x  y none          continue
275op   c6 add-float/2addr             12x  y none          continue
276op   c7 sub-float/2addr             12x  y none          continue
277op   c8 mul-float/2addr             12x  y none          continue
278op   c9 div-float/2addr             12x  y none          continue
279op   ca rem-float/2addr             12x  y none          continue
280op   cb add-double/2addr            12x  y none          continue
281op   cc sub-double/2addr            12x  y none          continue
282op   cd mul-double/2addr            12x  y none          continue
283op   ce div-double/2addr            12x  y none          continue
284op   cf rem-double/2addr            12x  y none          continue
285op   d0 add-int/lit16               22s  y none          continue
286op   d1 rsub-int                    22s  y none          continue
287op   d2 mul-int/lit16               22s  y none          continue
288op   d3 div-int/lit16               22s  y none          continue|throw
289op   d4 rem-int/lit16               22s  y none          continue|throw
290op   d5 and-int/lit16               22s  y none          continue
291op   d6 or-int/lit16                22s  y none          continue
292op   d7 xor-int/lit16               22s  y none          continue
293op   d8 add-int/lit8                22b  y none          continue
294op   d9 rsub-int/lit8               22b  y none          continue
295op   da mul-int/lit8                22b  y none          continue
296op   db div-int/lit8                22b  y none          continue|throw
297op   dc rem-int/lit8                22b  y none          continue|throw
298op   dd and-int/lit8                22b  y none          continue
299op   de or-int/lit8                 22b  y none          continue
300op   df xor-int/lit8                22b  y none          continue
301op   e0 shl-int/lit8                22b  y none          continue
302op   e1 shr-int/lit8                22b  y none          continue
303op   e2 ushr-int/lit8               22b  y none          continue
304
305# Optimized opcodes (not valid in an unoptimized dex file)
306#
307# Note: Technically "breakpoint" isn't really an optimized opcode, but
308# it fits the label in terms of not being valid in dex files.
309op   e3 +iget-volatile              22c  y field-ref     optimized|continue|throw
310op   e4 +iput-volatile              22c  n field-ref     optimized|continue|throw
311op   e5 +sget-volatile              21c  y field-ref     optimized|continue|throw
312op   e6 +sput-volatile              21c  n field-ref     optimized|continue|throw
313op   e7 +iget-object-volatile       22c  y field-ref     optimized|continue|throw
314op   e8 +iget-wide-volatile         22c  y field-ref     optimized|continue|throw
315op   e9 +iput-wide-volatile         22c  n field-ref     optimized|continue|throw
316op   ea +sget-wide-volatile         21c  y field-ref     optimized|continue|throw
317op   eb +sput-wide-volatile         21c  n field-ref     optimized|continue|throw
318op   ec ^breakpoint                 00x  n unknown       optimized
319op   ed ^throw-verification-error   20bc n varies        optimized|throw
320op   ee +execute-inline             35mi n inline-method optimized|continue|throw
321op   ef +execute-inline/range       3rmi n inline-method optimized|continue|throw
322op   f0 +invoke-direct-empty        35c  n method-ref    optimized|continue
323op   f1 +return-void-barrier        10x  n none          optimized|return
324op   f2 +iget-quick                 22cs y field-offset  optimized|continue|throw
325op   f3 +iget-wide-quick            22cs y field-offset  optimized|continue|throw
326op   f4 +iget-object-quick          22cs y field-offset  optimized|continue|throw
327op   f5 +iput-quick                 22cs n field-offset  optimized|continue|throw
328op   f6 +iput-wide-quick            22cs n field-offset  optimized|continue|throw
329op   f7 +iput-object-quick          22cs n field-offset  optimized|continue|throw
330op   f8 +invoke-virtual-quick       35ms n vtable-offset optimized|continue|throw|invoke
331op   f9 +invoke-virtual-quick/range 3rms n vtable-offset optimized|continue|throw|invoke
332op   fa +invoke-super-quick         35ms n vtable-offset optimized|continue|throw|invoke
333op   fb +invoke-super-quick/range   3rms n vtable-offset optimized|continue|throw|invoke
334op   fc +iput-object-volatile       22c  n field-ref     optimized|continue|throw
335op   fd +sget-object-volatile       21c  y field-ref     optimized|continue|throw
336op   fe +sput-object-volatile       21c  n field-ref     optimized|continue|throw
337
338# Extended-width opcodes 
339op 00ff const-class/jumbo           41c  y type-ref      continue|throw
340op 01ff check-cast/jumbo            41c  n type-ref      continue|throw
341op 02ff instance-of/jumbo           52c  y type-ref      continue|throw
342op 03ff new-instance/jumbo          41c  y type-ref      continue|throw
343op 04ff new-array/jumbo             52c  y type-ref      continue|throw
344op 05ff filled-new-array/jumbo      5rc  n type-ref      continue|throw
345op 06ff iget/jumbo                  52c  y field-ref     continue|throw
346op 07ff iget-wide/jumbo             52c  y field-ref     continue|throw
347op 08ff iget-object/jumbo           52c  y field-ref     continue|throw
348op 09ff iget-boolean/jumbo          52c  y field-ref     continue|throw
349op 0aff iget-byte/jumbo             52c  y field-ref     continue|throw
350op 0bff iget-char/jumbo             52c  y field-ref     continue|throw
351op 0cff iget-short/jumbo            52c  y field-ref     continue|throw
352op 0dff iput/jumbo                  52c  n field-ref     continue|throw
353op 0eff iput-wide/jumbo             52c  n field-ref     continue|throw
354op 0fff iput-object/jumbo           52c  n field-ref     continue|throw
355op 10ff iput-boolean/jumbo          52c  n field-ref     continue|throw
356op 11ff iput-byte/jumbo             52c  n field-ref     continue|throw
357op 12ff iput-char/jumbo             52c  n field-ref     continue|throw
358op 13ff iput-short/jumbo            52c  n field-ref     continue|throw
359op 14ff sget/jumbo                  41c  y field-ref     continue|throw
360op 15ff sget-wide/jumbo             41c  y field-ref     continue|throw
361op 16ff sget-object/jumbo           41c  y field-ref     continue|throw
362op 17ff sget-boolean/jumbo          41c  y field-ref     continue|throw
363op 18ff sget-byte/jumbo             41c  y field-ref     continue|throw
364op 19ff sget-char/jumbo             41c  y field-ref     continue|throw
365op 1aff sget-short/jumbo            41c  y field-ref     continue|throw
366op 1bff sput/jumbo                  41c  n field-ref     continue|throw
367op 1cff sput-wide/jumbo             41c  n field-ref     continue|throw
368op 1dff sput-object/jumbo           41c  n field-ref     continue|throw
369op 1eff sput-boolean/jumbo          41c  n field-ref     continue|throw
370op 1fff sput-byte/jumbo             41c  n field-ref     continue|throw
371op 20ff sput-char/jumbo             41c  n field-ref     continue|throw
372op 21ff sput-short/jumbo            41c  n field-ref     continue|throw
373op 22ff invoke-virtual/jumbo        5rc  n method-ref    continue|throw|invoke
374op 23ff invoke-super/jumbo          5rc  n method-ref    continue|throw|invoke
375op 24ff invoke-direct/jumbo         5rc  n method-ref    continue|throw|invoke
376op 25ff invoke-static/jumbo         5rc  n method-ref    continue|throw|invoke
377op 26ff invoke-interface/jumbo      5rc  n method-ref    continue|throw|invoke
378# unused: op 27ff..ffff
379