src/share/vm/oops/instanceMirrorKlass.hpp

changeset 2658
c7f3d0b4570f
child 2693
63997f575155
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/oops/instanceMirrorKlass.hpp	Fri Mar 18 16:00:34 2011 -0700
     1.3 @@ -0,0 +1,110 @@
     1.4 +/*
     1.5 + * Copyright (c) 2011, 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 "oops/instanceKlass.hpp"
    1.32 +
    1.33 +// An instanceMirrorKlass is a specialized instanceKlass for
    1.34 +// java.lang.Class instances.  These instances are special because
    1.35 +// they contain the static fields of the class in addition to the
    1.36 +// normal fields of Class.  This means they are variable sized
    1.37 +// instances and need special logic for computing their size and for
    1.38 +// iteration of their oops.
    1.39 +
    1.40 +
    1.41 +class instanceMirrorKlass: public instanceKlass {
    1.42 + private:
    1.43 +  static int _offset_of_static_fields;
    1.44 +
    1.45 + public:
    1.46 +  // Type testing
    1.47 +  bool oop_is_instanceMirror() const             { return true; }
    1.48 +
    1.49 +  // Casting from klassOop
    1.50 +  static instanceMirrorKlass* cast(klassOop k) {
    1.51 +    assert(k->klass_part()->oop_is_instanceMirror(), "cast to instanceMirrorKlass");
    1.52 +    return (instanceMirrorKlass*) k->klass_part();
    1.53 +  }
    1.54 +
    1.55 +  // Returns the size of the instance including the extra static fields.
    1.56 +  virtual int oop_size(oop obj) const;
    1.57 +
    1.58 +  // Static field offset is an offset into the Heap, should be converted by
    1.59 +  // based on UseCompressedOop for traversal
    1.60 +  static HeapWord* start_of_static_fields(oop obj) {
    1.61 +    return (HeapWord*)((intptr_t)obj + offset_of_static_fields());
    1.62 +  }
    1.63 +
    1.64 +  static void init_offset_of_static_fields() {
    1.65 +    // Cache the offset of the static fields in the Class instance
    1.66 +    assert(_offset_of_static_fields == 0, "once");
    1.67 +    _offset_of_static_fields = instanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;
    1.68 +  }
    1.69 +
    1.70 +  static int offset_of_static_fields() {
    1.71 +    return _offset_of_static_fields;
    1.72 +  }
    1.73 +
    1.74 +  int compute_static_oop_field_count(oop obj);
    1.75 +
    1.76 +  // Given a Klass return the size of the instance
    1.77 +  int instance_size(KlassHandle k);
    1.78 +
    1.79 +  // allocation
    1.80 +  DEFINE_ALLOCATE_PERMANENT(instanceMirrorKlass);
    1.81 +  instanceOop allocate_instance(KlassHandle k, TRAPS);
    1.82 +
    1.83 +  // Garbage collection
    1.84 +  int  oop_adjust_pointers(oop obj);
    1.85 +  void oop_follow_contents(oop obj);
    1.86 +
    1.87 +  // Parallel Scavenge and Parallel Old
    1.88 +  PARALLEL_GC_DECLS
    1.89 +
    1.90 +  int oop_oop_iterate(oop obj, OopClosure* blk) {
    1.91 +    return oop_oop_iterate_v(obj, blk);
    1.92 +  }
    1.93 +  int oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
    1.94 +    return oop_oop_iterate_v_m(obj, blk, mr);
    1.95 +  }
    1.96 +
    1.97 +#define InstanceMirrorKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix)           \
    1.98 +  int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk);                       \
    1.99 +  int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr);
   1.100 +
   1.101 +  ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
   1.102 +  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)
   1.103 +
   1.104 +#ifndef SERIALGC
   1.105 +#define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \
   1.106 +  int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk);
   1.107 +
   1.108 +  ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
   1.109 +  ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)
   1.110 +#endif // !SERIALGC
   1.111 +};
   1.112 +
   1.113 +#endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP

mercurial