567 bool result = mh->force_inline(); |
567 bool result = mh->force_inline(); |
568 mh->set_force_inline(value == JNI_TRUE); |
568 mh->set_force_inline(value == JNI_TRUE); |
569 return result; |
569 return result; |
570 WB_END |
570 WB_END |
571 |
571 |
|
572 bool WhiteBox::compile_method(Method* method, int comp_level, int bci, Thread* THREAD) { |
|
573 // Screen for unavailable/bad comp level or null method |
|
574 AbstractCompiler* comp = CompileBroker::compiler(comp_level); |
|
575 if (method == NULL) { |
|
576 tty->print_cr("WB error: request to compile NULL method"); |
|
577 return false; |
|
578 } |
|
579 if (comp_level > MIN2((CompLevel) TieredStopAtLevel, CompLevel_highest_tier)) { |
|
580 tty->print_cr("WB error: invalid compilation level %d", comp_level); |
|
581 return false; |
|
582 } |
|
583 if (comp == NULL) { |
|
584 tty->print_cr("WB error: no compiler for requested compilation level %d", comp_level); |
|
585 return false; |
|
586 } |
|
587 |
|
588 methodHandle mh(THREAD, method); |
|
589 |
|
590 // Compile method and check result |
|
591 nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "Whitebox", THREAD); |
|
592 MutexLocker mu(Compile_lock); |
|
593 bool is_queued = mh->queued_for_compilation(); |
|
594 if (is_queued || nm != NULL) { |
|
595 return true; |
|
596 } |
|
597 tty->print("WB error: failed to compile at level %d method ", comp_level); |
|
598 mh->print_short_name(tty); |
|
599 tty->cr(); |
|
600 if (is_queued) { |
|
601 tty->print_cr("WB error: blocking compilation is still in queue!"); |
|
602 } |
|
603 return false; |
|
604 } |
|
605 |
572 WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci)) |
606 WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci)) |
573 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
607 jmethodID jmid = reflected_method_to_jmid(thread, env, method); |
574 CHECK_JNI_EXCEPTION_(env, JNI_FALSE); |
608 CHECK_JNI_EXCEPTION_(env, JNI_FALSE); |
575 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); |
609 return WhiteBox::compile_method(Method::checked_resolve_jmethod_id(jmid), comp_level, bci, THREAD); |
576 nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD); |
610 WB_END |
577 MutexLockerEx mu(Compile_lock); |
611 |
578 return (mh->queued_for_compilation() || nm != NULL); |
612 WB_ENTRY(jboolean, WB_EnqueueInitializerForCompilation(JNIEnv* env, jobject o, jclass klass, jint comp_level)) |
|
613 InstanceKlass* ik = InstanceKlass::cast(java_lang_Class::as_Klass(JNIHandles::resolve(klass))); |
|
614 Method* clinit = ik->class_initializer(); |
|
615 if (clinit == NULL) { |
|
616 return false; |
|
617 } |
|
618 return WhiteBox::compile_method(clinit, comp_level, InvocationEntryBci, THREAD); |
579 WB_END |
619 WB_END |
580 |
620 |
581 class VM_WhiteBoxOperation : public VM_Operation { |
621 class VM_WhiteBoxOperation : public VM_Operation { |
582 public: |
622 public: |
583 VM_WhiteBoxOperation() { } |
623 VM_WhiteBoxOperation() { } |
803 if (needFree) { |
843 if (needFree) { |
804 FREE_C_HEAP_ARRAY(char, ccstrResult, mtInternal); |
844 FREE_C_HEAP_ARRAY(char, ccstrResult, mtInternal); |
805 } |
845 } |
806 WB_END |
846 WB_END |
807 |
847 |
808 |
|
809 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString)) |
848 WB_ENTRY(jboolean, WB_IsInStringTable(JNIEnv* env, jobject o, jstring javaString)) |
810 ResourceMark rm(THREAD); |
849 ResourceMark rm(THREAD); |
811 int len; |
850 int len; |
812 jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false); |
851 jchar* name = java_lang_String::as_unicode_string(JNIHandles::resolve(javaString), len, CHECK_false); |
813 return (StringTable::lookup(name, len) != NULL); |
852 return (StringTable::lookup(name, len) != NULL); |
1038 WB_END |
1077 WB_END |
1039 |
1078 |
1040 WB_ENTRY(void, WB_ForceSafepoint(JNIEnv* env, jobject wb)) |
1079 WB_ENTRY(void, WB_ForceSafepoint(JNIEnv* env, jobject wb)) |
1041 VM_ForceSafepoint force_safepoint_op; |
1080 VM_ForceSafepoint force_safepoint_op; |
1042 VMThread::execute(&force_safepoint_op); |
1081 VMThread::execute(&force_safepoint_op); |
|
1082 WB_END |
|
1083 |
|
1084 WB_ENTRY(jlong, WB_GetHeapAlignment(JNIEnv* env, jobject o)) |
|
1085 size_t alignment = Universe::heap()->collector_policy()->heap_alignment(); |
|
1086 return (jlong)alignment; |
1043 WB_END |
1087 WB_END |
1044 |
1088 |
1045 //Some convenience methods to deal with objects from java |
1089 //Some convenience methods to deal with objects from java |
1046 int WhiteBox::offset_for_field(const char* field_name, oop object, |
1090 int WhiteBox::offset_for_field(const char* field_name, oop object, |
1047 Symbol* signature_symbol) { |
1091 Symbol* signature_symbol) { |
1154 {CC"getObjectSize", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectSize }, |
1198 {CC"getObjectSize", CC"(Ljava/lang/Object;)J", (void*)&WB_GetObjectSize }, |
1155 {CC"isObjectInOldGen", CC"(Ljava/lang/Object;)Z", (void*)&WB_isObjectInOldGen }, |
1199 {CC"isObjectInOldGen", CC"(Ljava/lang/Object;)Z", (void*)&WB_isObjectInOldGen }, |
1156 {CC"getHeapOopSize", CC"()I", (void*)&WB_GetHeapOopSize }, |
1200 {CC"getHeapOopSize", CC"()I", (void*)&WB_GetHeapOopSize }, |
1157 {CC"getVMPageSize", CC"()I", (void*)&WB_GetVMPageSize }, |
1201 {CC"getVMPageSize", CC"()I", (void*)&WB_GetVMPageSize }, |
1158 {CC"getVMLargePageSize", CC"()J", (void*)&WB_GetVMLargePageSize}, |
1202 {CC"getVMLargePageSize", CC"()J", (void*)&WB_GetVMLargePageSize}, |
|
1203 {CC"getHeapAlignment", CC"()J", (void*)&WB_GetHeapAlignment }, |
1159 {CC"isClassAlive0", CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive }, |
1204 {CC"isClassAlive0", CC"(Ljava/lang/String;)Z", (void*)&WB_IsClassAlive }, |
1160 {CC"classKnownToNotExist", |
1205 {CC"classKnownToNotExist", |
1161 CC"(Ljava/lang/ClassLoader;Ljava/lang/String;)Z",(void*)&WB_ClassKnownToNotExist}, |
1206 CC"(Ljava/lang/ClassLoader;Ljava/lang/String;)Z",(void*)&WB_ClassKnownToNotExist}, |
1162 {CC"getLookupCacheURLs", CC"(Ljava/lang/ClassLoader;)[Ljava/net/URL;", (void*)&WB_GetLookupCacheURLs}, |
1207 {CC"getLookupCacheURLs", CC"(Ljava/lang/ClassLoader;)[Ljava/net/URL;", (void*)&WB_GetLookupCacheURLs}, |
1163 {CC"getLookupCacheMatches", CC"(Ljava/lang/ClassLoader;Ljava/lang/String;)[I", |
1208 {CC"getLookupCacheMatches", CC"(Ljava/lang/ClassLoader;Ljava/lang/String;)[I", |
1219 CC"(Ljava/lang/reflect/Executable;)I", (void*)&WB_GetMethodEntryBci}, |
1264 CC"(Ljava/lang/reflect/Executable;)I", (void*)&WB_GetMethodEntryBci}, |
1220 {CC"getCompileQueueSize", |
1265 {CC"getCompileQueueSize", |
1221 CC"(I)I", (void*)&WB_GetCompileQueueSize}, |
1266 CC"(I)I", (void*)&WB_GetCompileQueueSize}, |
1222 {CC"testSetForceInlineMethod", |
1267 {CC"testSetForceInlineMethod", |
1223 CC"(Ljava/lang/reflect/Executable;Z)Z", (void*)&WB_TestSetForceInlineMethod}, |
1268 CC"(Ljava/lang/reflect/Executable;Z)Z", (void*)&WB_TestSetForceInlineMethod}, |
1224 {CC"enqueueMethodForCompilation", |
1269 {CC"enqueueMethodForCompilation0", |
1225 CC"(Ljava/lang/reflect/Executable;II)Z", (void*)&WB_EnqueueMethodForCompilation}, |
1270 CC"(Ljava/lang/reflect/Executable;II)Z", (void*)&WB_EnqueueMethodForCompilation}, |
|
1271 {CC"enqueueInitializerForCompilation0", |
|
1272 CC"(Ljava/lang/Class;I)Z", (void*)&WB_EnqueueInitializerForCompilation}, |
1226 {CC"clearMethodState", |
1273 {CC"clearMethodState", |
1227 CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState}, |
1274 CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState}, |
1228 {CC"markMethodProfiled", |
1275 {CC"markMethodProfiled", |
1229 CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_MarkMethodProfiled}, |
1276 CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_MarkMethodProfiled}, |
1230 {CC"setBooleanVMFlag", CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag}, |
1277 {CC"setBooleanVMFlag", CC"(Ljava/lang/String;Z)V",(void*)&WB_SetBooleanVMFlag}, |