Mercurial > hg > truffle
annotate src/share/vm/classfile/javaClasses.hpp @ 6233:d5bc62fcfac7
Merge
author | zgu |
---|---|
date | Thu, 19 Jul 2012 09:10:12 -0400 |
parents | 58ad5f22317e |
children | 1d7922586cf6 |
rev | line source |
---|---|
0 | 1 /* |
6057 | 2 * Copyright (c) 1997, 2012, 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 static int value_offset; | |
56 static int offset_offset; | |
57 static int count_offset; | |
58 static int hash_offset; | |
59 | |
6057 | 60 static bool initialized; |
61 | |
0 | 62 static Handle basic_create(int length, bool tenured, TRAPS); |
63 static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS); | |
64 | |
6057 | 65 static void set_value( oop string, typeArrayOop buffer) { |
66 assert(initialized, "Must be initialized"); | |
67 string->obj_field_put(value_offset, (oop)buffer); | |
68 } | |
69 static void set_offset(oop string, int offset) { | |
70 assert(initialized, "Must be initialized"); | |
71 if (offset_offset > 0) { | |
72 string->int_field_put(offset_offset, offset); | |
73 } | |
74 } | |
75 static void set_count( oop string, int count) { | |
76 assert(initialized, "Must be initialized"); | |
77 if (count_offset > 0) { | |
78 string->int_field_put(count_offset, count); | |
79 } | |
80 } | |
0 | 81 |
82 public: | |
6057 | 83 static void compute_offsets(); |
84 | |
0 | 85 // Instance creation |
86 static Handle create_from_unicode(jchar* unicode, int len, TRAPS); | |
87 static Handle create_tenured_from_unicode(jchar* unicode, int len, TRAPS); | |
88 static oop create_oop_from_unicode(jchar* unicode, int len, TRAPS); | |
89 static Handle create_from_str(const char* utf8_str, TRAPS); | |
90 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
|
91 static Handle create_from_symbol(Symbol* symbol, TRAPS); |
0 | 92 static Handle create_from_platform_dependent_str(const char* str, TRAPS); |
93 static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS); | |
94 | |
6057 | 95 static bool has_offset_field() { |
96 assert(initialized, "Must be initialized"); | |
97 return (offset_offset > 0); | |
98 } | |
99 | |
100 static bool has_count_field() { | |
101 assert(initialized, "Must be initialized"); | |
102 return (count_offset > 0); | |
103 } | |
104 | |
105 static bool has_hash_field() { | |
106 assert(initialized, "Must be initialized"); | |
107 return (hash_offset > 0); | |
108 } | |
109 | |
110 static int value_offset_in_bytes() { | |
111 assert(initialized && (value_offset > 0), "Must be initialized"); | |
112 return value_offset; | |
113 } | |
114 static int count_offset_in_bytes() { | |
115 assert(initialized && (count_offset > 0), "Must be initialized"); | |
116 return count_offset; | |
117 } | |
118 static int offset_offset_in_bytes() { | |
119 assert(initialized && (offset_offset > 0), "Must be initialized"); | |
120 return offset_offset; | |
121 } | |
122 static int hash_offset_in_bytes() { | |
123 assert(initialized && (hash_offset > 0), "Must be initialized"); | |
124 return hash_offset; | |
125 } | |
0 | 126 |
127 // Accessors | |
128 static typeArrayOop value(oop java_string) { | |
6057 | 129 assert(initialized && (value_offset > 0), "Must be initialized"); |
0 | 130 assert(is_instance(java_string), "must be java_string"); |
131 return (typeArrayOop) java_string->obj_field(value_offset); | |
132 } | |
133 static int offset(oop java_string) { | |
6057 | 134 assert(initialized, "Must be initialized"); |
0 | 135 assert(is_instance(java_string), "must be java_string"); |
6057 | 136 if (offset_offset > 0) { |
137 return java_string->int_field(offset_offset); | |
138 } else { | |
139 return 0; | |
140 } | |
0 | 141 } |
142 static int length(oop java_string) { | |
6057 | 143 assert(initialized, "Must be initialized"); |
0 | 144 assert(is_instance(java_string), "must be java_string"); |
6057 | 145 if (count_offset > 0) { |
146 return java_string->int_field(count_offset); | |
147 } else { | |
148 return ((typeArrayOop)java_string->obj_field(value_offset))->length(); | |
149 } | |
0 | 150 } |
151 static int utf8_length(oop java_string); | |
152 | |
153 // String converters | |
154 static char* as_utf8_string(oop java_string); | |
1989
017cd8bce8a8
6539281: -Xcheck:jni should validate char* argument to ReleaseStringUTFChars
sla
parents:
1972
diff
changeset
|
155 static char* as_utf8_string(oop java_string, char* buf, int buflen); |
0 | 156 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
|
157 static char* as_platform_dependent_str(Handle java_string, TRAPS); |
0 | 158 static jchar* as_unicode_string(oop java_string, int& length); |
159 | |
2418
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
160 // Compute the hash value for a java.lang.String object which would |
6162 | 161 // contain the characters passed in. |
2418
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
162 // |
6162 | 163 // As the hash value used by the String object itself, in |
164 // String.hashCode(). This value is normally calculated in Java code | |
165 // in the String.hashCode method(), but is precomputed for String | |
166 // objects in the shared archive file. | |
167 // hash P(31) from Kernighan & Ritchie | |
2418
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
168 // |
6162 | 169 // For this reason, THIS ALGORITHM MUST MATCH String.toHash(). |
170 template <typename T> static unsigned int to_hash(T* s, int len) { | |
2418
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
171 unsigned int h = 0; |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
172 while (len-- > 0) { |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
173 h = 31*h + (unsigned int) *s; |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
174 s++; |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
175 } |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
176 return h; |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
177 } |
6162 | 178 static unsigned int to_hash(oop java_string); |
179 | |
180 // This is the string hash code used by the StringTable, which may be | |
181 // the same as String.toHash or an alternate hash code. | |
2418
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
182 static unsigned int hash_string(oop java_string); |
352622fd140a
7032129: Native memory usage grow unexpectedly for vm/oom/*InternedString tests
never
parents:
2376
diff
changeset
|
183 |
0 | 184 static bool equals(oop java_string, jchar* chars, int len); |
185 | |
186 // Conversion between '.' and '/' formats | |
187 static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); } | |
188 static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); } | |
189 | |
190 // Conversion | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
191 static Symbol* as_symbol(Handle java_string, TRAPS); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
192 static Symbol* as_symbol_or_null(oop java_string); |
0 | 193 |
194 // Testers | |
195 static bool is_instance(oop obj) { | |
1142 | 196 return obj != NULL && obj->klass() == SystemDictionary::String_klass(); |
0 | 197 } |
198 | |
199 // Debugging | |
200 static void print(Handle java_string, outputStream* st); | |
201 friend class JavaClasses; | |
202 }; | |
203 | |
204 | |
205 // Interface to java.lang.Class objects | |
206 | |
3938 | 207 #define CLASS_INJECTED_FIELDS(macro) \ |
208 macro(java_lang_Class, klass, object_signature, false) \ | |
209 macro(java_lang_Class, resolved_constructor, object_signature, false) \ | |
210 macro(java_lang_Class, array_klass, object_signature, false) \ | |
211 macro(java_lang_Class, oop_size, int_signature, false) \ | |
212 macro(java_lang_Class, static_oop_field_count, int_signature, false) | |
213 | |
0 | 214 class java_lang_Class : AllStatic { |
3938 | 215 friend class VMStructs; |
216 | |
0 | 217 private: |
218 // The fake offsets are added by the class loader when java.lang.Class is loaded | |
219 | |
3938 | 220 static int _klass_offset; |
221 static int _resolved_constructor_offset; | |
222 static int _array_klass_offset; | |
0 | 223 |
3938 | 224 static int _oop_size_offset; |
225 static int _static_oop_field_count_offset; | |
0 | 226 |
227 static bool offsets_computed; | |
228 static int classRedefinedCount_offset; | |
229 | |
230 public: | |
3938 | 231 static void compute_offsets(); |
232 | |
0 | 233 // Instance creation |
234 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
|
235 static void fixup_mirror(KlassHandle k, TRAPS); |
0 | 236 static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); |
237 // Conversion | |
238 static klassOop as_klassOop(oop java_class); | |
4009 | 239 static void set_klass(oop java_class, klassOop klass); |
665
c89f86385056
6814659: separable cleanups and subroutines for 6655638
jrose
parents:
579
diff
changeset
|
240 static BasicType as_BasicType(oop java_class, klassOop* reference_klass = NULL); |
710 | 241 static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) { |
242 klassOop refk_oop = NULL; | |
243 BasicType result = as_BasicType(java_class, &refk_oop); | |
244 (*reference_klass) = KlassHandle(refk_oop); | |
245 return result; | |
246 } | |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
247 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
|
248 static void print_signature(oop java_class, outputStream *st); |
0 | 249 // Testing |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
250 static bool is_instance(oop obj) { |
1142 | 251 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
|
252 } |
0 | 253 static bool is_primitive(oop java_class); |
254 static BasicType primitive_type(oop java_class); | |
255 static oop primitive_mirror(BasicType t); | |
256 // JVM_NewInstance support | |
257 static methodOop resolved_constructor(oop java_class); | |
258 static void set_resolved_constructor(oop java_class, methodOop constructor); | |
259 // JVM_NewArray support | |
260 static klassOop array_klass(oop java_class); | |
261 static void set_array_klass(oop java_class, klassOop klass); | |
262 // compiler support for class operations | |
3938 | 263 static int klass_offset_in_bytes() { return _klass_offset; } |
264 static int resolved_constructor_offset_in_bytes() { return _resolved_constructor_offset; } | |
265 static int array_klass_offset_in_bytes() { return _array_klass_offset; } | |
0 | 266 // Support for classRedefinedCount field |
267 static int classRedefinedCount(oop the_class_mirror); | |
268 static void set_classRedefinedCount(oop the_class_mirror, int value); | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2357
diff
changeset
|
269 |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2357
diff
changeset
|
270 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
|
271 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
|
272 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
|
273 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
|
274 |
0 | 275 // Debugging |
276 friend class JavaClasses; | |
277 friend class instanceKlass; // verification code accesses offsets | |
278 friend class ClassFileParser; // access to number_of_fake_fields | |
279 }; | |
280 | |
281 // Interface to java.lang.Thread objects | |
282 | |
283 class java_lang_Thread : AllStatic { | |
284 private: | |
285 // Note that for this class the layout changed between JDK1.2 and JDK1.3, | |
286 // so we compute the offsets at startup rather than hard-wiring them. | |
287 static int _name_offset; | |
288 static int _group_offset; | |
289 static int _contextClassLoader_offset; | |
290 static int _inheritedAccessControlContext_offset; | |
291 static int _priority_offset; | |
292 static int _eetop_offset; | |
293 static int _daemon_offset; | |
294 static int _stillborn_offset; | |
295 static int _stackSize_offset; | |
296 static int _tid_offset; | |
297 static int _thread_status_offset; | |
298 static int _park_blocker_offset; | |
299 static int _park_event_offset ; | |
300 | |
301 static void compute_offsets(); | |
302 | |
303 public: | |
304 // Instance creation | |
305 static oop create(); | |
306 // Returns the JavaThread associated with the thread obj | |
307 static JavaThread* thread(oop java_thread); | |
308 // Set JavaThread for instance | |
309 static void set_thread(oop java_thread, JavaThread* thread); | |
310 // Name | |
311 static typeArrayOop name(oop java_thread); | |
312 static void set_name(oop java_thread, typeArrayOop name); | |
313 // Priority | |
314 static ThreadPriority priority(oop java_thread); | |
315 static void set_priority(oop java_thread, ThreadPriority priority); | |
316 // Thread group | |
317 static oop threadGroup(oop java_thread); | |
318 // Stillborn | |
319 static bool is_stillborn(oop java_thread); | |
320 static void set_stillborn(oop java_thread); | |
321 // Alive (NOTE: this is not really a field, but provides the correct | |
322 // definition without doing a Java call) | |
323 static bool is_alive(oop java_thread); | |
324 // Daemon | |
325 static bool is_daemon(oop java_thread); | |
326 static void set_daemon(oop java_thread); | |
327 // Context ClassLoader | |
328 static oop context_class_loader(oop java_thread); | |
329 // Control context | |
330 static oop inherited_access_control_context(oop java_thread); | |
331 // Stack size hint | |
332 static jlong stackSize(oop java_thread); | |
333 // Thread ID | |
334 static jlong thread_id(oop java_thread); | |
335 | |
336 // Blocker object responsible for thread parking | |
337 static oop park_blocker(oop java_thread); | |
338 | |
339 // Pointer to type-stable park handler, encoded as jlong. | |
340 // Should be set when apparently null | |
341 // For details, see unsafe.cpp Unsafe_Unpark | |
342 static jlong park_event(oop java_thread); | |
343 static bool set_park_event(oop java_thread, jlong ptr); | |
344 | |
345 // Java Thread Status for JVMTI and M&M use. | |
346 // This thread status info is saved in threadStatus field of | |
347 // java.lang.Thread java class. | |
348 enum ThreadStatus { | |
349 NEW = 0, | |
350 RUNNABLE = JVMTI_THREAD_STATE_ALIVE + // runnable / running | |
351 JVMTI_THREAD_STATE_RUNNABLE, | |
352 SLEEPING = JVMTI_THREAD_STATE_ALIVE + // Thread.sleep() | |
353 JVMTI_THREAD_STATE_WAITING + | |
354 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + | |
355 JVMTI_THREAD_STATE_SLEEPING, | |
356 IN_OBJECT_WAIT = JVMTI_THREAD_STATE_ALIVE + // Object.wait() | |
357 JVMTI_THREAD_STATE_WAITING + | |
358 JVMTI_THREAD_STATE_WAITING_INDEFINITELY + | |
359 JVMTI_THREAD_STATE_IN_OBJECT_WAIT, | |
360 IN_OBJECT_WAIT_TIMED = JVMTI_THREAD_STATE_ALIVE + // Object.wait(long) | |
361 JVMTI_THREAD_STATE_WAITING + | |
362 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + | |
363 JVMTI_THREAD_STATE_IN_OBJECT_WAIT, | |
364 PARKED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park() | |
365 JVMTI_THREAD_STATE_WAITING + | |
366 JVMTI_THREAD_STATE_WAITING_INDEFINITELY + | |
367 JVMTI_THREAD_STATE_PARKED, | |
368 PARKED_TIMED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park(long) | |
369 JVMTI_THREAD_STATE_WAITING + | |
370 JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + | |
371 JVMTI_THREAD_STATE_PARKED, | |
372 BLOCKED_ON_MONITOR_ENTER = JVMTI_THREAD_STATE_ALIVE + // (re-)entering a synchronization block | |
373 JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER, | |
374 TERMINATED = JVMTI_THREAD_STATE_TERMINATED | |
375 }; | |
376 // Write thread status info to threadStatus field of java.lang.Thread. | |
377 static void set_thread_status(oop java_thread_oop, ThreadStatus status); | |
378 // Read thread status info from threadStatus field of java.lang.Thread. | |
379 static ThreadStatus get_thread_status(oop java_thread_oop); | |
380 | |
381 static const char* thread_status_name(oop java_thread_oop); | |
382 | |
383 // Debugging | |
384 friend class JavaClasses; | |
385 }; | |
386 | |
387 // Interface to java.lang.ThreadGroup objects | |
388 | |
389 class java_lang_ThreadGroup : AllStatic { | |
390 private: | |
391 static int _parent_offset; | |
392 static int _name_offset; | |
393 static int _threads_offset; | |
394 static int _groups_offset; | |
395 static int _maxPriority_offset; | |
396 static int _destroyed_offset; | |
397 static int _daemon_offset; | |
398 static int _vmAllowSuspension_offset; | |
399 static int _nthreads_offset; | |
400 static int _ngroups_offset; | |
401 | |
402 static void compute_offsets(); | |
403 | |
404 public: | |
405 // parent ThreadGroup | |
406 static oop parent(oop java_thread_group); | |
407 // name | |
408 static typeArrayOop name(oop java_thread_group); | |
409 // ("name as oop" accessor is not necessary) | |
410 // Number of threads in group | |
411 static int nthreads(oop java_thread_group); | |
412 // threads | |
413 static objArrayOop threads(oop java_thread_group); | |
414 // Number of threads in group | |
415 static int ngroups(oop java_thread_group); | |
416 // groups | |
417 static objArrayOop groups(oop java_thread_group); | |
418 // maxPriority in group | |
419 static ThreadPriority maxPriority(oop java_thread_group); | |
420 // Destroyed | |
421 static bool is_destroyed(oop java_thread_group); | |
422 // Daemon | |
423 static bool is_daemon(oop java_thread_group); | |
424 // vmAllowSuspension | |
425 static bool is_vmAllowSuspension(oop java_thread_group); | |
426 // Debugging | |
427 friend class JavaClasses; | |
428 }; | |
429 | |
430 | |
431 | |
432 // Interface to java.lang.Throwable objects | |
433 | |
434 class java_lang_Throwable: AllStatic { | |
435 friend class BacktraceBuilder; | |
436 | |
437 private: | |
438 // Offsets | |
439 enum { | |
440 hc_backtrace_offset = 0, | |
441 hc_detailMessage_offset = 1, | |
442 hc_cause_offset = 2, // New since 1.4 | |
443 hc_stackTrace_offset = 3 // New since 1.4 | |
444 }; | |
3820
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3785
diff
changeset
|
445 enum { |
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3785
diff
changeset
|
446 hc_static_unassigned_stacktrace_offset = 0 // New since 1.7 |
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3785
diff
changeset
|
447 }; |
0 | 448 // Trace constants |
449 enum { | |
450 trace_methods_offset = 0, | |
451 trace_bcis_offset = 1, | |
452 trace_next_offset = 2, | |
453 trace_size = 3, | |
454 trace_chunk_size = 32 | |
455 }; | |
456 | |
457 static int backtrace_offset; | |
458 static int detailMessage_offset; | |
459 static int cause_offset; | |
460 static int stackTrace_offset; | |
3820
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3785
diff
changeset
|
461 static int static_unassigned_stacktrace_offset; |
0 | 462 |
463 // Printing | |
464 static char* print_stack_element_to_buffer(methodOop method, int bci); | |
465 static void print_to_stream(Handle stream, const char* str); | |
466 // StackTrace (programmatic access, new since 1.4) | |
467 static void clear_stacktrace(oop throwable); | |
468 // No stack trace available | |
469 static const char* no_stack_trace_message(); | |
3820
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3785
diff
changeset
|
470 // Stacktrace (post JDK 1.7.0 to allow immutability protocol to be followed) |
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3785
diff
changeset
|
471 static void set_stacktrace(oop throwable, oop st_element_array); |
0b80db433fcb
7046490: Preallocated OOME objects should obey Throwable stack trace protocol
dholmes
parents:
3785
diff
changeset
|
472 static oop unassigned_stacktrace(); |
0 | 473 |
474 public: | |
475 // Backtrace | |
476 static oop backtrace(oop throwable); | |
477 static void set_backtrace(oop throwable, oop value); | |
478 // Needed by JVMTI to filter out this internal field. | |
479 static int get_backtrace_offset() { return backtrace_offset;} | |
480 static int get_detailMessage_offset() { return detailMessage_offset;} | |
481 // Message | |
482 static oop message(oop throwable); | |
483 static oop message(Handle throwable); | |
484 static void set_message(oop throwable, oop value); | |
485 // Print stack trace stored in exception by call-back to Java | |
486 // Note: this is no longer used in Merlin, but we still suppport | |
487 // it for compatibility. | |
488 static void print_stack_trace(oop throwable, oop print_stream); | |
489 static void print_stack_element(Handle stream, methodOop method, int bci); | |
490 static void print_stack_element(outputStream *st, methodOop method, int bci); | |
491 static void print_stack_usage(Handle stream); | |
492 | |
493 // Allocate space for backtrace (created but stack trace not filled in) | |
494 static void allocate_backtrace(Handle throwable, TRAPS); | |
495 // Fill in current stack trace for throwable with preallocated backtrace (no GC) | |
496 static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable); | |
497 // Fill in current stack trace, can cause GC | |
3272
01147d8aac1d
7009923: JSR 292: VM crash in JavaThread::last_frame
coleenp
parents:
2418
diff
changeset
|
498 static void fill_in_stack_trace(Handle throwable, methodHandle method, TRAPS); |
01147d8aac1d
7009923: JSR 292: VM crash in JavaThread::last_frame
coleenp
parents:
2418
diff
changeset
|
499 static void fill_in_stack_trace(Handle throwable, methodHandle method = methodHandle()); |
0 | 500 // Programmatic access to stack trace |
501 static oop get_stack_trace_element(oop throwable, int index, TRAPS); | |
502 static int get_stack_trace_depth(oop throwable, TRAPS); | |
503 // Printing | |
504 static void print(oop throwable, outputStream* st); | |
505 static void print(Handle throwable, outputStream* st); | |
506 static void print_stack_trace(oop throwable, outputStream* st); | |
507 // Debugging | |
508 friend class JavaClasses; | |
509 }; | |
510 | |
511 | |
512 // Interface to java.lang.reflect.AccessibleObject objects | |
513 | |
514 class java_lang_reflect_AccessibleObject: AllStatic { | |
515 private: | |
516 // Note that to reduce dependencies on the JDK we compute these | |
517 // offsets at run-time. | |
518 static int override_offset; | |
519 | |
520 static void compute_offsets(); | |
521 | |
522 public: | |
523 // Accessors | |
524 static jboolean override(oop reflect); | |
525 static void set_override(oop reflect, jboolean value); | |
526 | |
527 // Debugging | |
528 friend class JavaClasses; | |
529 }; | |
530 | |
531 | |
532 // Interface to java.lang.reflect.Method objects | |
533 | |
534 class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject { | |
535 private: | |
536 // Note that to reduce dependencies on the JDK we compute these | |
537 // offsets at run-time. | |
538 static int clazz_offset; | |
539 static int name_offset; | |
540 static int returnType_offset; | |
541 static int parameterTypes_offset; | |
542 static int exceptionTypes_offset; | |
543 static int slot_offset; | |
544 static int modifiers_offset; | |
545 static int signature_offset; | |
546 static int annotations_offset; | |
547 static int parameter_annotations_offset; | |
548 static int annotation_default_offset; | |
549 | |
550 static void compute_offsets(); | |
551 | |
552 public: | |
553 // Allocation | |
554 static Handle create(TRAPS); | |
555 | |
556 // Accessors | |
557 static oop clazz(oop reflect); | |
558 static void set_clazz(oop reflect, oop value); | |
559 | |
560 static oop name(oop method); | |
561 static void set_name(oop method, oop value); | |
562 | |
563 static oop return_type(oop method); | |
564 static void set_return_type(oop method, oop value); | |
565 | |
566 static oop parameter_types(oop method); | |
567 static void set_parameter_types(oop method, oop value); | |
568 | |
569 static oop exception_types(oop method); | |
570 static void set_exception_types(oop method, oop value); | |
571 | |
572 static int slot(oop reflect); | |
573 static void set_slot(oop reflect, int value); | |
574 | |
575 static int modifiers(oop method); | |
576 static void set_modifiers(oop method, int value); | |
577 | |
578 static bool has_signature_field(); | |
579 static oop signature(oop method); | |
580 static void set_signature(oop method, oop value); | |
581 | |
582 static bool has_annotations_field(); | |
583 static oop annotations(oop method); | |
584 static void set_annotations(oop method, oop value); | |
585 | |
586 static bool has_parameter_annotations_field(); | |
587 static oop parameter_annotations(oop method); | |
588 static void set_parameter_annotations(oop method, oop value); | |
589 | |
590 static bool has_annotation_default_field(); | |
591 static oop annotation_default(oop method); | |
592 static void set_annotation_default(oop method, oop value); | |
593 | |
594 // Debugging | |
595 friend class JavaClasses; | |
596 }; | |
597 | |
598 | |
599 // Interface to java.lang.reflect.Constructor objects | |
600 | |
601 class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject { | |
602 private: | |
603 // Note that to reduce dependencies on the JDK we compute these | |
604 // offsets at run-time. | |
605 static int clazz_offset; | |
606 static int parameterTypes_offset; | |
607 static int exceptionTypes_offset; | |
608 static int slot_offset; | |
609 static int modifiers_offset; | |
610 static int signature_offset; | |
611 static int annotations_offset; | |
612 static int parameter_annotations_offset; | |
613 | |
614 static void compute_offsets(); | |
615 | |
616 public: | |
617 // Allocation | |
618 static Handle create(TRAPS); | |
619 | |
620 // Accessors | |
621 static oop clazz(oop reflect); | |
622 static void set_clazz(oop reflect, oop value); | |
623 | |
624 static oop parameter_types(oop constructor); | |
625 static void set_parameter_types(oop constructor, oop value); | |
626 | |
627 static oop exception_types(oop constructor); | |
628 static void set_exception_types(oop constructor, oop value); | |
629 | |
630 static int slot(oop reflect); | |
631 static void set_slot(oop reflect, int value); | |
632 | |
633 static int modifiers(oop constructor); | |
634 static void set_modifiers(oop constructor, int value); | |
635 | |
636 static bool has_signature_field(); | |
637 static oop signature(oop constructor); | |
638 static void set_signature(oop constructor, oop value); | |
639 | |
640 static bool has_annotations_field(); | |
641 static oop annotations(oop constructor); | |
642 static void set_annotations(oop constructor, oop value); | |
643 | |
644 static bool has_parameter_annotations_field(); | |
645 static oop parameter_annotations(oop method); | |
646 static void set_parameter_annotations(oop method, oop value); | |
647 | |
648 // Debugging | |
649 friend class JavaClasses; | |
650 }; | |
651 | |
652 | |
653 // Interface to java.lang.reflect.Field objects | |
654 | |
655 class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject { | |
656 private: | |
657 // Note that to reduce dependencies on the JDK we compute these | |
658 // offsets at run-time. | |
659 static int clazz_offset; | |
660 static int name_offset; | |
661 static int type_offset; | |
662 static int slot_offset; | |
663 static int modifiers_offset; | |
664 static int signature_offset; | |
665 static int annotations_offset; | |
666 | |
667 static void compute_offsets(); | |
668 | |
669 public: | |
670 // Allocation | |
671 static Handle create(TRAPS); | |
672 | |
673 // Accessors | |
674 static oop clazz(oop reflect); | |
675 static void set_clazz(oop reflect, oop value); | |
676 | |
677 static oop name(oop field); | |
678 static void set_name(oop field, oop value); | |
679 | |
680 static oop type(oop field); | |
681 static void set_type(oop field, oop value); | |
682 | |
683 static int slot(oop reflect); | |
684 static void set_slot(oop reflect, int value); | |
685 | |
686 static int modifiers(oop field); | |
687 static void set_modifiers(oop field, int value); | |
688 | |
689 static bool has_signature_field(); | |
690 static oop signature(oop constructor); | |
691 static void set_signature(oop constructor, oop value); | |
692 | |
693 static bool has_annotations_field(); | |
694 static oop annotations(oop constructor); | |
695 static void set_annotations(oop constructor, oop value); | |
696 | |
697 static bool has_parameter_annotations_field(); | |
698 static oop parameter_annotations(oop method); | |
699 static void set_parameter_annotations(oop method, oop value); | |
700 | |
701 static bool has_annotation_default_field(); | |
702 static oop annotation_default(oop method); | |
703 static void set_annotation_default(oop method, oop value); | |
704 | |
705 // Debugging | |
706 friend class JavaClasses; | |
707 }; | |
708 | |
709 // Interface to sun.reflect.ConstantPool objects | |
710 class sun_reflect_ConstantPool { | |
711 private: | |
712 // Note that to reduce dependencies on the JDK we compute these | |
713 // offsets at run-time. | |
714 static int _cp_oop_offset; | |
715 | |
716 static void compute_offsets(); | |
717 | |
718 public: | |
719 // Allocation | |
720 static Handle create(TRAPS); | |
721 | |
722 // Accessors | |
723 static oop cp_oop(oop reflect); | |
724 static void set_cp_oop(oop reflect, oop value); | |
725 static int cp_oop_offset() { | |
726 return _cp_oop_offset; | |
727 } | |
728 | |
729 // Debugging | |
730 friend class JavaClasses; | |
731 }; | |
732 | |
733 // Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects | |
734 class sun_reflect_UnsafeStaticFieldAccessorImpl { | |
735 private: | |
736 static int _base_offset; | |
737 static void compute_offsets(); | |
738 | |
739 public: | |
740 static int base_offset() { | |
741 return _base_offset; | |
742 } | |
743 | |
744 // Debugging | |
745 friend class JavaClasses; | |
746 }; | |
747 | |
748 // Interface to java.lang primitive type boxing objects: | |
749 // - java.lang.Boolean | |
750 // - java.lang.Character | |
751 // - java.lang.Float | |
752 // - java.lang.Double | |
753 // - java.lang.Byte | |
754 // - java.lang.Short | |
755 // - java.lang.Integer | |
756 // - java.lang.Long | |
757 | |
758 // This could be separated out into 8 individual classes. | |
759 | |
760 class java_lang_boxing_object: AllStatic { | |
761 private: | |
762 enum { | |
763 hc_value_offset = 0 | |
764 }; | |
765 static int value_offset; | |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
766 static int long_value_offset; |
0 | 767 |
132
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
768 static oop initialize_and_allocate(BasicType type, TRAPS); |
0 | 769 public: |
770 // Allocation. Returns a boxed value, or NULL for invalid type. | |
771 static oop create(BasicType type, jvalue* value, TRAPS); | |
772 // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop. | |
773 static BasicType get_value(oop box, jvalue* value); | |
774 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
|
775 static BasicType basic_type(oop box); |
60b728ec77c1
6652736: well known classes in system dictionary are inefficiently processed
jrose
parents:
113
diff
changeset
|
776 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
|
777 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
|
778 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
|
779 static void print(BasicType type, jvalue* value, outputStream* st); |
0 | 780 |
165
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
781 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
|
782 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
|
783 value_offset; |
437d03ea40b1
6703888: Compressed Oops: use the 32-bits gap after klass in a object
kvn
parents:
132
diff
changeset
|
784 } |
0 | 785 |
786 // Debugging | |
787 friend class JavaClasses; | |
788 }; | |
789 | |
790 | |
791 | |
792 // Interface to java.lang.ref.Reference objects | |
793 | |
794 class java_lang_ref_Reference: AllStatic { | |
795 public: | |
796 enum { | |
797 hc_referent_offset = 0, | |
798 hc_queue_offset = 1, | |
799 hc_next_offset = 2, | |
800 hc_discovered_offset = 3 // Is not last, see SoftRefs. | |
801 }; | |
802 enum { | |
803 hc_static_lock_offset = 0, | |
804 hc_static_pending_offset = 1 | |
805 }; | |
806 | |
807 static int referent_offset; | |
808 static int queue_offset; | |
809 static int next_offset; | |
810 static int discovered_offset; | |
811 static int static_lock_offset; | |
812 static int static_pending_offset; | |
813 static int number_of_fake_oop_fields; | |
814 | |
815 // Accessors | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
816 static oop referent(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
817 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
|
818 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
819 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
|
820 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
|
821 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
822 static void set_referent_raw(oop ref, oop value) { |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
823 ref->obj_field_put_raw(referent_offset, value); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
824 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
825 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
|
826 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
|
827 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
828 static oop next(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
829 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
|
830 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
831 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
|
832 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
|
833 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
834 static void set_next_raw(oop ref, oop value) { |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
835 ref->obj_field_put_raw(next_offset, value); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
836 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
837 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
|
838 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
|
839 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
840 static oop discovered(oop ref) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
841 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
|
842 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
843 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
|
844 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
|
845 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
846 static void set_discovered_raw(oop ref, oop value) { |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
847 ref->obj_field_put_raw(discovered_offset, value); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
848 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
849 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
|
850 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
|
851 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
852 // Accessors for statics |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
853 static oop pending_list_lock(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
854 static oop pending_list(); |
0 | 855 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
22
diff
changeset
|
856 static HeapWord* pending_list_addr(); |
0 | 857 }; |
858 | |
859 | |
860 // Interface to java.lang.ref.SoftReference objects | |
861 | |
862 class java_lang_ref_SoftReference: public java_lang_ref_Reference { | |
863 public: | |
864 enum { | |
865 // 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
|
866 hc_timestamp_offset = hc_discovered_offset + 1 |
0 | 867 }; |
868 enum { | |
869 hc_static_clock_offset = 0 | |
870 }; | |
871 | |
872 static int timestamp_offset; | |
873 static int static_clock_offset; | |
874 | |
875 // Accessors | |
876 static jlong timestamp(oop ref); | |
877 | |
878 // Accessors for statics | |
879 static jlong clock(); | |
880 static void set_clock(jlong value); | |
881 }; | |
882 | |
883 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
884 // Interface to java.lang.invoke.MethodHandle objects |
710 | 885 |
3938 | 886 #define METHODHANDLE_INJECTED_FIELDS(macro) \ |
887 macro(java_lang_invoke_MethodHandle, vmentry, intptr_signature, false) \ | |
888 macro(java_lang_invoke_MethodHandle, vmtarget, object_signature, true) | |
889 | |
710 | 890 class MethodHandleEntry; |
891 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
892 class java_lang_invoke_MethodHandle: AllStatic { |
710 | 893 friend class JavaClasses; |
894 | |
895 private: | |
3938 | 896 static int _vmentry_offset; // assembly code trampoline for MH |
897 static int _vmtarget_offset; // class-specific target reference | |
710 | 898 static int _type_offset; // the MethodType of this MH |
899 | |
900 static void compute_offsets(); | |
901 | |
902 public: | |
903 // Accessors | |
904 static oop type(oop mh); | |
905 static void set_type(oop mh, oop mtype); | |
906 | |
907 static oop vmtarget(oop mh); | |
908 static void set_vmtarget(oop mh, oop target); | |
909 | |
910 static MethodHandleEntry* vmentry(oop mh); | |
911 static void set_vmentry(oop mh, MethodHandleEntry* data); | |
912 | |
913 static int vmslots(oop mh); | |
914 | |
915 // Testers | |
916 static bool is_subclass(klassOop klass) { | |
917 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass()); | |
918 } | |
919 static bool is_instance(oop obj) { | |
920 return obj != NULL && is_subclass(obj->klass()); | |
921 } | |
922 | |
923 // Accessors for code generation: | |
924 static int type_offset_in_bytes() { return _type_offset; } | |
925 static int vmtarget_offset_in_bytes() { return _vmtarget_offset; } | |
926 static int vmentry_offset_in_bytes() { return _vmentry_offset; } | |
927 }; | |
928 | |
3938 | 929 #define DIRECTMETHODHANDLE_INJECTED_FIELDS(macro) \ |
930 macro(java_lang_invoke_DirectMethodHandle, vmindex, int_signature, true) | |
931 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
932 class java_lang_invoke_DirectMethodHandle: public java_lang_invoke_MethodHandle { |
710 | 933 friend class JavaClasses; |
934 | |
935 private: | |
936 static int _vmindex_offset; // negative or vtable idx or itable idx | |
937 static void compute_offsets(); | |
938 | |
939 public: | |
940 // Accessors | |
941 static int vmindex(oop mh); | |
942 static void set_vmindex(oop mh, int index); | |
943 | |
944 // Testers | |
945 static bool is_subclass(klassOop klass) { | |
946 return Klass::cast(klass)->is_subclass_of(SystemDictionary::DirectMethodHandle_klass()); | |
947 } | |
948 static bool is_instance(oop obj) { | |
949 return obj != NULL && is_subclass(obj->klass()); | |
950 } | |
951 | |
952 // Accessors for code generation: | |
953 static int vmindex_offset_in_bytes() { return _vmindex_offset; } | |
954 }; | |
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_BoundMethodHandle: public java_lang_invoke_MethodHandle { |
710 | 957 friend class JavaClasses; |
958 | |
959 private: | |
960 static int _argument_offset; // argument value bound into this MH | |
961 static int _vmargslot_offset; // relevant argument slot (<= vmslots) | |
962 static void compute_offsets(); | |
963 | |
964 public: | |
965 static oop argument(oop mh); | |
966 static void set_argument(oop mh, oop ref); | |
967 | |
968 static jint vmargslot(oop mh); | |
969 static void set_vmargslot(oop mh, jint slot); | |
970 | |
971 // Testers | |
972 static bool is_subclass(klassOop klass) { | |
973 return Klass::cast(klass)->is_subclass_of(SystemDictionary::BoundMethodHandle_klass()); | |
974 } | |
975 static bool is_instance(oop obj) { | |
976 return obj != NULL && is_subclass(obj->klass()); | |
977 } | |
978 | |
979 static int argument_offset_in_bytes() { return _argument_offset; } | |
980 static int vmargslot_offset_in_bytes() { return _vmargslot_offset; } | |
981 }; | |
982 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
983 class java_lang_invoke_AdapterMethodHandle: public java_lang_invoke_BoundMethodHandle { |
710 | 984 friend class JavaClasses; |
985 | |
986 private: | |
987 static int _conversion_offset; // type of conversion to apply | |
988 static void compute_offsets(); | |
989 | |
990 public: | |
991 static int conversion(oop mh); | |
992 static void set_conversion(oop mh, int conv); | |
993 | |
994 // Testers | |
995 static bool is_subclass(klassOop klass) { | |
996 return Klass::cast(klass)->is_subclass_of(SystemDictionary::AdapterMethodHandle_klass()); | |
997 } | |
998 static bool is_instance(oop obj) { | |
999 return obj != NULL && is_subclass(obj->klass()); | |
1000 } | |
1001 | |
1002 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants): | |
1003 enum { | |
1004 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
|
1005 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
|
1006 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
|
1007 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
|
1008 OP_REF_TO_PRIM = 0x4, // unboxes a wrapper to produce a primitive |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3272
diff
changeset
|
1009 OP_PRIM_TO_REF = 0x5, // boxes a primitive into a wrapper |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
1010 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
|
1011 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
|
1012 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
|
1013 OP_DROP_ARGS = 0x9, // remove one or more argument slots |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3272
diff
changeset
|
1014 OP_COLLECT_ARGS = 0xA, // combine arguments using an auxiliary function |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
1015 OP_SPREAD_ARGS = 0xB, // expand in place a varargs array (of known size) |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3272
diff
changeset
|
1016 OP_FOLD_ARGS = 0xC, // combine but do not remove arguments; prepend result |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3272
diff
changeset
|
1017 //OP_UNUSED_13 = 0xD, // unused code, perhaps for reified argument lists |
1039
987e948ebbc8
6815692: method handle code needs some cleanup (post-6655638)
jrose
parents:
726
diff
changeset
|
1018 CONV_OP_LIMIT = 0xE, // limit of CONV_OP enumeration |
710 | 1019 |
1020 CONV_OP_MASK = 0xF00, // this nybble contains the conversion op field | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3272
diff
changeset
|
1021 CONV_TYPE_MASK = 0x0F, // fits T_ADDRESS and below |
710 | 1022 CONV_VMINFO_MASK = 0x0FF, // LSB is reserved for JVM use |
1023 CONV_VMINFO_SHIFT = 0, // position of bits in CONV_VMINFO_MASK | |
1024 CONV_OP_SHIFT = 8, // position of bits in CONV_OP_MASK | |
1025 CONV_DEST_TYPE_SHIFT = 12, // byte 2 has the adapter BasicType (if needed) | |
1026 CONV_SRC_TYPE_SHIFT = 16, // byte 2 has the source BasicType (if needed) | |
1027 CONV_STACK_MOVE_SHIFT = 20, // high 12 bits give signed SP change | |
1028 CONV_STACK_MOVE_MASK = (1 << (32 - CONV_STACK_MOVE_SHIFT)) - 1 | |
1029 }; | |
1030 | |
1031 static int conversion_offset_in_bytes() { return _conversion_offset; } | |
1032 }; | |
1033 | |
1034 | |
3905
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1035 // A simple class that maintains an invocation count |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1036 class java_lang_invoke_CountingMethodHandle: public java_lang_invoke_MethodHandle { |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1037 friend class JavaClasses; |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1038 |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1039 private: |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1040 static int _vmcount_offset; |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1041 static void compute_offsets(); |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1042 |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1043 public: |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1044 // Accessors |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1045 static int vmcount(oop mh); |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1046 static void set_vmcount(oop mh, int count); |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1047 |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1048 // Testers |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1049 static bool is_subclass(klassOop klass) { |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1050 return SystemDictionary::CountingMethodHandle_klass() != NULL && |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1051 Klass::cast(klass)->is_subclass_of(SystemDictionary::CountingMethodHandle_klass()); |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1052 } |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1053 static bool is_instance(oop obj) { |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1054 return obj != NULL && is_subclass(obj->klass()); |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1055 } |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1056 |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1057 // Accessors for code generation: |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1058 static int vmcount_offset_in_bytes() { return _vmcount_offset; } |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1059 }; |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1060 |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1061 |
c26de9aef2ed
7071307: MethodHandle bimorphic inlining should consider the frequency
never
parents:
3820
diff
changeset
|
1062 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
1063 // Interface to java.lang.invoke.MemberName objects |
710 | 1064 // (These are a private interface for Java code to query the class hierarchy.) |
1065 | |
3938 | 1066 #define MEMBERNAME_INJECTED_FIELDS(macro) \ |
1067 macro(java_lang_invoke_MemberName, vmtarget, object_signature, true) | |
1068 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
1069 class java_lang_invoke_MemberName: AllStatic { |
710 | 1070 friend class JavaClasses; |
1071 | |
1072 private: | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
1073 // From java.lang.invoke.MemberName: |
710 | 1074 // private Class<?> clazz; // class in which the method is defined |
1075 // private String name; // may be null if not yet materialized | |
1076 // private Object type; // may be null if not yet materialized | |
1077 // private int flags; // modifier bits; see reflect.Modifier | |
1078 // private Object vmtarget; // VM-specific target value | |
1079 // private int vmindex; // method index within class or interface | |
1080 static int _clazz_offset; | |
1081 static int _name_offset; | |
1082 static int _type_offset; | |
1083 static int _flags_offset; | |
1084 static int _vmtarget_offset; | |
1085 static int _vmindex_offset; | |
1086 | |
1087 static void compute_offsets(); | |
1088 | |
1089 public: | |
1090 // Accessors | |
1091 static oop clazz(oop mname); | |
1092 static void set_clazz(oop mname, oop clazz); | |
1093 | |
1094 static oop type(oop mname); | |
1095 static void set_type(oop mname, oop type); | |
1096 | |
1097 static oop name(oop mname); | |
1098 static void set_name(oop mname, oop name); | |
1099 | |
1100 static int flags(oop mname); | |
1101 static void set_flags(oop mname, int flags); | |
1102 | |
1103 static int modifiers(oop mname) { return (u2) flags(mname); } | |
1104 static void set_modifiers(oop mname, int mods) | |
1105 { set_flags(mname, (flags(mname) &~ (u2)-1) | (u2)mods); } | |
1106 | |
1107 static oop vmtarget(oop mname); | |
1108 static void set_vmtarget(oop mname, oop target); | |
1109 | |
1110 static int vmindex(oop mname); | |
1111 static void set_vmindex(oop mname, int index); | |
1112 | |
1113 // Testers | |
1114 static bool is_subclass(klassOop klass) { | |
1115 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MemberName_klass()); | |
1116 } | |
1117 static bool is_instance(oop obj) { | |
1118 return obj != NULL && is_subclass(obj->klass()); | |
1119 } | |
1120 | |
1121 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants): | |
1122 enum { | |
1123 MN_IS_METHOD = 0x00010000, // method (not constructor) | |
1124 MN_IS_CONSTRUCTOR = 0x00020000, // constructor | |
1125 MN_IS_FIELD = 0x00040000, // field | |
1126 MN_IS_TYPE = 0x00080000, // nested type | |
1127 MN_SEARCH_SUPERCLASSES = 0x00100000, // for MHN.getMembers | |
1128 MN_SEARCH_INTERFACES = 0x00200000, // for MHN.getMembers | |
1129 VM_INDEX_UNINITIALIZED = -99 | |
1130 }; | |
1131 | |
1132 // Accessors for code generation: | |
1133 static int clazz_offset_in_bytes() { return _clazz_offset; } | |
1134 static int type_offset_in_bytes() { return _type_offset; } | |
1135 static int name_offset_in_bytes() { return _name_offset; } | |
1136 static int flags_offset_in_bytes() { return _flags_offset; } | |
1137 static int vmtarget_offset_in_bytes() { return _vmtarget_offset; } | |
1138 static int vmindex_offset_in_bytes() { return _vmindex_offset; } | |
1139 }; | |
1140 | |
1141 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
1142 // Interface to java.lang.invoke.MethodType objects |
710 | 1143 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
1144 class java_lang_invoke_MethodType: AllStatic { |
710 | 1145 friend class JavaClasses; |
1146 | |
1147 private: | |
1148 static int _rtype_offset; | |
1149 static int _ptypes_offset; | |
1150 static int _form_offset; | |
1151 | |
1152 static void compute_offsets(); | |
1153 | |
1154 public: | |
1155 // Accessors | |
1156 static oop rtype(oop mt); | |
1157 static objArrayOop ptypes(oop mt); | |
1158 static oop form(oop mt); | |
1159 | |
1160 static oop ptype(oop mt, int index); | |
1133
aa62b9388fce
6894206: JVM needs a way to traverse method handle structures
twisti
parents:
1059
diff
changeset
|
1161 static int ptype_count(oop mt); |
710 | 1162 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1989
diff
changeset
|
1163 static Symbol* as_signature(oop mt, bool intern_if_not_found, TRAPS); |
710 | 1164 static void print_signature(oop mt, outputStream* st); |
1165 | |
1166 static bool is_instance(oop obj) { | |
1167 return obj != NULL && obj->klass() == SystemDictionary::MethodType_klass(); | |
1168 } | |
1169 | |
3785
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3363
diff
changeset
|
1170 static bool equals(oop mt1, oop mt2); |
ddd894528dbc
7056328: JSR 292 invocation sometimes fails in adapters for types not on boot class path
jrose
parents:
3363
diff
changeset
|
1171 |
710 | 1172 // Accessors for code generation: |
1173 static int rtype_offset_in_bytes() { return _rtype_offset; } | |
1174 static int ptypes_offset_in_bytes() { return _ptypes_offset; } | |
1175 static int form_offset_in_bytes() { return _form_offset; } | |
1176 }; | |
1177 | |
3938 | 1178 #define METHODTYPEFORM_INJECTED_FIELDS(macro) \ |
1179 macro(java_lang_invoke_MethodTypeForm, vmslots, int_signature, true) \ | |
1180 macro(java_lang_invoke_MethodTypeForm, vmlayout, object_signature, true) | |
1181 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
1182 class java_lang_invoke_MethodTypeForm: AllStatic { |
710 | 1183 friend class JavaClasses; |
1184 | |
1185 private: | |
1186 static int _vmslots_offset; // number of argument slots needed | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3272
diff
changeset
|
1187 static int _vmlayout_offset; // object describing internal calling sequence |
710 | 1188 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
|
1189 static int _genericInvoker_offset; // genericInvoker = adapter for invokeGeneric |
710 | 1190 |
1191 static void compute_offsets(); | |
1192 | |
1193 public: | |
1194 // Accessors | |
1195 static int vmslots(oop mtform); | |
3938 | 1196 static void set_vmslots(oop mtform, int vmslots); |
1197 | |
710 | 1198 static oop erasedType(oop mtform); |
1793
d257356e35f0
6939224: MethodHandle.invokeGeneric needs to perform the correct set of conversions
jrose
parents:
1552
diff
changeset
|
1199 static oop genericInvoker(oop mtform); |
710 | 1200 |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3272
diff
changeset
|
1201 static oop vmlayout(oop mtform); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3272
diff
changeset
|
1202 static oop init_vmlayout(oop mtform, oop cookie); |
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3272
diff
changeset
|
1203 |
710 | 1204 // Accessors for code generation: |
1205 static int vmslots_offset_in_bytes() { return _vmslots_offset; } | |
3363
167b70ff3abc
6939861: JVM should handle more conversion operations
never
parents:
3272
diff
changeset
|
1206 static int vmlayout_offset_in_bytes() { return _vmlayout_offset; } |
710 | 1207 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
|
1208 static int genericInvoker_offset_in_bytes() { return _genericInvoker_offset; } |
710 | 1209 }; |
1210 | |
1211 | |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
1212 // Interface to java.lang.invoke.CallSite objects |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1213 |
2357
8033953d67ff
7012648: move JSR 292 to package java.lang.invoke and adjust names
jrose
parents:
2177
diff
changeset
|
1214 class java_lang_invoke_CallSite: AllStatic { |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1215 friend class JavaClasses; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1216 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1217 private: |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1218 static int _target_offset; |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1219 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1220 static void compute_offsets(); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1221 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1222 public: |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1223 // Accessors |
3932
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1224 static oop target( oop site) { return site->obj_field( _target_offset); } |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1225 static void set_target( oop site, oop target) { site->obj_field_put( _target_offset, target); } |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1226 |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1227 static volatile oop target_volatile(oop site) { return site->obj_field_volatile( _target_offset); } |
b0efc7ee3b31
7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods
twisti
parents:
3905
diff
changeset
|
1228 static void set_target_volatile(oop site, oop target) { site->obj_field_put_volatile(_target_offset, target); } |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1229 |
1135
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1230 // Testers |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1231 static bool is_subclass(klassOop klass) { |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1232 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
|
1233 } |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1234 static bool is_instance(oop obj) { |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1235 return obj != NULL && is_subclass(obj->klass()); |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1236 } |
e66fd840cb6b
6893081: method handle & invokedynamic code needs additional cleanup (post 6815692, 6858164)
twisti
parents:
1133
diff
changeset
|
1237 |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1238 // Accessors for code generation: |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1239 static int target_offset_in_bytes() { return _target_offset; } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
710
diff
changeset
|
1240 }; |
710 | 1241 |
1242 | |
0 | 1243 // Interface to java.security.AccessControlContext objects |
1244 | |
1245 class java_security_AccessControlContext: AllStatic { | |
1246 private: | |
1247 // Note that for this class the layout changed between JDK1.2 and JDK1.3, | |
1248 // so we compute the offsets at startup rather than hard-wiring them. | |
1249 static int _context_offset; | |
1250 static int _privilegedContext_offset; | |
1251 static int _isPrivileged_offset; | |
1252 | |
1253 static void compute_offsets(); | |
1254 public: | |
1255 static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS); | |
1256 | |
1257 // Debugging/initialization | |
1258 friend class JavaClasses; | |
1259 }; | |
1260 | |
1261 | |
1262 // Interface to java.lang.ClassLoader objects | |
1263 | |
1264 class java_lang_ClassLoader : AllStatic { | |
1265 private: | |
1266 enum { | |
1267 hc_parent_offset = 0 | |
1268 }; | |
1269 | |
3938 | 1270 static bool offsets_computed; |
0 | 1271 static int parent_offset; |
3938 | 1272 static int parallelCapable_offset; |
1273 | |
1274 static void compute_offsets(); | |
0 | 1275 |
1276 public: | |
1277 static oop parent(oop loader); | |
1278 | |
3938 | 1279 // Support for parallelCapable field |
1280 static bool parallelCapable(oop the_class_mirror); | |
1281 | |
0 | 1282 static bool is_trusted_loader(oop loader); |
1283 | |
1284 // Fix for 4474172 | |
1285 static oop non_reflection_class_loader(oop loader); | |
1286 | |
1287 // Debugging | |
1288 friend class JavaClasses; | |
1289 }; | |
1290 | |
1291 | |
1292 // Interface to java.lang.System objects | |
1293 | |
1294 class java_lang_System : AllStatic { | |
1295 private: | |
1296 enum { | |
1297 hc_static_in_offset = 0, | |
1298 hc_static_out_offset = 1, | |
1299 hc_static_err_offset = 2 | |
1300 }; | |
1301 | |
1302 static int static_in_offset; | |
1303 static int static_out_offset; | |
1304 static int static_err_offset; | |
1305 | |
1306 public: | |
1307 static int in_offset_in_bytes(); | |
1308 static int out_offset_in_bytes(); | |
1309 static int err_offset_in_bytes(); | |
1310 | |
1311 // Debugging | |
1312 friend class JavaClasses; | |
1313 }; | |
1314 | |
1315 | |
1316 // Interface to java.lang.StackTraceElement objects | |
1317 | |
1318 class java_lang_StackTraceElement: AllStatic { | |
1319 private: | |
1320 enum { | |
1321 hc_declaringClass_offset = 0, | |
1322 hc_methodName_offset = 1, | |
1323 hc_fileName_offset = 2, | |
1324 hc_lineNumber_offset = 3 | |
1325 }; | |
1326 | |
1327 static int declaringClass_offset; | |
1328 static int methodName_offset; | |
1329 static int fileName_offset; | |
1330 static int lineNumber_offset; | |
1331 | |
1332 public: | |
1333 // Setters | |
1334 static void set_declaringClass(oop element, oop value); | |
1335 static void set_methodName(oop element, oop value); | |
1336 static void set_fileName(oop element, oop value); | |
1337 static void set_lineNumber(oop element, int value); | |
1338 | |
1339 // Create an instance of StackTraceElement | |
1340 static oop create(methodHandle m, int bci, TRAPS); | |
1341 | |
1342 // Debugging | |
1343 friend class JavaClasses; | |
1344 }; | |
1345 | |
1346 | |
1347 // Interface to java.lang.AssertionStatusDirectives objects | |
1348 | |
1349 class java_lang_AssertionStatusDirectives: AllStatic { | |
1350 private: | |
1351 enum { | |
1352 hc_classes_offset, | |
1353 hc_classEnabled_offset, | |
1354 hc_packages_offset, | |
1355 hc_packageEnabled_offset, | |
1356 hc_deflt_offset | |
1357 }; | |
1358 | |
1359 static int classes_offset; | |
1360 static int classEnabled_offset; | |
1361 static int packages_offset; | |
1362 static int packageEnabled_offset; | |
1363 static int deflt_offset; | |
1364 | |
1365 public: | |
1366 // Setters | |
1367 static void set_classes(oop obj, oop val); | |
1368 static void set_classEnabled(oop obj, oop val); | |
1369 static void set_packages(oop obj, oop val); | |
1370 static void set_packageEnabled(oop obj, oop val); | |
1371 static void set_deflt(oop obj, bool val); | |
1372 // Debugging | |
1373 friend class JavaClasses; | |
1374 }; | |
1375 | |
1376 | |
1377 class java_nio_Buffer: AllStatic { | |
1378 private: | |
1379 static int _limit_offset; | |
1380 | |
1381 public: | |
1382 static int limit_offset(); | |
1383 static void compute_offsets(); | |
1384 }; | |
1385 | |
1386 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic { | |
1387 private: | |
1388 static int _owner_offset; | |
1389 public: | |
1390 static void initialize(TRAPS); | |
1391 static oop get_owner_threadObj(oop obj); | |
1392 }; | |
1393 | |
3938 | 1394 // Use to declare fields that need to be injected into Java classes |
1395 // for the JVM to use. The name_index and signature_index are | |
1396 // declared in vmSymbols. The may_be_java flag is used to declare | |
1397 // fields that might already exist in Java but should be injected if | |
1398 // they don't. Otherwise the field is unconditionally injected and | |
1399 // the JVM uses the injected one. This is to ensure that name | |
1400 // collisions don't occur. In general may_be_java should be false | |
1401 // unless there's a good reason. | |
1402 | |
1403 class InjectedField { | |
1404 public: | |
1405 const SystemDictionary::WKID klass_id; | |
1406 const vmSymbols::SID name_index; | |
1407 const vmSymbols::SID signature_index; | |
1408 const bool may_be_java; | |
1409 | |
1410 | |
1411 klassOop klass() const { return SystemDictionary::well_known_klass(klass_id); } | |
1412 Symbol* name() const { return lookup_symbol(name_index); } | |
1413 Symbol* signature() const { return lookup_symbol(signature_index); } | |
1414 | |
1415 int compute_offset(); | |
1416 | |
1417 // Find the Symbol for this index | |
1418 static Symbol* lookup_symbol(int symbol_index) { | |
1419 return vmSymbols::symbol_at((vmSymbols::SID)symbol_index); | |
1420 } | |
1421 }; | |
1422 | |
1423 #define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \ | |
1424 klass##_##name##_enum, | |
1425 | |
1426 #define ALL_INJECTED_FIELDS(macro) \ | |
1427 CLASS_INJECTED_FIELDS(macro) \ | |
1428 METHODHANDLE_INJECTED_FIELDS(macro) \ | |
1429 DIRECTMETHODHANDLE_INJECTED_FIELDS(macro) \ | |
1430 MEMBERNAME_INJECTED_FIELDS(macro) \ | |
1431 METHODTYPEFORM_INJECTED_FIELDS(macro) | |
1432 | |
0 | 1433 // Interface to hard-coded offset checking |
1434 | |
1435 class JavaClasses : AllStatic { | |
1436 private: | |
3938 | 1437 |
1438 static InjectedField _injected_fields[]; | |
1439 | |
0 | 1440 static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
1441 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
|
1442 static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0; |
3938 | 1443 |
0 | 1444 public: |
3938 | 1445 enum InjectedFieldID { |
1446 ALL_INJECTED_FIELDS(DECLARE_INJECTED_FIELD_ENUM) | |
1447 MAX_enum | |
1448 }; | |
1449 | |
1450 static int compute_injected_offset(InjectedFieldID id); | |
1451 | |
0 | 1452 static void compute_hard_coded_offsets(); |
1453 static void compute_offsets(); | |
1454 static void check_offsets() PRODUCT_RETURN; | |
3938 | 1455 |
1456 static InjectedField* get_injected(Symbol* class_name, int* field_count); | |
0 | 1457 }; |
1972 | 1458 |
3938 | 1459 #undef DECLARE_INJECTED_FIELD_ENUM |
1460 | |
1972 | 1461 #endif // SHARE_VM_CLASSFILE_JAVACLASSES_HPP |