31 #include "oops/objArrayOop.hpp" 32 #include "oops/oopHandle.hpp" 33 #include "oops/symbol.hpp" 34 #include "oops/typeArrayOop.hpp" 35 #include "runtime/handles.hpp" 36 #include "utilities/align.hpp" 37 #include "utilities/bytes.hpp" 38 #include "utilities/constantTag.hpp" 39 40 // A ConstantPool is an array containing class constants as described in the 41 // class file. 42 // 43 // Most of the constant pool entries are written during class parsing, which 44 // is safe. For klass types, the constant pool entry is 45 // modified when the entry is resolved. If a klass constant pool 46 // entry is read without a lock, only the resolved state guarantees that 47 // the entry in the constant pool is a klass object and not a Symbol*. 48 49 class SymbolHashMap; 50 51 class CPSlot VALUE_OBJ_CLASS_SPEC { 52 friend class ConstantPool; 53 intptr_t _ptr; 54 enum TagBits {_pseudo_bit = 1}; 55 public: 56 57 CPSlot(intptr_t ptr): _ptr(ptr) {} 58 CPSlot(Symbol* ptr, int tag_bits = 0): _ptr((intptr_t)ptr | tag_bits) {} 59 60 intptr_t value() { return _ptr; } 61 bool is_pseudo_string() { return (_ptr & _pseudo_bit) != 0; } 62 63 Symbol* get_symbol() { 64 return (Symbol*)(_ptr & ~_pseudo_bit); 65 } 66 }; 67 68 // This represents a JVM_CONSTANT_Class, JVM_CONSTANT_UnresolvedClass, or 69 // JVM_CONSTANT_UnresolvedClassInError slot in the constant pool. 70 class CPKlassSlot VALUE_OBJ_CLASS_SPEC { 71 // cp->symbol_at(_name_index) gives the name of the class. 72 int _name_index; 73 74 // cp->_resolved_klasses->at(_resolved_klass_index) gives the Klass* for the class. 75 int _resolved_klass_index; 76 public: 77 enum { 78 // This is used during constant pool merging where the resolved klass index is 79 // not yet known, and will be computed at a later stage (during a call to 80 // initialize_unresolved_klasses()). 81 _temp_resolved_klass_index = 0xffff 82 }; 83 CPKlassSlot(int n, int rk) { 84 _name_index = n; 85 _resolved_klass_index = rk; 86 } 87 int name_index() const { 88 return _name_index; 89 } 90 int resolved_klass_index() const { | 31 #include "oops/objArrayOop.hpp" 32 #include "oops/oopHandle.hpp" 33 #include "oops/symbol.hpp" 34 #include "oops/typeArrayOop.hpp" 35 #include "runtime/handles.hpp" 36 #include "utilities/align.hpp" 37 #include "utilities/bytes.hpp" 38 #include "utilities/constantTag.hpp" 39 40 // A ConstantPool is an array containing class constants as described in the 41 // class file. 42 // 43 // Most of the constant pool entries are written during class parsing, which 44 // is safe. For klass types, the constant pool entry is 45 // modified when the entry is resolved. If a klass constant pool 46 // entry is read without a lock, only the resolved state guarantees that 47 // the entry in the constant pool is a klass object and not a Symbol*. 48 49 class SymbolHashMap; 50 51 class CPSlot { 52 friend class ConstantPool; 53 intptr_t _ptr; 54 enum TagBits {_pseudo_bit = 1}; 55 public: 56 57 CPSlot(intptr_t ptr): _ptr(ptr) {} 58 CPSlot(Symbol* ptr, int tag_bits = 0): _ptr((intptr_t)ptr | tag_bits) {} 59 60 intptr_t value() { return _ptr; } 61 bool is_pseudo_string() { return (_ptr & _pseudo_bit) != 0; } 62 63 Symbol* get_symbol() { 64 return (Symbol*)(_ptr & ~_pseudo_bit); 65 } 66 }; 67 68 // This represents a JVM_CONSTANT_Class, JVM_CONSTANT_UnresolvedClass, or 69 // JVM_CONSTANT_UnresolvedClassInError slot in the constant pool. 70 class CPKlassSlot { 71 // cp->symbol_at(_name_index) gives the name of the class. 72 int _name_index; 73 74 // cp->_resolved_klasses->at(_resolved_klass_index) gives the Klass* for the class. 75 int _resolved_klass_index; 76 public: 77 enum { 78 // This is used during constant pool merging where the resolved klass index is 79 // not yet known, and will be computed at a later stage (during a call to 80 // initialize_unresolved_klasses()). 81 _temp_resolved_klass_index = 0xffff 82 }; 83 CPKlassSlot(int n, int rk) { 84 _name_index = n; 85 _resolved_klass_index = rk; 86 } 87 int name_index() const { 88 return _name_index; 89 } 90 int resolved_klass_index() const { |