Path: blob/master/src/hotspot/share/oops/arrayKlass.hpp
40951 views
/*1* Copyright (c) 1997, 2021, 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_OOPS_ARRAYKLASS_HPP25#define SHARE_OOPS_ARRAYKLASS_HPP2627#include "oops/klass.hpp"2829class fieldDescriptor;30class klassVtable;3132// ArrayKlass is the abstract baseclass for all array classes3334class ArrayKlass: public Klass {35friend class VMStructs;36private:37// If you add a new field that points to any metaspace object, you38// must add this field to ArrayKlass::metaspace_pointers_do().39int _dimension; // This is n'th-dimensional array.40Klass* volatile _higher_dimension; // Refers the (n+1)'th-dimensional array (if present).41Klass* volatile _lower_dimension; // Refers the (n-1)'th-dimensional array (if present).4243protected:44// Constructors45// The constructor with the Symbol argument does the real array46// initialization, the other is a dummy47ArrayKlass(Symbol* name, KlassID id);48ArrayKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); }4950public:51// Testing operation52DEBUG_ONLY(bool is_array_klass_slow() const { return true; })5354// Instance variables55int dimension() const { return _dimension; }56void set_dimension(int dimension) { _dimension = dimension; }5758Klass* higher_dimension() const { return _higher_dimension; }59inline Klass* higher_dimension_acquire() const; // load with acquire semantics60void set_higher_dimension(Klass* k) { _higher_dimension = k; }61inline void release_set_higher_dimension(Klass* k); // store with release semantics6263Klass* lower_dimension() const { return _lower_dimension; }64void set_lower_dimension(Klass* k) { _lower_dimension = k; }6566// offset of first element, including any padding for the sake of alignment67int array_header_in_bytes() const { return layout_helper_header_size(layout_helper()); }68int log2_element_size() const { return layout_helper_log2_element_size(layout_helper()); }69// type of elements (T_OBJECT for both oop arrays and array-arrays)70BasicType element_type() const { return layout_helper_element_type(layout_helper()); }7172virtual InstanceKlass* java_super() const;7374// Allocation75// Sizes points to the first dimension of the array, subsequent dimensions76// are always in higher memory. The callers of these set that up.77virtual oop multi_allocate(int rank, jint* sizes, TRAPS);78objArrayOop allocate_arrayArray(int n, int length, TRAPS);7980// find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined81Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;8283// Lookup operations84Method* uncached_lookup_method(const Symbol* name,85const Symbol* signature,86OverpassLookupMode overpass_mode,87PrivateLookupMode private_mode = PrivateLookupMode::find) const;8889static ArrayKlass* cast(Klass* k) {90return const_cast<ArrayKlass*>(cast(const_cast<const Klass*>(k)));91}9293static const ArrayKlass* cast(const Klass* k) {94assert(k->is_array_klass(), "cast to ArrayKlass");95return static_cast<const ArrayKlass*>(k);96}9798GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots,99Array<InstanceKlass*>* transitive_interfaces);100101// Sizing102static int static_size(int header_size);103104virtual void metaspace_pointers_do(MetaspaceClosure* iter);105106// Iterators107void array_klasses_do(void f(Klass* k));108void array_klasses_do(void f(Klass* k, TRAPS), TRAPS);109110// Return a handle.111static void complete_create_array_klass(ArrayKlass* k, Klass* super_klass, ModuleEntry* module, TRAPS);112113114// jvm support115jint compute_modifier_flags() const;116117// JVMTI support118jint jvmti_class_status() const;119120// CDS support - remove and restore oops from metadata. Oops are not shared.121virtual void remove_unshareable_info();122virtual void remove_java_mirror();123void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);124125// Printing126void print_on(outputStream* st) const;127void print_value_on(outputStream* st) const;128129void oop_print_on(oop obj, outputStream* st);130131// Verification132void verify_on(outputStream* st);133134void oop_verify_on(oop obj, outputStream* st);135};136137#endif // SHARE_OOPS_ARRAYKLASS_HPP138139140