0N/A/*
2004N/A * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_OOPS_ARRAYKLASS_HPP
1879N/A#define SHARE_VM_OOPS_ARRAYKLASS_HPP
1879N/A
1879N/A#include "memory/universe.hpp"
1879N/A#include "oops/klass.hpp"
1879N/A#include "oops/klassOop.hpp"
1879N/A#include "oops/klassVtable.hpp"
1879N/A
0N/A// arrayKlass is the abstract baseclass for all array classes
0N/A
0N/Aclass arrayKlass: public Klass {
0N/A friend class VMStructs;
0N/A private:
0N/A int _dimension; // This is n'th-dimensional array.
2004N/A volatile klassOop _higher_dimension; // Refers the (n+1)'th-dimensional array (if present).
2004N/A volatile klassOop _lower_dimension; // Refers the (n-1)'th-dimensional array (if present).
0N/A int _vtable_len; // size of vtable for this klass
0N/A juint _alloc_size; // allocation profiling support
0N/A oop _component_mirror; // component type, as a java/lang/Class
0N/A
0N/A public:
0N/A // Testing operation
0N/A bool oop_is_array() const { return true; }
0N/A
0N/A // Instance variables
0N/A int dimension() const { return _dimension; }
0N/A void set_dimension(int dimension) { _dimension = dimension; }
0N/A
0N/A klassOop higher_dimension() const { return _higher_dimension; }
0N/A void set_higher_dimension(klassOop k) { oop_store_without_check((oop*) &_higher_dimension, (oop) k); }
0N/A oop* adr_higher_dimension() { return (oop*)&this->_higher_dimension;}
0N/A
0N/A klassOop lower_dimension() const { return _lower_dimension; }
0N/A void set_lower_dimension(klassOop k) { oop_store_without_check((oop*) &_lower_dimension, (oop) k); }
0N/A oop* adr_lower_dimension() { return (oop*)&this->_lower_dimension;}
0N/A
0N/A // Allocation profiling support
0N/A juint alloc_size() const { return _alloc_size; }
0N/A void set_alloc_size(juint n) { _alloc_size = n; }
0N/A
0N/A // offset of first element, including any padding for the sake of alignment
0N/A int array_header_in_bytes() const { return layout_helper_header_size(layout_helper()); }
0N/A int log2_element_size() const { return layout_helper_log2_element_size(layout_helper()); }
0N/A // type of elements (T_OBJECT for both oop arrays and array-arrays)
0N/A BasicType element_type() const { return layout_helper_element_type(layout_helper()); }
0N/A
0N/A oop component_mirror() const { return _component_mirror; }
0N/A void set_component_mirror(oop m) { oop_store((oop*) &_component_mirror, m); }
0N/A oop* adr_component_mirror() { return (oop*)&this->_component_mirror;}
0N/A
0N/A // Compiler/Interpreter offset
3042N/A static ByteSize component_mirror_offset() { return in_ByteSize(sizeof(klassOopDesc) + offset_of(arrayKlass, _component_mirror)); }
0N/A
1142N/A virtual klassOop java_super() const;//{ return SystemDictionary::Object_klass(); }
0N/A
0N/A // Allocation
0N/A // Sizes points to the first dimension of the array, subsequent dimensions
0N/A // are always in higher memory. The callers of these set that up.
0N/A virtual oop multi_allocate(int rank, jint* sizes, TRAPS);
0N/A objArrayOop allocate_arrayArray(int n, int length, TRAPS);
0N/A
0N/A // Lookup operations
2062N/A methodOop uncached_lookup_method(Symbol* name, Symbol* signature) const;
0N/A
0N/A // Casting from klassOop
0N/A static arrayKlass* cast(klassOop k) {
0N/A Klass* kp = k->klass_part();
0N/A assert(kp->null_vtbl() || kp->oop_is_array(), "cast to arrayKlass");
0N/A return (arrayKlass*) kp;
0N/A }
0N/A
0N/A objArrayOop compute_secondary_supers(int num_extra_slots, TRAPS);
0N/A bool compute_is_subtype_of(klassOop k);
0N/A
0N/A // Sizing
0N/A static int header_size() { return oopDesc::header_size() + sizeof(arrayKlass)/HeapWordSize; }
0N/A int object_size(int header_size) const;
0N/A
0N/A bool object_is_parsable() const { return _vtable_len > 0; }
0N/A
0N/A // Java vtable
0N/A klassVtable* vtable() const; // return new klassVtable
0N/A int vtable_length() const { return _vtable_len; }
0N/A static int base_vtable_length() { return Universe::base_vtable_size(); }
0N/A void set_vtable_length(int len) { assert(len == base_vtable_length(), "bad length"); _vtable_len = len; }
0N/A protected:
0N/A inline intptr_t* start_of_vtable() const;
0N/A
0N/A public:
0N/A // Iterators
0N/A void array_klasses_do(void f(klassOop k));
0N/A void with_array_klasses_do(void f(klassOop k));
0N/A
0N/A // Shared creation method
0N/A static arrayKlassHandle base_create_array_klass(
0N/A const Klass_vtbl& vtbl,
0N/A int header_size, KlassHandle klass,
0N/A TRAPS);
0N/A // Return a handle.
0N/A static void complete_create_array_klass(arrayKlassHandle k, KlassHandle super_klass, TRAPS);
0N/A
1601N/A // jvm support
1601N/A jint compute_modifier_flags(TRAPS) const;
0N/A
1601N/A // JVMTI support
1601N/A jint jvmti_class_status() const;
0N/A
0N/A // Printing
0N/A void oop_print_on(oop obj, outputStream* st);
1601N/A
0N/A // Verification
0N/A void oop_verify_on(oop obj, outputStream* st);
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_OOPS_ARRAYKLASS_HPP