Mercurial > hg > graal-jvmci-8
annotate src/share/vm/classfile/javaClasses.hpp @ 431:a45484ea312d
6653858: dynamic languages need to be able to load anonymous classes
Summary: low-level privileged sun.misc.Unsafe.defineAnonymousClass
Reviewed-by: kvn
author | jrose |
---|---|
date | Wed, 12 Nov 2008 22:33:26 -0800 |
parents | d1605aabd0a1 |
children | c81d2ef51ca3 |
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; | |
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 | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
152 static bool is_instance(oop obj) { |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
153 return obj != NULL && obj->klass() == SystemDictionary::class_klass(); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
154 } |
0 | 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 }; | |
176 | |
177 // Interface to java.lang.Thread objects | |
178 | |
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 ; | |
196 | |
197 static void compute_offsets(); | |
198 | |
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); | |
231 | |
232 // Blocker object responsible for thread parking | |
233 static oop park_blocker(oop java_thread); | |
234 | |
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); | |
240 | |
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); | |
276 | |
277 static const char* thread_status_name(oop java_thread_oop); | |
278 | |
279 // Debugging | |
280 friend class JavaClasses; | |
281 }; | |
282 | |
283 // Interface to java.lang.ThreadGroup objects | |
284 | |
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; | |
297 | |
298 static void compute_offsets(); | |
299 | |
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 }; | |
325 | |
326 | |
327 | |
328 // Interface to java.lang.Throwable objects | |
329 | |
330 class java_lang_Throwable: AllStatic { | |
331 friend class BacktraceBuilder; | |
332 | |
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 }; | |
349 | |
350 static int backtrace_offset; | |
351 static int detailMessage_offset; | |
352 static int cause_offset; | |
353 static int stackTrace_offset; | |
354 | |
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(); | |
362 | |
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); | |
381 | |
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); | |
386 | |
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 }; | |
400 | |
401 | |
402 // Interface to java.lang.reflect.AccessibleObject objects | |
403 | |
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; | |
409 | |
410 static void compute_offsets(); | |
411 | |
412 public: | |
413 // Accessors | |
414 static jboolean override(oop reflect); | |
415 static void set_override(oop reflect, jboolean value); | |
416 | |
417 // Debugging | |
418 friend class JavaClasses; | |
419 }; | |
420 | |
421 | |
422 // Interface to java.lang.reflect.Method objects | |
423 | |
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; | |
439 | |
440 static void compute_offsets(); | |
441 | |
442 public: | |
443 // Allocation | |
444 static Handle create(TRAPS); | |
445 | |
446 // Accessors | |
447 static oop clazz(oop reflect); | |
448 static void set_clazz(oop reflect, oop value); | |
449 | |
450 static oop name(oop method); | |
451 static void set_name(oop method, oop value); | |
452 | |
453 static oop return_type(oop method); | |
454 static void set_return_type(oop method, oop value); | |
455 | |
456 static oop parameter_types(oop method); | |
457 static void set_parameter_types(oop method, oop value); | |
458 | |
459 static oop exception_types(oop method); | |
460 static void set_exception_types(oop method, oop value); | |
461 | |
462 static int slot(oop reflect); | |
463 static void set_slot(oop reflect, int value); | |
464 | |
465 static int modifiers(oop method); | |
466 static void set_modifiers(oop method, int value); | |
467 | |
468 static bool has_signature_field(); | |
469 static oop signature(oop method); | |
470 static void set_signature(oop method, oop value); | |
471 | |
472 static bool has_annotations_field(); | |
473 static oop annotations(oop method); | |
474 static void set_annotations(oop method, oop value); | |
475 | |
476 static bool has_parameter_annotations_field(); | |
477 static oop parameter_annotations(oop method); | |
478 static void set_parameter_annotations(oop method, oop value); | |
479 | |
480 static bool has_annotation_default_field(); | |
481 static oop annotation_default(oop method); | |
482 static void set_annotation_default(oop method, oop value); | |
483 | |
484 // Debugging | |
485 friend class JavaClasses; | |
486 }; | |
487 | |
488 | |
489 // Interface to java.lang.reflect.Constructor objects | |
490 | |
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; | |
503 | |
504 static void compute_offsets(); | |
505 | |
506 public: | |
507 // Allocation | |
508 static Handle create(TRAPS); | |
509 | |
510 // Accessors | |
511 static oop clazz(oop reflect); | |
512 static void set_clazz(oop reflect, oop value); | |
513 | |
514 static oop parameter_types(oop constructor); | |
515 static void set_parameter_types(oop constructor, oop value); | |
516 | |
517 static oop exception_types(oop constructor); | |
518 static void set_exception_types(oop constructor, oop value); | |
519 | |
520 static int slot(oop reflect); | |
521 static void set_slot(oop reflect, int value); | |
522 | |
523 static int modifiers(oop constructor); | |
524 static void set_modifiers(oop constructor, int value); | |
525 | |
526 static bool has_signature_field(); | |
527 static oop signature(oop constructor); | |
528 static void set_signature(oop constructor, oop value); | |
529 | |
530 static bool has_annotations_field(); | |
531 static oop annotations(oop constructor); | |
532 static void set_annotations(oop constructor, oop value); | |
533 | |
534 static bool has_parameter_annotations_field(); | |
535 static oop parameter_annotations(oop method); | |
536 static void set_parameter_annotations(oop method, oop value); | |
537 | |
538 // Debugging | |
539 friend class JavaClasses; | |
540 }; | |
541 | |
542 | |
543 // Interface to java.lang.reflect.Field objects | |
544 | |
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; | |
556 | |
557 static void compute_offsets(); | |
558 | |
559 public: | |
560 // Allocation | |
561 static Handle create(TRAPS); | |
562 | |
563 // Accessors | |
564 static oop clazz(oop reflect); | |
565 static void set_clazz(oop reflect, oop value); | |
566 | |
567 static oop name(oop field); | |
568 static void set_name(oop field, oop value); | |
569 | |
570 static oop type(oop field); | |
571 static void set_type(oop field, oop value); | |
572 | |
573 static int slot(oop reflect); | |
574 static void set_slot(oop reflect, int value); | |
575 | |
576 static int modifiers(oop field); | |
577 static void set_modifiers(oop field, int value); | |
578 | |
579 static bool has_signature_field(); | |
580 static oop signature(oop constructor); | |
581 static void set_signature(oop constructor, oop value); | |
582 | |
583 static bool has_annotations_field(); | |
584 static oop annotations(oop constructor); | |
585 static void set_annotations(oop constructor, oop value); | |
586 | |
587 static bool has_parameter_annotations_field(); | |
588 static oop parameter_annotations(oop method); | |
589 static void set_parameter_annotations(oop method, oop value); | |
590 | |
591 static bool has_annotation_default_field(); | |
592 static oop annotation_default(oop method); | |
593 static void set_annotation_default(oop method, oop value); | |
594 | |
595 // Debugging | |
596 friend class JavaClasses; | |
597 }; | |
598 | |
599 // 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; | |
605 | |
606 static void compute_offsets(); | |
607 | |
608 public: | |
609 // Allocation | |
610 static Handle create(TRAPS); | |
611 | |
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 } | |
618 | |
619 // Debugging | |
620 friend class JavaClasses; | |
621 }; | |
622 | |
623 // Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects | |
624 class sun_reflect_UnsafeStaticFieldAccessorImpl { | |
625 private: | |
626 static int _base_offset; | |
627 static void compute_offsets(); | |
628 | |
629 public: | |
630 static int base_offset() { | |
631 return _base_offset; | |
632 } | |
633 | |
634 // Debugging | |
635 friend class JavaClasses; | |
636 }; | |
637 | |
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 | |
647 | |
648 // This could be separated out into 8 individual classes. | |
649 | |
650 class java_lang_boxing_object: AllStatic { | |
651 private: | |
652 enum { | |
653 hc_value_offset = 0 | |
654 }; | |
655 static int value_offset; | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
656 static int long_value_offset; |
0 | 657 |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
658 static oop initialize_and_allocate(BasicType type, TRAPS); |
0 | 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); | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
665 static BasicType basic_type(oop box); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
666 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
|
667 static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; } |
0 | 668 |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
669 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
|
670 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
|
671 value_offset; |
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
672 } |
0 | 673 |
674 // Debugging | |
675 friend class JavaClasses; | |
676 }; | |
677 | |
678 | |
679 | |
680 // Interface to java.lang.ref.Reference objects | |
681 | |
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 }; | |
694 | |
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; | |
702 | |
703 // Accessors | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
704 static oop referent(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
705 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
|
706 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
707 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
|
708 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
|
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_raw(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_raw_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 HeapWord* referent_addr(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
714 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
|
715 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
716 static oop next(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(next_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 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
|
720 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
|
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_raw(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_raw_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 HeapWord* next_addr(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
726 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
|
727 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
728 static oop discovered(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(discovered_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 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
|
732 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
|
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_raw(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_raw_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 HeapWord* discovered_addr(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
738 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
|
739 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
740 // Accessors for statics |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
741 static oop pending_list_lock(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
742 static oop pending_list(); |
0 | 743 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
744 static HeapWord* pending_list_addr(); |
0 | 745 }; |
746 | |
747 | |
748 // Interface to java.lang.ref.SoftReference objects | |
749 | |
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. | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
754 hc_timestamp_offset = hc_discovered_offset + 1 |
0 | 755 }; |
756 enum { | |
757 hc_static_clock_offset = 0 | |
758 }; | |
759 | |
760 static int timestamp_offset; | |
761 static int static_clock_offset; | |
762 | |
763 // Accessors | |
764 static jlong timestamp(oop ref); | |
765 | |
766 // Accessors for statics | |
767 static jlong clock(); | |
768 static void set_clock(jlong value); | |
769 }; | |
770 | |
771 | |
772 // Interface to java.security.AccessControlContext objects | |
773 | |
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; | |
781 | |
782 static void compute_offsets(); | |
783 public: | |
784 static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS); | |
785 | |
786 // Debugging/initialization | |
787 friend class JavaClasses; | |
788 }; | |
789 | |
790 | |
791 // Interface to java.lang.ClassLoader objects | |
792 | |
793 class java_lang_ClassLoader : AllStatic { | |
794 private: | |
795 enum { | |
796 hc_parent_offset = 0 | |
797 }; | |
798 | |
799 static int parent_offset; | |
800 | |
801 public: | |
802 static oop parent(oop loader); | |
803 | |
804 static bool is_trusted_loader(oop loader); | |
805 | |
806 // Fix for 4474172 | |
807 static oop non_reflection_class_loader(oop loader); | |
808 | |
809 // Debugging | |
810 friend class JavaClasses; | |
811 }; | |
812 | |
813 | |
814 // Interface to java.lang.System objects | |
815 | |
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 }; | |
823 | |
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; | |
828 | |
829 static void compute_offsets(); | |
830 | |
831 public: | |
832 static int in_offset_in_bytes(); | |
833 static int out_offset_in_bytes(); | |
834 static int err_offset_in_bytes(); | |
835 | |
836 // Debugging | |
837 friend class JavaClasses; | |
838 }; | |
839 | |
840 | |
841 // Interface to java.lang.StackTraceElement objects | |
842 | |
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 }; | |
851 | |
852 static int declaringClass_offset; | |
853 static int methodName_offset; | |
854 static int fileName_offset; | |
855 static int lineNumber_offset; | |
856 | |
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); | |
863 | |
864 // Create an instance of StackTraceElement | |
865 static oop create(methodHandle m, int bci, TRAPS); | |
866 | |
867 // Debugging | |
868 friend class JavaClasses; | |
869 }; | |
870 | |
871 | |
872 // Interface to java.lang.AssertionStatusDirectives objects | |
873 | |
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 }; | |
883 | |
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; | |
889 | |
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 }; | |
900 | |
901 | |
902 class java_nio_Buffer: AllStatic { | |
903 private: | |
904 static int _limit_offset; | |
905 | |
906 public: | |
907 static int limit_offset(); | |
908 static void compute_offsets(); | |
909 }; | |
910 | |
911 class sun_misc_AtomicLongCSImpl: AllStatic { | |
912 private: | |
913 static int _value_offset; | |
914 | |
915 public: | |
916 static int value_offset(); | |
917 static void compute_offsets(); | |
918 }; | |
919 | |
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 }; | |
927 | |
928 // Interface to hard-coded offset checking | |
929 | |
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; | |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
934 static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
0 | 935 public: |
936 static void compute_hard_coded_offsets(); | |
937 static void compute_offsets(); | |
938 static void check_offsets() PRODUCT_RETURN; | |
939 }; |