annotate src/share/vm/oops/typeArrayKlass.cpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents 9d7a8ab3736b
children d4fca0a6abde
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1334
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1334
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1334
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
26 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
27 #include "classfile/vmSymbols.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
28 #include "gc_interface/collectedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
29 #include "gc_interface/collectedHeap.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
30 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
31 #include "memory/universe.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
32 #include "memory/universe.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
33 #include "oops/instanceKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
34 #include "oops/klassOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
35 #include "oops/objArrayKlassKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
36 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
37 #include "oops/typeArrayKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
38 #include "oops/typeArrayOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1706
diff changeset
39 #include "runtime/handles.inline.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41 bool typeArrayKlass::compute_is_subtype_of(klassOop k) {
a61af66fc99e Initial load
duke
parents:
diff changeset
42 if (!k->klass_part()->oop_is_typeArray()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 return arrayKlass::compute_is_subtype_of(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
44 }
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 typeArrayKlass* tak = typeArrayKlass::cast(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 if (dimension() != tak->dimension()) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 return element_type() == tak->element_type();
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
481
7d7a7c599c17 6578152: fill_region_with_object has usability and safety issues
jcoomes
parents: 0
diff changeset
52 klassOop typeArrayKlass::create_klass(BasicType type, int scale,
7d7a7c599c17 6578152: fill_region_with_object has usability and safety issues
jcoomes
parents: 0
diff changeset
53 const char* name_str, TRAPS) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
54 typeArrayKlass o;
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 symbolHandle sym(symbolOop(NULL));
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // bootstrapping: don't create sym if symbolKlass not created yet
481
7d7a7c599c17 6578152: fill_region_with_object has usability and safety issues
jcoomes
parents: 0
diff changeset
58 if (Universe::symbolKlassObj() != NULL && name_str != NULL) {
7d7a7c599c17 6578152: fill_region_with_object has usability and safety issues
jcoomes
parents: 0
diff changeset
59 sym = oopFactory::new_symbol_handle(name_str, CHECK_NULL);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 KlassHandle klassklass (THREAD, Universe::typeArrayKlassKlassObj());
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 arrayKlassHandle k = base_create_array_klass(o.vtbl_value(), header_size(), klassklass, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 typeArrayKlass* ak = typeArrayKlass::cast(k());
a61af66fc99e Initial load
duke
parents:
diff changeset
65 ak->set_name(sym());
a61af66fc99e Initial load
duke
parents:
diff changeset
66 ak->set_layout_helper(array_layout_helper(type));
a61af66fc99e Initial load
duke
parents:
diff changeset
67 assert(scale == (1 << ak->log2_element_size()), "scale must check out");
a61af66fc99e Initial load
duke
parents:
diff changeset
68 assert(ak->oop_is_javaArray(), "sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
69 assert(ak->oop_is_typeArray(), "sanity");
a61af66fc99e Initial load
duke
parents:
diff changeset
70 ak->set_max_length(arrayOopDesc::max_array_length(type));
a61af66fc99e Initial load
duke
parents:
diff changeset
71 assert(k()->size() > header_size(), "bad size");
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // Call complete_create_array_klass after all instance variables have been initialized.
a61af66fc99e Initial load
duke
parents:
diff changeset
74 KlassHandle super (THREAD, k->super());
a61af66fc99e Initial load
duke
parents:
diff changeset
75 complete_create_array_klass(k, super, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 return k();
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 typeArrayOop typeArrayKlass::allocate(int length, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 assert(log2_element_size() >= 0, "bad scale");
a61af66fc99e Initial load
duke
parents:
diff changeset
82 if (length >= 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 if (length <= max_length()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 size_t size = typeArrayOopDesc::object_size(layout_helper(), length);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 KlassHandle h_k(THREAD, as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
86 typeArrayOop t;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 CollectedHeap* ch = Universe::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
88 if (size < ch->large_typearray_limit()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 t = (typeArrayOop)CollectedHeap::array_allocate(h_k, (int)size, length, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
90 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 t = (typeArrayOop)CollectedHeap::large_typearray_allocate(h_k, (int)size, length, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 assert(t->is_parsable(), "Don't publish unless parsable");
a61af66fc99e Initial load
duke
parents:
diff changeset
94 return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 } else {
876
1413494da700 6850957: Honor -XX:OnOutOfMemoryError when array size exceeds VM limit
martin
parents: 579
diff changeset
96 report_java_out_of_memory("Requested array size exceeds VM limit");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
97 THROW_OOP_0(Universe::out_of_memory_error_array_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 typeArrayOop typeArrayKlass::allocate_permanent(int length, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
105 if (length < 0) THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
a61af66fc99e Initial load
duke
parents:
diff changeset
106 int size = typeArrayOopDesc::object_size(layout_helper(), length);
a61af66fc99e Initial load
duke
parents:
diff changeset
107 KlassHandle h_k(THREAD, as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
108 typeArrayOop t = (typeArrayOop)
a61af66fc99e Initial load
duke
parents:
diff changeset
109 CollectedHeap::permanent_array_allocate(h_k, size, length, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 assert(t->is_parsable(), "Can't publish until parsable");
a61af66fc99e Initial load
duke
parents:
diff changeset
111 return t;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 oop typeArrayKlass::multi_allocate(int rank, jint* last_size, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // For typeArrays this is only called for the last dimension
a61af66fc99e Initial load
duke
parents:
diff changeset
116 assert(rank == 1, "just checking");
a61af66fc99e Initial load
duke
parents:
diff changeset
117 int length = *last_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return allocate(length, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 void typeArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d, int dst_pos, int length, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 assert(s->is_typeArray(), "must be type array");
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Check destination
a61af66fc99e Initial load
duke
parents:
diff changeset
126 if (!d->is_typeArray() || element_type() != typeArrayKlass::cast(d->klass())->element_type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 THROW(vmSymbols::java_lang_ArrayStoreException());
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Check is all offsets and lengths are non negative
a61af66fc99e Initial load
duke
parents:
diff changeset
131 if (src_pos < 0 || dst_pos < 0 || length < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Check if the ranges are valid
a61af66fc99e Initial load
duke
parents:
diff changeset
135 if ( (((unsigned int) length + (unsigned int) src_pos) > (unsigned int) s->length())
a61af66fc99e Initial load
duke
parents:
diff changeset
136 || (((unsigned int) length + (unsigned int) dst_pos) > (unsigned int) d->length()) ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException());
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
1334
b5d78a3b8843 6892265: System.arraycopy unable to reference elements beyond Integer.MAX_VALUE bytes
kvn
parents: 876
diff changeset
139 // Check zero copy
b5d78a3b8843 6892265: System.arraycopy unable to reference elements beyond Integer.MAX_VALUE bytes
kvn
parents: 876
diff changeset
140 if (length == 0)
b5d78a3b8843 6892265: System.arraycopy unable to reference elements beyond Integer.MAX_VALUE bytes
kvn
parents: 876
diff changeset
141 return;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 // This is an attempt to make the copy_array fast.
a61af66fc99e Initial load
duke
parents:
diff changeset
144 int l2es = log2_element_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
145 int ihs = array_header_in_bytes() / wordSize;
1334
b5d78a3b8843 6892265: System.arraycopy unable to reference elements beyond Integer.MAX_VALUE bytes
kvn
parents: 876
diff changeset
146 char* src = (char*) ((oop*)s + ihs) + ((size_t)src_pos << l2es);
b5d78a3b8843 6892265: System.arraycopy unable to reference elements beyond Integer.MAX_VALUE bytes
kvn
parents: 876
diff changeset
147 char* dst = (char*) ((oop*)d + ihs) + ((size_t)dst_pos << l2es);
b5d78a3b8843 6892265: System.arraycopy unable to reference elements beyond Integer.MAX_VALUE bytes
kvn
parents: 876
diff changeset
148 Copy::conjoint_memory_atomic(src, dst, (size_t)length << l2es);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
149 }
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // create a klass of array holding typeArrays
a61af66fc99e Initial load
duke
parents:
diff changeset
153 klassOop typeArrayKlass::array_klass_impl(bool or_null, int n, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 typeArrayKlassHandle h_this(THREAD, as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
155 return array_klass_impl(h_this, or_null, n, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 klassOop typeArrayKlass::array_klass_impl(typeArrayKlassHandle h_this, bool or_null, int n, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 int dimension = h_this->dimension();
a61af66fc99e Initial load
duke
parents:
diff changeset
160 assert(dimension <= n, "check order of chain");
a61af66fc99e Initial load
duke
parents:
diff changeset
161 if (dimension == n)
a61af66fc99e Initial load
duke
parents:
diff changeset
162 return h_this();
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 objArrayKlassHandle h_ak(THREAD, h_this->higher_dimension());
a61af66fc99e Initial load
duke
parents:
diff changeset
165 if (h_ak.is_null()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 if (or_null) return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 JavaThread *jt = (JavaThread *)THREAD;
a61af66fc99e Initial load
duke
parents:
diff changeset
170 {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 MutexLocker mc(Compile_lock, THREAD); // for vtables
a61af66fc99e Initial load
duke
parents:
diff changeset
172 // Atomic create higher dimension and link into list
a61af66fc99e Initial load
duke
parents:
diff changeset
173 MutexLocker mu(MultiArray_lock, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 h_ak = objArrayKlassHandle(THREAD, h_this->higher_dimension());
a61af66fc99e Initial load
duke
parents:
diff changeset
176 if (h_ak.is_null()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 klassOop oak = objArrayKlassKlass::cast(
a61af66fc99e Initial load
duke
parents:
diff changeset
178 Universe::objArrayKlassKlassObj())->allocate_objArray_klass(
a61af66fc99e Initial load
duke
parents:
diff changeset
179 dimension + 1, h_this, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 h_ak = objArrayKlassHandle(THREAD, oak);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 h_ak->set_lower_dimension(h_this());
a61af66fc99e Initial load
duke
parents:
diff changeset
182 h_this->set_higher_dimension(h_ak());
a61af66fc99e Initial load
duke
parents:
diff changeset
183 assert(h_ak->oop_is_objArray(), "incorrect initialization of objArrayKlass");
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
187 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 if (or_null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
190 return h_ak->array_klass_or_null(n);
a61af66fc99e Initial load
duke
parents:
diff changeset
191 }
a61af66fc99e Initial load
duke
parents:
diff changeset
192 return h_ak->array_klass(n, CHECK_NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 klassOop typeArrayKlass::array_klass_impl(bool or_null, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 return array_klass_impl(or_null, dimension() + 1, THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
197 }
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 int typeArrayKlass::oop_size(oop obj) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
200 assert(obj->is_typeArray(),"must be a type array");
a61af66fc99e Initial load
duke
parents:
diff changeset
201 typeArrayOop t = typeArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
202 return t->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 void typeArrayKlass::oop_follow_contents(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
206 assert(obj->is_typeArray(),"must be a type array");
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // know that Universe::typeArrayKlass never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210
a61af66fc99e Initial load
duke
parents:
diff changeset
211 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
212 void typeArrayKlass::oop_follow_contents(ParCompactionManager* cm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
213 assert(obj->is_typeArray(),"must be a type array");
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // know that Universe::typeArrayKlass never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 int typeArrayKlass::oop_adjust_pointers(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
220 assert(obj->is_typeArray(),"must be a type array");
a61af66fc99e Initial load
duke
parents:
diff changeset
221 typeArrayOop t = typeArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
223 // know that Universe::typeArrayKlass never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
224 return t->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 int typeArrayKlass::oop_oop_iterate(oop obj, OopClosure* blk) {
a61af66fc99e Initial load
duke
parents:
diff changeset
228 assert(obj->is_typeArray(),"must be a type array");
a61af66fc99e Initial load
duke
parents:
diff changeset
229 typeArrayOop t = typeArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // know that Universe::typeArrayKlass never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
232 return t->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
233 }
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 int typeArrayKlass::oop_oop_iterate_m(oop obj, OopClosure* blk, MemRegion mr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 assert(obj->is_typeArray(),"must be a type array");
a61af66fc99e Initial load
duke
parents:
diff changeset
237 typeArrayOop t = typeArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // Performance tweak: We skip iterating over the klass pointer since we
a61af66fc99e Initial load
duke
parents:
diff changeset
239 // know that Universe::typeArrayKlass never moves.
a61af66fc99e Initial load
duke
parents:
diff changeset
240 return t->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
241 }
a61af66fc99e Initial load
duke
parents:
diff changeset
242
a61af66fc99e Initial load
duke
parents:
diff changeset
243 #ifndef SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
244 void typeArrayKlass::oop_push_contents(PSPromotionManager* pm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 assert(obj->is_typeArray(),"must be a type array");
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 int
a61af66fc99e Initial load
duke
parents:
diff changeset
249 typeArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 assert(obj->is_typeArray(),"must be a type array");
a61af66fc99e Initial load
duke
parents:
diff changeset
251 return typeArrayOop(obj)->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 int
a61af66fc99e Initial load
duke
parents:
diff changeset
255 typeArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj,
a61af66fc99e Initial load
duke
parents:
diff changeset
256 HeapWord* beg_addr, HeapWord* end_addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 assert(obj->is_typeArray(),"must be a type array");
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return typeArrayOop(obj)->object_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260 #endif // SERIALGC
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 void typeArrayKlass::initialize(TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // Nothing to do. Having this function is handy since objArrayKlasses can be
a61af66fc99e Initial load
duke
parents:
diff changeset
264 // initialized by calling initialize on their bottom_klass, see objArrayKlass::initialize
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 const char* typeArrayKlass::external_name(BasicType type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
268 switch (type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
269 case T_BOOLEAN: return "[Z";
a61af66fc99e Initial load
duke
parents:
diff changeset
270 case T_CHAR: return "[C";
a61af66fc99e Initial load
duke
parents:
diff changeset
271 case T_FLOAT: return "[F";
a61af66fc99e Initial load
duke
parents:
diff changeset
272 case T_DOUBLE: return "[D";
a61af66fc99e Initial load
duke
parents:
diff changeset
273 case T_BYTE: return "[B";
a61af66fc99e Initial load
duke
parents:
diff changeset
274 case T_SHORT: return "[S";
a61af66fc99e Initial load
duke
parents:
diff changeset
275 case T_INT: return "[I";
a61af66fc99e Initial load
duke
parents:
diff changeset
276 case T_LONG: return "[J";
a61af66fc99e Initial load
duke
parents:
diff changeset
277 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
278 }
a61af66fc99e Initial load
duke
parents:
diff changeset
279 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
280 }
a61af66fc99e Initial load
duke
parents:
diff changeset
281
a61af66fc99e Initial load
duke
parents:
diff changeset
282 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
283 // Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
284
a61af66fc99e Initial load
duke
parents:
diff changeset
285 static void print_boolean_array(typeArrayOop ta, int print_len, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
286 for (int index = 0; index < print_len; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
287 st->print_cr(" - %3d: %s", index, (ta->bool_at(index) == 0) ? "false" : "true");
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 }
a61af66fc99e Initial load
duke
parents:
diff changeset
290
a61af66fc99e Initial load
duke
parents:
diff changeset
291
a61af66fc99e Initial load
duke
parents:
diff changeset
292 static void print_char_array(typeArrayOop ta, int print_len, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
293 for (int index = 0; index < print_len; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
294 jchar c = ta->char_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
295 st->print_cr(" - %3d: %x %c", index, c, isprint(c) ? c : ' ');
a61af66fc99e Initial load
duke
parents:
diff changeset
296 }
a61af66fc99e Initial load
duke
parents:
diff changeset
297 }
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299
a61af66fc99e Initial load
duke
parents:
diff changeset
300 static void print_float_array(typeArrayOop ta, int print_len, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
301 for (int index = 0; index < print_len; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 st->print_cr(" - %3d: %g", index, ta->float_at(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
303 }
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 static void print_double_array(typeArrayOop ta, int print_len, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
308 for (int index = 0; index < print_len; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 st->print_cr(" - %3d: %g", index, ta->double_at(index));
a61af66fc99e Initial load
duke
parents:
diff changeset
310 }
a61af66fc99e Initial load
duke
parents:
diff changeset
311 }
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313
a61af66fc99e Initial load
duke
parents:
diff changeset
314 static void print_byte_array(typeArrayOop ta, int print_len, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
315 for (int index = 0; index < print_len; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
316 jbyte c = ta->byte_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
317 st->print_cr(" - %3d: %x %c", index, c, isprint(c) ? c : ' ');
a61af66fc99e Initial load
duke
parents:
diff changeset
318 }
a61af66fc99e Initial load
duke
parents:
diff changeset
319 }
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321
a61af66fc99e Initial load
duke
parents:
diff changeset
322 static void print_short_array(typeArrayOop ta, int print_len, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
323 for (int index = 0; index < print_len; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
324 int v = ta->ushort_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
325 st->print_cr(" - %3d: 0x%x\t %d", index, v, v);
a61af66fc99e Initial load
duke
parents:
diff changeset
326 }
a61af66fc99e Initial load
duke
parents:
diff changeset
327 }
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329
a61af66fc99e Initial load
duke
parents:
diff changeset
330 static void print_int_array(typeArrayOop ta, int print_len, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
331 for (int index = 0; index < print_len; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
332 jint v = ta->int_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
333 st->print_cr(" - %3d: 0x%x %d", index, v, v);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 }
a61af66fc99e Initial load
duke
parents:
diff changeset
335 }
a61af66fc99e Initial load
duke
parents:
diff changeset
336
a61af66fc99e Initial load
duke
parents:
diff changeset
337
a61af66fc99e Initial load
duke
parents:
diff changeset
338 static void print_long_array(typeArrayOop ta, int print_len, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
339 for (int index = 0; index < print_len; index++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
340 jlong v = ta->long_at(index);
a61af66fc99e Initial load
duke
parents:
diff changeset
341 st->print_cr(" - %3d: 0x%x 0x%x", index, high(v), low(v));
a61af66fc99e Initial load
duke
parents:
diff changeset
342 }
a61af66fc99e Initial load
duke
parents:
diff changeset
343 }
a61af66fc99e Initial load
duke
parents:
diff changeset
344
a61af66fc99e Initial load
duke
parents:
diff changeset
345
a61af66fc99e Initial load
duke
parents:
diff changeset
346 void typeArrayKlass::oop_print_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
347 arrayKlass::oop_print_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
348 typeArrayOop ta = typeArrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
349 int print_len = MIN2((intx) ta->length(), MaxElementPrintSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
350 switch (element_type()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
351 case T_BOOLEAN: print_boolean_array(ta, print_len, st); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
352 case T_CHAR: print_char_array(ta, print_len, st); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
353 case T_FLOAT: print_float_array(ta, print_len, st); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
354 case T_DOUBLE: print_double_array(ta, print_len, st); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
355 case T_BYTE: print_byte_array(ta, print_len, st); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
356 case T_SHORT: print_short_array(ta, print_len, st); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
357 case T_INT: print_int_array(ta, print_len, st); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
358 case T_LONG: print_long_array(ta, print_len, st); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
359 default: ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
360 }
a61af66fc99e Initial load
duke
parents:
diff changeset
361 int remaining = ta->length() - print_len;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 if (remaining > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
363 tty->print_cr(" - <%d more elements, increase MaxElementPrintSize to print>", remaining);
a61af66fc99e Initial load
duke
parents:
diff changeset
364 }
a61af66fc99e Initial load
duke
parents:
diff changeset
365 }
a61af66fc99e Initial load
duke
parents:
diff changeset
366
a61af66fc99e Initial load
duke
parents:
diff changeset
367 #endif // PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
368
a61af66fc99e Initial load
duke
parents:
diff changeset
369 const char* typeArrayKlass::internal_name() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
370 return Klass::external_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
371 }