Mercurial > hg > truffle
comparison src/share/vm/classfile/javaClasses.hpp @ 6275:957c266d8bc5
Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 21 Aug 2012 10:39:19 +0200 |
parents | 120820e30baa 1d7922586cf6 |
children | e522a00b91aa |
comparison
equal
deleted
inserted
replaced
5891:fd8832ae511d | 6275:957c266d8bc5 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
50 | 50 |
51 // Interface to java.lang.String objects | 51 // Interface to java.lang.String objects |
52 | 52 |
53 class java_lang_String : AllStatic { | 53 class java_lang_String : AllStatic { |
54 private: | 54 private: |
55 enum { | |
56 hc_value_offset = 0, | |
57 hc_offset_offset = 1 | |
58 //hc_count_offset = 2 -- not a word-scaled offset | |
59 //hc_hash_offset = 3 -- not a word-scaled offset | |
60 }; | |
61 | |
62 static int value_offset; | 55 static int value_offset; |
63 static int offset_offset; | 56 static int offset_offset; |
64 static int count_offset; | 57 static int count_offset; |
65 static int hash_offset; | 58 static int hash_offset; |
66 | 59 |
60 static bool initialized; | |
61 | |
67 static Handle basic_create(int length, bool tenured, TRAPS); | 62 static Handle basic_create(int length, bool tenured, TRAPS); |
68 static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS); | 63 static Handle basic_create_from_unicode(jchar* unicode, int length, bool tenured, TRAPS); |
69 | 64 |
70 static void set_value( oop string, typeArrayOop buffer) { string->obj_field_put(value_offset, (oop)buffer); } | 65 static void set_value( oop string, typeArrayOop buffer) { |
71 static void set_offset(oop string, int offset) { string->int_field_put(offset_offset, offset); } | 66 assert(initialized, "Must be initialized"); |
72 static void set_count( oop string, int count) { string->int_field_put(count_offset, count); } | 67 string->obj_field_put(value_offset, (oop)buffer); |
73 | 68 } |
74 public: | 69 static void set_offset(oop string, int offset) { |
70 assert(initialized, "Must be initialized"); | |
71 if (offset_offset > 0) { | |
72 string->int_field_put(offset_offset, offset); | |
73 } | |
74 } | |
75 static void set_count( oop string, int count) { | |
76 assert(initialized, "Must be initialized"); | |
77 if (count_offset > 0) { | |
78 string->int_field_put(count_offset, count); | |
79 } | |
80 } | |
81 | |
82 public: | |
83 static void compute_offsets(); | |
84 | |
75 // Instance creation | 85 // Instance creation |
76 static Handle create_from_unicode(jchar* unicode, int len, TRAPS); | 86 static Handle create_from_unicode(jchar* unicode, int len, TRAPS); |
77 static Handle create_tenured_from_unicode(jchar* unicode, int len, TRAPS); | 87 static Handle create_tenured_from_unicode(jchar* unicode, int len, TRAPS); |
78 static oop create_oop_from_unicode(jchar* unicode, int len, TRAPS); | 88 static oop create_oop_from_unicode(jchar* unicode, int len, TRAPS); |
79 static Handle create_from_str(const char* utf8_str, TRAPS); | 89 static Handle create_from_str(const char* utf8_str, TRAPS); |
80 static oop create_oop_from_str(const char* utf8_str, TRAPS); | 90 static oop create_oop_from_str(const char* utf8_str, TRAPS); |
81 static Handle create_from_symbol(Symbol* symbol, TRAPS); | 91 static Handle create_from_symbol(Symbol* symbol, TRAPS); |
82 static Handle create_from_platform_dependent_str(const char* str, TRAPS); | 92 static Handle create_from_platform_dependent_str(const char* str, TRAPS); |
83 static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS); | 93 static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS); |
84 | 94 |
85 static int value_offset_in_bytes() { return value_offset; } | 95 static bool has_offset_field() { |
86 static int count_offset_in_bytes() { return count_offset; } | 96 assert(initialized, "Must be initialized"); |
87 static int offset_offset_in_bytes() { return offset_offset; } | 97 return (offset_offset > 0); |
88 static int hash_offset_in_bytes() { return hash_offset; } | 98 } |
99 | |
100 static bool has_count_field() { | |
101 assert(initialized, "Must be initialized"); | |
102 return (count_offset > 0); | |
103 } | |
104 | |
105 static bool has_hash_field() { | |
106 assert(initialized, "Must be initialized"); | |
107 return (hash_offset > 0); | |
108 } | |
109 | |
110 static int value_offset_in_bytes() { | |
111 assert(initialized && (value_offset > 0), "Must be initialized"); | |
112 return value_offset; | |
113 } | |
114 static int count_offset_in_bytes() { | |
115 assert(initialized && (count_offset > 0), "Must be initialized"); | |
116 return count_offset; | |
117 } | |
118 static int offset_offset_in_bytes() { | |
119 assert(initialized && (offset_offset > 0), "Must be initialized"); | |
120 return offset_offset; | |
121 } | |
122 static int hash_offset_in_bytes() { | |
123 assert(initialized && (hash_offset > 0), "Must be initialized"); | |
124 return hash_offset; | |
125 } | |
89 | 126 |
90 // Accessors | 127 // Accessors |
91 static typeArrayOop value(oop java_string) { | 128 static typeArrayOop value(oop java_string) { |
129 assert(initialized && (value_offset > 0), "Must be initialized"); | |
92 assert(is_instance(java_string), "must be java_string"); | 130 assert(is_instance(java_string), "must be java_string"); |
93 return (typeArrayOop) java_string->obj_field(value_offset); | 131 return (typeArrayOop) java_string->obj_field(value_offset); |
94 } | 132 } |
95 static int offset(oop java_string) { | 133 static int offset(oop java_string) { |
134 assert(initialized, "Must be initialized"); | |
96 assert(is_instance(java_string), "must be java_string"); | 135 assert(is_instance(java_string), "must be java_string"); |
97 return java_string->int_field(offset_offset); | 136 if (offset_offset > 0) { |
137 return java_string->int_field(offset_offset); | |
138 } else { | |
139 return 0; | |
140 } | |
98 } | 141 } |
99 static int length(oop java_string) { | 142 static int length(oop java_string) { |
143 assert(initialized, "Must be initialized"); | |
100 assert(is_instance(java_string), "must be java_string"); | 144 assert(is_instance(java_string), "must be java_string"); |
101 return java_string->int_field(count_offset); | 145 if (count_offset > 0) { |
146 return java_string->int_field(count_offset); | |
147 } else { | |
148 return ((typeArrayOop)java_string->obj_field(value_offset))->length(); | |
149 } | |
102 } | 150 } |
103 static int utf8_length(oop java_string); | 151 static int utf8_length(oop java_string); |
104 | 152 |
105 // String converters | 153 // String converters |
106 static char* as_utf8_string(oop java_string); | 154 static char* as_utf8_string(oop java_string); |
108 static char* as_utf8_string(oop java_string, int start, int len); | 156 static char* as_utf8_string(oop java_string, int start, int len); |
109 static char* as_platform_dependent_str(Handle java_string, TRAPS); | 157 static char* as_platform_dependent_str(Handle java_string, TRAPS); |
110 static jchar* as_unicode_string(oop java_string, int& length); | 158 static jchar* as_unicode_string(oop java_string, int& length); |
111 | 159 |
112 // Compute the hash value for a java.lang.String object which would | 160 // Compute the hash value for a java.lang.String object which would |
113 // contain the characters passed in. This hash value is used for at | 161 // contain the characters passed in. |
114 // least two purposes. | |
115 // | 162 // |
116 // (a) As the hash value used by the StringTable for bucket selection | 163 // As the hash value used by the String object itself, in |
117 // and comparison (stored in the HashtableEntry structures). This | 164 // String.hashCode(). This value is normally calculated in Java code |
118 // is used in the String.intern() method. | 165 // in the String.hashCode method(), but is precomputed for String |
166 // objects in the shared archive file. | |
167 // hash P(31) from Kernighan & Ritchie | |
119 // | 168 // |
120 // (b) As the hash value used by the String object itself, in | 169 // For this reason, THIS ALGORITHM MUST MATCH String.toHash(). |
121 // String.hashCode(). This value is normally calculate in Java code | 170 template <typename T> static unsigned int to_hash(T* s, int len) { |
122 // in the String.hashCode method(), but is precomputed for String | |
123 // objects in the shared archive file. | |
124 // | |
125 // For this reason, THIS ALGORITHM MUST MATCH String.hashCode(). | |
126 static unsigned int hash_string(jchar* s, int len) { | |
127 unsigned int h = 0; | 171 unsigned int h = 0; |
128 while (len-- > 0) { | 172 while (len-- > 0) { |
129 h = 31*h + (unsigned int) *s; | 173 h = 31*h + (unsigned int) *s; |
130 s++; | 174 s++; |
131 } | 175 } |
132 return h; | 176 return h; |
133 } | 177 } |
178 static unsigned int to_hash(oop java_string); | |
179 | |
180 // This is the string hash code used by the StringTable, which may be | |
181 // the same as String.toHash or an alternate hash code. | |
134 static unsigned int hash_string(oop java_string); | 182 static unsigned int hash_string(oop java_string); |
135 | 183 |
136 static bool equals(oop java_string, jchar* chars, int len); | 184 static bool equals(oop java_string, jchar* chars, int len); |
137 | 185 |
138 // Conversion between '.' and '/' formats | 186 // Conversion between '.' and '/' formats |
834 }; | 882 }; |
835 | 883 |
836 | 884 |
837 // Interface to java.lang.invoke.MethodHandle objects | 885 // Interface to java.lang.invoke.MethodHandle objects |
838 | 886 |
839 #define METHODHANDLE_INJECTED_FIELDS(macro) \ | |
840 macro(java_lang_invoke_MethodHandle, vmentry, intptr_signature, false) \ | |
841 macro(java_lang_invoke_MethodHandle, vmtarget, object_signature, true) | |
842 | |
843 class MethodHandleEntry; | 887 class MethodHandleEntry; |
844 | 888 |
845 class java_lang_invoke_MethodHandle: AllStatic { | 889 class java_lang_invoke_MethodHandle: AllStatic { |
846 friend class JavaClasses; | 890 friend class JavaClasses; |
847 | 891 |
848 private: | 892 private: |
849 static int _vmentry_offset; // assembly code trampoline for MH | 893 static int _type_offset; // the MethodType of this MH |
850 static int _vmtarget_offset; // class-specific target reference | 894 static int _form_offset; // the LambdaForm of this MH |
851 static int _type_offset; // the MethodType of this MH | |
852 | 895 |
853 static void compute_offsets(); | 896 static void compute_offsets(); |
854 | 897 |
855 public: | 898 public: |
856 // Accessors | 899 // Accessors |
857 static oop type(oop mh); | 900 static oop type(oop mh); |
858 static void set_type(oop mh, oop mtype); | 901 static void set_type(oop mh, oop mtype); |
859 | 902 |
860 static oop vmtarget(oop mh); | 903 static oop form(oop mh); |
861 static void set_vmtarget(oop mh, oop target); | 904 static void set_form(oop mh, oop lform); |
862 | |
863 static MethodHandleEntry* vmentry(oop mh); | |
864 static void set_vmentry(oop mh, MethodHandleEntry* data); | |
865 | |
866 static int vmslots(oop mh); | |
867 | 905 |
868 // Testers | 906 // Testers |
869 static bool is_subclass(klassOop klass) { | 907 static bool is_subclass(klassOop klass) { |
870 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass()); | 908 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MethodHandle_klass()); |
871 } | 909 } |
873 return obj != NULL && is_subclass(obj->klass()); | 911 return obj != NULL && is_subclass(obj->klass()); |
874 } | 912 } |
875 | 913 |
876 // Accessors for code generation: | 914 // Accessors for code generation: |
877 static int type_offset_in_bytes() { return _type_offset; } | 915 static int type_offset_in_bytes() { return _type_offset; } |
878 static int vmtarget_offset_in_bytes() { return _vmtarget_offset; } | 916 static int form_offset_in_bytes() { return _form_offset; } |
879 static int vmentry_offset_in_bytes() { return _vmentry_offset; } | 917 }; |
880 }; | 918 |
881 | 919 // Interface to java.lang.invoke.LambdaForm objects |
882 #define DIRECTMETHODHANDLE_INJECTED_FIELDS(macro) \ | 920 // (These are a private interface for managing adapter code generation.) |
883 macro(java_lang_invoke_DirectMethodHandle, vmindex, int_signature, true) | 921 |
884 | 922 class java_lang_invoke_LambdaForm: AllStatic { |
885 class java_lang_invoke_DirectMethodHandle: public java_lang_invoke_MethodHandle { | 923 friend class JavaClasses; |
886 friend class JavaClasses; | 924 |
887 | 925 private: |
888 private: | 926 static int _vmentry_offset; // type is MemberName |
889 static int _vmindex_offset; // negative or vtable idx or itable idx | 927 |
890 static void compute_offsets(); | 928 static void compute_offsets(); |
891 | 929 |
892 public: | 930 public: |
893 // Accessors | 931 // Accessors |
894 static int vmindex(oop mh); | 932 static oop vmentry(oop lform); |
895 static void set_vmindex(oop mh, int index); | 933 static void set_vmentry(oop lform, oop invoker); |
896 | 934 |
897 // Testers | 935 // Testers |
898 static bool is_subclass(klassOop klass) { | 936 static bool is_subclass(klassOop klass) { |
899 return Klass::cast(klass)->is_subclass_of(SystemDictionary::DirectMethodHandle_klass()); | 937 return SystemDictionary::LambdaForm_klass() != NULL && |
938 Klass::cast(klass)->is_subclass_of(SystemDictionary::LambdaForm_klass()); | |
900 } | 939 } |
901 static bool is_instance(oop obj) { | 940 static bool is_instance(oop obj) { |
902 return obj != NULL && is_subclass(obj->klass()); | 941 return obj != NULL && is_subclass(obj->klass()); |
903 } | 942 } |
904 | 943 |
905 // Accessors for code generation: | 944 // Accessors for code generation: |
906 static int vmindex_offset_in_bytes() { return _vmindex_offset; } | 945 static int vmentry_offset_in_bytes() { return _vmentry_offset; } |
907 }; | 946 }; |
908 | |
909 class java_lang_invoke_BoundMethodHandle: public java_lang_invoke_MethodHandle { | |
910 friend class JavaClasses; | |
911 | |
912 private: | |
913 static int _argument_offset; // argument value bound into this MH | |
914 static int _vmargslot_offset; // relevant argument slot (<= vmslots) | |
915 static void compute_offsets(); | |
916 | |
917 public: | |
918 static oop argument(oop mh); | |
919 static void set_argument(oop mh, oop ref); | |
920 | |
921 static jint vmargslot(oop mh); | |
922 static void set_vmargslot(oop mh, jint slot); | |
923 | |
924 // Testers | |
925 static bool is_subclass(klassOop klass) { | |
926 return Klass::cast(klass)->is_subclass_of(SystemDictionary::BoundMethodHandle_klass()); | |
927 } | |
928 static bool is_instance(oop obj) { | |
929 return obj != NULL && is_subclass(obj->klass()); | |
930 } | |
931 | |
932 static int argument_offset_in_bytes() { return _argument_offset; } | |
933 static int vmargslot_offset_in_bytes() { return _vmargslot_offset; } | |
934 }; | |
935 | |
936 class java_lang_invoke_AdapterMethodHandle: public java_lang_invoke_BoundMethodHandle { | |
937 friend class JavaClasses; | |
938 | |
939 private: | |
940 static int _conversion_offset; // type of conversion to apply | |
941 static void compute_offsets(); | |
942 | |
943 public: | |
944 static int conversion(oop mh); | |
945 static void set_conversion(oop mh, int conv); | |
946 | |
947 // Testers | |
948 static bool is_subclass(klassOop klass) { | |
949 return Klass::cast(klass)->is_subclass_of(SystemDictionary::AdapterMethodHandle_klass()); | |
950 } | |
951 static bool is_instance(oop obj) { | |
952 return obj != NULL && is_subclass(obj->klass()); | |
953 } | |
954 | |
955 // Relevant integer codes (keep these in synch. with MethodHandleNatives.Constants): | |
956 enum { | |
957 OP_RETYPE_ONLY = 0x0, // no argument changes; straight retype | |
958 OP_RETYPE_RAW = 0x1, // straight retype, trusted (void->int, Object->T) | |
959 OP_CHECK_CAST = 0x2, // ref-to-ref conversion; requires a Class argument | |
960 OP_PRIM_TO_PRIM = 0x3, // converts from one primitive to another | |
961 OP_REF_TO_PRIM = 0x4, // unboxes a wrapper to produce a primitive | |
962 OP_PRIM_TO_REF = 0x5, // boxes a primitive into a wrapper | |
963 OP_SWAP_ARGS = 0x6, // swap arguments (vminfo is 2nd arg) | |
964 OP_ROT_ARGS = 0x7, // rotate arguments (vminfo is displaced arg) | |
965 OP_DUP_ARGS = 0x8, // duplicates one or more arguments (at TOS) | |
966 OP_DROP_ARGS = 0x9, // remove one or more argument slots | |
967 OP_COLLECT_ARGS = 0xA, // combine arguments using an auxiliary function | |
968 OP_SPREAD_ARGS = 0xB, // expand in place a varargs array (of known size) | |
969 OP_FOLD_ARGS = 0xC, // combine but do not remove arguments; prepend result | |
970 //OP_UNUSED_13 = 0xD, // unused code, perhaps for reified argument lists | |
971 CONV_OP_LIMIT = 0xE, // limit of CONV_OP enumeration | |
972 | |
973 CONV_OP_MASK = 0xF00, // this nybble contains the conversion op field | |
974 CONV_TYPE_MASK = 0x0F, // fits T_ADDRESS and below | |
975 CONV_VMINFO_MASK = 0x0FF, // LSB is reserved for JVM use | |
976 CONV_VMINFO_SHIFT = 0, // position of bits in CONV_VMINFO_MASK | |
977 CONV_OP_SHIFT = 8, // position of bits in CONV_OP_MASK | |
978 CONV_DEST_TYPE_SHIFT = 12, // byte 2 has the adapter BasicType (if needed) | |
979 CONV_SRC_TYPE_SHIFT = 16, // byte 2 has the source BasicType (if needed) | |
980 CONV_STACK_MOVE_SHIFT = 20, // high 12 bits give signed SP change | |
981 CONV_STACK_MOVE_MASK = (1 << (32 - CONV_STACK_MOVE_SHIFT)) - 1 | |
982 }; | |
983 | |
984 static int conversion_offset_in_bytes() { return _conversion_offset; } | |
985 }; | |
986 | |
987 | |
988 // A simple class that maintains an invocation count | |
989 class java_lang_invoke_CountingMethodHandle: public java_lang_invoke_MethodHandle { | |
990 friend class JavaClasses; | |
991 | |
992 private: | |
993 static int _vmcount_offset; | |
994 static void compute_offsets(); | |
995 | |
996 public: | |
997 // Accessors | |
998 static int vmcount(oop mh); | |
999 static void set_vmcount(oop mh, int count); | |
1000 | |
1001 // Testers | |
1002 static bool is_subclass(klassOop klass) { | |
1003 return SystemDictionary::CountingMethodHandle_klass() != NULL && | |
1004 Klass::cast(klass)->is_subclass_of(SystemDictionary::CountingMethodHandle_klass()); | |
1005 } | |
1006 static bool is_instance(oop obj) { | |
1007 return obj != NULL && is_subclass(obj->klass()); | |
1008 } | |
1009 | |
1010 // Accessors for code generation: | |
1011 static int vmcount_offset_in_bytes() { return _vmcount_offset; } | |
1012 }; | |
1013 | |
1014 | 947 |
1015 | 948 |
1016 // Interface to java.lang.invoke.MemberName objects | 949 // Interface to java.lang.invoke.MemberName objects |
1017 // (These are a private interface for Java code to query the class hierarchy.) | 950 // (These are a private interface for Java code to query the class hierarchy.) |
1018 | 951 |
1019 #define MEMBERNAME_INJECTED_FIELDS(macro) \ | 952 #define MEMBERNAME_INJECTED_FIELDS(macro) \ |
1020 macro(java_lang_invoke_MemberName, vmtarget, object_signature, true) | 953 macro(java_lang_invoke_MemberName, vmindex, intptr_signature, false) \ |
954 macro(java_lang_invoke_MemberName, vmtarget, object_signature, false) | |
1021 | 955 |
1022 class java_lang_invoke_MemberName: AllStatic { | 956 class java_lang_invoke_MemberName: AllStatic { |
1023 friend class JavaClasses; | 957 friend class JavaClasses; |
1024 | 958 |
1025 private: | 959 private: |
1027 // private Class<?> clazz; // class in which the method is defined | 961 // private Class<?> clazz; // class in which the method is defined |
1028 // private String name; // may be null if not yet materialized | 962 // private String name; // may be null if not yet materialized |
1029 // private Object type; // may be null if not yet materialized | 963 // private Object type; // may be null if not yet materialized |
1030 // private int flags; // modifier bits; see reflect.Modifier | 964 // private int flags; // modifier bits; see reflect.Modifier |
1031 // private Object vmtarget; // VM-specific target value | 965 // private Object vmtarget; // VM-specific target value |
1032 // private int vmindex; // method index within class or interface | 966 // private intptr_t vmindex; // member index within class or interface |
1033 static int _clazz_offset; | 967 static int _clazz_offset; |
1034 static int _name_offset; | 968 static int _name_offset; |
1035 static int _type_offset; | 969 static int _type_offset; |
1036 static int _flags_offset; | 970 static int _flags_offset; |
1037 static int _vmtarget_offset; | 971 static int _vmtarget_offset; |
1051 static void set_name(oop mname, oop name); | 985 static void set_name(oop mname, oop name); |
1052 | 986 |
1053 static int flags(oop mname); | 987 static int flags(oop mname); |
1054 static void set_flags(oop mname, int flags); | 988 static void set_flags(oop mname, int flags); |
1055 | 989 |
1056 static int modifiers(oop mname) { return (u2) flags(mname); } | |
1057 static void set_modifiers(oop mname, int mods) | |
1058 { set_flags(mname, (flags(mname) &~ (u2)-1) | (u2)mods); } | |
1059 | |
1060 static oop vmtarget(oop mname); | 990 static oop vmtarget(oop mname); |
1061 static void set_vmtarget(oop mname, oop target); | 991 static void set_vmtarget(oop mname, oop target); |
1062 | 992 |
1063 static int vmindex(oop mname); | 993 static intptr_t vmindex(oop mname); |
1064 static void set_vmindex(oop mname, int index); | 994 static void set_vmindex(oop mname, intptr_t index); |
1065 | 995 |
1066 // Testers | 996 // Testers |
1067 static bool is_subclass(klassOop klass) { | 997 static bool is_subclass(klassOop klass) { |
1068 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MemberName_klass()); | 998 return Klass::cast(klass)->is_subclass_of(SystemDictionary::MemberName_klass()); |
1069 } | 999 } |
1075 enum { | 1005 enum { |
1076 MN_IS_METHOD = 0x00010000, // method (not constructor) | 1006 MN_IS_METHOD = 0x00010000, // method (not constructor) |
1077 MN_IS_CONSTRUCTOR = 0x00020000, // constructor | 1007 MN_IS_CONSTRUCTOR = 0x00020000, // constructor |
1078 MN_IS_FIELD = 0x00040000, // field | 1008 MN_IS_FIELD = 0x00040000, // field |
1079 MN_IS_TYPE = 0x00080000, // nested type | 1009 MN_IS_TYPE = 0x00080000, // nested type |
1080 MN_SEARCH_SUPERCLASSES = 0x00100000, // for MHN.getMembers | 1010 MN_REFERENCE_KIND_SHIFT = 24, // refKind |
1081 MN_SEARCH_INTERFACES = 0x00200000, // for MHN.getMembers | 1011 MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT, |
1082 VM_INDEX_UNINITIALIZED = -99 | 1012 // The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers: |
1013 MN_SEARCH_SUPERCLASSES = 0x00100000, // walk super classes | |
1014 MN_SEARCH_INTERFACES = 0x00200000 // walk implemented interfaces | |
1083 }; | 1015 }; |
1084 | 1016 |
1085 // Accessors for code generation: | 1017 // Accessors for code generation: |
1086 static int clazz_offset_in_bytes() { return _clazz_offset; } | 1018 static int clazz_offset_in_bytes() { return _clazz_offset; } |
1087 static int type_offset_in_bytes() { return _type_offset; } | 1019 static int type_offset_in_bytes() { return _type_offset; } |
1098 friend class JavaClasses; | 1030 friend class JavaClasses; |
1099 | 1031 |
1100 private: | 1032 private: |
1101 static int _rtype_offset; | 1033 static int _rtype_offset; |
1102 static int _ptypes_offset; | 1034 static int _ptypes_offset; |
1103 static int _form_offset; | |
1104 | 1035 |
1105 static void compute_offsets(); | 1036 static void compute_offsets(); |
1106 | 1037 |
1107 public: | 1038 public: |
1108 // Accessors | 1039 // Accessors |
1109 static oop rtype(oop mt); | 1040 static oop rtype(oop mt); |
1110 static objArrayOop ptypes(oop mt); | 1041 static objArrayOop ptypes(oop mt); |
1111 static oop form(oop mt); | |
1112 | 1042 |
1113 static oop ptype(oop mt, int index); | 1043 static oop ptype(oop mt, int index); |
1114 static int ptype_count(oop mt); | 1044 static int ptype_count(oop mt); |
1045 | |
1046 static int ptype_slot_count(oop mt); // extra counts for long/double | |
1047 static int rtype_slot_count(oop mt); // extra counts for long/double | |
1115 | 1048 |
1116 static Symbol* as_signature(oop mt, bool intern_if_not_found, TRAPS); | 1049 static Symbol* as_signature(oop mt, bool intern_if_not_found, TRAPS); |
1117 static void print_signature(oop mt, outputStream* st); | 1050 static void print_signature(oop mt, outputStream* st); |
1118 | 1051 |
1119 static bool is_instance(oop obj) { | 1052 static bool is_instance(oop obj) { |
1123 static bool equals(oop mt1, oop mt2); | 1056 static bool equals(oop mt1, oop mt2); |
1124 | 1057 |
1125 // Accessors for code generation: | 1058 // Accessors for code generation: |
1126 static int rtype_offset_in_bytes() { return _rtype_offset; } | 1059 static int rtype_offset_in_bytes() { return _rtype_offset; } |
1127 static int ptypes_offset_in_bytes() { return _ptypes_offset; } | 1060 static int ptypes_offset_in_bytes() { return _ptypes_offset; } |
1128 static int form_offset_in_bytes() { return _form_offset; } | |
1129 }; | |
1130 | |
1131 #define METHODTYPEFORM_INJECTED_FIELDS(macro) \ | |
1132 macro(java_lang_invoke_MethodTypeForm, vmslots, int_signature, true) \ | |
1133 macro(java_lang_invoke_MethodTypeForm, vmlayout, object_signature, true) | |
1134 | |
1135 class java_lang_invoke_MethodTypeForm: AllStatic { | |
1136 friend class JavaClasses; | |
1137 | |
1138 private: | |
1139 static int _vmslots_offset; // number of argument slots needed | |
1140 static int _vmlayout_offset; // object describing internal calling sequence | |
1141 static int _erasedType_offset; // erasedType = canonical MethodType | |
1142 static int _genericInvoker_offset; // genericInvoker = adapter for invokeGeneric | |
1143 | |
1144 static void compute_offsets(); | |
1145 | |
1146 public: | |
1147 // Accessors | |
1148 static int vmslots(oop mtform); | |
1149 static void set_vmslots(oop mtform, int vmslots); | |
1150 | |
1151 static oop erasedType(oop mtform); | |
1152 static oop genericInvoker(oop mtform); | |
1153 | |
1154 static oop vmlayout(oop mtform); | |
1155 static oop init_vmlayout(oop mtform, oop cookie); | |
1156 | |
1157 // Accessors for code generation: | |
1158 static int vmslots_offset_in_bytes() { return _vmslots_offset; } | |
1159 static int vmlayout_offset_in_bytes() { return _vmlayout_offset; } | |
1160 static int erasedType_offset_in_bytes() { return _erasedType_offset; } | |
1161 static int genericInvoker_offset_in_bytes() { return _genericInvoker_offset; } | |
1162 }; | 1061 }; |
1163 | 1062 |
1164 | 1063 |
1165 // Interface to java.lang.invoke.CallSite objects | 1064 // Interface to java.lang.invoke.CallSite objects |
1166 | 1065 |
1226 | 1125 |
1227 static void compute_offsets(); | 1126 static void compute_offsets(); |
1228 | 1127 |
1229 public: | 1128 public: |
1230 static oop parent(oop loader); | 1129 static oop parent(oop loader); |
1130 static bool isAncestor(oop loader, oop cl); | |
1231 | 1131 |
1232 // Support for parallelCapable field | 1132 // Support for parallelCapable field |
1233 static bool parallelCapable(oop the_class_mirror); | 1133 static bool parallelCapable(oop the_class_mirror); |
1234 | 1134 |
1235 static bool is_trusted_loader(oop loader); | 1135 static bool is_trusted_loader(oop loader); |
1236 | 1136 |
1237 // Fix for 4474172 | 1137 // Fix for 4474172 |
1238 static oop non_reflection_class_loader(oop loader); | 1138 static oop non_reflection_class_loader(oop loader); |
1139 | |
1140 // Testers | |
1141 static bool is_subclass(klassOop klass) { | |
1142 return Klass::cast(klass)->is_subclass_of(SystemDictionary::ClassLoader_klass()); | |
1143 } | |
1144 static bool is_instance(oop obj) { | |
1145 return obj != NULL && is_subclass(obj->klass()); | |
1146 } | |
1239 | 1147 |
1240 // Debugging | 1148 // Debugging |
1241 friend class JavaClasses; | 1149 friend class JavaClasses; |
1242 }; | 1150 }; |
1243 | 1151 |
1331 private: | 1239 private: |
1332 static int _limit_offset; | 1240 static int _limit_offset; |
1333 | 1241 |
1334 public: | 1242 public: |
1335 static int limit_offset(); | 1243 static int limit_offset(); |
1336 static void compute_offsets(); | |
1337 }; | |
1338 | |
1339 class sun_misc_AtomicLongCSImpl: AllStatic { | |
1340 private: | |
1341 static int _value_offset; | |
1342 | |
1343 public: | |
1344 static int value_offset(); | |
1345 static void compute_offsets(); | 1244 static void compute_offsets(); |
1346 }; | 1245 }; |
1347 | 1246 |
1348 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic { | 1247 class java_util_concurrent_locks_AbstractOwnableSynchronizer : AllStatic { |
1349 private: | 1248 private: |
1385 #define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \ | 1284 #define DECLARE_INJECTED_FIELD_ENUM(klass, name, signature, may_be_java) \ |
1386 klass##_##name##_enum, | 1285 klass##_##name##_enum, |
1387 | 1286 |
1388 #define ALL_INJECTED_FIELDS(macro) \ | 1287 #define ALL_INJECTED_FIELDS(macro) \ |
1389 CLASS_INJECTED_FIELDS(macro) \ | 1288 CLASS_INJECTED_FIELDS(macro) \ |
1390 METHODHANDLE_INJECTED_FIELDS(macro) \ | 1289 MEMBERNAME_INJECTED_FIELDS(macro) |
1391 DIRECTMETHODHANDLE_INJECTED_FIELDS(macro) \ | |
1392 MEMBERNAME_INJECTED_FIELDS(macro) \ | |
1393 METHODTYPEFORM_INJECTED_FIELDS(macro) | |
1394 | 1290 |
1395 // Interface to hard-coded offset checking | 1291 // Interface to hard-coded offset checking |
1396 | 1292 |
1397 class JavaClasses : AllStatic { | 1293 class JavaClasses : AllStatic { |
1398 private: | 1294 private: |