annotate src/share/vm/ci/ciObjArrayKlass.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 c18cbe5936b8
children 3582bf76420e
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: 1552
diff changeset
2 * Copyright (c) 1999, 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: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
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: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "ci/ciInstanceKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "ci/ciObjArrayKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "ci/ciObjArrayKlassKlass.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "ci/ciSymbol.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "ci/ciUtilities.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "oops/objArrayKlass.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // ciObjArrayKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
34 //
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // This class represents a klassOop in the HotSpot virtual machine
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // whose Klass part is an objArrayKlass.
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // ciObjArrayKlass::ciObjArrayKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
40 //
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Constructor for loaded object array klasses.
a61af66fc99e Initial load
duke
parents:
diff changeset
42 ciObjArrayKlass::ciObjArrayKlass(KlassHandle h_k) : ciArrayKlass(h_k) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 assert(get_Klass()->oop_is_objArray(), "wrong type");
a61af66fc99e Initial load
duke
parents:
diff changeset
44 klassOop element_klassOop = get_objArrayKlass()->bottom_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
45 _base_element_klass = CURRENT_ENV->get_object(element_klassOop)->as_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
46 assert(_base_element_klass->is_instance_klass() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _base_element_klass->is_type_array_klass(), "bad base klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
48 if (dimension() == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 _element_klass = _base_element_klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 _element_klass = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 }
a61af66fc99e Initial load
duke
parents:
diff changeset
53 if (!ciObjectFactory::is_initialized()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 assert(_element_klass->is_java_lang_Object(), "only arrays of object are shared");
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // ciObjArrayKlass::ciObjArrayKlass
a61af66fc99e Initial load
duke
parents:
diff changeset
60 //
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Constructor for unloaded object array klasses.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 ciObjArrayKlass::ciObjArrayKlass(ciSymbol* array_name,
a61af66fc99e Initial load
duke
parents:
diff changeset
63 ciKlass* base_element_klass,
a61af66fc99e Initial load
duke
parents:
diff changeset
64 int dimension)
a61af66fc99e Initial load
duke
parents:
diff changeset
65 : ciArrayKlass(array_name,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 dimension,
a61af66fc99e Initial load
duke
parents:
diff changeset
67 ciObjArrayKlassKlass::make()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 _base_element_klass = base_element_klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 assert(_base_element_klass->is_instance_klass() ||
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _base_element_klass->is_type_array_klass(), "bad base klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
71 if (dimension == 1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _element_klass = base_element_klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _element_klass = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // ciObjArrayKlass::element_klass
a61af66fc99e Initial load
duke
parents:
diff changeset
80 //
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // What is the one-level element type of this array?
a61af66fc99e Initial load
duke
parents:
diff changeset
82 ciKlass* ciObjArrayKlass::element_klass() {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 if (_element_klass == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 assert(dimension() > 1, "_element_klass should not be NULL");
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // Produce the element klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
86 if (is_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 klassOop element_klassOop = get_objArrayKlass()->element_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
89 _element_klass = CURRENT_THREAD_ENV->get_object(element_klassOop)->as_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 VM_ENTRY_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // We are an unloaded array klass. Attempt to fetch our
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // element klass by name.
a61af66fc99e Initial load
duke
parents:
diff changeset
94 _element_klass = CURRENT_THREAD_ENV->get_klass_by_name_impl(
a61af66fc99e Initial load
duke
parents:
diff changeset
95 this,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 construct_array_name(base_element_klass()->name(),
a61af66fc99e Initial load
duke
parents:
diff changeset
97 dimension() - 1),
a61af66fc99e Initial load
duke
parents:
diff changeset
98 false);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 return _element_klass;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // ciObjArrayKlass::construct_array_name
a61af66fc99e Initial load
duke
parents:
diff changeset
106 //
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // Build an array name from an element name and a dimension.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 ciSymbol* ciObjArrayKlass::construct_array_name(ciSymbol* element_name,
a61af66fc99e Initial load
duke
parents:
diff changeset
109 int dimension) {
a61af66fc99e Initial load
duke
parents:
diff changeset
110 EXCEPTION_CONTEXT;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 int element_len = element_name->utf8_length();
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 symbolOop base_name_sym = element_name->get_symbolOop();
a61af66fc99e Initial load
duke
parents:
diff changeset
114 char* name;
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 if (base_name_sym->byte_at(0) == '[' ||
a61af66fc99e Initial load
duke
parents:
diff changeset
117 (base_name_sym->byte_at(0) == 'L' && // watch package name 'Lxx'
a61af66fc99e Initial load
duke
parents:
diff changeset
118 base_name_sym->byte_at(element_len-1) == ';')) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 int new_len = element_len + dimension + 1; // for the ['s and '\0'
a61af66fc99e Initial load
duke
parents:
diff changeset
121 name = CURRENT_THREAD_ENV->name_buffer(new_len);
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 int pos = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 for ( ; pos < dimension; pos++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 name[pos] = '[';
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127 strncpy(name+pos, (char*)element_name->base(), element_len);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 name[new_len-1] = '\0';
a61af66fc99e Initial load
duke
parents:
diff changeset
129 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 int new_len = 3 // for L, ;, and '\0'
a61af66fc99e Initial load
duke
parents:
diff changeset
131 + dimension // for ['s
a61af66fc99e Initial load
duke
parents:
diff changeset
132 + element_len;
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 name = CURRENT_THREAD_ENV->name_buffer(new_len);
a61af66fc99e Initial load
duke
parents:
diff changeset
135 int pos = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 for ( ; pos < dimension; pos++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 name[pos] = '[';
a61af66fc99e Initial load
duke
parents:
diff changeset
138 }
a61af66fc99e Initial load
duke
parents:
diff changeset
139 name[pos++] = 'L';
a61af66fc99e Initial load
duke
parents:
diff changeset
140 strncpy(name+pos, (char*)element_name->base(), element_len);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 name[new_len-2] = ';';
a61af66fc99e Initial load
duke
parents:
diff changeset
142 name[new_len-1] = '\0';
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return ciSymbol::make(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // ------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // ciObjArrayKlass::make_impl
a61af66fc99e Initial load
duke
parents:
diff changeset
149 //
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Implementation of make.
a61af66fc99e Initial load
duke
parents:
diff changeset
151 ciObjArrayKlass* ciObjArrayKlass::make_impl(ciKlass* element_klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 if (element_klass->is_loaded()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 EXCEPTION_CONTEXT;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // The element klass is loaded
a61af66fc99e Initial load
duke
parents:
diff changeset
156 klassOop array = element_klass->get_Klass()->array_klass(THREAD);
a61af66fc99e Initial load
duke
parents:
diff changeset
157 if (HAS_PENDING_EXCEPTION) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 CLEAR_PENDING_EXCEPTION;
a61af66fc99e Initial load
duke
parents:
diff changeset
159 CURRENT_THREAD_ENV->record_out_of_memory_failure();
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return ciEnv::unloaded_ciobjarrayklass();
a61af66fc99e Initial load
duke
parents:
diff changeset
161 }
a61af66fc99e Initial load
duke
parents:
diff changeset
162 return CURRENT_THREAD_ENV->get_object(array)->as_obj_array_klass();
a61af66fc99e Initial load
duke
parents:
diff changeset
163 }
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // The array klass was unable to be made or the element klass was
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // not loaded.
a61af66fc99e Initial load
duke
parents:
diff changeset
167 ciSymbol* array_name = construct_array_name(element_klass->name(), 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
168 if (array_name == ciEnv::unloaded_cisymbol()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 return ciEnv::unloaded_ciobjarrayklass();
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 return
a61af66fc99e Initial load
duke
parents:
diff changeset
172 CURRENT_ENV->get_unloaded_klass(element_klass, array_name)
a61af66fc99e Initial load
duke
parents:
diff changeset
173 ->as_obj_array_klass();
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 // ciObjArrayKlass::make
a61af66fc99e Initial load
duke
parents:
diff changeset
178 //
a61af66fc99e Initial load
duke
parents:
diff changeset
179 // Make an array klass corresponding to the specified primitive type.
a61af66fc99e Initial load
duke
parents:
diff changeset
180 ciObjArrayKlass* ciObjArrayKlass::make(ciKlass* element_klass) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 assert(element_klass->is_java_klass(), "wrong kind of klass");
a61af66fc99e Initial load
duke
parents:
diff changeset
182 GUARDED_VM_ENTRY(return make_impl(element_klass);)
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }