| 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 "compiler/compilerDefinitions.hpp" | 
|---|
| 28 | #include "utilities/exceptions.hpp" | 
|---|
| 29 |  | 
|---|
| 30 | class BoolObjectClosure; | 
|---|
| 31 | class constantPoolHandle; | 
|---|
| 32 | class JavaThread; | 
|---|
| 33 | class JVMCIEnv; | 
|---|
| 34 | class JVMCIRuntime; | 
|---|
| 35 | class Metadata; | 
|---|
| 36 | class MetadataHandleBlock; | 
|---|
| 37 | class OopClosure; | 
|---|
| 38 | class OopStorage; | 
|---|
| 39 |  | 
|---|
| 40 | struct _jmetadata; | 
|---|
| 41 | typedef struct _jmetadata *jmetadata; | 
|---|
| 42 |  | 
|---|
| 43 | class JVMCI : public AllStatic { | 
|---|
| 44 | friend class JVMCIRuntime; | 
|---|
| 45 | friend class JVMCIEnv; | 
|---|
| 46 |  | 
|---|
| 47 | private: | 
|---|
| 48 | // Handles to objects in the HotSpot heap. | 
|---|
| 49 | static OopStorage* _object_handles; | 
|---|
| 50 |  | 
|---|
| 51 | static OopStorage* object_handles(); | 
|---|
| 52 |  | 
|---|
| 53 | // Handles to Metadata objects. | 
|---|
| 54 | static MetadataHandleBlock* _metadata_handles; | 
|---|
| 55 |  | 
|---|
| 56 | // Access to the HotSpotJVMCIRuntime used by the CompileBroker. | 
|---|
| 57 | static JVMCIRuntime* _compiler_runtime; | 
|---|
| 58 |  | 
|---|
| 59 | // Access to the HotSpotJVMCIRuntime used by Java code running on the | 
|---|
| 60 | // HotSpot heap. It will be the same as _compiler_runtime if | 
|---|
| 61 | // UseJVMCINativeLibrary is false | 
|---|
| 62 | static JVMCIRuntime* _java_runtime; | 
|---|
| 63 |  | 
|---|
| 64 | public: | 
|---|
| 65 | enum CodeInstallResult { | 
|---|
| 66 | ok, | 
|---|
| 67 | dependencies_failed, | 
|---|
| 68 | dependencies_invalid, | 
|---|
| 69 | cache_full, | 
|---|
| 70 | code_too_large | 
|---|
| 71 | }; | 
|---|
| 72 |  | 
|---|
| 73 | static void do_unloading(bool unloading_occurred); | 
|---|
| 74 |  | 
|---|
| 75 | static void metadata_do(void f(Metadata*)); | 
|---|
| 76 |  | 
|---|
| 77 | static void oops_do(OopClosure* f); | 
|---|
| 78 |  | 
|---|
| 79 | static void shutdown(); | 
|---|
| 80 |  | 
|---|
| 81 | static bool shutdown_called(); | 
|---|
| 82 |  | 
|---|
| 83 | static bool is_compiler_initialized(); | 
|---|
| 84 |  | 
|---|
| 85 | /** | 
|---|
| 86 | * Determines if the VM is sufficiently booted to initialize JVMCI. | 
|---|
| 87 | */ | 
|---|
| 88 | static bool can_initialize_JVMCI(); | 
|---|
| 89 |  | 
|---|
| 90 | static void initialize_globals(); | 
|---|
| 91 |  | 
|---|
| 92 | static void initialize_compiler(TRAPS); | 
|---|
| 93 |  | 
|---|
| 94 | static jobject make_global(const Handle& obj); | 
|---|
| 95 | static bool is_global_handle(jobject handle); | 
|---|
| 96 |  | 
|---|
| 97 | static jmetadata allocate_handle(const methodHandle& handle); | 
|---|
| 98 | static jmetadata allocate_handle(const constantPoolHandle& handle); | 
|---|
| 99 |  | 
|---|
| 100 | static void release_handle(jmetadata handle); | 
|---|
| 101 |  | 
|---|
| 102 | static JVMCIRuntime* compiler_runtime() { return _compiler_runtime; } | 
|---|
| 103 | static JVMCIRuntime* java_runtime()     { return _java_runtime; } | 
|---|
| 104 | }; | 
|---|
| 105 |  | 
|---|
| 106 | #endif // SHARE_JVMCI_JVMCI_HPP | 
|---|
| 107 |  | 
|---|