Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/ci/ciArrayKlass.cpp
32285 views
/*1* Copyright (c) 1999, 2012, 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#include "precompiled.hpp"25#include "ci/ciArrayKlass.hpp"26#include "ci/ciObjArrayKlass.hpp"27#include "ci/ciTypeArrayKlass.hpp"28#include "ci/ciUtilities.hpp"2930// ciArrayKlass31//32// This class represents a Klass* in the HotSpot virtual machine33// whose Klass part in an ArrayKlass.3435// ------------------------------------------------------------------36// ciArrayKlass::ciArrayKlass37//38// Loaded array klass.39ciArrayKlass::ciArrayKlass(KlassHandle h_k) : ciKlass(h_k) {40assert(get_Klass()->oop_is_array(), "wrong type");41_dimension = get_ArrayKlass()->dimension();42}4344// ------------------------------------------------------------------45// ciArrayKlass::ciArrayKlass46//47// Unloaded array klass.48ciArrayKlass::ciArrayKlass(ciSymbol* name, int dimension, BasicType bt)49: ciKlass(name, bt) {50_dimension = dimension;51}5253// ------------------------------------------------------------------54// ciArrayKlass::element_type55//56// What type is obtained when this array is indexed once?57ciType* ciArrayKlass::element_type() {58if (is_type_array_klass()) {59return ciType::make(as_type_array_klass()->element_type());60} else {61return as_obj_array_klass()->element_klass()->as_klass();62}63}646566// ------------------------------------------------------------------67// ciArrayKlass::base_element_type68//69// What type is obtained when this array is indexed as many times as possible?70ciType* ciArrayKlass::base_element_type() {71if (is_type_array_klass()) {72return ciType::make(as_type_array_klass()->element_type());73} else {74ciKlass* ek = as_obj_array_klass()->base_element_klass();75if (ek->is_type_array_klass()) {76return ciType::make(ek->as_type_array_klass()->element_type());77}78return ek;79}80}818283// ------------------------------------------------------------------84// ciArrayKlass::is_leaf_type85bool ciArrayKlass::is_leaf_type() {86if (is_type_array_klass()) {87return true;88} else {89return as_obj_array_klass()->base_element_klass()->is_leaf_type();90}91}929394// ------------------------------------------------------------------95// ciArrayKlass::base_element_type96//97// What type is obtained when this array is indexed as many times as possible?98ciArrayKlass* ciArrayKlass::make(ciType* element_type) {99if (element_type->is_primitive_type()) {100return ciTypeArrayKlass::make(element_type->basic_type());101} else {102return ciObjArrayKlass::make(element_type->as_klass());103}104}105106107