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