Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalCompilerToVM.cpp @ 6588:b89b5038ad7e
removed _'s from method names in CompilerToVM
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 29 Oct 2012 17:12:47 +0100 |
parents | d5f7e737827f |
children | fd71ca8c5f88 |
comparison
equal
deleted
inserted
replaced
6586:cfd5c59df26a | 6588:b89b5038ad7e |
---|---|
50 return (methodDataOop)HotSpotMethodData::hotspotMirror(JNIHandles::resolve(hotspot_method_data)); | 50 return (methodDataOop)HotSpotMethodData::hotspotMirror(JNIHandles::resolve(hotspot_method_data)); |
51 } | 51 } |
52 | 52 |
53 // Entry to native method implementation that transitions current thread to '_thread_in_vm'. | 53 // Entry to native method implementation that transitions current thread to '_thread_in_vm'. |
54 #define C2V_VMENTRY(result_type, name, signature) \ | 54 #define C2V_VMENTRY(result_type, name, signature) \ |
55 JNIEXPORT result_type JNICALL name signature { \ | 55 JNIEXPORT result_type JNICALL c2v_ ## name signature { \ |
56 TRACE_graal_3("CompilerToVM::" #name); \ | 56 TRACE_graal_3("CompilerToVM::" #name); \ |
57 VM_ENTRY_MARK; \ | 57 VM_ENTRY_MARK; \ |
58 | 58 |
59 // Entry to native method implementation that calls a JNI function | 59 // Entry to native method implementation that calls a JNI function |
60 // and hence cannot transition current thread to '_thread_in_vm'. | 60 // and hence cannot transition current thread to '_thread_in_vm'. |
61 #define C2V_ENTRY(result_type, name, signature) \ | 61 #define C2V_ENTRY(result_type, name, signature) \ |
62 JNIEXPORT result_type JNICALL name signature { \ | 62 JNIEXPORT result_type JNICALL c2v_ ## name signature { \ |
63 TRACE_graal_3("CompilerToVM::" #name); \ | 63 TRACE_graal_3("CompilerToVM::" #name); \ |
64 | 64 |
65 #define C2V_END } | 65 #define C2V_END } |
66 | 66 |
67 C2V_ENTRY(jbyteArray, JavaMethod_code, (JNIEnv *env, jobject, jobject hotspot_method)) | 67 C2V_ENTRY(jbyteArray, getBytecode, (JNIEnv *env, jobject, jobject hotspot_method)) |
68 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); | 68 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); |
69 | 69 |
70 // copy all bytecodes | 70 // copy all bytecodes |
71 int code_size = method->code_size(); | 71 int code_size = method->code_size(); |
72 jbyteArray result = env->NewByteArray(code_size); | 72 jbyteArray result = env->NewByteArray(code_size); |
97 } | 97 } |
98 | 98 |
99 return result; | 99 return result; |
100 C2V_END | 100 C2V_END |
101 | 101 |
102 C2V_VMENTRY(jstring, JavaMethod_signature, (JNIEnv *env, jobject, jobject hotspot_method)) | 102 C2V_VMENTRY(jstring, getSignature, (JNIEnv *env, jobject, jobject hotspot_method)) |
103 methodOop method = getMethodFromHotSpotMethod(hotspot_method); | 103 methodOop method = getMethodFromHotSpotMethod(hotspot_method); |
104 assert(method != NULL && method->signature() != NULL, "signature required"); | 104 assert(method != NULL && method->signature() != NULL, "signature required"); |
105 return VmIds::toString<jstring>(method->signature(), THREAD); | 105 return VmIds::toString<jstring>(method->signature(), THREAD); |
106 C2V_END | 106 C2V_END |
107 | 107 |
108 C2V_VMENTRY(jobjectArray, JavaMethod_exceptionHandlers, (JNIEnv *, jobject, jobject hotspot_method)) | 108 C2V_VMENTRY(jobjectArray, getExceptionHandlers, (JNIEnv *, jobject, jobject hotspot_method)) |
109 ResourceMark rm; | 109 ResourceMark rm; |
110 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); | 110 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); |
111 int handler_count = method->exception_table_length(); | 111 int handler_count = method->exception_table_length(); |
112 ExceptionTableElement* handlers = handler_count == 0 ? NULL : method->exception_table_start(); | 112 ExceptionTableElement* handlers = handler_count == 0 ? NULL : method->exception_table_start(); |
113 | 113 |
140 } | 140 } |
141 | 141 |
142 return (jobjectArray) JNIHandles::make_local(array()); | 142 return (jobjectArray) JNIHandles::make_local(array()); |
143 C2V_END | 143 C2V_END |
144 | 144 |
145 C2V_VMENTRY(jint, JavaMethod_hasBalancedMonitors, (JNIEnv *, jobject, jobject hotspot_method)) | 145 C2V_VMENTRY(jint, hasBalancedMonitors, (JNIEnv *, jobject, jobject hotspot_method)) |
146 | 146 |
147 // Analyze the method to see if monitors are used properly. | 147 // Analyze the method to see if monitors are used properly. |
148 methodHandle method(THREAD, getMethodFromHotSpotMethod(hotspot_method)); | 148 methodHandle method(THREAD, getMethodFromHotSpotMethod(hotspot_method)); |
149 assert(method->has_monitor_bytecodes(), "should have checked this"); | 149 assert(method->has_monitor_bytecodes(), "should have checked this"); |
150 | 150 |
190 | 190 |
191 Handle ret = GraalCompiler::get_JavaField(offset, flags, field_name, field_holder, field_type, CHECK_NULL); | 191 Handle ret = GraalCompiler::get_JavaField(offset, flags, field_name, field_holder, field_type, CHECK_NULL); |
192 return JNIHandles::make_local(THREAD, ret()); | 192 return JNIHandles::make_local(THREAD, ret()); |
193 } | 193 } |
194 | 194 |
195 C2V_VMENTRY(jobject, JavaMethod_uniqueConcreteMethod, (JNIEnv *, jobject, jobject hotspot_method)) | 195 C2V_VMENTRY(jobject, getUniqueConcreteMethod, (JNIEnv *, jobject, jobject hotspot_method)) |
196 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); | 196 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); |
197 KlassHandle holder = method->method_holder(); | 197 KlassHandle holder = method->method_holder(); |
198 if (holder->is_interface()) { | 198 if (holder->is_interface()) { |
199 // Cannot trust interfaces. Because of: | 199 // Cannot trust interfaces. Because of: |
200 // interface I { void foo(); } | 200 // interface I { void foo(); } |
217 Handle method_resolved = GraalCompiler::createHotSpotResolvedJavaMethod(unique_concrete, CHECK_NULL); | 217 Handle method_resolved = GraalCompiler::createHotSpotResolvedJavaMethod(unique_concrete, CHECK_NULL); |
218 return JNIHandles::make_local(THREAD, method_resolved()); | 218 return JNIHandles::make_local(THREAD, method_resolved()); |
219 } | 219 } |
220 C2V_END | 220 C2V_END |
221 | 221 |
222 C2V_ENTRY(jint, JavaMethod_invocationCount, (JNIEnv *, jobject, jobject hotspot_method)) | 222 C2V_ENTRY(jint, getInvocationCount, (JNIEnv *, jobject, jobject hotspot_method)) |
223 return getMethodFromHotSpotMethod(hotspot_method)->invocation_count(); | 223 return getMethodFromHotSpotMethod(hotspot_method)->invocation_count(); |
224 C2V_END | 224 C2V_END |
225 | 225 |
226 C2V_VMENTRY(jobject, JavaMethod_methodData,(JNIEnv *, jobject, jobject hotspot_method)) | 226 C2V_VMENTRY(jobject, getMethodData,(JNIEnv *, jobject, jobject hotspot_method)) |
227 | 227 |
228 methodDataHandle method_data = getMethodFromHotSpotMethod(hotspot_method)->method_data(); | 228 methodDataHandle method_data = getMethodFromHotSpotMethod(hotspot_method)->method_data(); |
229 if(method_data.is_null()) { | 229 if(method_data.is_null()) { |
230 return NULL; | 230 return NULL; |
231 } else { | 231 } else { |
258 } | 258 } |
259 } | 259 } |
260 return count; | 260 return count; |
261 } | 261 } |
262 | 262 |
263 C2V_ENTRY(jboolean, JavaMethod_hasCompiledCode, (JNIEnv *, jobject, jobject hotspot_method)) | 263 C2V_ENTRY(jint, getCompiledCodeSize, (JNIEnv *env, jobject, jobject hotspot_method)) |
264 return getMethodFromHotSpotMethod(hotspot_method)->has_compiled_code(); | |
265 C2V_END | |
266 | |
267 C2V_ENTRY(jint, JavaMethod_getCompiledCodeSize, (JNIEnv *env, jobject, jobject hotspot_method)) | |
268 nmethod* code = getMethodFromHotSpotMethod(hotspot_method)->code(); | 264 nmethod* code = getMethodFromHotSpotMethod(hotspot_method)->code(); |
269 return code == NULL ? 0 : code->insts_size(); | 265 return code == NULL ? 0 : code->insts_size(); |
270 C2V_END | 266 C2V_END |
271 | 267 |
272 C2V_VMENTRY(jobject, Signature_lookupType, (JNIEnv *env, jobject, jstring jname, jobject accessingClass, jboolean eagerResolve)) | 268 C2V_VMENTRY(jobject, lookupType, (JNIEnv *env, jobject, jstring jname, jobject accessingClass, jboolean eagerResolve)) |
273 ResourceMark rm; | 269 ResourceMark rm; |
274 | 270 |
275 Symbol* nameSymbol = VmIds::toSymbol(jname); | 271 Symbol* nameSymbol = VmIds::toSymbol(jname); |
276 Handle name = JNIHandles::resolve(jname); | 272 Handle name = JNIHandles::resolve(jname); |
277 | 273 |
332 } | 328 } |
333 | 329 |
334 return JNIHandles::make_local(THREAD, result); | 330 return JNIHandles::make_local(THREAD, result); |
335 C2V_END | 331 C2V_END |
336 | 332 |
337 C2V_VMENTRY(jobject, ConstantPool_lookupConstant, (JNIEnv *env, jobject, jobject type, jint index)) | 333 C2V_VMENTRY(jobject, lookupConstantInPool, (JNIEnv *env, jobject, jobject type, jint index)) |
338 | 334 |
339 constantPoolOop cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(type)))->constants(); | 335 constantPoolOop cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(type)))->constants(); |
340 | 336 |
341 oop result = NULL; | 337 oop result = NULL; |
342 constantTag tag = cp->tag_at(index); | 338 constantTag tag = cp->tag_at(index); |
374 } | 370 } |
375 | 371 |
376 return JNIHandles::make_local(THREAD, result); | 372 return JNIHandles::make_local(THREAD, result); |
377 C2V_END | 373 C2V_END |
378 | 374 |
379 C2V_VMENTRY(jobject, ConstantPool_lookupMethod, (JNIEnv *env, jobject, jobject type, jint index, jbyte byteCode)) | 375 C2V_VMENTRY(jobject, lookupMethodInPool, (JNIEnv *env, jobject, jobject type, jint index, jbyte byteCode)) |
380 index = GraalCompiler::to_cp_index_u2(index); | 376 index = GraalCompiler::to_cp_index_u2(index); |
381 constantPoolHandle cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(type)))->constants(); | 377 constantPoolHandle cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(type)))->constants(); |
382 instanceKlassHandle pool_holder(cp->pool_holder()); | 378 instanceKlassHandle pool_holder(cp->pool_holder()); |
383 | 379 |
384 Bytecodes::Code bc = (Bytecodes::Code) (((int) byteCode) & 0xFF); | 380 Bytecodes::Code bc = (Bytecodes::Code) (((int) byteCode) & 0xFF); |
394 Handle type = GraalCompiler::get_JavaType(cp, holder_index, cp->pool_holder(), CHECK_NULL); | 390 Handle type = GraalCompiler::get_JavaType(cp, holder_index, cp->pool_holder(), CHECK_NULL); |
395 return JNIHandles::make_local(THREAD, VMToCompiler::createJavaMethod(name, signature, type, THREAD)); | 391 return JNIHandles::make_local(THREAD, VMToCompiler::createJavaMethod(name, signature, type, THREAD)); |
396 } | 392 } |
397 C2V_END | 393 C2V_END |
398 | 394 |
399 C2V_VMENTRY(jobject, ConstantPool_lookupType, (JNIEnv *env, jobject, jobject type, jint index)) | 395 C2V_VMENTRY(jobject, lookupTypeInPool, (JNIEnv *env, jobject, jobject type, jint index)) |
400 | 396 |
401 constantPoolOop cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(type)))->constants(); | 397 constantPoolOop cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(type)))->constants(); |
402 Handle result = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL); | 398 Handle result = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL); |
403 return JNIHandles::make_local(THREAD, result()); | 399 return JNIHandles::make_local(THREAD, result()); |
404 C2V_END | 400 C2V_END |
405 | 401 |
406 C2V_VMENTRY(void, ConstantPool_loadReferencedType, (JNIEnv *env, jobject, jobject type, jint index, jbyte op)) | 402 C2V_VMENTRY(void, lookupReferencedTypeInPool, (JNIEnv *env, jobject, jobject type, jint index, jbyte op)) |
407 constantPoolOop cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(type)))->constants(); | 403 constantPoolOop cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(type)))->constants(); |
408 int byteCode = (op & 0xFF); | 404 int opcode = (op & 0xFF); |
409 if (byteCode != Bytecodes::_checkcast && byteCode != Bytecodes::_instanceof && byteCode != Bytecodes::_new && byteCode != Bytecodes::_anewarray | 405 if (opcode != Bytecodes::_checkcast && opcode != Bytecodes::_instanceof && opcode != Bytecodes::_new && opcode != Bytecodes::_anewarray |
410 && byteCode != Bytecodes::_multianewarray && byteCode != Bytecodes::_ldc && byteCode != Bytecodes::_ldc_w && byteCode != Bytecodes::_ldc2_w) | 406 && opcode != Bytecodes::_multianewarray && opcode != Bytecodes::_ldc && opcode != Bytecodes::_ldc_w && opcode != Bytecodes::_ldc2_w) |
411 { | 407 { |
412 index = cp->remap_instruction_operand_from_cache(GraalCompiler::to_cp_index_u2(index)); | 408 index = cp->remap_instruction_operand_from_cache(GraalCompiler::to_cp_index_u2(index)); |
413 } | 409 } |
414 constantTag tag = cp->tag_at(index); | 410 constantTag tag = cp->tag_at(index); |
415 if (tag.is_field_or_method()) { | 411 if (tag.is_field_or_method()) { |
423 instanceKlass::cast(klass)->initialize(CHECK); | 419 instanceKlass::cast(klass)->initialize(CHECK); |
424 } | 420 } |
425 } | 421 } |
426 C2V_END | 422 C2V_END |
427 | 423 |
428 C2V_VMENTRY(jobject, ConstantPool_lookupField, (JNIEnv *env, jobject, jobject constantPoolHolder, jint index, jbyte byteCode)) | 424 C2V_VMENTRY(jobject, lookupFieldInPool, (JNIEnv *env, jobject, jobject constantPoolHolder, jint index, jbyte byteCode)) |
429 ResourceMark rm; | 425 ResourceMark rm; |
430 | 426 |
431 index = GraalCompiler::to_cp_index_u2(index); | 427 index = GraalCompiler::to_cp_index_u2(index); |
432 constantPoolHandle cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(constantPoolHolder)))->constants(); | 428 constantPoolHandle cp = instanceKlass::cast(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(constantPoolHolder)))->constants(); |
433 | 429 |
464 Handle field_handle = GraalCompiler::get_JavaField(offset, flags.as_int(), name, holder, type, THREAD); | 460 Handle field_handle = GraalCompiler::get_JavaField(offset, flags.as_int(), name, holder, type, THREAD); |
465 | 461 |
466 return JNIHandles::make_local(THREAD, field_handle()); | 462 return JNIHandles::make_local(THREAD, field_handle()); |
467 C2V_END | 463 C2V_END |
468 | 464 |
469 C2V_VMENTRY(jobject, JavaType_resolveMethodImpl, (JNIEnv *, jobject, jobject resolved_type, jstring name, jstring signature)) | 465 C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject resolved_type, jstring name, jstring signature)) |
470 | 466 |
471 assert(JNIHandles::resolve(resolved_type) != NULL, ""); | 467 assert(JNIHandles::resolve(resolved_type) != NULL, ""); |
472 klassOop klass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(resolved_type)); | 468 klassOop klass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(resolved_type)); |
473 Symbol* name_symbol = VmIds::toSymbol(name); | 469 Symbol* name_symbol = VmIds::toSymbol(name); |
474 Symbol* signature_symbol = VmIds::toSymbol(signature); | 470 Symbol* signature_symbol = VmIds::toSymbol(signature); |
482 } | 478 } |
483 Handle ret = GraalCompiler::createHotSpotResolvedJavaMethod(method, CHECK_NULL); | 479 Handle ret = GraalCompiler::createHotSpotResolvedJavaMethod(method, CHECK_NULL); |
484 return JNIHandles::make_local(THREAD, ret()); | 480 return JNIHandles::make_local(THREAD, ret()); |
485 C2V_END | 481 C2V_END |
486 | 482 |
487 C2V_VMENTRY(jboolean, JavaType_isSubtypeOf, (JNIEnv *, jobject, jobject klass, jobject jother)) | 483 C2V_VMENTRY(jboolean, isSubtypeOf, (JNIEnv *, jobject, jobject klass, jobject jother)) |
488 oop other = JNIHandles::resolve(jother); | 484 oop other = JNIHandles::resolve(jother); |
489 assert(other->is_a(HotSpotResolvedJavaType::klass()), "resolved hotspot type expected"); | 485 assert(other->is_a(HotSpotResolvedJavaType::klass()), "resolved hotspot type expected"); |
490 assert(JNIHandles::resolve(klass) != NULL, ""); | 486 assert(JNIHandles::resolve(klass) != NULL, ""); |
491 klassOop thisKlass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass)); | 487 klassOop thisKlass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass)); |
492 klassOop otherKlass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(other)); | 488 klassOop otherKlass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(other)); |
498 fatal("unexpected class type"); | 494 fatal("unexpected class type"); |
499 return false; | 495 return false; |
500 } | 496 } |
501 C2V_END | 497 C2V_END |
502 | 498 |
503 C2V_VMENTRY(jobject, JavaType_leastCommonAncestor, (JNIEnv *, jobject, jobject this_type, jobject other_type)) | 499 C2V_VMENTRY(jobject, getLeastCommonAncestor, (JNIEnv *, jobject, jobject this_type, jobject other_type)) |
504 | 500 |
505 Klass* this_klass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(this_type))->klass_part(); | 501 Klass* this_klass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(this_type))->klass_part(); |
506 Klass* other_klass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(other_type))->klass_part(); | 502 Klass* other_klass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(other_type))->klass_part(); |
507 Klass* lca = this_klass->LCA(other_klass); | 503 Klass* lca = this_klass->LCA(other_klass); |
508 | 504 |
509 return JNIHandles::make_local(GraalCompiler::get_JavaType(lca, THREAD)()); | 505 return JNIHandles::make_local(GraalCompiler::get_JavaType(lca, THREAD)()); |
510 C2V_END | 506 C2V_END |
511 | 507 |
512 C2V_VMENTRY(jobject, JavaType_componentType, (JNIEnv *, jobject, jobject klass)) | 508 C2V_VMENTRY(jobject, getComponentType, (JNIEnv *, jobject, jobject klass)) |
513 KlassHandle array_klass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass)); | 509 KlassHandle array_klass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass)); |
514 if(array_klass->oop_is_typeArray()) { | 510 if(array_klass->oop_is_typeArray()) { |
515 BasicType t = typeArrayKlass::cast(array_klass())->element_type(); | 511 BasicType t = typeArrayKlass::cast(array_klass())->element_type(); |
516 oop primitive_type = VMToCompiler::createPrimitiveJavaType((int) t, CHECK_NULL); | 512 oop primitive_type = VMToCompiler::createPrimitiveJavaType((int) t, CHECK_NULL); |
517 return JNIHandles::make_local(primitive_type); | 513 return JNIHandles::make_local(primitive_type); |
520 klassOop element_type = objArrayKlass::cast(array_klass())->element_klass(); | 516 klassOop element_type = objArrayKlass::cast(array_klass())->element_klass(); |
521 assert(JNIHandles::resolve(klass) != NULL, ""); | 517 assert(JNIHandles::resolve(klass) != NULL, ""); |
522 return JNIHandles::make_local(GraalCompiler::get_JavaType(element_type, THREAD)()); | 518 return JNIHandles::make_local(GraalCompiler::get_JavaType(element_type, THREAD)()); |
523 C2V_END | 519 C2V_END |
524 | 520 |
525 C2V_VMENTRY(jlong, JavaType_prototypeMarkWord, (JNIEnv *, jobject, jobject klass)) | 521 C2V_VMENTRY(jlong, getPrototypeMarkWord, (JNIEnv *, jobject, jobject klass)) |
526 KlassHandle klass_handle(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass))); | 522 KlassHandle klass_handle(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass))); |
527 if (klass_handle->oop_is_array()) { | 523 if (klass_handle->oop_is_array()) { |
528 return (int32_t)(intptr_t) markOopDesc::prototype(); | 524 return (int32_t)(intptr_t) markOopDesc::prototype(); |
529 } else { | 525 } else { |
530 return (jlong) (intptr_t) klass_handle->prototype_header(); | 526 return (jlong) (intptr_t) klass_handle->prototype_header(); |
531 } | 527 } |
532 C2V_END | 528 C2V_END |
533 | 529 |
534 C2V_VMENTRY(jobject, JavaType_superType, (JNIEnv *, jobject, jobject klass)) | 530 C2V_VMENTRY(jobject, getSuperType, (JNIEnv *, jobject, jobject klass)) |
535 KlassHandle klass_handle(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass))); | 531 KlassHandle klass_handle(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass))); |
536 klassOop k; | 532 klassOop k; |
537 | 533 |
538 if (klass_handle->oop_is_array()) { | 534 if (klass_handle->oop_is_array()) { |
539 k = SystemDictionary::Object_klass(); | 535 k = SystemDictionary::Object_klass(); |
547 } else { | 543 } else { |
548 return NULL; | 544 return NULL; |
549 } | 545 } |
550 C2V_END | 546 C2V_END |
551 | 547 |
552 C2V_VMENTRY(jobject, JavaType_uniqueConcreteSubtype, (JNIEnv *, jobject, jobject klass)) | 548 C2V_VMENTRY(jobject, getUniqueConcreteSubtype, (JNIEnv *, jobject, jobject klass)) |
553 KlassHandle klass_handle(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass))); | 549 KlassHandle klass_handle(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass))); |
554 Klass *up_cast = klass_handle->up_cast_abstract(); | 550 Klass *up_cast = klass_handle->up_cast_abstract(); |
555 if (!up_cast->is_interface() && up_cast->subklass() == NULL) { | 551 if (!up_cast->is_interface() && up_cast->subklass() == NULL) { |
556 return JNIHandles::make_local(GraalCompiler::get_JavaType(up_cast, THREAD)()); | 552 return JNIHandles::make_local(GraalCompiler::get_JavaType(up_cast, THREAD)()); |
557 } | 553 } |
558 return NULL; | 554 return NULL; |
559 C2V_END | 555 C2V_END |
560 | 556 |
561 C2V_VMENTRY(jboolean, JavaType_isInitialized,(JNIEnv *, jobject, jobject hotspot_klass)) | 557 C2V_VMENTRY(jboolean, isTypeInitialized,(JNIEnv *, jobject, jobject hotspot_klass)) |
562 klassOop klass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(hotspot_klass)); | 558 klassOop klass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(hotspot_klass)); |
563 assert(klass != NULL, "method must not be called for primitive types"); | 559 assert(klass != NULL, "method must not be called for primitive types"); |
564 return instanceKlass::cast(klass)->is_initialized(); | 560 return instanceKlass::cast(klass)->is_initialized(); |
565 C2V_END | 561 C2V_END |
566 | 562 |
567 // public bool JavaType_isInitialized(HotSpotResolvedType klass); | 563 C2V_VMENTRY(void, initializeType, (JNIEnv *, jobject, jobject hotspot_klass)) |
568 C2V_VMENTRY(void, JavaType_initialize, (JNIEnv *, jobject, jobject hotspot_klass)) | |
569 klassOop klass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(hotspot_klass)); | 564 klassOop klass = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(hotspot_klass)); |
570 assert(klass != NULL, "method must not be called for primitive types"); | 565 assert(klass != NULL, "method must not be called for primitive types"); |
571 instanceKlass::cast(klass)->initialize(JavaThread::current()); | 566 instanceKlass::cast(klass)->initialize(JavaThread::current()); |
572 C2V_END | 567 C2V_END |
573 | 568 |
574 C2V_VMENTRY(jobject, JavaType_arrayOf, (JNIEnv *, jobject, jobject klass)) | 569 C2V_VMENTRY(jobject, getArrayOf, (JNIEnv *, jobject, jobject klass)) |
575 KlassHandle klass_handle(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass))); | 570 KlassHandle klass_handle(java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass))); |
576 KlassHandle arr = klass_handle->array_klass(THREAD); | 571 KlassHandle arr = klass_handle->array_klass(THREAD); |
577 Handle name = VmIds::toString<Handle>(arr->name(), CHECK_NULL); | 572 Handle name = VmIds::toString<Handle>(arr->name(), CHECK_NULL); |
578 assert(arr->oop_is_array(), ""); | 573 assert(arr->oop_is_array(), ""); |
579 return JNIHandles::make_local(THREAD, GraalCompiler::createHotSpotResolvedJavaType(arr, name, THREAD)()); | 574 return JNIHandles::make_local(THREAD, GraalCompiler::createHotSpotResolvedJavaType(arr, name, THREAD)()); |
580 C2V_END | 575 C2V_END |
581 | 576 |
582 C2V_VMENTRY(jobject, JavaType_fields, (JNIEnv *, jobject, jobject klass)) | 577 C2V_VMENTRY(jobject, getFields, (JNIEnv *, jobject, jobject klass)) |
583 ResourceMark rm; | 578 ResourceMark rm; |
584 | 579 |
585 instanceKlassHandle k = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass)); | 580 instanceKlassHandle k = java_lang_Class::as_klassOop(HotSpotResolvedJavaType::javaMirror(klass)); |
586 class MyFieldClosure : public FieldClosure { | 581 class MyFieldClosure : public FieldClosure { |
587 public: | 582 public: |
831 | 826 |
832 Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL); | 827 Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL); |
833 return JNIHandles::make_local(result()); | 828 return JNIHandles::make_local(result()); |
834 C2V_END | 829 C2V_END |
835 | 830 |
836 C2V_VMENTRY(jobject, JavaMethod_toStackTraceElement, (JNIEnv *env, jobject, jobject hotspot_method, int bci)) | 831 C2V_VMENTRY(jobject, getStackTraceElement, (JNIEnv *env, jobject, jobject hotspot_method, int bci)) |
837 ResourceMark rm; | 832 ResourceMark rm; |
838 HandleMark hm; | 833 HandleMark hm; |
839 | 834 |
840 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); | 835 methodHandle method = getMethodFromHotSpotMethod(hotspot_method); |
841 oop element = java_lang_StackTraceElement::create(method, bci, CHECK_NULL); | 836 oop element = java_lang_StackTraceElement::create(method, bci, CHECK_NULL); |
891 JavaCalls::call(&result, actualMethod, nm, &args, CHECK_NULL); | 886 JavaCalls::call(&result, actualMethod, nm, &args, CHECK_NULL); |
892 | 887 |
893 return JNIHandles::make_local((oop) result.get_jobject()); | 888 return JNIHandles::make_local((oop) result.get_jobject()); |
894 C2V_END | 889 C2V_END |
895 | 890 |
896 C2V_VMENTRY(jint, JavaMethod_vtableEntryOffset, (JNIEnv *, jobject, jobject hotspot_method)) | 891 C2V_VMENTRY(jint, getVtableEntryOffset, (JNIEnv *, jobject, jobject hotspot_method)) |
897 | 892 |
898 methodOop method = getMethodFromHotSpotMethod(hotspot_method); | 893 methodOop method = getMethodFromHotSpotMethod(hotspot_method); |
899 assert(!instanceKlass::cast(method->method_holder())->is_interface(), "vtableEntryOffset cannot be called for interface methods"); | 894 assert(!instanceKlass::cast(method->method_holder())->is_interface(), "vtableEntryOffset cannot be called for interface methods"); |
900 assert(instanceKlass::cast(method->method_holder())->is_linked(), "vtableEntryOffset cannot be called is holder is not linked"); | 895 assert(instanceKlass::cast(method->method_holder())->is_linked(), "vtableEntryOffset cannot be called is holder is not linked"); |
901 | 896 |
937 return JNIHandles::make_local(result()); | 932 return JNIHandles::make_local(result()); |
938 C2V_END | 933 C2V_END |
939 | 934 |
940 | 935 |
941 #define CC (char*) /*cast a literal from (const char*)*/ | 936 #define CC (char*) /*cast a literal from (const char*)*/ |
942 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(f)) | 937 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f)) |
943 | 938 |
944 #define PROXY "J" | 939 #define PROXY "J" |
945 #define TYPE "Lcom/oracle/graal/api/meta/JavaType;" | 940 #define TYPE "Lcom/oracle/graal/api/meta/JavaType;" |
946 #define RESOLVED_TYPE "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaType;" | 941 #define RESOLVED_TYPE "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaType;" |
947 #define METHOD "Lcom/oracle/graal/api/meta/JavaMethod;" | 942 #define METHOD "Lcom/oracle/graal/api/meta/JavaMethod;" |
966 #define OBJECT "Ljava/lang/Object;" | 961 #define OBJECT "Ljava/lang/Object;" |
967 #define CLASS "Ljava/lang/Class;" | 962 #define CLASS "Ljava/lang/Class;" |
968 #define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;" | 963 #define STACK_TRACE_ELEMENT "Ljava/lang/StackTraceElement;" |
969 | 964 |
970 JNINativeMethod CompilerToVM_methods[] = { | 965 JNINativeMethod CompilerToVM_methods[] = { |
971 {CC"JavaMethod_code", CC"("RESOLVED_METHOD")[B", FN_PTR(JavaMethod_code)}, | 966 {CC"getBytecode", CC"("RESOLVED_METHOD")[B", FN_PTR(getBytecode)}, |
972 {CC"JavaMethod_signature", CC"("RESOLVED_METHOD")"STRING, FN_PTR(JavaMethod_signature)}, | 967 {CC"getSignature", CC"("RESOLVED_METHOD")"STRING, FN_PTR(getSignature)}, |
973 {CC"JavaMethod_exceptionHandlers", CC"("RESOLVED_METHOD")"EXCEPTION_HANDLERS, FN_PTR(JavaMethod_exceptionHandlers)}, | 968 {CC"getExceptionHandlers", CC"("RESOLVED_METHOD")"EXCEPTION_HANDLERS, FN_PTR(getExceptionHandlers)}, |
974 {CC"JavaMethod_hasBalancedMonitors", CC"("RESOLVED_METHOD")Z", FN_PTR(JavaMethod_hasBalancedMonitors)}, | 969 {CC"hasBalancedMonitors", CC"("RESOLVED_METHOD")Z", FN_PTR(hasBalancedMonitors)}, |
975 {CC"JavaMethod_uniqueConcreteMethod", CC"("RESOLVED_METHOD")"METHOD, FN_PTR(JavaMethod_uniqueConcreteMethod)}, | 970 {CC"getUniqueConcreteMethod", CC"("RESOLVED_METHOD")"METHOD, FN_PTR(getUniqueConcreteMethod)}, |
976 {CC"JavaMethod_toStackTraceElement", CC"("RESOLVED_METHOD"I)"STACK_TRACE_ELEMENT, FN_PTR(JavaMethod_toStackTraceElement)}, | 971 {CC"getStackTraceElement", CC"("RESOLVED_METHOD"I)"STACK_TRACE_ELEMENT, FN_PTR(getStackTraceElement)}, |
977 {CC"JavaMethod_methodData", CC"("RESOLVED_METHOD")"METHOD_DATA, FN_PTR(JavaMethod_methodData)}, | 972 {CC"getMethodData", CC"("RESOLVED_METHOD")"METHOD_DATA, FN_PTR(getMethodData)}, |
978 {CC"JavaMethod_invocationCount", CC"("RESOLVED_METHOD")I", FN_PTR(JavaMethod_invocationCount)}, | 973 {CC"getInvocationCount", CC"("RESOLVED_METHOD")I", FN_PTR(getInvocationCount)}, |
979 {CC"JavaMethod_hasCompiledCode", CC"("RESOLVED_METHOD")Z", FN_PTR(JavaMethod_hasCompiledCode)}, | 974 {CC"getCompiledCodeSize", CC"("RESOLVED_METHOD")I", FN_PTR(getCompiledCodeSize)}, |
980 {CC"JavaMethod_getCompiledCodeSize", CC"("RESOLVED_METHOD")I", FN_PTR(JavaMethod_getCompiledCodeSize)}, | 975 {CC"getVtableEntryOffset", CC"("RESOLVED_METHOD")I", FN_PTR(getVtableEntryOffset)}, |
981 {CC"JavaMethod_vtableEntryOffset", CC"("RESOLVED_METHOD")I", FN_PTR(JavaMethod_vtableEntryOffset)}, | 976 {CC"lookupType", CC"("STRING RESOLVED_TYPE"Z)"TYPE, FN_PTR(lookupType)}, |
982 | 977 {CC"lookupConstantInPool", CC"("RESOLVED_TYPE"I)"OBJECT, FN_PTR(lookupConstantInPool)}, |
983 {CC"Signature_lookupType", CC"("STRING RESOLVED_TYPE"Z)"TYPE, FN_PTR(Signature_lookupType)}, | 978 {CC"lookupMethodInPool", CC"("RESOLVED_TYPE"IB)"METHOD, FN_PTR(lookupMethodInPool)}, |
984 | 979 {CC"lookupTypeInPool", CC"("RESOLVED_TYPE"I)"TYPE, FN_PTR(lookupTypeInPool)}, |
985 {CC"ConstantPool_lookupConstant", CC"("RESOLVED_TYPE"I)"OBJECT, FN_PTR(ConstantPool_lookupConstant)}, | 980 {CC"lookupReferencedTypeInPool", CC"("RESOLVED_TYPE"IB)V", FN_PTR(lookupReferencedTypeInPool)}, |
986 {CC"ConstantPool_lookupMethod", CC"("RESOLVED_TYPE"IB)"METHOD, FN_PTR(ConstantPool_lookupMethod)}, | 981 {CC"lookupFieldInPool", CC"("RESOLVED_TYPE"IB)"FIELD, FN_PTR(lookupFieldInPool)}, |
987 {CC"ConstantPool_lookupType", CC"("RESOLVED_TYPE"I)"TYPE, FN_PTR(ConstantPool_lookupType)}, | 982 {CC"resolveMethod", CC"("RESOLVED_TYPE STRING STRING")"METHOD, FN_PTR(resolveMethod)}, |
988 {CC"ConstantPool_loadReferencedType", CC"("RESOLVED_TYPE"IB)V", FN_PTR(ConstantPool_loadReferencedType)}, | 983 {CC"isSubtypeOf", CC"("RESOLVED_TYPE TYPE")Z", FN_PTR(isSubtypeOf)}, |
989 {CC"ConstantPool_lookupField", CC"("RESOLVED_TYPE"IB)"FIELD, FN_PTR(ConstantPool_lookupField)}, | 984 {CC"getLeastCommonAncestor", CC"("RESOLVED_TYPE RESOLVED_TYPE")"TYPE, FN_PTR(getLeastCommonAncestor)}, |
990 | 985 {CC"getComponentType", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(getComponentType)}, |
991 {CC"JavaType_resolveMethodImpl", CC"("RESOLVED_TYPE STRING STRING")"METHOD, FN_PTR(JavaType_resolveMethodImpl)}, | 986 {CC"getUniqueConcreteSubtype", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(getUniqueConcreteSubtype)}, |
992 {CC"JavaType_isSubtypeOf", CC"("RESOLVED_TYPE TYPE")Z", FN_PTR(JavaType_isSubtypeOf)}, | 987 {CC"getSuperType", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(getSuperType)}, |
993 {CC"JavaType_leastCommonAncestor", CC"("RESOLVED_TYPE RESOLVED_TYPE")"TYPE, FN_PTR(JavaType_leastCommonAncestor)}, | 988 {CC"getPrototypeMarkWord", CC"("RESOLVED_TYPE")J", FN_PTR(getPrototypeMarkWord)}, |
994 {CC"JavaType_componentType", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(JavaType_componentType)}, | 989 {CC"getArrayOf", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(getArrayOf)}, |
995 {CC"JavaType_uniqueConcreteSubtype", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(JavaType_uniqueConcreteSubtype)}, | 990 {CC"getFields", CC"("RESOLVED_TYPE")["RESOLVED_FIELD, FN_PTR(getFields)}, |
996 {CC"JavaType_superType", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(JavaType_superType)}, | 991 {CC"isTypeInitialized", CC"("RESOLVED_TYPE")Z", FN_PTR(isTypeInitialized)}, |
997 {CC"JavaType_prototypeMarkWord", CC"("RESOLVED_TYPE")J", FN_PTR(JavaType_prototypeMarkWord)}, | 992 {CC"initializeType", CC"("RESOLVED_TYPE")V", FN_PTR(initializeType)}, |
998 {CC"JavaType_arrayOf", CC"("RESOLVED_TYPE")"TYPE, FN_PTR(JavaType_arrayOf)}, | 993 {CC"getPrimitiveArrayType", CC"("KIND")"TYPE, FN_PTR(getPrimitiveArrayType)}, |
999 {CC"JavaType_fields", CC"("RESOLVED_TYPE")["RESOLVED_FIELD, FN_PTR(JavaType_fields)}, | 994 {CC"getMaxCallTargetOffset", CC"(J)J", FN_PTR(getMaxCallTargetOffset)}, |
1000 {CC"JavaType_isInitialized", CC"("RESOLVED_TYPE")Z", FN_PTR(JavaType_isInitialized)}, | 995 {CC"getType", CC"("CLASS")"TYPE, FN_PTR(getType)}, |
1001 {CC"JavaType_initialize", CC"("RESOLVED_TYPE")V", FN_PTR(JavaType_initialize)}, | 996 {CC"getJavaMethod", CC"("REFLECT_METHOD")"METHOD , FN_PTR(getJavaMethod)}, |
1002 | 997 {CC"getJavaField", CC"("REFLECT_FIELD")"RESOLVED_FIELD, FN_PTR(getJavaField)}, |
1003 {CC"getPrimitiveArrayType", CC"("KIND")"TYPE, FN_PTR(getPrimitiveArrayType)}, | 998 {CC"initializeConfiguration", CC"("CONFIG")V", FN_PTR(initializeConfiguration)}, |
1004 {CC"getMaxCallTargetOffset", CC"(J)J", FN_PTR(getMaxCallTargetOffset)}, | 999 {CC"installMethod", CC"("HS_COMP_RESULT"Z"HS_CODE_INFO")"HS_COMP_METHOD, FN_PTR(installMethod)}, |
1005 {CC"getType", CC"("CLASS")"TYPE, FN_PTR(getType)}, | 1000 {CC"disassembleNative", CC"([BJ)"STRING, FN_PTR(disassembleNative)}, |
1006 {CC"getJavaMethod", CC"("REFLECT_METHOD")"METHOD , FN_PTR(getJavaMethod)}, | 1001 {CC"executeCompiledMethod", CC"("HS_COMP_METHOD OBJECT OBJECT OBJECT")"OBJECT, FN_PTR(executeCompiledMethod)}, |
1007 {CC"getJavaField", CC"("REFLECT_FIELD")"RESOLVED_FIELD, FN_PTR(getJavaField)}, | 1002 {CC"executeCompiledMethodVarargs", CC"("HS_COMP_METHOD "["OBJECT")"OBJECT, FN_PTR(executeCompiledMethodVarargs)}, |
1008 {CC"initializeConfiguration", CC"("CONFIG")V", FN_PTR(initializeConfiguration)}, | 1003 {CC"getDeoptedLeafGraphIds", CC"()[J", FN_PTR(getDeoptedLeafGraphIds)}, |
1009 {CC"installMethod", CC"("HS_COMP_RESULT"Z"HS_CODE_INFO")"HS_COMP_METHOD, FN_PTR(installMethod)}, | 1004 {CC"decodePC", CC"(J)"STRING, FN_PTR(decodePC)}, |
1010 {CC"disassembleNative", CC"([BJ)"STRING, FN_PTR(disassembleNative)}, | |
1011 {CC"executeCompiledMethod", CC"("HS_COMP_METHOD OBJECT OBJECT OBJECT")"OBJECT, FN_PTR(executeCompiledMethod)}, | |
1012 {CC"executeCompiledMethodVarargs", CC"("HS_COMP_METHOD "["OBJECT")"OBJECT, FN_PTR(executeCompiledMethodVarargs)}, | |
1013 {CC"getDeoptedLeafGraphIds", CC"()[J", FN_PTR(getDeoptedLeafGraphIds)}, | |
1014 {CC"decodePC", CC"(J)"STRING, FN_PTR(decodePC)}, | |
1015 }; | 1005 }; |
1016 | 1006 |
1017 int CompilerToVM_methods_count() { | 1007 int CompilerToVM_methods_count() { |
1018 return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod); | 1008 return sizeof(CompilerToVM_methods) / sizeof(JNINativeMethod); |
1019 } | 1009 } |