1733 if (!isa_HotSpotInstalledCode(installed_code)) {
1734 JVMCI_THROW_MSG(InternalError, "InstalledCode instance must be a subclass of HotSpotInstalledCode");
1735 }
1736
1737 // Ignore the version which can stay at 0
1738 if (cb->is_nmethod()) {
1739 nmethod* nm = cb->as_nmethod_or_null();
1740 if (nm->is_in_use()) {
1741 set_InstalledCode_entryPoint(installed_code, (jlong) nm->verified_entry_point());
1742 }
1743 } else {
1744 set_InstalledCode_entryPoint(installed_code, (jlong) cb->code_begin());
1745 }
1746 set_InstalledCode_address(installed_code, (jlong) cb);
1747 set_HotSpotInstalledCode_size(installed_code, cb->size());
1748 set_HotSpotInstalledCode_codeStart(installed_code, (jlong) cb->code_begin());
1749 set_HotSpotInstalledCode_codeSize(installed_code, cb->code_size());
1750 }
1751
1752
1753 void JVMCIEnv::invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimize, nmethod::ChangeReason change_reason, JVMCI_TRAPS) {
1754 if (mirror.is_null()) {
1755 JVMCI_THROW(NullPointerException);
1756 }
1757
1758 Thread* current = Thread::current();
1759 if (!mirror.is_hotspot() && !current->is_Java_thread()) {
1760 // Calling back into native might cause the execution to block, so only allow this when calling
1761 // from a JavaThread, which is the normal case anyway.
1762 JVMCI_THROW_MSG(IllegalArgumentException,
1763 "Cannot invalidate HotSpotNmethod object in shared library VM heap from non-JavaThread");
1764 }
1765
1766 JavaThread* thread = JavaThread::cast(current);
1767 JVMCINMethodHandle nmethod_handle(thread);
1768 nmethod* nm = JVMCIENV->get_nmethod(mirror, nmethod_handle);
1769 if (nm == nullptr) {
1770 // Nothing to do
1771 return;
1772 }
1773
1774 if (!deoptimize) {
1775 // Prevent future executions of the nmethod but let current executions complete.
1776 nm->make_not_entrant(change_reason);
1777
1778 // Do not clear the address field here as the Java code may still
1779 // want to later call this method with deoptimize == true. That requires
1780 // the address field to still be pointing at the nmethod.
1781 } else {
1782 // Deoptimize the nmethod immediately.
1783 DeoptimizationScope deopt_scope;
1784 deopt_scope.mark(nm);
1785 nm->make_not_entrant(change_reason);
1786 nm->make_deoptimized();
1787 deopt_scope.deoptimize_marked();
1788
1789 // A HotSpotNmethod instance can only reference a single nmethod
1790 // during its lifetime so simply clear it here.
1791 set_InstalledCode_address(mirror, 0);
1792 }
1793 }
1794
1795 Klass* JVMCIEnv::asKlass(JVMCIObject obj) {
1796 return (Klass*) get_HotSpotResolvedObjectTypeImpl_klassPointer(obj);
1797 }
1798
1799 Method* JVMCIEnv::asMethod(JVMCIObject obj) {
1800 Method** methodHandle = (Method**) get_HotSpotResolvedJavaMethodImpl_methodHandle(obj);
1801 return *methodHandle;
1802 }
1803
1804 ConstantPool* JVMCIEnv::asConstantPool(JVMCIObject obj) {
1805 ConstantPool** constantPoolHandle = (ConstantPool**) get_HotSpotConstantPool_constantPoolHandle(obj);
|
1733 if (!isa_HotSpotInstalledCode(installed_code)) {
1734 JVMCI_THROW_MSG(InternalError, "InstalledCode instance must be a subclass of HotSpotInstalledCode");
1735 }
1736
1737 // Ignore the version which can stay at 0
1738 if (cb->is_nmethod()) {
1739 nmethod* nm = cb->as_nmethod_or_null();
1740 if (nm->is_in_use()) {
1741 set_InstalledCode_entryPoint(installed_code, (jlong) nm->verified_entry_point());
1742 }
1743 } else {
1744 set_InstalledCode_entryPoint(installed_code, (jlong) cb->code_begin());
1745 }
1746 set_InstalledCode_address(installed_code, (jlong) cb);
1747 set_HotSpotInstalledCode_size(installed_code, cb->size());
1748 set_HotSpotInstalledCode_codeStart(installed_code, (jlong) cb->code_begin());
1749 set_HotSpotInstalledCode_codeSize(installed_code, cb->code_size());
1750 }
1751
1752
1753 void JVMCIEnv::invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimize, nmethod::InvalidationReason invalidation_reason, JVMCI_TRAPS) {
1754 if (mirror.is_null()) {
1755 JVMCI_THROW(NullPointerException);
1756 }
1757
1758 Thread* current = Thread::current();
1759 if (!mirror.is_hotspot() && !current->is_Java_thread()) {
1760 // Calling back into native might cause the execution to block, so only allow this when calling
1761 // from a JavaThread, which is the normal case anyway.
1762 JVMCI_THROW_MSG(IllegalArgumentException,
1763 "Cannot invalidate HotSpotNmethod object in shared library VM heap from non-JavaThread");
1764 }
1765
1766 JavaThread* thread = JavaThread::cast(current);
1767 JVMCINMethodHandle nmethod_handle(thread);
1768 nmethod* nm = JVMCIENV->get_nmethod(mirror, nmethod_handle);
1769 if (nm == nullptr) {
1770 // Nothing to do
1771 return;
1772 }
1773
1774 if (!deoptimize) {
1775 // Prevent future executions of the nmethod but let current executions complete.
1776 nm->make_not_entrant(invalidation_reason);
1777
1778 // Do not clear the address field here as the Java code may still
1779 // want to later call this method with deoptimize == true. That requires
1780 // the address field to still be pointing at the nmethod.
1781 } else {
1782 // Deoptimize the nmethod immediately.
1783 DeoptimizationScope deopt_scope;
1784 deopt_scope.mark(nm);
1785 nm->make_not_entrant(invalidation_reason);
1786 nm->make_deoptimized();
1787 deopt_scope.deoptimize_marked();
1788
1789 // A HotSpotNmethod instance can only reference a single nmethod
1790 // during its lifetime so simply clear it here.
1791 set_InstalledCode_address(mirror, 0);
1792 }
1793 }
1794
1795 Klass* JVMCIEnv::asKlass(JVMCIObject obj) {
1796 return (Klass*) get_HotSpotResolvedObjectTypeImpl_klassPointer(obj);
1797 }
1798
1799 Method* JVMCIEnv::asMethod(JVMCIObject obj) {
1800 Method** methodHandle = (Method**) get_HotSpotResolvedJavaMethodImpl_methodHandle(obj);
1801 return *methodHandle;
1802 }
1803
1804 ConstantPool* JVMCIEnv::asConstantPool(JVMCIObject obj) {
1805 ConstantPool** constantPoolHandle = (ConstantPool**) get_HotSpotConstantPool_constantPoolHandle(obj);
|