8191227: issues with unsafe handle resolution

Mon, 27 Nov 2017 03:11:38 -0800

author
rraghavan
date
Mon, 27 Nov 2017 03:11:38 -0800
changeset 9841
2e636385f137
parent 9840
9efdbe72ed1d
child 9842
4df47a343601

8191227: issues with unsafe handle resolution
Summary: added ThreadInVMfromNative or ThreadInVMfromUnknown support
Reviewed-by: thartmann, vlivanov

src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp file | annotate | diff | comparison | revisions
src/share/vm/code/debugInfo.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Tue Dec 03 20:13:16 2019 +0300
     1.2 +++ b/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp	Mon Nov 27 03:11:38 2017 -0800
     1.3 @@ -509,8 +509,13 @@
     1.4    if (o == NULL) {
     1.5      __ set(NULL_WORD, reg);
     1.6    } else {
     1.7 +#ifdef ASSERT
     1.8 +    {
     1.9 +      ThreadInVMfromNative tiv(JavaThread::current());
    1.10 +      assert(Universe::heap()->is_in_reserved(JNIHandles::resolve(o)), "should be real oop");
    1.11 +    }
    1.12 +#endif
    1.13      int oop_index = __ oop_recorder()->find_index(o);
    1.14 -    assert(Universe::heap()->is_in_reserved(JNIHandles::resolve(o)), "should be real oop");
    1.15      RelocationHolder rspec = oop_Relocation::spec(oop_index);
    1.16      __ set(NULL_WORD, reg, rspec); // Will be set when the nmethod is created
    1.17    }
     2.1 --- a/src/share/vm/code/debugInfo.cpp	Tue Dec 03 20:13:16 2019 +0300
     2.2 +++ b/src/share/vm/code/debugInfo.cpp	Mon Nov 27 03:11:38 2017 -0800
     2.3 @@ -27,6 +27,8 @@
     2.4  #include "code/debugInfoRec.hpp"
     2.5  #include "code/nmethod.hpp"
     2.6  #include "runtime/handles.inline.hpp"
     2.7 +#include "runtime/interfaceSupport.hpp"
     2.8 +#include "runtime/thread.hpp"
     2.9  
    2.10  PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
    2.11  
    2.12 @@ -204,14 +206,24 @@
    2.13  // ConstantOopWriteValue
    2.14  
    2.15  void ConstantOopWriteValue::write_on(DebugInfoWriteStream* stream) {
    2.16 -  assert(JNIHandles::resolve(value()) == NULL ||
    2.17 -         Universe::heap()->is_in_reserved(JNIHandles::resolve(value())),
    2.18 -         "Should be in heap");
    2.19 +#ifdef ASSERT
    2.20 +  {
    2.21 +    // cannot use ThreadInVMfromNative here since in case of JVMCI compiler,
    2.22 +    // thread is already in VM state.
    2.23 +    ThreadInVMfromUnknown tiv;
    2.24 +    assert(JNIHandles::resolve(value()) == NULL ||
    2.25 +           Universe::heap()->is_in_reserved(JNIHandles::resolve(value())),
    2.26 +           "Should be in heap");
    2.27 + }
    2.28 +#endif
    2.29    stream->write_int(CONSTANT_OOP_CODE);
    2.30    stream->write_handle(value());
    2.31  }
    2.32  
    2.33  void ConstantOopWriteValue::print_on(outputStream* st) const {
    2.34 +  // using ThreadInVMfromUnknown here since in case of JVMCI compiler,
    2.35 +  // thread is already in VM state.
    2.36 +  ThreadInVMfromUnknown tiv;
    2.37    JNIHandles::resolve(value())->print_value_on(st);
    2.38  }
    2.39  

mercurial