Mercurial > hg > openjdk > jdk8u > hotspot
changeset 9130:2e636385f137
8191227: issues with unsafe handle resolution
Summary: added ThreadInVMfromNative or ThreadInVMfromUnknown support
Reviewed-by: thartmann, vlivanov
author | rraghavan |
---|---|
date | Mon, 27 Nov 2017 03:11:38 -0800 |
parents | 9efdbe72ed1d |
children | 4df47a343601 |
files | src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp src/share/vm/code/debugInfo.cpp |
diffstat | 2 files changed, 21 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Tue Dec 03 20:13:16 2019 +0300 +++ b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp Mon Nov 27 03:11:38 2017 -0800 @@ -509,8 +509,13 @@ if (o == NULL) { __ set(NULL_WORD, reg); } else { +#ifdef ASSERT + { + ThreadInVMfromNative tiv(JavaThread::current()); + assert(Universe::heap()->is_in_reserved(JNIHandles::resolve(o)), "should be real oop"); + } +#endif int oop_index = __ oop_recorder()->find_index(o); - assert(Universe::heap()->is_in_reserved(JNIHandles::resolve(o)), "should be real oop"); RelocationHolder rspec = oop_Relocation::spec(oop_index); __ set(NULL_WORD, reg, rspec); // Will be set when the nmethod is created }
--- a/src/share/vm/code/debugInfo.cpp Tue Dec 03 20:13:16 2019 +0300 +++ b/src/share/vm/code/debugInfo.cpp Mon Nov 27 03:11:38 2017 -0800 @@ -27,6 +27,8 @@ #include "code/debugInfoRec.hpp" #include "code/nmethod.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/interfaceSupport.hpp" +#include "runtime/thread.hpp" PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC @@ -204,14 +206,24 @@ // ConstantOopWriteValue void ConstantOopWriteValue::write_on(DebugInfoWriteStream* stream) { - assert(JNIHandles::resolve(value()) == NULL || - Universe::heap()->is_in_reserved(JNIHandles::resolve(value())), - "Should be in heap"); +#ifdef ASSERT + { + // cannot use ThreadInVMfromNative here since in case of JVMCI compiler, + // thread is already in VM state. + ThreadInVMfromUnknown tiv; + assert(JNIHandles::resolve(value()) == NULL || + Universe::heap()->is_in_reserved(JNIHandles::resolve(value())), + "Should be in heap"); + } +#endif stream->write_int(CONSTANT_OOP_CODE); stream->write_handle(value()); } void ConstantOopWriteValue::print_on(outputStream* st) const { + // using ThreadInVMfromUnknown here since in case of JVMCI compiler, + // thread is already in VM state. + ThreadInVMfromUnknown tiv; JNIHandles::resolve(value())->print_value_on(st); }