Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/env/J9CompilerEnv.cpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2021 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
7
* or the Apache License, Version 2.0 which accompanies this distribution and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
20
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
21
*******************************************************************************/
22
23
#include "env/CompilerEnv.hpp"
24
#include "env/RawAllocator.hpp"
25
#include "env/defines.h"
26
#include "env/CPU.hpp"
27
#include "j9.h"
28
#if defined(J9VM_OPT_JITSERVER)
29
#include "control/CompilationRuntime.hpp"
30
#endif /* defined(J9VM_OPT_JITSERVER) */
31
32
J9::CompilerEnv::CompilerEnv(J9JavaVM *vm, TR::RawAllocator raw, const TR::PersistentAllocatorKit &persistentAllocatorKit) :
33
#if defined(TR_HOST_ARM)
34
OMR::CompilerEnvConnector(raw, persistentAllocatorKit),
35
#else
36
OMR::CompilerEnvConnector(raw, persistentAllocatorKit, OMRPORT_FROM_J9PORT(vm->portLibrary)),
37
#endif
38
portLib(vm->portLibrary),
39
javaVM(vm)
40
{
41
}
42
43
void
44
J9::CompilerEnv::initializeTargetEnvironment()
45
{
46
OMR::CompilerEnvConnector::initializeTargetEnvironment();
47
}
48
49
/**
50
* \brief Determines whether methods are compiled and the generated code simply
51
* "tossed" without execution.
52
* \return true if compiles have been requested to be tossed; false otherwise.
53
*/
54
bool
55
J9::CompilerEnv::isCodeTossed()
56
{
57
J9JITConfig *jitConfig = javaVM->jitConfig;
58
59
if (jitConfig == NULL)
60
{
61
return false;
62
}
63
64
if (jitConfig->runtimeFlags & J9JIT_TOSS_CODE)
65
{
66
return true;
67
}
68
69
return false;
70
}
71
72
TR::PersistentAllocator &
73
J9::CompilerEnv::persistentAllocator()
74
{
75
#if defined(J9VM_OPT_JITSERVER)
76
if (J9::PersistentInfo::_remoteCompilationMode == JITServer::SERVER)
77
{
78
auto compInfoPT = TR::compInfoPT;
79
if (compInfoPT && compInfoPT->getPerClientPersistentMemory())
80
{
81
// Returns per-client allocator after enterPerClientPersistentAllocator() is called
82
return compInfoPT->getPerClientPersistentMemory()->_persistentAllocator.get();
83
}
84
}
85
#endif
86
return OMR::CompilerEnv::persistentAllocator();
87
}
88
89
TR_PersistentMemory *
90
J9::CompilerEnv::persistentMemory()
91
{
92
#if defined(J9VM_OPT_JITSERVER)
93
if (J9::PersistentInfo::_remoteCompilationMode == JITServer::SERVER)
94
{
95
auto compInfoPT = TR::compInfoPT;
96
if (compInfoPT && compInfoPT->getPerClientPersistentMemory())
97
{
98
// Returns per-client persistent memory after enterPerClientPersistentAllocator() is called
99
return compInfoPT->getPerClientPersistentMemory();
100
}
101
}
102
#endif
103
return OMR::CompilerEnv::persistentMemory();
104
}
105
106
#if defined(J9VM_OPT_JITSERVER)
107
108
TR::PersistentAllocator &
109
J9::CompilerEnv::persistentGlobalAllocator()
110
{
111
return OMR::CompilerEnv::persistentAllocator();
112
}
113
114
TR_PersistentMemory *
115
J9::CompilerEnv::persistentGlobalMemory()
116
{
117
return OMR::CompilerEnv::persistentMemory();
118
}
119
120
#endif /* defined(J9VM_OPT_JITSERVER) */
121
122