Mercurial > hg > truffle
annotate src/share/vm/classfile/javaClasses.hpp @ 6275:957c266d8bc5
Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 21 Aug 2012 10:39:19 +0200 |
parents | 120820e30baa 1d7922586cf6 |
children | e522a00b91aa |
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 #ifndef SHARE_VM_CLASSFILE_JAVACLASSES_HPP |
26 #define SHARE_VM_CLASSFILE_JAVACLASSES_HPP | |
27 | |
28 #include "classfile/systemDictionary.hpp" | |
29 #include "jvmtifiles/jvmti.h" | |
30 #include "oops/oop.hpp" | |
31 #include "runtime/os.hpp" | |
32 #include "utilities/utf8.hpp" | |
33 | |
0 | 34 // Interface for manipulating the basic Java classes. |
35 // | |
36 // All dependencies on layout of actual Java classes should be kept here. | |
37 // If the layout of any of the classes above changes the offsets must be adjusted. | |
38 // | |
39 // For most classes we hardwire the offsets for performance reasons. In certain | |
40 // cases (e.g. java.security.AccessControlContext) we compute the offsets at | |
41 // startup since the layout here differs between JDK1.2 and JDK1.3. | |
42 // | |
43 // Note that fields (static and non-static) are arranged with oops before non-oops | |
44 // on a per class basis. The offsets below have to reflect this ordering. | |
45 // | |
46 // When editing the layouts please update the check_offset verification code | |
47 // correspondingly. The names in the enums must be identical to the actual field | |
48 // names in order for the verification code to work. | |
49 | |
50 | |
51 // Interface to java.lang.String objects | |
52 | |
53 class java_lang_String : AllStatic { | |
54 private: | |
55 static int value_offset; | |
56 static int offset_offset; | |
57 static int count_offset; | |
58 static int hash_offset; | |
59 | |
6057 | 60 static bool initialized; |
61 | |
0 | 62 static Handle basic_create(int length, bool tenured, TRAPS); |
63 static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS); | |
64 | |
6057 | 65 static void set_value( oop string, typeArrayOop buffer) { |
66 assert(initialized, "Must be initialized"); | |
67 string->obj_field_put(value_offset, (oop)buffer); | |
68 } | |
69 static void set_offset(oop string, int offset) { | |
70 assert(initialized, "Must be initialized"); | |
71 if (offset_offset > 0) { | |
72 string->int_field_put(offset_offset, offset); | |
73 } | |
74 } | |
75 static void set_count( oop string, int count) { | |
76 assert(initialized, "Must be initialized"); | |
77 if (count_offset > 0) { | |
78 string->int_field_put(count_offset, count); | |
79 } | |
80 } | |
0 | 81 |
82 public: | |
6057 | 83 static void compute_offsets(); |
84 | |
0 | 85 // Instance creation |
86 static Handle create_from_unicode(jchar* unicode, int len, TRAPS); | |
87 static Handle create_tenured_from_unicode(jchar* unicode, int len, TRAPS); | |
88 static oop create_oop_from_unicode(jchar* unicode, int len, TRAPS); | |
89 static Handle create_from_str(const char* utf8_str, TRAPS); | |
90 static oop create_oop_from_str(const char* utf8_str, TRAPS); | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
91 static Handle create_from_symbol(Symbol* symbol, TRAPS); |
0 | 92 static Handle create_from_platform_dependent_str(const char* str, TRAPS); |
93 static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS); | |
94 | |
6057 | 95 static bool has_offset_field() { |
96 assert(initialized, "Must be initialized"); | |
97 return (offset_offset > 0); | |
98 } | |
99 | |
100 static bool has_count_field() { | |
101 assert(initialized, "Must be initialized"); | |
102 return (count_offset > 0); | |
103 } | |
104 | |
105 static bool has_hash_field() { | |
106 assert(initialized, "Must be initialized"); | |
107 return (hash_offset > 0); | |
108 } | |
109 | |
110 static int value_offset_in_bytes() { | |
111 assert(initialized && (value_offset > 0), "Must be initialized"); | |
112 return value_offset; | |
113 } | |
114 static int count_offset_in_bytes() { | |
115 assert(initialized && (count_offset > 0), "Must be initialized"); | |
116 return count_offset; | |
117 } | |
118 static int offset_offset_in_bytes() { | |
119 assert(initialized && (offset_offset > 0), "Must be initialized"); | |
120 return offset_offset; | |
121 } | |
122 static int hash_offset_in_bytes() { | |
123 assert(initialized && (hash_offset > 0), "Must be initialized"); | |
124 return hash_offset; | |
125 } | |
0 | 126 |
127 // Accessors | |
128 static typeArrayOop value(oop java_string) { | |
6057 | 129 assert(initialized && (value_offset > 0), "Must be initialized"); |
0 | 130 assert(is_instance(java_string), "must be java_string"); |
131 return (typeArrayOop) java_string->obj_field(value_offset); | |
132 } | |
133 static int offset(oop java_string) { | |
6057 | 134 assert(initialized, "Must be initialized"); |
0 | 135 assert(is_instance(java_string), "must be java_string"); |
6057 | 136 if (offset_offset > 0) { |
137 return java_string->int_field(offset_offset); | |
138 } else { | |
139 return 0; | |
140 } | |
0 | 141 } |
142 static int length(oop java_string) { | |
6057 | 143 assert(initialized, "Must be initialized"); |
0 | 144 assert(is_instance(java_string), "must be java_string"); |
6057 | 145 if (count_offset > 0) { |
146 return java_string->int_field(count_offset); | |
147 } else { | |
148 return ((typeArrayOop)java_string->obj_field(value_offset))->length(); | |
149 } | |
0 | 150 } |
151 static int utf8_length(oop java_string); | |
152 | |
153 // String converters | |
154 static char* as_utf8_string(oop java_string); | |
1989
017cd8bce8a8
6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents:
1972
diff
changeset
|
155 static char* as_utf8_string(oop java_string, char* buf, int buflen); |
0 | 156 static char* as_utf8_string(oop java_string, int start, int len); |
22
90f5ddc7297b
6646946: Kernel installation failed on Japanese and Chinese XP SP2 (VM part)
coleenp
parents:
0
diff
changeset
|
157 static char* as_platform_dependent_str(Handle java_string, TRAPS); |
0 | 158 static jchar* as_unicode_string(oop java_string, int& length); |
159 | |
2418
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
160 // Compute the hash value for a java.lang.String object which would |
6162 | 161 // contain the characters passed in. |
2418
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
162 // |
6162 | 163 // As the hash value used by the String object itself, in |
164 // String.hashCode(). This value is normally calculated in Java code | |
165 // in the String.hashCode method(), but is precomputed for String | |
166 // objects in the shared archive file. | |
167 // hash P(31) from Kernighan & Ritchie | |
2418
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
168 // |
6162 | 169 // For this reason, THIS ALGORITHM MUST MATCH String.toHash(). |
170 template <typename T> static unsigned int to_hash(T* s, int len) { | |
2418
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
171 unsigned int h = 0; |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
172 while (len-- > 0) { |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
173 h = 31*h + (unsigned int) *s; |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
174 s++; |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
175 } |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
176 return h; |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
177 } |
6162 | 178 static unsigned int to_hash(oop java_string); |
179 | |
180 // This is the string hash code used by the StringTable, which may be | |
181 // the same as String.toHash or an alternate hash code. | |
2418
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
182 static unsigned int hash_string(oop java_string); |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
183 |
0 | 184 static bool equals(oop java_string, jchar* chars, int len); |
185 | |
186 // Conversion between '.' and '/' formats | |
187 static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); } | |
188 static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); } | |
189 | |
190 // Conversion | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
191 static Symbol* as_symbol(Handle java_string, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
192 static Symbol* as_symbol_or_null(oop java_string); |
0 | 193 |
194 // Testers | |
195 static bool is_instance(oop obj) { | |
1142 | 196 return obj != NULL && obj->klass() == SystemDictionary::String_klass(); |
0 | 197 } |
198 | |
199 // Debugging | |
200 static void print(Handle java_string, outputStream* st); | |
201 friend class JavaClasses; | |
202 }; | |
203 | |
204 | |
205 // Interface to java.lang.Class objects | |
206 | |
3938 | 207 #define CLASS_INJECTED_FIELDS(macro) \ |
208 macro(java_lang_Class, klass, object_signature, false) \ | |
209 macro(java_lang_Class, resolved_constructor, object_signature, false) \ | |
210 macro(java_lang_Class, array_klass, object_signature, false) \ | |
211 macro(java_lang_Class, oop_size, int_signature, false) \ | |
212 macro(java_lang_Class, static_oop_field_count, int_signature, false) | |
213 | |
0 | 214 class java_lang_Class : AllStatic { |
3938 | 215 friend class VMStructs; |
216 | |
0 | 217 private: |
218 // The fake offsets are added by the class loader when java.lang.Class is loaded | |
219 | |
3938 | 220 static int _klass_offset; |
221 static int _resolved_constructor_offset; | |
222 static int _array_klass_offset; | |
0 | 223 |
3938 | 224 static int _oop_size_offset; |
225 static int _static_oop_field_count_offset; | |
0 | 226 |
227 static bool offsets_computed; | |
228 static int classRedefinedCount_offset; | |
229 | |
230 public: | |
3938 | 231 static void compute_offsets(); |
232 | |
0 | 233 // Instance creation |
234 static oop create_mirror(KlassHandle k, TRAPS); | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2357
diff
changeset
|
235 static void fixup_mirror(KlassHandle k, TRAPS); |
0 | 236 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); |
237 // Conversion | |
238 static klassOop as_klassOop(oop java_class); | |
4009 | 239 static void set_klass(oop java_class, klassOop klass); |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
240 static BasicType as_BasicType(oop java_class, klassOop* reference_klass = NULL); |
710 | 241 static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) { |
242 klassOop refk_oop = NULL; | |
243 BasicType result = as_BasicType(java_class, &refk_oop); | |
244 (*reference_klass) = KlassHandle(refk_oop); | |
245 return result; | |
246 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
247 static Symbol* 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
|
248 static void print_signature(oop java_class, outputStream *st); |
0 | 249 // Testing |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
250 static bool is_instance(oop obj) { |
1142 | 251 return obj != NULL && obj->klass() == SystemDictionary::Class_klass(); |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
252 } |
0 | 253 static bool is_primitive(oop java_class); |
254 static BasicType primitive_type(oop java_class); | |
255 static oop primitive_mirror(BasicType t); | |
256 // JVM_NewInstance support | |
257 static methodOop resolved_constructor(oop java_class); | |
258 static void set_resolved_constructor(oop java_class, methodOop constructor); | |
259 // JVM_NewArray support | |
260 static klassOop array_klass(oop java_class); | |
261 static void set_array_klass(oop java_class, klassOop klass); | |
262 // compiler support for class operations | |
3938 | 263 static int klass_offset_in_bytes() { return _klass_offset; } |
264 static int resolved_constructor_offset_in_bytes() { return _resolved_constructor_offset; } | |
265 static int array_klass_offset_in_bytes() { return _array_klass_offset; } | |
0 | 266 // Support for classRedefinedCount field |
267 static int classRedefinedCount(oop the_class_mirror); | |
268 static void set_classRedefinedCount(oop the_class_mirror, int value); | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2357
diff
changeset
|
269 |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2357
diff
changeset
|
270 static int oop_size(oop java_class); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2357
diff
changeset
|
271 static void set_oop_size(oop java_class, int size); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2357
diff
changeset
|
272 static int static_oop_field_count(oop java_class); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2357
diff
changeset
|
273 static void set_static_oop_field_count(oop java_class, int size); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2357
diff
changeset
|
274 |
0 | 275 // Debugging |
276 friend class JavaClasses; | |
277 friend class instanceKlass; // verification code accesses offsets | |
278 friend class ClassFileParser; // access to number_of_fake_fields | |
279 }; | |
280 | |
281 // Interface to java.lang.Thread objects | |
282 | |
283 class java_lang_Thread : AllStatic { | |
284 private: | |
285 // Note that for this class the layout changed between JDK1.2 and JDK1.3, | |
286 // so we compute the offsets at startup rather than hard-wiring them. | |
287 static int _name_offset; | |
288 static int _group_offset; | |
289 static int _contextClassLoader_offset; | |
290 static int _inheritedAccessControlContext_offset; | |
291 static int _priority_offset; | |
292 static int _eetop_offset; | |
293 static int _daemon_offset; | |
294 static int _stillborn_offset; | |
295 static int _stackSize_offset; | |
296 static int _tid_offset; | |
297 static int _thread_status_offset; | |
298 static int _park_blocker_offset; | |
299 static int _park_event_offset ; | |
300 | |
301 static void compute_offsets(); | |
302 | |
303 public: | |
304 // Instance creation | |
305 static oop create(); | |
5747
120820e30baa
added basic high-level interpreter support to HotSpot
Christian Haeubl <haeubl@ssw.jku.at>
parents:
4009
diff
changeset
|
306 static int java_thread_offset_in_bytes() { return _eetop_offset; } |
0 | 307 // Returns the JavaThread associated with the thread obj |
308 static JavaThread* thread(oop java_thread); | |
309 // Set JavaThread for instance | |
310 static void set_thread(oop java_thread, JavaThread* thread); | |
311 // Name | |
312 static typeArrayOop name(oop java_thread); | |
313 static void set_name(oop java_thread, typeArrayOop name); | |
314 // Priority | |
315 static ThreadPriority priority(oop java_thread); | |
316 static void set_priority(oop java_thread, ThreadPriority priority); | |
317 // Thread group | |
318 static oop threadGroup(oop java_thread); | |
319 // Stillborn | |
320 static bool is_stillborn(oop java_thread); | |
321 static void set_stillborn(oop java_thread); | |
322 // Alive (NOTE: this is not really a field, but provides the correct | |
323 // definition without doing a Java call) | |
324 static bool is_alive(oop java_thread); | |
325 // Daemon | |
326 static bool is_daemon(oop java_thread); | |
327 static void set_daemon(oop java_thread); | |
328 // Context ClassLoader | |
329 static oop context_class_loader(oop java_thread); | |
330 // Control context | |
331 static oop inherited_access_control_context(oop java_thread); | |
332 // Stack size hint | |
333 static jlong stackSize(oop java_thread); | |
334 // Thread ID | |
335 static jlong thread_id(oop java_thread); | |
336 | |
337 // Blocker object responsible for thread parking | |
338 static oop park_blocker(oop java_thread); | |
339 | |
340 // Pointer to type-stable park handler, encoded as jlong. | |
341 // Should be set when apparently null | |
342 // For details, see unsafe.cpp Unsafe_Unpark | |
343 static jlong park_event(oop java_thread); | |
344 static bool set_park_event(oop java_thread, jlong ptr); | |
345 | |
346 // Java Thread Status for JVMTI and M&M use. | |
347 // This thread status info is saved in threadStatus field of | |
348 // java.lang.Thread java class. | |
349 enum ThreadStatus { | |
350 NEW = 0, | |
351 RUNNABLE = JVMTI_THREAD_STATE_ALIVE + // runnable / running | |
352 JVMTI_THREAD_STATE_RUNNABLE, | |
353 SLEEPING = JVMTI_THREAD_STATE_ALIVE + // Thread.sleep() | |
354 JVMTI_THREAD_STATE_WAITING + | |
355 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + | |
356 JVMTI_THREAD_STATE_SLEEPING, | |
357 IN_OBJECT_WAIT = JVMTI_THREAD_STATE_ALIVE + // Object.wait() | |
358 JVMTI_THREAD_STATE_WAITING + | |
359 JVMTI_THREAD_STATE_WAITING_INDEFINITELY + | |
360 JVMTI_THREAD_STATE_IN_OBJECT_WAIT, | |
361 IN_OBJECT_WAIT_TIMED = JVMTI_THREAD_STATE_ALIVE + // Object.wait(long) | |
362 JVMTI_THREAD_STATE_WAITING + | |
363 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + | |
364 JVMTI_THREAD_STATE_IN_OBJECT_WAIT, | |
365 PARKED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park() | |
366 JVMTI_THREAD_STATE_WAITING + | |
367 JVMTI_THREAD_STATE_WAITING_INDEFINITELY + | |
368 JVMTI_THREAD_STATE_PARKED, | |
369 PARKED_TIMED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park(long) | |
370 JVMTI_THREAD_STATE_WAITING + | |
371 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + | |
372 JVMTI_THREAD_STATE_PARKED, | |
373 BLOCKED_ON_MONITOR_ENTER = JVMTI_THREAD_STATE_ALIVE + // (re-)entering a synchronization block | |
374 JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER, | |
375 TERMINATED = JVMTI_THREAD_STATE_TERMINATED | |
376 }; | |
377 // Write thread status info to threadStatus field of java.lang.Thread. | |
378 static void set_thread_status(oop java_thread_oop, ThreadStatus status); | |
379 // Read thread status info from threadStatus field of java.lang.Thread. | |
380 static ThreadStatus get_thread_status(oop java_thread_oop); | |
381 | |
382 static const char* thread_status_name(oop java_thread_oop); | |
383 | |
384 // Debugging | |
385 friend class JavaClasses; | |
386 }; | |
387 | |
388 // Interface to java.lang.ThreadGroup objects | |
389 | |
390 class java_lang_ThreadGroup : AllStatic { | |
391 private: | |
392 static int _parent_offset; | |
393 static int _name_offset; | |
394 static int _threads_offset; | |
395 static int _groups_offset; | |
396 static int _maxPriority_offset; | |
397 static int _destroyed_offset; | |
398 static int _daemon_offset; | |
399 static int _vmAllowSuspension_offset; | |
400 static int _nthreads_offset; | |
401 static int _ngroups_offset; | |
402 | |
403 static void compute_offsets(); | |
404 | |
405 public: | |
406 // parent ThreadGroup | |
407 static oop parent(oop java_thread_group); | |
408 // name | |
409 static typeArrayOop name(oop java_thread_group); | |
410 // ("name as oop" accessor is not necessary) | |
411 // Number of threads in group | |
412 static int nthreads(oop java_thread_group); | |
413 // threads | |
414 static objArrayOop threads(oop java_thread_group); | |
415 // Number of threads in group | |
416 static int ngroups(oop java_thread_group); | |
417 // groups | |
418 static objArrayOop groups(oop java_thread_group); | |
419 // maxPriority in group | |
420 static ThreadPriority maxPriority(oop java_thread_group); | |
421 // Destroyed | |
422 static bool is_destroyed(oop java_thread_group); | |
423 // Daemon | |
424 static bool is_daemon(oop java_thread_group); | |
425 // vmAllowSuspension | |
426 static bool is_vmAllowSuspension(oop java_thread_group); | |
427 // Debugging | |
428 friend class JavaClasses; | |
429 }; | |
430 | |
431 | |
432 | |
433 // Interface to java.lang.Throwable objects | |
434 | |
435 class java_lang_Throwable: AllStatic { | |
436 friend class BacktraceBuilder; | |
437 | |
438 private: | |
439 // Offsets | |
440 enum { | |
441 hc_backtrace_offset = 0, | |
442 hc_detailMessage_offset = 1, | |
443 hc_cause_offset = 2, // New since 1.4 | |
444 hc_stackTrace_offset = 3 // New since 1.4 | |
445 }; | |
3820
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3461
diff
changeset
|
446 enum { |
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3461
diff
changeset
|
447 hc_static_unassigned_stacktrace_offset = 0 // New since 1.7 |
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3461
diff
changeset
|
448 }; |
0 | 449 // Trace constants |
450 enum { | |
451 trace_methods_offset = 0, | |
452 trace_bcis_offset = 1, | |
453 trace_next_offset = 2, | |
454 trace_size = 3, | |
455 trace_chunk_size = 32 | |
456 }; | |
457 | |
458 static int backtrace_offset; | |
459 static int detailMessage_offset; | |
460 static int cause_offset; | |
461 static int stackTrace_offset; | |
3820
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3461
diff
changeset
|
462 static int static_unassigned_stacktrace_offset; |
0 | 463 |
464 // Printing | |
465 static char* print_stack_element_to_buffer(methodOop method, int bci); | |
466 static void print_to_stream(Handle stream, const char* str); | |
467 // StackTrace (programmatic access, new since 1.4) | |
468 static void clear_stacktrace(oop throwable); | |
469 // No stack trace available | |
470 static const char* no_stack_trace_message(); | |
3820
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3461
diff
changeset
|
471 // Stacktrace (post JDK 1.7.0 to allow immutability protocol to be followed) |
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3461
diff
changeset
|
472 static void set_stacktrace(oop throwable, oop st_element_array); |
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3461
diff
changeset
|
473 static oop unassigned_stacktrace(); |
0 | 474 |
475 public: | |
476 // Backtrace | |
477 static oop backtrace(oop throwable); | |
478 static void set_backtrace(oop throwable, oop value); | |
479 // Needed by JVMTI to filter out this internal field. | |
480 static int get_backtrace_offset() { return backtrace_offset;} | |
481 static int get_detailMessage_offset() { return detailMessage_offset;} | |
482 // Message | |
483 static oop message(oop throwable); | |
484 static oop message(Handle throwable); | |
485 static void set_message(oop throwable, oop value); | |
486 // Print stack trace stored in exception by call-back to Java | |
487 // Note: this is no longer used in Merlin, but we still suppport | |
488 // it for compatibility. | |
489 static void print_stack_trace(oop throwable, oop print_stream); | |
490 static void print_stack_element(Handle stream, methodOop method, int bci); | |
491 static void print_stack_element(outputStream *st, methodOop method, int bci); | |
492 static void print_stack_usage(Handle stream); | |
493 | |
494 // Allocate space for backtrace (created but stack trace not filled in) | |
495 static void allocate_backtrace(Handle throwable, TRAPS); | |
496 // Fill in current stack trace for throwable with preallocated backtrace (no GC) | |
497 static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable); | |
498 // Fill in current stack trace, can cause GC | |
3272
01147d8aac1d
7009923: JSR 292: VM crash in JavaThread::last_frame
coleenp
parents:
2418
diff
changeset
|
499 static void fill_in_stack_trace(Handle throwable, methodHandle method, TRAPS); |
01147d8aac1d
7009923: JSR 292: VM crash in JavaThread::last_frame
coleenp
parents:
2418
diff
changeset
|
500 static void fill_in_stack_trace(Handle throwable, methodHandle method = methodHandle()); |
0 | 501 // Programmatic access to stack trace |
502 static oop get_stack_trace_element(oop throwable, int index, TRAPS); | |
503 static int get_stack_trace_depth(oop throwable, TRAPS); | |
504 // Printing | |
505 static void print(oop throwable, outputStream* st); | |
506 static void print(Handle throwable, outputStream* st); | |
507 static void print_stack_trace(oop throwable, outputStream* st); | |
508 // Debugging | |
509 friend class JavaClasses; | |
510 }; | |
511 | |
512 | |
513 // Interface to java.lang.reflect.AccessibleObject objects | |
514 | |
515 class java_lang_reflect_AccessibleObject: AllStatic { | |
516 private: | |
517 // Note that to reduce dependencies on the JDK we compute these | |
518 // offsets at run-time. | |
519 static int override_offset; | |
520 | |
521 static void compute_offsets(); | |
522 | |
523 public: | |
524 // Accessors | |
525 static jboolean override(oop reflect); | |
526 static void set_override(oop reflect, jboolean value); | |
527 | |
528 // Debugging | |
529 friend class JavaClasses; | |
530 }; | |
531 | |
532 | |
533 // Interface to java.lang.reflect.Method objects | |
534 | |
535 class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject { | |
536 private: | |
537 // Note that to reduce dependencies on the JDK we compute these | |
538 // offsets at run-time. | |
539 static int clazz_offset; | |
540 static int name_offset; | |
541 static int returnType_offset; | |
542 static int parameterTypes_offset; | |
543 static int exceptionTypes_offset; | |
544 static int slot_offset; | |
545 static int modifiers_offset; | |
546 static int signature_offset; | |
547 static int annotations_offset; | |
548 static int parameter_annotations_offset; | |
549 static int annotation_default_offset; | |
550 | |
551 static void compute_offsets(); | |
552 | |
553 public: | |
554 // Allocation | |
555 static Handle create(TRAPS); | |
556 | |
557 // Accessors | |
558 static oop clazz(oop reflect); | |
559 static void set_clazz(oop reflect, oop value); | |
560 | |
561 static oop name(oop method); | |
562 static void set_name(oop method, oop value); | |
563 | |
564 static oop return_type(oop method); | |
565 static void set_return_type(oop method, oop value); | |
566 | |
567 static oop parameter_types(oop method); | |
568 static void set_parameter_types(oop method, oop value); | |
569 | |
570 static oop exception_types(oop method); | |
571 static void set_exception_types(oop method, oop value); | |
572 | |
573 static int slot(oop reflect); | |
574 static void set_slot(oop reflect, int value); | |
575 | |
576 static int modifiers(oop method); | |
577 static void set_modifiers(oop method, int value); | |
578 | |
579 static bool has_signature_field(); | |
580 static oop signature(oop method); | |
581 static void set_signature(oop method, oop value); | |
582 | |
583 static bool has_annotations_field(); | |
584 static oop annotations(oop method); | |
585 static void set_annotations(oop method, oop value); | |
586 | |
587 static bool has_parameter_annotations_field(); | |
588 static oop parameter_annotations(oop method); | |
589 static void set_parameter_annotations(oop method, oop value); | |
590 | |
591 static bool has_annotation_default_field(); | |
592 static oop annotation_default(oop method); | |
593 static void set_annotation_default(oop method, oop value); | |
594 | |
595 // Debugging | |
596 friend class JavaClasses; | |
597 }; | |
598 | |
599 | |
600 // Interface to java.lang.reflect.Constructor objects | |
601 | |
602 class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject { | |
603 private: | |
604 // Note that to reduce dependencies on the JDK we compute these | |
605 // offsets at run-time. | |
606 static int clazz_offset; | |
607 static int parameterTypes_offset; | |
608 static int exceptionTypes_offset; | |
609 static int slot_offset; | |
610 static int modifiers_offset; | |
611 static int signature_offset; | |
612 static int annotations_offset; | |
613 static int parameter_annotations_offset; | |
614 | |
615 static void compute_offsets(); | |
616 | |
617 public: | |
618 // Allocation | |
619 static Handle create(TRAPS); | |
620 | |
621 // Accessors | |
622 static oop clazz(oop reflect); | |
623 static void set_clazz(oop reflect, oop value); | |
624 | |
625 static oop parameter_types(oop constructor); | |
626 static void set_parameter_types(oop constructor, oop value); | |
627 | |
628 static oop exception_types(oop constructor); | |
629 static void set_exception_types(oop constructor, oop value); | |
630 | |
631 static int slot(oop reflect); | |
632 static void set_slot(oop reflect, int value); | |
633 | |
634 static int modifiers(oop constructor); | |
635 static void set_modifiers(oop constructor, int value); | |
636 | |
637 static bool has_signature_field(); | |
638 static oop signature(oop constructor); | |
639 static void set_signature(oop constructor, oop value); | |
640 | |
641 static bool has_annotations_field(); | |
642 static oop annotations(oop constructor); | |
643 static void set_annotations(oop constructor, oop value); | |
644 | |
645 static bool has_parameter_annotations_field(); | |
646 static oop parameter_annotations(oop method); | |
647 static void set_parameter_annotations(oop method, oop value); | |
648 | |
649 // Debugging | |
650 friend class JavaClasses; | |
651 }; | |
652 | |
653 | |
654 // Interface to java.lang.reflect.Field objects | |
655 | |
656 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject { | |
657 private: | |
658 // Note that to reduce dependencies on the JDK we compute these | |
659 // offsets at run-time. | |
660 static int clazz_offset; | |
661 static int name_offset; | |
662 static int type_offset; | |
663 static int slot_offset; | |
664 static int modifiers_offset; | |
665 static int signature_offset; | |
666 static int annotations_offset; | |
667 | |
668 static void compute_offsets(); | |
669 | |
670 public: | |
671 // Allocation | |
672 static Handle create(TRAPS); | |
673 | |
674 // Accessors | |
675 static oop clazz(oop reflect); | |
676 static void set_clazz(oop reflect, oop value); | |
677 | |
678 static oop name(oop field); | |
679 static void set_name(oop field, oop value); | |
680 | |
681 static oop type(oop field); | |
682 static void set_type(oop field, oop value); | |
683 | |
684 static int slot(oop reflect); | |
685 static void set_slot(oop reflect, int value); | |
686 | |
687 static int modifiers(oop field); | |
688 static void set_modifiers(oop field, int value); | |
689 | |
690 static bool has_signature_field(); | |
691 static oop signature(oop constructor); | |
692 static void set_signature(oop constructor, oop value); | |
693 | |
694 static bool has_annotations_field(); | |
695 static oop annotations(oop constructor); | |
696 static void set_annotations(oop constructor, oop value); | |
697 | |
698 static bool has_parameter_annotations_field(); | |
699 static oop parameter_annotations(oop method); | |
700 static void set_parameter_annotations(oop method, oop value); | |
701 | |
702 static bool has_annotation_default_field(); | |
703 static oop annotation_default(oop method); | |
704 static void set_annotation_default(oop method, oop value); | |
705 | |
706 // Debugging | |
707 friend class JavaClasses; | |
708 }; | |
709 | |
710 // Interface to sun.reflect.ConstantPool objects | |
711 class sun_reflect_ConstantPool { | |
712 private: | |
713 // Note that to reduce dependencies on the JDK we compute these | |
714 // offsets at run-time. | |
715 static int _cp_oop_offset; | |
716 | |
717 static void compute_offsets(); | |
718 | |
719 public: | |
720 // Allocation | |
721 static Handle create(TRAPS); | |
722 | |
723 // Accessors | |
724 static oop cp_oop(oop reflect); | |
725 static void set_cp_oop(oop reflect, oop value); | |
726 static int cp_oop_offset() { | |
727 return _cp_oop_offset; | |
728 } | |
729 | |
730 // Debugging | |
731 friend class JavaClasses; | |
732 }; | |
733 | |
734 // Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects | |
735 class sun_reflect_UnsafeStaticFieldAccessorImpl { | |
736 private: | |
737 static int _base_offset; | |
738 static void compute_offsets(); | |
739 | |
740 public: | |
741 static int base_offset() { | |
742 return _base_offset; | |
743 } | |
744 | |
745 // Debugging | |
746 friend class JavaClasses; | |
747 }; | |
748 | |
749 // Interface to java.lang primitive type boxing objects: | |
750 // - java.lang.Boolean | |
751 // - java.lang.Character | |
752 // - java.lang.Float | |
753 // - java.lang.Double | |
754 // - java.lang.Byte | |
755 // - java.lang.Short | |
756 // - java.lang.Integer | |
757 // - java.lang.Long | |
758 | |
759 // This could be separated out into 8 individual classes. | |
760 | |
761 class java_lang_boxing_object: AllStatic { | |
762 private: | |
763 enum { | |
764 hc_value_offset = 0 | |
765 }; | |
766 static int value_offset; | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
767 static int long_value_offset; |
0 | 768 |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
769 static oop initialize_and_allocate(BasicType type, TRAPS); |
0 | 770 public: |
771 // Allocation. Returns a boxed value, or NULL for invalid type. | |
772 static oop create(BasicType type, jvalue* value, TRAPS); | |
773 // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop. | |
774 static BasicType get_value(oop box, jvalue* value); | |
775 static BasicType set_value(oop box, jvalue* value); | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
776 static BasicType basic_type(oop box); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
777 static bool is_instance(oop box) { return basic_type(box) != T_ILLEGAL; } |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
778 static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; } |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
779 static void print(oop box, outputStream* st) { jvalue value; print(get_value(box, &value), &value, st); } |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
780 static void print(BasicType type, jvalue* value, outputStream* st); |
0 | 781 |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
782 static int value_offset_in_bytes(BasicType type) { |
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
783 return ( type == T_LONG || type == T_DOUBLE ) ? long_value_offset : |
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
784 value_offset; |
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
785 } |
0 | 786 |
787 // Debugging | |
788 friend class JavaClasses; | |
789 }; | |
790 | |
791 | |
792 | |
793 // Interface to java.lang.ref.Reference objects | |
794 | |
795 class java_lang_ref_Reference: AllStatic { | |
796 public: | |
797 enum { | |
798 hc_referent_offset = 0, | |
799 hc_queue_offset = 1, | |
800 hc_next_offset = 2, | |
801 hc_discovered_offset = 3 // Is not last, see SoftRefs. | |
802 }; | |
803 enum { | |
804 hc_static_lock_offset = 0, | |
805 hc_static_pending_offset = 1 | |
806 }; | |
807 | |
808 static int referent_offset; | |
809 static int queue_offset; | |
810 static int next_offset; | |
811 static int discovered_offset; | |
812 static int static_lock_offset; | |
813 static int static_pending_offset; | |
814 static int number_of_fake_oop_fields; | |
815 | |
816 // Accessors | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
817 static oop referent(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
818 return ref->obj_field(referent_offset); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
819 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
820 static void set_referent(oop ref, oop value) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
821 ref->obj_field_put(referent_offset, value); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
822 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
823 static void set_referent_raw(oop ref, oop value) { |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
824 ref->obj_field_put_raw(referent_offset, value); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
825 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
826 static HeapWord* referent_addr(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
827 return ref->obj_field_addr<HeapWord>(referent_offset); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
828 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
829 static oop next(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
830 return ref->obj_field(next_offset); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
831 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
832 static void set_next(oop ref, oop value) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
833 ref->obj_field_put(next_offset, value); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
834 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
835 static void set_next_raw(oop ref, oop value) { |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
836 ref->obj_field_put_raw(next_offset, value); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
837 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
838 static HeapWord* next_addr(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
839 return ref->obj_field_addr<HeapWord>(next_offset); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
840 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
841 static oop discovered(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
842 return ref->obj_field(discovered_offset); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
843 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
844 static void set_discovered(oop ref, oop value) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
845 ref->obj_field_put(discovered_offset, value); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
846 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
847 static void set_discovered_raw(oop ref, oop value) { |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
848 ref->obj_field_put_raw(discovered_offset, value); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
849 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
850 static HeapWord* discovered_addr(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
851 return ref->obj_field_addr<HeapWord>(discovered_offset); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
852 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
853 // Accessors for statics |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
854 static oop pending_list_lock(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
855 static oop pending_list(); |
0 | 856 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
857 static HeapWord* pending_list_addr(); |
0 | 858 }; |
859 | |
860 | |
861 // Interface to java.lang.ref.SoftReference objects | |
862 | |
863 class java_lang_ref_SoftReference: public java_lang_ref_Reference { | |
864 public: | |
865 enum { | |
866 // The timestamp is a long field and may need to be adjusted for alignment. | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
867 hc_timestamp_offset = hc_discovered_offset + 1 |
0 | 868 }; |
869 enum { | |
870 hc_static_clock_offset = 0 | |
871 }; | |
872 | |
873 static int timestamp_offset; | |
874 static int static_clock_offset; | |
875 | |
876 // Accessors | |
877 static jlong timestamp(oop ref); | |
878 | |
879 // Accessors for statics | |
880 static jlong clock(); | |
881 static void set_clock(jlong value); | |
882 }; | |
883 | |
884 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
885 // Interface to java.lang.invoke.MethodHandle objects |
710 | 886 |
887 class MethodHandleEntry; | |
888 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
889 class java_lang_invoke_MethodHandle: AllStatic { |
710 | 890 friend class JavaClasses; |
891 | |
892 private: | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
893 static int _type_offset; // the MethodType of this MH |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
894 static int _form_offset; // the LambdaForm of this MH |
710 | 895 |
896 static void compute_offsets(); | |
897 | |
898 public: | |
899 // Accessors | |
900 static oop type(oop mh); | |
901 static void set_type(oop mh, oop mtype); | |
902 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
903 static oop form(oop mh); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
904 static void set_form(oop mh, oop lform); |
710 | 905 |
906 // Testers | |
907 static bool is_subclass(klassOop klass) { | |
908 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass()); | |
909 } | |
910 static bool is_instance(oop obj) { | |
911 return obj != NULL && is_subclass(obj->klass()); | |
912 } | |
913 | |
914 // Accessors for code generation: | |
915 static int type_offset_in_bytes() { return _type_offset; } | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
916 static int form_offset_in_bytes() { return _form_offset; } |
710 | 917 }; |
918 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
919 // Interface to java.lang.invoke.LambdaForm objects |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
920 // (These are a private interface for managing adapter code generation.) |
3938 | 921 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
922 class java_lang_invoke_LambdaForm: AllStatic { |
710 | 923 friend class JavaClasses; |
924 | |
925 private: | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
926 static int _vmentry_offset; // type is MemberName |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
927 |
710 | 928 static void compute_offsets(); |
929 | |
930 public: | |
931 // Accessors | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
932 static oop vmentry(oop lform); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
933 static void set_vmentry(oop lform, oop invoker); |
710 | 934 |
935 // Testers | |
936 static bool is_subclass(klassOop klass) { | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
937 return SystemDictionary::LambdaForm_klass() != NULL && |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
938 Klass::cast(klass)->is_subclass_of(SystemDictionary::LambdaForm_klass()); |
710 | 939 } |
940 static bool is_instance(oop obj) { | |
941 return obj != NULL && is_subclass(obj->klass()); | |
942 } | |
943 | |
944 // Accessors for code generation: | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
945 static int vmentry_offset_in_bytes() { return _vmentry_offset; } |
710 | 946 }; |
947 | |
3905
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
948 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
949 // Interface to java.lang.invoke.MemberName objects |
710 | 950 // (These are a private interface for Java code to query the class hierarchy.) |
951 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
952 #define MEMBERNAME_INJECTED_FIELDS(macro) \ |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
953 macro(java_lang_invoke_MemberName, vmindex, intptr_signature, false) \ |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
954 macro(java_lang_invoke_MemberName, vmtarget, object_signature, false) |
3938 | 955 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
956 class java_lang_invoke_MemberName: AllStatic { |
710 | 957 friend class JavaClasses; |
958 | |
959 private: | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
960 // From java.lang.invoke.MemberName: |
710 | 961 // private Class<?> clazz; // class in which the method is defined |
962 // private String name; // may be null if not yet materialized | |
963 // private Object type; // may be null if not yet materialized | |
964 // private int flags; // modifier bits; see reflect.Modifier | |
965 // private Object vmtarget; // VM-specific target value | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
966 // private intptr_t vmindex; // member index within class or interface |
710 | 967 static int _clazz_offset; |
968 static int _name_offset; | |
969 static int _type_offset; | |
970 static int _flags_offset; | |
971 static int _vmtarget_offset; | |
972 static int _vmindex_offset; | |
973 | |
974 static void compute_offsets(); | |
975 | |
976 public: | |
977 // Accessors | |
978 static oop clazz(oop mname); | |
979 static void set_clazz(oop mname, oop clazz); | |
980 | |
981 static oop type(oop mname); | |
982 static void set_type(oop mname, oop type); | |
983 | |
984 static oop name(oop mname); | |
985 static void set_name(oop mname, oop name); | |
986 | |
987 static int flags(oop mname); | |
988 static void set_flags(oop mname, int flags); | |
989 | |
990 static oop vmtarget(oop mname); | |
991 static void set_vmtarget(oop mname, oop target); | |
992 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
993 static intptr_t vmindex(oop mname); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
994 static void set_vmindex(oop mname, intptr_t index); |
710 | 995 |
996 // Testers | |
997 static bool is_subclass(klassOop klass) { | |
998 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MemberName_klass()); | |
999 } | |
1000 static bool is_instance(oop obj) { | |
1001 return obj != NULL && is_subclass(obj->klass()); | |
1002 } | |
1003 | |
1004 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants): | |
1005 enum { | |
1006 MN_IS_METHOD = 0x00010000, // method (not constructor) | |
1007 MN_IS_CONSTRUCTOR = 0x00020000, // constructor | |
1008 MN_IS_FIELD = 0x00040000, // field | |
1009 MN_IS_TYPE = 0x00080000, // nested type | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1010 MN_REFERENCE_KIND_SHIFT = 24, // refKind |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1011 MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT, |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1012 // The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers: |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1013 MN_SEARCH_SUPERCLASSES = 0x00100000, // walk super classes |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1014 MN_SEARCH_INTERFACES = 0x00200000 // walk implemented interfaces |
710 | 1015 }; |
1016 | |
1017 // Accessors for code generation: | |
1018 static int clazz_offset_in_bytes() { return _clazz_offset; } | |
1019 static int type_offset_in_bytes() { return _type_offset; } | |
1020 static int name_offset_in_bytes() { return _name_offset; } | |
1021 static int flags_offset_in_bytes() { return _flags_offset; } | |
1022 static int vmtarget_offset_in_bytes() { return _vmtarget_offset; } | |
1023 static int vmindex_offset_in_bytes() { return _vmindex_offset; } | |
1024 }; | |
1025 | |
1026 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
1027 // Interface to java.lang.invoke.MethodType objects |
710 | 1028 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
1029 class java_lang_invoke_MethodType: AllStatic { |
710 | 1030 friend class JavaClasses; |
1031 | |
1032 private: | |
1033 static int _rtype_offset; | |
1034 static int _ptypes_offset; | |
1035 | |
1036 static void compute_offsets(); | |
1037 | |
1038 public: | |
1039 // Accessors | |
1040 static oop rtype(oop mt); | |
1041 static objArrayOop ptypes(oop mt); | |
1042 | |
1043 static oop ptype(oop mt, int index); | |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
1059
diff
changeset
|
1044 static int ptype_count(oop mt); |
710 | 1045 |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1046 static int ptype_slot_count(oop mt); // extra counts for long/double |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1047 static int rtype_slot_count(oop mt); // extra counts for long/double |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1048 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1049 static Symbol* as_signature(oop mt, bool intern_if_not_found, TRAPS); |
710 | 1050 static void print_signature(oop mt, outputStream* st); |
1051 | |
1052 static bool is_instance(oop obj) { | |
1053 return obj != NULL && obj->klass() == SystemDictionary::MethodType_klass(); | |
1054 } | |
1055 | |
3461
81d815b05abb
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3363
diff
changeset
|
1056 static bool equals(oop mt1, oop mt2); |
81d815b05abb
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3363
diff
changeset
|
1057 |
710 | 1058 // Accessors for code generation: |
1059 static int rtype_offset_in_bytes() { return _rtype_offset; } | |
1060 static int ptypes_offset_in_bytes() { return _ptypes_offset; } | |
1061 }; | |
1062 | |
1063 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
1064 // Interface to java.lang.invoke.CallSite objects |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1065 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
1066 class java_lang_invoke_CallSite: AllStatic { |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1067 friend class JavaClasses; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1068 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1069 private: |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1070 static int _target_offset; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1071 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1072 static void compute_offsets(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1073 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1074 public: |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1075 // Accessors |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1076 static oop target( oop site) { return site->obj_field( _target_offset); } |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1077 static void set_target( oop site, oop target) { site->obj_field_put( _target_offset, target); } |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1078 |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1079 static volatile oop target_volatile(oop site) { return site->obj_field_volatile( _target_offset); } |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1080 static void set_target_volatile(oop site, oop target) { site->obj_field_put_volatile(_target_offset, target); } |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1081 |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1082 // Testers |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1083 static bool is_subclass(klassOop klass) { |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1084 return Klass::cast(klass)->is_subclass_of(SystemDictionary::CallSite_klass()); |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1085 } |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1086 static bool is_instance(oop obj) { |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1087 return obj != NULL && is_subclass(obj->klass()); |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1088 } |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1089 |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1090 // Accessors for code generation: |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1091 static int target_offset_in_bytes() { return _target_offset; } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1092 }; |
710 | 1093 |
1094 | |
0 | 1095 // Interface to java.security.AccessControlContext objects |
1096 | |
1097 class java_security_AccessControlContext: AllStatic { | |
1098 private: | |
1099 // Note that for this class the layout changed between JDK1.2 and JDK1.3, | |
1100 // so we compute the offsets at startup rather than hard-wiring them. | |
1101 static int _context_offset; | |
1102 static int _privilegedContext_offset; | |
1103 static int _isPrivileged_offset; | |
1104 | |
1105 static void compute_offsets(); | |
1106 public: | |
1107 static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS); | |
1108 | |
1109 // Debugging/initialization | |
1110 friend class JavaClasses; | |
1111 }; | |
1112 | |
1113 | |
1114 // Interface to java.lang.ClassLoader objects | |
1115 | |
1116 class java_lang_ClassLoader : AllStatic { | |
1117 private: | |
1118 enum { | |
1119 hc_parent_offset = 0 | |
1120 }; | |
1121 | |
3938 | 1122 static bool offsets_computed; |
0 | 1123 static int parent_offset; |
3938 | 1124 static int parallelCapable_offset; |
1125 | |
1126 static void compute_offsets(); | |
0 | 1127 |
1128 public: | |
1129 static oop parent(oop loader); | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1130 static bool isAncestor(oop loader, oop cl); |
0 | 1131 |
3938 | 1132 // Support for parallelCapable field |
1133 static bool parallelCapable(oop the_class_mirror); | |
1134 | |
0 | 1135 static bool is_trusted_loader(oop loader); |
1136 | |
1137 // Fix for 4474172 | |
1138 static oop non_reflection_class_loader(oop loader); | |
1139 | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1140 // Testers |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1141 static bool is_subclass(klassOop klass) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1142 return Klass::cast(klass)->is_subclass_of(SystemDictionary::ClassLoader_klass()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1143 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1144 static bool is_instance(oop obj) { |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1145 return obj != NULL && is_subclass(obj->klass()); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1146 } |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1147 |
0 | 1148 // Debugging |
1149 friend class JavaClasses; | |
1150 }; | |
1151 | |
1152 | |
1153 // Interface to java.lang.System objects | |
1154 | |
1155 class java_lang_System : AllStatic { | |
1156 private: | |
1157 enum { | |
1158 hc_static_in_offset = 0, | |
1159 hc_static_out_offset = 1, | |
1160 hc_static_err_offset = 2 | |
1161 }; | |
1162 | |
1163 static int static_in_offset; | |
1164 static int static_out_offset; | |
1165 static int static_err_offset; | |
1166 | |
1167 public: | |
1168 static int in_offset_in_bytes(); | |
1169 static int out_offset_in_bytes(); | |
1170 static int err_offset_in_bytes(); | |
1171 | |
1172 // Debugging | |
1173 friend class JavaClasses; | |
1174 }; | |
1175 | |
1176 | |
1177 // Interface to java.lang.StackTraceElement objects | |
1178 | |
1179 class java_lang_StackTraceElement: AllStatic { | |
1180 private: | |
1181 enum { | |
1182 hc_declaringClass_offset = 0, | |
1183 hc_methodName_offset = 1, | |
1184 hc_fileName_offset = 2, | |
1185 hc_lineNumber_offset = 3 | |
1186 }; | |
1187 | |
1188 static int declaringClass_offset; | |
1189 static int methodName_offset; | |
1190 static int fileName_offset; | |
1191 static int lineNumber_offset; | |
1192 | |
1193 public: | |
1194 // Setters | |
1195 static void set_declaringClass(oop element, oop value); | |
1196 static void set_methodName(oop element, oop value); | |
1197 static void set_fileName(oop element, oop value); | |
1198 static void set_lineNumber(oop element, int value); | |
1199 | |
1200 // Create an instance of StackTraceElement | |
1201 static oop create(methodHandle m, int bci, TRAPS); | |
1202 | |
1203 // Debugging | |
1204 friend class JavaClasses; | |
1205 }; | |
1206 | |
1207 | |
1208 // Interface to java.lang.AssertionStatusDirectives objects | |
1209 | |
1210 class java_lang_AssertionStatusDirectives: AllStatic { | |
1211 private: | |
1212 enum { | |
1213 hc_classes_offset, | |
1214 hc_classEnabled_offset, | |
1215 hc_packages_offset, | |
1216 hc_packageEnabled_offset, | |
1217 hc_deflt_offset | |
1218 }; | |
1219 | |
1220 static int classes_offset; | |
1221 static int classEnabled_offset; | |
1222 static int packages_offset; | |
1223 static int packageEnabled_offset; | |
1224 static int deflt_offset; | |
1225 | |
1226 public: | |
1227 // Setters | |
1228 static void set_classes(oop obj, oop val); | |
1229 static void set_classEnabled(oop obj, oop val); | |
1230 static void set_packages(oop obj, oop val); | |
1231 static void set_packageEnabled(oop obj, oop val); | |
1232 static void set_deflt(oop obj, bool val); | |
1233 // Debugging | |
1234 friend class JavaClasses; | |
1235 }; | |
1236 | |
1237 | |
1238 class java_nio_Buffer: AllStatic { | |
1239 private: | |
1240 static int _limit_offset; | |
1241 | |
1242 public: | |
1243 static int limit_offset(); | |
1244 static void compute_offsets(); | |
1245 }; | |
1246 | |
1247 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic { | |
1248 private: | |
1249 static int _owner_offset; | |
1250 public: | |
1251 static void initialize(TRAPS); | |
1252 static oop get_owner_threadObj(oop obj); | |
1253 }; | |
1254 | |
3938 | 1255 // Use to declare fields that need to be injected into Java classes |
1256 // for the JVM to use. The name_index and signature_index are | |
1257 // declared in vmSymbols. The may_be_java flag is used to declare | |
1258 // fields that might already exist in Java but should be injected if | |
1259 // they don't. Otherwise the field is unconditionally injected and | |
1260 // the JVM uses the injected one. This is to ensure that name | |
1261 // collisions don't occur. In general may_be_java should be false | |
1262 // unless there's a good reason. | |
1263 | |
1264 class InjectedField { | |
1265 public: | |
1266 const SystemDictionary::WKID klass_id; | |
1267 const vmSymbols::SID name_index; | |
1268 const vmSymbols::SID signature_index; | |
1269 const bool may_be_java; | |
1270 | |
1271 | |
1272 klassOop klass() const { return SystemDictionary::well_known_klass(klass_id); } | |
1273 Symbol* name() const { return lookup_symbol(name_index); } | |
1274 Symbol* signature() const { return lookup_symbol(signature_index); } | |
1275 | |
1276 int compute_offset(); | |
1277 | |
1278 // Find the Symbol for this index | |
1279 static Symbol* lookup_symbol(int symbol_index) { | |
1280 return vmSymbols::symbol_at((vmSymbols::SID)symbol_index); | |
1281 } | |
1282 }; | |
1283 | |
1284 #define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \ | |
1285 klass##_##name##_enum, | |
1286 | |
1287 #define ALL_INJECTED_FIELDS(macro) \ | |
1288 CLASS_INJECTED_FIELDS(macro) \ | |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
6166
diff
changeset
|
1289 MEMBERNAME_INJECTED_FIELDS(macro) |
3938 | 1290 |
0 | 1291 // Interface to hard-coded offset checking |
1292 | |
1293 class JavaClasses : AllStatic { | |
1294 private: | |
3938 | 1295 |
1296 static InjectedField _injected_fields[]; | |
1297 | |
0 | 1298 static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
1299 static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
1300 static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
3938 | 1301 |
0 | 1302 public: |
3938 | 1303 enum InjectedFieldID { |
1304 ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD_ENUM) | |
1305 MAX_enum | |
1306 }; | |
1307 | |
1308 static int compute_injected_offset(InjectedFieldID id); | |
1309 | |
0 | 1310 static void compute_hard_coded_offsets(); |
1311 static void compute_offsets(); | |
1312 static void check_offsets() PRODUCT_RETURN; | |
3938 | 1313 |
1314 static InjectedField* get_injected(Symbol* class_name, int* field_count); | |
0 | 1315 }; |
1972 | 1316 |
3938 | 1317 #undef DECLARE_INJECTED_FIELD_ENUM |
1318 | |
1972 | 1319 #endif // SHARE_VM_CLASSFILE_JAVACLASSES_HPP |