Mercurial > hg > truffle
annotate src/share/vm/classfile/javaClasses.cpp @ 669:eca19a8425b5
6810653: Change String cache class used by Hotspot from String to StringValue
Summary: Change create_vm() to load and initialize StringValue rather than String.
Reviewed-by: kvn
author | phh |
---|---|
date | Tue, 24 Mar 2009 21:56:53 -0400 |
parents | c89f86385056 |
children | e5b0439ef4ae |
rev | line source |
---|---|
0 | 1 /* |
579 | 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
0 | 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 # include "incls/_precompiled.incl" | |
26 # include "incls/_javaClasses.cpp.incl" | |
27 | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
28 // Helpful routine for computing field offsets at run time rather than hardcoding them |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
29 static void |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
30 compute_offset(int &dest_offset, |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
31 klassOop klass_oop, symbolOop name_symbol, symbolOop signature_symbol) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
32 fieldDescriptor fd; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
33 instanceKlass* ik = instanceKlass::cast(klass_oop); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
34 if (!ik->find_local_field(name_symbol, signature_symbol, &fd)) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
35 ResourceMark rm; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
36 tty->print_cr("Invalid layout of %s at %s", ik->external_name(), name_symbol->as_C_string()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
37 fatal("Invalid layout of preloaded class"); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
38 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
39 dest_offset = fd.offset(); |
0 | 40 } |
41 | |
42 // Same as above but for "optional" offsets that might not be present in certain JDK versions | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
43 static void |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
44 compute_optional_offset(int& dest_offset, |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
45 klassOop klass_oop, symbolOop name_symbol, symbolOop signature_symbol) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
46 fieldDescriptor fd; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
47 instanceKlass* ik = instanceKlass::cast(klass_oop); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
48 if (ik->find_local_field(name_symbol, signature_symbol, &fd)) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
49 dest_offset = fd.offset(); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
50 } |
0 | 51 } |
52 | |
53 Handle java_lang_String::basic_create(int length, bool tenured, TRAPS) { | |
54 // Create the String object first, so there's a chance that the String | |
55 // and the char array it points to end up in the same cache line. | |
56 oop obj; | |
57 if (tenured) { | |
58 obj = instanceKlass::cast(SystemDictionary::string_klass())->allocate_permanent_instance(CHECK_NH); | |
59 } else { | |
60 obj = instanceKlass::cast(SystemDictionary::string_klass())->allocate_instance(CHECK_NH); | |
61 } | |
62 | |
63 // Create the char array. The String object must be handlized here | |
64 // because GC can happen as a result of the allocation attempt. | |
65 Handle h_obj(THREAD, obj); | |
66 typeArrayOop buffer; | |
67 if (tenured) { | |
68 buffer = oopFactory::new_permanent_charArray(length, CHECK_NH); | |
69 } else { | |
70 buffer = oopFactory::new_charArray(length, CHECK_NH); | |
71 } | |
72 | |
73 // Point the String at the char array | |
74 obj = h_obj(); | |
75 set_value(obj, buffer); | |
76 // No need to zero the offset, allocation zero'ed the entire String object | |
77 assert(offset(obj) == 0, "initial String offset should be zero"); | |
78 //set_offset(obj, 0); | |
79 set_count(obj, length); | |
80 | |
81 return h_obj; | |
82 } | |
83 | |
84 Handle java_lang_String::basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS) { | |
85 Handle h_obj = basic_create(length, tenured, CHECK_NH); | |
86 typeArrayOop buffer = value(h_obj()); | |
87 for (int index = 0; index < length; index++) { | |
88 buffer->char_at_put(index, unicode[index]); | |
89 } | |
90 return h_obj; | |
91 } | |
92 | |
93 Handle java_lang_String::create_from_unicode(jchar* unicode, int length, TRAPS) { | |
94 return basic_create_from_unicode(unicode, length, false, CHECK_NH); | |
95 } | |
96 | |
97 Handle java_lang_String::create_tenured_from_unicode(jchar* unicode, int length, TRAPS) { | |
98 return basic_create_from_unicode(unicode, length, true, CHECK_NH); | |
99 } | |
100 | |
101 oop java_lang_String::create_oop_from_unicode(jchar* unicode, int length, TRAPS) { | |
102 Handle h_obj = basic_create_from_unicode(unicode, length, false, CHECK_0); | |
103 return h_obj(); | |
104 } | |
105 | |
106 Handle java_lang_String::create_from_str(const char* utf8_str, TRAPS) { | |
107 if (utf8_str == NULL) { | |
108 return Handle(); | |
109 } | |
110 int length = UTF8::unicode_length(utf8_str); | |
111 Handle h_obj = basic_create(length, false, CHECK_NH); | |
112 if (length > 0) { | |
113 UTF8::convert_to_unicode(utf8_str, value(h_obj())->char_at_addr(0), length); | |
114 } | |
115 return h_obj; | |
116 } | |
117 | |
118 oop java_lang_String::create_oop_from_str(const char* utf8_str, TRAPS) { | |
119 Handle h_obj = create_from_str(utf8_str, CHECK_0); | |
120 return h_obj(); | |
121 } | |
122 | |
123 Handle java_lang_String::create_from_symbol(symbolHandle symbol, TRAPS) { | |
124 int length = UTF8::unicode_length((char*)symbol->bytes(), symbol->utf8_length()); | |
125 Handle h_obj = basic_create(length, false, CHECK_NH); | |
126 if (length > 0) { | |
127 UTF8::convert_to_unicode((char*)symbol->bytes(), value(h_obj())->char_at_addr(0), length); | |
128 } | |
129 return h_obj; | |
130 } | |
131 | |
132 // Converts a C string to a Java String based on current encoding | |
133 Handle java_lang_String::create_from_platform_dependent_str(const char* str, TRAPS) { | |
134 assert(str != NULL, "bad arguments"); | |
135 | |
136 typedef jstring (*to_java_string_fn_t)(JNIEnv*, const char *); | |
137 static to_java_string_fn_t _to_java_string_fn = NULL; | |
138 | |
139 if (_to_java_string_fn == NULL) { | |
140 void *lib_handle = os::native_java_library(); | |
141 _to_java_string_fn = CAST_TO_FN_PTR(to_java_string_fn_t, hpi::dll_lookup(lib_handle, "NewStringPlatform")); | |
142 if (_to_java_string_fn == NULL) { | |
143 fatal("NewStringPlatform missing"); | |
144 } | |
145 } | |
146 | |
147 jstring js = NULL; | |
148 { JavaThread* thread = (JavaThread*)THREAD; | |
149 assert(thread->is_Java_thread(), "must be java thread"); | |
22
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
150 HandleMark hm(thread); |
0 | 151 ThreadToNativeFromVM ttn(thread); |
152 js = (_to_java_string_fn)(thread->jni_environment(), str); | |
153 } | |
154 return Handle(THREAD, JNIHandles::resolve(js)); | |
155 } | |
156 | |
22
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
157 // Converts a Java String to a native C string that can be used for |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
158 // native OS calls. |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
159 char* java_lang_String::as_platform_dependent_str(Handle java_string, TRAPS) { |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
160 |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
161 typedef char* (*to_platform_string_fn_t)(JNIEnv*, jstring, bool*); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
162 static to_platform_string_fn_t _to_platform_string_fn = NULL; |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
163 |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
164 if (_to_platform_string_fn == NULL) { |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
165 void *lib_handle = os::native_java_library(); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
166 _to_platform_string_fn = CAST_TO_FN_PTR(to_platform_string_fn_t, hpi::dll_lookup(lib_handle, "GetStringPlatformChars")); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
167 if (_to_platform_string_fn == NULL) { |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
168 fatal("GetStringPlatformChars missing"); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
169 } |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
170 } |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
171 |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
172 char *native_platform_string; |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
173 { JavaThread* thread = (JavaThread*)THREAD; |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
174 assert(thread->is_Java_thread(), "must be java thread"); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
175 JNIEnv *env = thread->jni_environment(); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
176 jstring js = (jstring) JNIHandles::make_local(env, java_string()); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
177 bool is_copy; |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
178 HandleMark hm(thread); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
179 ThreadToNativeFromVM ttn(thread); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
180 native_platform_string = (_to_platform_string_fn)(env, js, &is_copy); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
181 assert(is_copy == JNI_TRUE, "is_copy value changed"); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
182 JNIHandles::destroy_local(js); |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
183 } |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
184 return native_platform_string; |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
185 } |
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
186 |
0 | 187 Handle java_lang_String::char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS) { |
188 oop obj = java_string(); | |
189 // Typical usage is to convert all '/' to '.' in string. | |
190 typeArrayOop value = java_lang_String::value(obj); | |
191 int offset = java_lang_String::offset(obj); | |
192 int length = java_lang_String::length(obj); | |
193 | |
194 // First check if any from_char exist | |
195 int index; // Declared outside, used later | |
196 for (index = 0; index < length; index++) { | |
197 if (value->char_at(index + offset) == from_char) { | |
198 break; | |
199 } | |
200 } | |
201 if (index == length) { | |
202 // No from_char, so do not copy. | |
203 return java_string; | |
204 } | |
205 | |
206 // Create new UNICODE buffer. Must handlize value because GC | |
207 // may happen during String and char array creation. | |
208 typeArrayHandle h_value(THREAD, value); | |
209 Handle string = basic_create(length, false, CHECK_NH); | |
210 | |
211 typeArrayOop from_buffer = h_value(); | |
212 typeArrayOop to_buffer = java_lang_String::value(string()); | |
213 | |
214 // Copy contents | |
215 for (index = 0; index < length; index++) { | |
216 jchar c = from_buffer->char_at(index + offset); | |
217 if (c == from_char) { | |
218 c = to_char; | |
219 } | |
220 to_buffer->char_at_put(index, c); | |
221 } | |
222 return string; | |
223 } | |
224 | |
225 jchar* java_lang_String::as_unicode_string(oop java_string, int& length) { | |
226 typeArrayOop value = java_lang_String::value(java_string); | |
227 int offset = java_lang_String::offset(java_string); | |
228 length = java_lang_String::length(java_string); | |
229 | |
230 jchar* result = NEW_RESOURCE_ARRAY(jchar, length); | |
231 for (int index = 0; index < length; index++) { | |
232 result[index] = value->char_at(index + offset); | |
233 } | |
234 return result; | |
235 } | |
236 | |
237 symbolHandle java_lang_String::as_symbol(Handle java_string, TRAPS) { | |
238 oop obj = java_string(); | |
239 typeArrayOop value = java_lang_String::value(obj); | |
240 int offset = java_lang_String::offset(obj); | |
241 int length = java_lang_String::length(obj); | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
242 jchar* base = value->char_at_addr(offset); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
243 symbolOop sym = SymbolTable::lookup_unicode(base, length, THREAD); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
244 return symbolHandle(THREAD, sym); |
0 | 245 } |
246 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
247 symbolOop java_lang_String::as_symbol_or_null(oop java_string) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
248 typeArrayOop value = java_lang_String::value(java_string); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
249 int offset = java_lang_String::offset(java_string); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
250 int length = java_lang_String::length(java_string); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
251 jchar* base = value->char_at_addr(offset); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
252 return SymbolTable::probe_unicode(base, length); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
253 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
254 |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
255 |
0 | 256 int java_lang_String::utf8_length(oop java_string) { |
257 typeArrayOop value = java_lang_String::value(java_string); | |
258 int offset = java_lang_String::offset(java_string); | |
259 int length = java_lang_String::length(java_string); | |
260 jchar* position = (length == 0) ? NULL : value->char_at_addr(offset); | |
261 return UNICODE::utf8_length(position, length); | |
262 } | |
263 | |
264 char* java_lang_String::as_utf8_string(oop java_string) { | |
265 typeArrayOop value = java_lang_String::value(java_string); | |
266 int offset = java_lang_String::offset(java_string); | |
267 int length = java_lang_String::length(java_string); | |
268 jchar* position = (length == 0) ? NULL : value->char_at_addr(offset); | |
269 return UNICODE::as_utf8(position, length); | |
270 } | |
271 | |
272 char* java_lang_String::as_utf8_string(oop java_string, int start, int len) { | |
273 typeArrayOop value = java_lang_String::value(java_string); | |
274 int offset = java_lang_String::offset(java_string); | |
275 int length = java_lang_String::length(java_string); | |
276 assert(start + len <= length, "just checking"); | |
277 jchar* position = value->char_at_addr(offset + start); | |
278 return UNICODE::as_utf8(position, len); | |
279 } | |
280 | |
281 bool java_lang_String::equals(oop java_string, jchar* chars, int len) { | |
282 assert(SharedSkipVerify || | |
283 java_string->klass() == SystemDictionary::string_klass(), | |
284 "must be java_string"); | |
285 typeArrayOop value = java_lang_String::value(java_string); | |
286 int offset = java_lang_String::offset(java_string); | |
287 int length = java_lang_String::length(java_string); | |
288 if (length != len) { | |
289 return false; | |
290 } | |
291 for (int i = 0; i < len; i++) { | |
292 if (value->char_at(i + offset) != chars[i]) { | |
293 return false; | |
294 } | |
295 } | |
296 return true; | |
297 } | |
298 | |
299 void java_lang_String::print(Handle java_string, outputStream* st) { | |
300 oop obj = java_string(); | |
301 assert(obj->klass() == SystemDictionary::string_klass(), "must be java_string"); | |
302 typeArrayOop value = java_lang_String::value(obj); | |
303 int offset = java_lang_String::offset(obj); | |
304 int length = java_lang_String::length(obj); | |
305 | |
306 int end = MIN2(length, 100); | |
307 if (value == NULL) { | |
308 // This can happen if, e.g., printing a String | |
309 // object before its initializer has been called | |
310 st->print_cr("NULL"); | |
311 } else { | |
312 st->print("\""); | |
313 for (int index = 0; index < length; index++) { | |
314 st->print("%c", value->char_at(index + offset)); | |
315 } | |
316 st->print("\""); | |
317 } | |
318 } | |
319 | |
320 | |
321 oop java_lang_Class::create_mirror(KlassHandle k, TRAPS) { | |
322 assert(k->java_mirror() == NULL, "should only assign mirror once"); | |
323 // Use this moment of initialization to cache modifier_flags also, | |
324 // to support Class.getModifiers(). Instance classes recalculate | |
325 // the cached flags after the class file is parsed, but before the | |
326 // class is put into the system dictionary. | |
327 int computed_modifiers = k->compute_modifier_flags(CHECK_0); | |
328 k->set_modifier_flags(computed_modifiers); | |
329 if (SystemDictionary::class_klass_loaded()) { | |
330 // Allocate mirror (java.lang.Class instance) | |
331 Handle mirror = instanceKlass::cast(SystemDictionary::class_klass())->allocate_permanent_instance(CHECK_0); | |
332 // Setup indirections | |
333 mirror->obj_field_put(klass_offset, k()); | |
334 k->set_java_mirror(mirror()); | |
335 // It might also have a component mirror. This mirror must already exist. | |
336 if (k->oop_is_javaArray()) { | |
337 Handle comp_mirror; | |
338 if (k->oop_is_typeArray()) { | |
339 BasicType type = typeArrayKlass::cast(k->as_klassOop())->element_type(); | |
340 comp_mirror = Universe::java_mirror(type); | |
341 assert(comp_mirror.not_null(), "must have primitive mirror"); | |
342 } else if (k->oop_is_objArray()) { | |
343 klassOop element_klass = objArrayKlass::cast(k->as_klassOop())->element_klass(); | |
344 if (element_klass != NULL | |
345 && (Klass::cast(element_klass)->oop_is_instance() || | |
346 Klass::cast(element_klass)->oop_is_javaArray())) { | |
347 comp_mirror = Klass::cast(element_klass)->java_mirror(); | |
348 assert(comp_mirror.not_null(), "must have element mirror"); | |
349 } | |
350 // else some object array internal to the VM, like systemObjArrayKlassObj | |
351 } | |
352 if (comp_mirror.not_null()) { | |
353 // Two-way link between the array klass and its component mirror: | |
354 arrayKlass::cast(k->as_klassOop())->set_component_mirror(comp_mirror()); | |
355 set_array_klass(comp_mirror(), k->as_klassOop()); | |
356 } | |
357 } | |
358 return mirror(); | |
359 } else { | |
360 return NULL; | |
361 } | |
362 } | |
363 | |
364 | |
365 oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) { | |
366 // This should be improved by adding a field at the Java level or by | |
367 // introducing a new VM klass (see comment in ClassFileParser) | |
368 oop java_class = instanceKlass::cast(SystemDictionary::class_klass())->allocate_permanent_instance(CHECK_0); | |
369 if (type != T_VOID) { | |
370 klassOop aklass = Universe::typeArrayKlassObj(type); | |
371 assert(aklass != NULL, "correct bootstrap"); | |
372 set_array_klass(java_class, aklass); | |
373 } | |
374 return java_class; | |
375 } | |
376 | |
377 | |
378 klassOop java_lang_Class::as_klassOop(oop java_class) { | |
379 //%note memory_2 | |
380 klassOop k = klassOop(java_class->obj_field(klass_offset)); | |
381 assert(k == NULL || k->is_klass(), "type check"); | |
382 return k; | |
383 } | |
384 | |
385 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
386 void java_lang_Class::print_signature(oop java_class, outputStream* st) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
387 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
388 symbolOop name = NULL; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
389 bool is_instance = false; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
390 if (is_primitive(java_class)) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
391 name = vmSymbols::type_signature(primitive_type(java_class)); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
392 } else { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
393 klassOop k = as_klassOop(java_class); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
394 is_instance = Klass::cast(k)->oop_is_instance(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
395 name = Klass::cast(k)->name(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
396 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
397 if (name == NULL) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
398 st->print("<null>"); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
399 return; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
400 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
401 if (is_instance) st->print("L"); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
402 st->write((char*) name->base(), (int) name->utf8_length()); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
403 if (is_instance) st->print(";"); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
404 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
405 |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
406 symbolOop java_lang_Class::as_signature(oop java_class, bool intern_if_not_found, TRAPS) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
407 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
408 symbolOop name = NULL; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
409 if (is_primitive(java_class)) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
410 return vmSymbols::type_signature(primitive_type(java_class)); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
411 } else { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
412 klassOop k = as_klassOop(java_class); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
413 if (!Klass::cast(k)->oop_is_instance()) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
414 return Klass::cast(k)->name(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
415 } else { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
416 ResourceMark rm; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
417 const char* sigstr = Klass::cast(k)->signature_name(); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
418 int siglen = (int) strlen(sigstr); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
419 if (!intern_if_not_found) |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
420 return SymbolTable::probe(sigstr, siglen); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
421 else |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
422 return oopFactory::new_symbol(sigstr, siglen, THREAD); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
423 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
424 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
425 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
426 |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
427 |
0 | 428 klassOop java_lang_Class::array_klass(oop java_class) { |
429 klassOop k = klassOop(java_class->obj_field(array_klass_offset)); | |
430 assert(k == NULL || k->is_klass() && Klass::cast(k)->oop_is_javaArray(), "should be array klass"); | |
431 return k; | |
432 } | |
433 | |
434 | |
435 void java_lang_Class::set_array_klass(oop java_class, klassOop klass) { | |
436 assert(klass->is_klass() && Klass::cast(klass)->oop_is_javaArray(), "should be array klass"); | |
437 java_class->obj_field_put(array_klass_offset, klass); | |
438 } | |
439 | |
440 | |
441 methodOop java_lang_Class::resolved_constructor(oop java_class) { | |
442 oop constructor = java_class->obj_field(resolved_constructor_offset); | |
443 assert(constructor == NULL || constructor->is_method(), "should be method"); | |
444 return methodOop(constructor); | |
445 } | |
446 | |
447 | |
448 void java_lang_Class::set_resolved_constructor(oop java_class, methodOop constructor) { | |
449 assert(constructor->is_method(), "should be method"); | |
450 java_class->obj_field_put(resolved_constructor_offset, constructor); | |
451 } | |
452 | |
453 | |
454 bool java_lang_Class::is_primitive(oop java_class) { | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
455 // should assert: |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
456 //assert(java_lang_Class::is_instance(java_class), "must be a Class object"); |
0 | 457 klassOop k = klassOop(java_class->obj_field(klass_offset)); |
458 return k == NULL; | |
459 } | |
460 | |
461 | |
462 BasicType java_lang_Class::primitive_type(oop java_class) { | |
463 assert(java_lang_Class::is_primitive(java_class), "just checking"); | |
464 klassOop ak = klassOop(java_class->obj_field(array_klass_offset)); | |
465 BasicType type = T_VOID; | |
466 if (ak != NULL) { | |
467 // Note: create_basic_type_mirror above initializes ak to a non-null value. | |
468 type = arrayKlass::cast(ak)->element_type(); | |
469 } else { | |
470 assert(java_class == Universe::void_mirror(), "only valid non-array primitive"); | |
471 } | |
472 assert(Universe::java_mirror(type) == java_class, "must be consistent"); | |
473 return type; | |
474 } | |
475 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
476 BasicType java_lang_Class::as_BasicType(oop java_class, klassOop* reference_klass) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
477 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
478 if (is_primitive(java_class)) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
479 if (reference_klass != NULL) |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
480 (*reference_klass) = NULL; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
481 return primitive_type(java_class); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
482 } else { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
483 if (reference_klass != NULL) |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
484 (*reference_klass) = as_klassOop(java_class); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
485 return T_OBJECT; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
486 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
487 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
488 |
0 | 489 |
490 oop java_lang_Class::primitive_mirror(BasicType t) { | |
491 oop mirror = Universe::java_mirror(t); | |
492 assert(mirror != NULL && mirror->is_a(SystemDictionary::class_klass()), "must be a Class"); | |
493 assert(java_lang_Class::is_primitive(mirror), "must be primitive"); | |
494 return mirror; | |
495 } | |
496 | |
497 bool java_lang_Class::offsets_computed = false; | |
498 int java_lang_Class::classRedefinedCount_offset = -1; | |
514 | 499 int java_lang_Class::parallelCapable_offset = -1; |
0 | 500 |
501 void java_lang_Class::compute_offsets() { | |
502 assert(!offsets_computed, "offsets should be initialized only once"); | |
503 offsets_computed = true; | |
504 | |
505 klassOop k = SystemDictionary::class_klass(); | |
506 // The classRedefinedCount field is only present starting in 1.5, | |
507 // so don't go fatal. | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
508 compute_optional_offset(classRedefinedCount_offset, |
0 | 509 k, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature()); |
514 | 510 |
511 // The field indicating parallelCapable (parallelLockMap) is only present starting in 7, | |
512 klassOop k1 = SystemDictionary::classloader_klass(); | |
513 compute_optional_offset(parallelCapable_offset, | |
514 k1, vmSymbols::parallelCapable_name(), vmSymbols::concurrenthashmap_signature()); | |
515 } | |
516 | |
517 // For class loader classes, parallelCapable defined | |
518 // based on non-null field | |
519 // Written to by java.lang.ClassLoader, vm only reads this field, doesn't set it | |
520 bool java_lang_Class::parallelCapable(oop class_loader) { | |
521 if (!JDK_Version::is_gte_jdk17x_version() | |
522 || parallelCapable_offset == -1) { | |
523 // Default for backward compatibility is false | |
524 return false; | |
525 } | |
526 return (class_loader->obj_field(parallelCapable_offset) != NULL); | |
0 | 527 } |
528 | |
529 int java_lang_Class::classRedefinedCount(oop the_class_mirror) { | |
530 if (!JDK_Version::is_gte_jdk15x_version() | |
531 || classRedefinedCount_offset == -1) { | |
532 // The classRedefinedCount field is only present starting in 1.5. | |
533 // If we don't have an offset for it then just return -1 as a marker. | |
534 return -1; | |
535 } | |
536 | |
537 return the_class_mirror->int_field(classRedefinedCount_offset); | |
538 } | |
539 | |
540 void java_lang_Class::set_classRedefinedCount(oop the_class_mirror, int value) { | |
541 if (!JDK_Version::is_gte_jdk15x_version() | |
542 || classRedefinedCount_offset == -1) { | |
543 // The classRedefinedCount field is only present starting in 1.5. | |
544 // If we don't have an offset for it then nothing to set. | |
545 return; | |
546 } | |
547 | |
548 the_class_mirror->int_field_put(classRedefinedCount_offset, value); | |
549 } | |
550 | |
551 | |
552 // Note: JDK1.1 and before had a privateInfo_offset field which was used for the | |
553 // platform thread structure, and a eetop offset which was used for thread | |
554 // local storage (and unused by the HotSpot VM). In JDK1.2 the two structures | |
555 // merged, so in the HotSpot VM we just use the eetop field for the thread | |
556 // instead of the privateInfo_offset. | |
557 // | |
558 // Note: The stackSize field is only present starting in 1.4. | |
559 | |
560 int java_lang_Thread::_name_offset = 0; | |
561 int java_lang_Thread::_group_offset = 0; | |
562 int java_lang_Thread::_contextClassLoader_offset = 0; | |
563 int java_lang_Thread::_inheritedAccessControlContext_offset = 0; | |
564 int java_lang_Thread::_priority_offset = 0; | |
565 int java_lang_Thread::_eetop_offset = 0; | |
566 int java_lang_Thread::_daemon_offset = 0; | |
567 int java_lang_Thread::_stillborn_offset = 0; | |
568 int java_lang_Thread::_stackSize_offset = 0; | |
569 int java_lang_Thread::_tid_offset = 0; | |
570 int java_lang_Thread::_thread_status_offset = 0; | |
571 int java_lang_Thread::_park_blocker_offset = 0; | |
572 int java_lang_Thread::_park_event_offset = 0 ; | |
573 | |
574 | |
575 void java_lang_Thread::compute_offsets() { | |
576 assert(_group_offset == 0, "offsets should be initialized only once"); | |
577 | |
578 klassOop k = SystemDictionary::thread_klass(); | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
579 compute_offset(_name_offset, k, vmSymbols::name_name(), vmSymbols::char_array_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
580 compute_offset(_group_offset, k, vmSymbols::group_name(), vmSymbols::threadgroup_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
581 compute_offset(_contextClassLoader_offset, k, vmSymbols::contextClassLoader_name(), vmSymbols::classloader_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
582 compute_offset(_inheritedAccessControlContext_offset, k, vmSymbols::inheritedAccessControlContext_name(), vmSymbols::accesscontrolcontext_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
583 compute_offset(_priority_offset, k, vmSymbols::priority_name(), vmSymbols::int_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
584 compute_offset(_daemon_offset, k, vmSymbols::daemon_name(), vmSymbols::bool_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
585 compute_offset(_eetop_offset, k, vmSymbols::eetop_name(), vmSymbols::long_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
586 compute_offset(_stillborn_offset, k, vmSymbols::stillborn_name(), vmSymbols::bool_signature()); |
0 | 587 // The stackSize field is only present starting in 1.4, so don't go fatal. |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
588 compute_optional_offset(_stackSize_offset, k, vmSymbols::stackSize_name(), vmSymbols::long_signature()); |
0 | 589 // The tid and thread_status fields are only present starting in 1.5, so don't go fatal. |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
590 compute_optional_offset(_tid_offset, k, vmSymbols::thread_id_name(), vmSymbols::long_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
591 compute_optional_offset(_thread_status_offset, k, vmSymbols::thread_status_name(), vmSymbols::int_signature()); |
0 | 592 // The parkBlocker field is only present starting in 1.6, so don't go fatal. |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
593 compute_optional_offset(_park_blocker_offset, k, vmSymbols::park_blocker_name(), vmSymbols::object_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
594 compute_optional_offset(_park_event_offset, k, vmSymbols::park_event_name(), |
0 | 595 vmSymbols::long_signature()); |
596 } | |
597 | |
598 | |
599 JavaThread* java_lang_Thread::thread(oop java_thread) { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
600 return (JavaThread*)java_thread->address_field(_eetop_offset); |
0 | 601 } |
602 | |
603 | |
604 void java_lang_Thread::set_thread(oop java_thread, JavaThread* thread) { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
605 java_thread->address_field_put(_eetop_offset, (address)thread); |
0 | 606 } |
607 | |
608 | |
609 typeArrayOop java_lang_Thread::name(oop java_thread) { | |
610 oop name = java_thread->obj_field(_name_offset); | |
611 assert(name == NULL || (name->is_typeArray() && typeArrayKlass::cast(name->klass())->element_type() == T_CHAR), "just checking"); | |
612 return typeArrayOop(name); | |
613 } | |
614 | |
615 | |
616 void java_lang_Thread::set_name(oop java_thread, typeArrayOop name) { | |
617 assert(java_thread->obj_field(_name_offset) == NULL, "name should be NULL"); | |
618 java_thread->obj_field_put(_name_offset, name); | |
619 } | |
620 | |
621 | |
622 ThreadPriority java_lang_Thread::priority(oop java_thread) { | |
623 return (ThreadPriority)java_thread->int_field(_priority_offset); | |
624 } | |
625 | |
626 | |
627 void java_lang_Thread::set_priority(oop java_thread, ThreadPriority priority) { | |
628 java_thread->int_field_put(_priority_offset, priority); | |
629 } | |
630 | |
631 | |
632 oop java_lang_Thread::threadGroup(oop java_thread) { | |
633 return java_thread->obj_field(_group_offset); | |
634 } | |
635 | |
636 | |
637 bool java_lang_Thread::is_stillborn(oop java_thread) { | |
638 return java_thread->bool_field(_stillborn_offset) != 0; | |
639 } | |
640 | |
641 | |
642 // We never have reason to turn the stillborn bit off | |
643 void java_lang_Thread::set_stillborn(oop java_thread) { | |
644 java_thread->bool_field_put(_stillborn_offset, true); | |
645 } | |
646 | |
647 | |
648 bool java_lang_Thread::is_alive(oop java_thread) { | |
649 JavaThread* thr = java_lang_Thread::thread(java_thread); | |
650 return (thr != NULL); | |
651 } | |
652 | |
653 | |
654 bool java_lang_Thread::is_daemon(oop java_thread) { | |
655 return java_thread->bool_field(_daemon_offset) != 0; | |
656 } | |
657 | |
658 | |
659 void java_lang_Thread::set_daemon(oop java_thread) { | |
660 java_thread->bool_field_put(_daemon_offset, true); | |
661 } | |
662 | |
663 oop java_lang_Thread::context_class_loader(oop java_thread) { | |
664 return java_thread->obj_field(_contextClassLoader_offset); | |
665 } | |
666 | |
667 oop java_lang_Thread::inherited_access_control_context(oop java_thread) { | |
668 return java_thread->obj_field(_inheritedAccessControlContext_offset); | |
669 } | |
670 | |
671 | |
672 jlong java_lang_Thread::stackSize(oop java_thread) { | |
673 // The stackSize field is only present starting in 1.4 | |
674 if (_stackSize_offset > 0) { | |
675 assert(JDK_Version::is_gte_jdk14x_version(), "sanity check"); | |
676 return java_thread->long_field(_stackSize_offset); | |
677 } else { | |
678 return 0; | |
679 } | |
680 } | |
681 | |
682 // Write the thread status value to threadStatus field in java.lang.Thread java class. | |
683 void java_lang_Thread::set_thread_status(oop java_thread, | |
684 java_lang_Thread::ThreadStatus status) { | |
685 assert(JavaThread::current()->thread_state() == _thread_in_vm, "Java Thread is not running in vm"); | |
686 // The threadStatus is only present starting in 1.5 | |
687 if (_thread_status_offset > 0) { | |
688 java_thread->int_field_put(_thread_status_offset, status); | |
689 } | |
690 } | |
691 | |
692 // Read thread status value from threadStatus field in java.lang.Thread java class. | |
693 java_lang_Thread::ThreadStatus java_lang_Thread::get_thread_status(oop java_thread) { | |
694 assert(Thread::current()->is_VM_thread() || | |
695 JavaThread::current()->thread_state() == _thread_in_vm, | |
696 "Java Thread is not running in vm"); | |
697 // The threadStatus is only present starting in 1.5 | |
698 if (_thread_status_offset > 0) { | |
699 return (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset); | |
700 } else { | |
701 // All we can easily figure out is if it is alive, but that is | |
702 // enough info for a valid unknown status. | |
703 // These aren't restricted to valid set ThreadStatus values, so | |
704 // use JVMTI values and cast. | |
705 JavaThread* thr = java_lang_Thread::thread(java_thread); | |
706 if (thr == NULL) { | |
707 // the thread hasn't run yet or is in the process of exiting | |
708 return NEW; | |
709 } | |
710 return (java_lang_Thread::ThreadStatus)JVMTI_THREAD_STATE_ALIVE; | |
711 } | |
712 } | |
713 | |
714 | |
715 jlong java_lang_Thread::thread_id(oop java_thread) { | |
716 // The thread ID field is only present starting in 1.5 | |
717 if (_tid_offset > 0) { | |
718 return java_thread->long_field(_tid_offset); | |
719 } else { | |
720 return 0; | |
721 } | |
722 } | |
723 | |
724 oop java_lang_Thread::park_blocker(oop java_thread) { | |
242 | 725 assert(JDK_Version::current().supports_thread_park_blocker() && |
726 _park_blocker_offset != 0, "Must support parkBlocker field"); | |
0 | 727 |
728 if (_park_blocker_offset > 0) { | |
729 return java_thread->obj_field(_park_blocker_offset); | |
730 } | |
731 | |
732 return NULL; | |
733 } | |
734 | |
735 jlong java_lang_Thread::park_event(oop java_thread) { | |
736 if (_park_event_offset > 0) { | |
737 return java_thread->long_field(_park_event_offset); | |
738 } | |
739 return 0; | |
740 } | |
741 | |
742 bool java_lang_Thread::set_park_event(oop java_thread, jlong ptr) { | |
743 if (_park_event_offset > 0) { | |
744 java_thread->long_field_put(_park_event_offset, ptr); | |
745 return true; | |
746 } | |
747 return false; | |
748 } | |
749 | |
750 | |
751 const char* java_lang_Thread::thread_status_name(oop java_thread) { | |
752 assert(JDK_Version::is_gte_jdk15x_version() && _thread_status_offset != 0, "Must have thread status"); | |
753 ThreadStatus status = (java_lang_Thread::ThreadStatus)java_thread->int_field(_thread_status_offset); | |
754 switch (status) { | |
755 case NEW : return "NEW"; | |
756 case RUNNABLE : return "RUNNABLE"; | |
757 case SLEEPING : return "TIMED_WAITING (sleeping)"; | |
758 case IN_OBJECT_WAIT : return "WAITING (on object monitor)"; | |
759 case IN_OBJECT_WAIT_TIMED : return "TIMED_WAITING (on object monitor)"; | |
760 case PARKED : return "WAITING (parking)"; | |
761 case PARKED_TIMED : return "TIMED_WAITING (parking)"; | |
762 case BLOCKED_ON_MONITOR_ENTER : return "BLOCKED (on object monitor)"; | |
763 case TERMINATED : return "TERMINATED"; | |
764 default : return "UNKNOWN"; | |
765 }; | |
766 } | |
767 int java_lang_ThreadGroup::_parent_offset = 0; | |
768 int java_lang_ThreadGroup::_name_offset = 0; | |
769 int java_lang_ThreadGroup::_threads_offset = 0; | |
770 int java_lang_ThreadGroup::_groups_offset = 0; | |
771 int java_lang_ThreadGroup::_maxPriority_offset = 0; | |
772 int java_lang_ThreadGroup::_destroyed_offset = 0; | |
773 int java_lang_ThreadGroup::_daemon_offset = 0; | |
774 int java_lang_ThreadGroup::_vmAllowSuspension_offset = 0; | |
775 int java_lang_ThreadGroup::_nthreads_offset = 0; | |
776 int java_lang_ThreadGroup::_ngroups_offset = 0; | |
777 | |
778 oop java_lang_ThreadGroup::parent(oop java_thread_group) { | |
779 assert(java_thread_group->is_oop(), "thread group must be oop"); | |
780 return java_thread_group->obj_field(_parent_offset); | |
781 } | |
782 | |
783 // ("name as oop" accessor is not necessary) | |
784 | |
785 typeArrayOop java_lang_ThreadGroup::name(oop java_thread_group) { | |
786 oop name = java_thread_group->obj_field(_name_offset); | |
787 // ThreadGroup.name can be null | |
788 return name == NULL ? (typeArrayOop)NULL : java_lang_String::value(name); | |
789 } | |
790 | |
791 int java_lang_ThreadGroup::nthreads(oop java_thread_group) { | |
792 assert(java_thread_group->is_oop(), "thread group must be oop"); | |
793 return java_thread_group->int_field(_nthreads_offset); | |
794 } | |
795 | |
796 objArrayOop java_lang_ThreadGroup::threads(oop java_thread_group) { | |
797 oop threads = java_thread_group->obj_field(_threads_offset); | |
798 assert(threads != NULL, "threadgroups should have threads"); | |
799 assert(threads->is_objArray(), "just checking"); // Todo: Add better type checking code | |
800 return objArrayOop(threads); | |
801 } | |
802 | |
803 int java_lang_ThreadGroup::ngroups(oop java_thread_group) { | |
804 assert(java_thread_group->is_oop(), "thread group must be oop"); | |
805 return java_thread_group->int_field(_ngroups_offset); | |
806 } | |
807 | |
808 objArrayOop java_lang_ThreadGroup::groups(oop java_thread_group) { | |
809 oop groups = java_thread_group->obj_field(_groups_offset); | |
810 assert(groups == NULL || groups->is_objArray(), "just checking"); // Todo: Add better type checking code | |
811 return objArrayOop(groups); | |
812 } | |
813 | |
814 ThreadPriority java_lang_ThreadGroup::maxPriority(oop java_thread_group) { | |
815 assert(java_thread_group->is_oop(), "thread group must be oop"); | |
816 return (ThreadPriority) java_thread_group->int_field(_maxPriority_offset); | |
817 } | |
818 | |
819 bool java_lang_ThreadGroup::is_destroyed(oop java_thread_group) { | |
820 assert(java_thread_group->is_oop(), "thread group must be oop"); | |
821 return java_thread_group->bool_field(_destroyed_offset) != 0; | |
822 } | |
823 | |
824 bool java_lang_ThreadGroup::is_daemon(oop java_thread_group) { | |
825 assert(java_thread_group->is_oop(), "thread group must be oop"); | |
826 return java_thread_group->bool_field(_daemon_offset) != 0; | |
827 } | |
828 | |
829 bool java_lang_ThreadGroup::is_vmAllowSuspension(oop java_thread_group) { | |
830 assert(java_thread_group->is_oop(), "thread group must be oop"); | |
831 return java_thread_group->bool_field(_vmAllowSuspension_offset) != 0; | |
832 } | |
833 | |
834 void java_lang_ThreadGroup::compute_offsets() { | |
835 assert(_parent_offset == 0, "offsets should be initialized only once"); | |
836 | |
837 klassOop k = SystemDictionary::threadGroup_klass(); | |
838 | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
839 compute_offset(_parent_offset, k, vmSymbols::parent_name(), vmSymbols::threadgroup_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
840 compute_offset(_name_offset, k, vmSymbols::name_name(), vmSymbols::string_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
841 compute_offset(_threads_offset, k, vmSymbols::threads_name(), vmSymbols::thread_array_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
842 compute_offset(_groups_offset, k, vmSymbols::groups_name(), vmSymbols::threadgroup_array_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
843 compute_offset(_maxPriority_offset, k, vmSymbols::maxPriority_name(), vmSymbols::int_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
844 compute_offset(_destroyed_offset, k, vmSymbols::destroyed_name(), vmSymbols::bool_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
845 compute_offset(_daemon_offset, k, vmSymbols::daemon_name(), vmSymbols::bool_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
846 compute_offset(_vmAllowSuspension_offset, k, vmSymbols::vmAllowSuspension_name(), vmSymbols::bool_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
847 compute_offset(_nthreads_offset, k, vmSymbols::nthreads_name(), vmSymbols::int_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
848 compute_offset(_ngroups_offset, k, vmSymbols::ngroups_name(), vmSymbols::int_signature()); |
0 | 849 } |
850 | |
851 oop java_lang_Throwable::backtrace(oop throwable) { | |
852 return throwable->obj_field_acquire(backtrace_offset); | |
853 } | |
854 | |
855 | |
856 void java_lang_Throwable::set_backtrace(oop throwable, oop value) { | |
857 throwable->release_obj_field_put(backtrace_offset, value); | |
858 } | |
859 | |
860 | |
861 oop java_lang_Throwable::message(oop throwable) { | |
862 return throwable->obj_field(detailMessage_offset); | |
863 } | |
864 | |
865 | |
866 oop java_lang_Throwable::message(Handle throwable) { | |
867 return throwable->obj_field(detailMessage_offset); | |
868 } | |
869 | |
870 | |
871 void java_lang_Throwable::set_message(oop throwable, oop value) { | |
872 throwable->obj_field_put(detailMessage_offset, value); | |
873 } | |
874 | |
875 | |
876 void java_lang_Throwable::clear_stacktrace(oop throwable) { | |
877 assert(JDK_Version::is_gte_jdk14x_version(), "should only be called in >= 1.4"); | |
878 throwable->obj_field_put(stackTrace_offset, NULL); | |
879 } | |
880 | |
881 | |
882 void java_lang_Throwable::print(oop throwable, outputStream* st) { | |
883 ResourceMark rm; | |
884 klassOop k = throwable->klass(); | |
885 assert(k != NULL, "just checking"); | |
886 st->print("%s", instanceKlass::cast(k)->external_name()); | |
887 oop msg = message(throwable); | |
888 if (msg != NULL) { | |
889 st->print(": %s", java_lang_String::as_utf8_string(msg)); | |
890 } | |
891 } | |
892 | |
893 | |
894 void java_lang_Throwable::print(Handle throwable, outputStream* st) { | |
895 ResourceMark rm; | |
896 klassOop k = throwable->klass(); | |
897 assert(k != NULL, "just checking"); | |
898 st->print("%s", instanceKlass::cast(k)->external_name()); | |
899 oop msg = message(throwable); | |
900 if (msg != NULL) { | |
901 st->print(": %s", java_lang_String::as_utf8_string(msg)); | |
902 } | |
903 } | |
904 | |
905 // Print stack trace element to resource allocated buffer | |
906 char* java_lang_Throwable::print_stack_element_to_buffer(methodOop method, int bci) { | |
907 // Get strings and string lengths | |
908 instanceKlass* klass = instanceKlass::cast(method->method_holder()); | |
909 const char* klass_name = klass->external_name(); | |
910 int buf_len = (int)strlen(klass_name); | |
911 char* source_file_name; | |
912 if (klass->source_file_name() == NULL) { | |
913 source_file_name = NULL; | |
914 } else { | |
915 source_file_name = klass->source_file_name()->as_C_string(); | |
916 buf_len += (int)strlen(source_file_name); | |
917 } | |
918 char* method_name = method->name()->as_C_string(); | |
919 buf_len += (int)strlen(method_name); | |
920 | |
921 // Allocate temporary buffer with extra space for formatting and line number | |
922 char* buf = NEW_RESOURCE_ARRAY(char, buf_len + 64); | |
923 | |
924 // Print stack trace line in buffer | |
925 sprintf(buf, "\tat %s.%s", klass_name, method_name); | |
926 if (method->is_native()) { | |
927 strcat(buf, "(Native Method)"); | |
928 } else { | |
929 int line_number = method->line_number_from_bci(bci); | |
930 if (source_file_name != NULL && (line_number != -1)) { | |
931 // Sourcename and linenumber | |
932 sprintf(buf + (int)strlen(buf), "(%s:%d)", source_file_name, line_number); | |
933 } else if (source_file_name != NULL) { | |
934 // Just sourcename | |
935 sprintf(buf + (int)strlen(buf), "(%s)", source_file_name); | |
936 } else { | |
937 // Neither soucename and linenumber | |
938 sprintf(buf + (int)strlen(buf), "(Unknown Source)"); | |
939 } | |
940 nmethod* nm = method->code(); | |
941 if (WizardMode && nm != NULL) { | |
513
2328d1d3f8cf
6781583: Hotspot build fails on linux 64 bit platform with gcc 4.3.2
xlu
parents:
242
diff
changeset
|
942 sprintf(buf + (int)strlen(buf), "(nmethod " PTR_FORMAT ")", (intptr_t)nm); |
0 | 943 } |
944 } | |
945 | |
946 return buf; | |
947 } | |
948 | |
949 | |
950 void java_lang_Throwable::print_stack_element(Handle stream, methodOop method, int bci) { | |
951 ResourceMark rm; | |
952 char* buf = print_stack_element_to_buffer(method, bci); | |
953 print_to_stream(stream, buf); | |
954 } | |
955 | |
956 void java_lang_Throwable::print_stack_element(outputStream *st, methodOop method, int bci) { | |
957 ResourceMark rm; | |
958 char* buf = print_stack_element_to_buffer(method, bci); | |
959 st->print_cr("%s", buf); | |
960 } | |
961 | |
962 void java_lang_Throwable::print_to_stream(Handle stream, const char* str) { | |
963 if (stream.is_null()) { | |
964 tty->print_cr("%s", str); | |
965 } else { | |
966 EXCEPTION_MARK; | |
967 JavaValue result(T_VOID); | |
968 Handle arg (THREAD, oopFactory::new_charArray(str, THREAD)); | |
969 if (!HAS_PENDING_EXCEPTION) { | |
970 JavaCalls::call_virtual(&result, | |
971 stream, | |
972 KlassHandle(THREAD, stream->klass()), | |
973 vmSymbolHandles::println_name(), | |
974 vmSymbolHandles::char_array_void_signature(), | |
975 arg, | |
976 THREAD); | |
977 } | |
978 // Ignore any exceptions. we are in the middle of exception handling. Same as classic VM. | |
979 if (HAS_PENDING_EXCEPTION) CLEAR_PENDING_EXCEPTION; | |
980 } | |
981 | |
982 } | |
983 | |
984 | |
985 const char* java_lang_Throwable::no_stack_trace_message() { | |
986 return "\t<<no stack trace available>>"; | |
987 } | |
988 | |
989 | |
990 // Currently used only for exceptions occurring during startup | |
991 void java_lang_Throwable::print_stack_trace(oop throwable, outputStream* st) { | |
992 Thread *THREAD = Thread::current(); | |
993 Handle h_throwable(THREAD, throwable); | |
994 while (h_throwable.not_null()) { | |
995 objArrayHandle result (THREAD, objArrayOop(backtrace(h_throwable()))); | |
996 if (result.is_null()) { | |
997 st->print_cr(no_stack_trace_message()); | |
998 return; | |
999 } | |
1000 | |
1001 while (result.not_null()) { | |
1002 objArrayHandle methods (THREAD, | |
1003 objArrayOop(result->obj_at(trace_methods_offset))); | |
1004 typeArrayHandle bcis (THREAD, | |
1005 typeArrayOop(result->obj_at(trace_bcis_offset))); | |
1006 | |
1007 if (methods.is_null() || bcis.is_null()) { | |
1008 st->print_cr(no_stack_trace_message()); | |
1009 return; | |
1010 } | |
1011 | |
1012 int length = methods()->length(); | |
1013 for (int index = 0; index < length; index++) { | |
1014 methodOop method = methodOop(methods()->obj_at(index)); | |
1015 if (method == NULL) goto handle_cause; | |
1016 int bci = bcis->ushort_at(index); | |
1017 print_stack_element(st, method, bci); | |
1018 } | |
1019 result = objArrayHandle(THREAD, objArrayOop(result->obj_at(trace_next_offset))); | |
1020 } | |
1021 handle_cause: | |
1022 { | |
1023 EXCEPTION_MARK; | |
1024 JavaValue result(T_OBJECT); | |
1025 JavaCalls::call_virtual(&result, | |
1026 h_throwable, | |
1027 KlassHandle(THREAD, h_throwable->klass()), | |
1028 vmSymbolHandles::getCause_name(), | |
1029 vmSymbolHandles::void_throwable_signature(), | |
1030 THREAD); | |
1031 // Ignore any exceptions. we are in the middle of exception handling. Same as classic VM. | |
1032 if (HAS_PENDING_EXCEPTION) { | |
1033 CLEAR_PENDING_EXCEPTION; | |
1034 h_throwable = Handle(); | |
1035 } else { | |
1036 h_throwable = Handle(THREAD, (oop) result.get_jobject()); | |
1037 if (h_throwable.not_null()) { | |
1038 st->print("Caused by: "); | |
1039 print(h_throwable, st); | |
1040 st->cr(); | |
1041 } | |
1042 } | |
1043 } | |
1044 } | |
1045 } | |
1046 | |
1047 | |
1048 void java_lang_Throwable::print_stack_trace(oop throwable, oop print_stream) { | |
1049 // Note: this is no longer used in Merlin, but we support it for compatibility. | |
1050 Thread *thread = Thread::current(); | |
1051 Handle stream(thread, print_stream); | |
1052 objArrayHandle result (thread, objArrayOop(backtrace(throwable))); | |
1053 if (result.is_null()) { | |
1054 print_to_stream(stream, no_stack_trace_message()); | |
1055 return; | |
1056 } | |
1057 | |
1058 while (result.not_null()) { | |
1059 objArrayHandle methods (thread, | |
1060 objArrayOop(result->obj_at(trace_methods_offset))); | |
1061 typeArrayHandle bcis (thread, | |
1062 typeArrayOop(result->obj_at(trace_bcis_offset))); | |
1063 | |
1064 if (methods.is_null() || bcis.is_null()) { | |
1065 print_to_stream(stream, no_stack_trace_message()); | |
1066 return; | |
1067 } | |
1068 | |
1069 int length = methods()->length(); | |
1070 for (int index = 0; index < length; index++) { | |
1071 methodOop method = methodOop(methods()->obj_at(index)); | |
1072 if (method == NULL) return; | |
1073 int bci = bcis->ushort_at(index); | |
1074 print_stack_element(stream, method, bci); | |
1075 } | |
1076 result = objArrayHandle(thread, objArrayOop(result->obj_at(trace_next_offset))); | |
1077 } | |
1078 } | |
1079 | |
1080 // This class provides a simple wrapper over the internal structure of | |
1081 // exception backtrace to insulate users of the backtrace from needing | |
1082 // to know what it looks like. | |
1083 class BacktraceBuilder: public StackObj { | |
1084 private: | |
1085 Handle _backtrace; | |
1086 objArrayOop _head; | |
1087 objArrayOop _methods; | |
1088 typeArrayOop _bcis; | |
1089 int _index; | |
1090 bool _dirty; | |
1091 No_Safepoint_Verifier _nsv; | |
1092 | |
1093 public: | |
1094 | |
1095 enum { | |
1096 trace_methods_offset = java_lang_Throwable::trace_methods_offset, | |
1097 trace_bcis_offset = java_lang_Throwable::trace_bcis_offset, | |
1098 trace_next_offset = java_lang_Throwable::trace_next_offset, | |
1099 trace_size = java_lang_Throwable::trace_size, | |
1100 trace_chunk_size = java_lang_Throwable::trace_chunk_size | |
1101 }; | |
1102 | |
1103 // constructor for new backtrace | |
98
deb97b8ef02b
6679708: No_Safepoint_Verifier and BacktraceBuilder have uninitialized fields
never
parents:
22
diff
changeset
|
1104 BacktraceBuilder(TRAPS): _methods(NULL), _bcis(NULL), _head(NULL), _dirty(false) { |
0 | 1105 expand(CHECK); |
1106 _backtrace = _head; | |
1107 _index = 0; | |
1108 } | |
1109 | |
1110 void flush() { | |
1111 if (_dirty && _methods != NULL) { | |
1112 BarrierSet* bs = Universe::heap()->barrier_set(); | |
1113 assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt"); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
1114 bs->write_ref_array(MemRegion((HeapWord*)_methods->base(), |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
1115 _methods->array_size())); |
0 | 1116 _dirty = false; |
1117 } | |
1118 } | |
1119 | |
1120 void expand(TRAPS) { | |
1121 flush(); | |
1122 | |
1123 objArrayHandle old_head(THREAD, _head); | |
1124 Pause_No_Safepoint_Verifier pnsv(&_nsv); | |
1125 | |
1126 objArrayOop head = oopFactory::new_objectArray(trace_size, CHECK); | |
1127 objArrayHandle new_head(THREAD, head); | |
1128 | |
1129 objArrayOop methods = oopFactory::new_objectArray(trace_chunk_size, CHECK); | |
1130 objArrayHandle new_methods(THREAD, methods); | |
1131 | |
1132 typeArrayOop bcis = oopFactory::new_shortArray(trace_chunk_size, CHECK); | |
1133 typeArrayHandle new_bcis(THREAD, bcis); | |
1134 | |
1135 if (!old_head.is_null()) { | |
1136 old_head->obj_at_put(trace_next_offset, new_head()); | |
1137 } | |
1138 new_head->obj_at_put(trace_methods_offset, new_methods()); | |
1139 new_head->obj_at_put(trace_bcis_offset, new_bcis()); | |
1140 | |
1141 _head = new_head(); | |
1142 _methods = new_methods(); | |
1143 _bcis = new_bcis(); | |
1144 _index = 0; | |
1145 } | |
1146 | |
1147 oop backtrace() { | |
1148 flush(); | |
1149 return _backtrace(); | |
1150 } | |
1151 | |
1152 inline void push(methodOop method, short bci, TRAPS) { | |
1153 if (_index >= trace_chunk_size) { | |
1154 methodHandle mhandle(THREAD, method); | |
1155 expand(CHECK); | |
1156 method = mhandle(); | |
1157 } | |
1158 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
1159 _methods->obj_at_put(_index, method); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
1160 // bad for UseCompressedOops |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
1161 // *_methods->obj_at_addr(_index) = method; |
0 | 1162 _bcis->ushort_at_put(_index, bci); |
1163 _index++; | |
1164 _dirty = true; | |
1165 } | |
1166 | |
1167 methodOop current_method() { | |
1168 assert(_index >= 0 && _index < trace_chunk_size, "out of range"); | |
1169 return methodOop(_methods->obj_at(_index)); | |
1170 } | |
1171 | |
1172 jushort current_bci() { | |
1173 assert(_index >= 0 && _index < trace_chunk_size, "out of range"); | |
1174 return _bcis->ushort_at(_index); | |
1175 } | |
1176 }; | |
1177 | |
1178 | |
1179 void java_lang_Throwable::fill_in_stack_trace(Handle throwable, TRAPS) { | |
1180 if (!StackTraceInThrowable) return; | |
1181 ResourceMark rm(THREAD); | |
1182 | |
1183 // Start out by clearing the backtrace for this object, in case the VM | |
1184 // runs out of memory while allocating the stack trace | |
1185 set_backtrace(throwable(), NULL); | |
1186 if (JDK_Version::is_gte_jdk14x_version()) { | |
1187 // New since 1.4, clear lazily constructed Java level stacktrace if | |
1188 // refilling occurs | |
1189 clear_stacktrace(throwable()); | |
1190 } | |
1191 | |
1192 int max_depth = MaxJavaStackTraceDepth; | |
1193 JavaThread* thread = (JavaThread*)THREAD; | |
1194 BacktraceBuilder bt(CHECK); | |
1195 | |
1196 // Instead of using vframe directly, this version of fill_in_stack_trace | |
1197 // basically handles everything by hand. This significantly improved the | |
1198 // speed of this method call up to 28.5% on Solaris sparc. 27.1% on Windows. | |
1199 // See bug 6333838 for more details. | |
1200 // The "ASSERT" here is to verify this method generates the exactly same stack | |
1201 // trace as utilizing vframe. | |
1202 #ifdef ASSERT | |
1203 vframeStream st(thread); | |
1204 methodHandle st_method(THREAD, st.method()); | |
1205 #endif | |
1206 int total_count = 0; | |
1207 RegisterMap map(thread, false); | |
1208 int decode_offset = 0; | |
1209 nmethod* nm = NULL; | |
1210 bool skip_fillInStackTrace_check = false; | |
1211 bool skip_throwableInit_check = false; | |
1212 | |
1213 for (frame fr = thread->last_frame(); max_depth != total_count;) { | |
1214 methodOop method = NULL; | |
1215 int bci = 0; | |
1216 | |
1217 // Compiled java method case. | |
1218 if (decode_offset != 0) { | |
1219 DebugInfoReadStream stream(nm, decode_offset); | |
1220 decode_offset = stream.read_int(); | |
1221 method = (methodOop)nm->oop_at(stream.read_int()); | |
1222 bci = stream.read_bci(); | |
1223 } else { | |
1224 if (fr.is_first_frame()) break; | |
1225 address pc = fr.pc(); | |
1226 if (fr.is_interpreted_frame()) { | |
1227 intptr_t bcx = fr.interpreter_frame_bcx(); | |
1228 method = fr.interpreter_frame_method(); | |
1229 bci = fr.is_bci(bcx) ? bcx : method->bci_from((address)bcx); | |
1230 fr = fr.sender(&map); | |
1231 } else { | |
1232 CodeBlob* cb = fr.cb(); | |
1233 // HMMM QQQ might be nice to have frame return nm as NULL if cb is non-NULL | |
1234 // but non nmethod | |
1235 fr = fr.sender(&map); | |
1236 if (cb == NULL || !cb->is_nmethod()) { | |
1237 continue; | |
1238 } | |
1239 nm = (nmethod*)cb; | |
1240 if (nm->method()->is_native()) { | |
1241 method = nm->method(); | |
1242 bci = 0; | |
1243 } else { | |
1244 PcDesc* pd = nm->pc_desc_at(pc); | |
1245 decode_offset = pd->scope_decode_offset(); | |
1246 // if decode_offset is not equal to 0, it will execute the | |
1247 // "compiled java method case" at the beginning of the loop. | |
1248 continue; | |
1249 } | |
1250 } | |
1251 } | |
1252 #ifdef ASSERT | |
1253 assert(st_method() == method && st.bci() == bci, | |
1254 "Wrong stack trace"); | |
1255 st.next(); | |
1256 // vframeStream::method isn't GC-safe so store off a copy | |
1257 // of the methodOop in case we GC. | |
1258 if (!st.at_end()) { | |
1259 st_method = st.method(); | |
1260 } | |
1261 #endif | |
1262 if (!skip_fillInStackTrace_check) { | |
1263 // check "fillInStackTrace" only once, so we negate the flag | |
1264 // after the first time check. | |
1265 skip_fillInStackTrace_check = true; | |
1266 if (method->name() == vmSymbols::fillInStackTrace_name()) { | |
1267 continue; | |
1268 } | |
1269 } | |
1270 // skip <init> methods of the exceptions klass. If there is <init> methods | |
1271 // that belongs to a superclass of the exception we are going to skipping | |
1272 // them in stack trace. This is simlar to classic VM. | |
1273 if (!skip_throwableInit_check) { | |
1274 if (method->name() == vmSymbols::object_initializer_name() && | |
1275 throwable->is_a(method->method_holder())) { | |
1276 continue; | |
1277 } else { | |
1278 // if no "Throwable.init()" method found, we stop checking it next time. | |
1279 skip_throwableInit_check = true; | |
1280 } | |
1281 } | |
1282 bt.push(method, bci, CHECK); | |
1283 total_count++; | |
1284 } | |
1285 | |
1286 // Put completed stack trace into throwable object | |
1287 set_backtrace(throwable(), bt.backtrace()); | |
1288 } | |
1289 | |
1290 void java_lang_Throwable::fill_in_stack_trace(Handle throwable) { | |
1291 // No-op if stack trace is disabled | |
1292 if (!StackTraceInThrowable) { | |
1293 return; | |
1294 } | |
1295 | |
1296 // Disable stack traces for some preallocated out of memory errors | |
1297 if (!Universe::should_fill_in_stack_trace(throwable)) { | |
1298 return; | |
1299 } | |
1300 | |
1301 PRESERVE_EXCEPTION_MARK; | |
1302 | |
1303 JavaThread* thread = JavaThread::active(); | |
1304 fill_in_stack_trace(throwable, thread); | |
1305 // ignore exceptions thrown during stack trace filling | |
1306 CLEAR_PENDING_EXCEPTION; | |
1307 } | |
1308 | |
1309 void java_lang_Throwable::allocate_backtrace(Handle throwable, TRAPS) { | |
1310 // Allocate stack trace - backtrace is created but not filled in | |
1311 | |
1312 // No-op if stack trace is disabled | |
1313 if (!StackTraceInThrowable) return; | |
1314 | |
1315 objArrayOop h_oop = oopFactory::new_objectArray(trace_size, CHECK); | |
1316 objArrayHandle backtrace (THREAD, h_oop); | |
1317 objArrayOop m_oop = oopFactory::new_objectArray(trace_chunk_size, CHECK); | |
1318 objArrayHandle methods (THREAD, m_oop); | |
1319 typeArrayOop b = oopFactory::new_shortArray(trace_chunk_size, CHECK); | |
1320 typeArrayHandle bcis(THREAD, b); | |
1321 | |
1322 // backtrace has space for one chunk (next is NULL) | |
1323 backtrace->obj_at_put(trace_methods_offset, methods()); | |
1324 backtrace->obj_at_put(trace_bcis_offset, bcis()); | |
1325 set_backtrace(throwable(), backtrace()); | |
1326 } | |
1327 | |
1328 | |
1329 void java_lang_Throwable::fill_in_stack_trace_of_preallocated_backtrace(Handle throwable) { | |
1330 // Fill in stack trace into preallocated backtrace (no GC) | |
1331 | |
1332 // No-op if stack trace is disabled | |
1333 if (!StackTraceInThrowable) return; | |
1334 | |
1335 assert(throwable->is_a(SystemDictionary::throwable_klass()), "sanity check"); | |
1336 | |
1337 oop backtrace = java_lang_Throwable::backtrace(throwable()); | |
1338 assert(backtrace != NULL, "backtrace not preallocated"); | |
1339 | |
1340 oop m = objArrayOop(backtrace)->obj_at(trace_methods_offset); | |
1341 objArrayOop methods = objArrayOop(m); | |
1342 assert(methods != NULL && methods->length() > 0, "method array not preallocated"); | |
1343 | |
1344 oop b = objArrayOop(backtrace)->obj_at(trace_bcis_offset); | |
1345 typeArrayOop bcis = typeArrayOop(b); | |
1346 assert(bcis != NULL, "bci array not preallocated"); | |
1347 | |
1348 assert(methods->length() == bcis->length(), "method and bci arrays should match"); | |
1349 | |
1350 JavaThread* thread = JavaThread::current(); | |
1351 ResourceMark rm(thread); | |
1352 vframeStream st(thread); | |
1353 | |
1354 // Unlike fill_in_stack_trace we do not skip fillInStackTrace or throwable init | |
1355 // methods as preallocated errors aren't created by "java" code. | |
1356 | |
1357 // fill in as much stack trace as possible | |
1358 int max_chunks = MIN2(methods->length(), (int)MaxJavaStackTraceDepth); | |
1359 int chunk_count = 0; | |
1360 | |
1361 for (;!st.at_end(); st.next()) { | |
1362 // add element | |
1363 bcis->ushort_at_put(chunk_count, st.bci()); | |
1364 methods->obj_at_put(chunk_count, st.method()); | |
1365 | |
1366 chunk_count++; | |
1367 | |
1368 // Bail-out for deep stacks | |
1369 if (chunk_count >= max_chunks) break; | |
1370 } | |
1371 } | |
1372 | |
1373 | |
1374 int java_lang_Throwable::get_stack_trace_depth(oop throwable, TRAPS) { | |
1375 if (throwable == NULL) { | |
1376 THROW_0(vmSymbols::java_lang_NullPointerException()); | |
1377 } | |
1378 objArrayOop chunk = objArrayOop(backtrace(throwable)); | |
1379 int depth = 0; | |
1380 if (chunk != NULL) { | |
1381 // Iterate over chunks and count full ones | |
1382 while (true) { | |
1383 objArrayOop next = objArrayOop(chunk->obj_at(trace_next_offset)); | |
1384 if (next == NULL) break; | |
1385 depth += trace_chunk_size; | |
1386 chunk = next; | |
1387 } | |
1388 assert(chunk != NULL && chunk->obj_at(trace_next_offset) == NULL, "sanity check"); | |
1389 // Count element in remaining partial chunk | |
1390 objArrayOop methods = objArrayOop(chunk->obj_at(trace_methods_offset)); | |
1391 typeArrayOop bcis = typeArrayOop(chunk->obj_at(trace_bcis_offset)); | |
1392 assert(methods != NULL && bcis != NULL, "sanity check"); | |
1393 for (int i = 0; i < methods->length(); i++) { | |
1394 if (methods->obj_at(i) == NULL) break; | |
1395 depth++; | |
1396 } | |
1397 } | |
1398 return depth; | |
1399 } | |
1400 | |
1401 | |
1402 oop java_lang_Throwable::get_stack_trace_element(oop throwable, int index, TRAPS) { | |
1403 if (throwable == NULL) { | |
1404 THROW_0(vmSymbols::java_lang_NullPointerException()); | |
1405 } | |
1406 if (index < 0) { | |
1407 THROW_(vmSymbols::java_lang_IndexOutOfBoundsException(), NULL); | |
1408 } | |
1409 // Compute how many chunks to skip and index into actual chunk | |
1410 objArrayOop chunk = objArrayOop(backtrace(throwable)); | |
1411 int skip_chunks = index / trace_chunk_size; | |
1412 int chunk_index = index % trace_chunk_size; | |
1413 while (chunk != NULL && skip_chunks > 0) { | |
1414 chunk = objArrayOop(chunk->obj_at(trace_next_offset)); | |
1415 skip_chunks--; | |
1416 } | |
1417 if (chunk == NULL) { | |
1418 THROW_(vmSymbols::java_lang_IndexOutOfBoundsException(), NULL); | |
1419 } | |
1420 // Get method,bci from chunk | |
1421 objArrayOop methods = objArrayOop(chunk->obj_at(trace_methods_offset)); | |
1422 typeArrayOop bcis = typeArrayOop(chunk->obj_at(trace_bcis_offset)); | |
1423 assert(methods != NULL && bcis != NULL, "sanity check"); | |
1424 methodHandle method(THREAD, methodOop(methods->obj_at(chunk_index))); | |
1425 int bci = bcis->ushort_at(chunk_index); | |
1426 // Chunk can be partial full | |
1427 if (method.is_null()) { | |
1428 THROW_(vmSymbols::java_lang_IndexOutOfBoundsException(), NULL); | |
1429 } | |
1430 | |
1431 oop element = java_lang_StackTraceElement::create(method, bci, CHECK_0); | |
1432 return element; | |
1433 } | |
1434 | |
1435 oop java_lang_StackTraceElement::create(methodHandle method, int bci, TRAPS) { | |
1436 // SystemDictionary::stackTraceElement_klass() will be null for pre-1.4 JDKs | |
1437 assert(JDK_Version::is_gte_jdk14x_version(), "should only be called in >= 1.4"); | |
1438 | |
1439 // Allocate java.lang.StackTraceElement instance | |
1440 klassOop k = SystemDictionary::stackTraceElement_klass(); | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1441 assert(k != NULL, "must be loaded in 1.4+"); |
0 | 1442 instanceKlassHandle ik (THREAD, k); |
1443 if (ik->should_be_initialized()) { | |
1444 ik->initialize(CHECK_0); | |
1445 } | |
1446 | |
1447 Handle element = ik->allocate_instance_handle(CHECK_0); | |
1448 // Fill in class name | |
1449 ResourceMark rm(THREAD); | |
1450 const char* str = instanceKlass::cast(method->method_holder())->external_name(); | |
1451 oop classname = StringTable::intern((char*) str, CHECK_0); | |
1452 java_lang_StackTraceElement::set_declaringClass(element(), classname); | |
1453 // Fill in method name | |
1454 oop methodname = StringTable::intern(method->name(), CHECK_0); | |
1455 java_lang_StackTraceElement::set_methodName(element(), methodname); | |
1456 // Fill in source file name | |
1457 symbolOop source = instanceKlass::cast(method->method_holder())->source_file_name(); | |
1458 oop filename = StringTable::intern(source, CHECK_0); | |
1459 java_lang_StackTraceElement::set_fileName(element(), filename); | |
1460 // File in source line number | |
1461 int line_number; | |
1462 if (method->is_native()) { | |
1463 // Negative value different from -1 below, enabling Java code in | |
1464 // class java.lang.StackTraceElement to distinguish "native" from | |
1465 // "no LineNumberTable". | |
1466 line_number = -2; | |
1467 } else { | |
1468 // Returns -1 if no LineNumberTable, and otherwise actual line number | |
1469 line_number = method->line_number_from_bci(bci); | |
1470 } | |
1471 java_lang_StackTraceElement::set_lineNumber(element(), line_number); | |
1472 | |
1473 return element(); | |
1474 } | |
1475 | |
1476 | |
1477 void java_lang_reflect_AccessibleObject::compute_offsets() { | |
1478 klassOop k = SystemDictionary::reflect_accessible_object_klass(); | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1479 compute_offset(override_offset, k, vmSymbols::override_name(), vmSymbols::bool_signature()); |
0 | 1480 } |
1481 | |
1482 jboolean java_lang_reflect_AccessibleObject::override(oop reflect) { | |
1483 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1484 return (jboolean) reflect->bool_field(override_offset); | |
1485 } | |
1486 | |
1487 void java_lang_reflect_AccessibleObject::set_override(oop reflect, jboolean value) { | |
1488 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1489 reflect->bool_field_put(override_offset, (int) value); | |
1490 } | |
1491 | |
1492 void java_lang_reflect_Method::compute_offsets() { | |
1493 klassOop k = SystemDictionary::reflect_method_klass(); | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1494 compute_offset(clazz_offset, k, vmSymbols::clazz_name(), vmSymbols::class_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1495 compute_offset(name_offset, k, vmSymbols::name_name(), vmSymbols::string_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1496 compute_offset(returnType_offset, k, vmSymbols::returnType_name(), vmSymbols::class_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1497 compute_offset(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), vmSymbols::class_array_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1498 compute_offset(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), vmSymbols::class_array_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1499 compute_offset(slot_offset, k, vmSymbols::slot_name(), vmSymbols::int_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1500 compute_offset(modifiers_offset, k, vmSymbols::modifiers_name(), vmSymbols::int_signature()); |
0 | 1501 // The generic signature and annotations fields are only present in 1.5 |
1502 signature_offset = -1; | |
1503 annotations_offset = -1; | |
1504 parameter_annotations_offset = -1; | |
1505 annotation_default_offset = -1; | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1506 compute_optional_offset(signature_offset, k, vmSymbols::signature_name(), vmSymbols::string_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1507 compute_optional_offset(annotations_offset, k, vmSymbols::annotations_name(), vmSymbols::byte_array_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1508 compute_optional_offset(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), vmSymbols::byte_array_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1509 compute_optional_offset(annotation_default_offset, k, vmSymbols::annotation_default_name(), vmSymbols::byte_array_signature()); |
0 | 1510 } |
1511 | |
1512 Handle java_lang_reflect_Method::create(TRAPS) { | |
1513 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1514 klassOop klass = SystemDictionary::reflect_method_klass(); | |
1515 // This class is eagerly initialized during VM initialization, since we keep a refence | |
1516 // to one of the methods | |
1517 assert(instanceKlass::cast(klass)->is_initialized(), "must be initialized"); | |
1518 return instanceKlass::cast(klass)->allocate_instance_handle(CHECK_NH); | |
1519 } | |
1520 | |
1521 oop java_lang_reflect_Method::clazz(oop reflect) { | |
1522 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1523 return reflect->obj_field(clazz_offset); | |
1524 } | |
1525 | |
1526 void java_lang_reflect_Method::set_clazz(oop reflect, oop value) { | |
1527 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1528 reflect->obj_field_put(clazz_offset, value); | |
1529 } | |
1530 | |
1531 int java_lang_reflect_Method::slot(oop reflect) { | |
1532 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1533 return reflect->int_field(slot_offset); | |
1534 } | |
1535 | |
1536 void java_lang_reflect_Method::set_slot(oop reflect, int value) { | |
1537 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1538 reflect->int_field_put(slot_offset, value); | |
1539 } | |
1540 | |
1541 oop java_lang_reflect_Method::name(oop method) { | |
1542 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1543 return method->obj_field(name_offset); | |
1544 } | |
1545 | |
1546 void java_lang_reflect_Method::set_name(oop method, oop value) { | |
1547 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1548 method->obj_field_put(name_offset, value); | |
1549 } | |
1550 | |
1551 oop java_lang_reflect_Method::return_type(oop method) { | |
1552 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1553 return method->obj_field(returnType_offset); | |
1554 } | |
1555 | |
1556 void java_lang_reflect_Method::set_return_type(oop method, oop value) { | |
1557 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1558 method->obj_field_put(returnType_offset, value); | |
1559 } | |
1560 | |
1561 oop java_lang_reflect_Method::parameter_types(oop method) { | |
1562 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1563 return method->obj_field(parameterTypes_offset); | |
1564 } | |
1565 | |
1566 void java_lang_reflect_Method::set_parameter_types(oop method, oop value) { | |
1567 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1568 method->obj_field_put(parameterTypes_offset, value); | |
1569 } | |
1570 | |
1571 oop java_lang_reflect_Method::exception_types(oop method) { | |
1572 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1573 return method->obj_field(exceptionTypes_offset); | |
1574 } | |
1575 | |
1576 void java_lang_reflect_Method::set_exception_types(oop method, oop value) { | |
1577 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1578 method->obj_field_put(exceptionTypes_offset, value); | |
1579 } | |
1580 | |
1581 int java_lang_reflect_Method::modifiers(oop method) { | |
1582 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1583 return method->int_field(modifiers_offset); | |
1584 } | |
1585 | |
1586 void java_lang_reflect_Method::set_modifiers(oop method, int value) { | |
1587 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1588 method->int_field_put(modifiers_offset, value); | |
1589 } | |
1590 | |
1591 bool java_lang_reflect_Method::has_signature_field() { | |
1592 return (signature_offset >= 0); | |
1593 } | |
1594 | |
1595 oop java_lang_reflect_Method::signature(oop method) { | |
1596 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1597 assert(has_signature_field(), "signature field must be present"); | |
1598 return method->obj_field(signature_offset); | |
1599 } | |
1600 | |
1601 void java_lang_reflect_Method::set_signature(oop method, oop value) { | |
1602 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1603 assert(has_signature_field(), "signature field must be present"); | |
1604 method->obj_field_put(signature_offset, value); | |
1605 } | |
1606 | |
1607 bool java_lang_reflect_Method::has_annotations_field() { | |
1608 return (annotations_offset >= 0); | |
1609 } | |
1610 | |
1611 oop java_lang_reflect_Method::annotations(oop method) { | |
1612 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1613 assert(has_annotations_field(), "annotations field must be present"); | |
1614 return method->obj_field(annotations_offset); | |
1615 } | |
1616 | |
1617 void java_lang_reflect_Method::set_annotations(oop method, oop value) { | |
1618 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1619 assert(has_annotations_field(), "annotations field must be present"); | |
1620 method->obj_field_put(annotations_offset, value); | |
1621 } | |
1622 | |
1623 bool java_lang_reflect_Method::has_parameter_annotations_field() { | |
1624 return (parameter_annotations_offset >= 0); | |
1625 } | |
1626 | |
1627 oop java_lang_reflect_Method::parameter_annotations(oop method) { | |
1628 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1629 assert(has_parameter_annotations_field(), "parameter annotations field must be present"); | |
1630 return method->obj_field(parameter_annotations_offset); | |
1631 } | |
1632 | |
1633 void java_lang_reflect_Method::set_parameter_annotations(oop method, oop value) { | |
1634 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1635 assert(has_parameter_annotations_field(), "parameter annotations field must be present"); | |
1636 method->obj_field_put(parameter_annotations_offset, value); | |
1637 } | |
1638 | |
1639 bool java_lang_reflect_Method::has_annotation_default_field() { | |
1640 return (annotation_default_offset >= 0); | |
1641 } | |
1642 | |
1643 oop java_lang_reflect_Method::annotation_default(oop method) { | |
1644 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1645 assert(has_annotation_default_field(), "annotation default field must be present"); | |
1646 return method->obj_field(annotation_default_offset); | |
1647 } | |
1648 | |
1649 void java_lang_reflect_Method::set_annotation_default(oop method, oop value) { | |
1650 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1651 assert(has_annotation_default_field(), "annotation default field must be present"); | |
1652 method->obj_field_put(annotation_default_offset, value); | |
1653 } | |
1654 | |
1655 void java_lang_reflect_Constructor::compute_offsets() { | |
1656 klassOop k = SystemDictionary::reflect_constructor_klass(); | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1657 compute_offset(clazz_offset, k, vmSymbols::clazz_name(), vmSymbols::class_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1658 compute_offset(parameterTypes_offset, k, vmSymbols::parameterTypes_name(), vmSymbols::class_array_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1659 compute_offset(exceptionTypes_offset, k, vmSymbols::exceptionTypes_name(), vmSymbols::class_array_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1660 compute_offset(slot_offset, k, vmSymbols::slot_name(), vmSymbols::int_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1661 compute_offset(modifiers_offset, k, vmSymbols::modifiers_name(), vmSymbols::int_signature()); |
0 | 1662 // The generic signature and annotations fields are only present in 1.5 |
1663 signature_offset = -1; | |
1664 annotations_offset = -1; | |
1665 parameter_annotations_offset = -1; | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1666 compute_optional_offset(signature_offset, k, vmSymbols::signature_name(), vmSymbols::string_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1667 compute_optional_offset(annotations_offset, k, vmSymbols::annotations_name(), vmSymbols::byte_array_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1668 compute_optional_offset(parameter_annotations_offset, k, vmSymbols::parameter_annotations_name(), vmSymbols::byte_array_signature()); |
0 | 1669 } |
1670 | |
1671 Handle java_lang_reflect_Constructor::create(TRAPS) { | |
1672 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1673 symbolHandle name = vmSymbolHandles::java_lang_reflect_Constructor(); | |
1674 klassOop k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH); | |
1675 instanceKlassHandle klass (THREAD, k); | |
1676 // Ensure it is initialized | |
1677 klass->initialize(CHECK_NH); | |
1678 return klass->allocate_instance_handle(CHECK_NH); | |
1679 } | |
1680 | |
1681 oop java_lang_reflect_Constructor::clazz(oop reflect) { | |
1682 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1683 return reflect->obj_field(clazz_offset); | |
1684 } | |
1685 | |
1686 void java_lang_reflect_Constructor::set_clazz(oop reflect, oop value) { | |
1687 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1688 reflect->obj_field_put(clazz_offset, value); | |
1689 } | |
1690 | |
1691 oop java_lang_reflect_Constructor::parameter_types(oop constructor) { | |
1692 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1693 return constructor->obj_field(parameterTypes_offset); | |
1694 } | |
1695 | |
1696 void java_lang_reflect_Constructor::set_parameter_types(oop constructor, oop value) { | |
1697 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1698 constructor->obj_field_put(parameterTypes_offset, value); | |
1699 } | |
1700 | |
1701 oop java_lang_reflect_Constructor::exception_types(oop constructor) { | |
1702 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1703 return constructor->obj_field(exceptionTypes_offset); | |
1704 } | |
1705 | |
1706 void java_lang_reflect_Constructor::set_exception_types(oop constructor, oop value) { | |
1707 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1708 constructor->obj_field_put(exceptionTypes_offset, value); | |
1709 } | |
1710 | |
1711 int java_lang_reflect_Constructor::slot(oop reflect) { | |
1712 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1713 return reflect->int_field(slot_offset); | |
1714 } | |
1715 | |
1716 void java_lang_reflect_Constructor::set_slot(oop reflect, int value) { | |
1717 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1718 reflect->int_field_put(slot_offset, value); | |
1719 } | |
1720 | |
1721 int java_lang_reflect_Constructor::modifiers(oop constructor) { | |
1722 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1723 return constructor->int_field(modifiers_offset); | |
1724 } | |
1725 | |
1726 void java_lang_reflect_Constructor::set_modifiers(oop constructor, int value) { | |
1727 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1728 constructor->int_field_put(modifiers_offset, value); | |
1729 } | |
1730 | |
1731 bool java_lang_reflect_Constructor::has_signature_field() { | |
1732 return (signature_offset >= 0); | |
1733 } | |
1734 | |
1735 oop java_lang_reflect_Constructor::signature(oop constructor) { | |
1736 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1737 assert(has_signature_field(), "signature field must be present"); | |
1738 return constructor->obj_field(signature_offset); | |
1739 } | |
1740 | |
1741 void java_lang_reflect_Constructor::set_signature(oop constructor, oop value) { | |
1742 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1743 assert(has_signature_field(), "signature field must be present"); | |
1744 constructor->obj_field_put(signature_offset, value); | |
1745 } | |
1746 | |
1747 bool java_lang_reflect_Constructor::has_annotations_field() { | |
1748 return (annotations_offset >= 0); | |
1749 } | |
1750 | |
1751 oop java_lang_reflect_Constructor::annotations(oop constructor) { | |
1752 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1753 assert(has_annotations_field(), "annotations field must be present"); | |
1754 return constructor->obj_field(annotations_offset); | |
1755 } | |
1756 | |
1757 void java_lang_reflect_Constructor::set_annotations(oop constructor, oop value) { | |
1758 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1759 assert(has_annotations_field(), "annotations field must be present"); | |
1760 constructor->obj_field_put(annotations_offset, value); | |
1761 } | |
1762 | |
1763 bool java_lang_reflect_Constructor::has_parameter_annotations_field() { | |
1764 return (parameter_annotations_offset >= 0); | |
1765 } | |
1766 | |
1767 oop java_lang_reflect_Constructor::parameter_annotations(oop method) { | |
1768 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1769 assert(has_parameter_annotations_field(), "parameter annotations field must be present"); | |
1770 return method->obj_field(parameter_annotations_offset); | |
1771 } | |
1772 | |
1773 void java_lang_reflect_Constructor::set_parameter_annotations(oop method, oop value) { | |
1774 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1775 assert(has_parameter_annotations_field(), "parameter annotations field must be present"); | |
1776 method->obj_field_put(parameter_annotations_offset, value); | |
1777 } | |
1778 | |
1779 void java_lang_reflect_Field::compute_offsets() { | |
1780 klassOop k = SystemDictionary::reflect_field_klass(); | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1781 compute_offset(clazz_offset, k, vmSymbols::clazz_name(), vmSymbols::class_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1782 compute_offset(name_offset, k, vmSymbols::name_name(), vmSymbols::string_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1783 compute_offset(type_offset, k, vmSymbols::type_name(), vmSymbols::class_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1784 compute_offset(slot_offset, k, vmSymbols::slot_name(), vmSymbols::int_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1785 compute_offset(modifiers_offset, k, vmSymbols::modifiers_name(), vmSymbols::int_signature()); |
0 | 1786 // The generic signature and annotations fields are only present in 1.5 |
1787 signature_offset = -1; | |
1788 annotations_offset = -1; | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1789 compute_optional_offset(signature_offset, k, vmSymbols::signature_name(), vmSymbols::string_signature()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1790 compute_optional_offset(annotations_offset, k, vmSymbols::annotations_name(), vmSymbols::byte_array_signature()); |
0 | 1791 } |
1792 | |
1793 Handle java_lang_reflect_Field::create(TRAPS) { | |
1794 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1795 symbolHandle name = vmSymbolHandles::java_lang_reflect_Field(); | |
1796 klassOop k = SystemDictionary::resolve_or_fail(name, true, CHECK_NH); | |
1797 instanceKlassHandle klass (THREAD, k); | |
1798 // Ensure it is initialized | |
1799 klass->initialize(CHECK_NH); | |
1800 return klass->allocate_instance_handle(CHECK_NH); | |
1801 } | |
1802 | |
1803 oop java_lang_reflect_Field::clazz(oop reflect) { | |
1804 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1805 return reflect->obj_field(clazz_offset); | |
1806 } | |
1807 | |
1808 void java_lang_reflect_Field::set_clazz(oop reflect, oop value) { | |
1809 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1810 reflect->obj_field_put(clazz_offset, value); | |
1811 } | |
1812 | |
1813 oop java_lang_reflect_Field::name(oop field) { | |
1814 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1815 return field->obj_field(name_offset); | |
1816 } | |
1817 | |
1818 void java_lang_reflect_Field::set_name(oop field, oop value) { | |
1819 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1820 field->obj_field_put(name_offset, value); | |
1821 } | |
1822 | |
1823 oop java_lang_reflect_Field::type(oop field) { | |
1824 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1825 return field->obj_field(type_offset); | |
1826 } | |
1827 | |
1828 void java_lang_reflect_Field::set_type(oop field, oop value) { | |
1829 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1830 field->obj_field_put(type_offset, value); | |
1831 } | |
1832 | |
1833 int java_lang_reflect_Field::slot(oop reflect) { | |
1834 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1835 return reflect->int_field(slot_offset); | |
1836 } | |
1837 | |
1838 void java_lang_reflect_Field::set_slot(oop reflect, int value) { | |
1839 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1840 reflect->int_field_put(slot_offset, value); | |
1841 } | |
1842 | |
1843 int java_lang_reflect_Field::modifiers(oop field) { | |
1844 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1845 return field->int_field(modifiers_offset); | |
1846 } | |
1847 | |
1848 void java_lang_reflect_Field::set_modifiers(oop field, int value) { | |
1849 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1850 field->int_field_put(modifiers_offset, value); | |
1851 } | |
1852 | |
1853 bool java_lang_reflect_Field::has_signature_field() { | |
1854 return (signature_offset >= 0); | |
1855 } | |
1856 | |
1857 oop java_lang_reflect_Field::signature(oop field) { | |
1858 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1859 assert(has_signature_field(), "signature field must be present"); | |
1860 return field->obj_field(signature_offset); | |
1861 } | |
1862 | |
1863 void java_lang_reflect_Field::set_signature(oop field, oop value) { | |
1864 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1865 assert(has_signature_field(), "signature field must be present"); | |
1866 field->obj_field_put(signature_offset, value); | |
1867 } | |
1868 | |
1869 bool java_lang_reflect_Field::has_annotations_field() { | |
1870 return (annotations_offset >= 0); | |
1871 } | |
1872 | |
1873 oop java_lang_reflect_Field::annotations(oop field) { | |
1874 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1875 assert(has_annotations_field(), "annotations field must be present"); | |
1876 return field->obj_field(annotations_offset); | |
1877 } | |
1878 | |
1879 void java_lang_reflect_Field::set_annotations(oop field, oop value) { | |
1880 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1881 assert(has_annotations_field(), "annotations field must be present"); | |
1882 field->obj_field_put(annotations_offset, value); | |
1883 } | |
1884 | |
1885 | |
1886 void sun_reflect_ConstantPool::compute_offsets() { | |
1887 klassOop k = SystemDictionary::reflect_constant_pool_klass(); | |
1888 // This null test can be removed post beta | |
1889 if (k != NULL) { | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1890 compute_offset(_cp_oop_offset, k, vmSymbols::constantPoolOop_name(), vmSymbols::object_signature()); |
0 | 1891 } |
1892 } | |
1893 | |
1894 | |
1895 Handle sun_reflect_ConstantPool::create(TRAPS) { | |
1896 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1897 klassOop k = SystemDictionary::reflect_constant_pool_klass(); | |
1898 instanceKlassHandle klass (THREAD, k); | |
1899 // Ensure it is initialized | |
1900 klass->initialize(CHECK_NH); | |
1901 return klass->allocate_instance_handle(CHECK_NH); | |
1902 } | |
1903 | |
1904 | |
1905 oop sun_reflect_ConstantPool::cp_oop(oop reflect) { | |
1906 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1907 return reflect->obj_field(_cp_oop_offset); | |
1908 } | |
1909 | |
1910 | |
1911 void sun_reflect_ConstantPool::set_cp_oop(oop reflect, oop value) { | |
1912 assert(Universe::is_fully_initialized(), "Need to find another solution to the reflection problem"); | |
1913 reflect->obj_field_put(_cp_oop_offset, value); | |
1914 } | |
1915 | |
1916 void sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets() { | |
1917 klassOop k = SystemDictionary::reflect_unsafe_static_field_accessor_impl_klass(); | |
1918 // This null test can be removed post beta | |
1919 if (k != NULL) { | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1920 compute_offset(_base_offset, k, |
0 | 1921 vmSymbols::base_name(), vmSymbols::object_signature()); |
1922 } | |
1923 } | |
1924 | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1925 oop java_lang_boxing_object::initialize_and_allocate(BasicType type, TRAPS) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1926 klassOop k = SystemDictionary::box_klass(type); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1927 if (k == NULL) return NULL; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1928 instanceKlassHandle h (THREAD, k); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1929 if (!h->is_initialized()) h->initialize(CHECK_0); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1930 return h->allocate_instance(THREAD); |
0 | 1931 } |
1932 | |
1933 | |
1934 oop java_lang_boxing_object::create(BasicType type, jvalue* value, TRAPS) { | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1935 oop box = initialize_and_allocate(type, CHECK_0); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1936 if (box == NULL) return NULL; |
0 | 1937 switch (type) { |
1938 case T_BOOLEAN: | |
1939 box->bool_field_put(value_offset, value->z); | |
1940 break; | |
1941 case T_CHAR: | |
1942 box->char_field_put(value_offset, value->c); | |
1943 break; | |
1944 case T_FLOAT: | |
1945 box->float_field_put(value_offset, value->f); | |
1946 break; | |
1947 case T_DOUBLE: | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
1948 box->double_field_put(long_value_offset, value->d); |
0 | 1949 break; |
1950 case T_BYTE: | |
1951 box->byte_field_put(value_offset, value->b); | |
1952 break; | |
1953 case T_SHORT: | |
1954 box->short_field_put(value_offset, value->s); | |
1955 break; | |
1956 case T_INT: | |
1957 box->int_field_put(value_offset, value->i); | |
1958 break; | |
1959 case T_LONG: | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
1960 box->long_field_put(long_value_offset, value->j); |
0 | 1961 break; |
1962 default: | |
1963 return NULL; | |
1964 } | |
1965 return box; | |
1966 } | |
1967 | |
1968 | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1969 BasicType java_lang_boxing_object::basic_type(oop box) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1970 if (box == NULL) return T_ILLEGAL; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1971 BasicType type = SystemDictionary::box_klass_type(box->klass()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1972 if (type == T_OBJECT) // 'unknown' value returned by SD::bkt |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1973 return T_ILLEGAL; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1974 return type; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1975 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1976 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1977 |
0 | 1978 BasicType java_lang_boxing_object::get_value(oop box, jvalue* value) { |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1979 BasicType type = SystemDictionary::box_klass_type(box->klass()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1980 switch (type) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1981 case T_BOOLEAN: |
0 | 1982 value->z = box->bool_field(value_offset); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1983 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1984 case T_CHAR: |
0 | 1985 value->c = box->char_field(value_offset); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1986 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1987 case T_FLOAT: |
0 | 1988 value->f = box->float_field(value_offset); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1989 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1990 case T_DOUBLE: |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
1991 value->d = box->double_field(long_value_offset); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1992 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1993 case T_BYTE: |
0 | 1994 value->b = box->byte_field(value_offset); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1995 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1996 case T_SHORT: |
0 | 1997 value->s = box->short_field(value_offset); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1998 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1999 case T_INT: |
0 | 2000 value->i = box->int_field(value_offset); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2001 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2002 case T_LONG: |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2003 value->j = box->long_field(long_value_offset); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2004 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2005 default: |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2006 return T_ILLEGAL; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2007 } // end switch |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2008 return type; |
0 | 2009 } |
2010 | |
2011 | |
2012 BasicType java_lang_boxing_object::set_value(oop box, jvalue* value) { | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2013 BasicType type = SystemDictionary::box_klass_type(box->klass()); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2014 switch (type) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2015 case T_BOOLEAN: |
0 | 2016 box->bool_field_put(value_offset, value->z); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2017 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2018 case T_CHAR: |
0 | 2019 box->char_field_put(value_offset, value->c); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2020 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2021 case T_FLOAT: |
0 | 2022 box->float_field_put(value_offset, value->f); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2023 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2024 case T_DOUBLE: |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2025 box->double_field_put(long_value_offset, value->d); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2026 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2027 case T_BYTE: |
0 | 2028 box->byte_field_put(value_offset, value->b); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2029 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2030 case T_SHORT: |
0 | 2031 box->short_field_put(value_offset, value->s); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2032 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2033 case T_INT: |
0 | 2034 box->int_field_put(value_offset, value->i); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2035 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2036 case T_LONG: |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2037 box->long_field_put(long_value_offset, value->j); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2038 break; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2039 default: |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2040 return T_ILLEGAL; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2041 } // end switch |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2042 return type; |
0 | 2043 } |
2044 | |
2045 | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2046 void java_lang_boxing_object::print(BasicType type, jvalue* value, outputStream* st) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2047 switch (type) { |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2048 case T_BOOLEAN: st->print("%s", value->z ? "true" : "false"); break; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2049 case T_CHAR: st->print("%d", value->c); break; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2050 case T_BYTE: st->print("%d", value->b); break; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2051 case T_SHORT: st->print("%d", value->s); break; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2052 case T_INT: st->print("%d", value->i); break; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2053 case T_LONG: st->print(INT64_FORMAT, value->j); break; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2054 case T_FLOAT: st->print("%f", value->f); break; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2055 case T_DOUBLE: st->print("%lf", value->d); break; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2056 default: st->print("type %d?", type); break; |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2057 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2058 } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2059 |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
2060 |
0 | 2061 // Support for java_lang_ref_Reference |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2062 oop java_lang_ref_Reference::pending_list_lock() { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2063 instanceKlass* ik = instanceKlass::cast(SystemDictionary::reference_klass()); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2064 char *addr = (((char *)ik->start_of_static_fields()) + static_lock_offset); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2065 if (UseCompressedOops) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2066 return oopDesc::load_decode_heap_oop((narrowOop *)addr); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2067 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2068 return oopDesc::load_decode_heap_oop((oop*)addr); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2069 } |
0 | 2070 } |
2071 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2072 HeapWord *java_lang_ref_Reference::pending_list_addr() { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2073 instanceKlass* ik = instanceKlass::cast(SystemDictionary::reference_klass()); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2074 char *addr = (((char *)ik->start_of_static_fields()) + static_pending_offset); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2075 // XXX This might not be HeapWord aligned, almost rather be char *. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2076 return (HeapWord*)addr; |
0 | 2077 } |
2078 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2079 oop java_lang_ref_Reference::pending_list() { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2080 char *addr = (char *)pending_list_addr(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2081 if (UseCompressedOops) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2082 return oopDesc::load_decode_heap_oop((narrowOop *)addr); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2083 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2084 return oopDesc::load_decode_heap_oop((oop*)addr); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2085 } |
0 | 2086 } |
2087 | |
2088 | |
2089 // Support for java_lang_ref_SoftReference | |
2090 | |
2091 jlong java_lang_ref_SoftReference::timestamp(oop ref) { | |
2092 return ref->long_field(timestamp_offset); | |
2093 } | |
2094 | |
2095 jlong java_lang_ref_SoftReference::clock() { | |
2096 instanceKlass* ik = instanceKlass::cast(SystemDictionary::soft_reference_klass()); | |
2097 int offset = ik->offset_of_static_fields() + static_clock_offset; | |
2098 | |
2099 return SystemDictionary::soft_reference_klass()->long_field(offset); | |
2100 } | |
2101 | |
2102 void java_lang_ref_SoftReference::set_clock(jlong value) { | |
2103 instanceKlass* ik = instanceKlass::cast(SystemDictionary::soft_reference_klass()); | |
2104 int offset = ik->offset_of_static_fields() + static_clock_offset; | |
2105 | |
2106 SystemDictionary::soft_reference_klass()->long_field_put(offset, value); | |
2107 } | |
2108 | |
2109 | |
2110 // Support for java_security_AccessControlContext | |
2111 | |
2112 int java_security_AccessControlContext::_context_offset = 0; | |
2113 int java_security_AccessControlContext::_privilegedContext_offset = 0; | |
2114 int java_security_AccessControlContext::_isPrivileged_offset = 0; | |
2115 | |
2116 | |
2117 void java_security_AccessControlContext::compute_offsets() { | |
2118 assert(_isPrivileged_offset == 0, "offsets should be initialized only once"); | |
2119 fieldDescriptor fd; | |
2120 instanceKlass* ik = instanceKlass::cast(SystemDictionary::AccessControlContext_klass()); | |
2121 | |
2122 if (!ik->find_local_field(vmSymbols::context_name(), vmSymbols::protectiondomain_signature(), &fd)) { | |
2123 fatal("Invalid layout of java.security.AccessControlContext"); | |
2124 } | |
2125 _context_offset = fd.offset(); | |
2126 | |
2127 if (!ik->find_local_field(vmSymbols::privilegedContext_name(), vmSymbols::accesscontrolcontext_signature(), &fd)) { | |
2128 fatal("Invalid layout of java.security.AccessControlContext"); | |
2129 } | |
2130 _privilegedContext_offset = fd.offset(); | |
2131 | |
2132 if (!ik->find_local_field(vmSymbols::isPrivileged_name(), vmSymbols::bool_signature(), &fd)) { | |
2133 fatal("Invalid layout of java.security.AccessControlContext"); | |
2134 } | |
2135 _isPrivileged_offset = fd.offset(); | |
2136 } | |
2137 | |
2138 | |
2139 oop java_security_AccessControlContext::create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS) { | |
2140 assert(_isPrivileged_offset != 0, "offsets should have been initialized"); | |
2141 // Ensure klass is initialized | |
2142 instanceKlass::cast(SystemDictionary::AccessControlContext_klass())->initialize(CHECK_0); | |
2143 // Allocate result | |
2144 oop result = instanceKlass::cast(SystemDictionary::AccessControlContext_klass())->allocate_instance(CHECK_0); | |
2145 // Fill in values | |
2146 result->obj_field_put(_context_offset, context()); | |
2147 result->obj_field_put(_privilegedContext_offset, privileged_context()); | |
2148 result->bool_field_put(_isPrivileged_offset, isPrivileged); | |
2149 return result; | |
2150 } | |
2151 | |
2152 | |
2153 // Support for java_lang_ClassLoader | |
2154 | |
2155 oop java_lang_ClassLoader::parent(oop loader) { | |
2156 assert(loader->is_oop(), "loader must be oop"); | |
2157 return loader->obj_field(parent_offset); | |
2158 } | |
2159 | |
2160 | |
2161 bool java_lang_ClassLoader::is_trusted_loader(oop loader) { | |
2162 // Fix for 4474172; see evaluation for more details | |
2163 loader = non_reflection_class_loader(loader); | |
2164 | |
2165 oop cl = SystemDictionary::java_system_loader(); | |
2166 while(cl != NULL) { | |
2167 if (cl == loader) return true; | |
2168 cl = parent(cl); | |
2169 } | |
2170 return false; | |
2171 } | |
2172 | |
2173 oop java_lang_ClassLoader::non_reflection_class_loader(oop loader) { | |
2174 if (loader != NULL) { | |
2175 // See whether this is one of the class loaders associated with | |
2176 // the generated bytecodes for reflection, and if so, "magically" | |
2177 // delegate to its parent to prevent class loading from occurring | |
2178 // in places where applications using reflection didn't expect it. | |
2179 klassOop delegating_cl_class = SystemDictionary::reflect_delegating_classloader_klass(); | |
2180 // This might be null in non-1.4 JDKs | |
2181 if (delegating_cl_class != NULL && loader->is_a(delegating_cl_class)) { | |
2182 return parent(loader); | |
2183 } | |
2184 } | |
2185 return loader; | |
2186 } | |
2187 | |
2188 | |
2189 // Support for java_lang_System | |
2190 | |
2191 void java_lang_System::compute_offsets() { | |
2192 assert(offset_of_static_fields == 0, "offsets should be initialized only once"); | |
2193 | |
2194 instanceKlass* ik = instanceKlass::cast(SystemDictionary::system_klass()); | |
2195 offset_of_static_fields = ik->offset_of_static_fields(); | |
2196 } | |
2197 | |
2198 int java_lang_System::in_offset_in_bytes() { | |
2199 return (offset_of_static_fields + static_in_offset); | |
2200 } | |
2201 | |
2202 | |
2203 int java_lang_System::out_offset_in_bytes() { | |
2204 return (offset_of_static_fields + static_out_offset); | |
2205 } | |
2206 | |
2207 | |
2208 int java_lang_System::err_offset_in_bytes() { | |
2209 return (offset_of_static_fields + static_err_offset); | |
2210 } | |
2211 | |
2212 | |
2213 | |
2214 int java_lang_String::value_offset; | |
2215 int java_lang_String::offset_offset; | |
2216 int java_lang_String::count_offset; | |
2217 int java_lang_String::hash_offset; | |
2218 int java_lang_Class::klass_offset; | |
2219 int java_lang_Class::array_klass_offset; | |
2220 int java_lang_Class::resolved_constructor_offset; | |
2221 int java_lang_Class::number_of_fake_oop_fields; | |
2222 int java_lang_Throwable::backtrace_offset; | |
2223 int java_lang_Throwable::detailMessage_offset; | |
2224 int java_lang_Throwable::cause_offset; | |
2225 int java_lang_Throwable::stackTrace_offset; | |
2226 int java_lang_reflect_AccessibleObject::override_offset; | |
2227 int java_lang_reflect_Method::clazz_offset; | |
2228 int java_lang_reflect_Method::name_offset; | |
2229 int java_lang_reflect_Method::returnType_offset; | |
2230 int java_lang_reflect_Method::parameterTypes_offset; | |
2231 int java_lang_reflect_Method::exceptionTypes_offset; | |
2232 int java_lang_reflect_Method::slot_offset; | |
2233 int java_lang_reflect_Method::modifiers_offset; | |
2234 int java_lang_reflect_Method::signature_offset; | |
2235 int java_lang_reflect_Method::annotations_offset; | |
2236 int java_lang_reflect_Method::parameter_annotations_offset; | |
2237 int java_lang_reflect_Method::annotation_default_offset; | |
2238 int java_lang_reflect_Constructor::clazz_offset; | |
2239 int java_lang_reflect_Constructor::parameterTypes_offset; | |
2240 int java_lang_reflect_Constructor::exceptionTypes_offset; | |
2241 int java_lang_reflect_Constructor::slot_offset; | |
2242 int java_lang_reflect_Constructor::modifiers_offset; | |
2243 int java_lang_reflect_Constructor::signature_offset; | |
2244 int java_lang_reflect_Constructor::annotations_offset; | |
2245 int java_lang_reflect_Constructor::parameter_annotations_offset; | |
2246 int java_lang_reflect_Field::clazz_offset; | |
2247 int java_lang_reflect_Field::name_offset; | |
2248 int java_lang_reflect_Field::type_offset; | |
2249 int java_lang_reflect_Field::slot_offset; | |
2250 int java_lang_reflect_Field::modifiers_offset; | |
2251 int java_lang_reflect_Field::signature_offset; | |
2252 int java_lang_reflect_Field::annotations_offset; | |
2253 int java_lang_boxing_object::value_offset; | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2254 int java_lang_boxing_object::long_value_offset; |
0 | 2255 int java_lang_ref_Reference::referent_offset; |
2256 int java_lang_ref_Reference::queue_offset; | |
2257 int java_lang_ref_Reference::next_offset; | |
2258 int java_lang_ref_Reference::discovered_offset; | |
2259 int java_lang_ref_Reference::static_lock_offset; | |
2260 int java_lang_ref_Reference::static_pending_offset; | |
2261 int java_lang_ref_Reference::number_of_fake_oop_fields; | |
2262 int java_lang_ref_SoftReference::timestamp_offset; | |
2263 int java_lang_ref_SoftReference::static_clock_offset; | |
2264 int java_lang_ClassLoader::parent_offset; | |
2265 int java_lang_System::offset_of_static_fields; | |
2266 int java_lang_System::static_in_offset; | |
2267 int java_lang_System::static_out_offset; | |
2268 int java_lang_System::static_err_offset; | |
2269 int java_lang_StackTraceElement::declaringClass_offset; | |
2270 int java_lang_StackTraceElement::methodName_offset; | |
2271 int java_lang_StackTraceElement::fileName_offset; | |
2272 int java_lang_StackTraceElement::lineNumber_offset; | |
2273 int java_lang_AssertionStatusDirectives::classes_offset; | |
2274 int java_lang_AssertionStatusDirectives::classEnabled_offset; | |
2275 int java_lang_AssertionStatusDirectives::packages_offset; | |
2276 int java_lang_AssertionStatusDirectives::packageEnabled_offset; | |
2277 int java_lang_AssertionStatusDirectives::deflt_offset; | |
2278 int java_nio_Buffer::_limit_offset; | |
2279 int sun_misc_AtomicLongCSImpl::_value_offset; | |
2280 int java_util_concurrent_locks_AbstractOwnableSynchronizer::_owner_offset = 0; | |
2281 int sun_reflect_ConstantPool::_cp_oop_offset; | |
2282 int sun_reflect_UnsafeStaticFieldAccessorImpl::_base_offset; | |
2283 | |
2284 | |
2285 // Support for java_lang_StackTraceElement | |
2286 | |
2287 void java_lang_StackTraceElement::set_fileName(oop element, oop value) { | |
2288 element->obj_field_put(fileName_offset, value); | |
2289 } | |
2290 | |
2291 void java_lang_StackTraceElement::set_declaringClass(oop element, oop value) { | |
2292 element->obj_field_put(declaringClass_offset, value); | |
2293 } | |
2294 | |
2295 void java_lang_StackTraceElement::set_methodName(oop element, oop value) { | |
2296 element->obj_field_put(methodName_offset, value); | |
2297 } | |
2298 | |
2299 void java_lang_StackTraceElement::set_lineNumber(oop element, int value) { | |
2300 element->int_field_put(lineNumber_offset, value); | |
2301 } | |
2302 | |
2303 | |
2304 // Support for java Assertions - java_lang_AssertionStatusDirectives. | |
2305 | |
2306 void java_lang_AssertionStatusDirectives::set_classes(oop o, oop val) { | |
2307 o->obj_field_put(classes_offset, val); | |
2308 } | |
2309 | |
2310 void java_lang_AssertionStatusDirectives::set_classEnabled(oop o, oop val) { | |
2311 o->obj_field_put(classEnabled_offset, val); | |
2312 } | |
2313 | |
2314 void java_lang_AssertionStatusDirectives::set_packages(oop o, oop val) { | |
2315 o->obj_field_put(packages_offset, val); | |
2316 } | |
2317 | |
2318 void java_lang_AssertionStatusDirectives::set_packageEnabled(oop o, oop val) { | |
2319 o->obj_field_put(packageEnabled_offset, val); | |
2320 } | |
2321 | |
2322 void java_lang_AssertionStatusDirectives::set_deflt(oop o, bool val) { | |
2323 o->bool_field_put(deflt_offset, val); | |
2324 } | |
2325 | |
2326 | |
2327 // Support for intrinsification of java.nio.Buffer.checkIndex | |
2328 int java_nio_Buffer::limit_offset() { | |
2329 return _limit_offset; | |
2330 } | |
2331 | |
2332 | |
2333 void java_nio_Buffer::compute_offsets() { | |
2334 klassOop k = SystemDictionary::java_nio_Buffer_klass(); | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2335 assert(k != NULL, "must be loaded in 1.4+"); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2336 compute_offset(_limit_offset, k, vmSymbols::limit_name(), vmSymbols::int_signature()); |
0 | 2337 } |
2338 | |
2339 // Support for intrinsification of sun.misc.AtomicLongCSImpl.attemptUpdate | |
2340 int sun_misc_AtomicLongCSImpl::value_offset() { | |
2341 assert(SystemDictionary::sun_misc_AtomicLongCSImpl_klass() != NULL, "can't call this"); | |
2342 return _value_offset; | |
2343 } | |
2344 | |
2345 | |
2346 void sun_misc_AtomicLongCSImpl::compute_offsets() { | |
2347 klassOop k = SystemDictionary::sun_misc_AtomicLongCSImpl_klass(); | |
2348 // If this class is not present, its value field offset won't be referenced. | |
2349 if (k != NULL) { | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2350 compute_offset(_value_offset, k, vmSymbols::value_name(), vmSymbols::long_signature()); |
0 | 2351 } |
2352 } | |
2353 | |
2354 void java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(TRAPS) { | |
2355 if (_owner_offset != 0) return; | |
2356 | |
2357 assert(JDK_Version::is_gte_jdk16x_version(), "Must be JDK 1.6 or later"); | |
2358 SystemDictionary::load_abstract_ownable_synchronizer_klass(CHECK); | |
2359 klassOop k = SystemDictionary::abstract_ownable_synchronizer_klass(); | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2360 compute_offset(_owner_offset, k, |
0 | 2361 vmSymbols::exclusive_owner_thread_name(), vmSymbols::thread_signature()); |
2362 } | |
2363 | |
2364 oop java_util_concurrent_locks_AbstractOwnableSynchronizer::get_owner_threadObj(oop obj) { | |
2365 assert(_owner_offset != 0, "Must be initialized"); | |
2366 return obj->obj_field(_owner_offset); | |
2367 } | |
2368 | |
2369 // Compute hard-coded offsets | |
2370 // Invoked before SystemDictionary::initialize, so pre-loaded classes | |
2371 // are not available to determine the offset_of_static_fields. | |
2372 void JavaClasses::compute_hard_coded_offsets() { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
98
diff
changeset
|
2373 const int x = heapOopSize; |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2374 const int header = instanceOopDesc::base_offset_in_bytes(); |
0 | 2375 |
2376 // Do the String Class | |
2377 java_lang_String::value_offset = java_lang_String::hc_value_offset * x + header; | |
2378 java_lang_String::offset_offset = java_lang_String::hc_offset_offset * x + header; | |
2379 java_lang_String::count_offset = java_lang_String::offset_offset + sizeof (jint); | |
2380 java_lang_String::hash_offset = java_lang_String::count_offset + sizeof (jint); | |
2381 | |
2382 // Do the Class Class | |
2383 java_lang_Class::klass_offset = java_lang_Class::hc_klass_offset * x + header; | |
2384 java_lang_Class::array_klass_offset = java_lang_Class::hc_array_klass_offset * x + header; | |
2385 java_lang_Class::resolved_constructor_offset = java_lang_Class::hc_resolved_constructor_offset * x + header; | |
2386 | |
2387 // This is NOT an offset | |
2388 java_lang_Class::number_of_fake_oop_fields = java_lang_Class::hc_number_of_fake_oop_fields; | |
2389 | |
2390 // Throwable Class | |
2391 java_lang_Throwable::backtrace_offset = java_lang_Throwable::hc_backtrace_offset * x + header; | |
2392 java_lang_Throwable::detailMessage_offset = java_lang_Throwable::hc_detailMessage_offset * x + header; | |
2393 java_lang_Throwable::cause_offset = java_lang_Throwable::hc_cause_offset * x + header; | |
2394 java_lang_Throwable::stackTrace_offset = java_lang_Throwable::hc_stackTrace_offset * x + header; | |
2395 | |
2396 // java_lang_boxing_object | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2397 java_lang_boxing_object::value_offset = java_lang_boxing_object::hc_value_offset + header; |
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2398 java_lang_boxing_object::long_value_offset = align_size_up((java_lang_boxing_object::hc_value_offset + header), BytesPerLong); |
0 | 2399 |
2400 // java_lang_ref_Reference: | |
2401 java_lang_ref_Reference::referent_offset = java_lang_ref_Reference::hc_referent_offset * x + header; | |
2402 java_lang_ref_Reference::queue_offset = java_lang_ref_Reference::hc_queue_offset * x + header; | |
2403 java_lang_ref_Reference::next_offset = java_lang_ref_Reference::hc_next_offset * x + header; | |
2404 java_lang_ref_Reference::discovered_offset = java_lang_ref_Reference::hc_discovered_offset * x + header; | |
2405 java_lang_ref_Reference::static_lock_offset = java_lang_ref_Reference::hc_static_lock_offset * x; | |
2406 java_lang_ref_Reference::static_pending_offset = java_lang_ref_Reference::hc_static_pending_offset * x; | |
2407 // Artificial fields for java_lang_ref_Reference | |
2408 // The first field is for the discovered field added in 1.4 | |
2409 java_lang_ref_Reference::number_of_fake_oop_fields = 1; | |
2410 | |
2411 // java_lang_ref_SoftReference Class | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2412 java_lang_ref_SoftReference::timestamp_offset = align_size_up((java_lang_ref_SoftReference::hc_timestamp_offset * x + header), BytesPerLong); |
0 | 2413 // Don't multiply static fields because they are always in wordSize units |
2414 java_lang_ref_SoftReference::static_clock_offset = java_lang_ref_SoftReference::hc_static_clock_offset * x; | |
2415 | |
2416 // java_lang_ClassLoader | |
2417 java_lang_ClassLoader::parent_offset = java_lang_ClassLoader::hc_parent_offset * x + header; | |
2418 | |
2419 // java_lang_System | |
2420 java_lang_System::static_in_offset = java_lang_System::hc_static_in_offset * x; | |
2421 java_lang_System::static_out_offset = java_lang_System::hc_static_out_offset * x; | |
2422 java_lang_System::static_err_offset = java_lang_System::hc_static_err_offset * x; | |
2423 | |
2424 // java_lang_StackTraceElement | |
2425 java_lang_StackTraceElement::declaringClass_offset = java_lang_StackTraceElement::hc_declaringClass_offset * x + header; | |
2426 java_lang_StackTraceElement::methodName_offset = java_lang_StackTraceElement::hc_methodName_offset * x + header; | |
2427 java_lang_StackTraceElement::fileName_offset = java_lang_StackTraceElement::hc_fileName_offset * x + header; | |
2428 java_lang_StackTraceElement::lineNumber_offset = java_lang_StackTraceElement::hc_lineNumber_offset * x + header; | |
2429 java_lang_AssertionStatusDirectives::classes_offset = java_lang_AssertionStatusDirectives::hc_classes_offset * x + header; | |
2430 java_lang_AssertionStatusDirectives::classEnabled_offset = java_lang_AssertionStatusDirectives::hc_classEnabled_offset * x + header; | |
2431 java_lang_AssertionStatusDirectives::packages_offset = java_lang_AssertionStatusDirectives::hc_packages_offset * x + header; | |
2432 java_lang_AssertionStatusDirectives::packageEnabled_offset = java_lang_AssertionStatusDirectives::hc_packageEnabled_offset * x + header; | |
2433 java_lang_AssertionStatusDirectives::deflt_offset = java_lang_AssertionStatusDirectives::hc_deflt_offset * x + header; | |
2434 | |
2435 } | |
2436 | |
2437 | |
2438 // Compute non-hard-coded field offsets of all the classes in this file | |
2439 void JavaClasses::compute_offsets() { | |
2440 | |
2441 java_lang_Class::compute_offsets(); | |
2442 java_lang_System::compute_offsets(); | |
2443 java_lang_Thread::compute_offsets(); | |
2444 java_lang_ThreadGroup::compute_offsets(); | |
2445 java_security_AccessControlContext::compute_offsets(); | |
2446 // Initialize reflection classes. The layouts of these classes | |
2447 // changed with the new reflection implementation in JDK 1.4, and | |
2448 // since the Universe doesn't know what JDK version it is until this | |
2449 // point we defer computation of these offsets until now. | |
2450 java_lang_reflect_AccessibleObject::compute_offsets(); | |
2451 java_lang_reflect_Method::compute_offsets(); | |
2452 java_lang_reflect_Constructor::compute_offsets(); | |
2453 java_lang_reflect_Field::compute_offsets(); | |
2454 if (JDK_Version::is_gte_jdk14x_version()) { | |
2455 java_nio_Buffer::compute_offsets(); | |
2456 } | |
2457 if (JDK_Version::is_gte_jdk15x_version()) { | |
2458 sun_reflect_ConstantPool::compute_offsets(); | |
2459 sun_reflect_UnsafeStaticFieldAccessorImpl::compute_offsets(); | |
2460 } | |
2461 sun_misc_AtomicLongCSImpl::compute_offsets(); | |
2462 } | |
2463 | |
2464 #ifndef PRODUCT | |
2465 | |
2466 // These functions exist to assert the validity of hard-coded field offsets to guard | |
2467 // against changes in the class files | |
2468 | |
2469 bool JavaClasses::check_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) { | |
2470 EXCEPTION_MARK; | |
2471 fieldDescriptor fd; | |
2472 symbolHandle klass_sym = oopFactory::new_symbol_handle(klass_name, CATCH); | |
2473 klassOop k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH); | |
2474 instanceKlassHandle h_klass (THREAD, k); | |
2475 //instanceKlassHandle h_klass(klass); | |
2476 symbolHandle f_name = oopFactory::new_symbol_handle(field_name, CATCH); | |
2477 symbolHandle f_sig = oopFactory::new_symbol_handle(field_sig, CATCH); | |
2478 if (!h_klass->find_local_field(f_name(), f_sig(), &fd)) { | |
2479 tty->print_cr("Nonstatic field %s.%s not found", klass_name, field_name); | |
2480 return false; | |
2481 } | |
2482 if (fd.is_static()) { | |
2483 tty->print_cr("Nonstatic field %s.%s appears to be static", klass_name, field_name); | |
2484 return false; | |
2485 } | |
2486 if (fd.offset() == hardcoded_offset ) { | |
2487 return true; | |
2488 } else { | |
2489 tty->print_cr("Offset of nonstatic field %s.%s is hardcoded as %d but should really be %d.", | |
2490 klass_name, field_name, hardcoded_offset, fd.offset()); | |
2491 return false; | |
2492 } | |
2493 } | |
2494 | |
2495 | |
2496 bool JavaClasses::check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) { | |
2497 EXCEPTION_MARK; | |
2498 fieldDescriptor fd; | |
2499 symbolHandle klass_sym = oopFactory::new_symbol_handle(klass_name, CATCH); | |
2500 klassOop k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH); | |
2501 instanceKlassHandle h_klass (THREAD, k); | |
2502 symbolHandle f_name = oopFactory::new_symbol_handle(field_name, CATCH); | |
2503 symbolHandle f_sig = oopFactory::new_symbol_handle(field_sig, CATCH); | |
2504 if (!h_klass->find_local_field(f_name(), f_sig(), &fd)) { | |
2505 tty->print_cr("Static field %s.%s not found", klass_name, field_name); | |
2506 return false; | |
2507 } | |
2508 if (!fd.is_static()) { | |
2509 tty->print_cr("Static field %s.%s appears to be nonstatic", klass_name, field_name); | |
2510 return false; | |
2511 } | |
2512 if (fd.offset() == hardcoded_offset + h_klass->offset_of_static_fields()) { | |
2513 return true; | |
2514 } else { | |
2515 tty->print_cr("Offset of static field %s.%s is hardcoded as %d but should really be %d.", klass_name, field_name, hardcoded_offset, fd.offset() - h_klass->offset_of_static_fields()); | |
2516 return false; | |
2517 } | |
2518 } | |
2519 | |
2520 | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2521 bool JavaClasses::check_constant(const char *klass_name, int hardcoded_constant, const char *field_name, const char* field_sig) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2522 EXCEPTION_MARK; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2523 fieldDescriptor fd; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2524 symbolHandle klass_sym = oopFactory::new_symbol_handle(klass_name, CATCH); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2525 klassOop k = SystemDictionary::resolve_or_fail(klass_sym, true, CATCH); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2526 instanceKlassHandle h_klass (THREAD, k); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2527 symbolHandle f_name = oopFactory::new_symbol_handle(field_name, CATCH); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2528 symbolHandle f_sig = oopFactory::new_symbol_handle(field_sig, CATCH); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2529 if (!h_klass->find_local_field(f_name(), f_sig(), &fd)) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2530 tty->print_cr("Static field %s.%s not found", klass_name, field_name); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2531 return false; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2532 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2533 if (!fd.is_static() || !fd.has_initial_value()) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2534 tty->print_cr("Static field %s.%s appears to be non-constant", klass_name, field_name); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2535 return false; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2536 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2537 if (!fd.initial_value_tag().is_int()) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2538 tty->print_cr("Static field %s.%s is not an int", klass_name, field_name); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2539 return false; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2540 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2541 jint field_value = fd.int_initial_value(); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2542 if (field_value == hardcoded_constant) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2543 return true; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2544 } else { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2545 tty->print_cr("Constant value of static field %s.%s is hardcoded as %d but should really be %d.", klass_name, field_name, hardcoded_constant, field_value); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2546 return false; |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2547 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2548 } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2549 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2550 |
0 | 2551 // Check the hard-coded field offsets of all the classes in this file |
2552 | |
2553 void JavaClasses::check_offsets() { | |
2554 bool valid = true; | |
2555 | |
2556 #define CHECK_OFFSET(klass_name, cpp_klass_name, field_name, field_sig) \ | |
2557 valid &= check_offset(klass_name, cpp_klass_name :: field_name ## _offset, #field_name, field_sig) | |
2558 | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2559 #define CHECK_LONG_OFFSET(klass_name, cpp_klass_name, field_name, field_sig) \ |
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2560 valid &= check_offset(klass_name, cpp_klass_name :: long_ ## field_name ## _offset, #field_name, field_sig) |
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2561 |
0 | 2562 #define CHECK_STATIC_OFFSET(klass_name, cpp_klass_name, field_name, field_sig) \ |
2563 valid &= check_static_offset(klass_name, cpp_klass_name :: static_ ## field_name ## _offset, #field_name, field_sig) | |
2564 | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2565 #define CHECK_CONSTANT(klass_name, cpp_klass_name, field_name, field_sig) \ |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2566 valid &= check_constant(klass_name, cpp_klass_name :: field_name, #field_name, field_sig) |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
2567 |
0 | 2568 // java.lang.String |
2569 | |
2570 CHECK_OFFSET("java/lang/String", java_lang_String, value, "[C"); | |
2571 CHECK_OFFSET("java/lang/String", java_lang_String, offset, "I"); | |
2572 CHECK_OFFSET("java/lang/String", java_lang_String, count, "I"); | |
2573 CHECK_OFFSET("java/lang/String", java_lang_String, hash, "I"); | |
2574 | |
2575 // java.lang.Class | |
2576 | |
2577 // Fake fields | |
2578 // CHECK_OFFSET("java/lang/Class", java_lang_Class, klass); // %%% this needs to be checked | |
2579 // CHECK_OFFSET("java/lang/Class", java_lang_Class, array_klass); // %%% this needs to be checked | |
2580 // CHECK_OFFSET("java/lang/Class", java_lang_Class, resolved_constructor); // %%% this needs to be checked | |
2581 | |
2582 // java.lang.Throwable | |
2583 | |
2584 CHECK_OFFSET("java/lang/Throwable", java_lang_Throwable, backtrace, "Ljava/lang/Object;"); | |
2585 CHECK_OFFSET("java/lang/Throwable", java_lang_Throwable, detailMessage, "Ljava/lang/String;"); | |
2586 CHECK_OFFSET("java/lang/Throwable", java_lang_Throwable, cause, "Ljava/lang/Throwable;"); | |
2587 CHECK_OFFSET("java/lang/Throwable", java_lang_Throwable, stackTrace, "[Ljava/lang/StackTraceElement;"); | |
2588 | |
2589 // Boxed primitive objects (java_lang_boxing_object) | |
2590 | |
2591 CHECK_OFFSET("java/lang/Boolean", java_lang_boxing_object, value, "Z"); | |
2592 CHECK_OFFSET("java/lang/Character", java_lang_boxing_object, value, "C"); | |
2593 CHECK_OFFSET("java/lang/Float", java_lang_boxing_object, value, "F"); | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2594 CHECK_LONG_OFFSET("java/lang/Double", java_lang_boxing_object, value, "D"); |
0 | 2595 CHECK_OFFSET("java/lang/Byte", java_lang_boxing_object, value, "B"); |
2596 CHECK_OFFSET("java/lang/Short", java_lang_boxing_object, value, "S"); | |
2597 CHECK_OFFSET("java/lang/Integer", java_lang_boxing_object, value, "I"); | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
2598 CHECK_LONG_OFFSET("java/lang/Long", java_lang_boxing_object, value, "J"); |
0 | 2599 |
2600 // java.lang.ClassLoader | |
2601 | |
2602 CHECK_OFFSET("java/lang/ClassLoader", java_lang_ClassLoader, parent, "Ljava/lang/ClassLoader;"); | |
2603 | |
2604 // java.lang.System | |
2605 | |
2606 CHECK_STATIC_OFFSET("java/lang/System", java_lang_System, in, "Ljava/io/InputStream;"); | |
2607 CHECK_STATIC_OFFSET("java/lang/System", java_lang_System, out, "Ljava/io/PrintStream;"); | |
2608 CHECK_STATIC_OFFSET("java/lang/System", java_lang_System, err, "Ljava/io/PrintStream;"); | |
2609 | |
2610 // java.lang.StackTraceElement | |
2611 | |
2612 CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, declaringClass, "Ljava/lang/String;"); | |
2613 CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, methodName, "Ljava/lang/String;"); | |
2614 CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, fileName, "Ljava/lang/String;"); | |
2615 CHECK_OFFSET("java/lang/StackTraceElement", java_lang_StackTraceElement, lineNumber, "I"); | |
2616 | |
2617 // java.lang.ref.Reference | |
2618 | |
2619 CHECK_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, referent, "Ljava/lang/Object;"); | |
2620 CHECK_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, queue, "Ljava/lang/ref/ReferenceQueue;"); | |
2621 CHECK_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, next, "Ljava/lang/ref/Reference;"); | |
2622 // Fake field | |
2623 //CHECK_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, discovered, "Ljava/lang/ref/Reference;"); | |
2624 CHECK_STATIC_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, lock, "Ljava/lang/ref/Reference$Lock;"); | |
2625 CHECK_STATIC_OFFSET("java/lang/ref/Reference", java_lang_ref_Reference, pending, "Ljava/lang/ref/Reference;"); | |
2626 | |
2627 // java.lang.ref.SoftReference | |
2628 | |
2629 CHECK_OFFSET("java/lang/ref/SoftReference", java_lang_ref_SoftReference, timestamp, "J"); | |
2630 CHECK_STATIC_OFFSET("java/lang/ref/SoftReference", java_lang_ref_SoftReference, clock, "J"); | |
2631 | |
2632 // java.lang.AssertionStatusDirectives | |
2633 // | |
2634 // The CheckAssertionStatusDirectives boolean can be removed from here and | |
2635 // globals.hpp after the AssertionStatusDirectives class has been integrated | |
2636 // into merlin "for some time." Without it, the vm will fail with early | |
2637 // merlin builds. | |
2638 | |
2639 if (CheckAssertionStatusDirectives && JDK_Version::is_gte_jdk14x_version()) { | |
2640 const char* nm = "java/lang/AssertionStatusDirectives"; | |
2641 const char* sig = "[Ljava/lang/String;"; | |
2642 CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, classes, sig); | |
2643 CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, classEnabled, "[Z"); | |
2644 CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, packages, sig); | |
2645 CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, packageEnabled, "[Z"); | |
2646 CHECK_OFFSET(nm, java_lang_AssertionStatusDirectives, deflt, "Z"); | |
2647 } | |
2648 | |
2649 if (!valid) vm_exit_during_initialization("Hard-coded field offset verification failed"); | |
2650 } | |
2651 | |
2652 #endif // PRODUCT | |
2653 | |
2654 void javaClasses_init() { | |
2655 JavaClasses::compute_offsets(); | |
2656 JavaClasses::check_offsets(); | |
2657 FilteredFieldsMap::initialize(); // must be done after computing offsets. | |
2658 } |