duke@435: /* jrose@2639: * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_CLASSFILE_JAVACLASSES_HPP stefank@2314: #define SHARE_VM_CLASSFILE_JAVACLASSES_HPP stefank@2314: stefank@2314: #include "classfile/systemDictionary.hpp" stefank@2314: #include "jvmtifiles/jvmti.h" stefank@2314: #include "oops/oop.hpp" stefank@2314: #include "runtime/os.hpp" stefank@2314: #include "utilities/utf8.hpp" stefank@2314: duke@435: // Interface for manipulating the basic Java classes. duke@435: // duke@435: // All dependencies on layout of actual Java classes should be kept here. duke@435: // If the layout of any of the classes above changes the offsets must be adjusted. duke@435: // duke@435: // For most classes we hardwire the offsets for performance reasons. In certain duke@435: // cases (e.g. java.security.AccessControlContext) we compute the offsets at duke@435: // startup since the layout here differs between JDK1.2 and JDK1.3. duke@435: // duke@435: // Note that fields (static and non-static) are arranged with oops before non-oops duke@435: // on a per class basis. The offsets below have to reflect this ordering. duke@435: // duke@435: // When editing the layouts please update the check_offset verification code duke@435: // correspondingly. The names in the enums must be identical to the actual field duke@435: // names in order for the verification code to work. duke@435: duke@435: duke@435: // Interface to java.lang.String objects duke@435: duke@435: class java_lang_String : AllStatic { duke@435: private: duke@435: enum { duke@435: hc_value_offset = 0, jrose@567: hc_offset_offset = 1 jrose@567: //hc_count_offset = 2 -- not a word-scaled offset jrose@567: //hc_hash_offset = 3 -- not a word-scaled offset duke@435: }; duke@435: duke@435: static int value_offset; duke@435: static int offset_offset; duke@435: static int count_offset; duke@435: static int hash_offset; duke@435: duke@435: static Handle basic_create(int length, bool tenured, TRAPS); duke@435: static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS); duke@435: duke@435: static void set_value( oop string, typeArrayOop buffer) { string->obj_field_put(value_offset, (oop)buffer); } duke@435: static void set_offset(oop string, int offset) { string->int_field_put(offset_offset, offset); } duke@435: static void set_count( oop string, int count) { string->int_field_put(count_offset, count); } duke@435: duke@435: public: duke@435: // Instance creation duke@435: static Handle create_from_unicode(jchar* unicode, int len, TRAPS); duke@435: static Handle create_tenured_from_unicode(jchar* unicode, int len, TRAPS); duke@435: static oop create_oop_from_unicode(jchar* unicode, int len, TRAPS); duke@435: static Handle create_from_str(const char* utf8_str, TRAPS); duke@435: static oop create_oop_from_str(const char* utf8_str, TRAPS); coleenp@2497: static Handle create_from_symbol(Symbol* symbol, TRAPS); duke@435: static Handle create_from_platform_dependent_str(const char* str, TRAPS); duke@435: static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS); duke@435: duke@435: static int value_offset_in_bytes() { return value_offset; } duke@435: static int count_offset_in_bytes() { return count_offset; } duke@435: static int offset_offset_in_bytes() { return offset_offset; } duke@435: static int hash_offset_in_bytes() { return hash_offset; } duke@435: duke@435: // Accessors duke@435: static typeArrayOop value(oop java_string) { duke@435: assert(is_instance(java_string), "must be java_string"); duke@435: return (typeArrayOop) java_string->obj_field(value_offset); duke@435: } duke@435: static int offset(oop java_string) { duke@435: assert(is_instance(java_string), "must be java_string"); duke@435: return java_string->int_field(offset_offset); duke@435: } duke@435: static int length(oop java_string) { duke@435: assert(is_instance(java_string), "must be java_string"); duke@435: return java_string->int_field(count_offset); duke@435: } duke@435: static int utf8_length(oop java_string); duke@435: duke@435: // String converters duke@435: static char* as_utf8_string(oop java_string); sla@2331: static char* as_utf8_string(oop java_string, char* buf, int buflen); duke@435: static char* as_utf8_string(oop java_string, int start, int len); coleenp@457: static char* as_platform_dependent_str(Handle java_string, TRAPS); duke@435: static jchar* as_unicode_string(oop java_string, int& length); duke@435: never@2700: // Compute the hash value for a java.lang.String object which would never@2700: // contain the characters passed in. This hash value is used for at never@2700: // least two purposes. never@2700: // never@2700: // (a) As the hash value used by the StringTable for bucket selection never@2700: // and comparison (stored in the HashtableEntry structures). This never@2700: // is used in the String.intern() method. never@2700: // never@2700: // (b) As the hash value used by the String object itself, in never@2700: // String.hashCode(). This value is normally calculate in Java code never@2700: // in the String.hashCode method(), but is precomputed for String never@2700: // objects in the shared archive file. never@2700: // never@2700: // For this reason, THIS ALGORITHM MUST MATCH String.hashCode(). never@2700: static unsigned int hash_string(jchar* s, int len) { never@2700: unsigned int h = 0; never@2700: while (len-- > 0) { never@2700: h = 31*h + (unsigned int) *s; never@2700: s++; never@2700: } never@2700: return h; never@2700: } never@2700: static unsigned int hash_string(oop java_string); never@2700: duke@435: static bool equals(oop java_string, jchar* chars, int len); duke@435: duke@435: // Conversion between '.' and '/' formats duke@435: static Handle externalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '/', '.', THREAD); } duke@435: static Handle internalize_classname(Handle java_string, TRAPS) { return char_converter(java_string, '.', '/', THREAD); } duke@435: duke@435: // Conversion coleenp@2497: static Symbol* as_symbol(Handle java_string, TRAPS); coleenp@2497: static Symbol* as_symbol_or_null(oop java_string); duke@435: duke@435: // Testers duke@435: static bool is_instance(oop obj) { never@1577: return obj != NULL && obj->klass() == SystemDictionary::String_klass(); duke@435: } duke@435: duke@435: // Debugging duke@435: static void print(Handle java_string, outputStream* st); duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: duke@435: // Interface to java.lang.Class objects duke@435: duke@435: class java_lang_Class : AllStatic { duke@435: friend class VMStructs; duke@435: private: duke@435: // The fake offsets are added by the class loader when java.lang.Class is loaded duke@435: duke@435: enum { never@2658: hc_number_of_fake_oop_fields = 3, never@2658: hc_number_of_fake_int_fields = 2 duke@435: }; duke@435: duke@435: static int klass_offset; duke@435: static int resolved_constructor_offset; duke@435: static int array_klass_offset; duke@435: static int number_of_fake_oop_fields; duke@435: never@2658: static int oop_size_offset; never@2658: static int static_oop_field_count_offset; never@2658: duke@435: static void compute_offsets(); duke@435: static bool offsets_computed; duke@435: static int classRedefinedCount_offset; acorn@949: static int parallelCapable_offset; duke@435: duke@435: public: duke@435: // Instance creation duke@435: static oop create_mirror(KlassHandle k, TRAPS); never@2658: static void fixup_mirror(KlassHandle k, TRAPS); duke@435: static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS); duke@435: // Conversion duke@435: static klassOop as_klassOop(oop java_class); jrose@1100: static BasicType as_BasicType(oop java_class, klassOop* reference_klass = NULL); jrose@1145: static BasicType as_BasicType(oop java_class, KlassHandle* reference_klass) { jrose@1145: klassOop refk_oop = NULL; jrose@1145: BasicType result = as_BasicType(java_class, &refk_oop); jrose@1145: (*reference_klass) = KlassHandle(refk_oop); jrose@1145: return result; jrose@1145: } coleenp@2497: static Symbol* as_signature(oop java_class, bool intern_if_not_found, TRAPS); jrose@1100: static void print_signature(oop java_class, outputStream *st); duke@435: // Testing jrose@567: static bool is_instance(oop obj) { never@1577: return obj != NULL && obj->klass() == SystemDictionary::Class_klass(); jrose@567: } duke@435: static bool is_primitive(oop java_class); duke@435: static BasicType primitive_type(oop java_class); duke@435: static oop primitive_mirror(BasicType t); duke@435: // JVM_NewInstance support duke@435: static methodOop resolved_constructor(oop java_class); duke@435: static void set_resolved_constructor(oop java_class, methodOop constructor); duke@435: // JVM_NewArray support duke@435: static klassOop array_klass(oop java_class); duke@435: static void set_array_klass(oop java_class, klassOop klass); duke@435: // compiler support for class operations duke@435: static int klass_offset_in_bytes() { return klass_offset; } duke@435: static int resolved_constructor_offset_in_bytes() { return resolved_constructor_offset; } duke@435: static int array_klass_offset_in_bytes() { return array_klass_offset; } duke@435: // Support for classRedefinedCount field duke@435: static int classRedefinedCount(oop the_class_mirror); duke@435: static void set_classRedefinedCount(oop the_class_mirror, int value); acorn@949: // Support for parallelCapable field acorn@949: static bool parallelCapable(oop the_class_mirror); never@2658: never@2658: static int oop_size(oop java_class); never@2658: static void set_oop_size(oop java_class, int size); never@2658: static int static_oop_field_count(oop java_class); never@2658: static void set_static_oop_field_count(oop java_class, int size); never@2658: duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: friend class instanceKlass; // verification code accesses offsets duke@435: friend class ClassFileParser; // access to number_of_fake_fields duke@435: }; duke@435: duke@435: // Interface to java.lang.Thread objects duke@435: duke@435: class java_lang_Thread : AllStatic { duke@435: private: duke@435: // Note that for this class the layout changed between JDK1.2 and JDK1.3, duke@435: // so we compute the offsets at startup rather than hard-wiring them. duke@435: static int _name_offset; duke@435: static int _group_offset; duke@435: static int _contextClassLoader_offset; duke@435: static int _inheritedAccessControlContext_offset; duke@435: static int _priority_offset; duke@435: static int _eetop_offset; duke@435: static int _daemon_offset; duke@435: static int _stillborn_offset; duke@435: static int _stackSize_offset; duke@435: static int _tid_offset; duke@435: static int _thread_status_offset; duke@435: static int _park_blocker_offset; duke@435: static int _park_event_offset ; duke@435: duke@435: static void compute_offsets(); duke@435: duke@435: public: duke@435: // Instance creation duke@435: static oop create(); duke@435: // Returns the JavaThread associated with the thread obj duke@435: static JavaThread* thread(oop java_thread); duke@435: // Set JavaThread for instance duke@435: static void set_thread(oop java_thread, JavaThread* thread); duke@435: // Name duke@435: static typeArrayOop name(oop java_thread); duke@435: static void set_name(oop java_thread, typeArrayOop name); duke@435: // Priority duke@435: static ThreadPriority priority(oop java_thread); duke@435: static void set_priority(oop java_thread, ThreadPriority priority); duke@435: // Thread group duke@435: static oop threadGroup(oop java_thread); duke@435: // Stillborn duke@435: static bool is_stillborn(oop java_thread); duke@435: static void set_stillborn(oop java_thread); duke@435: // Alive (NOTE: this is not really a field, but provides the correct duke@435: // definition without doing a Java call) duke@435: static bool is_alive(oop java_thread); duke@435: // Daemon duke@435: static bool is_daemon(oop java_thread); duke@435: static void set_daemon(oop java_thread); duke@435: // Context ClassLoader duke@435: static oop context_class_loader(oop java_thread); duke@435: // Control context duke@435: static oop inherited_access_control_context(oop java_thread); duke@435: // Stack size hint duke@435: static jlong stackSize(oop java_thread); duke@435: // Thread ID duke@435: static jlong thread_id(oop java_thread); duke@435: duke@435: // Blocker object responsible for thread parking duke@435: static oop park_blocker(oop java_thread); duke@435: duke@435: // Pointer to type-stable park handler, encoded as jlong. duke@435: // Should be set when apparently null duke@435: // For details, see unsafe.cpp Unsafe_Unpark duke@435: static jlong park_event(oop java_thread); duke@435: static bool set_park_event(oop java_thread, jlong ptr); duke@435: duke@435: // Java Thread Status for JVMTI and M&M use. duke@435: // This thread status info is saved in threadStatus field of duke@435: // java.lang.Thread java class. duke@435: enum ThreadStatus { duke@435: NEW = 0, duke@435: RUNNABLE = JVMTI_THREAD_STATE_ALIVE + // runnable / running duke@435: JVMTI_THREAD_STATE_RUNNABLE, duke@435: SLEEPING = JVMTI_THREAD_STATE_ALIVE + // Thread.sleep() duke@435: JVMTI_THREAD_STATE_WAITING + duke@435: JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + duke@435: JVMTI_THREAD_STATE_SLEEPING, duke@435: IN_OBJECT_WAIT = JVMTI_THREAD_STATE_ALIVE + // Object.wait() duke@435: JVMTI_THREAD_STATE_WAITING + duke@435: JVMTI_THREAD_STATE_WAITING_INDEFINITELY + duke@435: JVMTI_THREAD_STATE_IN_OBJECT_WAIT, duke@435: IN_OBJECT_WAIT_TIMED = JVMTI_THREAD_STATE_ALIVE + // Object.wait(long) duke@435: JVMTI_THREAD_STATE_WAITING + duke@435: JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + duke@435: JVMTI_THREAD_STATE_IN_OBJECT_WAIT, duke@435: PARKED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park() duke@435: JVMTI_THREAD_STATE_WAITING + duke@435: JVMTI_THREAD_STATE_WAITING_INDEFINITELY + duke@435: JVMTI_THREAD_STATE_PARKED, duke@435: PARKED_TIMED = JVMTI_THREAD_STATE_ALIVE + // LockSupport.park(long) duke@435: JVMTI_THREAD_STATE_WAITING + duke@435: JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT + duke@435: JVMTI_THREAD_STATE_PARKED, duke@435: BLOCKED_ON_MONITOR_ENTER = JVMTI_THREAD_STATE_ALIVE + // (re-)entering a synchronization block duke@435: JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER, duke@435: TERMINATED = JVMTI_THREAD_STATE_TERMINATED duke@435: }; duke@435: // Write thread status info to threadStatus field of java.lang.Thread. duke@435: static void set_thread_status(oop java_thread_oop, ThreadStatus status); duke@435: // Read thread status info from threadStatus field of java.lang.Thread. duke@435: static ThreadStatus get_thread_status(oop java_thread_oop); duke@435: duke@435: static const char* thread_status_name(oop java_thread_oop); duke@435: duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: // Interface to java.lang.ThreadGroup objects duke@435: duke@435: class java_lang_ThreadGroup : AllStatic { duke@435: private: duke@435: static int _parent_offset; duke@435: static int _name_offset; duke@435: static int _threads_offset; duke@435: static int _groups_offset; duke@435: static int _maxPriority_offset; duke@435: static int _destroyed_offset; duke@435: static int _daemon_offset; duke@435: static int _vmAllowSuspension_offset; duke@435: static int _nthreads_offset; duke@435: static int _ngroups_offset; duke@435: duke@435: static void compute_offsets(); duke@435: duke@435: public: duke@435: // parent ThreadGroup duke@435: static oop parent(oop java_thread_group); duke@435: // name duke@435: static typeArrayOop name(oop java_thread_group); duke@435: // ("name as oop" accessor is not necessary) duke@435: // Number of threads in group duke@435: static int nthreads(oop java_thread_group); duke@435: // threads duke@435: static objArrayOop threads(oop java_thread_group); duke@435: // Number of threads in group duke@435: static int ngroups(oop java_thread_group); duke@435: // groups duke@435: static objArrayOop groups(oop java_thread_group); duke@435: // maxPriority in group duke@435: static ThreadPriority maxPriority(oop java_thread_group); duke@435: // Destroyed duke@435: static bool is_destroyed(oop java_thread_group); duke@435: // Daemon duke@435: static bool is_daemon(oop java_thread_group); duke@435: // vmAllowSuspension duke@435: static bool is_vmAllowSuspension(oop java_thread_group); duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: duke@435: duke@435: // Interface to java.lang.Throwable objects duke@435: duke@435: class java_lang_Throwable: AllStatic { duke@435: friend class BacktraceBuilder; duke@435: duke@435: private: duke@435: // Offsets duke@435: enum { duke@435: hc_backtrace_offset = 0, duke@435: hc_detailMessage_offset = 1, duke@435: hc_cause_offset = 2, // New since 1.4 duke@435: hc_stackTrace_offset = 3 // New since 1.4 duke@435: }; duke@435: // Trace constants duke@435: enum { duke@435: trace_methods_offset = 0, duke@435: trace_bcis_offset = 1, duke@435: trace_next_offset = 2, duke@435: trace_size = 3, duke@435: trace_chunk_size = 32 duke@435: }; duke@435: duke@435: static int backtrace_offset; duke@435: static int detailMessage_offset; duke@435: static int cause_offset; duke@435: static int stackTrace_offset; duke@435: duke@435: // Printing duke@435: static char* print_stack_element_to_buffer(methodOop method, int bci); duke@435: static void print_to_stream(Handle stream, const char* str); duke@435: // StackTrace (programmatic access, new since 1.4) duke@435: static void clear_stacktrace(oop throwable); duke@435: // No stack trace available duke@435: static const char* no_stack_trace_message(); duke@435: duke@435: public: duke@435: // Backtrace duke@435: static oop backtrace(oop throwable); duke@435: static void set_backtrace(oop throwable, oop value); duke@435: // Needed by JVMTI to filter out this internal field. duke@435: static int get_backtrace_offset() { return backtrace_offset;} duke@435: static int get_detailMessage_offset() { return detailMessage_offset;} duke@435: // Message duke@435: static oop message(oop throwable); duke@435: static oop message(Handle throwable); duke@435: static void set_message(oop throwable, oop value); duke@435: // Print stack trace stored in exception by call-back to Java duke@435: // Note: this is no longer used in Merlin, but we still suppport duke@435: // it for compatibility. duke@435: static void print_stack_trace(oop throwable, oop print_stream); duke@435: static void print_stack_element(Handle stream, methodOop method, int bci); duke@435: static void print_stack_element(outputStream *st, methodOop method, int bci); duke@435: static void print_stack_usage(Handle stream); duke@435: duke@435: // Allocate space for backtrace (created but stack trace not filled in) duke@435: static void allocate_backtrace(Handle throwable, TRAPS); duke@435: // Fill in current stack trace for throwable with preallocated backtrace (no GC) duke@435: static void fill_in_stack_trace_of_preallocated_backtrace(Handle throwable); duke@435: duke@435: // Fill in current stack trace, can cause GC coleenp@2804: static void fill_in_stack_trace(Handle throwable, methodHandle method, TRAPS); coleenp@2804: static void fill_in_stack_trace(Handle throwable, methodHandle method = methodHandle()); duke@435: // Programmatic access to stack trace duke@435: static oop get_stack_trace_element(oop throwable, int index, TRAPS); duke@435: static int get_stack_trace_depth(oop throwable, TRAPS); duke@435: // Printing duke@435: static void print(oop throwable, outputStream* st); duke@435: static void print(Handle throwable, outputStream* st); duke@435: static void print_stack_trace(oop throwable, outputStream* st); duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: duke@435: // Interface to java.lang.reflect.AccessibleObject objects duke@435: duke@435: class java_lang_reflect_AccessibleObject: AllStatic { duke@435: private: duke@435: // Note that to reduce dependencies on the JDK we compute these duke@435: // offsets at run-time. duke@435: static int override_offset; duke@435: duke@435: static void compute_offsets(); duke@435: duke@435: public: duke@435: // Accessors duke@435: static jboolean override(oop reflect); duke@435: static void set_override(oop reflect, jboolean value); duke@435: duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: duke@435: // Interface to java.lang.reflect.Method objects duke@435: duke@435: class java_lang_reflect_Method : public java_lang_reflect_AccessibleObject { duke@435: private: duke@435: // Note that to reduce dependencies on the JDK we compute these duke@435: // offsets at run-time. duke@435: static int clazz_offset; duke@435: static int name_offset; duke@435: static int returnType_offset; duke@435: static int parameterTypes_offset; duke@435: static int exceptionTypes_offset; duke@435: static int slot_offset; duke@435: static int modifiers_offset; duke@435: static int signature_offset; duke@435: static int annotations_offset; duke@435: static int parameter_annotations_offset; duke@435: static int annotation_default_offset; duke@435: duke@435: static void compute_offsets(); duke@435: duke@435: public: duke@435: // Allocation duke@435: static Handle create(TRAPS); duke@435: duke@435: // Accessors duke@435: static oop clazz(oop reflect); duke@435: static void set_clazz(oop reflect, oop value); duke@435: duke@435: static oop name(oop method); duke@435: static void set_name(oop method, oop value); duke@435: duke@435: static oop return_type(oop method); duke@435: static void set_return_type(oop method, oop value); duke@435: duke@435: static oop parameter_types(oop method); duke@435: static void set_parameter_types(oop method, oop value); duke@435: duke@435: static oop exception_types(oop method); duke@435: static void set_exception_types(oop method, oop value); duke@435: duke@435: static int slot(oop reflect); duke@435: static void set_slot(oop reflect, int value); duke@435: duke@435: static int modifiers(oop method); duke@435: static void set_modifiers(oop method, int value); duke@435: duke@435: static bool has_signature_field(); duke@435: static oop signature(oop method); duke@435: static void set_signature(oop method, oop value); duke@435: duke@435: static bool has_annotations_field(); duke@435: static oop annotations(oop method); duke@435: static void set_annotations(oop method, oop value); duke@435: duke@435: static bool has_parameter_annotations_field(); duke@435: static oop parameter_annotations(oop method); duke@435: static void set_parameter_annotations(oop method, oop value); duke@435: duke@435: static bool has_annotation_default_field(); duke@435: static oop annotation_default(oop method); duke@435: static void set_annotation_default(oop method, oop value); duke@435: duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: duke@435: // Interface to java.lang.reflect.Constructor objects duke@435: duke@435: class java_lang_reflect_Constructor : public java_lang_reflect_AccessibleObject { duke@435: private: duke@435: // Note that to reduce dependencies on the JDK we compute these duke@435: // offsets at run-time. duke@435: static int clazz_offset; duke@435: static int parameterTypes_offset; duke@435: static int exceptionTypes_offset; duke@435: static int slot_offset; duke@435: static int modifiers_offset; duke@435: static int signature_offset; duke@435: static int annotations_offset; duke@435: static int parameter_annotations_offset; duke@435: duke@435: static void compute_offsets(); duke@435: duke@435: public: duke@435: // Allocation duke@435: static Handle create(TRAPS); duke@435: duke@435: // Accessors duke@435: static oop clazz(oop reflect); duke@435: static void set_clazz(oop reflect, oop value); duke@435: duke@435: static oop parameter_types(oop constructor); duke@435: static void set_parameter_types(oop constructor, oop value); duke@435: duke@435: static oop exception_types(oop constructor); duke@435: static void set_exception_types(oop constructor, oop value); duke@435: duke@435: static int slot(oop reflect); duke@435: static void set_slot(oop reflect, int value); duke@435: duke@435: static int modifiers(oop constructor); duke@435: static void set_modifiers(oop constructor, int value); duke@435: duke@435: static bool has_signature_field(); duke@435: static oop signature(oop constructor); duke@435: static void set_signature(oop constructor, oop value); duke@435: duke@435: static bool has_annotations_field(); duke@435: static oop annotations(oop constructor); duke@435: static void set_annotations(oop constructor, oop value); duke@435: duke@435: static bool has_parameter_annotations_field(); duke@435: static oop parameter_annotations(oop method); duke@435: static void set_parameter_annotations(oop method, oop value); duke@435: duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: duke@435: // Interface to java.lang.reflect.Field objects duke@435: duke@435: class java_lang_reflect_Field : public java_lang_reflect_AccessibleObject { duke@435: private: duke@435: // Note that to reduce dependencies on the JDK we compute these duke@435: // offsets at run-time. duke@435: static int clazz_offset; duke@435: static int name_offset; duke@435: static int type_offset; duke@435: static int slot_offset; duke@435: static int modifiers_offset; duke@435: static int signature_offset; duke@435: static int annotations_offset; duke@435: duke@435: static void compute_offsets(); duke@435: duke@435: public: duke@435: // Allocation duke@435: static Handle create(TRAPS); duke@435: duke@435: // Accessors duke@435: static oop clazz(oop reflect); duke@435: static void set_clazz(oop reflect, oop value); duke@435: duke@435: static oop name(oop field); duke@435: static void set_name(oop field, oop value); duke@435: duke@435: static oop type(oop field); duke@435: static void set_type(oop field, oop value); duke@435: duke@435: static int slot(oop reflect); duke@435: static void set_slot(oop reflect, int value); duke@435: duke@435: static int modifiers(oop field); duke@435: static void set_modifiers(oop field, int value); duke@435: duke@435: static bool has_signature_field(); duke@435: static oop signature(oop constructor); duke@435: static void set_signature(oop constructor, oop value); duke@435: duke@435: static bool has_annotations_field(); duke@435: static oop annotations(oop constructor); duke@435: static void set_annotations(oop constructor, oop value); duke@435: duke@435: static bool has_parameter_annotations_field(); duke@435: static oop parameter_annotations(oop method); duke@435: static void set_parameter_annotations(oop method, oop value); duke@435: duke@435: static bool has_annotation_default_field(); duke@435: static oop annotation_default(oop method); duke@435: static void set_annotation_default(oop method, oop value); duke@435: duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: // Interface to sun.reflect.ConstantPool objects duke@435: class sun_reflect_ConstantPool { duke@435: private: duke@435: // Note that to reduce dependencies on the JDK we compute these duke@435: // offsets at run-time. duke@435: static int _cp_oop_offset; duke@435: duke@435: static void compute_offsets(); duke@435: duke@435: public: duke@435: // Allocation duke@435: static Handle create(TRAPS); duke@435: duke@435: // Accessors duke@435: static oop cp_oop(oop reflect); duke@435: static void set_cp_oop(oop reflect, oop value); duke@435: static int cp_oop_offset() { duke@435: return _cp_oop_offset; duke@435: } duke@435: duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: // Interface to sun.reflect.UnsafeStaticFieldAccessorImpl objects duke@435: class sun_reflect_UnsafeStaticFieldAccessorImpl { duke@435: private: duke@435: static int _base_offset; duke@435: static void compute_offsets(); duke@435: duke@435: public: duke@435: static int base_offset() { duke@435: return _base_offset; duke@435: } duke@435: duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: // Interface to java.lang primitive type boxing objects: duke@435: // - java.lang.Boolean duke@435: // - java.lang.Character duke@435: // - java.lang.Float duke@435: // - java.lang.Double duke@435: // - java.lang.Byte duke@435: // - java.lang.Short duke@435: // - java.lang.Integer duke@435: // - java.lang.Long duke@435: duke@435: // This could be separated out into 8 individual classes. duke@435: duke@435: class java_lang_boxing_object: AllStatic { duke@435: private: duke@435: enum { duke@435: hc_value_offset = 0 duke@435: }; duke@435: static int value_offset; kvn@600: static int long_value_offset; duke@435: jrose@567: static oop initialize_and_allocate(BasicType type, TRAPS); duke@435: public: duke@435: // Allocation. Returns a boxed value, or NULL for invalid type. duke@435: static oop create(BasicType type, jvalue* value, TRAPS); duke@435: // Accessors. Returns the basic type being boxed, or T_ILLEGAL for invalid oop. duke@435: static BasicType get_value(oop box, jvalue* value); duke@435: static BasicType set_value(oop box, jvalue* value); jrose@567: static BasicType basic_type(oop box); jrose@567: static bool is_instance(oop box) { return basic_type(box) != T_ILLEGAL; } jrose@567: static bool is_instance(oop box, BasicType type) { return basic_type(box) == type; } jrose@1100: static void print(oop box, outputStream* st) { jvalue value; print(get_value(box, &value), &value, st); } jrose@1100: static void print(BasicType type, jvalue* value, outputStream* st); duke@435: kvn@600: static int value_offset_in_bytes(BasicType type) { kvn@600: return ( type == T_LONG || type == T_DOUBLE ) ? long_value_offset : kvn@600: value_offset; kvn@600: } duke@435: duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: duke@435: duke@435: // Interface to java.lang.ref.Reference objects duke@435: duke@435: class java_lang_ref_Reference: AllStatic { duke@435: public: duke@435: enum { duke@435: hc_referent_offset = 0, duke@435: hc_queue_offset = 1, duke@435: hc_next_offset = 2, duke@435: hc_discovered_offset = 3 // Is not last, see SoftRefs. duke@435: }; duke@435: enum { duke@435: hc_static_lock_offset = 0, duke@435: hc_static_pending_offset = 1 duke@435: }; duke@435: duke@435: static int referent_offset; duke@435: static int queue_offset; duke@435: static int next_offset; duke@435: static int discovered_offset; duke@435: static int static_lock_offset; duke@435: static int static_pending_offset; duke@435: static int number_of_fake_oop_fields; duke@435: duke@435: // Accessors coleenp@548: static oop referent(oop ref) { coleenp@548: return ref->obj_field(referent_offset); coleenp@548: } coleenp@548: static void set_referent(oop ref, oop value) { coleenp@548: ref->obj_field_put(referent_offset, value); coleenp@548: } coleenp@548: static void set_referent_raw(oop ref, oop value) { coleenp@548: ref->obj_field_raw_put(referent_offset, value); coleenp@548: } coleenp@548: static HeapWord* referent_addr(oop ref) { coleenp@548: return ref->obj_field_addr(referent_offset); coleenp@548: } coleenp@548: static oop next(oop ref) { coleenp@548: return ref->obj_field(next_offset); coleenp@548: } coleenp@548: static void set_next(oop ref, oop value) { coleenp@548: ref->obj_field_put(next_offset, value); coleenp@548: } coleenp@548: static void set_next_raw(oop ref, oop value) { coleenp@548: ref->obj_field_raw_put(next_offset, value); coleenp@548: } coleenp@548: static HeapWord* next_addr(oop ref) { coleenp@548: return ref->obj_field_addr(next_offset); coleenp@548: } coleenp@548: static oop discovered(oop ref) { coleenp@548: return ref->obj_field(discovered_offset); coleenp@548: } coleenp@548: static void set_discovered(oop ref, oop value) { coleenp@548: ref->obj_field_put(discovered_offset, value); coleenp@548: } coleenp@548: static void set_discovered_raw(oop ref, oop value) { coleenp@548: ref->obj_field_raw_put(discovered_offset, value); coleenp@548: } coleenp@548: static HeapWord* discovered_addr(oop ref) { coleenp@548: return ref->obj_field_addr(discovered_offset); coleenp@548: } coleenp@548: // Accessors for statics coleenp@548: static oop pending_list_lock(); coleenp@548: static oop pending_list(); duke@435: coleenp@548: static HeapWord* pending_list_addr(); duke@435: }; duke@435: duke@435: duke@435: // Interface to java.lang.ref.SoftReference objects duke@435: duke@435: class java_lang_ref_SoftReference: public java_lang_ref_Reference { duke@435: public: duke@435: enum { duke@435: // The timestamp is a long field and may need to be adjusted for alignment. kvn@600: hc_timestamp_offset = hc_discovered_offset + 1 duke@435: }; duke@435: enum { duke@435: hc_static_clock_offset = 0 duke@435: }; duke@435: duke@435: static int timestamp_offset; duke@435: static int static_clock_offset; duke@435: duke@435: // Accessors duke@435: static jlong timestamp(oop ref); duke@435: duke@435: // Accessors for statics duke@435: static jlong clock(); duke@435: static void set_clock(jlong value); duke@435: }; duke@435: duke@435: jrose@2639: // Interface to java.lang.invoke.MethodHandle objects jrose@1145: jrose@1145: class MethodHandleEntry; jrose@1145: jrose@2639: class java_lang_invoke_MethodHandle: AllStatic { jrose@1145: friend class JavaClasses; jrose@1145: jrose@1145: private: jrose@1145: static int _vmentry_offset; // assembly code trampoline for MH jrose@1145: static int _vmtarget_offset; // class-specific target reference jrose@1145: static int _type_offset; // the MethodType of this MH jrose@1145: static int _vmslots_offset; // OPTIONAL hoisted type.form.vmslots jrose@1145: jrose@1145: static void compute_offsets(); jrose@1145: jrose@1145: public: jrose@1145: // Accessors jrose@1145: static oop type(oop mh); jrose@1145: static void set_type(oop mh, oop mtype); jrose@1145: jrose@1145: static oop vmtarget(oop mh); jrose@1145: static void set_vmtarget(oop mh, oop target); jrose@1145: jrose@1145: static MethodHandleEntry* vmentry(oop mh); jrose@1145: static void set_vmentry(oop mh, MethodHandleEntry* data); jrose@1145: jrose@1145: static int vmslots(oop mh); jrose@1145: static void init_vmslots(oop mh); jrose@1145: static int compute_vmslots(oop mh); jrose@1145: jrose@1145: // Testers jrose@1145: static bool is_subclass(klassOop klass) { jrose@1145: return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass()); jrose@1145: } jrose@1145: static bool is_instance(oop obj) { jrose@1145: return obj != NULL && is_subclass(obj->klass()); jrose@1145: } jrose@1145: jrose@1145: // Accessors for code generation: jrose@1145: static int type_offset_in_bytes() { return _type_offset; } jrose@1145: static int vmtarget_offset_in_bytes() { return _vmtarget_offset; } jrose@1145: static int vmentry_offset_in_bytes() { return _vmentry_offset; } jrose@1145: static int vmslots_offset_in_bytes() { return _vmslots_offset; } jrose@1145: }; jrose@1145: jrose@2639: class java_lang_invoke_DirectMethodHandle: public java_lang_invoke_MethodHandle { jrose@1145: friend class JavaClasses; jrose@1145: jrose@1145: private: jrose@1145: // _vmtarget_offset; // method or class or interface jrose@1145: static int _vmindex_offset; // negative or vtable idx or itable idx jrose@1145: static void compute_offsets(); jrose@1145: jrose@1145: public: jrose@1145: // Accessors jrose@1145: static int vmindex(oop mh); jrose@1145: static void set_vmindex(oop mh, int index); jrose@1145: jrose@1145: // Testers jrose@1145: static bool is_subclass(klassOop klass) { jrose@1145: return Klass::cast(klass)->is_subclass_of(SystemDictionary::DirectMethodHandle_klass()); jrose@1145: } jrose@1145: static bool is_instance(oop obj) { jrose@1145: return obj != NULL && is_subclass(obj->klass()); jrose@1145: } jrose@1145: jrose@1145: // Accessors for code generation: jrose@1145: static int vmindex_offset_in_bytes() { return _vmindex_offset; } jrose@1145: }; jrose@1145: jrose@2639: class java_lang_invoke_BoundMethodHandle: public java_lang_invoke_MethodHandle { jrose@1145: friend class JavaClasses; jrose@1145: jrose@1145: private: jrose@1145: static int _argument_offset; // argument value bound into this MH jrose@1145: static int _vmargslot_offset; // relevant argument slot (<= vmslots) jrose@1145: static void compute_offsets(); jrose@1145: jrose@1145: public: jrose@1145: static oop argument(oop mh); jrose@1145: static void set_argument(oop mh, oop ref); jrose@1145: jrose@1145: static jint vmargslot(oop mh); jrose@1145: static void set_vmargslot(oop mh, jint slot); jrose@1145: jrose@1145: // Testers jrose@1145: static bool is_subclass(klassOop klass) { jrose@1145: return Klass::cast(klass)->is_subclass_of(SystemDictionary::BoundMethodHandle_klass()); jrose@1145: } jrose@1145: static bool is_instance(oop obj) { jrose@1145: return obj != NULL && is_subclass(obj->klass()); jrose@1145: } jrose@1145: jrose@1145: static int argument_offset_in_bytes() { return _argument_offset; } jrose@1145: static int vmargslot_offset_in_bytes() { return _vmargslot_offset; } jrose@1145: }; jrose@1145: jrose@2639: class java_lang_invoke_AdapterMethodHandle: public java_lang_invoke_BoundMethodHandle { jrose@1145: friend class JavaClasses; jrose@1145: jrose@1145: private: jrose@1145: static int _conversion_offset; // type of conversion to apply jrose@1145: static void compute_offsets(); jrose@1145: jrose@1145: public: jrose@1145: static int conversion(oop mh); jrose@1145: static void set_conversion(oop mh, int conv); jrose@1145: jrose@1145: // Testers jrose@1145: static bool is_subclass(klassOop klass) { jrose@1145: return Klass::cast(klass)->is_subclass_of(SystemDictionary::AdapterMethodHandle_klass()); jrose@1145: } jrose@1145: static bool is_instance(oop obj) { jrose@1145: return obj != NULL && is_subclass(obj->klass()); jrose@1145: } jrose@1145: jrose@1145: // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants): jrose@1145: enum { jrose@1145: OP_RETYPE_ONLY = 0x0, // no argument changes; straight retype jrose@1474: OP_RETYPE_RAW = 0x1, // straight retype, trusted (void->int, Object->T) jrose@1474: OP_CHECK_CAST = 0x2, // ref-to-ref conversion; requires a Class argument jrose@1474: OP_PRIM_TO_PRIM = 0x3, // converts from one primitive to another jrose@1474: OP_REF_TO_PRIM = 0x4, // unboxes a wrapper to produce a primitive never@2895: OP_PRIM_TO_REF = 0x5, // boxes a primitive into a wrapper jrose@1474: OP_SWAP_ARGS = 0x6, // swap arguments (vminfo is 2nd arg) jrose@1474: OP_ROT_ARGS = 0x7, // rotate arguments (vminfo is displaced arg) jrose@1474: OP_DUP_ARGS = 0x8, // duplicates one or more arguments (at TOS) jrose@1474: OP_DROP_ARGS = 0x9, // remove one or more argument slots never@2895: OP_COLLECT_ARGS = 0xA, // combine arguments using an auxiliary function jrose@1474: OP_SPREAD_ARGS = 0xB, // expand in place a varargs array (of known size) never@2895: OP_FOLD_ARGS = 0xC, // combine but do not remove arguments; prepend result never@2895: //OP_UNUSED_13 = 0xD, // unused code, perhaps for reified argument lists jrose@1474: CONV_OP_LIMIT = 0xE, // limit of CONV_OP enumeration jrose@1145: jrose@1145: CONV_OP_MASK = 0xF00, // this nybble contains the conversion op field never@2895: CONV_TYPE_MASK = 0x0F, // fits T_ADDRESS and below jrose@1145: CONV_VMINFO_MASK = 0x0FF, // LSB is reserved for JVM use jrose@1145: CONV_VMINFO_SHIFT = 0, // position of bits in CONV_VMINFO_MASK jrose@1145: CONV_OP_SHIFT = 8, // position of bits in CONV_OP_MASK jrose@1145: CONV_DEST_TYPE_SHIFT = 12, // byte 2 has the adapter BasicType (if needed) jrose@1145: CONV_SRC_TYPE_SHIFT = 16, // byte 2 has the source BasicType (if needed) jrose@1145: CONV_STACK_MOVE_SHIFT = 20, // high 12 bits give signed SP change jrose@1145: CONV_STACK_MOVE_MASK = (1 << (32 - CONV_STACK_MOVE_SHIFT)) - 1 jrose@1145: }; jrose@1145: jrose@1145: static int conversion_offset_in_bytes() { return _conversion_offset; } jrose@1145: }; jrose@1145: jrose@1145: jrose@2639: // Interface to java.lang.invoke.MemberName objects jrose@1145: // (These are a private interface for Java code to query the class hierarchy.) jrose@1145: jrose@2639: class java_lang_invoke_MemberName: AllStatic { jrose@1145: friend class JavaClasses; jrose@1145: jrose@1145: private: jrose@2639: // From java.lang.invoke.MemberName: jrose@1145: // private Class clazz; // class in which the method is defined jrose@1145: // private String name; // may be null if not yet materialized jrose@1145: // private Object type; // may be null if not yet materialized jrose@1145: // private int flags; // modifier bits; see reflect.Modifier jrose@1145: // private Object vmtarget; // VM-specific target value jrose@1145: // private int vmindex; // method index within class or interface jrose@1145: static int _clazz_offset; jrose@1145: static int _name_offset; jrose@1145: static int _type_offset; jrose@1145: static int _flags_offset; jrose@1145: static int _vmtarget_offset; jrose@1145: static int _vmindex_offset; jrose@1145: jrose@1145: static void compute_offsets(); jrose@1145: jrose@1145: public: jrose@1145: // Accessors jrose@1145: static oop clazz(oop mname); jrose@1145: static void set_clazz(oop mname, oop clazz); jrose@1145: jrose@1145: static oop type(oop mname); jrose@1145: static void set_type(oop mname, oop type); jrose@1145: jrose@1145: static oop name(oop mname); jrose@1145: static void set_name(oop mname, oop name); jrose@1145: jrose@1145: static int flags(oop mname); jrose@1145: static void set_flags(oop mname, int flags); jrose@1145: jrose@1145: static int modifiers(oop mname) { return (u2) flags(mname); } jrose@1145: static void set_modifiers(oop mname, int mods) jrose@1145: { set_flags(mname, (flags(mname) &~ (u2)-1) | (u2)mods); } jrose@1145: jrose@1145: static oop vmtarget(oop mname); jrose@1145: static void set_vmtarget(oop mname, oop target); jrose@1145: jrose@1145: static int vmindex(oop mname); jrose@1145: static void set_vmindex(oop mname, int index); jrose@1145: jrose@1145: // Testers jrose@1145: static bool is_subclass(klassOop klass) { jrose@1145: return Klass::cast(klass)->is_subclass_of(SystemDictionary::MemberName_klass()); jrose@1145: } jrose@1145: static bool is_instance(oop obj) { jrose@1145: return obj != NULL && is_subclass(obj->klass()); jrose@1145: } jrose@1145: jrose@1145: // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants): jrose@1145: enum { jrose@1145: MN_IS_METHOD = 0x00010000, // method (not constructor) jrose@1145: MN_IS_CONSTRUCTOR = 0x00020000, // constructor jrose@1145: MN_IS_FIELD = 0x00040000, // field jrose@1145: MN_IS_TYPE = 0x00080000, // nested type jrose@1145: MN_SEARCH_SUPERCLASSES = 0x00100000, // for MHN.getMembers jrose@1145: MN_SEARCH_INTERFACES = 0x00200000, // for MHN.getMembers jrose@1145: VM_INDEX_UNINITIALIZED = -99 jrose@1145: }; jrose@1145: jrose@1145: // Accessors for code generation: jrose@1145: static int clazz_offset_in_bytes() { return _clazz_offset; } jrose@1145: static int type_offset_in_bytes() { return _type_offset; } jrose@1145: static int name_offset_in_bytes() { return _name_offset; } jrose@1145: static int flags_offset_in_bytes() { return _flags_offset; } jrose@1145: static int vmtarget_offset_in_bytes() { return _vmtarget_offset; } jrose@1145: static int vmindex_offset_in_bytes() { return _vmindex_offset; } jrose@1145: }; jrose@1145: jrose@1145: jrose@2639: // Interface to java.lang.invoke.MethodType objects jrose@1145: jrose@2639: class java_lang_invoke_MethodType: AllStatic { jrose@1145: friend class JavaClasses; jrose@1145: jrose@1145: private: jrose@1145: static int _rtype_offset; jrose@1145: static int _ptypes_offset; jrose@1145: static int _form_offset; jrose@1145: jrose@1145: static void compute_offsets(); jrose@1145: jrose@1145: public: jrose@1145: // Accessors jrose@1145: static oop rtype(oop mt); jrose@1145: static objArrayOop ptypes(oop mt); jrose@1145: static oop form(oop mt); jrose@1145: jrose@1145: static oop ptype(oop mt, int index); twisti@1568: static int ptype_count(oop mt); jrose@1145: coleenp@2497: static Symbol* as_signature(oop mt, bool intern_if_not_found, TRAPS); jrose@1145: static void print_signature(oop mt, outputStream* st); jrose@1145: jrose@1145: static bool is_instance(oop obj) { jrose@1145: return obj != NULL && obj->klass() == SystemDictionary::MethodType_klass(); jrose@1145: } jrose@1145: jrose@1145: // Accessors for code generation: jrose@1145: static int rtype_offset_in_bytes() { return _rtype_offset; } jrose@1145: static int ptypes_offset_in_bytes() { return _ptypes_offset; } jrose@1145: static int form_offset_in_bytes() { return _form_offset; } jrose@1145: }; jrose@1145: jrose@2639: class java_lang_invoke_MethodTypeForm: AllStatic { jrose@1145: friend class JavaClasses; jrose@1145: jrose@1145: private: jrose@1145: static int _vmslots_offset; // number of argument slots needed never@2895: static int _vmlayout_offset; // object describing internal calling sequence jrose@1145: static int _erasedType_offset; // erasedType = canonical MethodType jrose@2148: static int _genericInvoker_offset; // genericInvoker = adapter for invokeGeneric jrose@1145: jrose@1145: static void compute_offsets(); jrose@1145: jrose@1145: public: jrose@1145: // Accessors jrose@1145: static int vmslots(oop mtform); jrose@1145: static oop erasedType(oop mtform); jrose@2148: static oop genericInvoker(oop mtform); jrose@1145: never@2895: static oop vmlayout(oop mtform); never@2895: static oop init_vmlayout(oop mtform, oop cookie); never@2895: jrose@1145: // Accessors for code generation: jrose@1145: static int vmslots_offset_in_bytes() { return _vmslots_offset; } never@2895: static int vmlayout_offset_in_bytes() { return _vmlayout_offset; } jrose@1145: static int erasedType_offset_in_bytes() { return _erasedType_offset; } jrose@2148: static int genericInvoker_offset_in_bytes() { return _genericInvoker_offset; } jrose@1145: }; jrose@1145: jrose@1145: jrose@2639: // Interface to java.lang.invoke.CallSite objects jrose@1161: jrose@2639: class java_lang_invoke_CallSite: AllStatic { jrose@1161: friend class JavaClasses; jrose@1161: jrose@1161: private: jrose@1161: static int _target_offset; jrose@1862: static int _caller_method_offset; jrose@1862: static int _caller_bci_offset; jrose@1161: jrose@1161: static void compute_offsets(); jrose@1161: jrose@1161: public: jrose@1161: // Accessors jrose@1161: static oop target(oop site); jrose@1161: static void set_target(oop site, oop target); jrose@1161: jrose@1862: static oop caller_method(oop site); jrose@1862: static void set_caller_method(oop site, oop ref); jrose@1862: jrose@1862: static jint caller_bci(oop site); jrose@1862: static void set_caller_bci(oop site, jint bci); jrose@1161: twisti@1570: // Testers twisti@1570: static bool is_subclass(klassOop klass) { twisti@1570: return Klass::cast(klass)->is_subclass_of(SystemDictionary::CallSite_klass()); twisti@1570: } twisti@1570: static bool is_instance(oop obj) { twisti@1570: return obj != NULL && is_subclass(obj->klass()); twisti@1570: } twisti@1570: jrose@1161: // Accessors for code generation: jrose@1161: static int target_offset_in_bytes() { return _target_offset; } jrose@1862: static int caller_method_offset_in_bytes() { return _caller_method_offset; } jrose@1862: static int caller_bci_offset_in_bytes() { return _caller_bci_offset; } jrose@1161: }; jrose@1145: jrose@1145: duke@435: // Interface to java.security.AccessControlContext objects duke@435: duke@435: class java_security_AccessControlContext: AllStatic { duke@435: private: duke@435: // Note that for this class the layout changed between JDK1.2 and JDK1.3, duke@435: // so we compute the offsets at startup rather than hard-wiring them. duke@435: static int _context_offset; duke@435: static int _privilegedContext_offset; duke@435: static int _isPrivileged_offset; duke@435: duke@435: static void compute_offsets(); duke@435: public: duke@435: static oop create(objArrayHandle context, bool isPrivileged, Handle privileged_context, TRAPS); duke@435: duke@435: // Debugging/initialization duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: duke@435: // Interface to java.lang.ClassLoader objects duke@435: duke@435: class java_lang_ClassLoader : AllStatic { duke@435: private: duke@435: enum { duke@435: hc_parent_offset = 0 duke@435: }; duke@435: duke@435: static int parent_offset; duke@435: duke@435: public: duke@435: static oop parent(oop loader); duke@435: duke@435: static bool is_trusted_loader(oop loader); duke@435: duke@435: // Fix for 4474172 duke@435: static oop non_reflection_class_loader(oop loader); duke@435: duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: duke@435: // Interface to java.lang.System objects duke@435: duke@435: class java_lang_System : AllStatic { duke@435: private: duke@435: enum { duke@435: hc_static_in_offset = 0, duke@435: hc_static_out_offset = 1, duke@435: hc_static_err_offset = 2 duke@435: }; duke@435: duke@435: static int static_in_offset; duke@435: static int static_out_offset; duke@435: static int static_err_offset; duke@435: duke@435: public: duke@435: static int in_offset_in_bytes(); duke@435: static int out_offset_in_bytes(); duke@435: static int err_offset_in_bytes(); duke@435: duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: duke@435: // Interface to java.lang.StackTraceElement objects duke@435: duke@435: class java_lang_StackTraceElement: AllStatic { duke@435: private: duke@435: enum { duke@435: hc_declaringClass_offset = 0, duke@435: hc_methodName_offset = 1, duke@435: hc_fileName_offset = 2, duke@435: hc_lineNumber_offset = 3 duke@435: }; duke@435: duke@435: static int declaringClass_offset; duke@435: static int methodName_offset; duke@435: static int fileName_offset; duke@435: static int lineNumber_offset; duke@435: duke@435: public: duke@435: // Setters duke@435: static void set_declaringClass(oop element, oop value); duke@435: static void set_methodName(oop element, oop value); duke@435: static void set_fileName(oop element, oop value); duke@435: static void set_lineNumber(oop element, int value); duke@435: duke@435: // Create an instance of StackTraceElement duke@435: static oop create(methodHandle m, int bci, TRAPS); duke@435: duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: duke@435: // Interface to java.lang.AssertionStatusDirectives objects duke@435: duke@435: class java_lang_AssertionStatusDirectives: AllStatic { duke@435: private: duke@435: enum { duke@435: hc_classes_offset, duke@435: hc_classEnabled_offset, duke@435: hc_packages_offset, duke@435: hc_packageEnabled_offset, duke@435: hc_deflt_offset duke@435: }; duke@435: duke@435: static int classes_offset; duke@435: static int classEnabled_offset; duke@435: static int packages_offset; duke@435: static int packageEnabled_offset; duke@435: static int deflt_offset; duke@435: duke@435: public: duke@435: // Setters duke@435: static void set_classes(oop obj, oop val); duke@435: static void set_classEnabled(oop obj, oop val); duke@435: static void set_packages(oop obj, oop val); duke@435: static void set_packageEnabled(oop obj, oop val); duke@435: static void set_deflt(oop obj, bool val); duke@435: // Debugging duke@435: friend class JavaClasses; duke@435: }; duke@435: duke@435: duke@435: class java_nio_Buffer: AllStatic { duke@435: private: duke@435: static int _limit_offset; duke@435: duke@435: public: duke@435: static int limit_offset(); duke@435: static void compute_offsets(); duke@435: }; duke@435: duke@435: class sun_misc_AtomicLongCSImpl: AllStatic { duke@435: private: duke@435: static int _value_offset; duke@435: duke@435: public: duke@435: static int value_offset(); duke@435: static void compute_offsets(); duke@435: }; duke@435: duke@435: class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic { duke@435: private: duke@435: static int _owner_offset; duke@435: public: duke@435: static void initialize(TRAPS); duke@435: static oop get_owner_threadObj(oop obj); duke@435: }; duke@435: duke@435: // Interface to hard-coded offset checking duke@435: duke@435: class JavaClasses : AllStatic { duke@435: private: duke@435: static bool check_offset(const char *klass_name, int offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; duke@435: static bool check_static_offset(const char *klass_name, int hardcoded_offset, const char *field_name, const char* field_sig) PRODUCT_RETURN0; jrose@567: static bool check_constant(const char *klass_name, int constant, const char *field_name, const char* field_sig) PRODUCT_RETURN0; duke@435: public: duke@435: static void compute_hard_coded_offsets(); duke@435: static void compute_offsets(); duke@435: static void check_offsets() PRODUCT_RETURN; duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_CLASSFILE_JAVACLASSES_HPP