hotspot/src/share/vm/oops/instanceMirrorKlass.hpp
changeset 13738 d67be49a5beb
parent 13728 882756847a04
child 15482 470d0b0c09f1
equal deleted inserted replaced
13737:aa8c9eb6d900 13738:d67be49a5beb
    27 
    27 
    28 #include "classfile/systemDictionary.hpp"
    28 #include "classfile/systemDictionary.hpp"
    29 #include "oops/instanceKlass.hpp"
    29 #include "oops/instanceKlass.hpp"
    30 #include "runtime/handles.hpp"
    30 #include "runtime/handles.hpp"
    31 
    31 
    32 // An instanceMirrorKlass is a specialized InstanceKlass for
    32 // An InstanceMirrorKlass is a specialized InstanceKlass for
    33 // java.lang.Class instances.  These instances are special because
    33 // java.lang.Class instances.  These instances are special because
    34 // they contain the static fields of the class in addition to the
    34 // they contain the static fields of the class in addition to the
    35 // normal fields of Class.  This means they are variable sized
    35 // normal fields of Class.  This means they are variable sized
    36 // instances and need special logic for computing their size and for
    36 // instances and need special logic for computing their size and for
    37 // iteration of their oops.
    37 // iteration of their oops.
    38 
    38 
    39 
    39 
    40 class instanceMirrorKlass: public InstanceKlass {
    40 class InstanceMirrorKlass: public InstanceKlass {
    41   friend class VMStructs;
    41   friend class VMStructs;
    42   friend class InstanceKlass;
    42   friend class InstanceKlass;
    43 
    43 
    44  private:
    44  private:
    45   static int _offset_of_static_fields;
    45   static int _offset_of_static_fields;
    46 
    46 
    47   // Constructor
    47   // Constructor
    48   instanceMirrorKlass(int vtable_len, int itable_len, int static_field_size, int nonstatic_oop_map_size, ReferenceType rt, AccessFlags access_flags,  bool is_anonymous)
    48   InstanceMirrorKlass(int vtable_len, int itable_len, int static_field_size, int nonstatic_oop_map_size, ReferenceType rt, AccessFlags access_flags,  bool is_anonymous)
    49     : InstanceKlass(vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, access_flags, is_anonymous) {}
    49     : InstanceKlass(vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, access_flags, is_anonymous) {}
    50 
    50 
    51  public:
    51  public:
    52   instanceMirrorKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
    52   InstanceMirrorKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
    53   // Type testing
    53   // Type testing
    54   bool oop_is_instanceMirror() const             { return true; }
    54   bool oop_is_instanceMirror() const             { return true; }
    55 
    55 
    56   // Casting from Klass*
    56   // Casting from Klass*
    57   static instanceMirrorKlass* cast(Klass* k) {
    57   static InstanceMirrorKlass* cast(Klass* k) {
    58     assert(k->oop_is_instanceMirror(), "cast to instanceMirrorKlass");
    58     assert(k->oop_is_instanceMirror(), "cast to InstanceMirrorKlass");
    59     return (instanceMirrorKlass*) k;
    59     return (InstanceMirrorKlass*) k;
    60   }
    60   }
    61 
    61 
    62   // Returns the size of the instance including the extra static fields.
    62   // Returns the size of the instance including the extra static fields.
    63   virtual int oop_size(oop obj) const;
    63   virtual int oop_size(oop obj) const;
    64 
    64 
    69   }
    69   }
    70 
    70 
    71   static void init_offset_of_static_fields() {
    71   static void init_offset_of_static_fields() {
    72     // Cache the offset of the static fields in the Class instance
    72     // Cache the offset of the static fields in the Class instance
    73     assert(_offset_of_static_fields == 0, "once");
    73     assert(_offset_of_static_fields == 0, "once");
    74     _offset_of_static_fields = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;
    74     _offset_of_static_fields = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;
    75   }
    75   }
    76 
    76 
    77   static int offset_of_static_fields() {
    77   static int offset_of_static_fields() {
    78     return _offset_of_static_fields;
    78     return _offset_of_static_fields;
    79   }
    79   }