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