Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/env/J9JitMemory.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 <stdint.h>
24
#include "jilconsts.h"
25
#include "compile/Compilation.hpp"
26
#include "env/jittypes.h"
27
#include "env/VerboseLog.hpp"
28
#include "infra/Monitor.hpp"
29
#include "runtime/RuntimeAssumptions.hpp"
30
#include "control/CompilationRuntime.hpp"
31
#include "control/CompilationThread.hpp"
32
#include "env/J9JitMemory.hpp"
33
#include "env/VMJ9.h"
34
35
void preventAllocationOfBTLMemory(J9MemorySegment * &segment, J9JavaVM * javaVM, TR_AllocationKind segmentType, bool freeSegmentOverride)
36
{
37
#if defined(J9ZOS390)
38
// Special code for zOS. If we allocated BTL memory (first 16MB), then we must
39
// release this segment, failing the compilation and forcing to use only one compilation thread
40
if (TR::Options::getCmdLineOptions()->getOption(TR_DontAllocateScratchBTL) &&
41
segment && ((uintptr_t)(segment->heapBase) < (uintptr_t)(1 << 24)))
42
{
43
// If applicable, reduce the number of compilation threads to 1
44
TR::CompilationInfo * compInfo = TR::CompilationInfo::get((J9JITConfig*)jitConfig);
45
if (compInfo)
46
{
47
if (!compInfo->getRampDownMCT())
48
{
49
compInfo->setRampDownMCT();
50
if (TR::Options::getCmdLineOptions()->getVerboseOption(TR_VerboseCompilationThreads))
51
{
52
TR_VerboseLog::writeLineLocked(TR_Vlog_INFO, "t=%u setRampDownMCT because JIT allocated BTL memory", (uint32_t)compInfo->getPersistentInfo()->getElapsedTime());
53
}
54
}
55
else
56
{
57
// Perhaps we should consider lowering the compilation aggressiveness
58
if (!TR::Options::getAOTCmdLineOptions()->getOption(TR_NoOptServer))
59
{
60
TR::Options::getAOTCmdLineOptions()->setOption(TR_NoOptServer);
61
}
62
if (!TR::Options::getJITCmdLineOptions()->getOption(TR_NoOptServer))
63
{
64
TR::Options::getJITCmdLineOptions()->setOption(TR_NoOptServer);
65
}
66
}
67
68
// For scratch memory refuse to return memory below the line. Free the segment and let the compilation fail
69
// Compilation will be retried at lower opt level.
70
if (freeSegmentOverride || segmentType == heapAlloc || segmentType == stackAlloc)
71
{
72
J9VMThread *crtVMThread = javaVM->internalVMFunctions->currentVMThread(javaVM);
73
if (compInfo->getCompInfoForThread(crtVMThread))
74
{
75
javaVM->internalVMFunctions->freeMemorySegment(javaVM, segment, TRUE);
76
segment = NULL;
77
}
78
}
79
}
80
}
81
#endif // defined(J9ZOS390)
82
}
83
84