src/share/vm/interpreter/bytecodes.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 1
2d8a650513c2
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial