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