< prev index next > src/hotspot/share/oops/instanceMirrorKlass.cpp
Print this page
return align_object_size(size_helper() + InstanceKlass::cast(k)->static_field_size());
}
return size_helper();
}
! instanceOop InstanceMirrorKlass::allocate_instance(Klass* k, TRAPS) {
// Query before forming handle.
! size_t size = instance_size(k);
! assert(size > 0, "total object size must be non-zero: " SIZE_FORMAT, size);
// Since mirrors can be variable sized because of the static fields, store
// the size in the mirror itself.
! return (instanceOop)Universe::heap()->class_allocate(this, size, THREAD);
}
! size_t InstanceMirrorKlass::oop_size(oop obj) const {
return java_lang_Class::oop_size(obj);
}
int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) {
Klass* k = java_lang_Class::as_Klass(obj);
return align_object_size(size_helper() + InstanceKlass::cast(k)->static_field_size());
}
return size_helper();
}
! instanceOop InstanceMirrorKlass::allocate_instance(Klass* k, bool extend, TRAPS) {
// Query before forming handle.
! size_t base_size = instance_size(k);
! size_t size = base_size;
+ if (extend && UseCompactObjectHeaders) {
+ size = align_object_size(size + 1);
+ }
+ assert(base_size > 0, "base object size must be non-zero: " SIZE_FORMAT, base_size);
// Since mirrors can be variable sized because of the static fields, store
// the size in the mirror itself.
! instanceOop obj = (instanceOop)Universe::heap()->class_allocate(this, size, base_size, THREAD);
+ if (extend && UseCompactObjectHeaders) {
+ obj->set_mark(obj->mark().set_not_hashed_expanded());
+ }
+ return obj;
}
! size_t InstanceMirrorKlass::oop_size(oop obj, markWord mark) const {
return java_lang_Class::oop_size(obj);
}
int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) {
Klass* k = java_lang_Class::as_Klass(obj);
return InstanceKlass::cast(k)->static_oop_field_count();
}
return 0;
}
+ int InstanceMirrorKlass::hash_offset_in_bytes(oop obj) const {
+ assert(UseCompactObjectHeaders, "only with compact i-hash");
+ // TODO: There may be gaps that we could use, e.g. in the fields of Class,
+ // between the fields of Class and the static fields or in or at the end of
+ // the static fields block.
+ // When implementing any change here, make sure that allocate_instance()
+ // and corresponding code in InstanceMirrorKlass.java are in sync.
+ return checked_cast<int>(obj->base_size_given_klass(obj->mark(), this) * BytesPerWord);
+ }
+
#if INCLUDE_CDS
void InstanceMirrorKlass::serialize_offsets(SerializeClosure* f) {
f->do_int(&_offset_of_static_fields);
}
#endif
< prev index next >