5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 // Base class for different kinds of abstractions working 26 // relative to an objects 'this' pointer. 27 28 class ThisRelativeObj VALUE_OBJ_CLASS_SPEC { 29 public: 30 // Address computation 31 address addr_at (int offset) const { return (address)this + offset; } 32 int byte_at (int offset) const { return *(addr_at(offset)); } 33 address aligned_addr_at (int offset) const { return (address)round_to((intptr_t)addr_at(offset), jintSize); } 34 int aligned_offset (int offset) const { return aligned_addr_at(offset) - addr_at(0); } 35 36 // Word access: 37 int get_Java_u2_at (int offset) const { return Bytes::get_Java_u2(addr_at(offset)); } 38 int get_Java_u4_at (int offset) const { return Bytes::get_Java_u4(addr_at(offset)); } 39 int get_native_u2_at (int offset) const { return Bytes::get_native_u2(addr_at(offset)); } 40 int get_native_u4_at (int offset) const { return Bytes::get_native_u4(addr_at(offset)); } 41 }; 42 43 44 // The base class for different kinds of bytecode abstractions. 414 bool has_cache_index() const { return code() >= Bytecodes::number_of_java_codes; } 415 416 int pool_index() const; // index into constant pool 417 int cache_index() const { // index into CP cache (or -1 if none) 418 return has_cache_index() ? raw_index() : -1; 419 } 420 421 BasicType result_type() const; // returns the result type of the ldc 422 423 oop resolve_constant(TRAPS) const; 424 425 // Creation 426 inline friend Bytecode_loadconstant* Bytecode_loadconstant_at(methodHandle method, int bci); 427 }; 428 429 inline Bytecode_loadconstant* Bytecode_loadconstant_at(methodHandle method, int bci) { 430 Bytecode_loadconstant* b = new Bytecode_loadconstant(method, bci); 431 DEBUG_ONLY(b->verify()); 432 return b; 433 } | 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_VM_INTERPRETER_BYTECODE_HPP 26 #define SHARE_VM_INTERPRETER_BYTECODE_HPP 27 28 #include "interpreter/bytecodes.hpp" 29 #include "memory/allocation.hpp" 30 #include "oops/methodOop.hpp" 31 #ifdef TARGET_ARCH_x86 32 # include "bytes_x86.hpp" 33 #endif 34 #ifdef TARGET_ARCH_sparc 35 # include "bytes_sparc.hpp" 36 #endif 37 #ifdef TARGET_ARCH_zero 38 # include "bytes_zero.hpp" 39 #endif 40 41 // Base class for different kinds of abstractions working 42 // relative to an objects 'this' pointer. 43 44 class ThisRelativeObj VALUE_OBJ_CLASS_SPEC { 45 public: 46 // Address computation 47 address addr_at (int offset) const { return (address)this + offset; } 48 int byte_at (int offset) const { return *(addr_at(offset)); } 49 address aligned_addr_at (int offset) const { return (address)round_to((intptr_t)addr_at(offset), jintSize); } 50 int aligned_offset (int offset) const { return aligned_addr_at(offset) - addr_at(0); } 51 52 // Word access: 53 int get_Java_u2_at (int offset) const { return Bytes::get_Java_u2(addr_at(offset)); } 54 int get_Java_u4_at (int offset) const { return Bytes::get_Java_u4(addr_at(offset)); } 55 int get_native_u2_at (int offset) const { return Bytes::get_native_u2(addr_at(offset)); } 56 int get_native_u4_at (int offset) const { return Bytes::get_native_u4(addr_at(offset)); } 57 }; 58 59 60 // The base class for different kinds of bytecode abstractions. 430 bool has_cache_index() const { return code() >= Bytecodes::number_of_java_codes; } 431 432 int pool_index() const; // index into constant pool 433 int cache_index() const { // index into CP cache (or -1 if none) 434 return has_cache_index() ? raw_index() : -1; 435 } 436 437 BasicType result_type() const; // returns the result type of the ldc 438 439 oop resolve_constant(TRAPS) const; 440 441 // Creation 442 inline friend Bytecode_loadconstant* Bytecode_loadconstant_at(methodHandle method, int bci); 443 }; 444 445 inline Bytecode_loadconstant* Bytecode_loadconstant_at(methodHandle method, int bci) { 446 Bytecode_loadconstant* b = new Bytecode_loadconstant(method, bci); 447 DEBUG_ONLY(b->verify()); 448 return b; 449 } 450 451 #endif // SHARE_VM_INTERPRETER_BYTECODE_HPP |