1 /* 2 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 #ifndef SHARE_JVMCI_JVMCI_HPP 25 #define SHARE_JVMCI_JVMCI_HPP 26 27 #include "interpreter/interpreter.hpp" 28 #include "jvmci/jvmciExceptions.hpp" 29 #include "jvmci/jvmciJavaClasses.hpp" 30 #include "memory/allocation.hpp" 31 #include "runtime/arguments.hpp" 32 #include "runtime/deoptimization.hpp" 33 34 class MetadataHandleBlock; 35 class JVMCIRuntime; 36 37 struct _jmetadata; 38 typedef struct _jmetadata *jmetadata; 39 40 class JVMCI : public AllStatic { 41 friend class JVMCIRuntime; 42 friend class JVMCIEnv; 43 44 private: 45 // Handles to objects in the HotSpot heap. 46 static JNIHandleBlock* _object_handles; 47 48 // Handles to Metadata objects. 49 static MetadataHandleBlock* _metadata_handles; 50 51 // Access to the HotSpotJVMCIRuntime used by the CompileBroker. 52 static JVMCIRuntime* _compiler_runtime; 53 54 // Access to the HotSpotJVMCIRuntime used by Java code running on the 55 // HotSpot heap. It will be the same as _compiler_runtime if 56 // UseJVMCINativeLibrary is false 57 static JVMCIRuntime* _java_runtime; 58 59 public: 60 enum CodeInstallResult { 61 ok, 62 dependencies_failed, 63 dependencies_invalid, 64 cache_full, 65 code_too_large 66 }; 67 68 static void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred); 69 70 static void metadata_do(void f(Metadata*)); 71 72 static void oops_do(OopClosure* f); 73 74 static void shutdown(); 75 76 static bool shutdown_called(); 77 78 /** 79 * Lets JVMCI modify the compilation level currently selected for a method by 80 * the VM compilation policy. 81 * 82 * @param method the method being scheduled for compilation 83 * @param is_osr specifies if the compilation is an OSR compilation 84 * @param level the compilation level currently selected by the VM compilation policy 85 * @param thread the current thread 86 * @return the compilation level to use for the compilation 87 */ 88 static CompLevel adjust_comp_level(methodHandle method, bool is_osr, CompLevel level, JavaThread* thread); 89 90 static bool is_compiler_initialized(); 91 92 /** 93 * Determines if the VM is sufficiently booted to initialize JVMCI. 94 */ 95 static bool can_initialize_JVMCI(); 96 97 static void initialize_globals(); 98 99 static void initialize_compiler(TRAPS); 100 // JVMCIRuntime::call_getCompiler(CHECK); 101 102 static jobject make_global(Handle obj); 103 static bool is_global_handle(jobject handle); 104 105 static jmetadata allocate_handle(const methodHandle& handle); 106 static jmetadata allocate_handle(const constantPoolHandle& handle); 107 108 static void release_handle(jmetadata handle); 109 110 static JVMCIRuntime* compiler_runtime() { return _compiler_runtime; } 111 static JVMCIRuntime* java_runtime() { return _java_runtime; } 112 }; 113 114 #endif // SHARE_JVMCI_JVMCI_HPP