Mercurial > hg > truffle
annotate src/share/vm/classfile/javaClasses.hpp @ 613:5caef2219893
Merge
author | dcubed |
---|---|
date | Mon, 02 Mar 2009 16:56:51 -0700 |
parents | c81d2ef51ca3 |
children | 0fbdb4381b99 |
rev | line source |
---|---|
0 | 1 /* |
196 | 2 * Copyright 1997-2008 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); | |
110 | |
111 // Testers | |
112 static bool is_instance(oop obj) { | |
113 return obj != NULL && obj->klass() == SystemDictionary::string_klass(); | |
114 } | |
115 | |
116 // Debugging | |
117 static void print(Handle java_string, outputStream* st); | |
118 friend class JavaClasses; | |
119 }; | |
120 | |
121 | |
122 // Interface to java.lang.Class objects | |
123 | |
124 class java_lang_Class : AllStatic { | |
125 friend class VMStructs; | |
126 private: | |
127 // The fake offsets are added by the class loader when java.lang.Class is loaded | |
128 | |
129 enum { | |
130 hc_klass_offset = 0, | |
131 hc_array_klass_offset = 1, | |
132 hc_resolved_constructor_offset = 2, | |
133 hc_number_of_fake_oop_fields = 3 | |
134 }; | |
135 | |
136 static int klass_offset; | |
137 static int resolved_constructor_offset; | |
138 static int array_klass_offset; | |
139 static int number_of_fake_oop_fields; | |
140 | |
141 static void compute_offsets(); | |
142 static bool offsets_computed; | |
143 static int classRedefinedCount_offset; | |
514 | 144 static int parallelCapable_offset; |
0 | 145 |
146 public: | |
147 // Instance creation | |
148 static oop create_mirror(KlassHandle k, TRAPS); | |
149 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); | |
150 // Conversion | |
151 static klassOop as_klassOop(oop java_class); | |
152 // Testing | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
153 static bool is_instance(oop obj) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
154 return obj != NULL && obj->klass() == SystemDictionary::class_klass(); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
155 } |
0 | 156 static bool is_primitive(oop java_class); |
157 static BasicType primitive_type(oop java_class); | |
158 static oop primitive_mirror(BasicType t); | |
159 // JVM_NewInstance support | |
160 static methodOop resolved_constructor(oop java_class); | |
161 static void set_resolved_constructor(oop java_class, methodOop constructor); | |
162 // JVM_NewArray support | |
163 static klassOop array_klass(oop java_class); | |
164 static void set_array_klass(oop java_class, klassOop klass); | |
165 // compiler support for class operations | |
166 static int klass_offset_in_bytes() { return klass_offset; } | |
167 static int resolved_constructor_offset_in_bytes() { return resolved_constructor_offset; } | |
168 static int array_klass_offset_in_bytes() { return array_klass_offset; } | |
169 // Support for classRedefinedCount field | |
170 static int classRedefinedCount(oop the_class_mirror); | |
171 static void set_classRedefinedCount(oop the_class_mirror, int value); | |
514 | 172 // Support for parallelCapable field |
173 static bool parallelCapable(oop the_class_mirror); | |
0 | 174 // Debugging |
175 friend class JavaClasses; | |
176 friend class instanceKlass; // verification code accesses offsets | |
177 friend class ClassFileParser; // access to number_of_fake_fields | |
178 }; | |
179 | |
180 // Interface to java.lang.Thread objects | |
181 | |
182 class java_lang_Thread : AllStatic { | |
183 private: | |
184 // Note that for this class the layout changed between JDK1.2 and JDK1.3, | |
185 // so we compute the offsets at startup rather than hard-wiring them. | |
186 static int _name_offset; | |
187 static int _group_offset; | |
188 static int _contextClassLoader_offset; | |
189 static int _inheritedAccessControlContext_offset; | |
190 static int _priority_offset; | |
191 static int _eetop_offset; | |
192 static int _daemon_offset; | |
193 static int _stillborn_offset; | |
194 static int _stackSize_offset; | |
195 static int _tid_offset; | |
196 static int _thread_status_offset; | |
197 static int _park_blocker_offset; | |
198 static int _park_event_offset ; | |
199 | |
200 static void compute_offsets(); | |
201 | |
202 public: | |
203 // Instance creation | |
204 static oop create(); | |
205 // Returns the JavaThread associated with the thread obj | |
206 static JavaThread* thread(oop java_thread); | |
207 // Set JavaThread for instance | |
208 static void set_thread(oop java_thread, JavaThread* thread); | |
209 // Name | |
210 static typeArrayOop name(oop java_thread); | |
211 static void set_name(oop java_thread, typeArrayOop name); | |
212 // Priority | |
213 static ThreadPriority priority(oop java_thread); | |
214 static void set_priority(oop java_thread, ThreadPriority priority); | |
215 // Thread group | |
216 static oop threadGroup(oop java_thread); | |
217 // Stillborn | |
218 static bool is_stillborn(oop java_thread); | |
219 static void set_stillborn(oop java_thread); | |
220 // Alive (NOTE: this is not really a field, but provides the correct | |
221 // definition without doing a Java call) | |
222 static bool is_alive(oop java_thread); | |
223 // Daemon | |
224 static bool is_daemon(oop java_thread); | |
225 static void set_daemon(oop java_thread); | |
226 // Context ClassLoader | |
227 static oop context_class_loader(oop java_thread); | |
228 // Control context | |
229 static oop inherited_access_control_context(oop java_thread); | |
230 // Stack size hint | |
231 static jlong stackSize(oop java_thread); | |
232 // Thread ID | |
233 static jlong thread_id(oop java_thread); | |
234 | |
235 // Blocker object responsible for thread parking | |
236 static oop park_blocker(oop java_thread); | |
237 | |
238 // Pointer to type-stable park handler, encoded as jlong. | |
239 // Should be set when apparently null | |
240 // For details, see unsafe.cpp Unsafe_Unpark | |
241 static jlong park_event(oop java_thread); | |
242 static bool set_park_event(oop java_thread, jlong ptr); | |
243 | |
244 // Java Thread Status for JVMTI and M&M use. | |
245 // This thread status info is saved in threadStatus field of | |
246 // java.lang.Thread java class. | |
247 enum ThreadStatus { | |
248 NEW = 0, | |
249 RUNNABLE = JVMTI_THREAD_STATE_ALIVE + // runnable / running | |
250 JVMTI_THREAD_STATE_RUNNABLE, | |
251 SLEEPING = JVMTI_THREAD_STATE_ALIVE + // Thread.sleep() | |
252 JVMTI_THREAD_STATE_WAITING + | |
253 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + | |
254 JVMTI_THREAD_STATE_SLEEPING, | |
255 IN_OBJECT_WAIT = JVMTI_THREAD_STATE_ALIVE + // Object.wait() | |
256 JVMTI_THREAD_STATE_WAITING + | |
257 JVMTI_THREAD_STATE_WAITING_INDEFINITELY + | |
258 JVMTI_THREAD_STATE_IN_OBJECT_WAIT, | |
259 IN_OBJECT_WAIT_TIMED = JVMTI_THREAD_STATE_ALIVE + // Object.wait(long) | |
260 JVMTI_THREAD_STATE_WAITING + | |
261 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + | |
262 JVMTI_THREAD_STATE_IN_OBJECT_WAIT, | |
263 PARKED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park() | |
264 JVMTI_THREAD_STATE_WAITING + | |
265 JVMTI_THREAD_STATE_WAITING_INDEFINITELY + | |
266 JVMTI_THREAD_STATE_PARKED, | |
267 PARKED_TIMED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park(long) | |
268 JVMTI_THREAD_STATE_WAITING + | |
269 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + | |
270 JVMTI_THREAD_STATE_PARKED, | |
271 BLOCKED_ON_MONITOR_ENTER = JVMTI_THREAD_STATE_ALIVE + // (re-)entering a synchronization block | |
272 JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER, | |
273 TERMINATED = JVMTI_THREAD_STATE_TERMINATED | |
274 }; | |
275 // Write thread status info to threadStatus field of java.lang.Thread. | |
276 static void set_thread_status(oop java_thread_oop, ThreadStatus status); | |
277 // Read thread status info from threadStatus field of java.lang.Thread. | |
278 static ThreadStatus get_thread_status(oop java_thread_oop); | |
279 | |
280 static const char* thread_status_name(oop java_thread_oop); | |
281 | |
282 // Debugging | |
283 friend class JavaClasses; | |
284 }; | |
285 | |
286 // Interface to java.lang.ThreadGroup objects | |
287 | |
288 class java_lang_ThreadGroup : AllStatic { | |
289 private: | |
290 static int _parent_offset; | |
291 static int _name_offset; | |
292 static int _threads_offset; | |
293 static int _groups_offset; | |
294 static int _maxPriority_offset; | |
295 static int _destroyed_offset; | |
296 static int _daemon_offset; | |
297 static int _vmAllowSuspension_offset; | |
298 static int _nthreads_offset; | |
299 static int _ngroups_offset; | |
300 | |
301 static void compute_offsets(); | |
302 | |
303 public: | |
304 // parent ThreadGroup | |
305 static oop parent(oop java_thread_group); | |
306 // name | |
307 static typeArrayOop name(oop java_thread_group); | |
308 // ("name as oop" accessor is not necessary) | |
309 // Number of threads in group | |
310 static int nthreads(oop java_thread_group); | |
311 // threads | |
312 static objArrayOop threads(oop java_thread_group); | |
313 // Number of threads in group | |
314 static int ngroups(oop java_thread_group); | |
315 // groups | |
316 static objArrayOop groups(oop java_thread_group); | |
317 // maxPriority in group | |
318 static ThreadPriority maxPriority(oop java_thread_group); | |
319 // Destroyed | |
320 static bool is_destroyed(oop java_thread_group); | |
321 // Daemon | |
322 static bool is_daemon(oop java_thread_group); | |
323 // vmAllowSuspension | |
324 static bool is_vmAllowSuspension(oop java_thread_group); | |
325 // Debugging | |
326 friend class JavaClasses; | |
327 }; | |
328 | |
329 | |
330 | |
331 // Interface to java.lang.Throwable objects | |
332 | |
333 class java_lang_Throwable: AllStatic { | |
334 friend class BacktraceBuilder; | |
335 | |
336 private: | |
337 // Offsets | |
338 enum { | |
339 hc_backtrace_offset = 0, | |
340 hc_detailMessage_offset = 1, | |
341 hc_cause_offset = 2, // New since 1.4 | |
342 hc_stackTrace_offset = 3 // New since 1.4 | |
343 }; | |
344 // Trace constants | |
345 enum { | |
346 trace_methods_offset = 0, | |
347 trace_bcis_offset = 1, | |
348 trace_next_offset = 2, | |
349 trace_size = 3, | |
350 trace_chunk_size = 32 | |
351 }; | |
352 | |
353 static int backtrace_offset; | |
354 static int detailMessage_offset; | |
355 static int cause_offset; | |
356 static int stackTrace_offset; | |
357 | |
358 // Printing | |
359 static char* print_stack_element_to_buffer(methodOop method, int bci); | |
360 static void print_to_stream(Handle stream, const char* str); | |
361 // StackTrace (programmatic access, new since 1.4) | |
362 static void clear_stacktrace(oop throwable); | |
363 // No stack trace available | |
364 static const char* no_stack_trace_message(); | |
365 | |
366 public: | |
367 // Backtrace | |
368 static oop backtrace(oop throwable); | |
369 static void set_backtrace(oop throwable, oop value); | |
370 // Needed by JVMTI to filter out this internal field. | |
371 static int get_backtrace_offset() { return backtrace_offset;} | |
372 static int get_detailMessage_offset() { return detailMessage_offset;} | |
373 // Message | |
374 static oop message(oop throwable); | |
375 static oop message(Handle throwable); | |
376 static void set_message(oop throwable, oop value); | |
377 // Print stack trace stored in exception by call-back to Java | |
378 // Note: this is no longer used in Merlin, but we still suppport | |
379 // it for compatibility. | |
380 static void print_stack_trace(oop throwable, oop print_stream); | |
381 static void print_stack_element(Handle stream, methodOop method, int bci); | |
382 static void print_stack_element(outputStream *st, methodOop method, int bci); | |
383 static void print_stack_usage(Handle stream); | |
384 | |
385 // Allocate space for backtrace (created but stack trace not filled in) | |
386 static void allocate_backtrace(Handle throwable, TRAPS); | |
387 // Fill in current stack trace for throwable with preallocated backtrace (no GC) | |
388 static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable); | |
389 | |
390 // Fill in current stack trace, can cause GC | |
391 static void fill_in_stack_trace(Handle throwable, TRAPS); | |
392 static void fill_in_stack_trace(Handle throwable); | |
393 // Programmatic access to stack trace | |
394 static oop get_stack_trace_element(oop throwable, int index, TRAPS); | |
395 static int get_stack_trace_depth(oop throwable, TRAPS); | |
396 // Printing | |
397 static void print(oop throwable, outputStream* st); | |
398 static void print(Handle throwable, outputStream* st); | |
399 static void print_stack_trace(oop throwable, outputStream* st); | |
400 // Debugging | |
401 friend class JavaClasses; | |
402 }; | |
403 | |
404 | |
405 // Interface to java.lang.reflect.AccessibleObject objects | |
406 | |
407 class java_lang_reflect_AccessibleObject: AllStatic { | |
408 private: | |
409 // Note that to reduce dependencies on the JDK we compute these | |
410 // offsets at run-time. | |
411 static int override_offset; | |
412 | |
413 static void compute_offsets(); | |
414 | |
415 public: | |
416 // Accessors | |
417 static jboolean override(oop reflect); | |
418 static void set_override(oop reflect, jboolean value); | |
419 | |
420 // Debugging | |
421 friend class JavaClasses; | |
422 }; | |
423 | |
424 | |
425 // Interface to java.lang.reflect.Method objects | |
426 | |
427 class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject { | |
428 private: | |
429 // Note that to reduce dependencies on the JDK we compute these | |
430 // offsets at run-time. | |
431 static int clazz_offset; | |
432 static int name_offset; | |
433 static int returnType_offset; | |
434 static int parameterTypes_offset; | |
435 static int exceptionTypes_offset; | |
436 static int slot_offset; | |
437 static int modifiers_offset; | |
438 static int signature_offset; | |
439 static int annotations_offset; | |
440 static int parameter_annotations_offset; | |
441 static int annotation_default_offset; | |
442 | |
443 static void compute_offsets(); | |
444 | |
445 public: | |
446 // Allocation | |
447 static Handle create(TRAPS); | |
448 | |
449 // Accessors | |
450 static oop clazz(oop reflect); | |
451 static void set_clazz(oop reflect, oop value); | |
452 | |
453 static oop name(oop method); | |
454 static void set_name(oop method, oop value); | |
455 | |
456 static oop return_type(oop method); | |
457 static void set_return_type(oop method, oop value); | |
458 | |
459 static oop parameter_types(oop method); | |
460 static void set_parameter_types(oop method, oop value); | |
461 | |
462 static oop exception_types(oop method); | |
463 static void set_exception_types(oop method, oop value); | |
464 | |
465 static int slot(oop reflect); | |
466 static void set_slot(oop reflect, int value); | |
467 | |
468 static int modifiers(oop method); | |
469 static void set_modifiers(oop method, int value); | |
470 | |
471 static bool has_signature_field(); | |
472 static oop signature(oop method); | |
473 static void set_signature(oop method, oop value); | |
474 | |
475 static bool has_annotations_field(); | |
476 static oop annotations(oop method); | |
477 static void set_annotations(oop method, oop value); | |
478 | |
479 static bool has_parameter_annotations_field(); | |
480 static oop parameter_annotations(oop method); | |
481 static void set_parameter_annotations(oop method, oop value); | |
482 | |
483 static bool has_annotation_default_field(); | |
484 static oop annotation_default(oop method); | |
485 static void set_annotation_default(oop method, oop value); | |
486 | |
487 // Debugging | |
488 friend class JavaClasses; | |
489 }; | |
490 | |
491 | |
492 // Interface to java.lang.reflect.Constructor objects | |
493 | |
494 class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject { | |
495 private: | |
496 // Note that to reduce dependencies on the JDK we compute these | |
497 // offsets at run-time. | |
498 static int clazz_offset; | |
499 static int parameterTypes_offset; | |
500 static int exceptionTypes_offset; | |
501 static int slot_offset; | |
502 static int modifiers_offset; | |
503 static int signature_offset; | |
504 static int annotations_offset; | |
505 static int parameter_annotations_offset; | |
506 | |
507 static void compute_offsets(); | |
508 | |
509 public: | |
510 // Allocation | |
511 static Handle create(TRAPS); | |
512 | |
513 // Accessors | |
514 static oop clazz(oop reflect); | |
515 static void set_clazz(oop reflect, oop value); | |
516 | |
517 static oop parameter_types(oop constructor); | |
518 static void set_parameter_types(oop constructor, oop value); | |
519 | |
520 static oop exception_types(oop constructor); | |
521 static void set_exception_types(oop constructor, oop value); | |
522 | |
523 static int slot(oop reflect); | |
524 static void set_slot(oop reflect, int value); | |
525 | |
526 static int modifiers(oop constructor); | |
527 static void set_modifiers(oop constructor, int value); | |
528 | |
529 static bool has_signature_field(); | |
530 static oop signature(oop constructor); | |
531 static void set_signature(oop constructor, oop value); | |
532 | |
533 static bool has_annotations_field(); | |
534 static oop annotations(oop constructor); | |
535 static void set_annotations(oop constructor, oop value); | |
536 | |
537 static bool has_parameter_annotations_field(); | |
538 static oop parameter_annotations(oop method); | |
539 static void set_parameter_annotations(oop method, oop value); | |
540 | |
541 // Debugging | |
542 friend class JavaClasses; | |
543 }; | |
544 | |
545 | |
546 // Interface to java.lang.reflect.Field objects | |
547 | |
548 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject { | |
549 private: | |
550 // Note that to reduce dependencies on the JDK we compute these | |
551 // offsets at run-time. | |
552 static int clazz_offset; | |
553 static int name_offset; | |
554 static int type_offset; | |
555 static int slot_offset; | |
556 static int modifiers_offset; | |
557 static int signature_offset; | |
558 static int annotations_offset; | |
559 | |
560 static void compute_offsets(); | |
561 | |
562 public: | |
563 // Allocation | |
564 static Handle create(TRAPS); | |
565 | |
566 // Accessors | |
567 static oop clazz(oop reflect); | |
568 static void set_clazz(oop reflect, oop value); | |
569 | |
570 static oop name(oop field); | |
571 static void set_name(oop field, oop value); | |
572 | |
573 static oop type(oop field); | |
574 static void set_type(oop field, oop value); | |
575 | |
576 static int slot(oop reflect); | |
577 static void set_slot(oop reflect, int value); | |
578 | |
579 static int modifiers(oop field); | |
580 static void set_modifiers(oop field, int value); | |
581 | |
582 static bool has_signature_field(); | |
583 static oop signature(oop constructor); | |
584 static void set_signature(oop constructor, oop value); | |
585 | |
586 static bool has_annotations_field(); | |
587 static oop annotations(oop constructor); | |
588 static void set_annotations(oop constructor, oop value); | |
589 | |
590 static bool has_parameter_annotations_field(); | |
591 static oop parameter_annotations(oop method); | |
592 static void set_parameter_annotations(oop method, oop value); | |
593 | |
594 static bool has_annotation_default_field(); | |
595 static oop annotation_default(oop method); | |
596 static void set_annotation_default(oop method, oop value); | |
597 | |
598 // Debugging | |
599 friend class JavaClasses; | |
600 }; | |
601 | |
602 // Interface to sun.reflect.ConstantPool objects | |
603 class sun_reflect_ConstantPool { | |
604 private: | |
605 // Note that to reduce dependencies on the JDK we compute these | |
606 // offsets at run-time. | |
607 static int _cp_oop_offset; | |
608 | |
609 static void compute_offsets(); | |
610 | |
611 public: | |
612 // Allocation | |
613 static Handle create(TRAPS); | |
614 | |
615 // Accessors | |
616 static oop cp_oop(oop reflect); | |
617 static void set_cp_oop(oop reflect, oop value); | |
618 static int cp_oop_offset() { | |
619 return _cp_oop_offset; | |
620 } | |
621 | |
622 // Debugging | |
623 friend class JavaClasses; | |
624 }; | |
625 | |
626 // Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects | |
627 class sun_reflect_UnsafeStaticFieldAccessorImpl { | |
628 private: | |
629 static int _base_offset; | |
630 static void compute_offsets(); | |
631 | |
632 public: | |
633 static int base_offset() { | |
634 return _base_offset; | |
635 } | |
636 | |
637 // Debugging | |
638 friend class JavaClasses; | |
639 }; | |
640 | |
641 // Interface to java.lang primitive type boxing objects: | |
642 // - java.lang.Boolean | |
643 // - java.lang.Character | |
644 // - java.lang.Float | |
645 // - java.lang.Double | |
646 // - java.lang.Byte | |
647 // - java.lang.Short | |
648 // - java.lang.Integer | |
649 // - java.lang.Long | |
650 | |
651 // This could be separated out into 8 individual classes. | |
652 | |
653 class java_lang_boxing_object: AllStatic { | |
654 private: | |
655 enum { | |
656 hc_value_offset = 0 | |
657 }; | |
658 static int value_offset; | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
659 static int long_value_offset; |
0 | 660 |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
661 static oop initialize_and_allocate(BasicType type, TRAPS); |
0 | 662 public: |
663 // Allocation. Returns a boxed value, or NULL for invalid type. | |
664 static oop create(BasicType type, jvalue* value, TRAPS); | |
665 // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop. | |
666 static BasicType get_value(oop box, jvalue* value); | |
667 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
|
668 static BasicType basic_type(oop box); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
669 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
|
670 static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; } |
0 | 671 |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
672 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
|
673 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
|
674 value_offset; |
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
675 } |
0 | 676 |
677 // Debugging | |
678 friend class JavaClasses; | |
679 }; | |
680 | |
681 | |
682 | |
683 // Interface to java.lang.ref.Reference objects | |
684 | |
685 class java_lang_ref_Reference: AllStatic { | |
686 public: | |
687 enum { | |
688 hc_referent_offset = 0, | |
689 hc_queue_offset = 1, | |
690 hc_next_offset = 2, | |
691 hc_discovered_offset = 3 // Is not last, see SoftRefs. | |
692 }; | |
693 enum { | |
694 hc_static_lock_offset = 0, | |
695 hc_static_pending_offset = 1 | |
696 }; | |
697 | |
698 static int referent_offset; | |
699 static int queue_offset; | |
700 static int next_offset; | |
701 static int discovered_offset; | |
702 static int static_lock_offset; | |
703 static int static_pending_offset; | |
704 static int number_of_fake_oop_fields; | |
705 | |
706 // Accessors | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
707 static oop referent(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
708 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
|
709 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
710 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
|
711 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
|
712 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
713 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
|
714 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
|
715 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
716 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
|
717 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
|
718 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
719 static oop next(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(next_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_next(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(next_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_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
|
726 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
|
727 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
728 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
|
729 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
|
730 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
731 static oop discovered(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(discovered_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_discovered(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(discovered_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_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
|
738 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
|
739 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
740 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
|
741 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
|
742 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
743 // Accessors for statics |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
744 static oop pending_list_lock(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
745 static oop pending_list(); |
0 | 746 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
747 static HeapWord* pending_list_addr(); |
0 | 748 }; |
749 | |
750 | |
751 // Interface to java.lang.ref.SoftReference objects | |
752 | |
753 class java_lang_ref_SoftReference: public java_lang_ref_Reference { | |
754 public: | |
755 enum { | |
756 // 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
|
757 hc_timestamp_offset = hc_discovered_offset + 1 |
0 | 758 }; |
759 enum { | |
760 hc_static_clock_offset = 0 | |
761 }; | |
762 | |
763 static int timestamp_offset; | |
764 static int static_clock_offset; | |
765 | |
766 // Accessors | |
767 static jlong timestamp(oop ref); | |
768 | |
769 // Accessors for statics | |
770 static jlong clock(); | |
771 static void set_clock(jlong value); | |
772 }; | |
773 | |
774 | |
775 // Interface to java.security.AccessControlContext objects | |
776 | |
777 class java_security_AccessControlContext: AllStatic { | |
778 private: | |
779 // Note that for this class the layout changed between JDK1.2 and JDK1.3, | |
780 // so we compute the offsets at startup rather than hard-wiring them. | |
781 static int _context_offset; | |
782 static int _privilegedContext_offset; | |
783 static int _isPrivileged_offset; | |
784 | |
785 static void compute_offsets(); | |
786 public: | |
787 static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS); | |
788 | |
789 // Debugging/initialization | |
790 friend class JavaClasses; | |
791 }; | |
792 | |
793 | |
794 // Interface to java.lang.ClassLoader objects | |
795 | |
796 class java_lang_ClassLoader : AllStatic { | |
797 private: | |
798 enum { | |
799 hc_parent_offset = 0 | |
800 }; | |
801 | |
802 static int parent_offset; | |
803 | |
804 public: | |
805 static oop parent(oop loader); | |
806 | |
807 static bool is_trusted_loader(oop loader); | |
808 | |
809 // Fix for 4474172 | |
810 static oop non_reflection_class_loader(oop loader); | |
811 | |
812 // Debugging | |
813 friend class JavaClasses; | |
814 }; | |
815 | |
816 | |
817 // Interface to java.lang.System objects | |
818 | |
819 class java_lang_System : AllStatic { | |
820 private: | |
821 enum { | |
822 hc_static_in_offset = 0, | |
823 hc_static_out_offset = 1, | |
824 hc_static_err_offset = 2 | |
825 }; | |
826 | |
827 static int offset_of_static_fields; | |
828 static int static_in_offset; | |
829 static int static_out_offset; | |
830 static int static_err_offset; | |
831 | |
832 static void compute_offsets(); | |
833 | |
834 public: | |
835 static int in_offset_in_bytes(); | |
836 static int out_offset_in_bytes(); | |
837 static int err_offset_in_bytes(); | |
838 | |
839 // Debugging | |
840 friend class JavaClasses; | |
841 }; | |
842 | |
843 | |
844 // Interface to java.lang.StackTraceElement objects | |
845 | |
846 class java_lang_StackTraceElement: AllStatic { | |
847 private: | |
848 enum { | |
849 hc_declaringClass_offset = 0, | |
850 hc_methodName_offset = 1, | |
851 hc_fileName_offset = 2, | |
852 hc_lineNumber_offset = 3 | |
853 }; | |
854 | |
855 static int declaringClass_offset; | |
856 static int methodName_offset; | |
857 static int fileName_offset; | |
858 static int lineNumber_offset; | |
859 | |
860 public: | |
861 // Setters | |
862 static void set_declaringClass(oop element, oop value); | |
863 static void set_methodName(oop element, oop value); | |
864 static void set_fileName(oop element, oop value); | |
865 static void set_lineNumber(oop element, int value); | |
866 | |
867 // Create an instance of StackTraceElement | |
868 static oop create(methodHandle m, int bci, TRAPS); | |
869 | |
870 // Debugging | |
871 friend class JavaClasses; | |
872 }; | |
873 | |
874 | |
875 // Interface to java.lang.AssertionStatusDirectives objects | |
876 | |
877 class java_lang_AssertionStatusDirectives: AllStatic { | |
878 private: | |
879 enum { | |
880 hc_classes_offset, | |
881 hc_classEnabled_offset, | |
882 hc_packages_offset, | |
883 hc_packageEnabled_offset, | |
884 hc_deflt_offset | |
885 }; | |
886 | |
887 static int classes_offset; | |
888 static int classEnabled_offset; | |
889 static int packages_offset; | |
890 static int packageEnabled_offset; | |
891 static int deflt_offset; | |
892 | |
893 public: | |
894 // Setters | |
895 static void set_classes(oop obj, oop val); | |
896 static void set_classEnabled(oop obj, oop val); | |
897 static void set_packages(oop obj, oop val); | |
898 static void set_packageEnabled(oop obj, oop val); | |
899 static void set_deflt(oop obj, bool val); | |
900 // Debugging | |
901 friend class JavaClasses; | |
902 }; | |
903 | |
904 | |
905 class java_nio_Buffer: AllStatic { | |
906 private: | |
907 static int _limit_offset; | |
908 | |
909 public: | |
910 static int limit_offset(); | |
911 static void compute_offsets(); | |
912 }; | |
913 | |
914 class sun_misc_AtomicLongCSImpl: AllStatic { | |
915 private: | |
916 static int _value_offset; | |
917 | |
918 public: | |
919 static int value_offset(); | |
920 static void compute_offsets(); | |
921 }; | |
922 | |
923 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic { | |
924 private: | |
925 static int _owner_offset; | |
926 public: | |
927 static void initialize(TRAPS); | |
928 static oop get_owner_threadObj(oop obj); | |
929 }; | |
930 | |
931 // Interface to hard-coded offset checking | |
932 | |
933 class JavaClasses : AllStatic { | |
934 private: | |
935 static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; | |
936 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
|
937 static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
0 | 938 public: |
939 static void compute_hard_coded_offsets(); | |
940 static void compute_offsets(); | |
941 static void check_offsets() PRODUCT_RETURN; | |
942 }; |