366 } |
366 } |
367 |
367 |
368 // Build a MethodData* object to hold information about this method |
368 // Build a MethodData* object to hold information about this method |
369 // collected in the interpreter. |
369 // collected in the interpreter. |
370 void Method::build_interpreter_method_data(methodHandle method, TRAPS) { |
370 void Method::build_interpreter_method_data(methodHandle method, TRAPS) { |
|
371 // Do not profile the method if metaspace has hit an OOM previously |
|
372 // allocating profiling data. Callers clear pending exception so don't |
|
373 // add one here. |
|
374 if (ClassLoaderDataGraph::has_metaspace_oom()) { |
|
375 return; |
|
376 } |
|
377 |
371 // Do not profile method if current thread holds the pending list lock, |
378 // Do not profile method if current thread holds the pending list lock, |
372 // which avoids deadlock for acquiring the MethodData_lock. |
379 // which avoids deadlock for acquiring the MethodData_lock. |
373 if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) { |
380 if (InstanceRefKlass::owns_pending_list_lock((JavaThread*)THREAD)) { |
374 return; |
381 return; |
375 } |
382 } |
377 // Grab a lock here to prevent multiple |
384 // Grab a lock here to prevent multiple |
378 // MethodData*s from being created. |
385 // MethodData*s from being created. |
379 MutexLocker ml(MethodData_lock, THREAD); |
386 MutexLocker ml(MethodData_lock, THREAD); |
380 if (method->method_data() == NULL) { |
387 if (method->method_data() == NULL) { |
381 ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); |
388 ClassLoaderData* loader_data = method->method_holder()->class_loader_data(); |
382 MethodData* method_data = MethodData::allocate(loader_data, method, CHECK); |
389 MethodData* method_data = MethodData::allocate(loader_data, method, THREAD); |
|
390 if (HAS_PENDING_EXCEPTION) { |
|
391 CompileBroker::log_metaspace_failure(); |
|
392 ClassLoaderDataGraph::set_metaspace_oom(true); |
|
393 return; // return the exception (which is cleared) |
|
394 } |
|
395 |
383 method->set_method_data(method_data); |
396 method->set_method_data(method_data); |
384 if (PrintMethodData && (Verbose || WizardMode)) { |
397 if (PrintMethodData && (Verbose || WizardMode)) { |
385 ResourceMark rm(THREAD); |
398 ResourceMark rm(THREAD); |
386 tty->print("build_interpreter_method_data for "); |
399 tty->print("build_interpreter_method_data for "); |
387 method->print_name(tty); |
400 method->print_name(tty); |
390 } |
403 } |
391 } |
404 } |
392 } |
405 } |
393 |
406 |
394 MethodCounters* Method::build_method_counters(Method* m, TRAPS) { |
407 MethodCounters* Method::build_method_counters(Method* m, TRAPS) { |
|
408 // Do not profile the method if metaspace has hit an OOM previously |
|
409 if (ClassLoaderDataGraph::has_metaspace_oom()) { |
|
410 return NULL; |
|
411 } |
|
412 |
395 methodHandle mh(m); |
413 methodHandle mh(m); |
396 ClassLoaderData* loader_data = mh->method_holder()->class_loader_data(); |
414 ClassLoaderData* loader_data = mh->method_holder()->class_loader_data(); |
397 MethodCounters* counters = MethodCounters::allocate(loader_data, CHECK_NULL); |
415 MethodCounters* counters = MethodCounters::allocate(loader_data, THREAD); |
|
416 if (HAS_PENDING_EXCEPTION) { |
|
417 CompileBroker::log_metaspace_failure(); |
|
418 ClassLoaderDataGraph::set_metaspace_oom(true); |
|
419 return NULL; // return the exception (which is cleared) |
|
420 } |
398 if (!mh->init_method_counters(counters)) { |
421 if (!mh->init_method_counters(counters)) { |
399 MetadataFactory::free_metadata(loader_data, counters); |
422 MetadataFactory::free_metadata(loader_data, counters); |
400 } |
423 } |
401 return mh->method_counters(); |
424 return mh->method_counters(); |
402 } |
425 } |