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