- Notifications
You must be signed in to change notification settings - Fork 5.8k
/
Copy pathjvmciCompiler.hpp
166 lines (130 loc) · 5.5 KB
/
jvmciCompiler.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* Copyright (c) 2011, 2024, 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_JVMCI_JVMCICOMPILER_HPP
#defineSHARE_JVMCI_JVMCICOMPILER_HPP
#include"compiler/abstractCompiler.hpp"
#include"compiler/compiler_globals.hpp"
#include"runtime/atomic.hpp"
classJVMCICompileState;
classJVMCICompiler : publicAbstractCompiler {
public:
// Code installation specific statistics.
classCodeInstallStats {
private:
elapsedTimer _timer;
volatileint _count;
volatileint _codeBlobs_size;
volatileint _codeBlobs_code_size;
public:
CodeInstallStats() :
_count(0),
_codeBlobs_size(0),
_codeBlobs_code_size(0)
{}
elapsedTimer* timer() { return &_timer; }
voidprint_on(outputStream* st, constchar* prefix) const;
// Notifies this object that `cb` has just been
// installed in the code cache.
voidon_install(CodeBlob* cb);
};
private:
bool _bootstrapping;
/**
* True if we have seen a bootstrap compilation request.
*/
volatilebool _bootstrap_compilation_request_handled;
/**
* Number of methods successfully compiled by a call to
* JVMCIRuntime::compile_method().
*/
volatileint _methods_compiled;
// Tracks upcalls that should only fail under severe conditions (e.g.
// memory pressure) and disables JVMCI compilation if too many fail
// with an error. A good example is an OOME thrown
// when libgraal calls into the HotSpot heap to get a copy
// of the system properties or to translate an exception from
// the HotSpot heap to the libgraal heap.
volatileint _ok_upcalls;
volatileint _err_upcalls;
bool _disabled;
// Incremented periodically by JVMCI compiler threads
// to indicate JVMCI compilation activity.
volatileint _global_compilation_ticks;
static JVMCICompiler* _instance;
CodeInstallStats _jit_code_installs; // CompileBroker compilations
CodeInstallStats _hosted_code_installs; // Non-CompileBroker compilations
/**
* Exits the VM due to an unexpected exception.
*/
staticvoidexit_on_pending_exception(oop exception, constchar* message);
public:
JVMCICompiler();
static JVMCICompiler* instance(bool require_non_null, TRAPS);
virtualconstchar* name() { return UseJVMCINativeLibrary ? "JVMCI-native" : "JVMCI"; }
boolis_jvmci() { returntrue; }
boolis_c1 () { returnfalse; }
boolis_c2 () { returnfalse; }
virtualboolis_hidden_from_external_view() const { return UseJVMCINativeLibrary && LibJVMCICompilerThreadHidden; }
boolneeds_stubs () { returnfalse; }
// Initialization
virtualvoidinitialize();
/**
* Initialize the compile queue with the methods in java.lang.Object and
* then wait until the queue is empty.
*/
voidbootstrap(TRAPS);
// Should force compilation of method at CompLevel_simple?
boolforce_comp_at_level_simple(const methodHandle& method);
boolis_bootstrapping() const { return _bootstrapping; }
voidset_bootstrap_compilation_request_handled() {
_instance->_bootstrap_compilation_request_handled = true;
}
// Compilation entry point for methods
virtualvoidcompile_method(ciEnv* env, ciMethod* target, int entry_bci, bool install_code, DirectiveSet* directive);
virtualvoidstopping_compiler_thread(CompilerThread* current);
virtualvoidon_empty_queue(CompileQueue* queue, CompilerThread* thread);
// Print compilation timers and statistics
virtualvoidprint_timers();
virtualboolis_intrinsic_supported(const methodHandle& method);
// Gets the number of methods that have been successfully compiled by
// a call to JVMCICompiler::compile_method().
intmethods_compiled() { return _methods_compiled; }
voidinc_methods_compiled();
// Called after a JVMCI upcall whose success is a measure of the
// JVMCI compiler's health. The value of `error` describes
// an error during the upcall, null if no error.
voidon_upcall(constchar* error, JVMCICompileState* compile_state=nullptr);
// Gets a value indicating JVMCI compilation activity on any thread.
// If successive calls to this method return a different value, then
// some degree of JVMCI compilation occurred between the calls.
intglobal_compilation_ticks() const { return _global_compilation_ticks; }
voidinc_global_compilation_ticks();
CodeInstallStats* code_install_stats(bool hosted) {
if (!hosted) {
return &_jit_code_installs;
} else {
return &_hosted_code_installs;
}
}
};
#endif// SHARE_JVMCI_JVMCICOMPILER_HPP