Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/jvmci/jvmci.hpp
40949 views
1
/*
2
* Copyright (c) 2017, 2020, 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/compiler_globals.hpp"
28
#include "compiler/compilerDefinitions.hpp"
29
#include "utilities/exceptions.hpp"
30
31
class BoolObjectClosure;
32
class constantPoolHandle;
33
class JavaThread;
34
class JVMCIEnv;
35
class JVMCIRuntime;
36
class Metadata;
37
class MetadataHandleBlock;
38
class OopClosure;
39
class OopStorage;
40
41
template <size_t>
42
class FormatStringEventLog;
43
44
typedef FormatStringEventLog<256> StringEventLog;
45
46
struct _jmetadata;
47
typedef struct _jmetadata *jmetadata;
48
49
class JVMCI : public AllStatic {
50
friend class JVMCIRuntime;
51
friend class JVMCIEnv;
52
53
private:
54
// Access to the HotSpotJVMCIRuntime used by the CompileBroker.
55
static JVMCIRuntime* _compiler_runtime;
56
57
// True when at least one JVMCIRuntime::initialize_HotSpotJVMCIRuntime()
58
// execution has completed successfully.
59
static volatile bool _is_initialized;
60
61
// True once boxing cache classes are guaranteed to be initialized.
62
static bool _box_caches_initialized;
63
64
// Handle created when loading the JVMCI shared library with os::dll_load.
65
// Must hold JVMCI_lock when initializing.
66
static void* _shared_library_handle;
67
68
// Argument to os::dll_load when loading JVMCI shared library
69
static char* _shared_library_path;
70
71
// Records whether JVMCI::shutdown has been called.
72
static volatile bool _in_shutdown;
73
74
// Access to the HotSpot heap based JVMCIRuntime
75
static JVMCIRuntime* _java_runtime;
76
77
// JVMCI event log (shows up in hs_err crash logs).
78
static StringEventLog* _events;
79
static StringEventLog* _verbose_events;
80
enum {
81
max_EventLog_level = 4
82
};
83
84
// Gets the Thread* value for the current thread or NULL if it's not available.
85
static Thread* current_thread_or_null();
86
87
public:
88
enum CodeInstallResult {
89
ok,
90
dependencies_failed,
91
cache_full,
92
code_too_large
93
};
94
95
// Gets the handle to the loaded JVMCI shared library, loading it
96
// first if not yet loaded and `load` is true. The path from
97
// which the library is loaded is returned in `path`. If
98
// `load` is true then JVMCI_lock must be locked.
99
static void* get_shared_library(char*& path, bool load);
100
101
static void do_unloading(bool unloading_occurred);
102
103
static void metadata_do(void f(Metadata*));
104
105
static void shutdown();
106
107
// Returns whether JVMCI::shutdown has been called.
108
static bool in_shutdown();
109
110
static bool is_compiler_initialized();
111
112
/**
113
* Determines if the VM is sufficiently booted to initialize JVMCI.
114
*/
115
static bool can_initialize_JVMCI();
116
117
static void initialize_globals();
118
119
static void initialize_compiler(TRAPS);
120
121
// Ensures the boxing cache classes (e.g., java.lang.Integer.IntegerCache) are initialized.
122
static void ensure_box_caches_initialized(TRAPS);
123
124
// Increments a value indicating some JVMCI compilation activity
125
// happened on `thread` if it is a CompilerThread.
126
// Returns `thread`.
127
static JavaThread* compilation_tick(JavaThread* thread);
128
129
static JVMCIRuntime* compiler_runtime() { return _compiler_runtime; }
130
// Gets the single runtime for JVMCI on the Java heap. This is the only
131
// JVMCI runtime available when !UseJVMCINativeLibrary.
132
static JVMCIRuntime* java_runtime() { return _java_runtime; }
133
134
// Appends an event to the JVMCI event log if JVMCIEventLogLevel >= `level`
135
static void vlog(int level, const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);
136
137
// Traces an event to tty if JVMCITraceLevel >= `level`
138
static void vtrace(int level, const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0);
139
140
public:
141
// Log/trace a JVMCI event
142
static void event(int level, const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
143
static void event1(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);
144
static void event2(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);
145
static void event3(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);
146
static void event4(const char* format, ...) ATTRIBUTE_PRINTF(1, 2);
147
};
148
149
// JVMCI event macros.
150
#define JVMCI_event_1 if (JVMCITraceLevel < 1 && JVMCIEventLogLevel < 1) ; else ::JVMCI::event1
151
#define JVMCI_event_2 if (JVMCITraceLevel < 2 && JVMCIEventLogLevel < 2) ; else ::JVMCI::event2
152
#define JVMCI_event_3 if (JVMCITraceLevel < 3 && JVMCIEventLogLevel < 3) ; else ::JVMCI::event3
153
#define JVMCI_event_4 if (JVMCITraceLevel < 4 && JVMCIEventLogLevel < 4) ; else ::JVMCI::event4
154
155
#endif // SHARE_JVMCI_JVMCI_HPP
156
157