Fri, 06 Jun 2008 13:43:36 -0400
Merge
1 /*
2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
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 */
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.
42 // Interface to java.lang.String objects
44 class java_lang_String : AllStatic {
45 private:
46 enum {
47 hc_value_offset = 0,
48 hc_offset_offset = 1
49 //hc_count_offset = 2 -- not a word-scaled offset
50 //hc_hash_offset = 3 -- not a word-scaled offset
51 };
53 static int value_offset;
54 static int offset_offset;
55 static int count_offset;
56 static int hash_offset;
58 static Handle basic_create(int length, bool tenured, TRAPS);
59 static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS);
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); }
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);
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; }
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);
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);
99 static char* as_platform_dependent_str(Handle java_string, TRAPS);
100 static jchar* as_unicode_string(oop java_string, int& length);
102 static bool equals(oop java_string, jchar* chars, int len);
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); }
108 // Conversion
109 static symbolHandle as_symbol(Handle java_string, TRAPS);
111 // Testers
112 static bool is_instance(oop obj) {
113 return obj != NULL && obj->klass() == SystemDictionary::string_klass();
114 }
116 // Debugging
117 static void print(Handle java_string, outputStream* st);
118 friend class JavaClasses;
119 };
122 // Interface to java.lang.Class objects
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
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 };
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;
141 static void compute_offsets();
142 static bool offsets_computed;
143 static int classRedefinedCount_offset;
145 public:
146 // Instance creation
147 static oop create_mirror(KlassHandle k, TRAPS);
148 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
149 // Conversion
150 static klassOop as_klassOop(oop java_class);
151 // Testing
152 static bool is_instance(oop obj) {
153 return obj != NULL && obj->klass() == SystemDictionary::class_klass();
154 }
155 static bool is_primitive(oop java_class);
156 static BasicType primitive_type(oop java_class);
157 static oop primitive_mirror(BasicType t);
158 // JVM_NewInstance support
159 static methodOop resolved_constructor(oop java_class);
160 static void set_resolved_constructor(oop java_class, methodOop constructor);
161 // JVM_NewArray support
162 static klassOop array_klass(oop java_class);
163 static void set_array_klass(oop java_class, klassOop klass);
164 // compiler support for class operations
165 static int klass_offset_in_bytes() { return klass_offset; }
166 static int resolved_constructor_offset_in_bytes() { return resolved_constructor_offset; }
167 static int array_klass_offset_in_bytes() { return array_klass_offset; }
168 // Support for classRedefinedCount field
169 static int classRedefinedCount(oop the_class_mirror);
170 static void set_classRedefinedCount(oop the_class_mirror, int value);
171 // Debugging
172 friend class JavaClasses;
173 friend class instanceKlass; // verification code accesses offsets
174 friend class ClassFileParser; // access to number_of_fake_fields
175 };
177 // Interface to java.lang.Thread objects
179 class java_lang_Thread : AllStatic {
180 private:
181 // Note that for this class the layout changed between JDK1.2 and JDK1.3,
182 // so we compute the offsets at startup rather than hard-wiring them.
183 static int _name_offset;
184 static int _group_offset;
185 static int _contextClassLoader_offset;
186 static int _inheritedAccessControlContext_offset;
187 static int _priority_offset;
188 static int _eetop_offset;
189 static int _daemon_offset;
190 static int _stillborn_offset;
191 static int _stackSize_offset;
192 static int _tid_offset;
193 static int _thread_status_offset;
194 static int _park_blocker_offset;
195 static int _park_event_offset ;
197 static void compute_offsets();
199 public:
200 // Instance creation
201 static oop create();
202 // Returns the JavaThread associated with the thread obj
203 static JavaThread* thread(oop java_thread);
204 // Set JavaThread for instance
205 static void set_thread(oop java_thread, JavaThread* thread);
206 // Name
207 static typeArrayOop name(oop java_thread);
208 static void set_name(oop java_thread, typeArrayOop name);
209 // Priority
210 static ThreadPriority priority(oop java_thread);
211 static void set_priority(oop java_thread, ThreadPriority priority);
212 // Thread group
213 static oop threadGroup(oop java_thread);
214 // Stillborn
215 static bool is_stillborn(oop java_thread);
216 static void set_stillborn(oop java_thread);
217 // Alive (NOTE: this is not really a field, but provides the correct
218 // definition without doing a Java call)
219 static bool is_alive(oop java_thread);
220 // Daemon
221 static bool is_daemon(oop java_thread);
222 static void set_daemon(oop java_thread);
223 // Context ClassLoader
224 static oop context_class_loader(oop java_thread);
225 // Control context
226 static oop inherited_access_control_context(oop java_thread);
227 // Stack size hint
228 static jlong stackSize(oop java_thread);
229 // Thread ID
230 static jlong thread_id(oop java_thread);
232 // Blocker object responsible for thread parking
233 static oop park_blocker(oop java_thread);
235 // Pointer to type-stable park handler, encoded as jlong.
236 // Should be set when apparently null
237 // For details, see unsafe.cpp Unsafe_Unpark
238 static jlong park_event(oop java_thread);
239 static bool set_park_event(oop java_thread, jlong ptr);
241 // Java Thread Status for JVMTI and M&M use.
242 // This thread status info is saved in threadStatus field of
243 // java.lang.Thread java class.
244 enum ThreadStatus {
245 NEW = 0,
246 RUNNABLE = JVMTI_THREAD_STATE_ALIVE + // runnable / running
247 JVMTI_THREAD_STATE_RUNNABLE,
248 SLEEPING = JVMTI_THREAD_STATE_ALIVE + // Thread.sleep()
249 JVMTI_THREAD_STATE_WAITING +
250 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
251 JVMTI_THREAD_STATE_SLEEPING,
252 IN_OBJECT_WAIT = JVMTI_THREAD_STATE_ALIVE + // Object.wait()
253 JVMTI_THREAD_STATE_WAITING +
254 JVMTI_THREAD_STATE_WAITING_INDEFINITELY +
255 JVMTI_THREAD_STATE_IN_OBJECT_WAIT,
256 IN_OBJECT_WAIT_TIMED = JVMTI_THREAD_STATE_ALIVE + // Object.wait(long)
257 JVMTI_THREAD_STATE_WAITING +
258 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
259 JVMTI_THREAD_STATE_IN_OBJECT_WAIT,
260 PARKED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park()
261 JVMTI_THREAD_STATE_WAITING +
262 JVMTI_THREAD_STATE_WAITING_INDEFINITELY +
263 JVMTI_THREAD_STATE_PARKED,
264 PARKED_TIMED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park(long)
265 JVMTI_THREAD_STATE_WAITING +
266 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +
267 JVMTI_THREAD_STATE_PARKED,
268 BLOCKED_ON_MONITOR_ENTER = JVMTI_THREAD_STATE_ALIVE + // (re-)entering a synchronization block
269 JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER,
270 TERMINATED = JVMTI_THREAD_STATE_TERMINATED
271 };
272 // Write thread status info to threadStatus field of java.lang.Thread.
273 static void set_thread_status(oop java_thread_oop, ThreadStatus status);
274 // Read thread status info from threadStatus field of java.lang.Thread.
275 static ThreadStatus get_thread_status(oop java_thread_oop);
277 static const char* thread_status_name(oop java_thread_oop);
279 // Debugging
280 friend class JavaClasses;
281 };
283 // Interface to java.lang.ThreadGroup objects
285 class java_lang_ThreadGroup : AllStatic {
286 private:
287 static int _parent_offset;
288 static int _name_offset;
289 static int _threads_offset;
290 static int _groups_offset;
291 static int _maxPriority_offset;
292 static int _destroyed_offset;
293 static int _daemon_offset;
294 static int _vmAllowSuspension_offset;
295 static int _nthreads_offset;
296 static int _ngroups_offset;
298 static void compute_offsets();
300 public:
301 // parent ThreadGroup
302 static oop parent(oop java_thread_group);
303 // name
304 static typeArrayOop name(oop java_thread_group);
305 // ("name as oop" accessor is not necessary)
306 // Number of threads in group
307 static int nthreads(oop java_thread_group);
308 // threads
309 static objArrayOop threads(oop java_thread_group);
310 // Number of threads in group
311 static int ngroups(oop java_thread_group);
312 // groups
313 static objArrayOop groups(oop java_thread_group);
314 // maxPriority in group
315 static ThreadPriority maxPriority(oop java_thread_group);
316 // Destroyed
317 static bool is_destroyed(oop java_thread_group);
318 // Daemon
319 static bool is_daemon(oop java_thread_group);
320 // vmAllowSuspension
321 static bool is_vmAllowSuspension(oop java_thread_group);
322 // Debugging
323 friend class JavaClasses;
324 };
328 // Interface to java.lang.Throwable objects
330 class java_lang_Throwable: AllStatic {
331 friend class BacktraceBuilder;
333 private:
334 // Offsets
335 enum {
336 hc_backtrace_offset = 0,
337 hc_detailMessage_offset = 1,
338 hc_cause_offset = 2, // New since 1.4
339 hc_stackTrace_offset = 3 // New since 1.4
340 };
341 // Trace constants
342 enum {
343 trace_methods_offset = 0,
344 trace_bcis_offset = 1,
345 trace_next_offset = 2,
346 trace_size = 3,
347 trace_chunk_size = 32
348 };
350 static int backtrace_offset;
351 static int detailMessage_offset;
352 static int cause_offset;
353 static int stackTrace_offset;
355 // Printing
356 static char* print_stack_element_to_buffer(methodOop method, int bci);
357 static void print_to_stream(Handle stream, const char* str);
358 // StackTrace (programmatic access, new since 1.4)
359 static void clear_stacktrace(oop throwable);
360 // No stack trace available
361 static const char* no_stack_trace_message();
363 public:
364 // Backtrace
365 static oop backtrace(oop throwable);
366 static void set_backtrace(oop throwable, oop value);
367 // Needed by JVMTI to filter out this internal field.
368 static int get_backtrace_offset() { return backtrace_offset;}
369 static int get_detailMessage_offset() { return detailMessage_offset;}
370 // Message
371 static oop message(oop throwable);
372 static oop message(Handle throwable);
373 static void set_message(oop throwable, oop value);
374 // Print stack trace stored in exception by call-back to Java
375 // Note: this is no longer used in Merlin, but we still suppport
376 // it for compatibility.
377 static void print_stack_trace(oop throwable, oop print_stream);
378 static void print_stack_element(Handle stream, methodOop method, int bci);
379 static void print_stack_element(outputStream *st, methodOop method, int bci);
380 static void print_stack_usage(Handle stream);
382 // Allocate space for backtrace (created but stack trace not filled in)
383 static void allocate_backtrace(Handle throwable, TRAPS);
384 // Fill in current stack trace for throwable with preallocated backtrace (no GC)
385 static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable);
387 // Fill in current stack trace, can cause GC
388 static void fill_in_stack_trace(Handle throwable, TRAPS);
389 static void fill_in_stack_trace(Handle throwable);
390 // Programmatic access to stack trace
391 static oop get_stack_trace_element(oop throwable, int index, TRAPS);
392 static int get_stack_trace_depth(oop throwable, TRAPS);
393 // Printing
394 static void print(oop throwable, outputStream* st);
395 static void print(Handle throwable, outputStream* st);
396 static void print_stack_trace(oop throwable, outputStream* st);
397 // Debugging
398 friend class JavaClasses;
399 };
402 // Interface to java.lang.reflect.AccessibleObject objects
404 class java_lang_reflect_AccessibleObject: AllStatic {
405 private:
406 // Note that to reduce dependencies on the JDK we compute these
407 // offsets at run-time.
408 static int override_offset;
410 static void compute_offsets();
412 public:
413 // Accessors
414 static jboolean override(oop reflect);
415 static void set_override(oop reflect, jboolean value);
417 // Debugging
418 friend class JavaClasses;
419 };
422 // Interface to java.lang.reflect.Method objects
424 class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject {
425 private:
426 // Note that to reduce dependencies on the JDK we compute these
427 // offsets at run-time.
428 static int clazz_offset;
429 static int name_offset;
430 static int returnType_offset;
431 static int parameterTypes_offset;
432 static int exceptionTypes_offset;
433 static int slot_offset;
434 static int modifiers_offset;
435 static int signature_offset;
436 static int annotations_offset;
437 static int parameter_annotations_offset;
438 static int annotation_default_offset;
440 static void compute_offsets();
442 public:
443 // Allocation
444 static Handle create(TRAPS);
446 // Accessors
447 static oop clazz(oop reflect);
448 static void set_clazz(oop reflect, oop value);
450 static oop name(oop method);
451 static void set_name(oop method, oop value);
453 static oop return_type(oop method);
454 static void set_return_type(oop method, oop value);
456 static oop parameter_types(oop method);
457 static void set_parameter_types(oop method, oop value);
459 static oop exception_types(oop method);
460 static void set_exception_types(oop method, oop value);
462 static int slot(oop reflect);
463 static void set_slot(oop reflect, int value);
465 static int modifiers(oop method);
466 static void set_modifiers(oop method, int value);
468 static bool has_signature_field();
469 static oop signature(oop method);
470 static void set_signature(oop method, oop value);
472 static bool has_annotations_field();
473 static oop annotations(oop method);
474 static void set_annotations(oop method, oop value);
476 static bool has_parameter_annotations_field();
477 static oop parameter_annotations(oop method);
478 static void set_parameter_annotations(oop method, oop value);
480 static bool has_annotation_default_field();
481 static oop annotation_default(oop method);
482 static void set_annotation_default(oop method, oop value);
484 // Debugging
485 friend class JavaClasses;
486 };
489 // Interface to java.lang.reflect.Constructor objects
491 class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject {
492 private:
493 // Note that to reduce dependencies on the JDK we compute these
494 // offsets at run-time.
495 static int clazz_offset;
496 static int parameterTypes_offset;
497 static int exceptionTypes_offset;
498 static int slot_offset;
499 static int modifiers_offset;
500 static int signature_offset;
501 static int annotations_offset;
502 static int parameter_annotations_offset;
504 static void compute_offsets();
506 public:
507 // Allocation
508 static Handle create(TRAPS);
510 // Accessors
511 static oop clazz(oop reflect);
512 static void set_clazz(oop reflect, oop value);
514 static oop parameter_types(oop constructor);
515 static void set_parameter_types(oop constructor, oop value);
517 static oop exception_types(oop constructor);
518 static void set_exception_types(oop constructor, oop value);
520 static int slot(oop reflect);
521 static void set_slot(oop reflect, int value);
523 static int modifiers(oop constructor);
524 static void set_modifiers(oop constructor, int value);
526 static bool has_signature_field();
527 static oop signature(oop constructor);
528 static void set_signature(oop constructor, oop value);
530 static bool has_annotations_field();
531 static oop annotations(oop constructor);
532 static void set_annotations(oop constructor, oop value);
534 static bool has_parameter_annotations_field();
535 static oop parameter_annotations(oop method);
536 static void set_parameter_annotations(oop method, oop value);
538 // Debugging
539 friend class JavaClasses;
540 };
543 // Interface to java.lang.reflect.Field objects
545 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject {
546 private:
547 // Note that to reduce dependencies on the JDK we compute these
548 // offsets at run-time.
549 static int clazz_offset;
550 static int name_offset;
551 static int type_offset;
552 static int slot_offset;
553 static int modifiers_offset;
554 static int signature_offset;
555 static int annotations_offset;
557 static void compute_offsets();
559 public:
560 // Allocation
561 static Handle create(TRAPS);
563 // Accessors
564 static oop clazz(oop reflect);
565 static void set_clazz(oop reflect, oop value);
567 static oop name(oop field);
568 static void set_name(oop field, oop value);
570 static oop type(oop field);
571 static void set_type(oop field, oop value);
573 static int slot(oop reflect);
574 static void set_slot(oop reflect, int value);
576 static int modifiers(oop field);
577 static void set_modifiers(oop field, int value);
579 static bool has_signature_field();
580 static oop signature(oop constructor);
581 static void set_signature(oop constructor, oop value);
583 static bool has_annotations_field();
584 static oop annotations(oop constructor);
585 static void set_annotations(oop constructor, oop value);
587 static bool has_parameter_annotations_field();
588 static oop parameter_annotations(oop method);
589 static void set_parameter_annotations(oop method, oop value);
591 static bool has_annotation_default_field();
592 static oop annotation_default(oop method);
593 static void set_annotation_default(oop method, oop value);
595 // Debugging
596 friend class JavaClasses;
597 };
599 // Interface to sun.reflect.ConstantPool objects
600 class sun_reflect_ConstantPool {
601 private:
602 // Note that to reduce dependencies on the JDK we compute these
603 // offsets at run-time.
604 static int _cp_oop_offset;
606 static void compute_offsets();
608 public:
609 // Allocation
610 static Handle create(TRAPS);
612 // Accessors
613 static oop cp_oop(oop reflect);
614 static void set_cp_oop(oop reflect, oop value);
615 static int cp_oop_offset() {
616 return _cp_oop_offset;
617 }
619 // Debugging
620 friend class JavaClasses;
621 };
623 // Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects
624 class sun_reflect_UnsafeStaticFieldAccessorImpl {
625 private:
626 static int _base_offset;
627 static void compute_offsets();
629 public:
630 static int base_offset() {
631 return _base_offset;
632 }
634 // Debugging
635 friend class JavaClasses;
636 };
638 // Interface to java.lang primitive type boxing objects:
639 // - java.lang.Boolean
640 // - java.lang.Character
641 // - java.lang.Float
642 // - java.lang.Double
643 // - java.lang.Byte
644 // - java.lang.Short
645 // - java.lang.Integer
646 // - java.lang.Long
648 // This could be separated out into 8 individual classes.
650 class java_lang_boxing_object: AllStatic {
651 private:
652 enum {
653 hc_value_offset = 0
654 };
655 static int value_offset;
656 static int long_value_offset;
658 static oop initialize_and_allocate(BasicType type, TRAPS);
659 public:
660 // Allocation. Returns a boxed value, or NULL for invalid type.
661 static oop create(BasicType type, jvalue* value, TRAPS);
662 // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop.
663 static BasicType get_value(oop box, jvalue* value);
664 static BasicType set_value(oop box, jvalue* value);
665 static BasicType basic_type(oop box);
666 static bool is_instance(oop box) { return basic_type(box) != T_ILLEGAL; }
667 static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; }
669 static int value_offset_in_bytes(BasicType type) {
670 return ( type == T_LONG || type == T_DOUBLE ) ? long_value_offset :
671 value_offset;
672 }
674 // Debugging
675 friend class JavaClasses;
676 };
680 // Interface to java.lang.ref.Reference objects
682 class java_lang_ref_Reference: AllStatic {
683 public:
684 enum {
685 hc_referent_offset = 0,
686 hc_queue_offset = 1,
687 hc_next_offset = 2,
688 hc_discovered_offset = 3 // Is not last, see SoftRefs.
689 };
690 enum {
691 hc_static_lock_offset = 0,
692 hc_static_pending_offset = 1
693 };
695 static int referent_offset;
696 static int queue_offset;
697 static int next_offset;
698 static int discovered_offset;
699 static int static_lock_offset;
700 static int static_pending_offset;
701 static int number_of_fake_oop_fields;
703 // Accessors
704 static oop referent(oop ref) {
705 return ref->obj_field(referent_offset);
706 }
707 static void set_referent(oop ref, oop value) {
708 ref->obj_field_put(referent_offset, value);
709 }
710 static void set_referent_raw(oop ref, oop value) {
711 ref->obj_field_raw_put(referent_offset, value);
712 }
713 static HeapWord* referent_addr(oop ref) {
714 return ref->obj_field_addr<HeapWord>(referent_offset);
715 }
716 static oop next(oop ref) {
717 return ref->obj_field(next_offset);
718 }
719 static void set_next(oop ref, oop value) {
720 ref->obj_field_put(next_offset, value);
721 }
722 static void set_next_raw(oop ref, oop value) {
723 ref->obj_field_raw_put(next_offset, value);
724 }
725 static HeapWord* next_addr(oop ref) {
726 return ref->obj_field_addr<HeapWord>(next_offset);
727 }
728 static oop discovered(oop ref) {
729 return ref->obj_field(discovered_offset);
730 }
731 static void set_discovered(oop ref, oop value) {
732 ref->obj_field_put(discovered_offset, value);
733 }
734 static void set_discovered_raw(oop ref, oop value) {
735 ref->obj_field_raw_put(discovered_offset, value);
736 }
737 static HeapWord* discovered_addr(oop ref) {
738 return ref->obj_field_addr<HeapWord>(discovered_offset);
739 }
740 // Accessors for statics
741 static oop pending_list_lock();
742 static oop pending_list();
744 static HeapWord* pending_list_addr();
745 };
748 // Interface to java.lang.ref.SoftReference objects
750 class java_lang_ref_SoftReference: public java_lang_ref_Reference {
751 public:
752 enum {
753 // The timestamp is a long field and may need to be adjusted for alignment.
754 hc_timestamp_offset = hc_discovered_offset + 1
755 };
756 enum {
757 hc_static_clock_offset = 0
758 };
760 static int timestamp_offset;
761 static int static_clock_offset;
763 // Accessors
764 static jlong timestamp(oop ref);
766 // Accessors for statics
767 static jlong clock();
768 static void set_clock(jlong value);
769 };
772 // Interface to java.security.AccessControlContext objects
774 class java_security_AccessControlContext: AllStatic {
775 private:
776 // Note that for this class the layout changed between JDK1.2 and JDK1.3,
777 // so we compute the offsets at startup rather than hard-wiring them.
778 static int _context_offset;
779 static int _privilegedContext_offset;
780 static int _isPrivileged_offset;
782 static void compute_offsets();
783 public:
784 static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS);
786 // Debugging/initialization
787 friend class JavaClasses;
788 };
791 // Interface to java.lang.ClassLoader objects
793 class java_lang_ClassLoader : AllStatic {
794 private:
795 enum {
796 hc_parent_offset = 0
797 };
799 static int parent_offset;
801 public:
802 static oop parent(oop loader);
804 static bool is_trusted_loader(oop loader);
806 // Fix for 4474172
807 static oop non_reflection_class_loader(oop loader);
809 // Debugging
810 friend class JavaClasses;
811 };
814 // Interface to java.lang.System objects
816 class java_lang_System : AllStatic {
817 private:
818 enum {
819 hc_static_in_offset = 0,
820 hc_static_out_offset = 1,
821 hc_static_err_offset = 2
822 };
824 static int offset_of_static_fields;
825 static int static_in_offset;
826 static int static_out_offset;
827 static int static_err_offset;
829 static void compute_offsets();
831 public:
832 static int in_offset_in_bytes();
833 static int out_offset_in_bytes();
834 static int err_offset_in_bytes();
836 // Debugging
837 friend class JavaClasses;
838 };
841 // Interface to java.lang.StackTraceElement objects
843 class java_lang_StackTraceElement: AllStatic {
844 private:
845 enum {
846 hc_declaringClass_offset = 0,
847 hc_methodName_offset = 1,
848 hc_fileName_offset = 2,
849 hc_lineNumber_offset = 3
850 };
852 static int declaringClass_offset;
853 static int methodName_offset;
854 static int fileName_offset;
855 static int lineNumber_offset;
857 public:
858 // Setters
859 static void set_declaringClass(oop element, oop value);
860 static void set_methodName(oop element, oop value);
861 static void set_fileName(oop element, oop value);
862 static void set_lineNumber(oop element, int value);
864 // Create an instance of StackTraceElement
865 static oop create(methodHandle m, int bci, TRAPS);
867 // Debugging
868 friend class JavaClasses;
869 };
872 // Interface to java.lang.AssertionStatusDirectives objects
874 class java_lang_AssertionStatusDirectives: AllStatic {
875 private:
876 enum {
877 hc_classes_offset,
878 hc_classEnabled_offset,
879 hc_packages_offset,
880 hc_packageEnabled_offset,
881 hc_deflt_offset
882 };
884 static int classes_offset;
885 static int classEnabled_offset;
886 static int packages_offset;
887 static int packageEnabled_offset;
888 static int deflt_offset;
890 public:
891 // Setters
892 static void set_classes(oop obj, oop val);
893 static void set_classEnabled(oop obj, oop val);
894 static void set_packages(oop obj, oop val);
895 static void set_packageEnabled(oop obj, oop val);
896 static void set_deflt(oop obj, bool val);
897 // Debugging
898 friend class JavaClasses;
899 };
902 class java_nio_Buffer: AllStatic {
903 private:
904 static int _limit_offset;
906 public:
907 static int limit_offset();
908 static void compute_offsets();
909 };
911 class sun_misc_AtomicLongCSImpl: AllStatic {
912 private:
913 static int _value_offset;
915 public:
916 static int value_offset();
917 static void compute_offsets();
918 };
920 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic {
921 private:
922 static int _owner_offset;
923 public:
924 static void initialize(TRAPS);
925 static oop get_owner_threadObj(oop obj);
926 };
928 // Interface to hard-coded offset checking
930 class JavaClasses : AllStatic {
931 private:
932 static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
933 static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
934 static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0;
935 public:
936 static void compute_hard_coded_offsets();
937 static void compute_offsets();
938 static void check_offsets() PRODUCT_RETURN;
939 };