|
Java Class Encryption and License Management
Create evaluation versions, host- and user based licenses using the same installation package. FREE evaluation version available. www.jsecurity.net |
00001 /* 00002 * Copyright 2001-2004 Sun Microsystems, Inc. All Rights Reserved. 00003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 00004 * 00005 * This code is free software; you can redistribute it and/or modify it 00006 * under the terms of the GNU General Public License version 2 only, as 00007 * published by the Free Software Foundation. 00008 * 00009 * This code is distributed in the hope that it will be useful, but WITHOUT 00010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00012 * version 2 for more details (a copy is included in the LICENSE file that 00013 * accompanied this code). 00014 * 00015 * You should have received a copy of the GNU General Public License version 00016 * 2 along with this work; if not, write to the Free Software Foundation, 00017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 00018 * 00019 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 00020 * CA 95054 USA or visit www.sun.com if you need additional information or 00021 * have any questions. 00022 * 00023 */ 00024 00025 package sun.jvm.hotspot.interpreter; 00026 00027 import java.util.*; 00028 import sun.jvm.hotspot.oops.*; 00029 import sun.jvm.hotspot.runtime.*; 00030 import sun.jvm.hotspot.utilities.*; 00031 00032 // Bytecodes specifies all bytecodes used in the VM and 00033 // provides utility functions to get bytecode attributes. 00034 00035 public class Bytecodes { 00036 public static final int _illegal = -1; 00037 00038 // Java bytecodes 00039 public static final int _nop = 0; // 0x00 00040 public static final int _aconst_null = 1; // 0x01 00041 public static final int _iconst_m1 = 2; // 0x02 00042 public static final int _iconst_0 = 3; // 0x03 00043 public static final int _iconst_1 = 4; // 0x04 00044 public static final int _iconst_2 = 5; // 0x05 00045 public static final int _iconst_3 = 6; // 0x06 00046 public static final int _iconst_4 = 7; // 0x07 00047 public static final int _iconst_5 = 8; // 0x08 00048 public static final int _lconst_0 = 9; // 0x09 00049 public static final int _lconst_1 = 10; // 0x0a 00050 public static final int _fconst_0 = 11; // 0x0b 00051 public static final int _fconst_1 = 12; // 0x0c 00052 public static final int _fconst_2 = 13; // 0x0d 00053 public static final int _dconst_0 = 14; // 0x0e 00054 public static final int _dconst_1 = 15; // 0x0f 00055 public static final int _bipush = 16; // 0x10 00056 public static final int _sipush = 17; // 0x11 00057 public static final int _ldc = 18; // 0x12 00058 public static final int _ldc_w = 19; // 0x13 00059 public static final int _ldc2_w = 20; // 0x14 00060 public static final int _iload = 21; // 0x15 00061 public static final int _lload = 22; // 0x16 00062 public static final int _fload = 23; // 0x17 00063 public static final int _dload = 24; // 0x18 00064 public static final int _aload = 25; // 0x19 00065 public static final int _iload_0 = 26; // 0x1a 00066 public static final int _iload_1 = 27; // 0x1b 00067 public static final int _iload_2 = 28; // 0x1c 00068 public static final int _iload_3 = 29; // 0x1d 00069 public static final int _lload_0 = 30; // 0x1e 00070 public static final int _lload_1 = 31; // 0x1f 00071 public static final int _lload_2 = 32; // 0x20 00072 public static final int _lload_3 = 33; // 0x21 00073 public static final int _fload_0 = 34; // 0x22 00074 public static final int _fload_1 = 35; // 0x23 00075 public static final int _fload_2 = 36; // 0x24 00076 public static final int _fload_3 = 37; // 0x25 00077 public static final int _dload_0 = 38; // 0x26 00078 public static final int _dload_1 = 39; // 0x27 00079 public static final int _dload_2 = 40; // 0x28 00080 public static final int _dload_3 = 41; // 0x29 00081 public static final int _aload_0 = 42; // 0x2a 00082 public static final int _aload_1 = 43; // 0x2b 00083 public static final int _aload_2 = 44; // 0x2c 00084 public static final int _aload_3 = 45; // 0x2d 00085 public static final int _iaload = 46; // 0x2e 00086 public static final int _laload = 47; // 0x2f 00087 public static final int _faload = 48; // 0x30 00088 public static final int _daload = 49; // 0x31 00089 public static final int _aaload = 50; // 0x32 00090 public static final int _baload = 51; // 0x33 00091 public static final int _caload = 52; // 0x34 00092 public static final int _saload = 53; // 0x35 00093 public static final int _istore = 54; // 0x36 00094 public static final int _lstore = 55; // 0x37 00095 public static final int _fstore = 56; // 0x38 00096 public static final int _dstore = 57; // 0x39 00097 public static final int _astore = 58; // 0x3a 00098 public static final int _istore_0 = 59; // 0x3b 00099 public static final int _istore_1 = 60; // 0x3c 00100 public static final int _istore_2 = 61; // 0x3d 00101 public static final int _istore_3 = 62; // 0x3e 00102 public static final int _lstore_0 = 63; // 0x3f 00103 public static final int _lstore_1 = 64; // 0x40 00104 public static final int _lstore_2 = 65; // 0x41 00105 public static final int _lstore_3 = 66; // 0x42 00106 public static final int _fstore_0 = 67; // 0x43 00107 public static final int _fstore_1 = 68; // 0x44 00108 public static final int _fstore_2 = 69; // 0x45 00109 public static final int _fstore_3 = 70; // 0x46 00110 public static final int _dstore_0 = 71; // 0x47 00111 public static final int _dstore_1 = 72; // 0x48 00112 public static final int _dstore_2 = 73; // 0x49 00113 public static final int _dstore_3 = 74; // 0x4a 00114 public static final int _astore_0 = 75; // 0x4b 00115 public static final int _astore_1 = 76; // 0x4c 00116 public static final int _astore_2 = 77; // 0x4d 00117 public static final int _astore_3 = 78; // 0x4e 00118 public static final int _iastore = 79; // 0x4f 00119 public static final int _lastore = 80; // 0x50 00120 public static final int _fastore = 81; // 0x51 00121 public static final int _dastore = 82; // 0x52 00122 public static final int _aastore = 83; // 0x53 00123 public static final int _bastore = 84; // 0x54 00124 public static final int _castore = 85; // 0x55 00125 public static final int _sastore = 86; // 0x56 00126 public static final int _pop = 87; // 0x57 00127 public static final int _pop2 = 88; // 0x58 00128 public static final int _dup = 89; // 0x59 00129 public static final int _dup_x1 = 90; // 0x5a 00130 public static final int _dup_x2 = 91; // 0x5b 00131 public static final int _dup2 = 92; // 0x5c 00132 public static final int _dup2_x1 = 93; // 0x5d 00133 public static final int _dup2_x2 = 94; // 0x5e 00134 public static final int _swap = 95; // 0x5f 00135 public static final int _iadd = 96; // 0x60 00136 public static final int _ladd = 97; // 0x61 00137 public static final int _fadd = 98; // 0x62 00138 public static final int _dadd = 99; // 0x63 00139 public static final int _isub = 100; // 0x64 00140 public static final int _lsub = 101; // 0x65 00141 public static final int _fsub = 102; // 0x66 00142 public static final int _dsub = 103; // 0x67 00143 public static final int _imul = 104; // 0x68 00144 public static final int _lmul = 105; // 0x69 00145 public static final int _fmul = 106; // 0x6a 00146 public static final int _dmul = 107; // 0x6b 00147 public static final int _idiv = 108; // 0x6c 00148 public static final int _ldiv = 109; // 0x6d 00149 public static final int _fdiv = 110; // 0x6e 00150 public static final int _ddiv = 111; // 0x6f 00151 public static final int _irem = 112; // 0x70 00152 public static final int _lrem = 113; // 0x71 00153 public static final int _frem = 114; // 0x72 00154 public static final int _drem = 115; // 0x73 00155 public static final int _ineg = 116; // 0x74 00156 public static final int _lneg = 117; // 0x75 00157 public static final int _fneg = 118; // 0x76 00158 public static final int _dneg = 119; // 0x77 00159 public static final int _ishl = 120; // 0x78 00160 public static final int _lshl = 121; // 0x79 00161 public static final int _ishr = 122; // 0x7a 00162 public static final int _lshr = 123; // 0x7b 00163 public static final int _iushr = 124; // 0x7c 00164 public static final int _lushr = 125; // 0x7d 00165 public static final int _iand = 126; // 0x7e 00166 public static final int _land = 127; // 0x7f 00167 public static final int _ior = 128; // 0x80 00168 public static final int _lor = 129; // 0x81 00169 public static final int _ixor = 130; // 0x82 00170 public static final int _lxor = 131; // 0x83 00171 public static final int _iinc = 132; // 0x84 00172 public static final int _i2l = 133; // 0x85 00173 public static final int _i2f = 134; // 0x86 00174 public static final int _i2d = 135; // 0x87 00175 public static final int _l2i = 136; // 0x88 00176 public static final int _l2f = 137; // 0x89 00177 public static final int _l2d = 138; // 0x8a 00178 public static final int _f2i = 139; // 0x8b 00179 public static final int _f2l = 140; // 0x8c 00180 public static final int _f2d = 141; // 0x8d 00181 public static final int _d2i = 142; // 0x8e 00182 public static final int _d2l = 143; // 0x8f 00183 public static final int _d2f = 144; // 0x90 00184 public static final int _i2b = 145; // 0x91 00185 public static final int _i2c = 146; // 0x92 00186 public static final int _i2s = 147; // 0x93 00187 public static final int _lcmp = 148; // 0x94 00188 public static final int _fcmpl = 149; // 0x95 00189 public static final int _fcmpg = 150; // 0x96 00190 public static final int _dcmpl = 151; // 0x97 00191 public static final int _dcmpg = 152; // 0x98 00192 public static final int _ifeq = 153; // 0x99 00193 public static final int _ifne = 154; // 0x9a 00194 public static final int _iflt = 155; // 0x9b 00195 public static final int _ifge = 156; // 0x9c 00196 public static final int _ifgt = 157; // 0x9d 00197 public static final int _ifle = 158; // 0x9e 00198 public static final int _if_icmpeq = 159; // 0x9f 00199 public static final int _if_icmpne = 160; // 0xa0 00200 public static final int _if_icmplt = 161; // 0xa1 00201 public static final int _if_icmpge = 162; // 0xa2 00202 public static final int _if_icmpgt = 163; // 0xa3 00203 public static final int _if_icmple = 164; // 0xa4 00204 public static final int _if_acmpeq = 165; // 0xa5 00205 public static final int _if_acmpne = 166; // 0xa6 00206 public static final int _goto = 167; // 0xa7 00207 public static final int _jsr = 168; // 0xa8 00208 public static final int _ret = 169; // 0xa9 00209 public static final int _tableswitch = 170; // 0xaa 00210 public static final int _lookupswitch = 171; // 0xab 00211 public static final int _ireturn = 172; // 0xac 00212 public static final int _lreturn = 173; // 0xad 00213 public static final int _freturn = 174; // 0xae 00214 public static final int _dreturn = 175; // 0xaf 00215 public static final int _areturn = 176; // 0xb0 00216 public static final int _return = 177; // 0xb1 00217 public static final int _getstatic = 178; // 0xb2 00218 public static final int _putstatic = 179; // 0xb3 00219 public static final int _getfield = 180; // 0xb4 00220 public static final int _putfield = 181; // 0xb5 00221 public static final int _invokevirtual = 182; // 0xb6 00222 public static final int _invokespecial = 183; // 0xb7 00223 public static final int _invokestatic = 184; // 0xb8 00224 public static final int _invokeinterface = 185; // 0xb9 00225 public static final int _xxxunusedxxx = 186; // 0xba 00226 public static final int _new = 187; // 0xbb 00227 public static final int _newarray = 188; // 0xbc 00228 public static final int _anewarray = 189; // 0xbd 00229 public static final int _arraylength = 190; // 0xbe 00230 public static final int _athrow = 191; // 0xbf 00231 public static final int _checkcast = 192; // 0xc0 00232 public static final int _instanceof = 193; // 0xc1 00233 public static final int _monitorenter = 194; // 0xc2 00234 public static final int _monitorexit = 195; // 0xc3 00235 public static final int _wide = 196; // 0xc4 00236 public static final int _multianewarray = 197; // 0xc5 00237 public static final int _ifnull = 198; // 0xc6 00238 public static final int _ifnonnull = 199; // 0xc7 00239 public static final int _goto_w = 200; // 0xc8 00240 public static final int _jsr_w = 201; // 0xc9 00241 public static final int _breakpoint = 202; // 0xca 00242 00243 public static final int number_of_java_codes = 203; 00244 00245 // JVM bytecodes 00246 public static final int _fast_agetfield = number_of_java_codes; 00247 public static final int _fast_bgetfield = 204; 00248 public static final int _fast_cgetfield = 205; 00249 public static final int _fast_dgetfield = 206; 00250 public static final int _fast_fgetfield = 207; 00251 public static final int _fast_igetfield = 208; 00252 public static final int _fast_lgetfield = 209; 00253 public static final int _fast_sgetfield = 210; 00254 public static final int _fast_aputfield = 211; 00255 public static final int _fast_bputfield = 212; 00256 public static final int _fast_cputfield = 213; 00257 public static final int _fast_dputfield = 214; 00258 public static final int _fast_fputfield = 215; 00259 public static final int _fast_iputfield = 216; 00260 public static final int _fast_lputfield = 217; 00261 public static final int _fast_sputfield = 218; 00262 public static final int _fast_aload_0 = 219; 00263 public static final int _fast_iaccess_0 = 220; 00264 public static final int _fast_aaccess_0 = 221; 00265 public static final int _fast_faccess_0 = 222; 00266 public static final int _fast_iload = 223; 00267 public static final int _fast_iload2 = 224; 00268 public static final int _fast_icaload = 225; 00269 public static final int _fast_invokevfinal = 226; 00270 public static final int _fast_linearswitch = 227; 00271 public static final int _fast_binaryswitch = 228; 00272 public static final int _shouldnotreachhere = 229; // For debugging 00273 00274 public static final int number_of_codes = 230; 00275 00276 public static int specialLengthAt(Method method, int bci) { 00277 int code = codeAt(method, bci); 00278 switch (code) { 00279 case _wide: 00280 return wideLengthFor(method.getBytecodeOrBPAt(bci + 1)); 00281 case _tableswitch: 00282 { 00283 int alignedBCI = Bits.roundTo(bci + 1, jintSize); 00284 int lo = method.getBytecodeIntArg(alignedBCI + 1*jintSize); 00285 int hi = method.getBytecodeIntArg(alignedBCI + 2*jintSize); 00286 return (alignedBCI - bci) + (3 + hi - lo + 1)*jintSize; 00287 } 00288 00289 case _lookupswitch: // fall through 00290 case _fast_binaryswitch: // fall through 00291 case _fast_linearswitch: 00292 { 00293 int alignedBCI = Bits.roundTo(bci + 1, jintSize); 00294 int npairs = method.getBytecodeIntArg(alignedBCI + jintSize); 00295 return (alignedBCI - bci) + (2 + 2*npairs)*jintSize; 00296 } 00297 00298 } 00299 throw new RuntimeException("should not reach here"); 00300 } 00301 00302 // Conversion 00303 public static void check(int code) { 00304 if (Assert.ASSERTS_ENABLED) { 00305 Assert.that(isDefined(code), "illegal code " + code); 00306 } 00307 } 00308 public static void wideCheck(int code) { 00309 if (Assert.ASSERTS_ENABLED) { 00310 Assert.that(wideIsDefined(code), "illegal code " + code); 00311 } 00312 } 00313 00315 public static int codeAt(Method method, int bci) { 00316 int res = codeOrBPAt(method, bci); 00317 if (res == _breakpoint) { 00318 res = method.getOrigBytecodeAt(bci); 00319 } 00320 return res; 00321 } 00322 00324 public static int codeOrBPAt(Method method, int bci) { 00325 return method.getBytecodeOrBPAt(bci); 00326 } 00327 00328 public static boolean isActiveBreakpointAt(Method method, int bci) { 00329 return (codeOrBPAt(method, bci) == _breakpoint); 00330 } 00331 00332 // find a bytecode, behind a breakpoint if necessary: 00333 // FIXME: not yet implementable 00334 // static Code non_breakpoint_code_at(address bcp, methodOop method = null); 00335 00336 // Bytecode attributes 00337 public static boolean isDefined (int code) { return 0 <= code && code < number_of_codes && _format[code] != null; } 00338 public static boolean wideIsDefined(int code) { return isDefined(code) && _wide_format[code] != null; } 00339 public static String name (int code) { check(code); return _name [code]; } 00340 public static String format (int code) { check(code); return _format [code]; } 00341 public static String wideFormat (int code) { wideCheck(code); return _wide_format [code]; } 00342 public static int resultType (int code) { check(code); return _result_type [code]; } 00343 public static int depth (int code) { check(code); return _depth [code]; } 00344 public static int lengthFor (int code) { check(code); return _length [code]; } 00345 public static boolean canTrap (int code) { check(code); return _can_trap [code]; } 00346 public static int javaCode (int code) { check(code); return _java_code [code]; } 00347 public static boolean canRewrite (int code) { check(code); return _can_rewrite [code]; } 00348 public static int wideLengthFor(int code) { wideCheck(code); return wideFormat(code).length(); } 00349 public static int lengthAt (Method method, int bci) { int l = lengthFor(codeAt(method, bci)); return l > 0 ? l : specialLengthAt(method, bci); } 00350 public static int javaLengthAt (Method method, int bci) { int l = lengthFor(javaCode(codeAt(method, bci))); return l > 0 ? l : specialLengthAt(method, bci); } 00351 public static boolean isJavaCode (int code) { return 0 <= code && code < number_of_java_codes; } 00352 public static boolean isFastCode (int code) { return number_of_java_codes <= code && code < number_of_codes; } 00353 00354 public static boolean isAload (int code) { return (code == _aload || code == _aload_0 || code == _aload_1 00355 || code == _aload_2 || code == _aload_3); } 00356 public static boolean isAstore (int code) { return (code == _astore || code == _astore_0 || code == _astore_1 00357 || code == _astore_2 || code == _astore_3); } 00358 00359 public static boolean isZeroConst (int code) { return (code == _aconst_null || code == _iconst_0 00360 || code == _fconst_0 || code == _dconst_0); } 00361 00362 //---------------------------------------------------------------------- 00363 // Internals only below this point 00364 // 00365 00366 private static String[] _name; 00367 private static String[] _format; 00368 private static String[] _wide_format; 00369 private static int[] _result_type; 00370 private static byte[] _depth; 00371 private static byte[] _length; 00372 private static boolean[] _can_trap; 00373 private static int[] _java_code; 00374 private static boolean[] _can_rewrite; 00375 00376 static { 00377 _name = new String [number_of_codes]; 00378 _format = new String [number_of_codes]; 00379 _wide_format = new String [number_of_codes]; 00380 _result_type = new int [number_of_codes]; // See BasicType.java 00381 _depth = new byte [number_of_codes]; 00382 _length = new byte [number_of_codes]; 00383 _can_trap = new boolean[number_of_codes]; 00384 _java_code = new int [number_of_codes]; 00385 _can_rewrite = new boolean[number_of_codes]; 00386 00387 // In case we want to fetch this information from the VM in the 00388 // future 00389 VM.registerVMInitializedObserver(new Observer() { 00390 public void update(Observable o, Object data) { 00391 initialize(); 00392 } 00393 }); 00394 } 00395 00396 private static final int jintSize = 4; 00397 00398 // private static String[] _name = new String [number_of_codes]; 00399 // private static String[] _format = new String [number_of_codes]; 00400 // private static String[] _wide_format = new String [number_of_codes]; 00401 // private static int[] _result_type = new int [number_of_codes]; // See BasicType.java 00402 // private static byte[] _depth = new byte [number_of_codes]; 00403 // private static byte[] _length = new byte [number_of_codes]; 00404 // private static boolean[] _can_trap = new boolean[number_of_codes]; 00405 // private static int[] _java_code = new int [number_of_codes]; 00406 // private static boolean[] _can_rewrite = new boolean[number_of_codes]; 00407 00408 // Initialization 00409 private static void initialize() { 00410 if (Assert.ASSERTS_ENABLED) { 00411 Assert.that(number_of_codes <= 256, "too many bytecodes"); 00412 } 00413 00414 // Format strings interpretation: 00415 // 00416 // b: bytecode 00417 // c: signed constant, Java byte-ordering 00418 // i: unsigned index , Java byte-ordering 00419 // j: unsigned index , native byte-ordering 00420 // o: branch offset , Java byte-ordering 00421 // _: unused/ignored 00422 // w: wide bytecode 00423 // 00424 // Note: Right now the format strings are used for 2 purposes: 00425 // 1. to specify the length of the bytecode 00426 // (= number of characters in format string) 00427 // 2. to specify the bytecode attributes 00428 // 00429 // The bytecode attributes are currently used only for bytecode tracing 00430 // (see BytecodeTracer); thus if more specific format information is 00431 // used, one would also have to adjust the bytecode tracer. 00432 // 00433 // Note: For bytecodes with variable length, the format string is the empty string. 00434 00435 // Note 1: null for the format string means the bytecode doesn't exist 00436 // in that form. 00437 // 00438 // Note 2: The result type is T_ILLEGAL for bytecodes where the top of stack 00439 // type after execution is not only determined by the bytecode itself. 00440 00441 // Java bytecodes 00442 // bytecode bytecode name format wide f. result tp stk traps 00443 def(_nop , "nop" , "b" , null , BasicType.getTVoid() , 0, false); 00444 def(_aconst_null , "aconst_null" , "b" , null , BasicType.getTObject() , 1, false); 00445 def(_iconst_m1 , "iconst_m1" , "b" , null , BasicType.getTInt() , 1, false); 00446 def(_iconst_0 , "iconst_0" , "b" , null , BasicType.getTInt() , 1, false); 00447 def(_iconst_1 , "iconst_1" , "b" , null , BasicType.getTInt() , 1, false); 00448 def(_iconst_2 , "iconst_2" , "b" , null , BasicType.getTInt() , 1, false); 00449 def(_iconst_3 , "iconst_3" , "b" , null , BasicType.getTInt() , 1, false); 00450 def(_iconst_4 , "iconst_4" , "b" , null , BasicType.getTInt() , 1, false); 00451 def(_iconst_5 , "iconst_5" , "b" , null , BasicType.getTInt() , 1, false); 00452 def(_lconst_0 , "lconst_0" , "b" , null , BasicType.getTLong() , 2, false); 00453 def(_lconst_1 , "lconst_1" , "b" , null , BasicType.getTLong() , 2, false); 00454 def(_fconst_0 , "fconst_0" , "b" , null , BasicType.getTFloat() , 1, false); 00455 def(_fconst_1 , "fconst_1" , "b" , null , BasicType.getTFloat() , 1, false); 00456 def(_fconst_2 , "fconst_2" , "b" , null , BasicType.getTFloat() , 1, false); 00457 def(_dconst_0 , "dconst_0" , "b" , null , BasicType.getTDouble() , 2, false); 00458 def(_dconst_1 , "dconst_1" , "b" , null , BasicType.getTDouble() , 2, false); 00459 def(_bipush , "bipush" , "bc" , null , BasicType.getTInt() , 1, false); 00460 def(_sipush , "sipush" , "bcc" , null , BasicType.getTInt() , 1, false); 00461 def(_ldc , "ldc" , "bi" , null , BasicType.getTIllegal(), 1, true ); 00462 def(_ldc_w , "ldc_w" , "bii" , null , BasicType.getTIllegal(), 1, true ); 00463 def(_ldc2_w , "ldc2_w" , "bii" , null , BasicType.getTIllegal(), 2, true ); 00464 def(_iload , "iload" , "bi" , "wbii" , BasicType.getTInt() , 1, false); 00465 def(_lload , "lload" , "bi" , "wbii" , BasicType.getTLong() , 2, false); 00466 def(_fload , "fload" , "bi" , "wbii" , BasicType.getTFloat() , 1, false); 00467 def(_dload , "dload" , "bi" , "wbii" , BasicType.getTDouble() , 2, false); 00468 def(_aload , "aload" , "bi" , "wbii" , BasicType.getTObject() , 1, false); 00469 def(_iload_0 , "iload_0" , "b" , null , BasicType.getTInt() , 1, false); 00470 def(_iload_1 , "iload_1" , "b" , null , BasicType.getTInt() , 1, false); 00471 def(_iload_2 , "iload_2" , "b" , null , BasicType.getTInt() , 1, false); 00472 def(_iload_3 , "iload_3" , "b" , null , BasicType.getTInt() , 1, false); 00473 def(_lload_0 , "lload_0" , "b" , null , BasicType.getTLong() , 2, false); 00474 def(_lload_1 , "lload_1" , "b" , null , BasicType.getTLong() , 2, false); 00475 def(_lload_2 , "lload_2" , "b" , null , BasicType.getTLong() , 2, false); 00476 def(_lload_3 , "lload_3" , "b" , null , BasicType.getTLong() , 2, false); 00477 def(_fload_0 , "fload_0" , "b" , null , BasicType.getTFloat() , 1, false); 00478 def(_fload_1 , "fload_1" , "b" , null , BasicType.getTFloat() , 1, false); 00479 def(_fload_2 , "fload_2" , "b" , null , BasicType.getTFloat() , 1, false); 00480 def(_fload_3 , "fload_3" , "b" , null , BasicType.getTFloat() , 1, false); 00481 def(_dload_0 , "dload_0" , "b" , null , BasicType.getTDouble() , 2, false); 00482 def(_dload_1 , "dload_1" , "b" , null , BasicType.getTDouble() , 2, false); 00483 def(_dload_2 , "dload_2" , "b" , null , BasicType.getTDouble() , 2, false); 00484 def(_dload_3 , "dload_3" , "b" , null , BasicType.getTDouble() , 2, false); 00485 def(_aload_0 , "aload_0" , "b" , null , BasicType.getTObject() , 1, true ); // rewriting in interpreter 00486 def(_aload_1 , "aload_1" , "b" , null , BasicType.getTObject() , 1, false); 00487 def(_aload_2 , "aload_2" , "b" , null , BasicType.getTObject() , 1, false); 00488 def(_aload_3 , "aload_3" , "b" , null , BasicType.getTObject() , 1, false); 00489 def(_iaload , "iaload" , "b" , null , BasicType.getTInt() , -1, true ); 00490 def(_laload , "laload" , "b" , null , BasicType.getTLong() , 0, true ); 00491 def(_faload , "faload" , "b" , null , BasicType.getTFloat() , -1, true ); 00492 def(_daload , "daload" , "b" , null , BasicType.getTDouble() , 0, true ); 00493 def(_aaload , "aaload" , "b" , null , BasicType.getTObject() , -1, true ); 00494 def(_baload , "baload" , "b" , null , BasicType.getTInt() , -1, true ); 00495 def(_caload , "caload" , "b" , null , BasicType.getTInt() , -1, true ); 00496 def(_saload , "saload" , "b" , null , BasicType.getTInt() , -1, true ); 00497 def(_istore , "istore" , "bi" , "wbii" , BasicType.getTVoid() , -1, false); 00498 def(_lstore , "lstore" , "bi" , "wbii" , BasicType.getTVoid() , -2, false); 00499 def(_fstore , "fstore" , "bi" , "wbii" , BasicType.getTVoid() , -1, false); 00500 def(_dstore , "dstore" , "bi" , "wbii" , BasicType.getTVoid() , -2, false); 00501 def(_astore , "astore" , "bi" , "wbii" , BasicType.getTVoid() , -1, false); 00502 def(_istore_0 , "istore_0" , "b" , null , BasicType.getTVoid() , -1, false); 00503 def(_istore_1 , "istore_1" , "b" , null , BasicType.getTVoid() , -1, false); 00504 def(_istore_2 , "istore_2" , "b" , null , BasicType.getTVoid() , -1, false); 00505 def(_istore_3 , "istore_3" , "b" , null , BasicType.getTVoid() , -1, false); 00506 def(_lstore_0 , "lstore_0" , "b" , null , BasicType.getTVoid() , -2, false); 00507 def(_lstore_1 , "lstore_1" , "b" , null , BasicType.getTVoid() , -2, false); 00508 def(_lstore_2 , "lstore_2" , "b" , null , BasicType.getTVoid() , -2, false); 00509 def(_lstore_3 , "lstore_3" , "b" , null , BasicType.getTVoid() , -2, false); 00510 def(_fstore_0 , "fstore_0" , "b" , null , BasicType.getTVoid() , -1, false); 00511 def(_fstore_1 , "fstore_1" , "b" , null , BasicType.getTVoid() , -1, false); 00512 def(_fstore_2 , "fstore_2" , "b" , null , BasicType.getTVoid() , -1, false); 00513 def(_fstore_3 , "fstore_3" , "b" , null , BasicType.getTVoid() , -1, false); 00514 def(_dstore_0 , "dstore_0" , "b" , null , BasicType.getTVoid() , -2, false); 00515 def(_dstore_1 , "dstore_1" , "b" , null , BasicType.getTVoid() , -2, false); 00516 def(_dstore_2 , "dstore_2" , "b" , null , BasicType.getTVoid() , -2, false); 00517 def(_dstore_3 , "dstore_3" , "b" , null , BasicType.getTVoid() , -2, false); 00518 def(_astore_0 , "astore_0" , "b" , null , BasicType.getTVoid() , -1, false); 00519 def(_astore_1 , "astore_1" , "b" , null , BasicType.getTVoid() , -1, false); 00520 def(_astore_2 , "astore_2" , "b" , null , BasicType.getTVoid() , -1, false); 00521 def(_astore_3 , "astore_3" , "b" , null , BasicType.getTVoid() , -1, false); 00522 def(_iastore , "iastore" , "b" , null , BasicType.getTVoid() , -3, true ); 00523 def(_lastore , "lastore" , "b" , null , BasicType.getTVoid() , -4, true ); 00524 def(_fastore , "fastore" , "b" , null , BasicType.getTVoid() , -3, true ); 00525 def(_dastore , "dastore" , "b" , null , BasicType.getTVoid() , -4, true ); 00526 def(_aastore , "aastore" , "b" , null , BasicType.getTVoid() , -3, true ); 00527 def(_bastore , "bastore" , "b" , null , BasicType.getTVoid() , -3, true ); 00528 def(_castore , "castore" , "b" , null , BasicType.getTVoid() , -3, true ); 00529 def(_sastore , "sastore" , "b" , null , BasicType.getTVoid() , -3, true ); 00530 def(_pop , "pop" , "b" , null , BasicType.getTVoid() , -1, false); 00531 def(_pop2 , "pop2" , "b" , null , BasicType.getTVoid() , -2, false); 00532 def(_dup , "dup" , "b" , null , BasicType.getTVoid() , 1, false); 00533 def(_dup_x1 , "dup_x1" , "b" , null , BasicType.getTVoid() , 1, false); 00534 def(_dup_x2 , "dup_x2" , "b" , null , BasicType.getTVoid() , 1, false); 00535 def(_dup2 , "dup2" , "b" , null , BasicType.getTVoid() , 2, false); 00536 def(_dup2_x1 , "dup2_x1" , "b" , null , BasicType.getTVoid() , 2, false); 00537 def(_dup2_x2 , "dup2_x2" , "b" , null , BasicType.getTVoid() , 2, false); 00538 def(_swap , "swap" , "b" , null , BasicType.getTVoid() , 0, false); 00539 def(_iadd , "iadd" , "b" , null , BasicType.getTInt() , -1, false); 00540 def(_ladd , "ladd" , "b" , null , BasicType.getTLong() , -2, false); 00541 def(_fadd , "fadd" , "b" , null , BasicType.getTFloat() , -1, false); 00542 def(_dadd , "dadd" , "b" , null , BasicType.getTDouble() , -2, false); 00543 def(_isub , "isub" , "b" , null , BasicType.getTInt() , -1, false); 00544 def(_lsub , "lsub" , "b" , null , BasicType.getTLong() , -2, false); 00545 def(_fsub , "fsub" , "b" , null , BasicType.getTFloat() , -1, false); 00546 def(_dsub , "dsub" , "b" , null , BasicType.getTDouble() , -2, false); 00547 def(_imul , "imul" , "b" , null , BasicType.getTInt() , -1, false); 00548 def(_lmul , "lmul" , "b" , null , BasicType.getTLong() , -2, false); 00549 def(_fmul , "fmul" , "b" , null , BasicType.getTFloat() , -1, false); 00550 def(_dmul , "dmul" , "b" , null , BasicType.getTDouble() , -2, false); 00551 def(_idiv , "idiv" , "b" , null , BasicType.getTInt() , -1, true ); 00552 def(_ldiv , "ldiv" , "b" , null , BasicType.getTLong() , -2, true ); 00553 def(_fdiv , "fdiv" , "b" , null , BasicType.getTFloat() , -1, false); 00554 def(_ddiv , "ddiv" , "b" , null , BasicType.getTDouble() , -2, false); 00555 def(_irem , "irem" , "b" , null , BasicType.getTInt() , -1, true ); 00556 def(_lrem , "lrem" , "b" , null , BasicType.getTLong() , -2, true ); 00557 def(_frem , "frem" , "b" , null , BasicType.getTFloat() , -1, false); 00558 def(_drem , "drem" , "b" , null , BasicType.getTDouble() , -2, false); 00559 def(_ineg , "ineg" , "b" , null , BasicType.getTInt() , 0, false); 00560 def(_lneg , "lneg" , "b" , null , BasicType.getTLong() , 0, false); 00561 def(_fneg , "fneg" , "b" , null , BasicType.getTFloat() , 0, false); 00562 def(_dneg , "dneg" , "b" , null , BasicType.getTDouble() , 0, false); 00563 def(_ishl , "ishl" , "b" , null , BasicType.getTInt() , -1, false); 00564 def(_lshl , "lshl" , "b" , null , BasicType.getTLong() , -1, false); 00565 def(_ishr , "ishr" , "b" , null , BasicType.getTInt() , -1, false); 00566 def(_lshr , "lshr" , "b" , null , BasicType.getTLong() , -1, false); 00567 def(_iushr , "iushr" , "b" , null , BasicType.getTInt() , -1, false); 00568 def(_lushr , "lushr" , "b" , null , BasicType.getTLong() , -1, false); 00569 def(_iand , "iand" , "b" , null , BasicType.getTInt() , -1, false); 00570 def(_land , "land" , "b" , null , BasicType.getTLong() , -2, false); 00571 def(_ior , "ior" , "b" , null , BasicType.getTInt() , -1, false); 00572 def(_lor , "lor" , "b" , null , BasicType.getTLong() , -2, false); 00573 def(_ixor , "ixor" , "b" , null , BasicType.getTInt() , -1, false); 00574 def(_lxor , "lxor" , "b" , null , BasicType.getTLong() , -2, false); 00575 def(_iinc , "iinc" , "bic" , "wbiicc", BasicType.getTVoid() , 0, false); 00576 def(_i2l , "i2l" , "b" , null , BasicType.getTLong() , 1, false); 00577 def(_i2f , "i2f" , "b" , null , BasicType.getTFloat() , 0, false); 00578 def(_i2d , "i2d" , "b" , null , BasicType.getTDouble() , 1, false); 00579 def(_l2i , "l2i" , "b" , null , BasicType.getTInt() , -1, false); 00580 def(_l2f , "l2f" , "b" , null , BasicType.getTFloat() , -1, false); 00581 def(_l2d , "l2d" , "b" , null , BasicType.getTDouble() , 0, false); 00582 def(_f2i , "f2i" , "b" , null , BasicType.getTInt() , 0, false); 00583 def(_f2l , "f2l" , "b" , null , BasicType.getTLong() , 1, false); 00584 def(_f2d , "f2d" , "b" , null , BasicType.getTDouble() , 1, false); 00585 def(_d2i , "d2i" , "b" , null , BasicType.getTInt() , -1, false); 00586 def(_d2l , "d2l" , "b" , null , BasicType.getTLong() , 0, false); 00587 def(_d2f , "d2f" , "b" , null , BasicType.getTFloat() , -1, false); 00588 def(_i2b , "i2b" , "b" , null , BasicType.getTByte() , 0, false); 00589 def(_i2c , "i2c" , "b" , null , BasicType.getTChar() , 0, false); 00590 def(_i2s , "i2s" , "b" , null , BasicType.getTShort() , 0, false); 00591 def(_lcmp , "lcmp" , "b" , null , BasicType.getTVoid() , -3, false); 00592 def(_fcmpl , "fcmpl" , "b" , null , BasicType.getTVoid() , -1, false); 00593 def(_fcmpg , "fcmpg" , "b" , null , BasicType.getTVoid() , -1, false); 00594 def(_dcmpl , "dcmpl" , "b" , null , BasicType.getTVoid() , -3, false); 00595 def(_dcmpg , "dcmpg" , "b" , null , BasicType.getTVoid() , -3, false); 00596 def(_ifeq , "ifeq" , "boo" , null , BasicType.getTVoid() , -1, false); 00597 def(_ifne , "ifne" , "boo" , null , BasicType.getTVoid() , -1, false); 00598 def(_iflt , "iflt" , "boo" , null , BasicType.getTVoid() , -1, false); 00599 def(_ifge , "ifge" , "boo" , null , BasicType.getTVoid() , -1, false); 00600 def(_ifgt , "ifgt" , "boo" , null , BasicType.getTVoid() , -1, false); 00601 def(_ifle , "ifle" , "boo" , null , BasicType.getTVoid() , -1, false); 00602 def(_if_icmpeq , "if_icmpeq" , "boo" , null , BasicType.getTVoid() , -2, false); 00603 def(_if_icmpne , "if_icmpne" , "boo" , null , BasicType.getTVoid() , -2, false); 00604 def(_if_icmplt , "if_icmplt" , "boo" , null , BasicType.getTVoid() , -2, false); 00605 def(_if_icmpge , "if_icmpge" , "boo" , null , BasicType.getTVoid() , -2, false); 00606 def(_if_icmpgt , "if_icmpgt" , "boo" , null , BasicType.getTVoid() , -2, false); 00607 def(_if_icmple , "if_icmple" , "boo" , null , BasicType.getTVoid() , -2, false); 00608 def(_if_acmpeq , "if_acmpeq" , "boo" , null , BasicType.getTVoid() , -2, false); 00609 def(_if_acmpne , "if_acmpne" , "boo" , null , BasicType.getTVoid() , -2, false); 00610 def(_goto , "goto" , "boo" , null , BasicType.getTVoid() , 0, false); 00611 def(_jsr , "jsr" , "boo" , null , BasicType.getTInt() , 0, false); 00612 def(_ret , "ret" , "bi" , "wbii" , BasicType.getTVoid() , 0, false); 00613 def(_tableswitch , "tableswitch" , "" , null , BasicType.getTVoid() , -1, false); // may have backward branches 00614 def(_lookupswitch , "lookupswitch" , "" , null , BasicType.getTVoid() , -1, false); // rewriting in interpreter 00615 def(_ireturn , "ireturn" , "b" , null , BasicType.getTInt() , -1, true ); 00616 def(_lreturn , "lreturn" , "b" , null , BasicType.getTLong() , -2, true ); 00617 def(_freturn , "freturn" , "b" , null , BasicType.getTFloat() , -1, true ); 00618 def(_dreturn , "dreturn" , "b" , null , BasicType.getTDouble() , -2, true ); 00619 def(_areturn , "areturn" , "b" , null , BasicType.getTObject() , -1, true ); 00620 def(_return , "return" , "b" , null , BasicType.getTVoid() , 0, true ); 00621 def(_getstatic , "getstatic" , "bjj" , null , BasicType.getTIllegal(), 1, true ); 00622 def(_putstatic , "putstatic" , "bjj" , null , BasicType.getTIllegal(), -1, true ); 00623 def(_getfield , "getfield" , "bjj" , null , BasicType.getTIllegal(), 0, true ); 00624 def(_putfield , "putfield" , "bjj" , null , BasicType.getTIllegal(), -2, true ); 00625 def(_invokevirtual , "invokevirtual" , "bjj" , null , BasicType.getTIllegal(), -1, true ); 00626 def(_invokespecial , "invokespecial" , "bjj" , null , BasicType.getTIllegal(), -1, true ); 00627 def(_invokestatic , "invokestatic" , "bjj" , null , BasicType.getTIllegal(), 0, true ); 00628 def(_invokeinterface , "invokeinterface" , "bjj__", null , BasicType.getTIllegal(), -1, true ); 00629 def(_xxxunusedxxx , "xxxunusedxxx" , null , null , BasicType.getTVoid() , 0, false); 00630 def(_new , "new" , "bii" , null , BasicType.getTObject() , 1, true ); 00631 def(_newarray , "newarray" , "bc" , null , BasicType.getTObject() , 0, true ); 00632 def(_anewarray , "anewarray" , "bii" , null , BasicType.getTObject() , 0, true ); 00633 def(_arraylength , "arraylength" , "b" , null , BasicType.getTVoid() , 0, true ); 00634 def(_athrow , "athrow" , "b" , null , BasicType.getTVoid() , -1, true ); 00635 def(_checkcast , "checkcast" , "bii" , null , BasicType.getTObject() , 0, true ); 00636 def(_instanceof , "instanceof" , "bii" , null , BasicType.getTInt() , 0, true ); 00637 def(_monitorenter , "monitorenter" , "b" , null , BasicType.getTVoid() , -1, true ); 00638 def(_monitorexit , "monitorexit" , "b" , null , BasicType.getTVoid() , -1, true ); 00639 def(_wide , "wide" , "" , null , BasicType.getTVoid() , 0, false); 00640 def(_multianewarray , "multianewarray" , "biic" , null , BasicType.getTObject() , 1, true ); 00641 def(_ifnull , "ifnull" , "boo" , null , BasicType.getTVoid() , -1, false); 00642 def(_ifnonnull , "ifnonnull" , "boo" , null , BasicType.getTVoid() , -1, false); 00643 def(_goto_w , "goto_w" , "boooo", null , BasicType.getTVoid() , 0, false); 00644 def(_jsr_w , "jsr_w" , "boooo", null , BasicType.getTInt() , 0, false); 00645 def(_breakpoint , "breakpoint" , "" , null , BasicType.getTVoid() , 0, true ); 00646 00647 // JVM bytecodes 00648 // bytecode bytecode name format wide f. result tp stk traps std code 00649 def(_fast_agetfield , "fast_agetfield" , "bjj" , null , BasicType.getTObject() , 0, true , _getfield ); 00650 def(_fast_bgetfield , "fast_bgetfield" , "bjj" , null , BasicType.getTInt() , 0, true , _getfield ); 00651 def(_fast_cgetfield , "fast_cgetfield" , "bjj" , null , BasicType.getTChar() , 0, true , _getfield ); 00652 def(_fast_dgetfield , "fast_dgetfield" , "bjj" , null , BasicType.getTDouble() , 0, true , _getfield ); 00653 def(_fast_fgetfield , "fast_fgetfield" , "bjj" , null , BasicType.getTFloat() , 0, true , _getfield ); 00654 def(_fast_igetfield , "fast_igetfield" , "bjj" , null , BasicType.getTInt() , 0, true , _getfield ); 00655 def(_fast_lgetfield , "fast_lgetfield" , "bjj" , null , BasicType.getTLong() , 0, true , _getfield ); 00656 def(_fast_sgetfield , "fast_sgetfield" , "bjj" , null , BasicType.getTShort() , 0, true , _getfield ); 00657 00658 def(_fast_aputfield , "fast_aputfield" , "bjj" , null , BasicType.getTObject() , 0, true , _putfield ); 00659 def(_fast_bputfield , "fast_bputfield" , "bjj" , null , BasicType.getTInt() , 0, true , _putfield ); 00660 def(_fast_cputfield , "fast_cputfield" , "bjj" , null , BasicType.getTChar() , 0, true , _putfield ); 00661 def(_fast_dputfield , "fast_dputfield" , "bjj" , null , BasicType.getTDouble() , 0, true , _putfield ); 00662 def(_fast_fputfield , "fast_fputfield" , "bjj" , null , BasicType.getTFloat() , 0, true , _putfield ); 00663 def(_fast_iputfield , "fast_iputfield" , "bjj" , null , BasicType.getTInt() , 0, true , _putfield ); 00664 def(_fast_lputfield , "fast_lputfield" , "bjj" , null , BasicType.getTLong() , 0, true , _putfield ); 00665 def(_fast_sputfield , "fast_sputfield" , "bjj" , null , BasicType.getTShort() , 0, true , _putfield ); 00666 00667 def(_fast_aload_0 , "fast_aload_0" , "b" , null , BasicType.getTObject() , 1, true , _aload_0 ); 00668 def(_fast_iaccess_0 , "fast_iaccess_0" , "b_jj" , null , BasicType.getTInt() , 1, true , _aload_0 ); 00669 def(_fast_aaccess_0 , "fast_aaccess_0" , "b_jj" , null , BasicType.getTObject() , 1, true , _aload_0 ); 00670 def(_fast_faccess_0 , "fast_faccess_0" , "b_jj" , null , BasicType.getTObject() , 1, true , _aload_0 ); 00671 00672 def(_fast_iload , "fast_iload" , "bi" , null , BasicType.getTInt() , 1, false, _iload); 00673 def(_fast_iload2 , "fast_iload2" , "bi_i" , null , BasicType.getTInt() , 2, false, _iload); 00674 def(_fast_icaload , "fast_icaload" , "bi_" , null , BasicType.getTInt() , 0, false, _iload); 00675 00676 // Faster method invocation. 00677 def(_fast_invokevfinal , "fast_invokevfinal" , "bjj" , null , BasicType.getTIllegal(), -1, true, _invokevirtual); 00678 00679 def(_fast_linearswitch , "fast_linearswitch" , "" , null , BasicType.getTVoid() , -1, false, _lookupswitch ); 00680 def(_fast_binaryswitch , "fast_binaryswitch" , "" , null , BasicType.getTVoid() , -1, false, _lookupswitch ); 00681 def(_shouldnotreachhere , "_shouldnotreachhere" , "b" , null , BasicType.getTVoid() , 0, false); 00682 00683 if (Assert.ASSERTS_ENABLED) { 00684 // compare can_trap information for each bytecode with the 00685 // can_trap information for the corresponding base bytecode 00686 // (if a rewritten bytecode can trap, so must the base bytecode) 00687 for (int i = 0; i < number_of_codes; i++) { 00688 if (isDefined(i)) { 00689 int j = javaCode(i); 00690 if (canTrap(i) && !canTrap(j)) { 00691 Assert.that(false, name(i) + " can trap => " + name(j) + " can trap, too"); 00692 } 00693 } 00694 } 00695 } 00696 } 00697 00698 private static void def(int code, String name, String format, String wide_format, int result_type, int depth, boolean can_trap) { 00699 def(code, name, format, wide_format, result_type, depth, can_trap, code); 00700 } 00701 00702 private static void def(int code, String name, String format, String wide_format, int result_type, int depth, boolean can_trap, int java_code) { 00703 if (Assert.ASSERTS_ENABLED) { 00704 Assert.that(wide_format == null || format != null, "short form must exist if there's a wide form"); 00705 } 00706 _name [code] = name; 00707 _format [code] = format; 00708 _wide_format [code] = wide_format; 00709 _result_type [code] = result_type; 00710 _depth [code] = (byte) depth; 00711 _can_trap [code] = can_trap; 00712 _length [code] = (byte) (format != null ? format.length() : 0); 00713 _java_code [code] = java_code; 00714 if (java_code != code) { 00715 _can_rewrite[java_code] = true; 00716 } else { 00717 _can_rewrite[java_code] = false; 00718 } 00719 } 00720 }
