Mercurial > hg > graal-jvmci-8
comparison src/share/vm/c1x/c1x_VMEntries.cpp @ 1421:6223633ce7dd
changed VMExit/VMEntries to non-static, added eclipse c++ project, CIR interface changes
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Fri, 23 Jul 2010 15:53:02 -0700 |
parents | 7bf6a77b9c5a |
children | 3483ec571caf |
comparison
equal
deleted
inserted
replaced
1420:44efca8a02d6 | 1421:6223633ce7dd |
---|---|
24 | 24 |
25 | 25 |
26 # include "incls/_precompiled.incl" | 26 # include "incls/_precompiled.incl" |
27 # include "incls/_c1x_VMEntries.cpp.incl" | 27 # include "incls/_c1x_VMEntries.cpp.incl" |
28 | 28 |
29 | |
29 /* | 30 /* |
30 * Class: com_sun_hotspot_c1x_VMEntries | 31 * Class: com_sun_hotspot_c1x_VMEntries |
31 * Method: RiMethod_code | 32 * Method: RiMethod_code |
32 * Signature: (Ljava/lang/Object;)[B | 33 * Signature: (Ljava/lang/Object;)[B |
33 */ | 34 */ |
34 JNIEXPORT jbyteArray JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1code(JNIEnv *env, jclass, jobject method) { | 35 JNIEXPORT jbyteArray JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1code(JNIEnv *env, jobject, jobject method) { |
35 methodOop m = (methodOop)JNIHandles::resolve(method); | 36 methodOop m = (methodOop)JNIHandles::resolve(method); |
36 int code_size = m->code_size(); | 37 int code_size = m->code_size(); |
37 jbyteArray result = env->NewByteArray(code_size); | 38 jbyteArray result = env->NewByteArray(code_size); |
38 env->SetByteArrayRegion(result, 0, code_size, (const jbyte *)m->code_base()); | 39 env->SetByteArrayRegion(result, 0, code_size, (const jbyte *)m->code_base()); |
39 return result; | 40 return result; |
42 /* | 43 /* |
43 * Class: com_sun_hotspot_c1x_VMEntries | 44 * Class: com_sun_hotspot_c1x_VMEntries |
44 * Method: RiMethod_maxStackSize | 45 * Method: RiMethod_maxStackSize |
45 * Signature: (Ljava/lang/Object;)I | 46 * Signature: (Ljava/lang/Object;)I |
46 */ | 47 */ |
47 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxStackSize(JNIEnv *, jclass, jobject method) { | 48 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxStackSize(JNIEnv *, jobject, jobject method) { |
48 methodOop m = (methodOop)JNIHandles::resolve(method); | 49 methodOop m = (methodOop)JNIHandles::resolve(method); |
49 return m->max_stack(); | 50 return m->max_stack(); |
50 } | 51 } |
51 | 52 |
52 /* | 53 /* |
53 * Class: com_sun_hotspot_c1x_VMEntries | 54 * Class: com_sun_hotspot_c1x_VMEntries |
54 * Method: RiMethod_maxLocals | 55 * Method: RiMethod_maxLocals |
55 * Signature: (Ljava/lang/Object;)I | 56 * Signature: (Ljava/lang/Object;)I |
56 */ | 57 */ |
57 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxLocals(JNIEnv *, jclass, jobject method) { | 58 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxLocals(JNIEnv *, jobject, jobject method) { |
58 methodOop m = (methodOop)JNIHandles::resolve(method); | 59 methodOop m = (methodOop)JNIHandles::resolve(method); |
59 return m->max_locals(); | 60 return m->max_locals(); |
60 } | 61 } |
61 | 62 |
62 /* | 63 /* |
63 * Class: com_sun_hotspot_c1x_VMEntries | 64 * Class: com_sun_hotspot_c1x_VMEntries |
64 * Method: RiMethod_holder | 65 * Method: RiMethod_holder |
65 * Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiType; | 66 * Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiType; |
66 */ | 67 */ |
67 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1holder(JNIEnv *, jclass, jobject method) { | 68 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1holder(JNIEnv *, jobject, jobject method) { |
68 VM_ENTRY_MARK | 69 VM_ENTRY_MARK |
69 methodOop m = (methodOop)JNIHandles::resolve(method); | 70 methodOop m = (methodOop)JNIHandles::resolve(method); |
70 klassOop k = m->method_holder(); | 71 klassOop k = m->method_holder(); |
71 return JNIHandles::make_local(Thread::current(), C1XCompiler::get_RiType(k)); | 72 return JNIHandles::make_local(Thread::current(), C1XCompiler::get_RiType(k)); |
72 } | 73 } |
74 /* | 75 /* |
75 * Class: com_sun_hotspot_c1x_VMEntries | 76 * Class: com_sun_hotspot_c1x_VMEntries |
76 * Method: RiMethod_signature | 77 * Method: RiMethod_signature |
77 * Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiSignature; | 78 * Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiSignature; |
78 */ | 79 */ |
79 JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1signature(JNIEnv *env, jclass, jobject method) { | 80 JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1signature(JNIEnv *env, jobject, jobject method) { |
80 methodOop m = (methodOop)JNIHandles::resolve(method); | 81 methodOop m = (methodOop)JNIHandles::resolve(method); |
81 return env->NewStringUTF(m->signature()->as_utf8()); | 82 return env->NewStringUTF(m->signature()->as_utf8()); |
82 } | 83 } |
83 | 84 |
84 /* | 85 /* |
85 * Class: com_sun_hotspot_c1x_VMEntries | 86 * Class: com_sun_hotspot_c1x_VMEntries |
86 * Method: RiMethod_name | 87 * Method: RiMethod_name |
87 * Signature: (Ljava/lang/Object;)Ljava/lang/String; | 88 * Signature: (Ljava/lang/Object;)Ljava/lang/String; |
88 */ | 89 */ |
89 JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1name(JNIEnv *env, jclass, jobject method) { | 90 JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1name(JNIEnv *env, jobject, jobject method) { |
90 methodOop m = (methodOop)JNIHandles::resolve(method); | 91 methodOop m = (methodOop)JNIHandles::resolve(method); |
91 return env->NewStringUTF(m->name()->as_utf8()); | 92 return env->NewStringUTF(m->name()->as_utf8()); |
92 } | 93 } |
93 | 94 |
94 /* | 95 /* |
95 * Class: com_sun_hotspot_c1x_VMEntries | 96 * Class: com_sun_hotspot_c1x_VMEntries |
96 * Method: RiSignature_lookupType | 97 * Method: RiSignature_lookupType |
97 * Signature: (Ljava/lang/String;Lcom/sun/cri/ri/RiType;)Lcom/sun/cri/ri/RiType; | 98 * Signature: (Ljava/lang/String;Lcom/sun/cri/ri/RiType;)Lcom/sun/cri/ri/RiType; |
98 */ | 99 */ |
99 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1lookupType(JNIEnv *, jclass, jstring name, jobject accessor) { | 100 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1lookupType(JNIEnv *, jobject, jstring name, jobject accessor) { |
100 VM_ENTRY_MARK | 101 VM_ENTRY_MARK |
101 klassOop k = (klassOop)JNIHandles::resolve(accessor); | 102 klassOop k = (klassOop)JNIHandles::resolve(accessor); |
102 oop n = JNIHandles::resolve_external_guard(name); | 103 oop n = JNIHandles::resolve_external_guard(name); |
103 if (n == NULL) { | 104 if (n == NULL) { |
104 THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "Name must not be null.", NULL); | 105 THROW_MSG_(vmSymbols::java_lang_NullPointerException(), "Name must not be null.", NULL); |
112 /* | 113 /* |
113 * Class: com_sun_hotspot_c1x_VMEntries | 114 * Class: com_sun_hotspot_c1x_VMEntries |
114 * Method: RiSignature_symbolToString | 115 * Method: RiSignature_symbolToString |
115 * Signature: (Ljava/lang/Object;)Ljava/lang/String; | 116 * Signature: (Ljava/lang/Object;)Ljava/lang/String; |
116 */ | 117 */ |
117 JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1symbolToString(JNIEnv *env, jclass, jobject symbol) { | 118 JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1symbolToString(JNIEnv *env, jobject, jobject symbol) { |
118 symbolOop s = (symbolOop)JNIHandles::resolve(symbol); | 119 symbolOop s = (symbolOop)JNIHandles::resolve(symbol); |
119 return env->NewStringUTF(s->as_utf8()); | 120 return env->NewStringUTF(s->as_utf8()); |
120 } | 121 } |
121 | 122 |
122 /* | 123 /* |
123 * Class: com_sun_hotspot_c1x_VMEntries | 124 * Class: com_sun_hotspot_c1x_VMEntries |
124 * Method: RiType_javaClass | 125 * Method: RiType_javaClass |
125 * Signature: (Ljava/lang/Object;)Ljava/lang/Class; | 126 * Signature: (Ljava/lang/Object;)Ljava/lang/Class; |
126 */ | 127 */ |
127 JNIEXPORT jclass JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1javaClass(JNIEnv *, jclass, jobject klass) { | 128 JNIEXPORT jclass JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1javaClass(JNIEnv *, jobject, jobject klass) { |
128 klassOop k = (klassOop)JNIHandles::resolve(klass); | 129 klassOop k = (klassOop)JNIHandles::resolve(klass); |
129 oop result = k->klass_part()->java_mirror(); | 130 oop result = k->klass_part()->java_mirror(); |
130 return (jclass) JNIHandles::make_local(Thread::current(), result); | 131 return (jclass) JNIHandles::make_local(Thread::current(), result); |
131 } | 132 } |
132 | 133 |
133 /* | 134 /* |
134 * Class: com_sun_hotspot_c1x_VMEntries | 135 * Class: com_sun_hotspot_c1x_VMEntries |
135 * Method: RiType_name | 136 * Method: RiType_name |
136 * Signature: (Ljava/lang/Object;)Ljava/lang/String; | 137 * Signature: (Ljava/lang/Object;)Ljava/lang/String; |
137 */ | 138 */ |
138 JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1name(JNIEnv *env, jclass, jobject klass) { | 139 JNIEXPORT jstring JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1name(JNIEnv *env, jobject, jobject klass) { |
139 klassOop k = (klassOop)JNIHandles::resolve(klass); | 140 klassOop k = (klassOop)JNIHandles::resolve(klass); |
140 return env->NewStringUTF(k->klass_part()->name()->as_utf8()); | 141 return env->NewStringUTF(k->klass_part()->name()->as_utf8()); |
141 } | 142 } |
142 | 143 |
143 | 144 |
144 /* | 145 /* |
145 * Class: com_sun_hotspot_c1x_VMEntries | 146 * Class: com_sun_hotspot_c1x_VMEntries |
146 * Method: RiConstantPool_lookupConstant | 147 * Method: RiConstantPool_lookupConstant |
147 * Signature: (Ljava/lang/Object;I)Ljava/lang/Object; | 148 * Signature: (Ljava/lang/Object;I)Ljava/lang/Object; |
148 */ | 149 */ |
149 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupConstant(JNIEnv *env, jclass, jobject cpHandle, jint index) { | 150 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupConstant(JNIEnv *env, jobject, jobject cpHandle, jint index) { |
150 | 151 |
151 VM_ENTRY_MARK; | 152 VM_ENTRY_MARK; |
152 constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); | 153 constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); |
153 | 154 |
154 oop result = NULL; | 155 oop result = NULL; |
204 /* | 205 /* |
205 * Class: com_sun_hotspot_c1x_VMEntries | 206 * Class: com_sun_hotspot_c1x_VMEntries |
206 * Method: RiConstantPool_lookupMethod | 207 * Method: RiConstantPool_lookupMethod |
207 * Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiMethod; | 208 * Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiMethod; |
208 */ | 209 */ |
209 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jclass, jobject cpHandle, jint index, jbyte byteCode) { | 210 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jobject, jobject cpHandle, jint index, jbyte byteCode) { |
210 VM_ENTRY_MARK; | 211 VM_ENTRY_MARK; |
211 constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); | 212 constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); |
212 Bytecodes::Code bc = (Bytecodes::Code)(((int)byteCode) & 0xFF); | 213 Bytecodes::Code bc = (Bytecodes::Code)(((int)byteCode) & 0xFF); |
213 ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); | 214 ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); |
214 ciMethod *method = CURRENT_ENV->get_method_by_index(cp, index, bc, loading_klass); | 215 ciMethod *method = CURRENT_ENV->get_method_by_index(cp, index, bc, loading_klass); |
218 /* | 219 /* |
219 * Class: com_sun_hotspot_c1x_VMEntries | 220 * Class: com_sun_hotspot_c1x_VMEntries |
220 * Method: RiConstantPool_lookupSignature | 221 * Method: RiConstantPool_lookupSignature |
221 * Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiSignature; | 222 * Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiSignature; |
222 */ | 223 */ |
223 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupSignature(JNIEnv *env, jclass, jobject cpHandle, jint index) { | 224 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupSignature(JNIEnv *env, jobject, jobject cpHandle, jint index) { |
224 fatal("currently unsupported"); | 225 fatal("currently unsupported"); |
225 return NULL; | 226 return NULL; |
226 } | 227 } |
227 | 228 |
228 /* | 229 /* |
229 * Class: com_sun_hotspot_c1x_VMEntries | 230 * Class: com_sun_hotspot_c1x_VMEntries |
230 * Method: RiConstantPool_lookupType | 231 * Method: RiConstantPool_lookupType |
231 * Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiType; | 232 * Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiType; |
232 */ | 233 */ |
233 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType(JNIEnv *env, jclass, jobject cpHandle, jint index) { | 234 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType(JNIEnv *env, jobject, jobject cpHandle, jint index) { |
234 VM_ENTRY_MARK; | 235 VM_ENTRY_MARK; |
235 constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); | 236 constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); |
236 ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); | 237 ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); |
237 bool is_accessible = false; | 238 bool is_accessible = false; |
238 ciKlass *klass = CURRENT_ENV->get_klass_by_index(cp, index, is_accessible, loading_klass); | 239 ciKlass *klass = CURRENT_ENV->get_klass_by_index(cp, index, is_accessible, loading_klass); |
243 /* | 244 /* |
244 * Class: com_sun_hotspot_c1x_VMEntries | 245 * Class: com_sun_hotspot_c1x_VMEntries |
245 * Method: RiConstantPool_lookupField | 246 * Method: RiConstantPool_lookupField |
246 * Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiField; | 247 * Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiField; |
247 */ | 248 */ |
248 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jclass, jobject cpHandle, jint index) { | 249 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jobject, jobject cpHandle, jint index) { |
249 VM_ENTRY_MARK; | 250 VM_ENTRY_MARK; |
250 constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); | 251 constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); |
251 ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); | 252 ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); |
252 ciField *field = CURRENT_ENV->get_field_by_index(loading_klass, index); | 253 ciField *field = CURRENT_ENV->get_field_by_index(loading_klass, index); |
253 return JNIHandles::make_local(THREAD, C1XCompiler::get_RiField(field)); | 254 return JNIHandles::make_local(THREAD, C1XCompiler::get_RiField(field)); |
256 /* | 257 /* |
257 * Class: com_sun_hotspot_c1x_VMEntries | 258 * Class: com_sun_hotspot_c1x_VMEntries |
258 * Method: findRiType | 259 * Method: findRiType |
259 * Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiType; | 260 * Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiType; |
260 */ | 261 */ |
261 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_findRiType(JNIEnv *, jclass, jobject klass) { | 262 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_findRiType(JNIEnv *, jobject, jobject klass) { |
262 VM_ENTRY_MARK; | 263 VM_ENTRY_MARK; |
263 klassOop o = (klassOop)JNIHandles::resolve(klass); | 264 klassOop o = (klassOop)JNIHandles::resolve(klass); |
264 return JNIHandles::make_local(THREAD, C1XCompiler::get_RiType(o)); | 265 return JNIHandles::make_local(THREAD, C1XCompiler::get_RiType(o)); |
265 } | 266 } |
266 | 267 |
267 /* | 268 /* |
268 * Class: com_sun_hotspot_c1x_VMEntries | 269 * Class: com_sun_hotspot_c1x_VMEntries |
269 * Method: RiRuntime_getConstantPool | 270 * Method: RiRuntime_getConstantPool |
270 * Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiConstantPool; | 271 * Signature: (Ljava/lang/Object;)Lcom/sun/cri/ri/RiConstantPool; |
271 */ | 272 */ |
272 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiRuntime_1getConstantPool(JNIEnv *, jclass, jobject klass) { | 273 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiRuntime_1getConstantPool(JNIEnv *, jobject, jobject klass) { |
273 VM_ENTRY_MARK; | 274 VM_ENTRY_MARK; |
274 klassOop o = (klassOop)JNIHandles::resolve(klass); | 275 klassOop o = (klassOop)JNIHandles::resolve(klass); |
275 return JNIHandles::make_local(THREAD, C1XCompiler::get_RiConstantPool(((instanceKlass*)o->klass_part())->constants())); | 276 return JNIHandles::make_local(THREAD, C1XCompiler::get_RiConstantPool(((instanceKlass*)o->klass_part())->constants())); |
276 } | 277 } |
277 | 278 |
278 /* | 279 /* |
279 * Class: com_sun_hotspot_c1x_VMEntries | 280 * Class: com_sun_hotspot_c1x_VMEntries |
280 * Method: RiType_isArrayClass | 281 * Method: RiType_isArrayClass |
281 * Signature: (Ljava/lang/Object;)Z | 282 * Signature: (Ljava/lang/Object;)Z |
282 */ | 283 */ |
283 JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass(JNIEnv *, jclass, jobject klass) { | 284 JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass(JNIEnv *, jobject, jobject klass) { |
284 klassOop o = (klassOop)JNIHandles::resolve(klass); | 285 klassOop o = (klassOop)JNIHandles::resolve(klass); |
285 o->print(); | 286 o->print(); |
286 bool result = o->klass_part()->oop_is_array(); | 287 bool result = o->klass_part()->oop_is_array(); |
287 tty->print_cr("result=%d", (int)result); | 288 tty->print_cr("result=%d", (int)result); |
288 return result; | 289 return result; |
291 /* | 292 /* |
292 * Class: com_sun_hotspot_c1x_VMEntries | 293 * Class: com_sun_hotspot_c1x_VMEntries |
293 * Method: RiType_isInstanceClass | 294 * Method: RiType_isInstanceClass |
294 * Signature: (Ljava/lang/Object;)Z | 295 * Signature: (Ljava/lang/Object;)Z |
295 */ | 296 */ |
296 JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass(JNIEnv *, jclass, jobject klass) { | 297 JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass(JNIEnv *, jobject, jobject klass) { |
297 klassOop o = (klassOop)JNIHandles::resolve(klass); | 298 klassOop o = (klassOop)JNIHandles::resolve(klass); |
298 return o->klass_part()->oop_is_instanceKlass(); | 299 return o->klass_part()->oop_is_instanceKlass(); |
299 } | 300 } |
300 | 301 |
301 /* | 302 /* |
302 * Class: com_sun_hotspot_c1x_VMEntries | 303 * Class: com_sun_hotspot_c1x_VMEntries |
303 * Method: RiType_isInterface | 304 * Method: RiType_isInterface |
304 * Signature: (Ljava/lang/Object;)Z | 305 * Signature: (Ljava/lang/Object;)Z |
305 */ | 306 */ |
306 JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface(JNIEnv *, jclass, jobject klass) { | 307 JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface(JNIEnv *, jobject, jobject klass) { |
307 klassOop o = (klassOop)JNIHandles::resolve(klass); | 308 klassOop o = (klassOop)JNIHandles::resolve(klass); |
308 return o->klass_part()->is_interface(); | 309 return o->klass_part()->is_interface(); |
309 } | 310 } |
310 | 311 |
311 /* | 312 /* |
312 * Class: com_sun_hotspot_c1x_VMEntries | 313 * Class: com_sun_hotspot_c1x_VMEntries |
313 * Method: RiMethod_accessFlags | 314 * Method: RiMethod_accessFlags |
314 * Signature: (Ljava/lang/Object;)I | 315 * Signature: (Ljava/lang/Object;)I |
315 */ | 316 */ |
316 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1accessFlags(JNIEnv *, jclass, jobject method) { | 317 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1accessFlags(JNIEnv *, jobject, jobject method) { |
317 methodOop m = (methodOop)JNIHandles::resolve(method); | 318 methodOop m = (methodOop)JNIHandles::resolve(method); |
318 return m->access_flags().as_int(); | 319 return m->access_flags().as_int(); |
319 } | 320 } |
320 | 321 |
322 | |
323 // helpers used to set fields in the HotSpotVMConfig object | |
324 jfieldID getFieldID(JNIEnv* env, jobject obj, const char* name, const char* sig) { | |
325 jfieldID id = env->GetFieldID(env->GetObjectClass(obj), name, sig); | |
326 if (id == NULL) { | |
327 tty->print_cr("field not found: %s (%s)", name, sig); | |
328 assert(id != NULL, "field not found"); | |
329 } | |
330 return id; | |
331 } | |
332 | |
333 void set_boolean(JNIEnv* env, jobject obj, const char* name, bool value) { env->SetBooleanField(obj, getFieldID(env, obj, name, "Z"), value); } | |
334 void set_int(JNIEnv* env, jobject obj, const char* name, int value) { env->SetIntField(obj, getFieldID(env, obj, name, "I"), value); } | |
335 void set_long(JNIEnv* env, jobject obj, const char* name, long value) { env->SetLongField(obj, getFieldID(env, obj, name, "J"), value); } | |
336 | |
337 jboolean get_boolean(JNIEnv* env, jobject obj, const char* name) { return env->GetBooleanField(obj, getFieldID(env, obj, name, "Z")); } | |
338 jint get_int(JNIEnv* env, jobject obj, const char* name) { return env->GetIntField(obj, getFieldID(env, obj, name, "I")); } | |
339 jobject get_object(JNIEnv* env, jobject obj, const char* name) { return env->GetObjectField(obj, getFieldID(env, obj, name, "Ljava/lang/Object;")); } | |
340 jobject get_object(JNIEnv* env, jobject obj, const char* name, const char* sig) { return env->GetObjectField(obj, getFieldID(env, obj, name, sig)); } | |
341 | |
342 | |
343 // Helpful routine for computing field offsets at run time rather than hardcoding them | |
344 int compute_offset(klassOop klass_oop, const char* name, const char* sig) { | |
345 JavaThread* THREAD = JavaThread::current(); | |
346 fieldDescriptor fd; | |
347 instanceKlass* ik = instanceKlass::cast(klass_oop); | |
348 symbolOop name_symbol = SymbolTable::probe(name, (int)strlen(name)); | |
349 symbolOop signature_symbol = SymbolTable::probe(sig, (int)strlen(sig)); | |
350 if (name_symbol == NULL || signature_symbol == NULL || !ik->find_local_field(name_symbol, signature_symbol, &fd)) { | |
351 ResourceMark rm; | |
352 tty->print_cr("Invalid layout of %s at %s", ik->external_name(), name_symbol->as_C_string()); | |
353 fatal("Invalid layout of c1x4hotspot class"); | |
354 } | |
355 return fd.offset(); | |
356 } | |
357 | |
358 | |
359 class TypeHelper { | |
360 public: | |
361 jclass jniHotSpotType; | |
362 jclass jniHotSpotTargetMethod; | |
363 klassOop HotSpotType; | |
364 klassOop HotSpotTargetMethod; | |
365 int HotSpotType_klassOop; | |
366 | |
367 TypeHelper(JNIEnv* jniEnv) { | |
368 jniHotSpotType = jniEnv->FindClass("com/sun/hotspot/c1x/HotSpotType"); | |
369 jniHotSpotTargetMethod = jniEnv->FindClass("com/sun/hotspot/c1x/HotSpotTargetMethod"); | |
370 } | |
371 | |
372 void initialize() { | |
373 HotSpotType = java_lang_Class::as_klassOop(JNIHandles::resolve(jniHotSpotType)); | |
374 HotSpotTargetMethod = java_lang_Class::as_klassOop(JNIHandles::resolve(jniHotSpotTargetMethod)); | |
375 HotSpotType_klassOop = compute_offset(HotSpotType, "klassOop", "Ljava/lang/Object;"); | |
376 } | |
377 }; | |
378 | |
379 | |
380 | |
381 | |
321 /* | 382 /* |
322 * Class: com_sun_hotspot_c1x_VMEntries | 383 * Class: com_sun_hotspot_c1x_VMEntries |
323 * Method: installCode | 384 * Method: installCode |
324 * Signature: (Ljava/lang/Object;[BI)V | 385 * Signature: (Lcom/sun/hotspot/c1x/HotSpotTargetMethod;)V |
325 */ | 386 */ |
326 JNIEXPORT void JNICALL Java_com_sun_hotspot_c1x_VMEntries_installCode(JNIEnv *jniEnv, jclass, jobject method, jbyteArray code, jint frameSize) { | 387 JNIEXPORT void JNICALL Java_com_sun_hotspot_c1x_VMEntries_installCode(JNIEnv *jniEnv, jobject, jobject targetMethod) { |
327 | 388 TypeHelper types(jniEnv); |
328 methodOop m = (methodOop)JNIHandles::resolve(method); | 389 |
329 jboolean isCopy = false; | 390 methodOop m = (methodOop)JNIHandles::resolve(get_object(jniEnv, targetMethod, "methodOop")); |
330 jbyte *codeBytes = jniEnv->GetByteArrayElements(code, &isCopy); | 391 jbyteArray code = (jbyteArray)get_object(jniEnv, targetMethod, "code", "[B"); |
331 // TODO: Check if we need to disallocate? | 392 jintArray relocationOffsetsObj = (jintArray)get_object(jniEnv, targetMethod, "relocationOffsets", "[I"); |
332 int codeSize = jniEnv->GetArrayLength(code); | 393 jobjectArray relocationDataObj = (jobjectArray)get_object(jniEnv, targetMethod, "relocationData", "[Ljava/lang/Object;"); |
394 jint frameSize = get_int(jniEnv, targetMethod, "frameSize"); | |
395 | |
396 CodeOffsets offsets; | |
397 | |
398 // TODO: This is a hack.. Produce correct entries. | |
399 offsets.set_value(CodeOffsets::Exceptions, 0); | |
400 offsets.set_value(CodeOffsets::Deopt, 0); | |
401 | |
402 offsets.set_value(CodeOffsets::Entry, get_int(jniEnv, targetMethod, "unverifiedEntrypoint")); | |
403 offsets.set_value(CodeOffsets::Verified_Entry, get_int(jniEnv, targetMethod, "verifiedEntrypoint")); | |
404 | |
333 VM_ENTRY_MARK; | 405 VM_ENTRY_MARK; |
334 ciEnv *env = CURRENT_ENV; | 406 ciEnv *env = CURRENT_ENV; |
407 | |
408 types.initialize(); | |
335 | 409 |
336 env->set_oop_recorder(new OopRecorder(env->arena())); | 410 env->set_oop_recorder(new OopRecorder(env->arena())); |
337 env->set_debug_info(new DebugInformationRecorder(env->oop_recorder())); | 411 env->set_debug_info(new DebugInformationRecorder(env->oop_recorder())); |
338 env->set_dependencies(new Dependencies(env)); | 412 env->set_dependencies(new Dependencies(env)); |
339 ciMethod *ciMethodObject = (ciMethod *)env->get_object(m); | 413 ciMethod *ciMethodObject = (ciMethod *)env->get_object(m); |
340 CodeOffsets offsets; | 414 |
341 | 415 int codeSize = ((arrayOop)JNIHandles::resolve(code))->length(); |
342 // TODO: This is a hack.. Produce correct entries. | 416 int relocationCount = relocationOffsetsObj == NULL ? 0 : ((arrayOop)JNIHandles::resolve(relocationOffsetsObj))->length(); |
343 offsets.set_value(CodeOffsets::Exceptions, 0); | 417 |
344 offsets.set_value(CodeOffsets::Deopt, 0); | 418 CodeBuffer buffer("c1x nmethod", codeSize, relocationCount * relocInfo::length_limit); |
345 | 419 buffer.initialize_oop_recorder(env->oop_recorder()); |
346 CodeBuffer buffer((address)codeBytes, codeSize); | 420 |
421 // copy the code into the newly created CodeBuffer | |
422 CodeSection* instructions = buffer.insts(); | |
423 memcpy(instructions->start(), ((arrayOop)JNIHandles::resolve(code))->base(T_BYTE), codeSize); | |
424 instructions->set_end(instructions->start() + codeSize); | |
425 | |
426 if (relocationCount > 0) { | |
427 jint* relocationOffsets = (jint*)((arrayOop)JNIHandles::resolve(relocationOffsetsObj))->base(T_INT); | |
428 oop* relocationObjects = (oop*)((arrayOop)JNIHandles::resolve(relocationDataObj))->base(T_OBJECT); | |
429 | |
430 for (int i=0; i<relocationCount; i++) { | |
431 address inst = (address)instructions->start() + relocationOffsets[i]; | |
432 oop obj = relocationObjects[i]; | |
433 assert(obj != NULL, "NULL oop needn't be patched"); | |
434 | |
435 if (java_lang_boxing_object::is_instance(obj, T_LONG)) { | |
436 address operand = Assembler::locate_operand(inst, Assembler::call32_operand); | |
437 long dest = obj->long_field(java_lang_boxing_object::value_offset_in_bytes(T_LONG)); | |
438 long disp = dest - (long)(operand + 4); | |
439 assert(disp == (int) disp, "disp doesn't fit in 32 bits"); | |
440 *((int*)operand) = (int)disp; | |
441 | |
442 instructions->relocate(inst, runtime_call_Relocation::spec(), Assembler::call32_operand); | |
443 tty->print_cr("relocating (Long)"); | |
444 } else if (obj->is_a(types.HotSpotType)) { | |
445 address operand = Assembler::locate_operand(inst, Assembler::imm_operand); | |
446 | |
447 *((oop**)operand) = obj->obj_field_addr<oop>(types.HotSpotType_klassOop); | |
448 instructions->relocate(inst, oop_Relocation::spec_for_immediate(), Assembler::imm_operand); | |
449 tty->print_cr("relocating (HotSpotType)"); | |
450 } else { | |
451 tty->print_cr("unknown relocation type"); | |
452 } | |
453 } | |
454 } | |
455 | |
347 buffer.print(); | 456 buffer.print(); |
348 CodeSection *inst_section = buffer.insts(); | 457 |
349 inst_section->set_end(inst_section->start() + codeSize); | |
350 buffer.initialize_oop_recorder(env->oop_recorder()); | |
351 OopMapSet oop_map_set; | 458 OopMapSet oop_map_set; |
352 ExceptionHandlerTable handler_table; | 459 ExceptionHandlerTable handler_table; |
353 ImplicitExceptionTable inc_table; | 460 ImplicitExceptionTable inc_table; |
354 { | 461 { |
355 ThreadToNativeFromVM t((JavaThread*)THREAD); | 462 ThreadToNativeFromVM t((JavaThread*)THREAD); |
356 env->register_method(ciMethodObject, -1, &offsets, 0, &buffer, frameSize, &oop_map_set, &handler_table, &inc_table, NULL, env->comp_level(), false, false); | 463 env->register_method(ciMethodObject, -1, &offsets, 0, &buffer, frameSize, &oop_map_set, &handler_table, &inc_table, NULL, env->comp_level(), false, false); |
357 | 464 |
358 } | 465 } |
359 } | 466 } |
360 | 467 |
361 // helpers used to set fields in the HotSpotVMConfig object | |
362 #define SET_CONFIG_BOOLEAN(name, value) { jfieldID id = jniEnv->GetFieldID(klass, #name, "Z"); jniEnv->SetBooleanField(config, id, value); } | |
363 #define SET_CONFIG_INT(name, value) { jfieldID id = jniEnv->GetFieldID(klass, #name, "I"); jniEnv->SetIntField(config, id, value); } | |
364 | |
365 /* | 468 /* |
366 * Class: com_sun_hotspot_c1x_VMEntries | 469 * Class: com_sun_hotspot_c1x_VMEntries |
367 * Method: getConfiguration | 470 * Method: getConfiguration |
368 * Signature: ()Lcom/sun/hotspot/c1x/HotSpotVMConfig; | 471 * Signature: ()Lcom/sun/hotspot/c1x/HotSpotVMConfig; |
369 */ | 472 */ |
370 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_getConfiguration(JNIEnv *jniEnv, jclass) { | 473 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_getConfiguration(JNIEnv *env, jobject) { |
371 jclass klass = jniEnv->FindClass("com/sun/hotspot/c1x/HotSpotVMConfig"); | 474 jclass klass = env->FindClass("com/sun/hotspot/c1x/HotSpotVMConfig"); |
372 assert(klass != NULL, "HotSpot vm config class not found"); | 475 assert(klass != NULL, "HotSpot vm config class not found"); |
373 jobject config = jniEnv->AllocObject(klass); | 476 jobject config = env->AllocObject(klass); |
374 jfieldID id = jniEnv->GetFieldID(klass, "windowsOs", "Z"); | |
375 #ifdef _WIN64 | 477 #ifdef _WIN64 |
376 SET_CONFIG_BOOLEAN(windowsOs, true) | 478 set_boolean(env, config, "windowsOs", true); |
377 #else | 479 #else |
378 SET_CONFIG_BOOLEAN(windowsOs, false) | 480 set_boolean(env, config, "windowsOs", false); |
379 #endif | 481 #endif |
482 set_int(env, config, "codeEntryAlignment", CodeEntryAlignment); | |
483 set_int(env, config, "vmPageSize", os::vm_page_size()); | |
484 set_int(env, config, "stackShadowPages", StackShadowPages); | |
485 set_int(env, config, "hubOffset", oopDesc::klass_offset_in_bytes()); | |
486 set_long(env, config, "instanceofStub", (long)Runtime1::entry_for(Runtime1::slow_subtype_check_id)); | |
487 set_long(env, config, "debugStub", (long)warning); | |
380 return config; | 488 return config; |
381 } | 489 } |
382 | 490 |
383 | 491 |
384 JNINativeMethod VMEntries_methods[] = { | 492 JNINativeMethod VMEntries_methods[] = { |
387 {CC"RiMethod_maxLocals", CC"(Ljava/lang/Object;)I", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxLocals)}, | 495 {CC"RiMethod_maxLocals", CC"(Ljava/lang/Object;)I", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxLocals)}, |
388 {CC"RiMethod_holder", CC"(Ljava/lang/Object;)Lcom/sun/cri/ri/RiType;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1holder)}, | 496 {CC"RiMethod_holder", CC"(Ljava/lang/Object;)Lcom/sun/cri/ri/RiType;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1holder)}, |
389 {CC"RiMethod_signature", CC"(Ljava/lang/Object;)Ljava/lang/String;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1signature)}, | 497 {CC"RiMethod_signature", CC"(Ljava/lang/Object;)Ljava/lang/String;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1signature)}, |
390 {CC"RiMethod_name", CC"(Ljava/lang/Object;)Ljava/lang/String;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1name)}, | 498 {CC"RiMethod_name", CC"(Ljava/lang/Object;)Ljava/lang/String;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1name)}, |
391 {CC"RiSignature_lookupType", CC"(Ljava/lang/String;Ljava/lang/Object;)Lcom/sun/cri/ri/RiType;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1lookupType)}, | 499 {CC"RiSignature_lookupType", CC"(Ljava/lang/String;Ljava/lang/Object;)Lcom/sun/cri/ri/RiType;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1lookupType)}, |
500 {CC"RiSignature_symbolToString", CC"(Ljava/lang/Object;)Ljava/lang/String;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiSignature_1symbolToString)}, | |
392 {CC"RiType_javaClass", CC"(Ljava/lang/Object;)Ljava/lang/Class;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1javaClass)}, | 501 {CC"RiType_javaClass", CC"(Ljava/lang/Object;)Ljava/lang/Class;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1javaClass)}, |
393 {CC"RiType_name", CC"(Ljava/lang/Object;)Ljava/lang/String;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1name)}, | 502 {CC"RiType_name", CC"(Ljava/lang/Object;)Ljava/lang/String;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1name)}, |
394 {CC"RiConstantPool_lookupConstant", CC"(Ljava/lang/Object;I)Ljava/lang/Object;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupConstant)}, | 503 {CC"RiConstantPool_lookupConstant", CC"(Ljava/lang/Object;I)Ljava/lang/Object;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupConstant)}, |
395 {CC"RiConstantPool_lookupMethod", CC"(Ljava/lang/Object;IB)Lcom/sun/cri/ri/RiMethod;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod)}, | 504 {CC"RiConstantPool_lookupMethod", CC"(Ljava/lang/Object;IB)Lcom/sun/cri/ri/RiMethod;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod)}, |
396 {CC"RiConstantPool_lookupSignature", CC"(Ljava/lang/Object;I)Lcom/sun/cri/ri/RiSignature;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupSignature)}, | 505 {CC"RiConstantPool_lookupSignature", CC"(Ljava/lang/Object;I)Lcom/sun/cri/ri/RiSignature;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupSignature)}, |
399 {CC"RiRuntime_getConstantPool", CC"(Ljava/lang/Object;)Lcom/sun/cri/ri/RiConstantPool;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiRuntime_1getConstantPool)}, | 508 {CC"RiRuntime_getConstantPool", CC"(Ljava/lang/Object;)Lcom/sun/cri/ri/RiConstantPool;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiRuntime_1getConstantPool)}, |
400 {CC"RiType_isArrayClass", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass)}, | 509 {CC"RiType_isArrayClass", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass)}, |
401 {CC"RiType_isInstanceClass", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass)}, | 510 {CC"RiType_isInstanceClass", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass)}, |
402 {CC"RiType_isInterface", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface)}, | 511 {CC"RiType_isInterface", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface)}, |
403 {CC"RiMethod_accessFlags", CC"(Ljava/lang/Object;)I", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1accessFlags)}, | 512 {CC"RiMethod_accessFlags", CC"(Ljava/lang/Object;)I", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1accessFlags)}, |
404 {CC"installCode", CC"(Ljava/lang/Object;[BI)V", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_installCode)}, | 513 {CC"installCode", CC"(Lcom/sun/hotspot/c1x/HotSpotTargetMethod;)V", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_installCode)}, |
405 {CC"getConfiguration", CC"()Lcom/sun/hotspot/c1x/HotSpotVMConfig;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_getConfiguration)} | 514 {CC"getConfiguration", CC"()Lcom/sun/hotspot/c1x/HotSpotVMConfig;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_getConfiguration)} |
406 }; | 515 }; |
407 | 516 |
408 int VMEntries_methods_count() { | 517 int VMEntries_methods_count() { |
409 return sizeof(VMEntries_methods) / sizeof(JNINativeMethod); | 518 return sizeof(VMEntries_methods) / sizeof(JNINativeMethod); |