| 369 | } |
| 370 | |
| 371 | void VM::loadMethodIDs(jvmtiEnv* jvmti, JNIEnv* jni, jclass klass, bool update_count) { |
| 372 | if (loadAcquire(_jmethod_id_count) > JMETHOD_ID_LIMIT) { |
| 373 | if (__sync_bool_compare_and_swap(&_jmethod_id_count_warned, false, true)) { |
| 374 | Log::warn("Total number of generated jmethod-ids exceeds %d, stop generating more", JMETHOD_ID_LIMIT); |
| 375 | } |
| 376 | return; |
| 377 | } |
| 378 | if (VMStructs::hasClassLoaderData()) { |
| 379 | VMKlass* vmklass = VMKlass::fromJavaClass(jni, klass); |
| 380 | int method_count = vmklass->methodCount(); |
| 381 | if (method_count > 0) { |
| 382 | ClassLoaderData* cld = vmklass->classLoaderData(); |
| 383 | cld->lock(); |
| 384 | // Workaround for JVM bug: preallocate space for jmethodIDs |
| 385 | // at the beginning of the list (rather than at the end) |
| 386 | for (int i = 0; i < method_count; i += MethodList::SIZE) { |
| 387 | *cld->methodList() = new MethodList(*cld->methodList()); |
| 388 | } |
| 389 | cld->unlock(); |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | jint method_count; |
| 394 | jmethodID* methods; |
| 395 | if (jvmti->GetClassMethods(klass, &method_count, &methods) == 0) { |
| 396 | if (update_count) { |
| 397 | atomicInc(_jmethod_id_count, method_count); |
| 398 | } |
| 399 | jvmti->Deallocate((unsigned char*)methods); |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | void VM::loadAllMethodIDs(jvmtiEnv* jvmti, JNIEnv* jni) { |
| 404 | jint class_count; |
nothing calls this directly
no test coverage detected