< prev index next >

src/hotspot/share/oops/valueKlass.hpp

Print this page




 126 
 127   address adr_first_field_offset() const {
 128     assert(_adr_valueklass_fixed_block != NULL, "Should have been initialized");
 129     return ((address)_adr_valueklass_fixed_block) + in_bytes(byte_offset_of(ValueKlassFixedBlock, _first_field_offset));
 130   }
 131 
 132   address adr_exact_size_in_bytes() const {
 133     assert(_adr_valueklass_fixed_block != NULL, "Should have been initialized");
 134     return ((address)_adr_valueklass_fixed_block) + in_bytes(byte_offset_of(ValueKlassFixedBlock, _exact_size_in_bytes));
 135   }
 136 
 137  public:
 138   int get_alignment() const {
 139     return *(int*)adr_alignment();
 140   }
 141 
 142   void set_alignment(int alignment) {
 143     *(int*)adr_alignment() = alignment;
 144   }
 145 
 146   int get_first_field_offset() const {
 147     int offset = *(int*)adr_first_field_offset();
 148     assert(offset != 0, "Must be initialized before use");
 149     return *(int*)adr_first_field_offset();
 150   }
 151 
 152   void set_first_field_offset(int offset) {
 153     *(int*)adr_first_field_offset() = offset;
 154   }
 155 
 156   int get_exact_size_in_bytes() {
 157     return *(int*)adr_exact_size_in_bytes();
 158   }
 159 
 160   void set_exact_size_in_bytes(int exact_size) {
 161     *(int*)adr_exact_size_in_bytes() = exact_size;
 162   }
 163 


 164  private:
 165   int collect_fields(GrowableArray<SigEntry>* sig, int base_off = 0) const;
 166 
 167   void cleanup_blobs();
 168 
 169   int first_field_offset_old() const;
 170 
 171  protected:
 172   // Returns the array class for the n'th dimension
 173   Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, int n, TRAPS);
 174 
 175   // Returns the array class with this class as element type
 176   Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, TRAPS);
 177 
 178   // Specifically flat array klass
 179   Klass* value_array_klass(ArrayStorageProperties storage_props, bool or_null, int rank, TRAPS);
 180 
 181  public:
 182   // Type testing
 183   bool is_value_slow() const        { return true; }
 184 
 185   // value_mirror is the primary mirror
 186   oop value_mirror() const    { return java_lang_Class::inline_type_mirror(java_mirror()); }
 187   oop indirect_mirror() const { return java_lang_Class::indirect_type_mirror(java_mirror()); }
 188 
 189   // Casting from Klass*
 190   static ValueKlass* cast(Klass* k) {
 191     assert(k->is_value(), "cast to ValueKlass");
 192     return (ValueKlass*) k;
 193   }
 194 
 195   // Use this to return the size of an instance in heap words
 196   // Implementation is currently simple because all value types are allocated
 197   // in Java heap like Java objects.
 198   virtual int size_helper() const {
 199     return layout_helper_to_size_helper(layout_helper());
 200   }
 201 
 202   // Metadata iterators
 203   void array_klasses_do(void f(Klass* k));
 204 
 205   // allocate_instance() allocates a stand alone value in the Java heap
 206   instanceOop allocate_instance(TRAPS);
 207 
 208   // minimum number of bytes occupied by nonstatic fields, HeapWord aligned or pow2
 209   int raw_value_byte_size() const;
 210 
 211   int first_field_offset() const {
 212     // To be refactored/simplified once old layout code and UseNewLayout are removed
 213     if (UseNewLayout) {
 214       return get_first_field_offset();
 215     } else {
 216       return first_field_offset_old();
 217     }
 218   };
 219 
 220   address data_for_oop(oop o) const {
 221     return ((address) (void*) o) + first_field_offset();
 222   }
 223 
 224   oop oop_for_data(address data) const {
 225     oop o = (oop) (data - first_field_offset());
 226     assert(oopDesc::is_oop(o, false), "Not an oop");
 227     return o;
 228   }
 229 
 230   // Query if h/w provides atomic load/store
 231   bool is_atomic();
 232 
 233   bool flatten_array();
 234 
 235   bool contains_oops() const { return nonstatic_oop_map_count() > 0; }
 236   int nonstatic_oop_count();
 237 
 238   // Prototype general store methods...




 126 
 127   address adr_first_field_offset() const {
 128     assert(_adr_valueklass_fixed_block != NULL, "Should have been initialized");
 129     return ((address)_adr_valueklass_fixed_block) + in_bytes(byte_offset_of(ValueKlassFixedBlock, _first_field_offset));
 130   }
 131 
 132   address adr_exact_size_in_bytes() const {
 133     assert(_adr_valueklass_fixed_block != NULL, "Should have been initialized");
 134     return ((address)_adr_valueklass_fixed_block) + in_bytes(byte_offset_of(ValueKlassFixedBlock, _exact_size_in_bytes));
 135   }
 136 
 137  public:
 138   int get_alignment() const {
 139     return *(int*)adr_alignment();
 140   }
 141 
 142   void set_alignment(int alignment) {
 143     *(int*)adr_alignment() = alignment;
 144   }
 145 
 146   int first_field_offset() const {
 147     int offset = *(int*)adr_first_field_offset();
 148     assert(offset != 0, "Must be initialized before use");
 149     return *(int*)adr_first_field_offset();
 150   }
 151 
 152   void set_first_field_offset(int offset) {
 153     *(int*)adr_first_field_offset() = offset;
 154   }
 155 
 156   int get_exact_size_in_bytes() {
 157     return *(int*)adr_exact_size_in_bytes();
 158   }
 159 
 160   void set_exact_size_in_bytes(int exact_size) {
 161     *(int*)adr_exact_size_in_bytes() = exact_size;
 162   }
 163 
 164   int first_field_offset_old();
 165 
 166  private:
 167   int collect_fields(GrowableArray<SigEntry>* sig, int base_off = 0);
 168 
 169   void cleanup_blobs();
 170 

 171 
 172  protected:
 173   // Returns the array class for the n'th dimension
 174   Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, int n, TRAPS);
 175 
 176   // Returns the array class with this class as element type
 177   Klass* array_klass_impl(ArrayStorageProperties storage_props, bool or_null, TRAPS);
 178 
 179   // Specifically flat array klass
 180   Klass* value_array_klass(ArrayStorageProperties storage_props, bool or_null, int rank, TRAPS);
 181 
 182  public:
 183   // Type testing
 184   bool is_value_slow() const        { return true; }
 185 
 186   // value_mirror is the primary mirror
 187   oop value_mirror() const    { return java_lang_Class::inline_type_mirror(java_mirror()); }
 188   oop indirect_mirror() const { return java_lang_Class::indirect_type_mirror(java_mirror()); }
 189 
 190   // Casting from Klass*
 191   static ValueKlass* cast(Klass* k) {
 192     assert(k->is_value(), "cast to ValueKlass");
 193     return (ValueKlass*) k;
 194   }
 195 
 196   // Use this to return the size of an instance in heap words
 197   // Implementation is currently simple because all value types are allocated
 198   // in Java heap like Java objects.
 199   virtual int size_helper() const {
 200     return layout_helper_to_size_helper(layout_helper());
 201   }
 202 
 203   // Metadata iterators
 204   void array_klasses_do(void f(Klass* k));
 205 
 206   // allocate_instance() allocates a stand alone value in the Java heap
 207   instanceOop allocate_instance(TRAPS);
 208 
 209   // minimum number of bytes occupied by nonstatic fields, HeapWord aligned or pow2
 210   int raw_value_byte_size();









 211 
 212   address data_for_oop(oop o) const {
 213     return ((address) (void*) o) + first_field_offset();
 214   }
 215 
 216   oop oop_for_data(address data) const {
 217     oop o = (oop) (data - first_field_offset());
 218     assert(oopDesc::is_oop(o, false), "Not an oop");
 219     return o;
 220   }
 221 
 222   // Query if h/w provides atomic load/store
 223   bool is_atomic();
 224 
 225   bool flatten_array();
 226 
 227   bool contains_oops() const { return nonstatic_oop_map_count() > 0; }
 228   int nonstatic_oop_count();
 229 
 230   // Prototype general store methods...


< prev index next >