src/share/vm/oops/instanceMirrorKlass.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/oops/instanceMirrorKlass.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,120 @@
     1.4 +/*
     1.5 + * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
    1.29 +#define SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP
    1.30 +
    1.31 +#include "classfile/systemDictionary.hpp"
    1.32 +#include "oops/instanceKlass.hpp"
    1.33 +#include "runtime/handles.hpp"
    1.34 +#include "utilities/macros.hpp"
    1.35 +
    1.36 +// An InstanceMirrorKlass is a specialized InstanceKlass for
    1.37 +// java.lang.Class instances.  These instances are special because
    1.38 +// they contain the static fields of the class in addition to the
    1.39 +// normal fields of Class.  This means they are variable sized
    1.40 +// instances and need special logic for computing their size and for
    1.41 +// iteration of their oops.
    1.42 +
    1.43 +
    1.44 +class InstanceMirrorKlass: public InstanceKlass {
    1.45 +  friend class VMStructs;
    1.46 +  friend class InstanceKlass;
    1.47 +
    1.48 + private:
    1.49 +  static int _offset_of_static_fields;
    1.50 +
    1.51 +  // Constructor
    1.52 +  InstanceMirrorKlass(int vtable_len, int itable_len, int static_field_size, int nonstatic_oop_map_size, ReferenceType rt, AccessFlags access_flags,  bool is_anonymous)
    1.53 +    : InstanceKlass(vtable_len, itable_len, static_field_size, nonstatic_oop_map_size, rt, access_flags, is_anonymous) {}
    1.54 +
    1.55 + public:
    1.56 +  InstanceMirrorKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }
    1.57 +  // Type testing
    1.58 +  bool oop_is_instanceMirror() const             { return true; }
    1.59 +
    1.60 +  // Casting from Klass*
    1.61 +  static InstanceMirrorKlass* cast(Klass* k) {
    1.62 +    assert(k->oop_is_instanceMirror(), "cast to InstanceMirrorKlass");
    1.63 +    return (InstanceMirrorKlass*) k;
    1.64 +  }
    1.65 +
    1.66 +  // Returns the size of the instance including the extra static fields.
    1.67 +  virtual int oop_size(oop obj) const;
    1.68 +
    1.69 +  // Static field offset is an offset into the Heap, should be converted by
    1.70 +  // based on UseCompressedOop for traversal
    1.71 +  static HeapWord* start_of_static_fields(oop obj) {
    1.72 +    return (HeapWord*)(cast_from_oop<intptr_t>(obj) + offset_of_static_fields());
    1.73 +  }
    1.74 +
    1.75 +  static void init_offset_of_static_fields() {
    1.76 +    // Cache the offset of the static fields in the Class instance
    1.77 +    assert(_offset_of_static_fields == 0, "once");
    1.78 +    _offset_of_static_fields = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;
    1.79 +  }
    1.80 +
    1.81 +  static int offset_of_static_fields() {
    1.82 +    return _offset_of_static_fields;
    1.83 +  }
    1.84 +
    1.85 +  int compute_static_oop_field_count(oop obj);
    1.86 +
    1.87 +  // Given a Klass return the size of the instance
    1.88 +  int instance_size(KlassHandle k);
    1.89 +
    1.90 +  // allocation
    1.91 +  instanceOop allocate_instance(KlassHandle k, TRAPS);
    1.92 +
    1.93 +  // Garbage collection
    1.94 +  int  oop_adjust_pointers(oop obj);
    1.95 +  void oop_follow_contents(oop obj);
    1.96 +
    1.97 +  // Parallel Scavenge and Parallel Old
    1.98 +  PARALLEL_GC_DECLS
    1.99 +
   1.100 +  int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) {
   1.101 +    return oop_oop_iterate_v(obj, blk);
   1.102 +  }
   1.103 +  int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr) {
   1.104 +    return oop_oop_iterate_v_m(obj, blk, mr);
   1.105 +  }
   1.106 +
   1.107 +#define InstanceMirrorKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)           \
   1.108 +  int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);                       \
   1.109 +  int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr);
   1.110 +
   1.111 +  ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
   1.112 +  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
   1.113 +
   1.114 +#if INCLUDE_ALL_GCS
   1.115 +#define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \
   1.116 +  int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk);
   1.117 +
   1.118 +  ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
   1.119 +  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
   1.120 +#endif // INCLUDE_ALL_GCS
   1.121 +};
   1.122 +
   1.123 +#endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP

mercurial