Tue, 23 Nov 2010 13:22:55 -0800
6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg
duke@435 | 1 | /* |
jrose@1934 | 2 | * Copyright (c) 1997, 2010, 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_BYTECODE_HPP |
stefank@2314 | 26 | #define SHARE_VM_INTERPRETER_BYTECODE_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "interpreter/bytecodes.hpp" |
stefank@2314 | 29 | #include "memory/allocation.hpp" |
stefank@2314 | 30 | #include "oops/methodOop.hpp" |
stefank@2314 | 31 | #ifdef TARGET_ARCH_x86 |
stefank@2314 | 32 | # include "bytes_x86.hpp" |
stefank@2314 | 33 | #endif |
stefank@2314 | 34 | #ifdef TARGET_ARCH_sparc |
stefank@2314 | 35 | # include "bytes_sparc.hpp" |
stefank@2314 | 36 | #endif |
stefank@2314 | 37 | #ifdef TARGET_ARCH_zero |
stefank@2314 | 38 | # include "bytes_zero.hpp" |
stefank@2314 | 39 | #endif |
stefank@2314 | 40 | |
duke@435 | 41 | // Base class for different kinds of abstractions working |
duke@435 | 42 | // relative to an objects 'this' pointer. |
duke@435 | 43 | |
duke@435 | 44 | class ThisRelativeObj VALUE_OBJ_CLASS_SPEC { |
duke@435 | 45 | public: |
duke@435 | 46 | // Address computation |
duke@435 | 47 | address addr_at (int offset) const { return (address)this + offset; } |
jrose@1920 | 48 | int byte_at (int offset) const { return *(addr_at(offset)); } |
duke@435 | 49 | address aligned_addr_at (int offset) const { return (address)round_to((intptr_t)addr_at(offset), jintSize); } |
duke@435 | 50 | int aligned_offset (int offset) const { return aligned_addr_at(offset) - addr_at(0); } |
duke@435 | 51 | |
jrose@1920 | 52 | // Word access: |
jrose@1920 | 53 | int get_Java_u2_at (int offset) const { return Bytes::get_Java_u2(addr_at(offset)); } |
jrose@1920 | 54 | int get_Java_u4_at (int offset) const { return Bytes::get_Java_u4(addr_at(offset)); } |
jrose@1920 | 55 | int get_native_u2_at (int offset) const { return Bytes::get_native_u2(addr_at(offset)); } |
jrose@1920 | 56 | int get_native_u4_at (int offset) const { return Bytes::get_native_u4(addr_at(offset)); } |
duke@435 | 57 | }; |
duke@435 | 58 | |
duke@435 | 59 | |
duke@435 | 60 | // The base class for different kinds of bytecode abstractions. |
duke@435 | 61 | // Provides the primitive operations to manipulate code relative |
duke@435 | 62 | // to an objects 'this' pointer. |
jrose@1920 | 63 | // FIXME: Make this a ResourceObj, include the enclosing methodOop, and cache the opcode. |
duke@435 | 64 | |
duke@435 | 65 | class Bytecode: public ThisRelativeObj { |
duke@435 | 66 | protected: |
duke@435 | 67 | u_char byte_at(int offset) const { return *addr_at(offset); } |
jrose@1920 | 68 | bool check_must_rewrite(Bytecodes::Code bc) const; |
duke@435 | 69 | |
duke@435 | 70 | public: |
duke@435 | 71 | // Attributes |
duke@435 | 72 | address bcp() const { return addr_at(0); } |
jrose@1161 | 73 | int instruction_size() const { return Bytecodes::length_at(bcp()); } |
duke@435 | 74 | |
jrose@1920 | 75 | // Warning: Use code() with caution on live bytecode streams. 4926272 |
duke@435 | 76 | Bytecodes::Code code() const { return Bytecodes::code_at(addr_at(0)); } |
duke@435 | 77 | Bytecodes::Code java_code() const { return Bytecodes::java_code(code()); } |
jrose@1920 | 78 | bool must_rewrite(Bytecodes::Code code) const { return Bytecodes::can_rewrite(code) && check_must_rewrite(code); } |
duke@435 | 79 | |
duke@435 | 80 | // Creation |
duke@435 | 81 | inline friend Bytecode* Bytecode_at(address bcp); |
jrose@1161 | 82 | |
jrose@1920 | 83 | // Static functions for parsing bytecodes in place. |
jrose@1920 | 84 | int get_index_u1(Bytecodes::Code bc) const { |
jrose@1920 | 85 | assert_same_format_as(bc); assert_index_size(1, bc); |
jrose@1920 | 86 | return *(jubyte*)addr_at(1); |
jrose@1920 | 87 | } |
jrose@1920 | 88 | int get_index_u2(Bytecodes::Code bc, bool is_wide = false) const { |
jrose@1920 | 89 | assert_same_format_as(bc, is_wide); assert_index_size(2, bc, is_wide); |
jrose@1920 | 90 | address p = addr_at(is_wide ? 2 : 1); |
jrose@1920 | 91 | if (can_use_native_byte_order(bc, is_wide)) |
jrose@1920 | 92 | return Bytes::get_native_u2(p); |
jrose@1920 | 93 | else return Bytes::get_Java_u2(p); |
jrose@1920 | 94 | } |
jrose@1957 | 95 | int get_index_u1_cpcache(Bytecodes::Code bc) const { |
jrose@1957 | 96 | assert_same_format_as(bc); assert_index_size(1, bc); |
jrose@1957 | 97 | return *(jubyte*)addr_at(1) + constantPoolOopDesc::CPCACHE_INDEX_TAG; |
jrose@1957 | 98 | } |
jrose@1920 | 99 | int get_index_u2_cpcache(Bytecodes::Code bc) const { |
jrose@1920 | 100 | assert_same_format_as(bc); assert_index_size(2, bc); assert_native_index(bc); |
jrose@1957 | 101 | return Bytes::get_native_u2(addr_at(1)) + constantPoolOopDesc::CPCACHE_INDEX_TAG; |
jrose@1920 | 102 | } |
jrose@1920 | 103 | int get_index_u4(Bytecodes::Code bc) const { |
jrose@1920 | 104 | assert_same_format_as(bc); assert_index_size(4, bc); |
jrose@1920 | 105 | assert(can_use_native_byte_order(bc), ""); |
jrose@1920 | 106 | return Bytes::get_native_u4(addr_at(1)); |
jrose@1920 | 107 | } |
jrose@1920 | 108 | bool has_index_u4(Bytecodes::Code bc) const { |
jrose@1920 | 109 | return bc == Bytecodes::_invokedynamic; |
jrose@1920 | 110 | } |
jrose@1920 | 111 | |
jrose@1920 | 112 | int get_offset_s2(Bytecodes::Code bc) const { |
jrose@1920 | 113 | assert_same_format_as(bc); assert_offset_size(2, bc); |
jrose@1920 | 114 | return (jshort) Bytes::get_Java_u2(addr_at(1)); |
jrose@1920 | 115 | } |
jrose@1920 | 116 | int get_offset_s4(Bytecodes::Code bc) const { |
jrose@1920 | 117 | assert_same_format_as(bc); assert_offset_size(4, bc); |
jrose@1920 | 118 | return (jint) Bytes::get_Java_u4(addr_at(1)); |
jrose@1920 | 119 | } |
jrose@1920 | 120 | |
jrose@1920 | 121 | int get_constant_u1(int offset, Bytecodes::Code bc) const { |
jrose@1920 | 122 | assert_same_format_as(bc); assert_constant_size(1, offset, bc); |
jrose@1920 | 123 | return *(jbyte*)addr_at(offset); |
jrose@1920 | 124 | } |
jrose@1920 | 125 | int get_constant_u2(int offset, Bytecodes::Code bc, bool is_wide = false) const { |
jrose@1920 | 126 | assert_same_format_as(bc, is_wide); assert_constant_size(2, offset, bc, is_wide); |
jrose@1920 | 127 | return (jshort) Bytes::get_Java_u2(addr_at(offset)); |
jrose@1920 | 128 | } |
jrose@1920 | 129 | |
jrose@1920 | 130 | // These are used locally and also from bytecode streams. |
jrose@1920 | 131 | void assert_same_format_as(Bytecodes::Code testbc, bool is_wide = false) const NOT_DEBUG_RETURN; |
jrose@1920 | 132 | static void assert_index_size(int required_size, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN; |
jrose@1920 | 133 | static void assert_offset_size(int required_size, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN; |
jrose@1920 | 134 | static void assert_constant_size(int required_size, int where, Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN; |
jrose@1920 | 135 | static void assert_native_index(Bytecodes::Code bc, bool is_wide = false) NOT_DEBUG_RETURN; |
jrose@1920 | 136 | static bool can_use_native_byte_order(Bytecodes::Code bc, bool is_wide = false) { |
jrose@1920 | 137 | return (!Bytes::is_Java_byte_ordering_different() || Bytecodes::native_byte_order(bc /*, is_wide*/)); |
jrose@1161 | 138 | } |
duke@435 | 139 | }; |
duke@435 | 140 | |
duke@435 | 141 | inline Bytecode* Bytecode_at(address bcp) { |
jrose@1920 | 142 | // Warning: Use with caution on live bytecode streams. 4926272 |
duke@435 | 143 | return (Bytecode*)bcp; |
duke@435 | 144 | } |
duke@435 | 145 | |
duke@435 | 146 | |
duke@435 | 147 | // Abstractions for lookupswitch bytecode |
duke@435 | 148 | |
duke@435 | 149 | class LookupswitchPair: ThisRelativeObj { |
duke@435 | 150 | private: |
duke@435 | 151 | int _match; |
duke@435 | 152 | int _offset; |
duke@435 | 153 | |
duke@435 | 154 | public: |
jrose@1920 | 155 | int match() const { return get_Java_u4_at(0 * jintSize); } |
jrose@1920 | 156 | int offset() const { return get_Java_u4_at(1 * jintSize); } |
duke@435 | 157 | }; |
duke@435 | 158 | |
duke@435 | 159 | |
duke@435 | 160 | class Bytecode_lookupswitch: public Bytecode { |
duke@435 | 161 | public: |
duke@435 | 162 | void verify() const PRODUCT_RETURN; |
duke@435 | 163 | |
duke@435 | 164 | // Attributes |
jrose@1920 | 165 | int default_offset() const { return get_Java_u4_at(aligned_offset(1 + 0*jintSize)); } |
jrose@1920 | 166 | int number_of_pairs() const { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); } |
duke@435 | 167 | LookupswitchPair* pair_at(int i) const { assert(0 <= i && i < number_of_pairs(), "pair index out of bounds"); |
duke@435 | 168 | return (LookupswitchPair*)aligned_addr_at(1 + (1 + i)*2*jintSize); } |
duke@435 | 169 | // Creation |
duke@435 | 170 | inline friend Bytecode_lookupswitch* Bytecode_lookupswitch_at(address bcp); |
duke@435 | 171 | }; |
duke@435 | 172 | |
duke@435 | 173 | inline Bytecode_lookupswitch* Bytecode_lookupswitch_at(address bcp) { |
duke@435 | 174 | Bytecode_lookupswitch* b = (Bytecode_lookupswitch*)bcp; |
jrose@1957 | 175 | DEBUG_ONLY(b->verify()); |
duke@435 | 176 | return b; |
duke@435 | 177 | } |
duke@435 | 178 | |
duke@435 | 179 | |
duke@435 | 180 | class Bytecode_tableswitch: public Bytecode { |
duke@435 | 181 | public: |
duke@435 | 182 | void verify() const PRODUCT_RETURN; |
duke@435 | 183 | |
duke@435 | 184 | // Attributes |
jrose@1920 | 185 | int default_offset() const { return get_Java_u4_at(aligned_offset(1 + 0*jintSize)); } |
jrose@1920 | 186 | int low_key() const { return get_Java_u4_at(aligned_offset(1 + 1*jintSize)); } |
jrose@1920 | 187 | int high_key() const { return get_Java_u4_at(aligned_offset(1 + 2*jintSize)); } |
duke@435 | 188 | int dest_offset_at(int i) const; |
duke@435 | 189 | int length() { return high_key()-low_key()+1; } |
duke@435 | 190 | |
duke@435 | 191 | // Creation |
duke@435 | 192 | inline friend Bytecode_tableswitch* Bytecode_tableswitch_at(address bcp); |
duke@435 | 193 | }; |
duke@435 | 194 | |
duke@435 | 195 | inline Bytecode_tableswitch* Bytecode_tableswitch_at(address bcp) { |
duke@435 | 196 | Bytecode_tableswitch* b = (Bytecode_tableswitch*)bcp; |
jrose@1957 | 197 | DEBUG_ONLY(b->verify()); |
duke@435 | 198 | return b; |
duke@435 | 199 | } |
duke@435 | 200 | |
duke@435 | 201 | |
jrose@1957 | 202 | // Common code for decoding invokes and field references. |
duke@435 | 203 | |
jrose@1957 | 204 | class Bytecode_member_ref: public ResourceObj { |
duke@435 | 205 | protected: |
duke@435 | 206 | methodHandle _method; // method containing the bytecode |
duke@435 | 207 | int _bci; // position of the bytecode |
duke@435 | 208 | |
jrose@1957 | 209 | Bytecode_member_ref(methodHandle method, int bci) : _method(method), _bci(bci) {} |
jrose@1957 | 210 | |
jrose@1957 | 211 | public: |
jrose@1957 | 212 | // Attributes |
jrose@1957 | 213 | methodHandle method() const { return _method; } |
jrose@1957 | 214 | int bci() const { return _bci; } |
jrose@1957 | 215 | address bcp() const { return _method->bcp_from(bci()); } |
jrose@1957 | 216 | Bytecode* bytecode() const { return Bytecode_at(bcp()); } |
jrose@1957 | 217 | |
jrose@1957 | 218 | int index() const; // cache index (loaded from instruction) |
jrose@1957 | 219 | int pool_index() const; // constant pool index |
jrose@1957 | 220 | symbolOop name() const; // returns the name of the method or field |
jrose@1957 | 221 | symbolOop signature() const; // returns the signature of the method or field |
jrose@1957 | 222 | |
jrose@1957 | 223 | BasicType result_type(Thread* thread) const; // returns the result type of the getfield or invoke |
jrose@1957 | 224 | |
jrose@1957 | 225 | Bytecodes::Code code() const { return Bytecodes::code_at(bcp(), _method()); } |
jrose@1957 | 226 | Bytecodes::Code java_code() const { return Bytecodes::java_code(code()); } |
jrose@1957 | 227 | }; |
jrose@1957 | 228 | |
jrose@1957 | 229 | // Abstraction for invoke_{virtual, static, interface, special} |
jrose@1957 | 230 | |
jrose@1957 | 231 | class Bytecode_invoke: public Bytecode_member_ref { |
jrose@1957 | 232 | protected: |
jrose@1957 | 233 | Bytecode_invoke(methodHandle method, int bci) : Bytecode_member_ref(method, bci) {} |
duke@435 | 234 | |
duke@435 | 235 | public: |
duke@435 | 236 | void verify() const; |
duke@435 | 237 | |
duke@435 | 238 | // Attributes |
duke@435 | 239 | methodHandle static_target(TRAPS); // "specified" method (from constant pool) |
duke@435 | 240 | |
duke@435 | 241 | // Testers |
jrose@1957 | 242 | bool is_invokeinterface() const { return java_code() == Bytecodes::_invokeinterface; } |
jrose@1957 | 243 | bool is_invokevirtual() const { return java_code() == Bytecodes::_invokevirtual; } |
jrose@1957 | 244 | bool is_invokestatic() const { return java_code() == Bytecodes::_invokestatic; } |
jrose@1957 | 245 | bool is_invokespecial() const { return java_code() == Bytecodes::_invokespecial; } |
jrose@1957 | 246 | bool is_invokedynamic() const { return java_code() == Bytecodes::_invokedynamic; } |
jrose@1161 | 247 | |
twisti@1573 | 248 | bool has_receiver() const { return !is_invokestatic() && !is_invokedynamic(); } |
duke@435 | 249 | |
duke@435 | 250 | bool is_valid() const { return is_invokeinterface() || |
duke@435 | 251 | is_invokevirtual() || |
duke@435 | 252 | is_invokestatic() || |
twisti@1570 | 253 | is_invokespecial() || |
twisti@1570 | 254 | is_invokedynamic(); } |
duke@435 | 255 | |
duke@435 | 256 | // Creation |
duke@435 | 257 | inline friend Bytecode_invoke* Bytecode_invoke_at(methodHandle method, int bci); |
duke@435 | 258 | |
duke@435 | 259 | // Like Bytecode_invoke_at. Instead it returns NULL if the bci is not at an invoke. |
duke@435 | 260 | inline friend Bytecode_invoke* Bytecode_invoke_at_check(methodHandle method, int bci); |
duke@435 | 261 | }; |
duke@435 | 262 | |
duke@435 | 263 | inline Bytecode_invoke* Bytecode_invoke_at(methodHandle method, int bci) { |
duke@435 | 264 | Bytecode_invoke* b = new Bytecode_invoke(method, bci); |
jrose@1957 | 265 | DEBUG_ONLY(b->verify()); |
duke@435 | 266 | return b; |
duke@435 | 267 | } |
duke@435 | 268 | |
duke@435 | 269 | inline Bytecode_invoke* Bytecode_invoke_at_check(methodHandle method, int bci) { |
duke@435 | 270 | Bytecode_invoke* b = new Bytecode_invoke(method, bci); |
duke@435 | 271 | return b->is_valid() ? b : NULL; |
duke@435 | 272 | } |
duke@435 | 273 | |
duke@435 | 274 | |
jrose@1957 | 275 | // Abstraction for all field accesses (put/get field/static) |
jrose@1957 | 276 | class Bytecode_field: public Bytecode_member_ref { |
jrose@1957 | 277 | protected: |
jrose@1957 | 278 | Bytecode_field(methodHandle method, int bci) : Bytecode_member_ref(method, bci) {} |
jrose@1957 | 279 | |
jrose@1957 | 280 | public: |
jrose@1957 | 281 | // Testers |
jrose@1957 | 282 | bool is_getfield() const { return java_code() == Bytecodes::_getfield; } |
jrose@1957 | 283 | bool is_putfield() const { return java_code() == Bytecodes::_putfield; } |
jrose@1957 | 284 | bool is_getstatic() const { return java_code() == Bytecodes::_getstatic; } |
jrose@1957 | 285 | bool is_putstatic() const { return java_code() == Bytecodes::_putstatic; } |
jrose@1957 | 286 | |
jrose@1957 | 287 | bool is_getter() const { return is_getfield() || is_getstatic(); } |
jrose@1957 | 288 | bool is_static() const { return is_getstatic() || is_putstatic(); } |
jrose@1957 | 289 | |
jrose@1957 | 290 | bool is_valid() const { return is_getfield() || |
jrose@1957 | 291 | is_putfield() || |
jrose@1957 | 292 | is_getstatic() || |
jrose@1957 | 293 | is_putstatic(); } |
duke@435 | 294 | void verify() const; |
duke@435 | 295 | |
duke@435 | 296 | // Creation |
jrose@1957 | 297 | inline friend Bytecode_field* Bytecode_field_at(methodHandle method, int bci); |
duke@435 | 298 | }; |
duke@435 | 299 | |
jrose@1957 | 300 | inline Bytecode_field* Bytecode_field_at(methodHandle method, int bci) { |
jrose@1957 | 301 | Bytecode_field* b = new Bytecode_field(method, bci); |
jrose@1957 | 302 | DEBUG_ONLY(b->verify()); |
duke@435 | 303 | return b; |
duke@435 | 304 | } |
duke@435 | 305 | |
duke@435 | 306 | |
duke@435 | 307 | // Abstraction for checkcast |
duke@435 | 308 | |
duke@435 | 309 | class Bytecode_checkcast: public Bytecode { |
duke@435 | 310 | public: |
duke@435 | 311 | void verify() const { assert(Bytecodes::java_code(code()) == Bytecodes::_checkcast, "check checkcast"); } |
duke@435 | 312 | |
duke@435 | 313 | // Returns index |
jrose@1920 | 314 | long index() const { return get_index_u2(Bytecodes::_checkcast); }; |
duke@435 | 315 | |
duke@435 | 316 | // Creation |
duke@435 | 317 | inline friend Bytecode_checkcast* Bytecode_checkcast_at(address bcp); |
duke@435 | 318 | }; |
duke@435 | 319 | |
duke@435 | 320 | inline Bytecode_checkcast* Bytecode_checkcast_at(address bcp) { |
duke@435 | 321 | Bytecode_checkcast* b = (Bytecode_checkcast*)bcp; |
jrose@1957 | 322 | DEBUG_ONLY(b->verify()); |
duke@435 | 323 | return b; |
duke@435 | 324 | } |
duke@435 | 325 | |
duke@435 | 326 | |
duke@435 | 327 | // Abstraction for instanceof |
duke@435 | 328 | |
duke@435 | 329 | class Bytecode_instanceof: public Bytecode { |
duke@435 | 330 | public: |
duke@435 | 331 | void verify() const { assert(code() == Bytecodes::_instanceof, "check instanceof"); } |
duke@435 | 332 | |
duke@435 | 333 | // Returns index |
jrose@1920 | 334 | long index() const { return get_index_u2(Bytecodes::_instanceof); }; |
duke@435 | 335 | |
duke@435 | 336 | // Creation |
duke@435 | 337 | inline friend Bytecode_instanceof* Bytecode_instanceof_at(address bcp); |
duke@435 | 338 | }; |
duke@435 | 339 | |
duke@435 | 340 | inline Bytecode_instanceof* Bytecode_instanceof_at(address bcp) { |
duke@435 | 341 | Bytecode_instanceof* b = (Bytecode_instanceof*)bcp; |
jrose@1957 | 342 | DEBUG_ONLY(b->verify()); |
duke@435 | 343 | return b; |
duke@435 | 344 | } |
duke@435 | 345 | |
duke@435 | 346 | |
duke@435 | 347 | class Bytecode_new: public Bytecode { |
duke@435 | 348 | public: |
duke@435 | 349 | void verify() const { assert(java_code() == Bytecodes::_new, "check new"); } |
duke@435 | 350 | |
duke@435 | 351 | // Returns index |
jrose@1920 | 352 | long index() const { return get_index_u2(Bytecodes::_new); }; |
duke@435 | 353 | |
duke@435 | 354 | // Creation |
duke@435 | 355 | inline friend Bytecode_new* Bytecode_new_at(address bcp); |
duke@435 | 356 | }; |
duke@435 | 357 | |
duke@435 | 358 | inline Bytecode_new* Bytecode_new_at(address bcp) { |
duke@435 | 359 | Bytecode_new* b = (Bytecode_new*)bcp; |
jrose@1957 | 360 | DEBUG_ONLY(b->verify()); |
duke@435 | 361 | return b; |
duke@435 | 362 | } |
duke@435 | 363 | |
duke@435 | 364 | |
duke@435 | 365 | class Bytecode_multianewarray: public Bytecode { |
duke@435 | 366 | public: |
duke@435 | 367 | void verify() const { assert(java_code() == Bytecodes::_multianewarray, "check new"); } |
duke@435 | 368 | |
duke@435 | 369 | // Returns index |
jrose@1920 | 370 | long index() const { return get_index_u2(Bytecodes::_multianewarray); }; |
duke@435 | 371 | |
duke@435 | 372 | // Creation |
duke@435 | 373 | inline friend Bytecode_multianewarray* Bytecode_multianewarray_at(address bcp); |
duke@435 | 374 | }; |
duke@435 | 375 | |
duke@435 | 376 | inline Bytecode_multianewarray* Bytecode_multianewarray_at(address bcp) { |
duke@435 | 377 | Bytecode_multianewarray* b = (Bytecode_multianewarray*)bcp; |
jrose@1957 | 378 | DEBUG_ONLY(b->verify()); |
duke@435 | 379 | return b; |
duke@435 | 380 | } |
duke@435 | 381 | |
duke@435 | 382 | |
duke@435 | 383 | class Bytecode_anewarray: public Bytecode { |
duke@435 | 384 | public: |
duke@435 | 385 | void verify() const { assert(java_code() == Bytecodes::_anewarray, "check anewarray"); } |
duke@435 | 386 | |
duke@435 | 387 | // Returns index |
jrose@1920 | 388 | long index() const { return get_index_u2(Bytecodes::_anewarray); }; |
duke@435 | 389 | |
duke@435 | 390 | // Creation |
duke@435 | 391 | inline friend Bytecode_anewarray* Bytecode_anewarray_at(address bcp); |
duke@435 | 392 | }; |
duke@435 | 393 | |
duke@435 | 394 | inline Bytecode_anewarray* Bytecode_anewarray_at(address bcp) { |
duke@435 | 395 | Bytecode_anewarray* b = (Bytecode_anewarray*)bcp; |
jrose@1957 | 396 | DEBUG_ONLY(b->verify()); |
duke@435 | 397 | return b; |
duke@435 | 398 | } |
duke@435 | 399 | |
duke@435 | 400 | |
duke@435 | 401 | // Abstraction for ldc, ldc_w and ldc2_w |
duke@435 | 402 | |
jrose@1957 | 403 | class Bytecode_loadconstant: public ResourceObj { |
jrose@1957 | 404 | private: |
jrose@1957 | 405 | int _bci; |
jrose@1957 | 406 | methodHandle _method; |
jrose@1957 | 407 | |
jrose@1957 | 408 | Bytecodes::Code code() const { return bytecode()->code(); } |
jrose@1957 | 409 | |
jrose@1957 | 410 | int raw_index() const; |
jrose@1957 | 411 | |
jrose@1957 | 412 | Bytecode_loadconstant(methodHandle method, int bci) : _method(method), _bci(bci) {} |
jrose@1957 | 413 | |
duke@435 | 414 | public: |
jrose@1957 | 415 | // Attributes |
jrose@1957 | 416 | methodHandle method() const { return _method; } |
jrose@1957 | 417 | int bci() const { return _bci; } |
jrose@1957 | 418 | address bcp() const { return _method->bcp_from(bci()); } |
jrose@1957 | 419 | Bytecode* bytecode() const { return Bytecode_at(bcp()); } |
jrose@1957 | 420 | |
duke@435 | 421 | void verify() const { |
jrose@1957 | 422 | assert(_method.not_null(), "must supply method"); |
duke@435 | 423 | Bytecodes::Code stdc = Bytecodes::java_code(code()); |
duke@435 | 424 | assert(stdc == Bytecodes::_ldc || |
duke@435 | 425 | stdc == Bytecodes::_ldc_w || |
duke@435 | 426 | stdc == Bytecodes::_ldc2_w, "load constant"); |
duke@435 | 427 | } |
duke@435 | 428 | |
jrose@1957 | 429 | // Only non-standard bytecodes (fast_aldc) have CP cache indexes. |
jrose@1957 | 430 | bool has_cache_index() const { return code() >= Bytecodes::number_of_java_codes; } |
duke@435 | 431 | |
jrose@1957 | 432 | int pool_index() const; // index into constant pool |
jrose@1957 | 433 | int cache_index() const { // index into CP cache (or -1 if none) |
jrose@1957 | 434 | return has_cache_index() ? raw_index() : -1; |
jrose@1957 | 435 | } |
jrose@1957 | 436 | |
jrose@1957 | 437 | BasicType result_type() const; // returns the result type of the ldc |
jrose@1957 | 438 | |
jrose@1957 | 439 | oop resolve_constant(TRAPS) const; |
jrose@1957 | 440 | |
jrose@1957 | 441 | // Creation |
jrose@1957 | 442 | inline friend Bytecode_loadconstant* Bytecode_loadconstant_at(methodHandle method, int bci); |
duke@435 | 443 | }; |
duke@435 | 444 | |
jrose@1957 | 445 | inline Bytecode_loadconstant* Bytecode_loadconstant_at(methodHandle method, int bci) { |
jrose@1957 | 446 | Bytecode_loadconstant* b = new Bytecode_loadconstant(method, bci); |
jrose@1957 | 447 | DEBUG_ONLY(b->verify()); |
duke@435 | 448 | return b; |
duke@435 | 449 | } |
stefank@2314 | 450 | |
stefank@2314 | 451 | #endif // SHARE_VM_INTERPRETER_BYTECODE_HPP |