comparison src/share/vm/ci/ciEnv.cpp @ 3619:5e9645341ec3

support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
author Lukas Stadler <lukas.stadler@jku.at>
date Wed, 09 Nov 2011 11:27:38 +0100
parents 22d11b3bc561
children c7d4198a9bce 1976ebe361c2
comparison
equal deleted inserted replaced
3601:3822c5969a8b 3619:5e9645341ec3
926 } 926 }
927 } 927 }
928 928
929 // ------------------------------------------------------------------ 929 // ------------------------------------------------------------------
930 // ciEnv::register_method 930 // ciEnv::register_method
931 void ciEnv::register_method(ciMethod* target, 931 nmethod* ciEnv::register_method(ciMethod* target,
932 int entry_bci, 932 int entry_bci,
933 CodeOffsets* offsets, 933 CodeOffsets* offsets,
934 int orig_pc_offset, 934 int orig_pc_offset,
935 CodeBuffer* code_buffer, 935 CodeBuffer* code_buffer,
936 int frame_words, 936 int frame_words,
937 OopMapSet* oop_map_set, 937 OopMapSet* oop_map_set,
938 ExceptionHandlerTable* handler_table, 938 ExceptionHandlerTable* handler_table,
939 ImplicitExceptionTable* inc_table, 939 ImplicitExceptionTable* inc_table,
940 AbstractCompiler* compiler, 940 AbstractCompiler* compiler,
941 int comp_level, 941 int comp_level,
942 bool has_debug_info, 942 bool has_debug_info,
943 bool has_unsafe_access) { 943 bool has_unsafe_access,
944 bool install_code) {
944 VM_ENTRY_MARK; 945 VM_ENTRY_MARK;
945 nmethod* nm = NULL; 946 nmethod* nm = NULL;
946 { 947 {
947 // To prevent compile queue updates. 948 // To prevent compile queue updates.
948 MutexLocker locker(MethodCompileQueue_lock, THREAD); 949 MutexLocker locker(MethodCompileQueue_lock, THREAD);
994 995
995 // All buffers in the CodeBuffer are allocated in the CodeCache. 996 // All buffers in the CodeBuffer are allocated in the CodeCache.
996 // If the code buffer is created on each compile attempt 997 // If the code buffer is created on each compile attempt
997 // as in C2, then it must be freed. 998 // as in C2, then it must be freed.
998 code_buffer->free_blob(); 999 code_buffer->free_blob();
999 return; 1000 return NULL;
1000 } 1001 }
1001 1002
1002 assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry"); 1003 assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry");
1003 assert(offsets->value(CodeOffsets::Exceptions) != -1, "must have exception entry"); 1004 assert(offsets->value(CodeOffsets::Exceptions) != -1, "must have exception entry");
1004 1005
1039 1040
1040 // Record successful registration. 1041 // Record successful registration.
1041 // (Put nm into the task handle *before* publishing to the Java heap.) 1042 // (Put nm into the task handle *before* publishing to the Java heap.)
1042 if (task() != NULL) task()->set_code(nm); 1043 if (task() != NULL) task()->set_code(nm);
1043 1044
1044 if (entry_bci == InvocationEntryBci) { 1045 if (install_code) {
1045 if (TieredCompilation) { 1046 if (entry_bci == InvocationEntryBci) {
1046 // If there is an old version we're done with it 1047 if (TieredCompilation) {
1047 nmethod* old = method->code(); 1048 // If there is an old version we're done with it
1048 if (TraceMethodReplacement && old != NULL) { 1049 nmethod* old = method->code();
1050 if (TraceMethodReplacement && old != NULL) {
1051 ResourceMark rm;
1052 char *method_name = method->name_and_sig_as_C_string();
1053 tty->print_cr("Replacing method %s", method_name);
1054 }
1055 if (old != NULL ) {
1056 old->make_not_entrant();
1057 }
1058 }
1059 if (TraceNMethodInstalls ) {
1049 ResourceMark rm; 1060 ResourceMark rm;
1050 char *method_name = method->name_and_sig_as_C_string(); 1061 char *method_name = method->name_and_sig_as_C_string();
1051 tty->print_cr("Replacing method %s", method_name); 1062 ttyLocker ttyl;
1063 tty->print_cr("Installing method (%d) %s ",
1064 comp_level,
1065 method_name);
1052 } 1066 }
1053 if (old != NULL ) { 1067 // Allow the code to be executed
1054 old->make_not_entrant(); 1068 method->set_code(method, nm);
1069 } else {
1070 if (TraceNMethodInstalls ) {
1071 ResourceMark rm;
1072 char *method_name = method->name_and_sig_as_C_string();
1073 ttyLocker ttyl;
1074 tty->print_cr("Installing osr method (%d) %s @ %d",
1075 comp_level,
1076 method_name,
1077 entry_bci);
1055 } 1078 }
1079 instanceKlass::cast(method->method_holder())->add_osr_nmethod(nm);
1080
1056 } 1081 }
1057 if (TraceNMethodInstalls ) {
1058 ResourceMark rm;
1059 char *method_name = method->name_and_sig_as_C_string();
1060 ttyLocker ttyl;
1061 tty->print_cr("Installing method (%d) %s ",
1062 comp_level,
1063 method_name);
1064 }
1065 // Allow the code to be executed
1066 method->set_code(method, nm);
1067 } else {
1068 if (TraceNMethodInstalls ) {
1069 ResourceMark rm;
1070 char *method_name = method->name_and_sig_as_C_string();
1071 ttyLocker ttyl;
1072 tty->print_cr("Installing osr method (%d) %s @ %d",
1073 comp_level,
1074 method_name,
1075 entry_bci);
1076 }
1077 instanceKlass::cast(method->method_holder())->add_osr_nmethod(nm);
1078
1079 } 1082 }
1080 } 1083 }
1081 } 1084 }
1082 // JVMTI -- compiled method notification (must be done outside lock) 1085 // JVMTI -- compiled method notification (must be done outside lock)
1083 if (nm != NULL) { 1086 if (nm != NULL) {
1084 nm->post_compiled_method_load_event(); 1087 nm->post_compiled_method_load_event();
1085 } 1088 }
1086 1089
1090 return nm;
1087 } 1091 }
1088 1092
1089 1093
1090 // ------------------------------------------------------------------ 1094 // ------------------------------------------------------------------
1091 // ciEnv::find_system_klass 1095 // ciEnv::find_system_klass