001    /*
002     * Copyright 1999-2005 Sun Microsystems, Inc.  All Rights Reserved.
003     * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004     *
005     * This code is free software; you can redistribute it and/or modify it
006     * under the terms of the GNU General Public License version 2 only, as
007     * published by the Free Software Foundation.  Sun designates this
008     * particular file as subject to the "Classpath" exception as provided
009     * by Sun in the LICENSE file that accompanied this code.
010     *
011     * This code is distributed in the hope that it will be useful, but WITHOUT
012     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014     * version 2 for more details (a copy is included in the LICENSE file that
015     * accompanied this code).
016     *
017     * You should have received a copy of the GNU General Public License version
018     * 2 along with this work; if not, write to the Free Software Foundation,
019     * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020     *
021     * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022     * CA 95054 USA or visit www.sun.com if you need additional information or
023     * have any questions.
024     */
025    
026    package com.sun.tools.javac.jvm;
027    
028    
029    /** Bytecode instruction codes, as well as typecodes used as
030     *  instruction modifiers.
031     *
032     *  <p><b>This is NOT part of any API supported by Sun Microsystems.  If
033     *  you write code that depends on this, you do so at your own risk.
034     *  This code and its internal interfaces are subject to change or
035     *  deletion without notice.</b>
036     */
037    public interface ByteCodes {
038    
039        /** Byte code instruction codes.
040         */
041        int illegal         = -1,
042            nop             = 0,
043            aconst_null     = 1,
044            iconst_m1       = 2,
045            iconst_0        = 3,
046            iconst_1        = 4,
047            iconst_2        = 5,
048            iconst_3        = 6,
049            iconst_4        = 7,
050            iconst_5        = 8,
051            lconst_0        = 9,
052            lconst_1        = 10,
053            fconst_0        = 11,
054            fconst_1        = 12,
055            fconst_2        = 13,
056            dconst_0        = 14,
057            dconst_1        = 15,
058            bipush          = 16,
059            sipush          = 17,
060            ldc1            = 18,
061            ldc2            = 19,
062            ldc2w           = 20,
063            iload           = 21,
064            lload           = 22,
065            fload           = 23,
066            dload           = 24,
067            aload           = 25,
068            iload_0         = 26,
069            iload_1         = 27,
070            iload_2         = 28,
071            iload_3         = 29,
072            lload_0         = 30,
073            lload_1         = 31,
074            lload_2         = 32,
075            lload_3         = 33,
076            fload_0         = 34,
077            fload_1         = 35,
078            fload_2         = 36,
079            fload_3         = 37,
080            dload_0         = 38,
081            dload_1         = 39,
082            dload_2         = 40,
083            dload_3         = 41,
084            aload_0         = 42,
085            aload_1         = 43,
086            aload_2         = 44,
087            aload_3         = 45,
088            iaload          = 46,
089            laload          = 47,
090            faload          = 48,
091            daload          = 49,
092            aaload          = 50,
093            baload          = 51,
094            caload          = 52,
095            saload          = 53,
096            istore          = 54,
097            lstore          = 55,
098            fstore          = 56,
099            dstore          = 57,
100            astore          = 58,
101            istore_0        = 59,
102            istore_1        = 60,
103            istore_2        = 61,
104            istore_3        = 62,
105            lstore_0        = 63,
106            lstore_1        = 64,
107            lstore_2        = 65,
108            lstore_3        = 66,
109            fstore_0        = 67,
110            fstore_1        = 68,
111            fstore_2        = 69,
112            fstore_3        = 70,
113            dstore_0        = 71,
114            dstore_1        = 72,
115            dstore_2        = 73,
116            dstore_3        = 74,
117            astore_0        = 75,
118            astore_1        = 76,
119            astore_2        = 77,
120            astore_3        = 78,
121            iastore         = 79,
122            lastore         = 80,
123            fastore         = 81,
124            dastore         = 82,
125            aastore         = 83,
126            bastore         = 84,
127            castore         = 85,
128            sastore         = 86,
129            pop             = 87,
130            pop2            = 88,
131            dup             = 89,
132            dup_x1          = 90,
133            dup_x2          = 91,
134            dup2            = 92,
135            dup2_x1         = 93,
136            dup2_x2         = 94,
137            swap            = 95,
138            iadd            = 96,
139            ladd            = 97,
140            fadd            = 98,
141            dadd            = 99,
142            isub            = 100,
143            lsub            = 101,
144            fsub            = 102,
145            dsub            = 103,
146            imul            = 104,
147            lmul            = 105,
148            fmul            = 106,
149            dmul            = 107,
150            idiv            = 108,
151            ldiv            = 109,
152            fdiv            = 110,
153            ddiv            = 111,
154            imod            = 112,
155            lmod            = 113,
156            fmod            = 114,
157            dmod            = 115,
158            ineg            = 116,
159            lneg            = 117,
160            fneg            = 118,
161            dneg            = 119,
162            ishl            = 120,
163            lshl            = 121,
164            ishr            = 122,
165            lshr            = 123,
166            iushr           = 124,
167            lushr           = 125,
168            iand            = 126,
169            land            = 127,
170            ior             = 128,
171            lor             = 129,
172            ixor            = 130,
173            lxor            = 131,
174            iinc            = 132,
175            i2l             = 133,
176            i2f             = 134,
177            i2d             = 135,
178            l2i             = 136,
179            l2f             = 137,
180            l2d             = 138,
181            f2i             = 139,
182            f2l             = 140,
183            f2d             = 141,
184            d2i             = 142,
185            d2l             = 143,
186            d2f             = 144,
187            int2byte        = 145,
188            int2char        = 146,
189            int2short       = 147,
190            lcmp            = 148,
191            fcmpl           = 149,
192            fcmpg           = 150,
193            dcmpl           = 151,
194            dcmpg           = 152,
195            ifeq            = 153,
196            ifne            = 154,
197            iflt            = 155,
198            ifge            = 156,
199            ifgt            = 157,
200            ifle            = 158,
201            if_icmpeq       = 159,
202            if_icmpne       = 160,
203            if_icmplt       = 161,
204            if_icmpge       = 162,
205            if_icmpgt       = 163,
206            if_icmple       = 164,
207            if_acmpeq       = 165,
208            if_acmpne       = 166,
209            goto_           = 167,
210            jsr             = 168,
211            ret             = 169,
212            tableswitch     = 170,
213            lookupswitch    = 171,
214            ireturn         = 172,
215            lreturn         = 173,
216            freturn         = 174,
217            dreturn         = 175,
218            areturn         = 176,
219            return_         = 177,
220            getstatic       = 178,
221            putstatic       = 179,
222            getfield        = 180,
223            putfield        = 181,
224            invokevirtual   = 182,
225            invokespecial   = 183,
226            invokestatic    = 184,
227            invokeinterface = 185,
228            // ___unused___ = 186,
229            new_            = 187,
230            newarray        = 188,
231            anewarray       = 189,
232            arraylength     = 190,
233            athrow          = 191,
234            checkcast       = 192,
235            instanceof_     = 193,
236            monitorenter    = 194,
237            monitorexit     = 195,
238            wide            = 196,
239            multianewarray  = 197,
240            if_acmp_null    = 198,
241            if_acmp_nonnull = 199,
242            goto_w          = 200,
243            jsr_w           = 201,
244            breakpoint      = 202,
245            ByteCodeCount   = 203;
246    
247        /** Virtual instruction codes; used for constant folding.
248         */
249        int string_add      = 256,  // string +
250            bool_not        = 257,  // boolean !
251            bool_and        = 258,  // boolean &&
252            bool_or         = 259;  // boolean ||
253    
254        /** Virtual opcodes; used for shifts with long shiftcount
255         */
256        int ishll           = 270,  // int shift left with long count
257            lshll           = 271,  // long shift left with long count
258            ishrl           = 272,  // int shift right with long count
259            lshrl           = 273,  // long shift right with long count
260            iushrl          = 274,  // int unsigned shift right with long count
261            lushrl          = 275;  // long unsigned shift right with long count
262    
263        /** Virtual opcode for null reference checks
264         */
265        int nullchk         = 276;  // return operand if non-null,
266                                    // otherwise throw NullPointerException.
267    
268        /** Virtual opcode for disallowed operations.
269         */
270        int error           = 277;
271    
272        /** All conditional jumps come in pairs. To streamline the
273         *  treatment of jumps, we also introduce a negation of an
274         *  unconditional jump. That opcode happens to be jsr.
275         */
276        int dontgoto        = jsr;
277    
278        /** Shift and mask constants for shifting prefix instructions.
279         *  a pair of instruction codes such as LCMP ; IFEQ is encoded
280         *  in Symtab as (LCMP << preShift) + IFEQ.
281         */
282        int preShift        = 9;
283        int preMask         = (1 << preShift) - 1;
284    
285        /** Type codes.
286         */
287        int INTcode         = 0,
288            LONGcode        = 1,
289            FLOATcode       = 2,
290            DOUBLEcode      = 3,
291            OBJECTcode      = 4,
292            BYTEcode        = 5,
293            CHARcode        = 6,
294            SHORTcode       = 7,
295            VOIDcode        = 8,
296            TypeCodeCount   = 9;
297    
298        static final String[] typecodeNames = {
299            "int",
300            "long",
301            "float",
302            "double",
303            "object",
304            "byte",
305            "char",
306            "short",
307            "void",
308            "oops"
309        };
310    }