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