Mercurial > hg > graal-jvmci-8
comparison src/share/vm/c1x/c1x_VMEntries.cpp @ 1414:e1a275dbc8cd
Executing a+b with C1X on HotSpot ;-) !
author | Thomas Wuerthinger <thomas.wuerthinger@gmail.com> |
---|---|
date | Tue, 18 May 2010 21:53:05 +0200 |
parents | 1ecc8f0aad00 |
children | 712c7ff1afc1 |
comparison
equal
deleted
inserted
replaced
1413:1ecc8f0aad00 | 1414:e1a275dbc8cd |
---|---|
207 * Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiMethod; | 207 * Signature: (Ljava/lang/Object;I)Lcom/sun/cri/ri/RiMethod; |
208 */ | 208 */ |
209 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jclass, jobject cpHandle, jint index, jbyte byteCode) { | 209 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod(JNIEnv *env, jclass, jobject cpHandle, jint index, jbyte byteCode) { |
210 VM_ENTRY_MARK; | 210 VM_ENTRY_MARK; |
211 constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); | 211 constantPoolOop cp = (constantPoolOop)JNIHandles::resolve(cpHandle); |
212 Bytecodes::Code bc = (Bytecodes::Code)byteCode; | 212 Bytecodes::Code bc = (Bytecodes::Code)(((int)byteCode) & 0xFF); |
213 ciInstanceKlass* loading_klass = (ciInstanceKlass *)CURRENT_ENV->get_object(cp->pool_holder()); | 213 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); | 214 ciMethod *method = CURRENT_ENV->get_method_by_index(cp, index, bc, loading_klass); |
215 return JNIHandles::make_local(THREAD, C1XCompiler::get_RiMethod(method)); | 215 return JNIHandles::make_local(THREAD, C1XCompiler::get_RiMethod(method)); |
216 } | 216 } |
217 | 217 |
305 */ | 305 */ |
306 JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface(JNIEnv *, jclass, jobject klass) { | 306 JNIEXPORT jboolean JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface(JNIEnv *, jclass, jobject klass) { |
307 klassOop o = (klassOop)JNIHandles::resolve(klass); | 307 klassOop o = (klassOop)JNIHandles::resolve(klass); |
308 return o->klass_part()->is_interface(); | 308 return o->klass_part()->is_interface(); |
309 } | 309 } |
310 | |
311 /* | |
312 * Class: com_sun_hotspot_c1x_VMEntries | |
313 * Method: RiMethod_accessFlags | |
314 * Signature: (Ljava/lang/Object;)I | |
315 */ | |
316 JNIEXPORT jint JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1accessFlags(JNIEnv *, jclass, jobject method) { | |
317 methodOop m = (methodOop)JNIHandles::resolve(method); | |
318 return m->access_flags().as_int(); | |
319 } | |
320 | |
321 /* | |
322 * Class: com_sun_hotspot_c1x_VMEntries | |
323 * Method: installCode | |
324 * Signature: (Ljava/lang/Object;[BI)V | |
325 */ | |
326 JNIEXPORT void JNICALL Java_com_sun_hotspot_c1x_VMEntries_installCode(JNIEnv *jniEnv, jclass, jobject method, jbyteArray code, jint frameSize) { | |
327 | |
328 methodOop m = (methodOop)JNIHandles::resolve(method); | |
329 jboolean isCopy = false; | |
330 jbyte *codeBytes = jniEnv->GetByteArrayElements(code, &isCopy); | |
331 // TODO: Check if we need to disallocate? | |
332 int codeSize = jniEnv->GetArrayLength(code); | |
333 VM_ENTRY_MARK; | |
334 ciEnv *env = CURRENT_ENV; | |
335 | |
336 env->set_oop_recorder(new OopRecorder(env->arena())); | |
337 env->set_debug_info(new DebugInformationRecorder(env->oop_recorder())); | |
338 env->set_dependencies(new Dependencies(env)); | |
339 ciMethod *ciMethodObject = (ciMethod *)env->get_object(m); | |
340 CodeOffsets offsets; | |
341 | |
342 // TODO: This is a hack.. Produce correct entries. | |
343 offsets.set_value(CodeOffsets::Exceptions, 0); | |
344 offsets.set_value(CodeOffsets::Deopt, 0); | |
345 | |
346 CodeBuffer buffer((address)codeBytes, codeSize); | |
347 buffer.print(); | |
348 CodeSection *inst_section = buffer.insts(); | |
349 inst_section->set_end(inst_section->start() + codeSize); | |
350 buffer.initialize_oop_recorder(env->oop_recorder()); | |
351 OopMapSet oop_map_set; | |
352 ExceptionHandlerTable handler_table; | |
353 ImplicitExceptionTable inc_table; | |
354 { | |
355 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); | |
357 | |
358 } | |
359 } | |
360 | |
310 | 361 |
311 | 362 |
312 JNINativeMethod VMEntries_methods[] = { | 363 JNINativeMethod VMEntries_methods[] = { |
313 {CC"RiMethod_code", CC"(Ljava/lang/Object;)[B", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1code)}, | 364 {CC"RiMethod_code", CC"(Ljava/lang/Object;)[B", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1code)}, |
314 {CC"RiMethod_maxStackSize", CC"(Ljava/lang/Object;)I", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxStackSize)}, | 365 {CC"RiMethod_maxStackSize", CC"(Ljava/lang/Object;)I", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1maxStackSize)}, |
325 {CC"RiConstantPool_lookupType", CC"(Ljava/lang/Object;I)Lcom/sun/cri/ri/RiType;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType)}, | 376 {CC"RiConstantPool_lookupType", CC"(Ljava/lang/Object;I)Lcom/sun/cri/ri/RiType;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType)}, |
326 {CC"RiConstantPool_lookupField", CC"(Ljava/lang/Object;I)Lcom/sun/cri/ri/RiField;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField)}, | 377 {CC"RiConstantPool_lookupField", CC"(Ljava/lang/Object;I)Lcom/sun/cri/ri/RiField;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField)}, |
327 {CC"RiRuntime_getConstantPool", CC"(Ljava/lang/Object;)Lcom/sun/cri/ri/RiConstantPool;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiRuntime_1getConstantPool)}, | 378 {CC"RiRuntime_getConstantPool", CC"(Ljava/lang/Object;)Lcom/sun/cri/ri/RiConstantPool;", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiRuntime_1getConstantPool)}, |
328 {CC"RiType_isArrayClass", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass)}, | 379 {CC"RiType_isArrayClass", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isArrayClass)}, |
329 {CC"RiType_isInstanceClass", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass)}, | 380 {CC"RiType_isInstanceClass", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInstanceClass)}, |
330 {CC"RiType_isInterface", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface)} | 381 {CC"RiType_isInterface", CC"(Ljava/lang/Object;)Z", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1isInterface)}, |
382 {CC"RiMethod_accessFlags", CC"(Ljava/lang/Object;)I", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1accessFlags)}, | |
383 {CC"installCode", CC"(Ljava/lang/Object;[BI)V", FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_installCode)} | |
331 }; | 384 }; |
332 | 385 |
333 int VMEntries_methods_count() { | 386 int VMEntries_methods_count() { |
334 return sizeof(VMEntries_methods) / sizeof(JNINativeMethod); | 387 return sizeof(VMEntries_methods) / sizeof(JNINativeMethod); |
335 } | 388 } |