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