comparison src/share/vm/runtime/simpleThresholdPolicy.cpp @ 3791:2c359f27615c

7057120: Tiered: Allow C1 to inline methods with loops Summary: Recompile the enclosing methods without inlining of the method that has OSRed to level 4 or recompile the enclosing method at level 4. Reviewed-by: kvn, never
author iveresov
date Fri, 01 Jul 2011 10:37:37 -0700
parents 6f6e91603a45
children 43f9d800f276
comparison
equal deleted inserted replaced
3790:6f6e91603a45 3791:2c359f27615c
48 tty->print("loop"); 48 tty->print("loop");
49 break; 49 break;
50 case COMPILE: 50 case COMPILE:
51 tty->print("compile"); 51 tty->print("compile");
52 break; 52 break;
53 case KILL: 53 case REMOVE_FROM_QUEUE:
54 tty->print("kill"); 54 tty->print("remove-from-queue");
55 break; 55 break;
56 case UPDATE: 56 case UPDATE_IN_QUEUE:
57 tty->print("update"); 57 tty->print("update-in-queue");
58 break; 58 break;
59 case REPROFILE: 59 case REPROFILE:
60 tty->print("reprofile"); 60 tty->print("reprofile");
61 break;
62 case MAKE_NOT_ENTRANT:
63 tty->print("make-not-entrant");
61 break; 64 break;
62 default: 65 default:
63 tty->print("unknown"); 66 tty->print("unknown");
64 } 67 }
65 68
66 tty->print(" level: %d ", level); 69 tty->print(" level: %d ", level);
67 70
68 ResourceMark rm; 71 ResourceMark rm;
69 char *method_name = mh->name_and_sig_as_C_string(); 72 char *method_name = mh->name_and_sig_as_C_string();
70 tty->print("[%s", method_name); 73 tty->print("[%s", method_name);
71 // We can have an inlinee, although currently we don't generate any notifications for the inlined methods.
72 if (inlinee_event) { 74 if (inlinee_event) {
73 char *inlinee_name = imh->name_and_sig_as_C_string(); 75 char *inlinee_name = imh->name_and_sig_as_C_string();
74 tty->print(" [%s]] ", inlinee_name); 76 tty->print(" [%s]] ", inlinee_name);
75 } 77 }
76 else tty->print("] "); 78 else tty->print("] ");
168 if (sd->is_top()) break; 170 if (sd->is_top()) break;
169 } 171 }
170 } 172 }
171 173
172 nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee, 174 nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee,
173 int branch_bci, int bci, CompLevel comp_level, TRAPS) { 175 int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS) {
174 if (comp_level == CompLevel_none && 176 if (comp_level == CompLevel_none &&
175 JvmtiExport::can_post_interpreter_events()) { 177 JvmtiExport::can_post_interpreter_events()) {
176 assert(THREAD->is_Java_thread(), "Should be java thread"); 178 assert(THREAD->is_Java_thread(), "Should be java thread");
177 if (((JavaThread*)THREAD)->is_interp_only_mode()) { 179 if (((JavaThread*)THREAD)->is_interp_only_mode()) {
178 return NULL; 180 return NULL;
188 if (PrintTieredEvents) { 190 if (PrintTieredEvents) {
189 print_event(bci == InvocationEntryBci ? CALL : LOOP, method, inlinee, bci, comp_level); 191 print_event(bci == InvocationEntryBci ? CALL : LOOP, method, inlinee, bci, comp_level);
190 } 192 }
191 193
192 if (bci == InvocationEntryBci) { 194 if (bci == InvocationEntryBci) {
193 method_invocation_event(method, inlinee, comp_level, THREAD); 195 method_invocation_event(method, inlinee, comp_level, nm, THREAD);
194 } else { 196 } else {
195 method_back_branch_event(method, inlinee, bci, comp_level, THREAD); 197 method_back_branch_event(method, inlinee, bci, comp_level, nm, THREAD);
196 int highest_level = method->highest_osr_comp_level(); 198 // method == inlinee if the event originated in the main method
199 int highest_level = inlinee->highest_osr_comp_level();
197 if (highest_level > comp_level) { 200 if (highest_level > comp_level) {
198 osr_nm = method->lookup_osr_nmethod_for(bci, highest_level, false); 201 osr_nm = inlinee->lookup_osr_nmethod_for(bci, highest_level, false);
199 } 202 }
200 } 203 }
201 return osr_nm; 204 return osr_nm;
202 } 205 }
203 206
358 } 361 }
359 362
360 363
361 // Handle the invocation event. 364 // Handle the invocation event.
362 void SimpleThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh, 365 void SimpleThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh,
363 CompLevel level, TRAPS) { 366 CompLevel level, nmethod* nm, TRAPS) {
364 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) { 367 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) {
365 CompLevel next_level = call_event(mh(), level); 368 CompLevel next_level = call_event(mh(), level);
366 if (next_level != level) { 369 if (next_level != level) {
367 compile(mh, InvocationEntryBci, next_level, THREAD); 370 compile(mh, InvocationEntryBci, next_level, THREAD);
368 } 371 }
370 } 373 }
371 374
372 // Handle the back branch event. Notice that we can compile the method 375 // Handle the back branch event. Notice that we can compile the method
373 // with a regular entry from here. 376 // with a regular entry from here.
374 void SimpleThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh, 377 void SimpleThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh,
375 int bci, CompLevel level, TRAPS) { 378 int bci, CompLevel level, nmethod* nm, TRAPS) {
376 // If the method is already compiling, quickly bail out. 379 // If the method is already compiling, quickly bail out.
377 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, bci)) { 380 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, bci)) {
378 // Use loop event as an opportinity to also check there's been 381 // Use loop event as an opportinity to also check there's been
379 // enough calls. 382 // enough calls.
380 CompLevel cur_level = comp_level(mh()); 383 CompLevel cur_level = comp_level(mh());