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