Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/codegen/J9CodeGenPhase.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
#if defined(J9ZOS390)
24
//On zOS XLC linker can't handle files with same name at link time
25
//This workaround with pragma is needed. What this does is essentially
26
//give a different name to the codesection (csect) for this file. So it
27
//doesn't conflict with another file with same name.
28
29
#pragma csect(CODE,"TRJ9CGPhase#C")
30
#pragma csect(STATIC,"TRJ9CGPhase#S")
31
#pragma csect(TEST,"TRJ9CGPhase#T")
32
#endif
33
34
#include "codegen/CodeGenPhase.hpp"
35
#include "codegen/CodeGenerator.hpp"
36
#include "compile/Compilation.hpp"
37
#include "compile/Method.hpp"
38
#include "il/Block.hpp"
39
#include "optimizer/SequentialStoreSimplifier.hpp"
40
#include "env/VMJ9.h"
41
42
#ifdef TR_TARGET_S390
43
#include "codegen/InMemoryLoadStoreMarking.hpp"
44
#endif
45
46
// to decide if asyncchecks should be inserted at method exits
47
#define BYTECODESIZE_THRESHOLD_FOR_ASYNCCHECKS 300
48
49
void
50
J9::CodeGenPhase::reportPhase(PhaseValue phase)
51
{
52
TR_J9VMBase *fej9 = (TR_J9VMBase *)(_cg->comp()->fe());
53
fej9->reportCodeGeneratorPhase(phase);
54
_currentPhase = phase;
55
}
56
57
int
58
J9::CodeGenPhase::getNumPhases()
59
{
60
return static_cast<int>(TR::CodeGenPhase::LastJ9Phase);
61
}
62
63
void
64
J9::CodeGenPhase::performFixUpProfiledInterfaceGuardTestPhase(TR::CodeGenerator *cg, TR::CodeGenPhase *phase)
65
{
66
cg->fixUpProfiledInterfaceGuardTest();
67
}
68
69
void
70
J9::CodeGenPhase::performAllocateLinkageRegistersPhase(TR::CodeGenerator * cg, TR::CodeGenPhase * phase)
71
{
72
TR::Compilation * comp = cg->comp();
73
if (!comp->getOption(TR_DisableLinkageRegisterAllocation))
74
cg->allocateLinkageRegisters();
75
}
76
77
78
void
79
J9::CodeGenPhase::performPopulateOSRBufferPhase(TR::CodeGenerator * cg, TR::CodeGenPhase * phase)
80
{
81
phase->reportPhase(PopulateOSRBufferPhase);
82
cg->populateOSRBuffer();
83
}
84
85
86
void
87
J9::CodeGenPhase::performMoveUpArrayLengthStoresPhase(TR::CodeGenerator * cg, TR::CodeGenPhase * phase)
88
{
89
phase->reportPhase(MoveUpArrayLengthStoresPhase);
90
cg->moveUpArrayLengthStores(cg->comp()->getStartBlock()->getEntry());
91
}
92
93
void
94
J9::CodeGenPhase::performInsertEpilogueYieldPointsPhase(TR::CodeGenerator * cg, TR::CodeGenPhase * phase)
95
{
96
TR::Compilation * comp = cg->comp();
97
phase->reportPhase(InsertEpilogueYieldPointsPhase);
98
99
// insert asyncchecks for non-loopy large methods that contain no calls
100
// (important for sunflow where the second hottest method is one such)
101
//
102
// FIXME: the value for methodContainsCalls is not computed until
103
// after the main tree traversal (below). However, we can't move
104
// this code after the loop because the inserted yield points need
105
// to be lowered by the same loop.
106
//
107
if ((comp->getCurrentMethod()->maxBytecodeIndex() >= BYTECODESIZE_THRESHOLD_FOR_ASYNCCHECKS) &&
108
!comp->mayHaveLoops() &&
109
comp->getCurrentMethod()->convertToMethod()->methodType() == TR::Method::J9 && // FIXME: enable for ruby and python
110
comp->getOSRMode() != TR::involuntaryOSR)
111
{
112
cg->insertEpilogueYieldPoints();
113
}
114
}
115
116
void
117
J9::CodeGenPhase::performCompressedReferenceRematerializationPhase(TR::CodeGenerator * cg, TR::CodeGenPhase *)
118
{
119
cg->compressedReferenceRematerialization();
120
}
121
122
const char *
123
J9::CodeGenPhase::getName()
124
{
125
return TR::CodeGenPhase::getName(_currentPhase);
126
}
127
128
const char *
129
J9::CodeGenPhase::getName(TR::CodeGenPhase::PhaseValue phase)
130
{
131
switch (phase)
132
{
133
case AllocateLinkageRegisters:
134
return "AllocateLinkageRegisters";
135
case PopulateOSRBufferPhase:
136
return "PopulateOSRBuffer";
137
case MoveUpArrayLengthStoresPhase:
138
return "MoveUpArrayLengthStores";
139
case InsertEpilogueYieldPointsPhase:
140
return "InsertEpilogueYieldPoints";
141
case CompressedReferenceRematerializationPhase:
142
return "CompressedReferenceRematerialization";
143
case IdentifyUnneededByteConvsPhase:
144
return "IdentifyUnneededByteConvsPhase";
145
case FixUpProfiledInterfaceGuardTest:
146
return "FixUpProfiledInterfaceGuardTest";
147
default:
148
return OMR::CodeGenPhaseConnector::getName(phase);
149
}
150
}
151
152
void
153
J9::CodeGenPhase::performIdentifyUnneededByteConvsPhase(TR::CodeGenerator * cg, TR::CodeGenPhase * phase)
154
{
155
cg->identifyUnneededByteConvNodes();
156
}
157
158
159
160