5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
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 #include "precompiled.hpp"
25 #include "asm/codeBuffer.hpp"
26 #include "classfile/javaClasses.inline.hpp"
27 #include "code/codeCache.hpp"
28 #include "compiler/compileBroker.hpp"
29 #include "compiler/disassembler.hpp"
30 #include "jvmci/jvmciRuntime.hpp"
31 #include "jvmci/jvmciCompilerToVM.hpp"
32 #include "jvmci/jvmciCompiler.hpp"
33 #include "jvmci/jvmciJavaClasses.hpp"
34 #include "jvmci/jvmciEnv.hpp"
35 #include "logging/log.hpp"
36 #include "memory/oopFactory.hpp"
37 #include "memory/resourceArea.hpp"
38 #include "oops/oop.inline.hpp"
39 #include "oops/objArrayOop.inline.hpp"
40 #include "prims/jvm.h"
41 #include "runtime/biasedLocking.hpp"
42 #include "runtime/interfaceSupport.hpp"
43 #include "runtime/reflection.hpp"
44 #include "runtime/sharedRuntime.hpp"
45 #include "utilities/debug.hpp"
46 #include "utilities/defaultStream.hpp"
47 #include "utilities/macros.hpp"
48
49 #if defined(_MSC_VER)
50 #define strtoll _strtoi64
51 #endif
52
53 jobject JVMCIRuntime::_HotSpotJVMCIRuntime_instance = NULL;
54 bool JVMCIRuntime::_HotSpotJVMCIRuntime_initialized = false;
55 bool JVMCIRuntime::_well_known_classes_initialized = false;
56 int JVMCIRuntime::_trivial_prefixes_count = 0;
57 char** JVMCIRuntime::_trivial_prefixes = NULL;
58 JVMCIRuntime::CompLevelAdjustment JVMCIRuntime::_comp_level_adjustment = JVMCIRuntime::none;
59 bool JVMCIRuntime::_shutdown_called = false;
60
594 JRT_END
595
596 JRT_ENTRY(jint, JVMCIRuntime::identity_hash_code(JavaThread* thread, oopDesc* obj))
597 return (jint) obj->identity_hash();
598 JRT_END
599
600 JRT_ENTRY(jboolean, JVMCIRuntime::thread_is_interrupted(JavaThread* thread, oopDesc* receiver, jboolean clear_interrupted))
601 // Ensure that the C++ Thread and OSThread structures aren't freed before we operate.
602 // This locking requires thread_in_vm which is why this method cannot be JRT_LEAF.
603 Handle receiverHandle(thread, receiver);
604 MutexLockerEx ml(thread->threadObj() == (void*)receiver ? NULL : Threads_lock);
605 JavaThread* receiverThread = java_lang_Thread::thread(receiverHandle());
606 if (receiverThread == NULL) {
607 // The other thread may exit during this process, which is ok so return false.
608 return JNI_FALSE;
609 } else {
610 return (jint) Thread::is_interrupted(receiverThread, clear_interrupted != 0);
611 }
612 JRT_END
613
614 JRT_ENTRY(jint, JVMCIRuntime::test_deoptimize_call_int(JavaThread* thread, int value))
615 deopt_caller();
616 return value;
617 JRT_END
618
619 void JVMCIRuntime::force_initialization(TRAPS) {
620 JVMCIRuntime::initialize_well_known_classes(CHECK);
621
622 ResourceMark rm;
623 TempNewSymbol getCompiler = SymbolTable::new_symbol("getCompiler", CHECK);
624 TempNewSymbol sig = SymbolTable::new_symbol("()Ljdk/vm/ci/runtime/JVMCICompiler;", CHECK);
625 Handle jvmciRuntime = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK);
626 JavaValue result(T_OBJECT);
627 JavaCalls::call_virtual(&result, jvmciRuntime, HotSpotJVMCIRuntime::klass(), getCompiler, sig, CHECK);
628 }
629
630 // private static JVMCIRuntime JVMCI.initializeRuntime()
631 JVM_ENTRY(jobject, JVM_GetJVMCIRuntime(JNIEnv *env, jclass c))
632 if (!EnableJVMCI) {
633 THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVMCI is not enabled")
634 }
|
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
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 #include "precompiled.hpp"
25 #include "jvm.h"
26 #include "asm/codeBuffer.hpp"
27 #include "classfile/javaClasses.inline.hpp"
28 #include "code/codeCache.hpp"
29 #include "compiler/compileBroker.hpp"
30 #include "compiler/disassembler.hpp"
31 #include "jvmci/jvmciRuntime.hpp"
32 #include "jvmci/jvmciCompilerToVM.hpp"
33 #include "jvmci/jvmciCompiler.hpp"
34 #include "jvmci/jvmciJavaClasses.hpp"
35 #include "jvmci/jvmciEnv.hpp"
36 #include "logging/log.hpp"
37 #include "memory/oopFactory.hpp"
38 #include "memory/resourceArea.hpp"
39 #include "oops/oop.inline.hpp"
40 #include "oops/objArrayOop.inline.hpp"
41 #include "runtime/biasedLocking.hpp"
42 #include "runtime/interfaceSupport.hpp"
43 #include "runtime/reflection.hpp"
44 #include "runtime/sharedRuntime.hpp"
45 #include "utilities/debug.hpp"
46 #include "utilities/defaultStream.hpp"
47 #include "utilities/macros.hpp"
48
49 #if defined(_MSC_VER)
50 #define strtoll _strtoi64
51 #endif
52
53 jobject JVMCIRuntime::_HotSpotJVMCIRuntime_instance = NULL;
54 bool JVMCIRuntime::_HotSpotJVMCIRuntime_initialized = false;
55 bool JVMCIRuntime::_well_known_classes_initialized = false;
56 int JVMCIRuntime::_trivial_prefixes_count = 0;
57 char** JVMCIRuntime::_trivial_prefixes = NULL;
58 JVMCIRuntime::CompLevelAdjustment JVMCIRuntime::_comp_level_adjustment = JVMCIRuntime::none;
59 bool JVMCIRuntime::_shutdown_called = false;
60
594 JRT_END
595
596 JRT_ENTRY(jint, JVMCIRuntime::identity_hash_code(JavaThread* thread, oopDesc* obj))
597 return (jint) obj->identity_hash();
598 JRT_END
599
600 JRT_ENTRY(jboolean, JVMCIRuntime::thread_is_interrupted(JavaThread* thread, oopDesc* receiver, jboolean clear_interrupted))
601 // Ensure that the C++ Thread and OSThread structures aren't freed before we operate.
602 // This locking requires thread_in_vm which is why this method cannot be JRT_LEAF.
603 Handle receiverHandle(thread, receiver);
604 MutexLockerEx ml(thread->threadObj() == (void*)receiver ? NULL : Threads_lock);
605 JavaThread* receiverThread = java_lang_Thread::thread(receiverHandle());
606 if (receiverThread == NULL) {
607 // The other thread may exit during this process, which is ok so return false.
608 return JNI_FALSE;
609 } else {
610 return (jint) Thread::is_interrupted(receiverThread, clear_interrupted != 0);
611 }
612 JRT_END
613
614 JRT_ENTRY(int, JVMCIRuntime::test_deoptimize_call_int(JavaThread* thread, int value))
615 deopt_caller();
616 return value;
617 JRT_END
618
619 void JVMCIRuntime::force_initialization(TRAPS) {
620 JVMCIRuntime::initialize_well_known_classes(CHECK);
621
622 ResourceMark rm;
623 TempNewSymbol getCompiler = SymbolTable::new_symbol("getCompiler", CHECK);
624 TempNewSymbol sig = SymbolTable::new_symbol("()Ljdk/vm/ci/runtime/JVMCICompiler;", CHECK);
625 Handle jvmciRuntime = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK);
626 JavaValue result(T_OBJECT);
627 JavaCalls::call_virtual(&result, jvmciRuntime, HotSpotJVMCIRuntime::klass(), getCompiler, sig, CHECK);
628 }
629
630 // private static JVMCIRuntime JVMCI.initializeRuntime()
631 JVM_ENTRY(jobject, JVM_GetJVMCIRuntime(JNIEnv *env, jclass c))
632 if (!EnableJVMCI) {
633 THROW_MSG_NULL(vmSymbols::java_lang_InternalError(), "JVMCI is not enabled")
634 }
|