Wed, 03 Jul 2019 20:42:37 +0800
Merge
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@1 | 25 | /* |
aoqi@1 | 26 | * This file has been modified by Loongson Technology in 2015. These |
aoqi@1 | 27 | * modifications are Copyright (c) 2015 Loongson Technology, and are made |
aoqi@1 | 28 | * available on the same license terms set forth above. |
aoqi@1 | 29 | */ |
aoqi@1 | 30 | |
aoqi@0 | 31 | #ifndef SHARE_VM_INTERPRETER_BYTECODE_HPP |
aoqi@0 | 32 | #define SHARE_VM_INTERPRETER_BYTECODE_HPP |
aoqi@0 | 33 | |
aoqi@0 | 34 | #include "interpreter/bytecodes.hpp" |
aoqi@0 | 35 | #include "memory/allocation.hpp" |
aoqi@0 | 36 | #include "oops/method.hpp" |
aoqi@0 | 37 | #ifdef TARGET_ARCH_x86 |
aoqi@0 | 38 | # include "bytes_x86.hpp" |
aoqi@0 | 39 | #endif |
aoqi@1 | 40 | #ifdef TARGET_ARCH_mips |
aoqi@1 | 41 | # include "bytes_mips.hpp" |
aoqi@1 | 42 | #endif |
aoqi@0 | 43 | #ifdef TARGET_ARCH_sparc |
aoqi@0 | 44 | # include "bytes_sparc.hpp" |
aoqi@0 | 45 | #endif |
aoqi@0 | 46 | #ifdef TARGET_ARCH_zero |
aoqi@0 | 47 | # include "bytes_zero.hpp" |
aoqi@0 | 48 | #endif |
aoqi@0 | 49 | #ifdef TARGET_ARCH_arm |
aoqi@0 | 50 | # include "bytes_arm.hpp" |
aoqi@0 | 51 | #endif |
aoqi@0 | 52 | #ifdef TARGET_ARCH_ppc |
aoqi@0 | 53 | # include "bytes_ppc.hpp" |
aoqi@0 | 54 | #endif |
aoqi@0 | 55 | |
aoqi@0 | 56 | class ciBytecodeStream; |
aoqi@0 | 57 | |
aoqi@0 | 58 | // The base class for different kinds of bytecode abstractions. |
aoqi@0 | 59 | // Provides the primitive operations to manipulate code relative |
aoqi@0 | 60 | // to the bcp. |
aoqi@0 | 61 | |
aoqi@0 | 62 | class Bytecode: public StackObj { |
aoqi@0 | 63 | protected: |
aoqi@0 | 64 | const address _bcp; |
aoqi@0 | 65 | const Bytecodes::Code _code; |
aoqi@0 | 66 | |
aoqi@0 | 67 | // Address computation |
aoqi@0 | 68 | address addr_at (int offset) const { return (address)_bcp + offset; } |
aoqi@0 | 69 | u_char byte_at(int offset) const { return *addr_at(offset); } |
aoqi@0 | 70 | address aligned_addr_at (int offset) const { return (address)round_to((intptr_t)addr_at(offset), jintSize); } |
aoqi@0 | 71 | int aligned_offset (int offset) const { return aligned_addr_at(offset) - addr_at(0); } |
aoqi@0 | 72 | |
aoqi@0 | 73 | // Word access: |
aoqi@0 | 74 | int get_Java_u2_at (int offset) const { return Bytes::get_Java_u2(addr_at(offset)); } |
aoqi@0 | 75 | int get_Java_u4_at (int offset) const { return Bytes::get_Java_u4(addr_at(offset)); } |
aoqi@0 | 76 | int get_native_u2_at (int offset) const { return Bytes::get_native_u2(addr_at(offset)); } |
aoqi@0 | 77 | int get_native_u4_at (int offset) const { return Bytes::get_native_u4(addr_at(offset)); } |
aoqi@0 | 78 | |
aoqi@0 | 79 | public: |
aoqi@0 | 80 | Bytecode(Method* method, address bcp): _bcp(bcp), _code(Bytecodes::code_at(method, addr_at(0))) { |
aoqi@0 | 81 | assert(method != NULL, "this form requires a valid Method*"); |
aoqi@0 | 82 | } |
aoqi@0 | 83 | // Defined in ciStreams.hpp |
aoqi@0 | 84 | inline Bytecode(const ciBytecodeStream* stream, address bcp = NULL); |
aoqi@0 | 85 | |
aoqi@0 | 86 | // Attributes |
aoqi@0 | 87 | address bcp() const { return _bcp; } |
aoqi@0 | 88 | int instruction_size() const { return Bytecodes::length_for_code_at(_code, bcp()); } |
aoqi@0 | 89 | |
aoqi@0 | 90 | Bytecodes::Code code() const { return _code; } |
aoqi@0 | 91 | Bytecodes::Code java_code() const { return Bytecodes::java_code(code()); } |
aoqi@0 | 92 | Bytecodes::Code invoke_code() const { return (code() == Bytecodes::_invokehandle) ? code() : java_code(); } |
aoqi@0 | 93 | |
aoqi@0 | 94 | // Static functions for parsing bytecodes in place. |
aoqi@0 | 95 | int get_index_u1(Bytecodes::Code bc) const { |
aoqi@0 | 96 | assert_same_format_as(bc); assert_index_size(1, bc); |
aoqi@0 | 97 | return *(jubyte*)addr_at(1); |
aoqi@0 | 98 | } |
aoqi@0 | 99 | int get_index_u2(Bytecodes::Code bc, bool is_wide = false) const { |
aoqi@0 | 100 | assert_same_format_as(bc, is_wide); assert_index_size(2, bc, is_wide); |
aoqi@0 | 101 | address p = addr_at(is_wide ? 2 : 1); |
aoqi@0 | 102 | if (can_use_native_byte_order(bc, is_wide)) |
aoqi@0 | 103 | return Bytes::get_native_u2(p); |
aoqi@0 | 104 | else return Bytes::get_Java_u2(p); |
aoqi@0 | 105 | } |
aoqi@0 | 106 | int get_index_u1_cpcache(Bytecodes::Code bc) const { |
aoqi@0 | 107 | assert_same_format_as(bc); assert_index_size(1, bc); |
aoqi@0 | 108 | return *(jubyte*)addr_at(1) + ConstantPool::CPCACHE_INDEX_TAG; |
aoqi@0 | 109 | } |
aoqi@0 | 110 | int get_index_u2_cpcache(Bytecodes::Code bc) const { |
aoqi@0 | 111 | assert_same_format_as(bc); assert_index_size(2, bc); assert_native_index(bc); |
aoqi@0 | 112 | return Bytes::get_native_u2(addr_at(1)) + ConstantPool::CPCACHE_INDEX_TAG; |
aoqi@0 | 113 | } |
aoqi@0 | 114 | int get_index_u4(Bytecodes::Code bc) const { |
aoqi@0 | 115 | assert_same_format_as(bc); assert_index_size(4, bc); |
aoqi@0 | 116 | assert(can_use_native_byte_order(bc), ""); |
aoqi@0 | 117 | return Bytes::get_native_u4(addr_at(1)); |
aoqi@0 | 118 | } |
aoqi@0 | 119 | bool has_index_u4(Bytecodes::Code bc) const { |
aoqi@0 | 120 | return bc == Bytecodes::_invokedynamic; |
aoqi@0 | 121 | } |
aoqi@0 | 122 | |
aoqi@0 | 123 | int get_offset_s2(Bytecodes::Code bc) const { |
aoqi@0 | 124 | assert_same_format_as(bc); assert_offset_size(2, bc); |
aoqi@0 | 125 | return (jshort) Bytes::get_Java_u2(addr_at(1)); |
aoqi@0 | 126 | } |
aoqi@0 | 127 | int get_offset_s4(Bytecodes::Code bc) const { |
aoqi@0 | 128 | assert_same_format_as(bc); assert_offset_size(4, bc); |
aoqi@0 | 129 | return (jint) Bytes::get_Java_u4(addr_at(1)); |
aoqi@0 | 130 | } |
aoqi@0 | 131 | |
aoqi@0 | 132 | int get_constant_u1(int offset, Bytecodes::Code bc) const { |
aoqi@0 | 133 | assert_same_format_as(bc); assert_constant_size(1, offset, bc); |
aoqi@0 | 134 | return *(jbyte*)addr_at(offset); |
aoqi@0 | 135 | } |
aoqi@0 | 136 | int get_constant_u2(int offset, Bytecodes::Code bc, bool is_wide = false) const { |
aoqi@0 | 137 | assert_same_format_as(bc, is_wide); assert_constant_size(2, offset, bc, is_wide); |
aoqi@0 | 138 | return (jshort) Bytes::get_Java_u2(addr_at(offset)); |
aoqi@0 | 139 | } |
aoqi@0 | 140 | |
aoqi@0 | 141 | // These are used locally and also from bytecode streams. |
aoqi@0 | 142 | void assert_same_format_as(Bytecodes::Code testbc, bool is_wide = false) const NOT_DEBUG_RETURN; |
aoqi@0 | 143 | static void assert_index_size(int required_size, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN; |
aoqi@0 | 144 | static void assert_offset_size(int required_size, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN; |
aoqi@0 | 145 | static void assert_constant_size(int required_size, int where, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN; |
aoqi@0 | 146 | static void assert_native_index(Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN; |
aoqi@0 | 147 | static bool can_use_native_byte_order(Bytecodes::Code bc, bool is_wide = false) { |
aoqi@0 | 148 | return (!Bytes::is_Java_byte_ordering_different() || Bytecodes::native_byte_order(bc /*, is_wide*/)); |
aoqi@0 | 149 | } |
aoqi@0 | 150 | }; |
aoqi@0 | 151 | |
aoqi@0 | 152 | |
aoqi@0 | 153 | // Abstractions for lookupswitch bytecode |
aoqi@0 | 154 | class LookupswitchPair VALUE_OBJ_CLASS_SPEC { |
aoqi@0 | 155 | private: |
aoqi@0 | 156 | const address _bcp; |
aoqi@0 | 157 | |
aoqi@0 | 158 | address addr_at (int offset) const { return _bcp + offset; } |
aoqi@0 | 159 | int get_Java_u4_at (int offset) const { return Bytes::get_Java_u4(addr_at(offset)); } |
aoqi@0 | 160 | |
aoqi@0 | 161 | public: |
aoqi@0 | 162 | LookupswitchPair(address bcp): _bcp(bcp) {} |
aoqi@0 | 163 | int match() const { return get_Java_u4_at(0 * jintSize); } |
aoqi@0 | 164 | int offset() const { return get_Java_u4_at(1 * jintSize); } |
aoqi@0 | 165 | }; |
aoqi@0 | 166 | |
aoqi@0 | 167 | |
aoqi@0 | 168 | class Bytecode_lookupswitch: public Bytecode { |
aoqi@0 | 169 | public: |
aoqi@0 | 170 | Bytecode_lookupswitch(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
aoqi@0 | 171 | // Defined in ciStreams.hpp |
aoqi@0 | 172 | inline Bytecode_lookupswitch(const ciBytecodeStream* stream); |
aoqi@0 | 173 | void verify() const PRODUCT_RETURN; |
aoqi@0 | 174 | |
aoqi@0 | 175 | // Attributes |
aoqi@0 | 176 | int default_offset() const { return get_Java_u4_at(aligned_offset(1 + 0*jintSize)); } |
aoqi@0 | 177 | int number_of_pairs() const { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); } |
aoqi@0 | 178 | LookupswitchPair pair_at(int i) const { |
aoqi@0 | 179 | assert(0 <= i && i < number_of_pairs(), "pair index out of bounds"); |
aoqi@0 | 180 | return LookupswitchPair(aligned_addr_at(1 + (1 + i)*2*jintSize)); |
aoqi@0 | 181 | } |
aoqi@0 | 182 | }; |
aoqi@0 | 183 | |
aoqi@0 | 184 | class Bytecode_tableswitch: public Bytecode { |
aoqi@0 | 185 | public: |
aoqi@0 | 186 | Bytecode_tableswitch(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
aoqi@0 | 187 | // Defined in ciStreams.hpp |
aoqi@0 | 188 | inline Bytecode_tableswitch(const ciBytecodeStream* stream); |
aoqi@0 | 189 | void verify() const PRODUCT_RETURN; |
aoqi@0 | 190 | |
aoqi@0 | 191 | // Attributes |
aoqi@0 | 192 | int default_offset() const { return get_Java_u4_at(aligned_offset(1 + 0*jintSize)); } |
aoqi@0 | 193 | int low_key() const { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); } |
aoqi@0 | 194 | int high_key() const { return get_Java_u4_at(aligned_offset(1 + 2*jintSize)); } |
aoqi@0 | 195 | int dest_offset_at(int i) const; |
aoqi@0 | 196 | int length() { return high_key()-low_key()+1; } |
aoqi@0 | 197 | }; |
aoqi@0 | 198 | |
aoqi@0 | 199 | // Common code for decoding invokes and field references. |
aoqi@0 | 200 | |
aoqi@0 | 201 | class Bytecode_member_ref: public Bytecode { |
aoqi@0 | 202 | protected: |
aoqi@0 | 203 | const methodHandle _method; // method containing the bytecode |
aoqi@0 | 204 | |
aoqi@0 | 205 | Bytecode_member_ref(methodHandle method, int bci) : Bytecode(method(), method()->bcp_from(bci)), _method(method) {} |
aoqi@0 | 206 | |
aoqi@0 | 207 | methodHandle method() const { return _method; } |
aoqi@0 | 208 | ConstantPool* constants() const { return _method->constants(); } |
aoqi@0 | 209 | ConstantPoolCache* cpcache() const { return _method->constants()->cache(); } |
aoqi@0 | 210 | ConstantPoolCacheEntry* cpcache_entry() const; |
aoqi@0 | 211 | |
aoqi@0 | 212 | public: |
aoqi@0 | 213 | int index() const; // cache index (loaded from instruction) |
aoqi@0 | 214 | int pool_index() const; // constant pool index |
aoqi@0 | 215 | Symbol* klass() const; // returns the klass of the method or field |
aoqi@0 | 216 | Symbol* name() const; // returns the name of the method or field |
aoqi@0 | 217 | Symbol* signature() const; // returns the signature of the method or field |
aoqi@0 | 218 | |
aoqi@0 | 219 | BasicType result_type() const; // returns the result type of the getfield or invoke |
aoqi@0 | 220 | }; |
aoqi@0 | 221 | |
aoqi@0 | 222 | // Abstraction for invoke_{virtual, static, interface, special} |
aoqi@0 | 223 | |
aoqi@0 | 224 | class Bytecode_invoke: public Bytecode_member_ref { |
aoqi@0 | 225 | protected: |
aoqi@0 | 226 | // Constructor that skips verification |
aoqi@0 | 227 | Bytecode_invoke(methodHandle method, int bci, bool unused) : Bytecode_member_ref(method, bci) {} |
aoqi@0 | 228 | |
aoqi@0 | 229 | public: |
aoqi@0 | 230 | Bytecode_invoke(methodHandle method, int bci) : Bytecode_member_ref(method, bci) { verify(); } |
aoqi@0 | 231 | void verify() const; |
aoqi@0 | 232 | |
aoqi@0 | 233 | // Attributes |
aoqi@0 | 234 | methodHandle static_target(TRAPS); // "specified" method (from constant pool) |
aoqi@0 | 235 | Handle appendix(TRAPS); // if CPCE::has_appendix (from constant pool) |
aoqi@0 | 236 | |
aoqi@0 | 237 | // Testers |
aoqi@0 | 238 | bool is_invokeinterface() const { return invoke_code() == Bytecodes::_invokeinterface; } |
aoqi@0 | 239 | bool is_invokevirtual() const { return invoke_code() == Bytecodes::_invokevirtual; } |
aoqi@0 | 240 | bool is_invokestatic() const { return invoke_code() == Bytecodes::_invokestatic; } |
aoqi@0 | 241 | bool is_invokespecial() const { return invoke_code() == Bytecodes::_invokespecial; } |
aoqi@0 | 242 | bool is_invokedynamic() const { return invoke_code() == Bytecodes::_invokedynamic; } |
aoqi@0 | 243 | bool is_invokehandle() const { return invoke_code() == Bytecodes::_invokehandle; } |
aoqi@0 | 244 | |
aoqi@0 | 245 | bool has_receiver() const { return !is_invokestatic() && !is_invokedynamic(); } |
aoqi@0 | 246 | |
aoqi@0 | 247 | bool is_valid() const { return is_invokeinterface() || |
aoqi@0 | 248 | is_invokevirtual() || |
aoqi@0 | 249 | is_invokestatic() || |
aoqi@0 | 250 | is_invokespecial() || |
aoqi@0 | 251 | is_invokedynamic() || |
aoqi@0 | 252 | is_invokehandle(); } |
aoqi@0 | 253 | |
aoqi@0 | 254 | bool has_appendix() { return cpcache_entry()->has_appendix(); } |
aoqi@0 | 255 | |
aoqi@0 | 256 | private: |
aoqi@0 | 257 | // Helper to skip verification. Used is_valid() to check if the result is really an invoke |
aoqi@0 | 258 | inline friend Bytecode_invoke Bytecode_invoke_check(methodHandle method, int bci); |
aoqi@0 | 259 | }; |
aoqi@0 | 260 | |
aoqi@0 | 261 | inline Bytecode_invoke Bytecode_invoke_check(methodHandle method, int bci) { |
aoqi@0 | 262 | return Bytecode_invoke(method, bci, false); |
aoqi@0 | 263 | } |
aoqi@0 | 264 | |
aoqi@0 | 265 | |
aoqi@0 | 266 | // Abstraction for all field accesses (put/get field/static) |
aoqi@0 | 267 | class Bytecode_field: public Bytecode_member_ref { |
aoqi@0 | 268 | public: |
aoqi@0 | 269 | Bytecode_field(methodHandle method, int bci) : Bytecode_member_ref(method, bci) { verify(); } |
aoqi@0 | 270 | |
aoqi@0 | 271 | // Testers |
aoqi@0 | 272 | bool is_getfield() const { return java_code() == Bytecodes::_getfield; } |
aoqi@0 | 273 | bool is_putfield() const { return java_code() == Bytecodes::_putfield; } |
aoqi@0 | 274 | bool is_getstatic() const { return java_code() == Bytecodes::_getstatic; } |
aoqi@0 | 275 | bool is_putstatic() const { return java_code() == Bytecodes::_putstatic; } |
aoqi@0 | 276 | |
aoqi@0 | 277 | bool is_getter() const { return is_getfield() || is_getstatic(); } |
aoqi@0 | 278 | bool is_static() const { return is_getstatic() || is_putstatic(); } |
aoqi@0 | 279 | |
aoqi@0 | 280 | bool is_valid() const { return is_getfield() || |
aoqi@0 | 281 | is_putfield() || |
aoqi@0 | 282 | is_getstatic() || |
aoqi@0 | 283 | is_putstatic(); } |
aoqi@0 | 284 | void verify() const; |
aoqi@0 | 285 | }; |
aoqi@0 | 286 | |
aoqi@0 | 287 | // Abstraction for checkcast |
aoqi@0 | 288 | class Bytecode_checkcast: public Bytecode { |
aoqi@0 | 289 | public: |
aoqi@0 | 290 | Bytecode_checkcast(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
aoqi@0 | 291 | void verify() const { assert(Bytecodes::java_code(code()) == Bytecodes::_checkcast, "check checkcast"); } |
aoqi@0 | 292 | |
aoqi@0 | 293 | // Returns index |
aoqi@0 | 294 | long index() const { return get_index_u2(Bytecodes::_checkcast); }; |
aoqi@0 | 295 | }; |
aoqi@0 | 296 | |
aoqi@0 | 297 | // Abstraction for instanceof |
aoqi@0 | 298 | class Bytecode_instanceof: public Bytecode { |
aoqi@0 | 299 | public: |
aoqi@0 | 300 | Bytecode_instanceof(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
aoqi@0 | 301 | void verify() const { assert(code() == Bytecodes::_instanceof, "check instanceof"); } |
aoqi@0 | 302 | |
aoqi@0 | 303 | // Returns index |
aoqi@0 | 304 | long index() const { return get_index_u2(Bytecodes::_instanceof); }; |
aoqi@0 | 305 | }; |
aoqi@0 | 306 | |
aoqi@0 | 307 | class Bytecode_new: public Bytecode { |
aoqi@0 | 308 | public: |
aoqi@0 | 309 | Bytecode_new(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
aoqi@0 | 310 | void verify() const { assert(java_code() == Bytecodes::_new, "check new"); } |
aoqi@0 | 311 | |
aoqi@0 | 312 | // Returns index |
aoqi@0 | 313 | long index() const { return get_index_u2(Bytecodes::_new); }; |
aoqi@0 | 314 | }; |
aoqi@0 | 315 | |
aoqi@0 | 316 | class Bytecode_multianewarray: public Bytecode { |
aoqi@0 | 317 | public: |
aoqi@0 | 318 | Bytecode_multianewarray(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
aoqi@0 | 319 | void verify() const { assert(java_code() == Bytecodes::_multianewarray, "check new"); } |
aoqi@0 | 320 | |
aoqi@0 | 321 | // Returns index |
aoqi@0 | 322 | long index() const { return get_index_u2(Bytecodes::_multianewarray); }; |
aoqi@0 | 323 | }; |
aoqi@0 | 324 | |
aoqi@0 | 325 | class Bytecode_anewarray: public Bytecode { |
aoqi@0 | 326 | public: |
aoqi@0 | 327 | Bytecode_anewarray(Method* method, address bcp): Bytecode(method, bcp) { verify(); } |
aoqi@0 | 328 | void verify() const { assert(java_code() == Bytecodes::_anewarray, "check anewarray"); } |
aoqi@0 | 329 | |
aoqi@0 | 330 | // Returns index |
aoqi@0 | 331 | long index() const { return get_index_u2(Bytecodes::_anewarray); }; |
aoqi@0 | 332 | }; |
aoqi@0 | 333 | |
aoqi@0 | 334 | // Abstraction for ldc, ldc_w and ldc2_w |
aoqi@0 | 335 | class Bytecode_loadconstant: public Bytecode { |
aoqi@0 | 336 | private: |
aoqi@0 | 337 | const methodHandle _method; |
aoqi@0 | 338 | |
aoqi@0 | 339 | int raw_index() const; |
aoqi@0 | 340 | |
aoqi@0 | 341 | public: |
aoqi@0 | 342 | Bytecode_loadconstant(methodHandle method, int bci): Bytecode(method(), method->bcp_from(bci)), _method(method) { verify(); } |
aoqi@0 | 343 | |
aoqi@0 | 344 | void verify() const { |
aoqi@0 | 345 | assert(_method.not_null(), "must supply method"); |
aoqi@0 | 346 | Bytecodes::Code stdc = Bytecodes::java_code(code()); |
aoqi@0 | 347 | assert(stdc == Bytecodes::_ldc || |
aoqi@0 | 348 | stdc == Bytecodes::_ldc_w || |
aoqi@0 | 349 | stdc == Bytecodes::_ldc2_w, "load constant"); |
aoqi@0 | 350 | } |
aoqi@0 | 351 | |
aoqi@0 | 352 | // Only non-standard bytecodes (fast_aldc) have reference cache indexes. |
aoqi@0 | 353 | bool has_cache_index() const { return code() >= Bytecodes::number_of_java_codes; } |
aoqi@0 | 354 | |
aoqi@0 | 355 | int pool_index() const; // index into constant pool |
aoqi@0 | 356 | int cache_index() const { // index into reference cache (or -1 if none) |
aoqi@0 | 357 | return has_cache_index() ? raw_index() : -1; |
aoqi@0 | 358 | } |
aoqi@0 | 359 | |
aoqi@0 | 360 | BasicType result_type() const; // returns the result type of the ldc |
aoqi@0 | 361 | |
aoqi@0 | 362 | oop resolve_constant(TRAPS) const; |
aoqi@0 | 363 | }; |
aoqi@0 | 364 | |
aoqi@0 | 365 | #endif // SHARE_VM_INTERPRETER_BYTECODE_HPP |