annotate src/share/vm/oops/arrayKlass.cpp @ 3011:f00918f35c7f

inlining and runtime interface related changes: added codeSize() and compilerStorage() to RiMethod HotSpotMethodResolved uses reflective methods instead of vmIds and survives compilations HotSpotResolvedType.isInitialized not represented as field (can change) inlining stores graphs into method objects and reuses them
author Lukas Stadler <lukas.stadler@jku.at>
date Thu, 16 Jun 2011 20:36:17 +0200
parents 1d1603768966
children a735aec54ea4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2426
1d1603768966 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 2177
diff changeset
2 * Copyright (c) 1997, 2011, 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: 1142
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
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: 1142
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: 1681
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
26 #include "classfile/javaClasses.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
27 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
28 #include "classfile/vmSymbols.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
29 #include "gc_interface/collectedHeap.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
30 #include "jvmtifiles/jvmti.h"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
31 #include "memory/gcLocker.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
32 #include "memory/universe.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
33 #include "oops/arrayKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
34 #include "oops/arrayKlassKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
35 #include "oops/arrayOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
36 #include "oops/instanceKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
37 #include "oops/objArrayOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
38 #include "oops/oop.inline.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 int arrayKlass::object_size(int header_size) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // size of an array klass object
a61af66fc99e Initial load
duke
parents:
diff changeset
42 assert(header_size <= instanceKlass::header_size(), "bad header size");
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // If this assert fails, see comments in base_create_array_klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
44 header_size = instanceKlass::header_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
45 #ifdef _LP64
a61af66fc99e Initial load
duke
parents:
diff changeset
46 int size = header_size + align_object_offset(vtable_length());
a61af66fc99e Initial load
duke
parents:
diff changeset
47 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
48 int size = header_size + vtable_length();
a61af66fc99e Initial load
duke
parents:
diff changeset
49 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
50 return align_object_size(size);
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 klassOop arrayKlass::java_super() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
55 if (super() == NULL) return NULL; // bootstrap case
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // Array klasses have primary supertypes which are not reported to Java.
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Example super chain: String[][] -> Object[][] -> Object[] -> Object
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 948
diff changeset
58 return SystemDictionary::Object_klass();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 oop arrayKlass::multi_allocate(int rank, jint* sizes, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
64 return NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66
2177
3582bf76420e 6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents: 1972
diff changeset
67 methodOop arrayKlass::uncached_lookup_method(Symbol* name, Symbol* signature) const {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // There are no methods in an array klass but the super class (Object) has some
a61af66fc99e Initial load
duke
parents:
diff changeset
69 assert(super(), "super klass must be present");
a61af66fc99e Initial load
duke
parents:
diff changeset
70 return Klass::cast(super())->uncached_lookup_method(name, signature);
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 arrayKlassHandle arrayKlass::base_create_array_klass(
a61af66fc99e Initial load
duke
parents:
diff changeset
75 const Klass_vtbl& cplusplus_vtbl, int header_size, KlassHandle klass, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Allocation
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // Note: because the Java vtable must start at the same offset in all klasses,
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // we must insert filler fields into arrayKlass to make it the same size as instanceKlass.
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // If this assert fails, add filler to instanceKlass to make it bigger.
a61af66fc99e Initial load
duke
parents:
diff changeset
80 assert(header_size <= instanceKlass::header_size(),
a61af66fc99e Initial load
duke
parents:
diff changeset
81 "array klasses must be same size as instanceKlass");
a61af66fc99e Initial load
duke
parents:
diff changeset
82 header_size = instanceKlass::header_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Arrays don't add any new methods, so their vtable is the same size as
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // the vtable of klass Object.
a61af66fc99e Initial load
duke
parents:
diff changeset
85 int vtable_size = Universe::base_vtable_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
86 arrayKlassHandle k;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 KlassHandle base_klass = Klass::base_create_klass(klass,
a61af66fc99e Initial load
duke
parents:
diff changeset
88 header_size + vtable_size,
a61af66fc99e Initial load
duke
parents:
diff changeset
89 cplusplus_vtbl, CHECK_(k));
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // No safepoint should be possible until the handle's
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // target below becomes parsable
a61af66fc99e Initial load
duke
parents:
diff changeset
93 No_Safepoint_Verifier no_safepoint;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 k = arrayKlassHandle(THREAD, base_klass());
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 assert(!k()->is_parsable(), "not expecting parsability yet.");
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 948
diff changeset
97 k->set_super(Universe::is_bootstrapping() ? (klassOop)NULL : SystemDictionary::Object_klass());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
98 k->set_layout_helper(Klass::_lh_neutral_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 k->set_dimension(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 k->set_higher_dimension(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 k->set_lower_dimension(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 k->set_component_mirror(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 k->set_vtable_length(vtable_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 k->set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5)
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 assert(k()->is_parsable(), "should be parsable here.");
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Make sure size calculation is right
a61af66fc99e Initial load
duke
parents:
diff changeset
108 assert(k()->size() == align_object_size(header_size + vtable_size), "wrong size for object");
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 return k;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // Initialization of vtables and mirror object is done separatly from base_create_array_klass,
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // since a GC can happen. At this point all instance variables of the arrayKlass must be setup.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 void arrayKlass::complete_create_array_klass(arrayKlassHandle k, KlassHandle super_klass, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
117 ResourceMark rm(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 k->initialize_supers(super_klass(), CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 k->vtable()->initialize_vtable(false, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 java_lang_Class::create_mirror(k, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 objArrayOop arrayKlass::compute_secondary_supers(int num_extra_slots, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // interfaces = { cloneable_klass, serializable_klass };
a61af66fc99e Initial load
duke
parents:
diff changeset
125 assert(num_extra_slots == 0, "sanity of primitive array type");
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Must share this for correct bootstrapping!
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return Universe::the_array_interfaces_array();
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 bool arrayKlass::compute_is_subtype_of(klassOop k) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // An array is a subtype of Serializable, Clonable, and Object
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 948
diff changeset
132 return k == SystemDictionary::Object_klass()
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 948
diff changeset
133 || k == SystemDictionary::Cloneable_klass()
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 948
diff changeset
134 || k == SystemDictionary::Serializable_klass();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 inline intptr_t* arrayKlass::start_of_vtable() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // all vtables start at the same place, that's why we use instanceKlass::header_size here
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return ((intptr_t*)as_klassOop()) + instanceKlass::header_size();
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 klassVtable* arrayKlass::vtable() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 KlassHandle kh(Thread::current(), as_klassOop());
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return new klassVtable(kh, start_of_vtable(), vtable_length() / vtableEntry::size());
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 objArrayOop arrayKlass::allocate_arrayArray(int n, int length, TRAPS) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 if (length < 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 THROW_0(vmSymbols::java_lang_NegativeArraySizeException());
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 if (length > arrayOopDesc::max_array_length(T_ARRAY)) {
876
1413494da700 6850957: Honor -XX:OnOutOfMemoryError when array size exceeds VM limit
martin
parents: 0
diff changeset
155 report_java_out_of_memory("Requested array size exceeds VM limit");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
156 THROW_OOP_0(Universe::out_of_memory_error_array_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 int size = objArrayOopDesc::object_size(length);
a61af66fc99e Initial load
duke
parents:
diff changeset
159 klassOop k = array_klass(n+dimension(), CHECK_0);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 arrayKlassHandle ak (THREAD, k);
a61af66fc99e Initial load
duke
parents:
diff changeset
161 objArrayOop o =
a61af66fc99e Initial load
duke
parents:
diff changeset
162 (objArrayOop)CollectedHeap::array_allocate(ak, size, length, CHECK_0);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // initialization to NULL not necessary, area already cleared
a61af66fc99e Initial load
duke
parents:
diff changeset
164 return o;
a61af66fc99e Initial load
duke
parents:
diff changeset
165 }
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 void arrayKlass::array_klasses_do(void f(klassOop k)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 klassOop k = as_klassOop();
a61af66fc99e Initial load
duke
parents:
diff changeset
170 // Iterate over this array klass and all higher dimensions
a61af66fc99e Initial load
duke
parents:
diff changeset
171 while (k != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 f(k);
a61af66fc99e Initial load
duke
parents:
diff changeset
173 k = arrayKlass::cast(k)->higher_dimension();
a61af66fc99e Initial load
duke
parents:
diff changeset
174 }
a61af66fc99e Initial load
duke
parents:
diff changeset
175 }
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 void arrayKlass::with_array_klasses_do(void f(klassOop k)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 array_klasses_do(f);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // JVM support
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 jint arrayKlass::compute_modifier_flags(TRAPS) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
185 return JVM_ACC_ABSTRACT | JVM_ACC_FINAL | JVM_ACC_PUBLIC;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // JVMTI support
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 jint arrayKlass::jvmti_class_status() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
191 return JVMTI_CLASS_STATUS_ARRAY;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // Printing
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 void arrayKlass::oop_print_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
197 assert(obj->is_array(), "must be array");
a61af66fc99e Initial load
duke
parents:
diff changeset
198 Klass::oop_print_on(obj, st);
a61af66fc99e Initial load
duke
parents:
diff changeset
199 st->print_cr(" - length: %d", arrayOop(obj)->length());
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // Verification
a61af66fc99e Initial load
duke
parents:
diff changeset
203
a61af66fc99e Initial load
duke
parents:
diff changeset
204 void arrayKlass::oop_verify_on(oop obj, outputStream* st) {
a61af66fc99e Initial load
duke
parents:
diff changeset
205 guarantee(obj->is_array(), "must be array");
a61af66fc99e Initial load
duke
parents:
diff changeset
206 arrayOop a = arrayOop(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
207 guarantee(a->length() >= 0, "array with negative length?");
a61af66fc99e Initial load
duke
parents:
diff changeset
208 }