14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "classfile/symbolTable.hpp"
28 #include "code/codeCache.hpp"
29 #include "memory/oopFactory.hpp"
30 #include "memory/resourceArea.hpp"
31 #include "memory/universe.hpp"
32 #include "oops/objArrayKlass.hpp"
33 #include "oops/typeArrayOop.inline.hpp"
34 #include "runtime/jniHandles.inline.hpp"
35 #include "runtime/javaCalls.hpp"
36 #include "jvmci/jniAccessMark.inline.hpp"
37 #include "jvmci/jvmciRuntime.hpp"
38
39 JVMCICompileState::JVMCICompileState(CompileTask* task):
40 _task(task),
41 _retryable(true),
42 _failure_reason(NULL),
43 _failure_reason_on_C_heap(false) {
44 // Get Jvmti capabilities under lock to get consistent values.
45 MutexLocker mu(JvmtiThreadState_lock);
46 _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint() ? 1 : 0;
47 _jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables() ? 1 : 0;
48 _jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions() ? 1 : 0;
49 _jvmti_can_pop_frame = JvmtiExport::can_pop_frame() ? 1 : 0;
50 }
51
52 bool JVMCICompileState::jvmti_state_changed() const {
53 if (!jvmti_can_access_local_variables() &&
1474 jlong nativeMethod = get_InstalledCode_address(mirror);
1475 nmethod* nm = JVMCIENV->asNmethod(mirror);
1476 if (nm == NULL) {
1477 // Nothing to do
1478 return;
1479 }
1480
1481 Thread* THREAD = Thread::current();
1482 if (!mirror.is_hotspot() && !THREAD->is_Java_thread()) {
1483 // Calling back into native might cause the execution to block, so only allow this when calling
1484 // from a JavaThread, which is the normal case anyway.
1485 JVMCI_THROW_MSG(IllegalArgumentException,
1486 "Cannot invalidate HotSpotNmethod object in shared library VM heap from non-JavaThread");
1487 }
1488
1489 nmethodLocker nml(nm);
1490 if (nm->is_alive()) {
1491 // Invalidating the HotSpotNmethod means we want the nmethod
1492 // to be deoptimized.
1493 nm->mark_for_deoptimization();
1494 VM_Deoptimize op;
1495 VMThread::execute(&op);
1496 }
1497
1498 // A HotSpotNmethod instance can only reference a single nmethod
1499 // during its lifetime so simply clear it here.
1500 set_InstalledCode_address(mirror, 0);
1501 }
1502
1503 Klass* JVMCIEnv::asKlass(JVMCIObject obj) {
1504 return (Klass*) get_HotSpotResolvedObjectTypeImpl_metadataPointer(obj);
1505 }
1506
1507 Method* JVMCIEnv::asMethod(JVMCIObject obj) {
1508 Method** metadataHandle = (Method**) get_HotSpotResolvedJavaMethodImpl_metadataHandle(obj);
1509 return *metadataHandle;
1510 }
1511
1512 ConstantPool* JVMCIEnv::asConstantPool(JVMCIObject obj) {
1513 ConstantPool** metadataHandle = (ConstantPool**) get_HotSpotConstantPool_metadataHandle(obj);
1514 return *metadataHandle;
1515 }
|
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "classfile/symbolTable.hpp"
28 #include "code/codeCache.hpp"
29 #include "memory/oopFactory.hpp"
30 #include "memory/resourceArea.hpp"
31 #include "memory/universe.hpp"
32 #include "oops/objArrayKlass.hpp"
33 #include "oops/typeArrayOop.inline.hpp"
34 #include "runtime/deoptimization.hpp"
35 #include "runtime/jniHandles.inline.hpp"
36 #include "runtime/javaCalls.hpp"
37 #include "jvmci/jniAccessMark.inline.hpp"
38 #include "jvmci/jvmciRuntime.hpp"
39
40 JVMCICompileState::JVMCICompileState(CompileTask* task):
41 _task(task),
42 _retryable(true),
43 _failure_reason(NULL),
44 _failure_reason_on_C_heap(false) {
45 // Get Jvmti capabilities under lock to get consistent values.
46 MutexLocker mu(JvmtiThreadState_lock);
47 _jvmti_can_hotswap_or_post_breakpoint = JvmtiExport::can_hotswap_or_post_breakpoint() ? 1 : 0;
48 _jvmti_can_access_local_variables = JvmtiExport::can_access_local_variables() ? 1 : 0;
49 _jvmti_can_post_on_exceptions = JvmtiExport::can_post_on_exceptions() ? 1 : 0;
50 _jvmti_can_pop_frame = JvmtiExport::can_pop_frame() ? 1 : 0;
51 }
52
53 bool JVMCICompileState::jvmti_state_changed() const {
54 if (!jvmti_can_access_local_variables() &&
1475 jlong nativeMethod = get_InstalledCode_address(mirror);
1476 nmethod* nm = JVMCIENV->asNmethod(mirror);
1477 if (nm == NULL) {
1478 // Nothing to do
1479 return;
1480 }
1481
1482 Thread* THREAD = Thread::current();
1483 if (!mirror.is_hotspot() && !THREAD->is_Java_thread()) {
1484 // Calling back into native might cause the execution to block, so only allow this when calling
1485 // from a JavaThread, which is the normal case anyway.
1486 JVMCI_THROW_MSG(IllegalArgumentException,
1487 "Cannot invalidate HotSpotNmethod object in shared library VM heap from non-JavaThread");
1488 }
1489
1490 nmethodLocker nml(nm);
1491 if (nm->is_alive()) {
1492 // Invalidating the HotSpotNmethod means we want the nmethod
1493 // to be deoptimized.
1494 nm->mark_for_deoptimization();
1495 Deoptimization::deoptimize_all_marked();
1496 }
1497
1498 // A HotSpotNmethod instance can only reference a single nmethod
1499 // during its lifetime so simply clear it here.
1500 set_InstalledCode_address(mirror, 0);
1501 }
1502
1503 Klass* JVMCIEnv::asKlass(JVMCIObject obj) {
1504 return (Klass*) get_HotSpotResolvedObjectTypeImpl_metadataPointer(obj);
1505 }
1506
1507 Method* JVMCIEnv::asMethod(JVMCIObject obj) {
1508 Method** metadataHandle = (Method**) get_HotSpotResolvedJavaMethodImpl_metadataHandle(obj);
1509 return *metadataHandle;
1510 }
1511
1512 ConstantPool* JVMCIEnv::asConstantPool(JVMCIObject obj) {
1513 ConstantPool** metadataHandle = (ConstantPool**) get_HotSpotConstantPool_metadataHandle(obj);
1514 return *metadataHandle;
1515 }
|