< prev index next >

src/hotspot/share/ci/ciArrayKlass.cpp

Print this page

  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 "ci/ciArrayKlass.hpp"


 26 #include "ci/ciObjArrayKlass.hpp"
 27 #include "ci/ciTypeArrayKlass.hpp"
 28 #include "ci/ciUtilities.inline.hpp"
 29 #include "memory/universe.hpp"

 30 
 31 // ciArrayKlass
 32 //
 33 // This class represents a Klass* in the HotSpot virtual machine
 34 // whose Klass part in an ArrayKlass.
 35 
 36 // ------------------------------------------------------------------
 37 // ciArrayKlass::ciArrayKlass
 38 //
 39 // Loaded array klass.
 40 ciArrayKlass::ciArrayKlass(Klass* k) : ciKlass(k) {
 41   assert(get_Klass()->is_array_klass(), "wrong type");
 42   _dimension = get_ArrayKlass()->dimension();
 43 }
 44 
 45 // ------------------------------------------------------------------
 46 // ciArrayKlass::ciArrayKlass
 47 //
 48 // Unloaded array klass.
 49 ciArrayKlass::ciArrayKlass(ciSymbol* name, int dimension, BasicType bt)
 50   : ciKlass(name, bt) {
 51   _dimension = dimension;
 52 }
 53 
 54 // ------------------------------------------------------------------
 55 // ciArrayKlass::element_type
 56 //
 57 // What type is obtained when this array is indexed once?
 58 ciType* ciArrayKlass::element_type() {
 59   if (is_type_array_klass()) {
 60     return ciType::make(as_type_array_klass()->element_type());
 61   } else {
 62     return as_obj_array_klass()->element_klass()->as_klass();
 63   }
 64 }
 65 
 66 
 67 // ------------------------------------------------------------------
 68 // ciArrayKlass::base_element_type
 69 //
 70 // What type is obtained when this array is indexed as many times as possible?
 71 ciType* ciArrayKlass::base_element_type() {
 72   if (is_type_array_klass()) {
 73     return ciType::make(as_type_array_klass()->element_type());
 74   } else {
 75     ciKlass* ek = as_obj_array_klass()->base_element_klass();
 76     if (ek->is_type_array_klass()) {
 77       return ciType::make(ek->as_type_array_klass()->element_type());
 78     }
 79     return ek;


 80   }
 81 }
 82 
 83 
 84 // ------------------------------------------------------------------
 85 // ciArrayKlass::is_leaf_type
 86 bool ciArrayKlass::is_leaf_type() {
 87   if (is_type_array_klass()) {
 88     return true;
 89   } else {
 90     return as_obj_array_klass()->base_element_klass()->is_leaf_type();
 91   }
 92 }
 93 
 94 
 95 // ------------------------------------------------------------------
 96 // ciArrayKlass::make
 97 //
 98 // Make an array klass of the specified element type.
 99 ciArrayKlass* ciArrayKlass::make(ciType* element_type) {
100   if (element_type->is_primitive_type()) {
101     return ciTypeArrayKlass::make(element_type->basic_type());
102   } else {
103     return ciObjArrayKlass::make(element_type->as_klass());
104   }
105 }
106 






















  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 "ci/ciArrayKlass.hpp"
 26 #include "ci/ciFlatArrayKlass.hpp"
 27 #include "ci/ciInlineKlass.hpp"
 28 #include "ci/ciObjArrayKlass.hpp"
 29 #include "ci/ciTypeArrayKlass.hpp"
 30 #include "ci/ciUtilities.inline.hpp"
 31 #include "memory/universe.hpp"
 32 #include "oops/inlineKlass.inline.hpp"
 33 
 34 // ciArrayKlass
 35 //
 36 // This class represents a Klass* in the HotSpot virtual machine
 37 // whose Klass part in an ArrayKlass.
 38 
 39 // ------------------------------------------------------------------
 40 // ciArrayKlass::ciArrayKlass
 41 //
 42 // Loaded array klass.
 43 ciArrayKlass::ciArrayKlass(Klass* k) : ciKlass(k) {
 44   assert(get_Klass()->is_array_klass(), "wrong type");
 45   _dimension = get_ArrayKlass()->dimension();
 46 }
 47 
 48 // ------------------------------------------------------------------
 49 // ciArrayKlass::ciArrayKlass
 50 //
 51 // Unloaded array klass.
 52 ciArrayKlass::ciArrayKlass(ciSymbol* name, int dimension, BasicType bt)
 53   : ciKlass(name, bt) {
 54   _dimension = dimension;
 55 }
 56 
 57 // ------------------------------------------------------------------
 58 // ciArrayKlass::element_type
 59 //
 60 // What type is obtained when this array is indexed once?
 61 ciType* ciArrayKlass::element_type() {
 62   if (is_type_array_klass()) {
 63     return ciType::make(as_type_array_klass()->element_type());
 64   } else {
 65     return element_klass()->as_klass();
 66   }
 67 }
 68 
 69 
 70 // ------------------------------------------------------------------
 71 // ciArrayKlass::base_element_type
 72 //
 73 // What type is obtained when this array is indexed as many times as possible?
 74 ciType* ciArrayKlass::base_element_type() {
 75   if (is_type_array_klass()) {
 76     return ciType::make(as_type_array_klass()->element_type());
 77   } else if (is_obj_array_klass()) {
 78     ciKlass* ek = as_obj_array_klass()->base_element_klass();
 79     if (ek->is_type_array_klass()) {
 80       return ciType::make(ek->as_type_array_klass()->element_type());
 81     }
 82     return ek;
 83   } else {
 84     return as_flat_array_klass()->base_element_klass();
 85   }
 86 }
 87 
 88 
 89 // ------------------------------------------------------------------
 90 // ciArrayKlass::is_leaf_type
 91 bool ciArrayKlass::is_leaf_type() {
 92   if (is_type_array_klass()) {
 93     return true;
 94   } else {
 95     return as_obj_array_klass()->base_element_klass()->is_leaf_type();
 96   }
 97 }
 98 
 99 
100 // ------------------------------------------------------------------
101 // ciArrayKlass::make
102 //
103 // Make an array klass of the specified element type.
104 ciArrayKlass* ciArrayKlass::make(ciType* element_type, bool null_free, bool atomic, bool vm_type) {
105   if (element_type->is_primitive_type()) {
106     return ciTypeArrayKlass::make(element_type->basic_type());
107   } else {
108     return ciObjArrayKlass::make(element_type->as_klass(), vm_type, null_free, atomic);
109   }
110 }
111 
112 int ciArrayKlass::array_header_in_bytes() {
113   return get_ArrayKlass()->array_header_in_bytes();
114 }
115 
116 ciInstance* ciArrayKlass::component_mirror_instance() const {
117   GUARDED_VM_ENTRY(
118     oop component_mirror = ArrayKlass::cast(get_Klass())->component_mirror();
119     return CURRENT_ENV->get_instance(component_mirror);
120   )
121 }
122 
123 bool ciArrayKlass::is_elem_null_free() const {
124   GUARDED_VM_ENTRY(return is_loaded() && get_Klass()->is_null_free_array_klass();)
125 }
126 
127 bool ciArrayKlass::is_elem_atomic() {
128   ciKlass* elem = element_klass();
129   GUARDED_VM_ENTRY(return elem != nullptr && elem->is_inlinetype() &&
130                           (ArrayKlass::cast(get_Klass())->properties() & ArrayKlass::ArrayProperties::INVALID) == 0 &&
131                           (ArrayKlass::cast(get_Klass())->properties() & ArrayKlass::ArrayProperties::NON_ATOMIC) == 0;)
132 }
< prev index next >