2
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
25
#include "precompiled.hpp"
26
#include "ci/ciArrayKlass.hpp"
27
#include "ci/ciObjArrayKlass.hpp"
28
#include "ci/ciTypeArrayKlass.hpp"
29
#include "ci/ciUtilities.inline.hpp"
30
#include "memory/universe.hpp"
34
// This class represents a Klass* in the HotSpot virtual machine
35
// whose Klass part in an ArrayKlass.
37
// ------------------------------------------------------------------
38
// ciArrayKlass::ciArrayKlass
41
ciArrayKlass::ciArrayKlass(Klass* k) : ciKlass(k) {
42
assert(get_Klass()->is_array_klass(), "wrong type");
43
_dimension = get_ArrayKlass()->dimension();
46
// ------------------------------------------------------------------
47
// ciArrayKlass::ciArrayKlass
49
// Unloaded array klass.
50
ciArrayKlass::ciArrayKlass(ciSymbol* name, int dimension, BasicType bt)
52
_dimension = dimension;
55
// ------------------------------------------------------------------
56
// ciArrayKlass::element_type
58
// What type is obtained when this array is indexed once?
59
ciType* ciArrayKlass::element_type() {
60
if (is_type_array_klass()) {
61
return ciType::make(as_type_array_klass()->element_type());
63
return as_obj_array_klass()->element_klass()->as_klass();
68
// ------------------------------------------------------------------
69
// ciArrayKlass::base_element_type
71
// What type is obtained when this array is indexed as many times as possible?
72
ciType* ciArrayKlass::base_element_type() {
73
if (is_type_array_klass()) {
74
return ciType::make(as_type_array_klass()->element_type());
76
ciKlass* ek = as_obj_array_klass()->base_element_klass();
77
if (ek->is_type_array_klass()) {
78
return ciType::make(ek->as_type_array_klass()->element_type());
85
// ------------------------------------------------------------------
86
// ciArrayKlass::is_leaf_type
87
bool ciArrayKlass::is_leaf_type() {
88
if (is_type_array_klass()) {
91
return as_obj_array_klass()->base_element_klass()->is_leaf_type();
96
// ------------------------------------------------------------------
99
// Make an array klass of the specified element type.
100
ciArrayKlass* ciArrayKlass::make(ciType* element_type) {
101
if (element_type->is_primitive_type()) {
102
return ciTypeArrayKlass::make(element_type->basic_type());
104
return ciObjArrayKlass::make(element_type->as_klass());