Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/oops/instanceMirrorKlass.hpp
32285 views
/*1* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP25#define SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP2627#include "classfile/systemDictionary.hpp"28#include "oops/instanceKlass.hpp"29#include "runtime/handles.hpp"30#include "utilities/macros.hpp"3132// An InstanceMirrorKlass is a specialized InstanceKlass for33// java.lang.Class instances. These instances are special because34// they contain the static fields of the class in addition to the35// normal fields of Class. This means they are variable sized36// instances and need special logic for computing their size and for37// iteration of their oops.383940class InstanceMirrorKlass: public InstanceKlass {41friend class VMStructs;42friend class InstanceKlass;4344private:45static int _offset_of_static_fields;4647// Constructor48InstanceMirrorKlass(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) {}5051public:52InstanceMirrorKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for CDS"); }53// Type testing54bool oop_is_instanceMirror() const { return true; }5556// Casting from Klass*57static InstanceMirrorKlass* cast(Klass* k) {58assert(k->oop_is_instanceMirror(), "cast to InstanceMirrorKlass");59return (InstanceMirrorKlass*) k;60}6162// Returns the size of the instance including the extra static fields.63virtual int oop_size(oop obj) const;6465// Static field offset is an offset into the Heap, should be converted by66// based on UseCompressedOop for traversal67static HeapWord* start_of_static_fields(oop obj) {68return (HeapWord*)(cast_from_oop<intptr_t>(obj) + offset_of_static_fields());69}7071static void init_offset_of_static_fields() {72// Cache the offset of the static fields in the Class instance73assert(_offset_of_static_fields == 0, "once");74_offset_of_static_fields = InstanceMirrorKlass::cast(SystemDictionary::Class_klass())->size_helper() << LogHeapWordSize;75}7677static int offset_of_static_fields() {78return _offset_of_static_fields;79}8081int compute_static_oop_field_count(oop obj);8283// Given a Klass return the size of the instance84int instance_size(KlassHandle k);8586// allocation87instanceOop allocate_instance(KlassHandle k, TRAPS);8889// Garbage collection90int oop_adjust_pointers(oop obj);91void oop_follow_contents(oop obj);9293// Parallel Scavenge and Parallel Old94PARALLEL_GC_DECLS9596int oop_oop_iterate(oop obj, ExtendedOopClosure* blk) {97return oop_oop_iterate_v(obj, blk);98}99int oop_oop_iterate_m(oop obj, ExtendedOopClosure* blk, MemRegion mr) {100return oop_oop_iterate_v_m(obj, blk, mr);101}102103#define InstanceMirrorKlass_OOP_OOP_ITERATE_DECL(OopClosureType, nv_suffix) \104int oop_oop_iterate##nv_suffix(oop obj, OopClosureType* blk); \105int oop_oop_iterate##nv_suffix##_m(oop obj, OopClosureType* blk, MemRegion mr);106107ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)108ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_DECL)109110#if INCLUDE_ALL_GCS111#define InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL(OopClosureType, nv_suffix) \112int oop_oop_iterate_backwards##nv_suffix(oop obj, OopClosureType* blk);113114ALL_OOP_OOP_ITERATE_CLOSURES_1(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)115ALL_OOP_OOP_ITERATE_CLOSURES_2(InstanceMirrorKlass_OOP_OOP_ITERATE_BACKWARDS_DECL)116#endif // INCLUDE_ALL_GCS117};118119#endif // SHARE_VM_OOPS_INSTANCEMIRRORKLASS_HPP120121122