Mercurial > hg > truffle
annotate src/share/vm/classfile/javaClasses.hpp @ 1294:7de45b5044c3
6932270: Allow Java's ELF symtab reader to use separate debuginfo files
Reviewed-by: never
Contributed-by: Andrew Haley <aph@redhat.com>
author | never |
---|---|
date | Tue, 09 Mar 2010 11:02:39 -0800 |
parents | 4ce7240d622c |
children | cd5dbf694d45 |
rev | line source |
---|---|
0 | 1 /* |
579 | 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 // Interface for manipulating the basic Java classes. | |
26 // | |
27 // All dependencies on layout of actual Java classes should be kept here. | |
28 // If the layout of any of the classes above changes the offsets must be adjusted. | |
29 // | |
30 // For most classes we hardwire the offsets for performance reasons. In certain | |
31 // cases (e.g. java.security.AccessControlContext) we compute the offsets at | |
32 // startup since the layout here differs between JDK1.2 and JDK1.3. | |
33 // | |
34 // Note that fields (static and non-static) are arranged with oops before non-oops | |
35 // on a per class basis. The offsets below have to reflect this ordering. | |
36 // | |
37 // When editing the layouts please update the check_offset verification code | |
38 // correspondingly. The names in the enums must be identical to the actual field | |
39 // names in order for the verification code to work. | |
40 | |
41 | |
42 // Interface to java.lang.String objects | |
43 | |
44 class java_lang_String : AllStatic { | |
45 private: | |
46 enum { | |
47 hc_value_offset = 0, | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
48 hc_offset_offset = 1 |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
49 //hc_count_offset = 2 -- not a word-scaled offset |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
50 //hc_hash_offset = 3 -- not a word-scaled offset |
0 | 51 }; |
52 | |
53 static int value_offset; | |
54 static int offset_offset; | |
55 static int count_offset; | |
56 static int hash_offset; | |
57 | |
58 static Handle basic_create(int length, bool tenured, TRAPS); | |
59 static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS); | |
60 | |
61 static void set_value( oop string, typeArrayOop buffer) { string->obj_field_put(value_offset, (oop)buffer); } | |
62 static void set_offset(oop string, int offset) { string->int_field_put(offset_offset, offset); } | |
63 static void set_count( oop string, int count) { string->int_field_put(count_offset, count); } | |
64 | |
65 public: | |
66 // Instance creation | |
67 static Handle create_from_unicode(jchar* unicode, int len, TRAPS); | |
68 static Handle create_tenured_from_unicode(jchar* unicode, int len, TRAPS); | |
69 static oop create_oop_from_unicode(jchar* unicode, int len, TRAPS); | |
70 static Handle create_from_str(const char* utf8_str, TRAPS); | |
71 static oop create_oop_from_str(const char* utf8_str, TRAPS); | |
72 static Handle create_from_symbol(symbolHandle symbol, TRAPS); | |
73 static Handle create_from_platform_dependent_str(const char* str, TRAPS); | |
74 static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS); | |
75 | |
76 static int value_offset_in_bytes() { return value_offset; } | |
77 static int count_offset_in_bytes() { return count_offset; } | |
78 static int offset_offset_in_bytes() { return offset_offset; } | |
79 static int hash_offset_in_bytes() { return hash_offset; } | |
80 | |
81 // Accessors | |
82 static typeArrayOop value(oop java_string) { | |
83 assert(is_instance(java_string), "must be java_string"); | |
84 return (typeArrayOop) java_string->obj_field(value_offset); | |
85 } | |
86 static int offset(oop java_string) { | |
87 assert(is_instance(java_string), "must be java_string"); | |
88 return java_string->int_field(offset_offset); | |
89 } | |
90 static int length(oop java_string) { | |
91 assert(is_instance(java_string), "must be java_string"); | |
92 return java_string->int_field(count_offset); | |
93 } | |
94 static int utf8_length(oop java_string); | |
95 | |
96 // String converters | |
97 static char* as_utf8_string(oop java_string); | |
98 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
|
99 static char* as_platform_dependent_str(Handle java_string, TRAPS); |
0 | 100 static jchar* as_unicode_string(oop java_string, int& length); |
101 | |
102 static bool equals(oop java_string, jchar* chars, int len); | |
103 | |
104 // Conversion between '.' and '/' formats | |
105 static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); } | |
106 static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); } | |
107 | |
108 // Conversion | |
109 static symbolHandle as_symbol(Handle java_string, TRAPS); | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
110 static symbolOop as_symbol_or_null(oop java_string); |
0 | 111 |
112 // Testers | |
113 static bool is_instance(oop obj) { | |
1142 | 114 return obj != NULL && obj->klass() == SystemDictionary::String_klass(); |
0 | 115 } |
116 | |
117 // Debugging | |
118 static void print(Handle java_string, outputStream* st); | |
119 friend class JavaClasses; | |
120 }; | |
121 | |
122 | |
123 // Interface to java.lang.Class objects | |
124 | |
125 class java_lang_Class : AllStatic { | |
126 friend class VMStructs; | |
127 private: | |
128 // The fake offsets are added by the class loader when java.lang.Class is loaded | |
129 | |
130 enum { | |
131 hc_klass_offset = 0, | |
132 hc_array_klass_offset = 1, | |
133 hc_resolved_constructor_offset = 2, | |
134 hc_number_of_fake_oop_fields = 3 | |
135 }; | |
136 | |
137 static int klass_offset; | |
138 static int resolved_constructor_offset; | |
139 static int array_klass_offset; | |
140 static int number_of_fake_oop_fields; | |
141 | |
142 static void compute_offsets(); | |
143 static bool offsets_computed; | |
144 static int classRedefinedCount_offset; | |
514 | 145 static int parallelCapable_offset; |
0 | 146 |
147 public: | |
148 // Instance creation | |
149 static oop create_mirror(KlassHandle k, TRAPS); | |
150 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); | |
151 // Conversion | |
152 static klassOop as_klassOop(oop java_class); | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
153 static BasicType as_BasicType(oop java_class, klassOop* reference_klass = NULL); |
710 | 154 static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) { |
155 klassOop refk_oop = NULL; | |
156 BasicType result = as_BasicType(java_class, &refk_oop); | |
157 (*reference_klass) = KlassHandle(refk_oop); | |
158 return result; | |
159 } | |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
160 static symbolOop as_signature(oop java_class, bool intern_if_not_found, TRAPS); |
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
161 static void print_signature(oop java_class, outputStream *st); |
0 | 162 // Testing |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
163 static bool is_instance(oop obj) { |
1142 | 164 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
|
165 } |
0 | 166 static bool is_primitive(oop java_class); |
167 static BasicType primitive_type(oop java_class); | |
168 static oop primitive_mirror(BasicType t); | |
169 // JVM_NewInstance support | |
170 static methodOop resolved_constructor(oop java_class); | |
171 static void set_resolved_constructor(oop java_class, methodOop constructor); | |
172 // JVM_NewArray support | |
173 static klassOop array_klass(oop java_class); | |
174 static void set_array_klass(oop java_class, klassOop klass); | |
175 // compiler support for class operations | |
176 static int klass_offset_in_bytes() { return klass_offset; } | |
177 static int resolved_constructor_offset_in_bytes() { return resolved_constructor_offset; } | |
178 static int array_klass_offset_in_bytes() { return array_klass_offset; } | |
179 // Support for classRedefinedCount field | |
180 static int classRedefinedCount(oop the_class_mirror); | |
181 static void set_classRedefinedCount(oop the_class_mirror, int value); | |
514 | 182 // Support for parallelCapable field |
183 static bool parallelCapable(oop the_class_mirror); | |
0 | 184 // Debugging |
185 friend class JavaClasses; | |
186 friend class instanceKlass; // verification code accesses offsets | |
187 friend class ClassFileParser; // access to number_of_fake_fields | |
188 }; | |
189 | |
190 // Interface to java.lang.Thread objects | |
191 | |
192 class java_lang_Thread : AllStatic { | |
193 private: | |
194 // Note that for this class the layout changed between JDK1.2 and JDK1.3, | |
195 // so we compute the offsets at startup rather than hard-wiring them. | |
196 static int _name_offset; | |
197 static int _group_offset; | |
198 static int _contextClassLoader_offset; | |
199 static int _inheritedAccessControlContext_offset; | |
200 static int _priority_offset; | |
201 static int _eetop_offset; | |
202 static int _daemon_offset; | |
203 static int _stillborn_offset; | |
204 static int _stackSize_offset; | |
205 static int _tid_offset; | |
206 static int _thread_status_offset; | |
207 static int _park_blocker_offset; | |
208 static int _park_event_offset ; | |
209 | |
210 static void compute_offsets(); | |
211 | |
212 public: | |
213 // Instance creation | |
214 static oop create(); | |
215 // Returns the JavaThread associated with the thread obj | |
216 static JavaThread* thread(oop java_thread); | |
217 // Set JavaThread for instance | |
218 static void set_thread(oop java_thread, JavaThread* thread); | |
219 // Name | |
220 static typeArrayOop name(oop java_thread); | |
221 static void set_name(oop java_thread, typeArrayOop name); | |
222 // Priority | |
223 static ThreadPriority priority(oop java_thread); | |
224 static void set_priority(oop java_thread, ThreadPriority priority); | |
225 // Thread group | |
226 static oop threadGroup(oop java_thread); | |
227 // Stillborn | |
228 static bool is_stillborn(oop java_thread); | |
229 static void set_stillborn(oop java_thread); | |
230 // Alive (NOTE: this is not really a field, but provides the correct | |
231 // definition without doing a Java call) | |
232 static bool is_alive(oop java_thread); | |
233 // Daemon | |
234 static bool is_daemon(oop java_thread); | |
235 static void set_daemon(oop java_thread); | |
236 // Context ClassLoader | |
237 static oop context_class_loader(oop java_thread); | |
238 // Control context | |
239 static oop inherited_access_control_context(oop java_thread); | |
240 // Stack size hint | |
241 static jlong stackSize(oop java_thread); | |
242 // Thread ID | |
243 static jlong thread_id(oop java_thread); | |
244 | |
245 // Blocker object responsible for thread parking | |
246 static oop park_blocker(oop java_thread); | |
247 | |
248 // Pointer to type-stable park handler, encoded as jlong. | |
249 // Should be set when apparently null | |
250 // For details, see unsafe.cpp Unsafe_Unpark | |
251 static jlong park_event(oop java_thread); | |
252 static bool set_park_event(oop java_thread, jlong ptr); | |
253 | |
254 // Java Thread Status for JVMTI and M&M use. | |
255 // This thread status info is saved in threadStatus field of | |
256 // java.lang.Thread java class. | |
257 enum ThreadStatus { | |
258 NEW = 0, | |
259 RUNNABLE = JVMTI_THREAD_STATE_ALIVE + // runnable / running | |
260 JVMTI_THREAD_STATE_RUNNABLE, | |
261 SLEEPING = JVMTI_THREAD_STATE_ALIVE + // Thread.sleep() | |
262 JVMTI_THREAD_STATE_WAITING + | |
263 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + | |
264 JVMTI_THREAD_STATE_SLEEPING, | |
265 IN_OBJECT_WAIT = JVMTI_THREAD_STATE_ALIVE + // Object.wait() | |
266 JVMTI_THREAD_STATE_WAITING + | |
267 JVMTI_THREAD_STATE_WAITING_INDEFINITELY + | |
268 JVMTI_THREAD_STATE_IN_OBJECT_WAIT, | |
269 IN_OBJECT_WAIT_TIMED = JVMTI_THREAD_STATE_ALIVE + // Object.wait(long) | |
270 JVMTI_THREAD_STATE_WAITING + | |
271 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + | |
272 JVMTI_THREAD_STATE_IN_OBJECT_WAIT, | |
273 PARKED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park() | |
274 JVMTI_THREAD_STATE_WAITING + | |
275 JVMTI_THREAD_STATE_WAITING_INDEFINITELY + | |
276 JVMTI_THREAD_STATE_PARKED, | |
277 PARKED_TIMED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park(long) | |
278 JVMTI_THREAD_STATE_WAITING + | |
279 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + | |
280 JVMTI_THREAD_STATE_PARKED, | |
281 BLOCKED_ON_MONITOR_ENTER = JVMTI_THREAD_STATE_ALIVE + // (re-)entering a synchronization block | |
282 JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER, | |
283 TERMINATED = JVMTI_THREAD_STATE_TERMINATED | |
284 }; | |
285 // Write thread status info to threadStatus field of java.lang.Thread. | |
286 static void set_thread_status(oop java_thread_oop, ThreadStatus status); | |
287 // Read thread status info from threadStatus field of java.lang.Thread. | |
288 static ThreadStatus get_thread_status(oop java_thread_oop); | |
289 | |
290 static const char* thread_status_name(oop java_thread_oop); | |
291 | |
292 // Debugging | |
293 friend class JavaClasses; | |
294 }; | |
295 | |
296 // Interface to java.lang.ThreadGroup objects | |
297 | |
298 class java_lang_ThreadGroup : AllStatic { | |
299 private: | |
300 static int _parent_offset; | |
301 static int _name_offset; | |
302 static int _threads_offset; | |
303 static int _groups_offset; | |
304 static int _maxPriority_offset; | |
305 static int _destroyed_offset; | |
306 static int _daemon_offset; | |
307 static int _vmAllowSuspension_offset; | |
308 static int _nthreads_offset; | |
309 static int _ngroups_offset; | |
310 | |
311 static void compute_offsets(); | |
312 | |
313 public: | |
314 // parent ThreadGroup | |
315 static oop parent(oop java_thread_group); | |
316 // name | |
317 static typeArrayOop name(oop java_thread_group); | |
318 // ("name as oop" accessor is not necessary) | |
319 // Number of threads in group | |
320 static int nthreads(oop java_thread_group); | |
321 // threads | |
322 static objArrayOop threads(oop java_thread_group); | |
323 // Number of threads in group | |
324 static int ngroups(oop java_thread_group); | |
325 // groups | |
326 static objArrayOop groups(oop java_thread_group); | |
327 // maxPriority in group | |
328 static ThreadPriority maxPriority(oop java_thread_group); | |
329 // Destroyed | |
330 static bool is_destroyed(oop java_thread_group); | |
331 // Daemon | |
332 static bool is_daemon(oop java_thread_group); | |
333 // vmAllowSuspension | |
334 static bool is_vmAllowSuspension(oop java_thread_group); | |
335 // Debugging | |
336 friend class JavaClasses; | |
337 }; | |
338 | |
339 | |
340 | |
341 // Interface to java.lang.Throwable objects | |
342 | |
343 class java_lang_Throwable: AllStatic { | |
344 friend class BacktraceBuilder; | |
345 | |
346 private: | |
347 // Offsets | |
348 enum { | |
349 hc_backtrace_offset = 0, | |
350 hc_detailMessage_offset = 1, | |
351 hc_cause_offset = 2, // New since 1.4 | |
352 hc_stackTrace_offset = 3 // New since 1.4 | |
353 }; | |
354 // Trace constants | |
355 enum { | |
356 trace_methods_offset = 0, | |
357 trace_bcis_offset = 1, | |
358 trace_next_offset = 2, | |
359 trace_size = 3, | |
360 trace_chunk_size = 32 | |
361 }; | |
362 | |
363 static int backtrace_offset; | |
364 static int detailMessage_offset; | |
365 static int cause_offset; | |
366 static int stackTrace_offset; | |
367 | |
368 // Printing | |
369 static char* print_stack_element_to_buffer(methodOop method, int bci); | |
370 static void print_to_stream(Handle stream, const char* str); | |
371 // StackTrace (programmatic access, new since 1.4) | |
372 static void clear_stacktrace(oop throwable); | |
373 // No stack trace available | |
374 static const char* no_stack_trace_message(); | |
375 | |
376 public: | |
377 // Backtrace | |
378 static oop backtrace(oop throwable); | |
379 static void set_backtrace(oop throwable, oop value); | |
380 // Needed by JVMTI to filter out this internal field. | |
381 static int get_backtrace_offset() { return backtrace_offset;} | |
382 static int get_detailMessage_offset() { return detailMessage_offset;} | |
383 // Message | |
384 static oop message(oop throwable); | |
385 static oop message(Handle throwable); | |
386 static void set_message(oop throwable, oop value); | |
387 // Print stack trace stored in exception by call-back to Java | |
388 // Note: this is no longer used in Merlin, but we still suppport | |
389 // it for compatibility. | |
390 static void print_stack_trace(oop throwable, oop print_stream); | |
391 static void print_stack_element(Handle stream, methodOop method, int bci); | |
392 static void print_stack_element(outputStream *st, methodOop method, int bci); | |
393 static void print_stack_usage(Handle stream); | |
394 | |
395 // Allocate space for backtrace (created but stack trace not filled in) | |
396 static void allocate_backtrace(Handle throwable, TRAPS); | |
397 // Fill in current stack trace for throwable with preallocated backtrace (no GC) | |
398 static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable); | |
399 | |
400 // Fill in current stack trace, can cause GC | |
401 static void fill_in_stack_trace(Handle throwable, TRAPS); | |
402 static void fill_in_stack_trace(Handle throwable); | |
403 // Programmatic access to stack trace | |
404 static oop get_stack_trace_element(oop throwable, int index, TRAPS); | |
405 static int get_stack_trace_depth(oop throwable, TRAPS); | |
406 // Printing | |
407 static void print(oop throwable, outputStream* st); | |
408 static void print(Handle throwable, outputStream* st); | |
409 static void print_stack_trace(oop throwable, outputStream* st); | |
410 // Debugging | |
411 friend class JavaClasses; | |
412 }; | |
413 | |
414 | |
415 // Interface to java.lang.reflect.AccessibleObject objects | |
416 | |
417 class java_lang_reflect_AccessibleObject: AllStatic { | |
418 private: | |
419 // Note that to reduce dependencies on the JDK we compute these | |
420 // offsets at run-time. | |
421 static int override_offset; | |
422 | |
423 static void compute_offsets(); | |
424 | |
425 public: | |
426 // Accessors | |
427 static jboolean override(oop reflect); | |
428 static void set_override(oop reflect, jboolean value); | |
429 | |
430 // Debugging | |
431 friend class JavaClasses; | |
432 }; | |
433 | |
434 | |
435 // Interface to java.lang.reflect.Method objects | |
436 | |
437 class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject { | |
438 private: | |
439 // Note that to reduce dependencies on the JDK we compute these | |
440 // offsets at run-time. | |
441 static int clazz_offset; | |
442 static int name_offset; | |
443 static int returnType_offset; | |
444 static int parameterTypes_offset; | |
445 static int exceptionTypes_offset; | |
446 static int slot_offset; | |
447 static int modifiers_offset; | |
448 static int signature_offset; | |
449 static int annotations_offset; | |
450 static int parameter_annotations_offset; | |
451 static int annotation_default_offset; | |
452 | |
453 static void compute_offsets(); | |
454 | |
455 public: | |
456 // Allocation | |
457 static Handle create(TRAPS); | |
458 | |
459 // Accessors | |
460 static oop clazz(oop reflect); | |
461 static void set_clazz(oop reflect, oop value); | |
462 | |
463 static oop name(oop method); | |
464 static void set_name(oop method, oop value); | |
465 | |
466 static oop return_type(oop method); | |
467 static void set_return_type(oop method, oop value); | |
468 | |
469 static oop parameter_types(oop method); | |
470 static void set_parameter_types(oop method, oop value); | |
471 | |
472 static oop exception_types(oop method); | |
473 static void set_exception_types(oop method, oop value); | |
474 | |
475 static int slot(oop reflect); | |
476 static void set_slot(oop reflect, int value); | |
477 | |
478 static int modifiers(oop method); | |
479 static void set_modifiers(oop method, int value); | |
480 | |
481 static bool has_signature_field(); | |
482 static oop signature(oop method); | |
483 static void set_signature(oop method, oop value); | |
484 | |
485 static bool has_annotations_field(); | |
486 static oop annotations(oop method); | |
487 static void set_annotations(oop method, oop value); | |
488 | |
489 static bool has_parameter_annotations_field(); | |
490 static oop parameter_annotations(oop method); | |
491 static void set_parameter_annotations(oop method, oop value); | |
492 | |
493 static bool has_annotation_default_field(); | |
494 static oop annotation_default(oop method); | |
495 static void set_annotation_default(oop method, oop value); | |
496 | |
497 // Debugging | |
498 friend class JavaClasses; | |
499 }; | |
500 | |
501 | |
502 // Interface to java.lang.reflect.Constructor objects | |
503 | |
504 class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject { | |
505 private: | |
506 // Note that to reduce dependencies on the JDK we compute these | |
507 // offsets at run-time. | |
508 static int clazz_offset; | |
509 static int parameterTypes_offset; | |
510 static int exceptionTypes_offset; | |
511 static int slot_offset; | |
512 static int modifiers_offset; | |
513 static int signature_offset; | |
514 static int annotations_offset; | |
515 static int parameter_annotations_offset; | |
516 | |
517 static void compute_offsets(); | |
518 | |
519 public: | |
520 // Allocation | |
521 static Handle create(TRAPS); | |
522 | |
523 // Accessors | |
524 static oop clazz(oop reflect); | |
525 static void set_clazz(oop reflect, oop value); | |
526 | |
527 static oop parameter_types(oop constructor); | |
528 static void set_parameter_types(oop constructor, oop value); | |
529 | |
530 static oop exception_types(oop constructor); | |
531 static void set_exception_types(oop constructor, oop value); | |
532 | |
533 static int slot(oop reflect); | |
534 static void set_slot(oop reflect, int value); | |
535 | |
536 static int modifiers(oop constructor); | |
537 static void set_modifiers(oop constructor, int value); | |
538 | |
539 static bool has_signature_field(); | |
540 static oop signature(oop constructor); | |
541 static void set_signature(oop constructor, oop value); | |
542 | |
543 static bool has_annotations_field(); | |
544 static oop annotations(oop constructor); | |
545 static void set_annotations(oop constructor, oop value); | |
546 | |
547 static bool has_parameter_annotations_field(); | |
548 static oop parameter_annotations(oop method); | |
549 static void set_parameter_annotations(oop method, oop value); | |
550 | |
551 // Debugging | |
552 friend class JavaClasses; | |
553 }; | |
554 | |
555 | |
556 // Interface to java.lang.reflect.Field objects | |
557 | |
558 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject { | |
559 private: | |
560 // Note that to reduce dependencies on the JDK we compute these | |
561 // offsets at run-time. | |
562 static int clazz_offset; | |
563 static int name_offset; | |
564 static int type_offset; | |
565 static int slot_offset; | |
566 static int modifiers_offset; | |
567 static int signature_offset; | |
568 static int annotations_offset; | |
569 | |
570 static void compute_offsets(); | |
571 | |
572 public: | |
573 // Allocation | |
574 static Handle create(TRAPS); | |
575 | |
576 // Accessors | |
577 static oop clazz(oop reflect); | |
578 static void set_clazz(oop reflect, oop value); | |
579 | |
580 static oop name(oop field); | |
581 static void set_name(oop field, oop value); | |
582 | |
583 static oop type(oop field); | |
584 static void set_type(oop field, oop value); | |
585 | |
586 static int slot(oop reflect); | |
587 static void set_slot(oop reflect, int value); | |
588 | |
589 static int modifiers(oop field); | |
590 static void set_modifiers(oop field, int value); | |
591 | |
592 static bool has_signature_field(); | |
593 static oop signature(oop constructor); | |
594 static void set_signature(oop constructor, oop value); | |
595 | |
596 static bool has_annotations_field(); | |
597 static oop annotations(oop constructor); | |
598 static void set_annotations(oop constructor, oop value); | |
599 | |
600 static bool has_parameter_annotations_field(); | |
601 static oop parameter_annotations(oop method); | |
602 static void set_parameter_annotations(oop method, oop value); | |
603 | |
604 static bool has_annotation_default_field(); | |
605 static oop annotation_default(oop method); | |
606 static void set_annotation_default(oop method, oop value); | |
607 | |
608 // Debugging | |
609 friend class JavaClasses; | |
610 }; | |
611 | |
612 // Interface to sun.reflect.ConstantPool objects | |
613 class sun_reflect_ConstantPool { | |
614 private: | |
615 // Note that to reduce dependencies on the JDK we compute these | |
616 // offsets at run-time. | |
617 static int _cp_oop_offset; | |
618 | |
619 static void compute_offsets(); | |
620 | |
621 public: | |
622 // Allocation | |
623 static Handle create(TRAPS); | |
624 | |
625 // Accessors | |
626 static oop cp_oop(oop reflect); | |
627 static void set_cp_oop(oop reflect, oop value); | |
628 static int cp_oop_offset() { | |
629 return _cp_oop_offset; | |
630 } | |
631 | |
632 // Debugging | |
633 friend class JavaClasses; | |
634 }; | |
635 | |
636 // Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects | |
637 class sun_reflect_UnsafeStaticFieldAccessorImpl { | |
638 private: | |
639 static int _base_offset; | |
640 static void compute_offsets(); | |
641 | |
642 public: | |
643 static int base_offset() { | |
644 return _base_offset; | |
645 } | |
646 | |
647 // Debugging | |
648 friend class JavaClasses; | |
649 }; | |
650 | |
651 // Interface to java.lang primitive type boxing objects: | |
652 // - java.lang.Boolean | |
653 // - java.lang.Character | |
654 // - java.lang.Float | |
655 // - java.lang.Double | |
656 // - java.lang.Byte | |
657 // - java.lang.Short | |
658 // - java.lang.Integer | |
659 // - java.lang.Long | |
660 | |
661 // This could be separated out into 8 individual classes. | |
662 | |
663 class java_lang_boxing_object: AllStatic { | |
664 private: | |
665 enum { | |
666 hc_value_offset = 0 | |
667 }; | |
668 static int value_offset; | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
669 static int long_value_offset; |
0 | 670 |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
671 static oop initialize_and_allocate(BasicType type, TRAPS); |
0 | 672 public: |
673 // Allocation. Returns a boxed value, or NULL for invalid type. | |
674 static oop create(BasicType type, jvalue* value, TRAPS); | |
675 // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop. | |
676 static BasicType get_value(oop box, jvalue* value); | |
677 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
|
678 static BasicType basic_type(oop box); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
679 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
|
680 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
|
681 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
|
682 static void print(BasicType type, jvalue* value, outputStream* st); |
0 | 683 |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
684 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
|
685 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
|
686 value_offset; |
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
687 } |
0 | 688 |
689 // Debugging | |
690 friend class JavaClasses; | |
691 }; | |
692 | |
693 | |
694 | |
695 // Interface to java.lang.ref.Reference objects | |
696 | |
697 class java_lang_ref_Reference: AllStatic { | |
698 public: | |
699 enum { | |
700 hc_referent_offset = 0, | |
701 hc_queue_offset = 1, | |
702 hc_next_offset = 2, | |
703 hc_discovered_offset = 3 // Is not last, see SoftRefs. | |
704 }; | |
705 enum { | |
706 hc_static_lock_offset = 0, | |
707 hc_static_pending_offset = 1 | |
708 }; | |
709 | |
710 static int referent_offset; | |
711 static int queue_offset; | |
712 static int next_offset; | |
713 static int discovered_offset; | |
714 static int static_lock_offset; | |
715 static int static_pending_offset; | |
716 static int number_of_fake_oop_fields; | |
717 | |
718 // Accessors | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
719 static oop referent(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
720 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
|
721 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
722 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
|
723 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
|
724 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
725 static void set_referent_raw(oop ref, oop value) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
726 ref->obj_field_raw_put(referent_offset, value); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
727 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
728 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
|
729 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
|
730 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
731 static oop next(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
732 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
|
733 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
734 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
|
735 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
|
736 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
737 static void set_next_raw(oop ref, oop value) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
738 ref->obj_field_raw_put(next_offset, value); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
739 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
740 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
|
741 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
|
742 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
743 static oop discovered(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
744 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
|
745 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
746 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
|
747 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
|
748 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
749 static void set_discovered_raw(oop ref, oop value) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
750 ref->obj_field_raw_put(discovered_offset, value); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
751 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
752 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
|
753 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
|
754 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
755 // Accessors for statics |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
756 static oop pending_list_lock(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
757 static oop pending_list(); |
0 | 758 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
759 static HeapWord* pending_list_addr(); |
0 | 760 }; |
761 | |
762 | |
763 // Interface to java.lang.ref.SoftReference objects | |
764 | |
765 class java_lang_ref_SoftReference: public java_lang_ref_Reference { | |
766 public: | |
767 enum { | |
768 // 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
|
769 hc_timestamp_offset = hc_discovered_offset + 1 |
0 | 770 }; |
771 enum { | |
772 hc_static_clock_offset = 0 | |
773 }; | |
774 | |
775 static int timestamp_offset; | |
776 static int static_clock_offset; | |
777 | |
778 // Accessors | |
779 static jlong timestamp(oop ref); | |
780 | |
781 // Accessors for statics | |
782 static jlong clock(); | |
783 static void set_clock(jlong value); | |
784 }; | |
785 | |
786 | |
710 | 787 // Interface to java.dyn.MethodHandle objects |
788 | |
789 class MethodHandleEntry; | |
790 | |
791 class java_dyn_MethodHandle: AllStatic { | |
792 friend class JavaClasses; | |
793 | |
794 private: | |
795 static int _vmentry_offset; // assembly code trampoline for MH | |
796 static int _vmtarget_offset; // class-specific target reference | |
797 static int _type_offset; // the MethodType of this MH | |
798 static int _vmslots_offset; // OPTIONAL hoisted type.form.vmslots | |
799 | |
800 static void compute_offsets(); | |
801 | |
802 public: | |
803 // Accessors | |
804 static oop type(oop mh); | |
805 static void set_type(oop mh, oop mtype); | |
806 | |
807 static oop vmtarget(oop mh); | |
808 static void set_vmtarget(oop mh, oop target); | |
809 | |
810 static MethodHandleEntry* vmentry(oop mh); | |
811 static void set_vmentry(oop mh, MethodHandleEntry* data); | |
812 | |
813 static int vmslots(oop mh); | |
814 static void init_vmslots(oop mh); | |
815 static int compute_vmslots(oop mh); | |
816 | |
817 // Testers | |
818 static bool is_subclass(klassOop klass) { | |
819 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass()); | |
820 } | |
821 static bool is_instance(oop obj) { | |
822 return obj != NULL && is_subclass(obj->klass()); | |
823 } | |
824 | |
825 // Accessors for code generation: | |
826 static int type_offset_in_bytes() { return _type_offset; } | |
827 static int vmtarget_offset_in_bytes() { return _vmtarget_offset; } | |
828 static int vmentry_offset_in_bytes() { return _vmentry_offset; } | |
829 static int vmslots_offset_in_bytes() { return _vmslots_offset; } | |
830 }; | |
831 | |
832 class sun_dyn_DirectMethodHandle: public java_dyn_MethodHandle { | |
833 friend class JavaClasses; | |
834 | |
835 private: | |
836 // _vmtarget_offset; // method or class or interface | |
837 static int _vmindex_offset; // negative or vtable idx or itable idx | |
838 static void compute_offsets(); | |
839 | |
840 public: | |
841 // Accessors | |
842 static int vmindex(oop mh); | |
843 static void set_vmindex(oop mh, int index); | |
844 | |
845 // Testers | |
846 static bool is_subclass(klassOop klass) { | |
847 return Klass::cast(klass)->is_subclass_of(SystemDictionary::DirectMethodHandle_klass()); | |
848 } | |
849 static bool is_instance(oop obj) { | |
850 return obj != NULL && is_subclass(obj->klass()); | |
851 } | |
852 | |
853 // Accessors for code generation: | |
854 static int vmindex_offset_in_bytes() { return _vmindex_offset; } | |
855 }; | |
856 | |
857 class sun_dyn_BoundMethodHandle: public java_dyn_MethodHandle { | |
858 friend class JavaClasses; | |
859 | |
860 private: | |
861 static int _argument_offset; // argument value bound into this MH | |
862 static int _vmargslot_offset; // relevant argument slot (<= vmslots) | |
863 static void compute_offsets(); | |
864 | |
865 public: | |
866 static oop argument(oop mh); | |
867 static void set_argument(oop mh, oop ref); | |
868 | |
869 static jint vmargslot(oop mh); | |
870 static void set_vmargslot(oop mh, jint slot); | |
871 | |
872 // Testers | |
873 static bool is_subclass(klassOop klass) { | |
874 return Klass::cast(klass)->is_subclass_of(SystemDictionary::BoundMethodHandle_klass()); | |
875 } | |
876 static bool is_instance(oop obj) { | |
877 return obj != NULL && is_subclass(obj->klass()); | |
878 } | |
879 | |
880 static int argument_offset_in_bytes() { return _argument_offset; } | |
881 static int vmargslot_offset_in_bytes() { return _vmargslot_offset; } | |
882 }; | |
883 | |
884 class sun_dyn_AdapterMethodHandle: public sun_dyn_BoundMethodHandle { | |
885 friend class JavaClasses; | |
886 | |
887 private: | |
888 static int _conversion_offset; // type of conversion to apply | |
889 static void compute_offsets(); | |
890 | |
891 public: | |
892 static int conversion(oop mh); | |
893 static void set_conversion(oop mh, int conv); | |
894 | |
895 // Testers | |
896 static bool is_subclass(klassOop klass) { | |
897 return Klass::cast(klass)->is_subclass_of(SystemDictionary::AdapterMethodHandle_klass()); | |
898 } | |
899 static bool is_instance(oop obj) { | |
900 return obj != NULL && is_subclass(obj->klass()); | |
901 } | |
902 | |
903 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants): | |
904 enum { | |
905 OP_RETYPE_ONLY = 0x0, // no argument changes; straight retype | |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
906 OP_RETYPE_RAW = 0x1, // straight retype, trusted (void->int, Object->T) |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
907 OP_CHECK_CAST = 0x2, // ref-to-ref conversion; requires a Class argument |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
908 OP_PRIM_TO_PRIM = 0x3, // converts from one primitive to another |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
909 OP_REF_TO_PRIM = 0x4, // unboxes a wrapper to produce a primitive |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
910 OP_PRIM_TO_REF = 0x5, // boxes a primitive into a wrapper (NYI) |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
911 OP_SWAP_ARGS = 0x6, // swap arguments (vminfo is 2nd arg) |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
912 OP_ROT_ARGS = 0x7, // rotate arguments (vminfo is displaced arg) |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
913 OP_DUP_ARGS = 0x8, // duplicates one or more arguments (at TOS) |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
914 OP_DROP_ARGS = 0x9, // remove one or more argument slots |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
915 OP_COLLECT_ARGS = 0xA, // combine one or more arguments into a varargs (NYI) |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
916 OP_SPREAD_ARGS = 0xB, // expand in place a varargs array (of known size) |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
917 OP_FLYBY = 0xC, // operate first on reified argument list (NYI) |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
918 OP_RICOCHET = 0xD, // run an adapter chain on the return value (NYI) |
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
919 CONV_OP_LIMIT = 0xE, // limit of CONV_OP enumeration |
710 | 920 |
921 CONV_OP_MASK = 0xF00, // this nybble contains the conversion op field | |
922 CONV_VMINFO_MASK = 0x0FF, // LSB is reserved for JVM use | |
923 CONV_VMINFO_SHIFT = 0, // position of bits in CONV_VMINFO_MASK | |
924 CONV_OP_SHIFT = 8, // position of bits in CONV_OP_MASK | |
925 CONV_DEST_TYPE_SHIFT = 12, // byte 2 has the adapter BasicType (if needed) | |
926 CONV_SRC_TYPE_SHIFT = 16, // byte 2 has the source BasicType (if needed) | |
927 CONV_STACK_MOVE_SHIFT = 20, // high 12 bits give signed SP change | |
928 CONV_STACK_MOVE_MASK = (1 << (32 - CONV_STACK_MOVE_SHIFT)) - 1 | |
929 }; | |
930 | |
931 static int conversion_offset_in_bytes() { return _conversion_offset; } | |
932 }; | |
933 | |
934 | |
935 // Interface to sun.dyn.MemberName objects | |
936 // (These are a private interface for Java code to query the class hierarchy.) | |
937 | |
938 class sun_dyn_MemberName: AllStatic { | |
939 friend class JavaClasses; | |
940 | |
941 private: | |
942 // From java.dyn.MemberName: | |
943 // private Class<?> clazz; // class in which the method is defined | |
944 // private String name; // may be null if not yet materialized | |
945 // private Object type; // may be null if not yet materialized | |
946 // private int flags; // modifier bits; see reflect.Modifier | |
947 // private Object vmtarget; // VM-specific target value | |
948 // private int vmindex; // method index within class or interface | |
949 static int _clazz_offset; | |
950 static int _name_offset; | |
951 static int _type_offset; | |
952 static int _flags_offset; | |
953 static int _vmtarget_offset; | |
954 static int _vmindex_offset; | |
955 | |
956 static void compute_offsets(); | |
957 | |
958 public: | |
959 // Accessors | |
960 static oop clazz(oop mname); | |
961 static void set_clazz(oop mname, oop clazz); | |
962 | |
963 static oop type(oop mname); | |
964 static void set_type(oop mname, oop type); | |
965 | |
966 static oop name(oop mname); | |
967 static void set_name(oop mname, oop name); | |
968 | |
969 static int flags(oop mname); | |
970 static void set_flags(oop mname, int flags); | |
971 | |
972 static int modifiers(oop mname) { return (u2) flags(mname); } | |
973 static void set_modifiers(oop mname, int mods) | |
974 { set_flags(mname, (flags(mname) &~ (u2)-1) | (u2)mods); } | |
975 | |
976 static oop vmtarget(oop mname); | |
977 static void set_vmtarget(oop mname, oop target); | |
978 | |
979 static int vmindex(oop mname); | |
980 static void set_vmindex(oop mname, int index); | |
981 | |
982 // Testers | |
983 static bool is_subclass(klassOop klass) { | |
984 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MemberName_klass()); | |
985 } | |
986 static bool is_instance(oop obj) { | |
987 return obj != NULL && is_subclass(obj->klass()); | |
988 } | |
989 | |
990 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants): | |
991 enum { | |
992 MN_IS_METHOD = 0x00010000, // method (not constructor) | |
993 MN_IS_CONSTRUCTOR = 0x00020000, // constructor | |
994 MN_IS_FIELD = 0x00040000, // field | |
995 MN_IS_TYPE = 0x00080000, // nested type | |
996 MN_SEARCH_SUPERCLASSES = 0x00100000, // for MHN.getMembers | |
997 MN_SEARCH_INTERFACES = 0x00200000, // for MHN.getMembers | |
998 VM_INDEX_UNINITIALIZED = -99 | |
999 }; | |
1000 | |
1001 // Accessors for code generation: | |
1002 static int clazz_offset_in_bytes() { return _clazz_offset; } | |
1003 static int type_offset_in_bytes() { return _type_offset; } | |
1004 static int name_offset_in_bytes() { return _name_offset; } | |
1005 static int flags_offset_in_bytes() { return _flags_offset; } | |
1006 static int vmtarget_offset_in_bytes() { return _vmtarget_offset; } | |
1007 static int vmindex_offset_in_bytes() { return _vmindex_offset; } | |
1008 }; | |
1009 | |
1010 | |
1011 // Interface to java.dyn.MethodType objects | |
1012 | |
1013 class java_dyn_MethodType: AllStatic { | |
1014 friend class JavaClasses; | |
1015 | |
1016 private: | |
1017 static int _rtype_offset; | |
1018 static int _ptypes_offset; | |
1019 static int _form_offset; | |
1020 | |
1021 static void compute_offsets(); | |
1022 | |
1023 public: | |
1024 // Accessors | |
1025 static oop rtype(oop mt); | |
1026 static objArrayOop ptypes(oop mt); | |
1027 static oop form(oop mt); | |
1028 | |
1029 static oop ptype(oop mt, int index); | |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
1059
diff
changeset
|
1030 static int ptype_count(oop mt); |
710 | 1031 |
1032 static symbolOop as_signature(oop mt, bool intern_if_not_found, TRAPS); | |
1033 static void print_signature(oop mt, outputStream* st); | |
1034 | |
1035 static bool is_instance(oop obj) { | |
1036 return obj != NULL && obj->klass() == SystemDictionary::MethodType_klass(); | |
1037 } | |
1038 | |
1039 // Accessors for code generation: | |
1040 static int rtype_offset_in_bytes() { return _rtype_offset; } | |
1041 static int ptypes_offset_in_bytes() { return _ptypes_offset; } | |
1042 static int form_offset_in_bytes() { return _form_offset; } | |
1043 }; | |
1044 | |
1045 class java_dyn_MethodTypeForm: AllStatic { | |
1046 friend class JavaClasses; | |
1047 | |
1048 private: | |
1049 static int _vmslots_offset; // number of argument slots needed | |
1050 static int _erasedType_offset; // erasedType = canonical MethodType | |
1051 | |
1052 static void compute_offsets(); | |
1053 | |
1054 public: | |
1055 // Accessors | |
1056 static int vmslots(oop mtform); | |
1057 static oop erasedType(oop mtform); | |
1058 | |
1059 // Accessors for code generation: | |
1060 static int vmslots_offset_in_bytes() { return _vmslots_offset; } | |
1061 static int erasedType_offset_in_bytes() { return _erasedType_offset; } | |
1062 }; | |
1063 | |
1064 | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
1039
diff
changeset
|
1065 // Interface to java.dyn.CallSite objects |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1066 |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
1039
diff
changeset
|
1067 class java_dyn_CallSite: AllStatic { |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1068 friend class JavaClasses; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1069 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1070 private: |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1071 static int _type_offset; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1072 static int _target_offset; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1073 static int _vmmethod_offset; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1074 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1075 static void compute_offsets(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1076 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1077 public: |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1078 // Accessors |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1079 static oop type(oop site); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1080 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1081 static oop target(oop site); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1082 static void set_target(oop site, oop target); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1083 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1084 static oop vmmethod(oop site); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1085 static void set_vmmethod(oop site, oop ref); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1086 |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1087 // Testers |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1088 static bool is_subclass(klassOop klass) { |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1089 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
|
1090 } |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1091 static bool is_instance(oop obj) { |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1092 return obj != NULL && is_subclass(obj->klass()); |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1093 } |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1094 |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1095 // Accessors for code generation: |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1096 static int target_offset_in_bytes() { return _target_offset; } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1097 static int type_offset_in_bytes() { return _type_offset; } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1098 static int vmmethod_offset_in_bytes() { return _vmmethod_offset; } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1099 }; |
710 | 1100 |
1101 | |
0 | 1102 // Interface to java.security.AccessControlContext objects |
1103 | |
1104 class java_security_AccessControlContext: AllStatic { | |
1105 private: | |
1106 // Note that for this class the layout changed between JDK1.2 and JDK1.3, | |
1107 // so we compute the offsets at startup rather than hard-wiring them. | |
1108 static int _context_offset; | |
1109 static int _privilegedContext_offset; | |
1110 static int _isPrivileged_offset; | |
1111 | |
1112 static void compute_offsets(); | |
1113 public: | |
1114 static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS); | |
1115 | |
1116 // Debugging/initialization | |
1117 friend class JavaClasses; | |
1118 }; | |
1119 | |
1120 | |
1121 // Interface to java.lang.ClassLoader objects | |
1122 | |
1123 class java_lang_ClassLoader : AllStatic { | |
1124 private: | |
1125 enum { | |
1126 hc_parent_offset = 0 | |
1127 }; | |
1128 | |
1129 static int parent_offset; | |
1130 | |
1131 public: | |
1132 static oop parent(oop loader); | |
1133 | |
1134 static bool is_trusted_loader(oop loader); | |
1135 | |
1136 // Fix for 4474172 | |
1137 static oop non_reflection_class_loader(oop loader); | |
1138 | |
1139 // Debugging | |
1140 friend class JavaClasses; | |
1141 }; | |
1142 | |
1143 | |
1144 // Interface to java.lang.System objects | |
1145 | |
1146 class java_lang_System : AllStatic { | |
1147 private: | |
1148 enum { | |
1149 hc_static_in_offset = 0, | |
1150 hc_static_out_offset = 1, | |
1151 hc_static_err_offset = 2 | |
1152 }; | |
1153 | |
1154 static int offset_of_static_fields; | |
1155 static int static_in_offset; | |
1156 static int static_out_offset; | |
1157 static int static_err_offset; | |
1158 | |
1159 static void compute_offsets(); | |
1160 | |
1161 public: | |
1162 static int in_offset_in_bytes(); | |
1163 static int out_offset_in_bytes(); | |
1164 static int err_offset_in_bytes(); | |
1165 | |
1166 // Debugging | |
1167 friend class JavaClasses; | |
1168 }; | |
1169 | |
1170 | |
1171 // Interface to java.lang.StackTraceElement objects | |
1172 | |
1173 class java_lang_StackTraceElement: AllStatic { | |
1174 private: | |
1175 enum { | |
1176 hc_declaringClass_offset = 0, | |
1177 hc_methodName_offset = 1, | |
1178 hc_fileName_offset = 2, | |
1179 hc_lineNumber_offset = 3 | |
1180 }; | |
1181 | |
1182 static int declaringClass_offset; | |
1183 static int methodName_offset; | |
1184 static int fileName_offset; | |
1185 static int lineNumber_offset; | |
1186 | |
1187 public: | |
1188 // Setters | |
1189 static void set_declaringClass(oop element, oop value); | |
1190 static void set_methodName(oop element, oop value); | |
1191 static void set_fileName(oop element, oop value); | |
1192 static void set_lineNumber(oop element, int value); | |
1193 | |
1194 // Create an instance of StackTraceElement | |
1195 static oop create(methodHandle m, int bci, TRAPS); | |
1196 | |
1197 // Debugging | |
1198 friend class JavaClasses; | |
1199 }; | |
1200 | |
1201 | |
1202 // Interface to java.lang.AssertionStatusDirectives objects | |
1203 | |
1204 class java_lang_AssertionStatusDirectives: AllStatic { | |
1205 private: | |
1206 enum { | |
1207 hc_classes_offset, | |
1208 hc_classEnabled_offset, | |
1209 hc_packages_offset, | |
1210 hc_packageEnabled_offset, | |
1211 hc_deflt_offset | |
1212 }; | |
1213 | |
1214 static int classes_offset; | |
1215 static int classEnabled_offset; | |
1216 static int packages_offset; | |
1217 static int packageEnabled_offset; | |
1218 static int deflt_offset; | |
1219 | |
1220 public: | |
1221 // Setters | |
1222 static void set_classes(oop obj, oop val); | |
1223 static void set_classEnabled(oop obj, oop val); | |
1224 static void set_packages(oop obj, oop val); | |
1225 static void set_packageEnabled(oop obj, oop val); | |
1226 static void set_deflt(oop obj, bool val); | |
1227 // Debugging | |
1228 friend class JavaClasses; | |
1229 }; | |
1230 | |
1231 | |
1232 class java_nio_Buffer: AllStatic { | |
1233 private: | |
1234 static int _limit_offset; | |
1235 | |
1236 public: | |
1237 static int limit_offset(); | |
1238 static void compute_offsets(); | |
1239 }; | |
1240 | |
1241 class sun_misc_AtomicLongCSImpl: AllStatic { | |
1242 private: | |
1243 static int _value_offset; | |
1244 | |
1245 public: | |
1246 static int value_offset(); | |
1247 static void compute_offsets(); | |
1248 }; | |
1249 | |
1250 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic { | |
1251 private: | |
1252 static int _owner_offset; | |
1253 public: | |
1254 static void initialize(TRAPS); | |
1255 static oop get_owner_threadObj(oop obj); | |
1256 }; | |
1257 | |
1258 // Interface to hard-coded offset checking | |
1259 | |
1260 class JavaClasses : AllStatic { | |
1261 private: | |
1262 static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; | |
1263 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
|
1264 static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
0 | 1265 public: |
1266 static void compute_hard_coded_offsets(); | |
1267 static void compute_offsets(); | |
1268 static void check_offsets() PRODUCT_RETURN; | |
1269 }; |