- Notifications
You must be signed in to change notification settings - Fork 5.8k
/
Copy pathcompilerThread.hpp
125 lines (101 loc) · 4.25 KB
/
compilerThread.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
/*
* Copyright (c) 2021, 2025, 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_COMPILER_COMPILERTHREAD_HPP
#defineSHARE_COMPILER_COMPILERTHREAD_HPP
#include"runtime/javaThread.hpp"
classAbstractCompiler;
classArenaStatCounter;
classBufferBlob;
classciEnv;
classCompilerThread;
classCompileLog;
classCompileTask;
classCompileQueue;
classCompilerCounters;
classIdealGraphPrinter;
// A thread used for Compilation.
classCompilerThread : publicJavaThread {
friendclassVMStructs;
JVMCI_ONLY(friendclassCompilerThreadCanCallJava;)
private:
CompilerCounters* _counters;
ciEnv* _env;
CompileLog* _log;
CompileTask* volatile _task; // print_threads_compiling can read this concurrently.
CompileQueue* _queue;
BufferBlob* _buffer_blob;
bool _can_call_java;
AbstractCompiler* _compiler;
TimeStamp _idle_time;
ArenaStatCounter* _arena_stat;
public:
static CompilerThread* current() {
returnCompilerThread::cast(JavaThread::current());
}
static CompilerThread* cast(Thread* t) {
assert(t->is_Compiler_thread(), "incorrect cast to CompilerThread");
returnstatic_cast<CompilerThread*>(t);
}
CompilerThread(CompileQueue* queue, CompilerCounters* counters);
~CompilerThread();
boolis_Compiler_thread() const { returntrue; }
virtualboolcan_call_java() const { return _can_call_java; }
// Returns true if this CompilerThread is hidden from JVMTI and FlightRecorder. C1 and C2 are
// always hidden but JVMCI compiler threads might be hidden.
virtualboolis_hidden_from_external_view() const;
voidset_compiler(AbstractCompiler* c);
AbstractCompiler* compiler() const { return _compiler; }
CompileQueue* queue() const { return _queue; }
CompilerCounters* counters() const { return _counters; }
ArenaStatCounter* arena_stat() const { return _arena_stat; }
voidset_arenastat(ArenaStatCounter* v) { _arena_stat = v; }
// Get/set the thread's compilation environment.
ciEnv* env() { return _env; }
voidset_env(ciEnv* env) { _env = env; }
BufferBlob* get_buffer_blob() const { return _buffer_blob; }
voidset_buffer_blob(BufferBlob* b) { _buffer_blob = b; }
// Get/set the thread's logging information
CompileLog* log() { return _log; }
voidinit_log(CompileLog* log) {
// Set once, for good.
assert(_log == nullptr, "set only once");
_log = log;
}
voidstart_idle_timer() { _idle_time.update(); }
jlong idle_time_millis() {
returnTimeHelper::counter_to_millis(_idle_time.ticks_since_update());
}
#ifndef PRODUCT
private:
IdealGraphPrinter *_ideal_graph_printer;
public:
IdealGraphPrinter *ideal_graph_printer() { return _ideal_graph_printer; }
voidset_ideal_graph_printer(IdealGraphPrinter *n) { _ideal_graph_printer = n; }
#endif
// Get/set the thread's current task
CompileTask* task() { return _task; }
voidset_task(CompileTask* task) { _task = task; }
staticvoidthread_entry(JavaThread* thread, TRAPS);
};
#endif// SHARE_COMPILER_COMPILERTHREAD_HPP