comparison src/share/vm/runtime/simpleThresholdPolicy.cpp @ 4825:20334ed5ed3c

7131259: compile_method and CompilationPolicy::event shouldn't be declared TRAPS Summary: Make sure that CompilationPolicy::event() doesn't throw exceptions Reviewed-by: kvn, never
author iveresov
date Thu, 26 Jan 2012 12:15:24 -0800
parents 973293defacd
children da91efe96a93
comparison
equal deleted inserted replaced
4824:5dbed2f542ff 4825:20334ed5ed3c
175 if (sd->is_top()) break; 175 if (sd->is_top()) break;
176 } 176 }
177 } 177 }
178 178
179 nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee, 179 nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee,
180 int branch_bci, int bci, CompLevel comp_level, nmethod* nm, TRAPS) { 180 int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) {
181 if (comp_level == CompLevel_none && 181 if (comp_level == CompLevel_none &&
182 JvmtiExport::can_post_interpreter_events()) { 182 JvmtiExport::can_post_interpreter_events() &&
183 assert(THREAD->is_Java_thread(), "Should be java thread"); 183 thread->is_interp_only_mode()) {
184 if (((JavaThread*)THREAD)->is_interp_only_mode()) { 184 return NULL;
185 return NULL;
186 }
187 } 185 }
188 nmethod *osr_nm = NULL; 186 nmethod *osr_nm = NULL;
189 187
190 handle_counter_overflow(method()); 188 handle_counter_overflow(method());
191 if (method() != inlinee()) { 189 if (method() != inlinee()) {
195 if (PrintTieredEvents) { 193 if (PrintTieredEvents) {
196 print_event(bci == InvocationEntryBci ? CALL : LOOP, method, inlinee, bci, comp_level); 194 print_event(bci == InvocationEntryBci ? CALL : LOOP, method, inlinee, bci, comp_level);
197 } 195 }
198 196
199 if (bci == InvocationEntryBci) { 197 if (bci == InvocationEntryBci) {
200 method_invocation_event(method, inlinee, comp_level, nm, THREAD); 198 method_invocation_event(method, inlinee, comp_level, nm, thread);
201 } else { 199 } else {
202 method_back_branch_event(method, inlinee, bci, comp_level, nm, THREAD); 200 method_back_branch_event(method, inlinee, bci, comp_level, nm, thread);
203 // method == inlinee if the event originated in the main method 201 // method == inlinee if the event originated in the main method
204 int highest_level = inlinee->highest_osr_comp_level(); 202 int highest_level = inlinee->highest_osr_comp_level();
205 if (highest_level > comp_level) { 203 if (highest_level > comp_level) {
206 osr_nm = inlinee->lookup_osr_nmethod_for(bci, highest_level, false); 204 osr_nm = inlinee->lookup_osr_nmethod_for(bci, highest_level, false);
207 } 205 }
208 } 206 }
209 return osr_nm; 207 return osr_nm;
210 } 208 }
211 209
212 // Check if the method can be compiled, change level if necessary 210 // Check if the method can be compiled, change level if necessary
213 void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, TRAPS) { 211 void SimpleThresholdPolicy::compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread) {
214 assert(level <= TieredStopAtLevel, "Invalid compilation level"); 212 assert(level <= TieredStopAtLevel, "Invalid compilation level");
215 if (level == CompLevel_none) { 213 if (level == CompLevel_none) {
216 return; 214 return;
217 } 215 }
218 // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling 216 // Check if the method can be compiled. If it cannot be compiled with C1, continue profiling
219 // in the interpreter and then compile with C2 (the transition function will request that, 217 // in the interpreter and then compile with C2 (the transition function will request that,
220 // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with 218 // see common() ). If the method cannot be compiled with C2 but still can with C1, compile it with
221 // pure C1. 219 // pure C1.
222 if (!can_be_compiled(mh, level)) { 220 if (!can_be_compiled(mh, level)) {
223 if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) { 221 if (level == CompLevel_full_optimization && can_be_compiled(mh, CompLevel_simple)) {
224 compile(mh, bci, CompLevel_simple, THREAD); 222 compile(mh, bci, CompLevel_simple, thread);
225 } 223 }
226 return; 224 return;
227 } 225 }
228 if (bci != InvocationEntryBci && mh->is_not_osr_compilable()) { 226 if (bci != InvocationEntryBci && mh->is_not_osr_compilable()) {
229 return; 227 return;
230 } 228 }
231 if (!CompileBroker::compilation_is_in_queue(mh, bci)) { 229 if (!CompileBroker::compilation_is_in_queue(mh, bci)) {
232 if (PrintTieredEvents) { 230 if (PrintTieredEvents) {
233 print_event(COMPILE, mh, mh, bci, level); 231 print_event(COMPILE, mh, mh, bci, level);
234 } 232 }
235 submit_compile(mh, bci, level, THREAD); 233 submit_compile(mh, bci, level, thread);
236 } 234 }
237 } 235 }
238 236
239 // Tell the broker to compile the method 237 // Tell the broker to compile the method
240 void SimpleThresholdPolicy::submit_compile(methodHandle mh, int bci, CompLevel level, TRAPS) { 238 void SimpleThresholdPolicy::submit_compile(methodHandle mh, int bci, CompLevel level, JavaThread* thread) {
241 int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); 239 int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count();
242 CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", THREAD); 240 CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", thread);
243 } 241 }
244 242
245 // Call and loop predicates determine whether a transition to a higher 243 // Call and loop predicates determine whether a transition to a higher
246 // compilation level should be performed (pointers to predicate functions 244 // compilation level should be performed (pointers to predicate functions
247 // are passed to common() transition function). 245 // are passed to common() transition function).
364 } 362 }
365 363
366 364
367 // Handle the invocation event. 365 // Handle the invocation event.
368 void SimpleThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh, 366 void SimpleThresholdPolicy::method_invocation_event(methodHandle mh, methodHandle imh,
369 CompLevel level, nmethod* nm, TRAPS) { 367 CompLevel level, nmethod* nm, JavaThread* thread) {
370 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) { 368 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, InvocationEntryBci)) {
371 CompLevel next_level = call_event(mh(), level); 369 CompLevel next_level = call_event(mh(), level);
372 if (next_level != level) { 370 if (next_level != level) {
373 compile(mh, InvocationEntryBci, next_level, THREAD); 371 compile(mh, InvocationEntryBci, next_level, thread);
374 } 372 }
375 } 373 }
376 } 374 }
377 375
378 // Handle the back branch event. Notice that we can compile the method 376 // Handle the back branch event. Notice that we can compile the method
379 // with a regular entry from here. 377 // with a regular entry from here.
380 void SimpleThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh, 378 void SimpleThresholdPolicy::method_back_branch_event(methodHandle mh, methodHandle imh,
381 int bci, CompLevel level, nmethod* nm, TRAPS) { 379 int bci, CompLevel level, nmethod* nm, JavaThread* thread) {
382 // If the method is already compiling, quickly bail out. 380 // If the method is already compiling, quickly bail out.
383 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, bci)) { 381 if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh, bci)) {
384 // Use loop event as an opportinity to also check there's been 382 // Use loop event as an opportinity to also check there's been
385 // enough calls. 383 // enough calls.
386 CompLevel cur_level = comp_level(mh()); 384 CompLevel cur_level = comp_level(mh());
389 387
390 next_level = MAX2(next_level, 388 next_level = MAX2(next_level,
391 next_osr_level < CompLevel_full_optimization ? next_osr_level : cur_level); 389 next_osr_level < CompLevel_full_optimization ? next_osr_level : cur_level);
392 bool is_compiling = false; 390 bool is_compiling = false;
393 if (next_level != cur_level) { 391 if (next_level != cur_level) {
394 compile(mh, InvocationEntryBci, next_level, THREAD); 392 compile(mh, InvocationEntryBci, next_level, thread);
395 is_compiling = true; 393 is_compiling = true;
396 } 394 }
397 395
398 // Do the OSR version 396 // Do the OSR version
399 if (!is_compiling && next_osr_level != level) { 397 if (!is_compiling && next_osr_level != level) {
400 compile(mh, bci, next_osr_level, THREAD); 398 compile(mh, bci, next_osr_level, thread);
401 } 399 }
402 } 400 }
403 } 401 }