1 /* 2 * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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. 8 * 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). 14 * 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. 18 * 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 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "ci/ciFlatArrayKlass.hpp" 27 #include "ci/ciInlineKlass.hpp" 28 #include "ci/ciInstanceKlass.hpp" 29 #include "ci/ciObjArrayKlass.hpp" 30 #include "ci/ciSymbol.hpp" 31 #include "ci/ciUtilities.hpp" 32 #include "ci/ciUtilities.inline.hpp" 33 #include "oops/flatArrayKlass.hpp" 34 #include "oops/inlineKlass.inline.hpp" 35 36 // ciFlatArrayKlass 37 // 38 // This class represents a Klass* in the HotSpot virtual machine 39 // whose Klass part is a FlatArrayKlass. 40 41 // ------------------------------------------------------------------ 42 // ciFlatArrayKlass::ciFlatArrayKlass 43 // 44 // Constructor for loaded inline type array klasses. 45 ciFlatArrayKlass::ciFlatArrayKlass(Klass* h_k) : ciArrayKlass(h_k) { 46 assert(get_Klass()->is_flatArray_klass(), "wrong type"); 47 InlineKlass* element_Klass = get_FlatArrayKlass()->element_klass(); 48 _base_element_klass = CURRENT_ENV->get_klass(element_Klass); 49 assert(_base_element_klass->is_inlinetype(), "bad base klass"); 50 if (dimension() == 1) { 51 _element_klass = _base_element_klass; 52 } else { 53 _element_klass = nullptr; 54 } 55 if (!ciObjectFactory::is_initialized()) { 56 assert(_element_klass->is_java_lang_Object(), "only arrays of object are shared"); 57 } 58 } 59 60 // ------------------------------------------------------------------ 61 // ciFlatArrayKlass::element_klass 62 // 63 // What is the one-level element type of this array? 64 ciKlass* ciFlatArrayKlass::element_klass() { 65 if (_element_klass == nullptr) { 66 assert(dimension() > 1, "_element_klass should not be nullptr"); 67 assert(is_loaded(), "FlatArrayKlass must be loaded"); 68 // Produce the element klass. 69 VM_ENTRY_MARK; 70 Klass* element_Klass = get_FlatArrayKlass()->element_klass(); 71 _element_klass = CURRENT_THREAD_ENV->get_klass(element_Klass); 72 } 73 return _element_klass; 74 } 75 76 ciKlass* ciFlatArrayKlass::exact_klass() { 77 assert(element_klass()->is_loaded() && element_klass()->as_inline_klass()->exact_klass() != nullptr, "must have exact klass"); 78 return this; 79 }