1619 jbyteArray insts = env->NewByteArray(insts_size);
1620 CHECK_JNI_EXCEPTION_(env, nullptr);
1621 env->SetByteArrayRegion(insts, 0, insts_size, (jbyte*) code->insts_begin());
1622 env->SetObjectArrayElement(result, 2, insts);
1623
1624 jobject id = integerBox(thread, env, code->compile_id());
1625 CHECK_JNI_EXCEPTION_(env, nullptr);
1626 env->SetObjectArrayElement(result, 3, id);
1627
1628 jobject entry_point = longBox(thread, env, (jlong) code->entry_point());
1629 CHECK_JNI_EXCEPTION_(env, nullptr);
1630 env->SetObjectArrayElement(result, 4, entry_point);
1631
1632 return result;
1633 WB_END
1634
1635 WB_ENTRY(void, WB_RelocateNMethodFromMethod(JNIEnv* env, jobject o, jobject method, jint blob_type))
1636 ResourceMark rm(THREAD);
1637 jmethodID jmid = reflected_method_to_jmid(thread, env, method);
1638 CHECK_JNI_EXCEPTION(env);
1639 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
1640 nmethod* code = mh->code();
1641 if (code != nullptr) {
1642 MutexLocker ml_Compile_lock(Compile_lock);
1643 CompiledICLocker ic_locker(code);
1644 MutexLocker ml_CodeCache_lock(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1645 code->relocate(static_cast<CodeBlobType>(blob_type));
1646 }
1647 WB_END
1648
1649 WB_ENTRY(void, WB_RelocateNMethodFromAddr(JNIEnv* env, jobject o, jlong addr, jint blob_type))
1650 ResourceMark rm(THREAD);
1651 CHECK_JNI_EXCEPTION(env);
1652 void* address = (void*) addr;
1653
1654 if (address == nullptr) {
1655 return;
1656 }
1657
1658 MutexLocker ml_Compile_lock(Compile_lock);
1659 MutexLocker ml_CompiledIC_lock(CompiledIC_lock, Mutex::_no_safepoint_check_flag);
1660 MutexLocker ml_CodeCache_lock(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1661
1662 // Verify that nmethod address is still valid
1663 CodeBlob* blob = CodeCache::find_blob(address);
1664 if (blob != nullptr && blob->is_nmethod()) {
1665 nmethod* code = blob->as_nmethod();
1666 if (code->is_in_use() && !code->is_unloading()) {
1667 CompiledICLocker ic_locker(code);
1668 code->relocate(static_cast<CodeBlobType>(blob_type));
1669 }
1670 }
1671 WB_END
1672
1673 CodeBlob* WhiteBox::allocate_code_blob(int size, CodeBlobType blob_type) {
1674 guarantee(WhiteBoxAPI, "internal testing API :: WhiteBox has to be enabled");
1675 BufferBlob* blob;
1676 int full_size = CodeBlob::align_code_offset(sizeof(BufferBlob));
1677 if (full_size < size) {
|
1619 jbyteArray insts = env->NewByteArray(insts_size);
1620 CHECK_JNI_EXCEPTION_(env, nullptr);
1621 env->SetByteArrayRegion(insts, 0, insts_size, (jbyte*) code->insts_begin());
1622 env->SetObjectArrayElement(result, 2, insts);
1623
1624 jobject id = integerBox(thread, env, code->compile_id());
1625 CHECK_JNI_EXCEPTION_(env, nullptr);
1626 env->SetObjectArrayElement(result, 3, id);
1627
1628 jobject entry_point = longBox(thread, env, (jlong) code->entry_point());
1629 CHECK_JNI_EXCEPTION_(env, nullptr);
1630 env->SetObjectArrayElement(result, 4, entry_point);
1631
1632 return result;
1633 WB_END
1634
1635 WB_ENTRY(void, WB_RelocateNMethodFromMethod(JNIEnv* env, jobject o, jobject method, jint blob_type))
1636 ResourceMark rm(THREAD);
1637 jmethodID jmid = reflected_method_to_jmid(thread, env, method);
1638 CHECK_JNI_EXCEPTION(env);
1639
1640 if (!NMethodRelocation) {
1641 return;
1642 }
1643
1644 methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
1645 nmethod* code = mh->code();
1646 if (code != nullptr) {
1647 MutexLocker ml_Compile_lock(Compile_lock);
1648 CompiledICLocker ic_locker(code);
1649 MutexLocker ml_CodeCache_lock(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1650 code->relocate(static_cast<CodeBlobType>(blob_type));
1651 }
1652 WB_END
1653
1654 WB_ENTRY(void, WB_RelocateNMethodFromAddr(JNIEnv* env, jobject o, jlong addr, jint blob_type))
1655 ResourceMark rm(THREAD);
1656 CHECK_JNI_EXCEPTION(env);
1657 void* address = (void*) addr;
1658
1659 if (address == nullptr) {
1660 return;
1661 }
1662
1663 if (!NMethodRelocation) {
1664 return;
1665 }
1666
1667 MutexLocker ml_Compile_lock(Compile_lock);
1668 MutexLocker ml_CompiledIC_lock(CompiledIC_lock, Mutex::_no_safepoint_check_flag);
1669 MutexLocker ml_CodeCache_lock(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1670
1671 // Verify that nmethod address is still valid
1672 CodeBlob* blob = CodeCache::find_blob(address);
1673 if (blob != nullptr && blob->is_nmethod()) {
1674 nmethod* code = blob->as_nmethod();
1675 if (code->is_in_use() && !code->is_unloading()) {
1676 CompiledICLocker ic_locker(code);
1677 code->relocate(static_cast<CodeBlobType>(blob_type));
1678 }
1679 }
1680 WB_END
1681
1682 CodeBlob* WhiteBox::allocate_code_blob(int size, CodeBlobType blob_type) {
1683 guarantee(WhiteBoxAPI, "internal testing API :: WhiteBox has to be enabled");
1684 BufferBlob* blob;
1685 int full_size = CodeBlob::align_code_offset(sizeof(BufferBlob));
1686 if (full_size < size) {
|