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