comparison src/share/vm/graal/graalCompilerToVM.cpp @ 8506:c3657d00e343

-Merge with tip
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Thu, 21 Mar 2013 14:11:13 +0100
parents 86b4965f0c9a 8d6ea1915d42
children 83fde86ae759
comparison
equal deleted inserted replaced
8505:dee7c8b578c7 8506:c3657d00e343
35 #include "graal/graalCompiler.hpp" 35 #include "graal/graalCompiler.hpp"
36 #include "graal/graalEnv.hpp" 36 #include "graal/graalEnv.hpp"
37 #include "graal/graalJavaAccess.hpp" 37 #include "graal/graalJavaAccess.hpp"
38 #include "graal/graalCodeInstaller.hpp" 38 #include "graal/graalCodeInstaller.hpp"
39 #include "graal/graalVMToCompiler.hpp" 39 #include "graal/graalVMToCompiler.hpp"
40 #include "graal/graalVmIds.hpp"
41 #include "gc_implementation/g1/heapRegion.hpp" 40 #include "gc_implementation/g1/heapRegion.hpp"
42 41
43 42
44 Method* getMethodFromHotSpotMethod(oop hotspot_method) { 43 Method* getMethodFromHotSpotMethod(oop hotspot_method) {
45 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethod::klass()), "sanity"); 44 assert(hotspot_method != NULL && hotspot_method->is_a(HotSpotResolvedJavaMethod::klass()), "sanity");
85 if (reconstituted_code == NULL) { 84 if (reconstituted_code == NULL) {
86 reconstituted_code = NEW_RESOURCE_ARRAY(jbyte, code_size); 85 reconstituted_code = NEW_RESOURCE_ARRAY(jbyte, code_size);
87 memcpy(reconstituted_code, (jbyte *) method->code_base(), code_size); 86 memcpy(reconstituted_code, (jbyte *) method->code_base(), code_size);
88 } 87 }
89 BytecodeStream s(method); 88 BytecodeStream s(method);
90 while(!s.is_last_bytecode()) { 89 while (!s.is_last_bytecode()) {
91 s.next(); 90 s.next();
92 Bytecodes::Code opcode = s.raw_code(); 91 Bytecodes::Code opcode = s.raw_code();
93 if (!Bytecodes::is_java_code(opcode)) { 92 if (!Bytecodes::is_java_code(opcode)) {
94 jbyte original_opcode = Bytecodes::java_code(opcode); 93 jbyte original_opcode = Bytecodes::java_code(opcode);
95 int bci = s.bci(); 94 int bci = s.bci();
119 C2V_END 118 C2V_END
120 119
121 C2V_VMENTRY(jstring, getSignature, (JNIEnv *env, jobject, jlong metaspace_method)) 120 C2V_VMENTRY(jstring, getSignature, (JNIEnv *env, jobject, jlong metaspace_method))
122 Method* method = asMethod(metaspace_method); 121 Method* method = asMethod(metaspace_method);
123 assert(method != NULL && method->signature() != NULL, "signature required"); 122 assert(method != NULL && method->signature() != NULL, "signature required");
124 return VmIds::toString<jstring>(method->signature(), THREAD); 123 return (jstring)JNIHandles::make_local(java_lang_String::create_from_symbol(method->signature(), THREAD)());
125 C2V_END 124 C2V_END
126 125
127 C2V_VMENTRY(jobjectArray, initializeExceptionHandlers, (JNIEnv *, jobject, jlong metaspace_method, jobjectArray java_handlers)) 126 C2V_VMENTRY(jobjectArray, initializeExceptionHandlers, (JNIEnv *, jobject, jlong metaspace_method, jobjectArray java_handlers))
128 ResourceMark rm; 127 ResourceMark rm;
129 methodHandle method = asMethod(metaspace_method); 128 methodHandle method = asMethod(metaspace_method);
270 return method->invocation_count(); 269 return method->invocation_count();
271 C2V_END 270 C2V_END
272 271
273 C2V_VMENTRY(void, initializeMethod,(JNIEnv *, jobject, jlong metaspace_method, jobject hotspot_method)) 272 C2V_VMENTRY(void, initializeMethod,(JNIEnv *, jobject, jlong metaspace_method, jobject hotspot_method))
274 methodHandle method = asMethod(metaspace_method); 273 methodHandle method = asMethod(metaspace_method);
275 Handle name = VmIds::toString<Handle>(method->name(), CHECK); 274 Handle name = java_lang_String::create_from_symbol(method->name(), CHECK);
276 InstanceKlass::cast(HotSpotResolvedJavaMethod::klass())->initialize(CHECK); 275 InstanceKlass::cast(HotSpotResolvedJavaMethod::klass())->initialize(CHECK);
277 HotSpotResolvedJavaMethod::set_name(hotspot_method, name()); 276 HotSpotResolvedJavaMethod::set_name(hotspot_method, name());
278 HotSpotResolvedJavaMethod::set_codeSize(hotspot_method, method->code_size()); 277 HotSpotResolvedJavaMethod::set_codeSize(hotspot_method, method->code_size());
279 HotSpotResolvedJavaMethod::set_exceptionHandlerCount(hotspot_method, method->exception_table_length()); 278 HotSpotResolvedJavaMethod::set_exceptionHandlerCount(hotspot_method, method->exception_table_length());
280 C2V_END 279 C2V_END
322 C2V_END 321 C2V_END
323 322
324 C2V_VMENTRY(jobject, lookupType, (JNIEnv *env, jobject, jstring jname, jobject accessingClass, jboolean eagerResolve)) 323 C2V_VMENTRY(jobject, lookupType, (JNIEnv *env, jobject, jstring jname, jobject accessingClass, jboolean eagerResolve))
325 ResourceMark rm; 324 ResourceMark rm;
326 325
327 Symbol* nameSymbol = VmIds::toSymbol(jname);
328 Handle name = JNIHandles::resolve(jname); 326 Handle name = JNIHandles::resolve(jname);
327 Symbol* nameSymbol = java_lang_String::as_symbol(name, THREAD);
329 assert(nameSymbol != NULL, "name to symbol creation failed"); 328 assert(nameSymbol != NULL, "name to symbol creation failed");
330 329
331 oop result = NULL; 330 oop result = NULL;
332 if (nameSymbol == vmSymbols::int_signature()) { 331 if (nameSymbol == vmSymbols::int_signature()) {
333 result = VMToCompiler::createPrimitiveJavaType((int) T_INT, THREAD); 332 result = VMToCompiler::createPrimitiveJavaType((int) T_INT, THREAD);
407 } 406 }
408 result = VMToCompiler::createConstantObject(string, CHECK_0); 407 result = VMToCompiler::createConstantObject(string, CHECK_0);
409 } else if (tag.is_klass() || tag.is_unresolved_klass()) { 408 } else if (tag.is_klass() || tag.is_unresolved_klass()) {
410 Handle type = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL); 409 Handle type = GraalCompiler::get_JavaType(cp, index, cp->pool_holder(), CHECK_NULL);
411 result = type(); 410 result = type();
412 } else if (tag.is_object()) {
413 oop obj = cp->object_at(index);
414 assert(obj->is_instance(), "must be an instance");
415 result = VMToCompiler::createConstantObject(obj, CHECK_NULL);
416 } else { 411 } else {
417 tty->print("unknown constant pool tag (%s) at cpi %d in %s: ", tag.internal_name(), index, cp->pool_holder()->name()->as_C_string()); 412 tty->print("unknown constant pool tag (%s) at cpi %d in %s: ", tag.internal_name(), index, cp->pool_holder()->name()->as_C_string());
418 ShouldNotReachHere(); 413 ShouldNotReachHere();
419 } 414 }
420 415
431 if (!method.is_null()) { 426 if (!method.is_null()) {
432 Handle holder = GraalCompiler::get_JavaType(method->method_holder(), CHECK_NULL); 427 Handle holder = GraalCompiler::get_JavaType(method->method_holder(), CHECK_NULL);
433 return JNIHandles::make_local(THREAD, VMToCompiler::createResolvedJavaMethod(holder, method(), THREAD)); 428 return JNIHandles::make_local(THREAD, VMToCompiler::createResolvedJavaMethod(holder, method(), THREAD));
434 } else { 429 } else {
435 // Get the method's name and signature. 430 // Get the method's name and signature.
436 Handle name = VmIds::toString<Handle>(cp->name_ref_at(index), CHECK_NULL); 431 Handle name = java_lang_String::create_from_symbol(cp->name_ref_at(index), CHECK_NULL);
437 Handle signature = VmIds::toString<Handle>(cp->signature_ref_at(index), CHECK_NULL); 432 Handle signature = java_lang_String::create_from_symbol(cp->signature_ref_at(index), CHECK_NULL);
438 int holder_index = cp->klass_ref_index_at(index); 433 int holder_index = cp->klass_ref_index_at(index);
439 Handle type = GraalCompiler::get_JavaType(cp, holder_index, cp->pool_holder(), CHECK_NULL); 434 Handle type = GraalCompiler::get_JavaType(cp, holder_index, cp->pool_holder(), CHECK_NULL);
440 return JNIHandles::make_local(THREAD, VMToCompiler::createUnresolvedJavaMethod(name, signature, type, THREAD)); 435 return JNIHandles::make_local(THREAD, VMToCompiler::createUnresolvedJavaMethod(name, signature, type, THREAD));
441 } 436 }
442 C2V_END 437 C2V_END
513 508
514 C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject resolved_type, jstring name, jstring signature)) 509 C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject resolved_type, jstring name, jstring signature))
515 510
516 assert(JNIHandles::resolve(resolved_type) != NULL, ""); 511 assert(JNIHandles::resolve(resolved_type) != NULL, "");
517 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(resolved_type)); 512 Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectType::javaMirror(resolved_type));
518 Symbol* name_symbol = VmIds::toSymbol(name); 513 Symbol* name_symbol = java_lang_String::as_symbol(JNIHandles::resolve(name), THREAD);
519 Symbol* signature_symbol = VmIds::toSymbol(signature); 514 Symbol* signature_symbol = java_lang_String::as_symbol(JNIHandles::resolve(signature), THREAD);
520 methodHandle method = klass->lookup_method(name_symbol, signature_symbol); 515 methodHandle method = klass->lookup_method(name_symbol, signature_symbol);
521 if (method.is_null()) { 516 if (method.is_null()) {
522 if (TraceGraal >= 3) { 517 if (TraceGraal >= 3) {
523 ResourceMark rm; 518 ResourceMark rm;
524 tty->print_cr("Could not resolve method %s %s on klass %s", name_symbol->as_C_string(), signature_symbol->as_C_string(), klass->name()->as_C_string()); 519 tty->print_cr("Could not resolve method %s %s on klass %s", name_symbol->as_C_string(), signature_symbol->as_C_string(), klass->name()->as_C_string());
550 for (AllFieldStream fs(k()); !fs.done(); fs.next()) { 545 for (AllFieldStream fs(k()); !fs.done(); fs.next()) {
551 if (!fs.access_flags().is_static()) { 546 if (!fs.access_flags().is_static()) {
552 Handle type = GraalCompiler::get_JavaTypeFromSignature(fs.signature(), k, Thread::current()); 547 Handle type = GraalCompiler::get_JavaTypeFromSignature(fs.signature(), k, Thread::current());
553 int flags = fs.access_flags().as_int(); 548 int flags = fs.access_flags().as_int();
554 bool internal = fs.access_flags().is_internal(); 549 bool internal = fs.access_flags().is_internal();
555 Handle name = VmIds::toString<Handle>(fs.name(), Thread::current()); 550 Handle name = java_lang_String::create_from_symbol(fs.name(), Thread::current());
556 Handle field = VMToCompiler::createJavaField(JNIHandles::resolve(klass), name, type, fs.offset(), flags, internal, Thread::current()); 551 Handle field = VMToCompiler::createJavaField(JNIHandles::resolve(klass), name, type, fs.offset(), flags, internal, Thread::current());
557 fields.append(field()); 552 fields.append(field());
558 } 553 }
559 } 554 }
560 objArrayHandle field_array = oopFactory::new_objArray(SystemDictionary::HotSpotResolvedJavaField_klass(), fields.length(), CHECK_NULL); 555 objArrayHandle field_array = oopFactory::new_objArray(SystemDictionary::HotSpotResolvedJavaField_klass(), fields.length(), CHECK_NULL);
597 C2V_ENTRY(void, initializeConfiguration, (JNIEnv *env, jobject, jobject config)) 592 C2V_ENTRY(void, initializeConfiguration, (JNIEnv *env, jobject, jobject config))
598 593
599 #define set_boolean(name, value) do { env->SetBooleanField(config, getFieldID(env, config, name, "Z"), value); } while (0) 594 #define set_boolean(name, value) do { env->SetBooleanField(config, getFieldID(env, config, name, "Z"), value); } while (0)
600 #define set_int(name, value) do { env->SetIntField(config, getFieldID(env, config, name, "I"), value); } while (0) 595 #define set_int(name, value) do { env->SetIntField(config, getFieldID(env, config, name, "I"), value); } while (0)
601 #define set_long(name, value) do { env->SetLongField(config, getFieldID(env, config, name, "J"), value); } while (0) 596 #define set_long(name, value) do { env->SetLongField(config, getFieldID(env, config, name, "J"), value); } while (0)
597 #define set_stub(name, value) do { set_long(name, (jlong) value); } while (0)
602 #define set_object(name, value) do { env->SetObjectField(config, getFieldID(env, config, name, "Ljava/lang/Object;"), value); } while (0) 598 #define set_object(name, value) do { env->SetObjectField(config, getFieldID(env, config, name, "Ljava/lang/Object;"), value); } while (0)
603 #define set_int_array(name, value) do { env->SetObjectField(config, getFieldID(env, config, name, "[I"), value); } while (0) 599 #define set_int_array(name, value) do { env->SetObjectField(config, getFieldID(env, config, name, "[I"), value); } while (0)
604 600
605 guarantee(HeapWordSize == sizeof(char*), "Graal assumption that HeadWordSize == machine word size is wrong"); 601 guarantee(HeapWordSize == sizeof(char*), "Graal assumption that HeadWordSize == machine word size is wrong");
606 #ifdef _WIN64 602 #ifdef _WIN64
615 set_boolean("usePopCountInstruction", UsePopCountInstruction); 611 set_boolean("usePopCountInstruction", UsePopCountInstruction);
616 set_boolean("useAESIntrinsics", UseAESIntrinsics); 612 set_boolean("useAESIntrinsics", UseAESIntrinsics);
617 set_boolean("useTLAB", UseTLAB); 613 set_boolean("useTLAB", UseTLAB);
618 set_boolean("useG1GC", UseG1GC); 614 set_boolean("useG1GC", UseG1GC);
619 set_int("codeEntryAlignment", CodeEntryAlignment); 615 set_int("codeEntryAlignment", CodeEntryAlignment);
620 set_int("vmPageSize", os::vm_page_size());
621 set_int("stackShadowPages", StackShadowPages); 616 set_int("stackShadowPages", StackShadowPages);
622 set_int("hubOffset", oopDesc::klass_offset_in_bytes()); 617 set_int("hubOffset", oopDesc::klass_offset_in_bytes());
623 set_int("markOffset", oopDesc::mark_offset_in_bytes()); 618 set_int("markOffset", oopDesc::mark_offset_in_bytes());
624 set_int("prototypeMarkWordOffset", in_bytes(Klass::prototype_header_offset())); 619 set_int("prototypeMarkWordOffset", in_bytes(Klass::prototype_header_offset()));
625 set_int("superCheckOffsetOffset", in_bytes(Klass::super_check_offset_offset())); 620 set_int("superCheckOffsetOffset", in_bytes(Klass::super_check_offset_offset()));
667 662
668 set_int("arrayKlassLayoutHelperIdentifier", 0x80000000); 663 set_int("arrayKlassLayoutHelperIdentifier", 0x80000000);
669 assert((Klass::_lh_array_tag_obj_value & Klass::_lh_array_tag_type_value & 0x80000000) != 0, "obj_array and type_array must have first bit set"); 664 assert((Klass::_lh_array_tag_obj_value & Klass::_lh_array_tag_type_value & 0x80000000) != 0, "obj_array and type_array must have first bit set");
670 set_int("arrayKlassComponentMirrorOffset", in_bytes(ArrayKlass::component_mirror_offset())); 665 set_int("arrayKlassComponentMirrorOffset", in_bytes(ArrayKlass::component_mirror_offset()));
671 666
667
668 set_int("pendingDeoptimizationOffset", in_bytes(ThreadShadow::pending_deoptimization_offset()));
669
672 set_int("metaspaceArrayLengthOffset", Array<Klass*>::length_offset_in_bytes()); 670 set_int("metaspaceArrayLengthOffset", Array<Klass*>::length_offset_in_bytes());
673 set_int("metaspaceArrayBaseOffset", Array<Klass*>::base_offset_in_bytes()); 671 set_int("metaspaceArrayBaseOffset", Array<Klass*>::base_offset_in_bytes());
674 set_int("methodDataOopDataOffset", in_bytes(MethodData::data_offset())); 672 set_int("methodDataOopDataOffset", in_bytes(MethodData::data_offset()));
675 set_int("methodDataOopTrapHistoryOffset", in_bytes(MethodData::trap_history_offset())); 673 set_int("methodDataOopTrapHistoryOffset", in_bytes(MethodData::trap_history_offset()));
676 set_int("dataLayoutHeaderSize", DataLayout::header_size_in_bytes()); 674 set_int("dataLayoutHeaderSize", DataLayout::header_size_in_bytes());
707 set_int("layoutHelperElementTypePrimitiveInPlace", (Klass::_lh_array_tag_type_value & ~Klass::_lh_array_tag_obj_value) << Klass::_lh_array_tag_shift); 705 set_int("layoutHelperElementTypePrimitiveInPlace", (Klass::_lh_array_tag_type_value & ~Klass::_lh_array_tag_obj_value) << Klass::_lh_array_tag_shift);
708 set_int("layoutHelperHeaderSizeShift", Klass::_lh_header_size_shift); 706 set_int("layoutHelperHeaderSizeShift", Klass::_lh_header_size_shift);
709 set_int("layoutHelperHeaderSizeMask", Klass::_lh_header_size_mask); 707 set_int("layoutHelperHeaderSizeMask", Klass::_lh_header_size_mask);
710 set_int("layoutHelperOffset", in_bytes(Klass::layout_helper_offset())); 708 set_int("layoutHelperOffset", in_bytes(Klass::layout_helper_offset()));
711 709
712 set_long("debugStub", VmIds::addStub((address)warning)); 710
713 set_long("instanceofStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_slow_subtype_check_id))); 711 set_stub("wbPreCallStub", GraalRuntime::entry_for(GraalRuntime::wb_pre_call_id));
714 set_long("newInstanceStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_new_instance_id))); 712 set_stub("wbPostCallStub", GraalRuntime::entry_for(GraalRuntime::wb_post_call_id));
715 set_long("newArrayStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_new_array_id))); 713
716 set_long("newMultiArrayStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_new_multi_array_id))); 714 set_stub("newInstanceStub", GraalRuntime::entry_for(GraalRuntime::new_instance_id));
717 set_long("identityHashCodeStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_identity_hash_code_id))); 715 set_stub("newArrayStub", GraalRuntime::entry_for(GraalRuntime::new_array_id));
718 set_long("threadIsInterruptedStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_thread_is_interrupted_id))); 716 set_stub("newMultiArrayStub", GraalRuntime::entry_for(GraalRuntime::new_multi_array_id));
719 set_long("inlineCacheMissStub", VmIds::addStub(SharedRuntime::get_ic_miss_stub())); 717 set_stub("identityHashCodeStub", GraalRuntime::entry_for(GraalRuntime::identity_hash_code_id));
720 set_long("handleExceptionStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_handle_exception_nofpu_id))); 718 set_stub("threadIsInterruptedStub", GraalRuntime::entry_for(GraalRuntime::thread_is_interrupted_id));
721 set_long("handleDeoptStub", VmIds::addStub(SharedRuntime::deopt_blob()->unpack())); 719 set_stub("inlineCacheMissStub", SharedRuntime::get_ic_miss_stub());
722 set_long("monitorEnterStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_monitorenter_id))); 720 set_stub("handleExceptionStub", GraalRuntime::entry_for(GraalRuntime::handle_exception_nofpu_id));
723 set_long("monitorExitStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_monitorexit_id))); 721 set_stub("handleDeoptStub", SharedRuntime::deopt_blob()->unpack());
724 set_long("wbPreCallStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_wb_pre_call_id))); 722 set_stub("monitorEnterStub", GraalRuntime::entry_for(GraalRuntime::monitorenter_id));
725 set_long("wbPostCallStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_wb_post_call_id))); 723 set_stub("monitorExitStub", GraalRuntime::entry_for(GraalRuntime::monitorexit_id));
726 724 set_stub("verifyOopStub", GraalRuntime::entry_for(GraalRuntime::verify_oop_id));
727 set_long("verifyOopStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_verify_oop_id))); 725 set_stub("vmErrorStub", GraalRuntime::entry_for(GraalRuntime::vm_error_id));
728 set_long("vmErrorStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_vm_error_id))); 726 set_stub("deoptimizeStub", SharedRuntime::deopt_blob()->uncommon_trap());
729 set_long("deoptimizeStub", VmIds::addStub(SharedRuntime::deopt_blob()->uncommon_trap())); 727 set_stub("unwindExceptionStub", GraalRuntime::entry_for(GraalRuntime::unwind_exception_call_id));
730 set_long("unwindExceptionStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_unwind_exception_call_id))); 728 set_stub("osrMigrationEndStub", GraalRuntime::entry_for(GraalRuntime::OSR_migration_end_id));
731 set_long("osrMigrationEndStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_OSR_migration_end_id))); 729 set_stub("registerFinalizerStub", GraalRuntime::entry_for(GraalRuntime::register_finalizer_id));
732 set_long("registerFinalizerStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_register_finalizer_id))); 730 set_stub("createNullPointerExceptionStub", GraalRuntime::entry_for(GraalRuntime::create_null_pointer_exception_id));
733 set_long("setDeoptInfoStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_set_deopt_info_id))); 731 set_stub("createOutOfBoundsExceptionStub", GraalRuntime::entry_for(GraalRuntime::create_out_of_bounds_exception_id));
734 set_long("createNullPointerExceptionStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_create_null_pointer_exception_id))); 732 set_stub("javaTimeMillisStub", CAST_FROM_FN_PTR(address, os::javaTimeMillis));
735 set_long("createOutOfBoundsExceptionStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_create_out_of_bounds_exception_id))); 733 set_stub("javaTimeNanosStub", CAST_FROM_FN_PTR(address, os::javaTimeNanos));
736 set_long("javaTimeMillisStub", VmIds::addStub(CAST_FROM_FN_PTR(address, os::javaTimeMillis))); 734 set_stub("arithmeticFremStub", GraalRuntime::entry_for(GraalRuntime::arithmetic_frem_id));
737 set_long("javaTimeNanosStub", VmIds::addStub(CAST_FROM_FN_PTR(address, os::javaTimeNanos))); 735 set_stub("arithmeticDremStub", GraalRuntime::entry_for(GraalRuntime::arithmetic_drem_id));
738 set_long("arithmeticFremStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_arithmetic_frem_id))); 736 set_stub("arithmeticSinStub", CAST_FROM_FN_PTR(address, SharedRuntime::dsin));
739 set_long("arithmeticDremStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_arithmetic_drem_id))); 737 set_stub("arithmeticCosStub", CAST_FROM_FN_PTR(address, SharedRuntime::dcos));
740 set_long("arithmeticSinStub", VmIds::addStub(CAST_FROM_FN_PTR(address, SharedRuntime::dsin))); 738 set_stub("arithmeticTanStub", CAST_FROM_FN_PTR(address, SharedRuntime::dtan));
741 set_long("arithmeticCosStub", VmIds::addStub(CAST_FROM_FN_PTR(address, SharedRuntime::dcos))); 739 set_stub("logPrimitiveStub", GraalRuntime::entry_for(GraalRuntime::log_primitive_id));
742 set_long("arithmeticTanStub", VmIds::addStub(CAST_FROM_FN_PTR(address, SharedRuntime::dtan))); 740 set_stub("logObjectStub", GraalRuntime::entry_for(GraalRuntime::log_object_id));
743 set_long("logPrimitiveStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_log_primitive_id))); 741 set_stub("logPrintfStub", GraalRuntime::entry_for(GraalRuntime::log_printf_id));
744 set_long("logObjectStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_log_object_id))); 742 set_stub("aescryptEncryptBlockStub", StubRoutines::aescrypt_encryptBlock());
745 set_long("logPrintfStub", VmIds::addStub(GraalRuntime::entry_for(GraalRuntime::graal_log_printf_id))); 743 set_stub("aescryptDecryptBlockStub", StubRoutines::aescrypt_decryptBlock());
746 set_long("aescryptEncryptBlockStub", VmIds::addStub(StubRoutines::aescrypt_encryptBlock())); 744 set_stub("cipherBlockChainingEncryptAESCryptStub", StubRoutines::cipherBlockChaining_encryptAESCrypt());
747 set_long("aescryptDecryptBlockStub", VmIds::addStub(StubRoutines::aescrypt_decryptBlock())); 745 set_stub("cipherBlockChainingDecryptAESCryptStub", StubRoutines::cipherBlockChaining_decryptAESCrypt());
748 set_long("cipherBlockChainingEncryptAESCryptStub", VmIds::addStub(StubRoutines::cipherBlockChaining_encryptAESCrypt()));
749 set_long("cipherBlockChainingDecryptAESCryptStub", VmIds::addStub(StubRoutines::cipherBlockChaining_decryptAESCrypt()));
750 746
751 set_int("deoptReasonNone", Deoptimization::Reason_none); 747 set_int("deoptReasonNone", Deoptimization::Reason_none);
752 set_int("deoptReasonNullCheck", Deoptimization::Reason_null_check); 748 set_int("deoptReasonNullCheck", Deoptimization::Reason_null_check);
753 set_int("deoptReasonRangeCheck", Deoptimization::Reason_range_check); 749 set_int("deoptReasonRangeCheck", Deoptimization::Reason_range_check);
754 set_int("deoptReasonClassCheck", Deoptimization::Reason_class_check); 750 set_int("deoptReasonClassCheck", Deoptimization::Reason_class_check);
805 #undef set_object 801 #undef set_object
806 #undef set_int_array 802 #undef set_int_array
807 803
808 C2V_END 804 C2V_END
809 805
810 C2V_VMENTRY(jint, installCode0, (JNIEnv *jniEnv, jobject, jobject compResult, jobject installed_code, jobject info)) 806 C2V_VMENTRY(jint, installCode0, (JNIEnv *jniEnv, jobject, jobject compResult, jobject installed_code, jobject triggered_deoptimizations))
811 ResourceMark rm; 807 ResourceMark rm;
812 HandleMark hm; 808 HandleMark hm;
813 Handle compResultHandle = JNIHandles::resolve(compResult); 809 Handle compResultHandle = JNIHandles::resolve(compResult);
814 nmethod* nm = NULL; 810 nmethod* nm = NULL;
815 methodHandle method = getMethodFromHotSpotMethod(HotSpotCompilationResult::method(compResult)); 811 methodHandle method = getMethodFromHotSpotMethod(HotSpotCompilationResult::method(compResult));
816 Handle installed_code_handle = JNIHandles::resolve(installed_code); 812 Handle installed_code_handle = JNIHandles::resolve(installed_code);
813 Handle triggered_deoptimizations_handle = JNIHandles::resolve(triggered_deoptimizations);
817 GraalEnv::CodeInstallResult result; 814 GraalEnv::CodeInstallResult result;
818 CodeInstaller installer(compResultHandle, method, result, nm, installed_code_handle); 815 CodeInstaller installer(compResultHandle, method, result, nm, installed_code_handle, triggered_deoptimizations_handle);
819 816
820 if (result != GraalEnv::ok) { 817 if (result != GraalEnv::ok) {
821 assert(nm == NULL, "should be"); 818 assert(nm == NULL, "should be");
822 } else { 819 } else {
823 if (info != NULL) {
824 arrayOop codeCopy = oopFactory::new_byteArray(nm->code_size(), CHECK_0);
825 memcpy(codeCopy->base(T_BYTE), nm->code_begin(), nm->code_size());
826 HotSpotCodeInfo::set_code(info, codeCopy);
827 HotSpotCodeInfo::set_start(info, (jlong) nm->code_begin());
828 }
829
830 if (!installed_code_handle.is_null()) { 820 if (!installed_code_handle.is_null()) {
831 assert(installed_code_handle->is_a(HotSpotInstalledCode::klass()), "wrong type"); 821 assert(installed_code_handle->is_a(HotSpotInstalledCode::klass()), "wrong type");
832 HotSpotInstalledCode::set_nmethod(installed_code_handle, (jlong) nm); 822 HotSpotInstalledCode::set_nmethod(installed_code_handle, (jlong) nm);
833 HotSpotInstalledCode::set_method(installed_code_handle, HotSpotCompilationResult::method(compResult)); 823 HotSpotInstalledCode::set_method(installed_code_handle, HotSpotCompilationResult::method(compResult));
824 HotSpotInstalledCode::set_start(installed_code_handle, (jlong) nm->code_begin());
834 assert(nm == NULL || !installed_code_handle->is_scavengable() || nm->on_scavenge_root_list(), "nm should be scavengable if installed_code is scavengable"); 825 assert(nm == NULL || !installed_code_handle->is_scavengable() || nm->on_scavenge_root_list(), "nm should be scavengable if installed_code is scavengable");
835 } 826 }
836 } 827 }
837 return result; 828 return result;
838 C2V_END 829 C2V_END
839 830
840 C2V_VMENTRY(jobject, disassembleNative, (JNIEnv *jniEnv, jobject, jbyteArray code, jlong start_address)) 831 C2V_VMENTRY(jobject, getCode, (JNIEnv *jniEnv, jobject, jlong metaspace_nmethod))
841 ResourceMark rm; 832 ResourceMark rm;
842 HandleMark hm; 833 HandleMark hm;
843 834
844 stringStream(st); 835 nmethod* nm = (nmethod*) (address) metaspace_nmethod;
845 arrayOop code_oop = (arrayOop) JNIHandles::resolve(code); 836 if (nm == NULL || !nm->is_alive()) {
846 int len = code_oop->length(); 837 return NULL;
847 address begin = (address) code_oop->base(T_BYTE); 838 }
848 address end = begin + len; 839 int length = nm->code_size();
849 Disassembler::decode(begin, end, &st); 840 arrayOop codeCopy = oopFactory::new_byteArray(length, CHECK_0);
850 841 memcpy(codeCopy->base(T_BYTE), nm->code_begin(), length);
851 Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL); 842 return JNIHandles::make_local(codeCopy);
852 return JNIHandles::make_local(result());
853 C2V_END 843 C2V_END
854 844
855 C2V_VMENTRY(jobject, disassembleNMethod, (JNIEnv *jniEnv, jobject, jlong metaspace_nmethod)) 845 C2V_VMENTRY(jobject, disassembleNMethod, (JNIEnv *jniEnv, jobject, jlong metaspace_nmethod))
856 ResourceMark rm; 846 ResourceMark rm;
857 HandleMark hm; 847 HandleMark hm;
891 nmethod* nm = (nmethod*) (address) metaspace_nmethod; 881 nmethod* nm = (nmethod*) (address) metaspace_nmethod;
892 if (nm == NULL || !nm->is_alive()) { 882 if (nm == NULL || !nm->is_alive()) {
893 THROW_0(vmSymbols::MethodInvalidatedException()); 883 THROW_0(vmSymbols::MethodInvalidatedException());
894 } 884 }
895 885
896 JavaCalls::call(&result, mh, nm, &jca, CHECK_NULL); 886 jca.set_alternative_target(nm);
887 JavaCalls::call(&result, mh, &jca, CHECK_NULL);
897 888
898 if (jap.get_ret_type() == T_VOID) { 889 if (jap.get_ret_type() == T_VOID) {
899 return NULL; 890 return NULL;
900 } else if (jap.get_ret_type() == T_OBJECT || jap.get_ret_type() == T_ARRAY) { 891 } else if (jap.get_ret_type() == T_OBJECT || jap.get_ret_type() == T_ARRAY) {
901 return JNIHandles::make_local((oop) result.get_jobject()); 892 return JNIHandles::make_local((oop) result.get_jobject());
920 nmethod* nm = (nmethod*) (address) metaspace_nmethod; 911 nmethod* nm = (nmethod*) (address) metaspace_nmethod;
921 if (nm == NULL || !nm->is_alive()) { 912 if (nm == NULL || !nm->is_alive()) {
922 THROW_0(vmSymbols::MethodInvalidatedException()); 913 THROW_0(vmSymbols::MethodInvalidatedException());
923 } 914 }
924 915
925 JavaCalls::call(&result, method, nm, &args, CHECK_NULL); 916 args.set_alternative_target(nm);
917 JavaCalls::call(&result, method, &args, CHECK_NULL);
926 918
927 return JNIHandles::make_local((oop) result.get_jobject()); 919 return JNIHandles::make_local((oop) result.get_jobject());
928 C2V_END 920 C2V_END
929 921
930 C2V_VMENTRY(jint, getVtableEntryOffset, (JNIEnv *, jobject, jlong metaspace_method)) 922 C2V_VMENTRY(jint, getVtableEntryOffset, (JNIEnv *, jobject, jlong metaspace_method))
950 942
951 oop array = GraalCompiler::instance()->dump_deopted_leaf_graphs(CHECK_NULL); 943 oop array = GraalCompiler::instance()->dump_deopted_leaf_graphs(CHECK_NULL);
952 return JNIHandles::make_local(array); 944 return JNIHandles::make_local(array);
953 C2V_END 945 C2V_END
954 946
955 C2V_VMENTRY(jobject, decodePC, (JNIEnv *, jobject, jlong pc))
956 stringStream(st);
957 CodeBlob* blob = CodeCache::find_blob_unsafe((void*) pc);
958 if (blob == NULL) {
959 st.print("[unidentified pc]");
960 } else {
961 st.print(blob->name());
962
963 nmethod* nm = blob->as_nmethod_or_null();
964 if (nm != NULL && nm->method() != NULL) {
965 st.print(" %s.", nm->method()->method_holder()->external_name());
966 nm->method()->name()->print_symbol_on(&st);
967 st.print(" @ %d", pc - (jlong) nm->entry_point());
968 }
969 }
970 Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL);
971 return JNIHandles::make_local(result());
972 C2V_END
973
974 C2V_ENTRY(jlongArray, getLineNumberTable, (JNIEnv *env, jobject, jobject hotspot_method)) 947 C2V_ENTRY(jlongArray, getLineNumberTable, (JNIEnv *env, jobject, jobject hotspot_method))
975 // XXX: Attention: it seEms that the line number table of a method just contains lines that are important, means that
976 // empty lines are left out or lines that can't have a breakpoint on it; eg int a; or try {
977 Method* method = getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method)); 948 Method* method = getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method));
978 if(!method->has_linenumber_table()) { 949 if (!method->has_linenumber_table()) {
979 return NULL; 950 return NULL;
980 } 951 }
981 u2 num_entries = 0; 952 u2 num_entries = 0;
982 CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table()); 953 CompressedLineNumberReadStream streamForSize(method->compressed_linenumber_table());
983 while (streamForSize.read_pair()) { 954 while (streamForSize.read_pair()) {
1002 973
1003 C2V_VMENTRY(jobject, getLocalVariableTable, (JNIEnv *, jobject, jobject hotspot_method)) 974 C2V_VMENTRY(jobject, getLocalVariableTable, (JNIEnv *, jobject, jobject hotspot_method))
1004 ResourceMark rm; 975 ResourceMark rm;
1005 976
1006 Method* method = getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method)); 977 Method* method = getMethodFromHotSpotMethod(JNIHandles::resolve(hotspot_method));
1007 if(!method->has_localvariable_table()) { 978 if (!method->has_localvariable_table()) {
1008 return NULL; 979 return NULL;
1009 } 980 }
1010 int localvariable_table_length = method->localvariable_table_length(); 981 int localvariable_table_length = method->localvariable_table_length();
1011 982
1012 objArrayHandle local_array = oopFactory::new_objArray(SystemDictionary::LocalImpl_klass(), localvariable_table_length, CHECK_NULL); 983 objArrayHandle local_array = oopFactory::new_objArray(SystemDictionary::LocalImpl_klass(), localvariable_table_length, CHECK_NULL);
1072 #define HS_RESOLVED_FIELD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaField;" 1043 #define HS_RESOLVED_FIELD "Lcom/oracle/graal/hotspot/meta/HotSpotResolvedJavaField;"
1073 #define HS_COMP_RESULT "Lcom/oracle/graal/hotspot/HotSpotCompilationResult;" 1044 #define HS_COMP_RESULT "Lcom/oracle/graal/hotspot/HotSpotCompilationResult;"
1074 #define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;" 1045 #define HS_CONFIG "Lcom/oracle/graal/hotspot/HotSpotVMConfig;"
1075 #define HS_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotMethod;" 1046 #define HS_METHOD "Lcom/oracle/graal/hotspot/meta/HotSpotMethod;"
1076 #define HS_INSTALLED_CODE "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;" 1047 #define HS_INSTALLED_CODE "Lcom/oracle/graal/hotspot/meta/HotSpotInstalledCode;"
1077 #define HS_CODE_INFO "Lcom/oracle/graal/hotspot/meta/HotSpotCodeInfo;"
1078 #define METHOD_DATA "Lcom/oracle/graal/hotspot/meta/HotSpotMethodData;" 1048 #define METHOD_DATA "Lcom/oracle/graal/hotspot/meta/HotSpotMethodData;"
1079 #define METASPACE_METHOD "J" 1049 #define METASPACE_METHOD "J"
1080 #define METASPACE_METHOD_DATA "J" 1050 #define METASPACE_METHOD_DATA "J"
1081 #define NMETHOD "J" 1051 #define NMETHOD "J"
1082 1052
1108 {CC"getResolvedType", CC"("CLASS")"RESOLVED_TYPE, FN_PTR(getResolvedType)}, 1078 {CC"getResolvedType", CC"("CLASS")"RESOLVED_TYPE, FN_PTR(getResolvedType)},
1109 {CC"getMetaspaceMethod", CC"("REFLECT_METHOD"["HS_RESOLVED_TYPE")"METASPACE_METHOD, FN_PTR(getMetaspaceMethod)}, 1079 {CC"getMetaspaceMethod", CC"("REFLECT_METHOD"["HS_RESOLVED_TYPE")"METASPACE_METHOD, FN_PTR(getMetaspaceMethod)},
1110 {CC"getMetaspaceConstructor", CC"("REFLECT_CONSTRUCTOR"["HS_RESOLVED_TYPE")"METASPACE_METHOD, FN_PTR(getMetaspaceConstructor)}, 1080 {CC"getMetaspaceConstructor", CC"("REFLECT_CONSTRUCTOR"["HS_RESOLVED_TYPE")"METASPACE_METHOD, FN_PTR(getMetaspaceConstructor)},
1111 {CC"getJavaField", CC"("REFLECT_FIELD")"HS_RESOLVED_FIELD, FN_PTR(getJavaField)}, 1081 {CC"getJavaField", CC"("REFLECT_FIELD")"HS_RESOLVED_FIELD, FN_PTR(getJavaField)},
1112 {CC"initializeConfiguration", CC"("HS_CONFIG")V", FN_PTR(initializeConfiguration)}, 1082 {CC"initializeConfiguration", CC"("HS_CONFIG")V", FN_PTR(initializeConfiguration)},
1113 {CC"installCode0", CC"("HS_COMP_RESULT HS_INSTALLED_CODE HS_CODE_INFO")I", FN_PTR(installCode0)}, 1083 {CC"installCode0", CC"("HS_COMP_RESULT HS_INSTALLED_CODE"[Z)I", FN_PTR(installCode0)},
1114 {CC"disassembleNative", CC"([BJ)"STRING, FN_PTR(disassembleNative)}, 1084 {CC"getCode", CC"(J)[B", FN_PTR(getCode)},
1115 {CC"disassembleNMethod", CC"(J)"STRING, FN_PTR(disassembleNMethod)}, 1085 {CC"disassembleNMethod", CC"(J)"STRING, FN_PTR(disassembleNMethod)},
1116 {CC"executeCompiledMethod", CC"("METASPACE_METHOD NMETHOD OBJECT OBJECT OBJECT")"OBJECT, FN_PTR(executeCompiledMethod)}, 1086 {CC"executeCompiledMethod", CC"("METASPACE_METHOD NMETHOD OBJECT OBJECT OBJECT")"OBJECT, FN_PTR(executeCompiledMethod)},
1117 {CC"executeCompiledMethodVarargs", CC"("METASPACE_METHOD NMETHOD "["OBJECT")"OBJECT, FN_PTR(executeCompiledMethodVarargs)}, 1087 {CC"executeCompiledMethodVarargs", CC"("METASPACE_METHOD NMETHOD "["OBJECT")"OBJECT, FN_PTR(executeCompiledMethodVarargs)},
1118 {CC"getDeoptedLeafGraphIds", CC"()[J", FN_PTR(getDeoptedLeafGraphIds)}, 1088 {CC"getDeoptedLeafGraphIds", CC"()[J", FN_PTR(getDeoptedLeafGraphIds)},
1119 {CC"decodePC", CC"(J)"STRING, FN_PTR(decodePC)},
1120 {CC"getLineNumberTable", CC"("HS_RESOLVED_METHOD")[J", FN_PTR(getLineNumberTable)}, 1089 {CC"getLineNumberTable", CC"("HS_RESOLVED_METHOD")[J", FN_PTR(getLineNumberTable)},
1121 {CC"getLocalVariableTable", CC"("HS_RESOLVED_METHOD")["LOCAL, FN_PTR(getLocalVariableTable)}, 1090 {CC"getLocalVariableTable", CC"("HS_RESOLVED_METHOD")["LOCAL, FN_PTR(getLocalVariableTable)},
1122 {CC"getFileName", CC"("HS_RESOLVED_JAVA_TYPE")"STRING, FN_PTR(getFileName)}, 1091 {CC"getFileName", CC"("HS_RESOLVED_JAVA_TYPE")"STRING, FN_PTR(getFileName)},
1123 }; 1092 };
1124 1093