< prev index next >

src/hotspot/share/oops/instanceMirrorKlass.cpp

Print this page




  35 #include "oops/symbol.hpp"
  36 #include "runtime/handles.inline.hpp"
  37 #include "utilities/macros.hpp"
  38 
  39 int InstanceMirrorKlass::_offset_of_static_fields = 0;
  40 
  41 int InstanceMirrorKlass::instance_size(Klass* k) {
  42   if (k != NULL && k->is_instance_klass()) {
  43     return align_object_size(size_helper() + InstanceKlass::cast(k)->static_field_size());
  44   }
  45   return size_helper();
  46 }
  47 
  48 instanceOop InstanceMirrorKlass::allocate_instance(Klass* k, TRAPS) {
  49   // Query before forming handle.
  50   int size = instance_size(k);
  51   assert(size > 0, "total object size must be positive: %d", size);
  52 
  53   // Since mirrors can be variable sized because of the static fields, store
  54   // the size in the mirror itself.
  55   return (instanceOop)Universe::heap()->class_allocate(this, size, CHECK_NULL);

  56 }
  57 
  58 int InstanceMirrorKlass::oop_size(oop obj) const {
  59   return java_lang_Class::oop_size_raw(obj);
  60 }
  61 
  62 int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) {
  63   Klass* k = java_lang_Class::as_Klass(obj);
  64   if (k != NULL && k->is_instance_klass()) {
  65     return InstanceKlass::cast(k)->static_oop_field_count();
  66   }
  67   return 0;
  68 }
  69 
  70 #if INCLUDE_CDS
  71 void InstanceMirrorKlass::serialize_offsets(SerializeClosure* f) {
  72   f->do_u4((u4*)&_offset_of_static_fields);
  73 }
  74 #endif


  35 #include "oops/symbol.hpp"
  36 #include "runtime/handles.inline.hpp"
  37 #include "utilities/macros.hpp"
  38 
  39 int InstanceMirrorKlass::_offset_of_static_fields = 0;
  40 
  41 int InstanceMirrorKlass::instance_size(Klass* k) {
  42   if (k != NULL && k->is_instance_klass()) {
  43     return align_object_size(size_helper() + InstanceKlass::cast(k)->static_field_size());
  44   }
  45   return size_helper();
  46 }
  47 
  48 instanceOop InstanceMirrorKlass::allocate_instance(Klass* k, TRAPS) {
  49   // Query before forming handle.
  50   int size = instance_size(k);
  51   assert(size > 0, "total object size must be positive: %d", size);
  52 
  53   // Since mirrors can be variable sized because of the static fields, store
  54   // the size in the mirror itself.
  55   instanceOop i = (instanceOop)Universe::heap()->class_allocate(this, size, CHECK_NULL);
  56   return i;
  57 }
  58 
  59 int InstanceMirrorKlass::oop_size(oop obj) const {
  60   return java_lang_Class::oop_size_raw(obj);
  61 }
  62 
  63 int InstanceMirrorKlass::compute_static_oop_field_count(oop obj) {
  64   Klass* k = java_lang_Class::as_Klass(obj);
  65   if (k != NULL && k->is_instance_klass()) {
  66     return InstanceKlass::cast(k)->static_oop_field_count();
  67   }
  68   return 0;
  69 }
  70 
  71 #if INCLUDE_CDS
  72 void InstanceMirrorKlass::serialize_offsets(SerializeClosure* f) {
  73   f->do_u4((u4*)&_offset_of_static_fields);
  74 }
  75 #endif
< prev index next >