Thu, 11 Jul 2013 12:56:29 -0700
Merge
duke@435 | 1 | /* |
coleenp@4037 | 2 | * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_INTERPRETER_BYTECODES_HPP |
stefank@2314 | 26 | #define SHARE_VM_INTERPRETER_BYTECODES_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "memory/allocation.hpp" |
stefank@2314 | 29 | #include "utilities/top.hpp" |
stefank@2314 | 30 | |
duke@435 | 31 | // Bytecodes specifies all bytecodes used in the VM and |
duke@435 | 32 | // provides utility functions to get bytecode attributes. |
duke@435 | 33 | |
duke@435 | 34 | // NOTE: replicated in SA in vm/agent/sun/jvm/hotspot/interpreter/Bytecodes.java |
duke@435 | 35 | class Bytecodes: AllStatic { |
duke@435 | 36 | public: |
duke@435 | 37 | enum Code { |
duke@435 | 38 | _illegal = -1, |
duke@435 | 39 | |
duke@435 | 40 | // Java bytecodes |
duke@435 | 41 | _nop = 0, // 0x00 |
duke@435 | 42 | _aconst_null = 1, // 0x01 |
duke@435 | 43 | _iconst_m1 = 2, // 0x02 |
duke@435 | 44 | _iconst_0 = 3, // 0x03 |
duke@435 | 45 | _iconst_1 = 4, // 0x04 |
duke@435 | 46 | _iconst_2 = 5, // 0x05 |
duke@435 | 47 | _iconst_3 = 6, // 0x06 |
duke@435 | 48 | _iconst_4 = 7, // 0x07 |
duke@435 | 49 | _iconst_5 = 8, // 0x08 |
duke@435 | 50 | _lconst_0 = 9, // 0x09 |
duke@435 | 51 | _lconst_1 = 10, // 0x0a |
duke@435 | 52 | _fconst_0 = 11, // 0x0b |
duke@435 | 53 | _fconst_1 = 12, // 0x0c |
duke@435 | 54 | _fconst_2 = 13, // 0x0d |
duke@435 | 55 | _dconst_0 = 14, // 0x0e |
duke@435 | 56 | _dconst_1 = 15, // 0x0f |
duke@435 | 57 | _bipush = 16, // 0x10 |
duke@435 | 58 | _sipush = 17, // 0x11 |
duke@435 | 59 | _ldc = 18, // 0x12 |
duke@435 | 60 | _ldc_w = 19, // 0x13 |
duke@435 | 61 | _ldc2_w = 20, // 0x14 |
duke@435 | 62 | _iload = 21, // 0x15 |
duke@435 | 63 | _lload = 22, // 0x16 |
duke@435 | 64 | _fload = 23, // 0x17 |
duke@435 | 65 | _dload = 24, // 0x18 |
duke@435 | 66 | _aload = 25, // 0x19 |
duke@435 | 67 | _iload_0 = 26, // 0x1a |
duke@435 | 68 | _iload_1 = 27, // 0x1b |
duke@435 | 69 | _iload_2 = 28, // 0x1c |
duke@435 | 70 | _iload_3 = 29, // 0x1d |
duke@435 | 71 | _lload_0 = 30, // 0x1e |
duke@435 | 72 | _lload_1 = 31, // 0x1f |
duke@435 | 73 | _lload_2 = 32, // 0x20 |
duke@435 | 74 | _lload_3 = 33, // 0x21 |
duke@435 | 75 | _fload_0 = 34, // 0x22 |
duke@435 | 76 | _fload_1 = 35, // 0x23 |
duke@435 | 77 | _fload_2 = 36, // 0x24 |
duke@435 | 78 | _fload_3 = 37, // 0x25 |
duke@435 | 79 | _dload_0 = 38, // 0x26 |
duke@435 | 80 | _dload_1 = 39, // 0x27 |
duke@435 | 81 | _dload_2 = 40, // 0x28 |
duke@435 | 82 | _dload_3 = 41, // 0x29 |
duke@435 | 83 | _aload_0 = 42, // 0x2a |
duke@435 | 84 | _aload_1 = 43, // 0x2b |
duke@435 | 85 | _aload_2 = 44, // 0x2c |
duke@435 | 86 | _aload_3 = 45, // 0x2d |
duke@435 | 87 | _iaload = 46, // 0x2e |
duke@435 | 88 | _laload = 47, // 0x2f |
duke@435 | 89 | _faload = 48, // 0x30 |
duke@435 | 90 | _daload = 49, // 0x31 |
duke@435 | 91 | _aaload = 50, // 0x32 |
duke@435 | 92 | _baload = 51, // 0x33 |
duke@435 | 93 | _caload = 52, // 0x34 |
duke@435 | 94 | _saload = 53, // 0x35 |
duke@435 | 95 | _istore = 54, // 0x36 |
duke@435 | 96 | _lstore = 55, // 0x37 |
duke@435 | 97 | _fstore = 56, // 0x38 |
duke@435 | 98 | _dstore = 57, // 0x39 |
duke@435 | 99 | _astore = 58, // 0x3a |
duke@435 | 100 | _istore_0 = 59, // 0x3b |
duke@435 | 101 | _istore_1 = 60, // 0x3c |
duke@435 | 102 | _istore_2 = 61, // 0x3d |
duke@435 | 103 | _istore_3 = 62, // 0x3e |
duke@435 | 104 | _lstore_0 = 63, // 0x3f |
duke@435 | 105 | _lstore_1 = 64, // 0x40 |
duke@435 | 106 | _lstore_2 = 65, // 0x41 |
duke@435 | 107 | _lstore_3 = 66, // 0x42 |
duke@435 | 108 | _fstore_0 = 67, // 0x43 |
duke@435 | 109 | _fstore_1 = 68, // 0x44 |
duke@435 | 110 | _fstore_2 = 69, // 0x45 |
duke@435 | 111 | _fstore_3 = 70, // 0x46 |
duke@435 | 112 | _dstore_0 = 71, // 0x47 |
duke@435 | 113 | _dstore_1 = 72, // 0x48 |
duke@435 | 114 | _dstore_2 = 73, // 0x49 |
duke@435 | 115 | _dstore_3 = 74, // 0x4a |
duke@435 | 116 | _astore_0 = 75, // 0x4b |
duke@435 | 117 | _astore_1 = 76, // 0x4c |
duke@435 | 118 | _astore_2 = 77, // 0x4d |
duke@435 | 119 | _astore_3 = 78, // 0x4e |
duke@435 | 120 | _iastore = 79, // 0x4f |
duke@435 | 121 | _lastore = 80, // 0x50 |
duke@435 | 122 | _fastore = 81, // 0x51 |
duke@435 | 123 | _dastore = 82, // 0x52 |
duke@435 | 124 | _aastore = 83, // 0x53 |
duke@435 | 125 | _bastore = 84, // 0x54 |
duke@435 | 126 | _castore = 85, // 0x55 |
duke@435 | 127 | _sastore = 86, // 0x56 |
duke@435 | 128 | _pop = 87, // 0x57 |
duke@435 | 129 | _pop2 = 88, // 0x58 |
duke@435 | 130 | _dup = 89, // 0x59 |
duke@435 | 131 | _dup_x1 = 90, // 0x5a |
duke@435 | 132 | _dup_x2 = 91, // 0x5b |
duke@435 | 133 | _dup2 = 92, // 0x5c |
duke@435 | 134 | _dup2_x1 = 93, // 0x5d |
duke@435 | 135 | _dup2_x2 = 94, // 0x5e |
duke@435 | 136 | _swap = 95, // 0x5f |
duke@435 | 137 | _iadd = 96, // 0x60 |
duke@435 | 138 | _ladd = 97, // 0x61 |
duke@435 | 139 | _fadd = 98, // 0x62 |
duke@435 | 140 | _dadd = 99, // 0x63 |
duke@435 | 141 | _isub = 100, // 0x64 |
duke@435 | 142 | _lsub = 101, // 0x65 |
duke@435 | 143 | _fsub = 102, // 0x66 |
duke@435 | 144 | _dsub = 103, // 0x67 |
duke@435 | 145 | _imul = 104, // 0x68 |
duke@435 | 146 | _lmul = 105, // 0x69 |
duke@435 | 147 | _fmul = 106, // 0x6a |
duke@435 | 148 | _dmul = 107, // 0x6b |
duke@435 | 149 | _idiv = 108, // 0x6c |
duke@435 | 150 | _ldiv = 109, // 0x6d |
duke@435 | 151 | _fdiv = 110, // 0x6e |
duke@435 | 152 | _ddiv = 111, // 0x6f |
duke@435 | 153 | _irem = 112, // 0x70 |
duke@435 | 154 | _lrem = 113, // 0x71 |
duke@435 | 155 | _frem = 114, // 0x72 |
duke@435 | 156 | _drem = 115, // 0x73 |
duke@435 | 157 | _ineg = 116, // 0x74 |
duke@435 | 158 | _lneg = 117, // 0x75 |
duke@435 | 159 | _fneg = 118, // 0x76 |
duke@435 | 160 | _dneg = 119, // 0x77 |
duke@435 | 161 | _ishl = 120, // 0x78 |
duke@435 | 162 | _lshl = 121, // 0x79 |
duke@435 | 163 | _ishr = 122, // 0x7a |
duke@435 | 164 | _lshr = 123, // 0x7b |
duke@435 | 165 | _iushr = 124, // 0x7c |
duke@435 | 166 | _lushr = 125, // 0x7d |
duke@435 | 167 | _iand = 126, // 0x7e |
duke@435 | 168 | _land = 127, // 0x7f |
duke@435 | 169 | _ior = 128, // 0x80 |
duke@435 | 170 | _lor = 129, // 0x81 |
duke@435 | 171 | _ixor = 130, // 0x82 |
duke@435 | 172 | _lxor = 131, // 0x83 |
duke@435 | 173 | _iinc = 132, // 0x84 |
duke@435 | 174 | _i2l = 133, // 0x85 |
duke@435 | 175 | _i2f = 134, // 0x86 |
duke@435 | 176 | _i2d = 135, // 0x87 |
duke@435 | 177 | _l2i = 136, // 0x88 |
duke@435 | 178 | _l2f = 137, // 0x89 |
duke@435 | 179 | _l2d = 138, // 0x8a |
duke@435 | 180 | _f2i = 139, // 0x8b |
duke@435 | 181 | _f2l = 140, // 0x8c |
duke@435 | 182 | _f2d = 141, // 0x8d |
duke@435 | 183 | _d2i = 142, // 0x8e |
duke@435 | 184 | _d2l = 143, // 0x8f |
duke@435 | 185 | _d2f = 144, // 0x90 |
duke@435 | 186 | _i2b = 145, // 0x91 |
duke@435 | 187 | _i2c = 146, // 0x92 |
duke@435 | 188 | _i2s = 147, // 0x93 |
duke@435 | 189 | _lcmp = 148, // 0x94 |
duke@435 | 190 | _fcmpl = 149, // 0x95 |
duke@435 | 191 | _fcmpg = 150, // 0x96 |
duke@435 | 192 | _dcmpl = 151, // 0x97 |
duke@435 | 193 | _dcmpg = 152, // 0x98 |
duke@435 | 194 | _ifeq = 153, // 0x99 |
duke@435 | 195 | _ifne = 154, // 0x9a |
duke@435 | 196 | _iflt = 155, // 0x9b |
duke@435 | 197 | _ifge = 156, // 0x9c |
duke@435 | 198 | _ifgt = 157, // 0x9d |
duke@435 | 199 | _ifle = 158, // 0x9e |
duke@435 | 200 | _if_icmpeq = 159, // 0x9f |
duke@435 | 201 | _if_icmpne = 160, // 0xa0 |
duke@435 | 202 | _if_icmplt = 161, // 0xa1 |
duke@435 | 203 | _if_icmpge = 162, // 0xa2 |
duke@435 | 204 | _if_icmpgt = 163, // 0xa3 |
duke@435 | 205 | _if_icmple = 164, // 0xa4 |
duke@435 | 206 | _if_acmpeq = 165, // 0xa5 |
duke@435 | 207 | _if_acmpne = 166, // 0xa6 |
duke@435 | 208 | _goto = 167, // 0xa7 |
duke@435 | 209 | _jsr = 168, // 0xa8 |
duke@435 | 210 | _ret = 169, // 0xa9 |
duke@435 | 211 | _tableswitch = 170, // 0xaa |
duke@435 | 212 | _lookupswitch = 171, // 0xab |
duke@435 | 213 | _ireturn = 172, // 0xac |
duke@435 | 214 | _lreturn = 173, // 0xad |
duke@435 | 215 | _freturn = 174, // 0xae |
duke@435 | 216 | _dreturn = 175, // 0xaf |
duke@435 | 217 | _areturn = 176, // 0xb0 |
duke@435 | 218 | _return = 177, // 0xb1 |
duke@435 | 219 | _getstatic = 178, // 0xb2 |
duke@435 | 220 | _putstatic = 179, // 0xb3 |
duke@435 | 221 | _getfield = 180, // 0xb4 |
duke@435 | 222 | _putfield = 181, // 0xb5 |
duke@435 | 223 | _invokevirtual = 182, // 0xb6 |
duke@435 | 224 | _invokespecial = 183, // 0xb7 |
duke@435 | 225 | _invokestatic = 184, // 0xb8 |
duke@435 | 226 | _invokeinterface = 185, // 0xb9 |
jrose@1161 | 227 | _invokedynamic = 186, // 0xba // if EnableInvokeDynamic |
duke@435 | 228 | _new = 187, // 0xbb |
duke@435 | 229 | _newarray = 188, // 0xbc |
duke@435 | 230 | _anewarray = 189, // 0xbd |
duke@435 | 231 | _arraylength = 190, // 0xbe |
duke@435 | 232 | _athrow = 191, // 0xbf |
duke@435 | 233 | _checkcast = 192, // 0xc0 |
duke@435 | 234 | _instanceof = 193, // 0xc1 |
duke@435 | 235 | _monitorenter = 194, // 0xc2 |
duke@435 | 236 | _monitorexit = 195, // 0xc3 |
duke@435 | 237 | _wide = 196, // 0xc4 |
duke@435 | 238 | _multianewarray = 197, // 0xc5 |
duke@435 | 239 | _ifnull = 198, // 0xc6 |
duke@435 | 240 | _ifnonnull = 199, // 0xc7 |
duke@435 | 241 | _goto_w = 200, // 0xc8 |
duke@435 | 242 | _jsr_w = 201, // 0xc9 |
duke@435 | 243 | _breakpoint = 202, // 0xca |
duke@435 | 244 | |
duke@435 | 245 | number_of_java_codes, |
duke@435 | 246 | |
duke@435 | 247 | // JVM bytecodes |
duke@435 | 248 | _fast_agetfield = number_of_java_codes, |
duke@435 | 249 | _fast_bgetfield , |
duke@435 | 250 | _fast_cgetfield , |
duke@435 | 251 | _fast_dgetfield , |
duke@435 | 252 | _fast_fgetfield , |
duke@435 | 253 | _fast_igetfield , |
duke@435 | 254 | _fast_lgetfield , |
duke@435 | 255 | _fast_sgetfield , |
duke@435 | 256 | |
duke@435 | 257 | _fast_aputfield , |
duke@435 | 258 | _fast_bputfield , |
duke@435 | 259 | _fast_cputfield , |
duke@435 | 260 | _fast_dputfield , |
duke@435 | 261 | _fast_fputfield , |
duke@435 | 262 | _fast_iputfield , |
duke@435 | 263 | _fast_lputfield , |
duke@435 | 264 | _fast_sputfield , |
duke@435 | 265 | |
duke@435 | 266 | _fast_aload_0 , |
duke@435 | 267 | _fast_iaccess_0 , |
duke@435 | 268 | _fast_aaccess_0 , |
duke@435 | 269 | _fast_faccess_0 , |
duke@435 | 270 | |
duke@435 | 271 | _fast_iload , |
duke@435 | 272 | _fast_iload2 , |
duke@435 | 273 | _fast_icaload , |
duke@435 | 274 | |
duke@435 | 275 | _fast_invokevfinal , |
duke@435 | 276 | _fast_linearswitch , |
duke@435 | 277 | _fast_binaryswitch , |
duke@435 | 278 | |
jrose@1957 | 279 | // special handling of oop constants: |
jrose@1957 | 280 | _fast_aldc , |
jrose@1957 | 281 | _fast_aldc_w , |
jrose@1957 | 282 | |
duke@435 | 283 | _return_register_finalizer , |
duke@435 | 284 | |
twisti@3969 | 285 | // special handling of signature-polymorphic methods: |
twisti@3969 | 286 | _invokehandle , |
twisti@3969 | 287 | |
duke@435 | 288 | _shouldnotreachhere, // For debugging |
duke@435 | 289 | |
duke@435 | 290 | // Platform specific JVM bytecodes |
stefank@2314 | 291 | #ifdef TARGET_ARCH_x86 |
stefank@2314 | 292 | # include "bytecodes_x86.hpp" |
stefank@2314 | 293 | #endif |
stefank@2314 | 294 | #ifdef TARGET_ARCH_sparc |
stefank@2314 | 295 | # include "bytecodes_sparc.hpp" |
stefank@2314 | 296 | #endif |
stefank@2314 | 297 | #ifdef TARGET_ARCH_zero |
stefank@2314 | 298 | # include "bytecodes_zero.hpp" |
stefank@2314 | 299 | #endif |
bobv@2508 | 300 | #ifdef TARGET_ARCH_arm |
bobv@2508 | 301 | # include "bytecodes_arm.hpp" |
bobv@2508 | 302 | #endif |
bobv@2508 | 303 | #ifdef TARGET_ARCH_ppc |
bobv@2508 | 304 | # include "bytecodes_ppc.hpp" |
bobv@2508 | 305 | #endif |
stefank@2314 | 306 | |
duke@435 | 307 | |
duke@435 | 308 | number_of_codes |
duke@435 | 309 | }; |
duke@435 | 310 | |
jrose@1920 | 311 | // Flag bits derived from format strings, can_trap, can_rewrite, etc.: |
jrose@1920 | 312 | enum Flags { |
jrose@1920 | 313 | // semantic flags: |
jrose@1920 | 314 | _bc_can_trap = 1<<0, // bytecode execution can trap or block |
jrose@1920 | 315 | _bc_can_rewrite = 1<<1, // bytecode execution has an alternate form |
jrose@1920 | 316 | |
jrose@1920 | 317 | // format bits (determined only by the format string): |
jrose@1920 | 318 | _fmt_has_c = 1<<2, // constant, such as sipush "bcc" |
jrose@1920 | 319 | _fmt_has_j = 1<<3, // constant pool cache index, such as getfield "bjj" |
jrose@1920 | 320 | _fmt_has_k = 1<<4, // constant pool index, such as ldc "bk" |
jrose@1920 | 321 | _fmt_has_i = 1<<5, // local index, such as iload |
jrose@1920 | 322 | _fmt_has_o = 1<<6, // offset, such as ifeq |
jrose@1920 | 323 | _fmt_has_nbo = 1<<7, // contains native-order field(s) |
jrose@1920 | 324 | _fmt_has_u2 = 1<<8, // contains double-byte field(s) |
jrose@1920 | 325 | _fmt_has_u4 = 1<<9, // contains quad-byte field |
jrose@1920 | 326 | _fmt_not_variable = 1<<10, // not of variable length (simple or wide) |
jrose@1920 | 327 | _fmt_not_simple = 1<<11, // either wide or variable length |
jrose@1920 | 328 | _all_fmt_bits = (_fmt_not_simple*2 - _fmt_has_c), |
jrose@1920 | 329 | |
jrose@1920 | 330 | // Example derived format syndromes: |
jrose@1920 | 331 | _fmt_b = _fmt_not_variable, |
jrose@1920 | 332 | _fmt_bc = _fmt_b | _fmt_has_c, |
jrose@1920 | 333 | _fmt_bi = _fmt_b | _fmt_has_i, |
jrose@1920 | 334 | _fmt_bkk = _fmt_b | _fmt_has_k | _fmt_has_u2, |
jrose@1920 | 335 | _fmt_bJJ = _fmt_b | _fmt_has_j | _fmt_has_u2 | _fmt_has_nbo, |
jrose@1920 | 336 | _fmt_bo2 = _fmt_b | _fmt_has_o | _fmt_has_u2, |
jrose@1920 | 337 | _fmt_bo4 = _fmt_b | _fmt_has_o | _fmt_has_u4 |
jrose@1920 | 338 | }; |
jrose@1920 | 339 | |
duke@435 | 340 | private: |
duke@435 | 341 | static bool _is_initialized; |
duke@435 | 342 | static const char* _name [number_of_codes]; |
duke@435 | 343 | static BasicType _result_type [number_of_codes]; |
duke@435 | 344 | static s_char _depth [number_of_codes]; |
jrose@1920 | 345 | static u_char _lengths [number_of_codes]; |
duke@435 | 346 | static Code _java_code [number_of_codes]; |
jrose@1920 | 347 | static jchar _flags [(1<<BitsPerByte)*2]; // all second page for wide formats |
duke@435 | 348 | |
duke@435 | 349 | static void def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap); |
duke@435 | 350 | static void def(Code code, const char* name, const char* format, const char* wide_format, BasicType result_type, int depth, bool can_trap, Code java_code); |
duke@435 | 351 | static void pd_initialize(); // platform specific initialization |
duke@435 | 352 | static Code pd_base_code_for(Code code); // platform specific base_code_for implementation |
duke@435 | 353 | |
never@2462 | 354 | // Verify that bcp points into method |
never@2462 | 355 | #ifdef ASSERT |
coleenp@4037 | 356 | static bool check_method(const Method* method, address bcp); |
never@2462 | 357 | #endif |
never@2462 | 358 | static bool check_must_rewrite(Bytecodes::Code bc); |
never@2462 | 359 | |
duke@435 | 360 | public: |
duke@435 | 361 | // Conversion |
twisti@3969 | 362 | static void check (Code code) { assert(is_defined(code), err_msg("illegal code: %d", (int)code)); } |
twisti@3969 | 363 | static void wide_check (Code code) { assert(wide_is_defined(code), err_msg("illegal code: %d", (int)code)); } |
duke@435 | 364 | static Code cast (int code) { return (Code)code; } |
duke@435 | 365 | |
duke@435 | 366 | |
never@2462 | 367 | // Fetch a bytecode, hiding breakpoints as necessary. The method |
never@2462 | 368 | // argument is used for conversion of breakpoints into the original |
never@2462 | 369 | // bytecode. The CI uses these methods but guarantees that |
never@2462 | 370 | // breakpoints are hidden so the method argument should be passed as |
coleenp@4037 | 371 | // NULL since in that case the bcp and Method* are unrelated |
never@2462 | 372 | // memory. |
coleenp@4037 | 373 | static Code code_at(const Method* method, address bcp) { |
never@2462 | 374 | assert(method == NULL || check_method(method, bcp), "bcp must point into method"); |
never@2462 | 375 | Code code = cast(*bcp); |
coleenp@4037 | 376 | assert(code != _breakpoint || method != NULL, "need Method* to decode breakpoint"); |
never@2462 | 377 | return (code != _breakpoint) ? code : non_breakpoint_code_at(method, bcp); |
never@2462 | 378 | } |
coleenp@4037 | 379 | static Code java_code_at(const Method* method, address bcp) { |
never@2462 | 380 | return java_code(code_at(method, bcp)); |
never@2462 | 381 | } |
duke@435 | 382 | |
never@2462 | 383 | // Fetch a bytecode or a breakpoint: |
never@2462 | 384 | static Code code_or_bp_at(address bcp) { return (Code)cast(*bcp); } |
duke@435 | 385 | |
coleenp@4037 | 386 | static Code code_at(Method* method, int bci); |
never@2462 | 387 | static bool is_active_breakpoint_at(address bcp) { return (Code)*bcp == _breakpoint; } |
duke@435 | 388 | |
never@2462 | 389 | // find a bytecode, behind a breakpoint if necessary: |
coleenp@4037 | 390 | static Code non_breakpoint_code_at(const Method* method, address bcp); |
duke@435 | 391 | |
duke@435 | 392 | // Bytecode attributes |
jrose@1920 | 393 | static bool is_defined (int code) { return 0 <= code && code < number_of_codes && flags(code, false) != 0; } |
jrose@1920 | 394 | static bool wide_is_defined(int code) { return is_defined(code) && flags(code, true) != 0; } |
duke@435 | 395 | static const char* name (Code code) { check(code); return _name [code]; } |
duke@435 | 396 | static BasicType result_type (Code code) { check(code); return _result_type [code]; } |
duke@435 | 397 | static int depth (Code code) { check(code); return _depth [code]; } |
jrose@1925 | 398 | // Note: Length functions must return <=0 for invalid bytecodes. |
jrose@1925 | 399 | // Calling check(code) in length functions would throw an unwanted assert. |
jrose@1925 | 400 | static int length_for (Code code) { /*no check*/ return _lengths [code] & 0xF; } |
jrose@1925 | 401 | static int wide_length_for(Code code) { /*no check*/ return _lengths [code] >> 4; } |
jrose@1920 | 402 | static bool can_trap (Code code) { check(code); return has_all_flags(code, _bc_can_trap, false); } |
duke@435 | 403 | static Code java_code (Code code) { check(code); return _java_code [code]; } |
jrose@1920 | 404 | static bool can_rewrite (Code code) { check(code); return has_all_flags(code, _bc_can_rewrite, false); } |
never@2462 | 405 | static bool must_rewrite(Bytecodes::Code code) { return can_rewrite(code) && check_must_rewrite(code); } |
jrose@1920 | 406 | static bool native_byte_order(Code code) { check(code); return has_all_flags(code, _fmt_has_nbo, false); } |
jrose@1920 | 407 | static bool uses_cp_cache (Code code) { check(code); return has_all_flags(code, _fmt_has_j, false); } |
kamg@848 | 408 | // if 'end' is provided, it indicates the end of the code buffer which |
kamg@848 | 409 | // should not be read past when parsing. |
never@2462 | 410 | static int special_length_at(Bytecodes::Code code, address bcp, address end = NULL); |
coleenp@4037 | 411 | static int special_length_at(Method* method, address bcp, address end = NULL) { return special_length_at(code_at(method, bcp), bcp, end); } |
kamg@848 | 412 | static int raw_special_length_at(address bcp, address end = NULL); |
never@2462 | 413 | static int length_for_code_at(Bytecodes::Code code, address bcp) { int l = length_for(code); return l > 0 ? l : special_length_at(code, bcp); } |
coleenp@4037 | 414 | static int length_at (Method* method, address bcp) { return length_for_code_at(code_at(method, bcp), bcp); } |
coleenp@4037 | 415 | static int java_length_at (Method* method, address bcp) { return length_for_code_at(java_code_at(method, bcp), bcp); } |
duke@435 | 416 | static bool is_java_code (Code code) { return 0 <= code && code < number_of_java_codes; } |
duke@435 | 417 | |
duke@435 | 418 | static bool is_aload (Code code) { return (code == _aload || code == _aload_0 || code == _aload_1 |
duke@435 | 419 | || code == _aload_2 || code == _aload_3); } |
duke@435 | 420 | static bool is_astore (Code code) { return (code == _astore || code == _astore_0 || code == _astore_1 |
duke@435 | 421 | || code == _astore_2 || code == _astore_3); } |
duke@435 | 422 | |
duke@435 | 423 | static bool is_zero_const (Code code) { return (code == _aconst_null || code == _iconst_0 |
duke@435 | 424 | || code == _fconst_0 || code == _dconst_0); } |
twisti@3097 | 425 | static bool is_invoke (Code code) { return (_invokevirtual <= code && code <= _invokedynamic); } |
twisti@4313 | 426 | static bool has_receiver (Code code) { assert(is_invoke(code), ""); return code == _invokevirtual || |
twisti@4313 | 427 | code == _invokespecial || |
twisti@4313 | 428 | code == _invokeinterface; } |
twisti@4021 | 429 | static bool has_optional_appendix(Code code) { return code == _invokedynamic || code == _invokehandle; } |
twisti@4021 | 430 | |
jrose@1920 | 431 | static int compute_flags (const char* format, int more_flags = 0); // compute the flags |
jrose@1920 | 432 | static int flags (int code, bool is_wide) { |
jrose@1920 | 433 | assert(code == (u_char)code, "must be a byte"); |
jrose@1920 | 434 | return _flags[code + (is_wide ? (1<<BitsPerByte) : 0)]; |
jrose@1920 | 435 | } |
jrose@1920 | 436 | static int format_bits (Code code, bool is_wide) { return flags(code, is_wide) & _all_fmt_bits; } |
jrose@1920 | 437 | static bool has_all_flags (Code code, int test_flags, bool is_wide) { |
jrose@1920 | 438 | return (flags(code, is_wide) & test_flags) == test_flags; |
jrose@1920 | 439 | } |
jrose@1920 | 440 | |
duke@435 | 441 | // Initialization |
duke@435 | 442 | static void initialize (); |
duke@435 | 443 | }; |
stefank@2314 | 444 | |
stefank@2314 | 445 | #endif // SHARE_VM_INTERPRETER_BYTECODES_HPP |