# HG changeset patch # User kbarrett # Date 1519941082 18000 # Node ID 6734eeef4283d9f1ef944e14c364b7d129cb344b # Parent 13378aa8527e0bc73056b03da5ae0addd717011d 8198474: Move JNIHandles::resolve into jniHandles.inline.hpp Summary: Moved resolve and friends to new jniHandles.inline.hpp. Reviewed-by: tschatzl, pliden, coleenp diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -43,6 +43,7 @@ #include "runtime/biasedLocking.hpp" #include "runtime/icache.hpp" #include "runtime/interfaceSupport.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/thread.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/cpu/ppc/frame_ppc.cpp --- a/src/hotspot/cpu/ppc/frame_ppc.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/cpu/ppc/frame_ppc.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2017 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -32,6 +32,7 @@ #include "runtime/frame.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/monitorChunk.hpp" #include "runtime/signature.hpp" #include "runtime/stubCodeGenerator.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp --- a/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/cpu/sparc/c1_LIRAssembler_sparc.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -35,6 +35,7 @@ #include "gc/shared/collectedHeap.hpp" #include "nativeInst_sparc.hpp" #include "oops/objArrayKlass.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/safepointMechanism.inline.hpp" #include "runtime/sharedRuntime.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/cpu/sparc/macroAssembler_sparc.cpp --- a/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/cpu/sparc/macroAssembler_sparc.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -36,6 +36,7 @@ #include "prims/methodHandles.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/interfaceSupport.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/objectMonitor.hpp" #include "runtime/os.inline.hpp" #include "runtime/safepoint.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/cpu/zero/cppInterpreter_zero.cpp --- a/src/hotspot/cpu/zero/cppInterpreter_zero.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/cpu/zero/cppInterpreter_zero.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010, 2011 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -41,6 +41,7 @@ #include "runtime/deoptimization.hpp" #include "runtime/frame.inline.hpp" #include "runtime/interfaceSupport.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/stubRoutines.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/ci/ciEnv.cpp --- a/src/hotspot/share/ci/ciEnv.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/ci/ciEnv.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,6 +53,7 @@ #include "prims/jvmtiExport.hpp" #include "runtime/init.hpp" #include "runtime/reflection.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/thread.inline.hpp" #include "trace/tracing.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/ci/ciInstanceKlass.cpp --- a/src/hotspot/share/ci/ciInstanceKlass.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/ci/ciInstanceKlass.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ #include "oops/oop.inline.hpp" #include "oops/fieldStreams.hpp" #include "runtime/fieldDescriptor.hpp" +#include "runtime/jniHandles.inline.hpp" // ciInstanceKlass // diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/ci/ciObject.cpp --- a/src/hotspot/share/ci/ciObject.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/ci/ciObject.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ #include "ci/ciUtilities.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "oops/oop.inline.hpp" +#include "runtime/jniHandles.inline.hpp" // ciObject // @@ -98,6 +99,14 @@ } // ------------------------------------------------------------------ +// ciObject::get_oop +// +// Get the oop of this ciObject. +oop ciObject::get_oop() const { + return JNIHandles::resolve_non_null(_handle); +} + +// ------------------------------------------------------------------ // ciObject::klass // // Get the ciKlass of this ciObject. diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/ci/ciObject.hpp --- a/src/hotspot/share/ci/ciObject.hpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/ci/ciObject.hpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,10 +67,7 @@ jobject handle() const { return _handle; } // Get the VM oop that this object holds. - oop get_oop() const { - assert(_handle != NULL, "null oop"); - return JNIHandles::resolve_non_null(_handle); - } + oop get_oop() const; void init_flags_from(oop x); diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/classfile/javaClasses.cpp --- a/src/hotspot/share/classfile/javaClasses.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/classfile/javaClasses.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -53,6 +53,7 @@ #include "runtime/interfaceSupport.hpp" #include "runtime/java.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/safepoint.hpp" #include "runtime/thread.inline.hpp" #include "runtime/vframe.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/classfile/modules.cpp --- a/src/hotspot/share/classfile/modules.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/classfile/modules.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. +* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,7 @@ #include "runtime/arguments.hpp" #include "runtime/handles.inline.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/reflection.hpp" #include "utilities/stringUtils.hpp" #include "utilities/utf8.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/classfile/verifier.cpp --- a/src/hotspot/share/classfile/verifier.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/classfile/verifier.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,6 +45,7 @@ #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/os.hpp" #include "runtime/thread.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/code/debugInfo.cpp --- a/src/hotspot/share/code/debugInfo.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/code/debugInfo.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ #include "oops/oop.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/thread.hpp" // Constructors diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/code/dependencies.cpp --- a/src/hotspot/share/code/dependencies.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/code/dependencies.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,6 +37,7 @@ #include "oops/objArrayKlass.hpp" #include "runtime/handles.hpp" #include "runtime/handles.inline.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/thread.inline.hpp" #include "utilities/copy.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/code/nmethod.cpp --- a/src/hotspot/share/code/nmethod.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/code/nmethod.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -44,6 +44,7 @@ #include "oops/oop.inline.hpp" #include "prims/jvmtiImpl.hpp" #include "runtime/atomic.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/os.hpp" #include "runtime/sharedRuntime.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/code/oopRecorder.cpp --- a/src/hotspot/share/code/oopRecorder.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/code/oopRecorder.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -29,6 +29,7 @@ #include "code/oopRecorder.hpp" #include "memory/allocation.inline.hpp" #include "oops/oop.inline.hpp" +#include "runtime/jniHandles.inline.hpp" #ifdef ASSERT template int ValueRecorder::_find_index_calls = 0; diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/jvmci/jvmciCodeInstaller.cpp --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -39,6 +39,7 @@ #include "oops/objArrayOop.inline.hpp" #include "oops/typeArrayOop.inline.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/safepointMechanism.inline.hpp" #include "utilities/align.hpp" @@ -97,6 +98,32 @@ } } +objArrayOop CodeInstaller::sites() { + return (objArrayOop) JNIHandles::resolve(_sites_handle); +} + +arrayOop CodeInstaller::code() { + return (arrayOop) JNIHandles::resolve(_code_handle); +} + +arrayOop CodeInstaller::data_section() { + return (arrayOop) JNIHandles::resolve(_data_section_handle); +} + +objArrayOop CodeInstaller::data_section_patches() { + return (objArrayOop) JNIHandles::resolve(_data_section_patches_handle); +} + +#ifndef PRODUCT +objArrayOop CodeInstaller::comments() { + return (objArrayOop) JNIHandles::resolve(_comments_handle); +} +#endif + +oop CodeInstaller::word_kind() { + return JNIHandles::resolve(_word_kind_handle); +} + // creates a HotSpot oop map out of the byte arrays provided by DebugInfo OopMap* CodeInstaller::create_oop_map(Handle debug_info, TRAPS) { Handle reference_map(THREAD, DebugInfo::referenceMap(debug_info)); diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/jvmci/jvmciCodeInstaller.hpp --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -188,15 +188,15 @@ void pd_relocate_JavaMethod(CodeBuffer &cbuf, Handle method, jint pc_offset, TRAPS); void pd_relocate_poll(address pc, jint mark, TRAPS); - objArrayOop sites() { return (objArrayOop) JNIHandles::resolve(_sites_handle); } - arrayOop code() { return (arrayOop) JNIHandles::resolve(_code_handle); } - arrayOop data_section() { return (arrayOop) JNIHandles::resolve(_data_section_handle); } - objArrayOop data_section_patches() { return (objArrayOop) JNIHandles::resolve(_data_section_patches_handle); } + objArrayOop sites(); + arrayOop code(); + arrayOop data_section(); + objArrayOop data_section_patches(); #ifndef PRODUCT - objArrayOop comments() { return (objArrayOop) JNIHandles::resolve(_comments_handle); } + objArrayOop comments(); #endif - oop word_kind() { return (oop) JNIHandles::resolve(_word_kind_handle); } + oop word_kind(); public: diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/jvmci/jvmciCompilerToVM.cpp --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -36,6 +36,7 @@ #include "oops/typeArrayOop.inline.hpp" #include "runtime/fieldDescriptor.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.inline.hpp" #include "jvmci/jvmciRuntime.hpp" #include "compiler/abstractCompiler.hpp" #include "compiler/compileBroker.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/jvmci/jvmciJavaClasses.hpp --- a/src/hotspot/share/jvmci/jvmciJavaClasses.hpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/jvmci/jvmciJavaClasses.hpp Thu Mar 01 16:51:22 2018 -0500 @@ -28,6 +28,7 @@ #include "oops/access.inline.hpp" #include "oops/instanceMirrorKlass.hpp" #include "oops/oop.inline.hpp" +#include "runtime/jniHandles.inline.hpp" class JVMCIJavaClasses : AllStatic { public: diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/jvmci/jvmciRuntime.cpp --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ #include "oops/objArrayOop.inline.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/interfaceSupport.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/reflection.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/threadSMR.hpp" @@ -630,6 +631,11 @@ return Handle(THREAD, (oop)result.get_jobject()); } +Handle JVMCIRuntime::get_HotSpotJVMCIRuntime(TRAPS) { + initialize_JVMCI(CHECK_(Handle())); + return Handle(THREAD, JNIHandles::resolve_non_null(_HotSpotJVMCIRuntime_instance)); +} + void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) { guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime"); JVMCIRuntime::initialize_well_known_classes(CHECK); diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/jvmci/jvmciRuntime.hpp --- a/src/hotspot/share/jvmci/jvmciRuntime.hpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/jvmci/jvmciRuntime.hpp Thu Mar 01 16:51:22 2018 -0500 @@ -73,10 +73,7 @@ /** * Gets the singleton HotSpotJVMCIRuntime instance, initializing it if necessary */ - static Handle get_HotSpotJVMCIRuntime(TRAPS) { - initialize_JVMCI(CHECK_(Handle())); - return Handle(THREAD, JNIHandles::resolve_non_null(_HotSpotJVMCIRuntime_instance)); - } + static Handle get_HotSpotJVMCIRuntime(TRAPS); static jobject get_HotSpotJVMCIRuntime_jobject(TRAPS) { initialize_JVMCI(CHECK_NULL); diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/jni.cpp --- a/src/hotspot/share/prims/jni.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/jni.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -69,6 +69,7 @@ #include "runtime/java.hpp" #include "runtime/javaCalls.hpp" #include "runtime/jfieldIDWorkaround.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/reflection.hpp" #include "runtime/sharedRuntime.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/jniCheck.cpp --- a/src/hotspot/share/prims/jniCheck.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/jniCheck.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -38,6 +38,7 @@ #include "runtime/handles.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/jfieldIDWorkaround.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/thread.inline.hpp" // Complain every extra number of unplanned local refs diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/jvm.cpp --- a/src/hotspot/share/prims/jvm.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/jvm.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -61,6 +61,7 @@ #include "runtime/java.hpp" #include "runtime/javaCalls.hpp" #include "runtime/jfieldIDWorkaround.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/os.inline.hpp" #include "runtime/perfData.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/jvmtiEnv.cpp --- a/src/hotspot/share/prims/jvmtiEnv.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/jvmtiEnv.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,6 +58,7 @@ #include "runtime/interfaceSupport.hpp" #include "runtime/javaCalls.hpp" #include "runtime/jfieldIDWorkaround.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/osThread.hpp" #include "runtime/reflectionUtils.hpp" #include "runtime/signature.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/jvmtiEnvBase.cpp --- a/src/hotspot/share/prims/jvmtiEnvBase.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -40,6 +40,7 @@ #include "runtime/deoptimization.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/jfieldIDWorkaround.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/objectMonitor.hpp" #include "runtime/objectMonitor.inline.hpp" #include "runtime/signature.hpp" @@ -501,6 +502,24 @@ } +// Handle management + +jobject JvmtiEnvBase::jni_reference(Handle hndl) { + return JNIHandles::make_local(hndl()); +} + +jobject JvmtiEnvBase::jni_reference(JavaThread *thread, Handle hndl) { + return JNIHandles::make_local(thread, hndl()); +} + +void JvmtiEnvBase::destroy_jni_reference(jobject jobj) { + JNIHandles::destroy_local(jobj); +} + +void JvmtiEnvBase::destroy_jni_reference(JavaThread *thread, jobject jobj) { + JNIHandles::destroy_local(jobj); // thread is unused. +} + // // Threads // diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/jvmtiEnvBase.hpp --- a/src/hotspot/share/prims/jvmtiEnvBase.hpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/jvmtiEnvBase.hpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -214,29 +214,20 @@ unsigned char* jvmtiMalloc(jlong size); // don't use this - call allocate // method to create a local handle - jobject jni_reference(Handle hndl) { - return JNIHandles::make_local(hndl()); - } + jobject jni_reference(Handle hndl); // method to create a local handle. // This function allows caller to specify which // threads local handle table to use. - jobject jni_reference(JavaThread *thread, Handle hndl) { - return JNIHandles::make_local(thread, hndl()); - } + jobject jni_reference(JavaThread *thread, Handle hndl); // method to destroy a local handle - void destroy_jni_reference(jobject jobj) { - JNIHandles::destroy_local(jobj); - } + void destroy_jni_reference(jobject jobj); // method to destroy a local handle. // This function allows caller to specify which - // threads local handle table to use although currently it is - // not used. - void destroy_jni_reference(JavaThread *thread, jobject jobj) { - destroy_jni_reference(jobj); - } + // threads local handle table to use. + void destroy_jni_reference(JavaThread *thread, jobject jobj); jvmtiEnv* jvmti_external() { return &_jvmti_external; }; diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/jvmtiExport.cpp --- a/src/hotspot/share/prims/jvmtiExport.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/jvmtiExport.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,6 +49,7 @@ #include "runtime/handles.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/objectMonitor.hpp" #include "runtime/objectMonitor.inline.hpp" #include "runtime/os.inline.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp --- a/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/jvmtiGetLoadedClasses.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -27,6 +27,7 @@ #include "gc/shared/collectedHeap.hpp" #include "memory/universe.inline.hpp" #include "prims/jvmtiGetLoadedClasses.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/thread.hpp" #include "utilities/stack.inline.hpp" #if INCLUDE_ALL_GCS diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/jvmtiRedefineClasses.cpp --- a/src/hotspot/share/prims/jvmtiRedefineClasses.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/jvmtiRedefineClasses.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,6 +47,7 @@ #include "prims/resolvedMethodTable.hpp" #include "prims/methodComparator.hpp" #include "runtime/deoptimization.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/relocator.hpp" #include "utilities/bitMap.inline.hpp" #include "utilities/events.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/jvmtiTagMap.cpp --- a/src/hotspot/share/prims/jvmtiTagMap.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/jvmtiTagMap.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -44,7 +44,7 @@ #include "prims/jvmtiTagMap.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/javaCalls.hpp" -#include "runtime/jniHandles.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/mutex.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/reflectionUtils.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/methodHandles.cpp --- a/src/hotspot/share/prims/methodHandles.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/methodHandles.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ #include "prims/methodHandles.hpp" #include "runtime/compilationPolicy.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/timerTrace.hpp" #include "runtime/reflection.hpp" #include "runtime/signature.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/unsafe.cpp --- a/src/hotspot/share/prims/unsafe.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/unsafe.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -38,6 +38,7 @@ #include "runtime/atomic.hpp" #include "runtime/globals.hpp" #include "runtime/interfaceSupport.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/reflection.hpp" #include "runtime/thread.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/wbtestmethods/parserTests.cpp --- a/src/hotspot/share/prims/wbtestmethods/parserTests.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/wbtestmethods/parserTests.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ #include "prims/whitebox.hpp" #include "prims/wbtestmethods/parserTests.hpp" #include "runtime/interfaceSupport.hpp" +#include "runtime/jniHandles.inline.hpp" #include "services/diagnosticArgument.hpp" #include "services/diagnosticFramework.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/prims/whitebox.cpp --- a/src/hotspot/share/prims/whitebox.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/prims/whitebox.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -53,6 +53,7 @@ #include "runtime/handshake.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/os.hpp" #include "runtime/sweeper.hpp" #include "runtime/thread.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/runtime/javaCalls.cpp --- a/src/hotspot/share/runtime/javaCalls.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/runtime/javaCalls.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/os.inline.hpp" #include "runtime/signature.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/runtime/jniHandles.cpp --- a/src/hotspot/share/runtime/jniHandles.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/runtime/jniHandles.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -27,7 +27,7 @@ #include "logging/log.hpp" #include "memory/iterator.hpp" #include "oops/oop.inline.hpp" -#include "runtime/jniHandles.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/thread.inline.hpp" #include "trace/traceMacros.hpp" @@ -135,6 +135,18 @@ return res; } +// Resolve some erroneous cases to NULL, rather than treating them as +// possibly unchecked errors. In particular, deleted handles are +// treated as NULL (though a deleted and later reallocated handle +// isn't detected). +oop JNIHandles::resolve_external_guard(jobject handle) { + oop result = NULL; + if (handle != NULL) { + result = resolve_impl(handle); + } + return result; +} + oop JNIHandles::resolve_jweak(jweak handle) { assert(handle != NULL, "precondition"); assert(is_jweak(handle), "precondition"); diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/runtime/jniHandles.hpp --- a/src/hotspot/share/runtime/jniHandles.hpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/runtime/jniHandles.hpp Thu Mar 01 16:51:22 2018 -0500 @@ -67,10 +67,10 @@ // Resolve handle into oop inline static oop resolve(jobject handle); - // Resolve externally provided handle into oop with some guards - inline static oop resolve_external_guard(jobject handle); // Resolve handle into oop, result guaranteed not to be null inline static oop resolve_non_null(jobject handle); + // Resolve externally provided handle into oop with some guards + static oop resolve_external_guard(jobject handle); // Local handles static jobject make_local(oop obj); @@ -198,72 +198,4 @@ #endif }; -inline bool JNIHandles::is_jweak(jobject handle) { - STATIC_ASSERT(weak_tag_size == 1); - STATIC_ASSERT(weak_tag_value == 1); - return (reinterpret_cast(handle) & weak_tag_mask) != 0; -} - -inline oop& JNIHandles::jobject_ref(jobject handle) { - assert(!is_jweak(handle), "precondition"); - return *reinterpret_cast(handle); -} - -inline oop& JNIHandles::jweak_ref(jobject handle) { - assert(is_jweak(handle), "precondition"); - char* ptr = reinterpret_cast(handle) - weak_tag_value; - return *reinterpret_cast(ptr); -} - -// external_guard is true if called from resolve_external_guard. -template -inline oop JNIHandles::resolve_impl(jobject handle) { - assert(handle != NULL, "precondition"); - assert(!current_thread_in_native(), "must not be in native"); - oop result; - if (is_jweak(handle)) { // Unlikely - result = resolve_jweak(handle); - } else { - result = jobject_ref(handle); - // Construction of jobjects canonicalize a null value into a null - // jobject, so for non-jweak the pointee should never be null. - assert(external_guard || result != NULL, "Invalid JNI handle"); - } - return result; -} - -inline oop JNIHandles::resolve(jobject handle) { - oop result = NULL; - if (handle != NULL) { - result = resolve_impl(handle); - } - return result; -} - -// Resolve some erroneous cases to NULL, rather than treating them as -// possibly unchecked errors. In particular, deleted handles are -// treated as NULL (though a deleted and later reallocated handle -// isn't detected). -inline oop JNIHandles::resolve_external_guard(jobject handle) { - oop result = NULL; - if (handle != NULL) { - result = resolve_impl(handle); - } - return result; -} - -inline oop JNIHandles::resolve_non_null(jobject handle) { - assert(handle != NULL, "JNI handle should not be null"); - oop result = resolve_impl(handle); - assert(result != NULL, "NULL read from jni handle"); - return result; -} - -inline void JNIHandles::destroy_local(jobject handle) { - if (handle != NULL) { - assert(!is_jweak(handle), "Invalid JNI local handle"); - jobject_ref(handle) = NULL; - } -} - #endif // SHARE_VM_RUNTIME_JNIHANDLES_HPP diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/runtime/jniHandles.inline.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/hotspot/share/runtime/jniHandles.inline.hpp Thu Mar 01 16:51:22 2018 -0500 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_RUNTIME_JNIHANDLES_INLINE_HPP +#define SHARE_RUNTIME_JNIHANDLES_INLINE_HPP + +#include "oops/oop.hpp" +#include "runtime/jniHandles.hpp" +#include "utilities/debug.hpp" +#include "utilities/globalDefinitions.hpp" + +inline bool JNIHandles::is_jweak(jobject handle) { + STATIC_ASSERT(weak_tag_size == 1); + STATIC_ASSERT(weak_tag_value == 1); + return (reinterpret_cast(handle) & weak_tag_mask) != 0; +} + +inline oop& JNIHandles::jobject_ref(jobject handle) { + assert(!is_jweak(handle), "precondition"); + return *reinterpret_cast(handle); +} + +inline oop& JNIHandles::jweak_ref(jobject handle) { + assert(is_jweak(handle), "precondition"); + char* ptr = reinterpret_cast(handle) - weak_tag_value; + return *reinterpret_cast(ptr); +} + +// external_guard is true if called from resolve_external_guard. +template +inline oop JNIHandles::resolve_impl(jobject handle) { + assert(handle != NULL, "precondition"); + assert(!current_thread_in_native(), "must not be in native"); + oop result; + if (is_jweak(handle)) { // Unlikely + result = resolve_jweak(handle); + } else { + result = jobject_ref(handle); + // Construction of jobjects canonicalize a null value into a null + // jobject, so for non-jweak the pointee should never be null. + assert(external_guard || result != NULL, "Invalid JNI handle"); + } + return result; +} + +inline oop JNIHandles::resolve(jobject handle) { + oop result = NULL; + if (handle != NULL) { + result = resolve_impl(handle); + } + return result; +} + +inline oop JNIHandles::resolve_non_null(jobject handle) { + assert(handle != NULL, "JNI handle should not be null"); + oop result = resolve_impl(handle); + assert(result != NULL, "NULL read from jni handle"); + return result; +} + +inline void JNIHandles::destroy_local(jobject handle) { + if (handle != NULL) { + assert(!is_jweak(handle), "Invalid JNI local handle"); + jobject_ref(handle) = NULL; + } +} + +#endif // SHARE_RUNTIME_JNIHANDLES_INLINE_HPP + diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/runtime/thread.cpp --- a/src/hotspot/share/runtime/thread.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/runtime/thread.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -71,6 +71,7 @@ #include "runtime/interfaceSupport.hpp" #include "runtime/java.hpp" #include "runtime/javaCalls.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/jniPeriodicChecker.hpp" #include "runtime/memprofiler.hpp" #include "runtime/mutexLocker.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/runtime/threadSMR.cpp --- a/src/hotspot/share/runtime/threadSMR.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/runtime/threadSMR.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "logging/logStream.hpp" #include "memory/allocation.inline.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/thread.inline.hpp" #include "runtime/threadSMR.inline.hpp" #include "services/threadService.hpp" diff -r 13378aa8527e -r 6734eeef4283 src/hotspot/share/services/management.cpp --- a/src/hotspot/share/services/management.cpp Thu Mar 01 09:03:30 2018 -0800 +++ b/src/hotspot/share/services/management.cpp Thu Mar 01 16:51:22 2018 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,7 @@ #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/javaCalls.hpp" -#include "runtime/jniHandles.hpp" +#include "runtime/jniHandles.inline.hpp" #include "runtime/os.hpp" #include "runtime/serviceThread.hpp" #include "runtime/thread.inline.hpp"