Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/oops/arrayKlass.hpp
32285 views
/*1* Copyright (c) 1997, 2017, 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_ARRAYKLASS_HPP25#define SHARE_VM_OOPS_ARRAYKLASS_HPP2627#include "memory/universe.hpp"28#include "oops/klass.hpp"2930class fieldDescriptor;31class klassVtable;3233// ArrayKlass is the abstract baseclass for all array classes3435class ArrayKlass: public Klass {36friend class VMStructs;37private:38int _dimension; // This is n'th-dimensional array.39Klass* volatile _higher_dimension; // Refers the (n+1)'th-dimensional array (if present).40Klass* volatile _lower_dimension; // Refers the (n-1)'th-dimensional array (if present).41int _vtable_len; // size of vtable for this klass42oop _component_mirror; // component type, as a java/lang/Class4344protected:45// Constructors46// The constructor with the Symbol argument does the real array47// initialization, the other is a dummy48ArrayKlass(Symbol* name);49ArrayKlass() { assert(DumpSharedSpaces || UseSharedSpaces, "only for cds"); }5051public:52// Testing operation53bool oop_is_array_slow() const { return true; }5455// Instance variables56int dimension() const { return _dimension; }57void set_dimension(int dimension) { _dimension = dimension; }5859Klass* higher_dimension() const { return _higher_dimension; }60void set_higher_dimension(Klass* k) { _higher_dimension = k; }61Klass** adr_higher_dimension() { return (Klass**)&this->_higher_dimension;}6263Klass* lower_dimension() const { return _lower_dimension; }64void set_lower_dimension(Klass* k) { _lower_dimension = k; }65Klass** adr_lower_dimension() { return (Klass**)&this->_lower_dimension;}6667// offset of first element, including any padding for the sake of alignment68int array_header_in_bytes() const { return layout_helper_header_size(layout_helper()); }69int log2_element_size() const { return layout_helper_log2_element_size(layout_helper()); }70// type of elements (T_OBJECT for both oop arrays and array-arrays)71BasicType element_type() const { return layout_helper_element_type(layout_helper()); }7273oop component_mirror() const { return _component_mirror; }74void set_component_mirror(oop m) { klass_oop_store(&_component_mirror, m); }75oop* adr_component_mirror() { return (oop*)&this->_component_mirror;}7677// Compiler/Interpreter offset78static ByteSize component_mirror_offset() { return in_ByteSize(offset_of(ArrayKlass, _component_mirror)); }7980virtual Klass* java_super() const;//{ return SystemDictionary::Object_klass(); }8182// Allocation83// Sizes points to the first dimension of the array, subsequent dimensions84// are always in higher memory. The callers of these set that up.85virtual oop multi_allocate(int rank, jint* sizes, TRAPS);86objArrayOop allocate_arrayArray(int n, int length, TRAPS);8788// find field according to JVM spec 5.4.3.2, returns the klass in which the field is defined89Klass* find_field(Symbol* name, Symbol* sig, fieldDescriptor* fd) const;9091// Lookup operations92Method* uncached_lookup_method(Symbol* name, Symbol* signature, OverpassLookupMode overpass_mode) const;9394// Casting from Klass*95static ArrayKlass* cast(Klass* k) {96assert(k->oop_is_array(), "cast to ArrayKlass");97return (ArrayKlass*) k;98}99100GrowableArray<Klass*>* compute_secondary_supers(int num_extra_slots);101bool compute_is_subtype_of(Klass* k);102103// Sizing104static int header_size() { return sizeof(ArrayKlass)/HeapWordSize; }105static int static_size(int header_size);106107#if INCLUDE_SERVICES108virtual void collect_statistics(KlassSizeStats *sz) const {109Klass::collect_statistics(sz);110// Do nothing for now, but remember to modify if you add new111// stuff to ArrayKlass.112}113#endif114115// Java vtable116klassVtable* vtable() const; // return new klassVtable117int vtable_length() const { return _vtable_len; }118static int base_vtable_length() { return Universe::base_vtable_size(); }119void set_vtable_length(int len) { assert(len == base_vtable_length(), "bad length"); _vtable_len = len; }120protected:121inline intptr_t* start_of_vtable() const;122123public:124// Iterators125void array_klasses_do(void f(Klass* k));126void array_klasses_do(void f(Klass* k, TRAPS), TRAPS);127128// GC support129virtual void oops_do(OopClosure* cl);130131// Return a handle.132static void complete_create_array_klass(ArrayKlass* k, KlassHandle super_klass, TRAPS);133134135// jvm support136jint compute_modifier_flags(TRAPS) const;137138// JVMTI support139jint jvmti_class_status() const;140141// CDS support - remove and restore oops from metadata. Oops are not shared.142virtual void remove_unshareable_info();143virtual void restore_unshareable_info(ClassLoaderData* loader_data, Handle protection_domain, TRAPS);144145// Printing146void print_on(outputStream* st) const;147void print_value_on(outputStream* st) const;148149void oop_print_on(oop obj, outputStream* st);150151// Verification152void verify_on(outputStream* st);153154void oop_verify_on(oop obj, outputStream* st);155};156157#endif // SHARE_VM_OOPS_ARRAYKLASS_HPP158159160