Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/compiler/compilerThread.cpp
40930 views
1
/*
2
* Copyright (c) 2021, 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
25
#include "precompiled.hpp"
26
#include "compiler/compileBroker.hpp"
27
#include "compiler/compileTask.hpp"
28
#include "compiler/compilerThread.hpp"
29
#include "runtime/sweeper.hpp"
30
#include "runtime/thread.inline.hpp"
31
32
// Create a CompilerThread
33
CompilerThread::CompilerThread(CompileQueue* queue,
34
CompilerCounters* counters)
35
: JavaThread(&CompilerThread::thread_entry) {
36
_env = NULL;
37
_log = NULL;
38
_task = NULL;
39
_queue = queue;
40
_counters = counters;
41
_buffer_blob = NULL;
42
_compiler = NULL;
43
44
// Compiler uses resource area for compilation, let's bias it to mtCompiler
45
resource_area()->bias_to(mtCompiler);
46
47
#ifndef PRODUCT
48
_ideal_graph_printer = NULL;
49
#endif
50
}
51
52
CompilerThread::~CompilerThread() {
53
// Delete objects which were allocated on heap.
54
delete _counters;
55
}
56
57
void CompilerThread::thread_entry(JavaThread* thread, TRAPS) {
58
assert(thread->is_Compiler_thread(), "must be compiler thread");
59
CompileBroker::compiler_thread_loop();
60
}
61
62
bool CompilerThread::can_call_java() const {
63
return _compiler != NULL && _compiler->is_jvmci();
64
}
65
66
// Create sweeper thread
67
CodeCacheSweeperThread::CodeCacheSweeperThread()
68
: JavaThread(&CodeCacheSweeperThread::thread_entry) {
69
_scanned_compiled_method = NULL;
70
}
71
72
void CodeCacheSweeperThread::thread_entry(JavaThread* thread, TRAPS) {
73
NMethodSweeper::sweeper_loop();
74
}
75
76
void CodeCacheSweeperThread::oops_do_no_frames(OopClosure* f, CodeBlobClosure* cf) {
77
JavaThread::oops_do_no_frames(f, cf);
78
if (_scanned_compiled_method != NULL && cf != NULL) {
79
// Safepoints can occur when the sweeper is scanning an nmethod so
80
// process it here to make sure it isn't unloaded in the middle of
81
// a scan.
82
cf->do_code_blob(_scanned_compiled_method);
83
}
84
}
85
86
void CodeCacheSweeperThread::nmethods_do(CodeBlobClosure* cf) {
87
JavaThread::nmethods_do(cf);
88
if (_scanned_compiled_method != NULL && cf != NULL) {
89
// Safepoints can occur when the sweeper is scanning an nmethod so
90
// process it here to make sure it isn't unloaded in the middle of
91
// a scan.
92
cf->do_code_blob(_scanned_compiled_method);
93
}
94
}
95
96
97