Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/x/i386/codegen/J9CodeGenerator.cpp
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2020 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 "codegen/CodeGenerator.hpp"
24
#include "codegen/CodeGenerator_inlines.hpp"
25
#include "codegen/X86PrivateLinkage.hpp"
26
#include "compile/Compilation.hpp"
27
#include "x/codegen/X86HelperLinkage.hpp"
28
#include "codegen/IA32PrivateLinkage.hpp"
29
#include "codegen/IA32J9SystemLinkage.hpp"
30
#include "codegen/IA32JNILinkage.hpp"
31
#include "codegen/Linkage_inlines.hpp"
32
#include "il/Node_inlines.hpp"
33
34
void
35
J9::X86::I386::CodeGenerator::initialize()
36
{
37
self()->J9::X86::CodeGenerator::initialize();
38
}
39
40
41
TR::Linkage *
42
J9::X86::I386::CodeGenerator::createLinkage(TR_LinkageConventions lc)
43
{
44
TR::Compilation *comp = self()->comp();
45
TR::Linkage *linkage = NULL;
46
47
switch (lc)
48
{
49
case TR_CHelper:
50
linkage = new (self()->trHeapMemory()) J9::X86::HelperLinkage(self());
51
break;
52
case TR_Helper:
53
case TR_Private:
54
{
55
J9::X86::PrivateLinkage *p = NULL;
56
p = new (self()->trHeapMemory()) J9::X86::I386::PrivateLinkage(self());
57
p->IPicParameters.roundedSizeOfSlot = 6+2+5+2+1;
58
p->IPicParameters.defaultNumberOfSlots = 2;
59
p->IPicParameters.defaultSlotAddress = -1;
60
p->VPicParameters.roundedSizeOfSlot = 6+2+5+2+1;
61
p->VPicParameters.defaultNumberOfSlots = 1;
62
p->VPicParameters.defaultSlotAddress = -1;
63
linkage = p;
64
}
65
break;
66
67
case TR_J9JNILinkage:
68
if (comp->target().isWindows() || comp->target().isLinux())
69
{
70
linkage = new (self()->trHeapMemory()) J9::X86::I386::JNILinkage(self());
71
}
72
else
73
{
74
TR_ASSERT(0, "linkage not supported: %d\n", lc);
75
linkage = NULL;
76
}
77
break;
78
79
case TR_System:
80
if (comp->target().isWindows() || comp->target().isLinux())
81
{
82
linkage = new (self()->trHeapMemory()) TR::IA32J9SystemLinkage(self());
83
}
84
else
85
{
86
TR_ASSERT(0, "linkage not supported: %d\n", lc);
87
linkage = NULL;
88
}
89
break;
90
91
default :
92
TR_ASSERT(0, "\nTestarossa error: Illegal linkage convention %d\n", lc);
93
}
94
95
self()->setLinkage(lc, linkage);
96
return linkage;
97
}
98
99
100
void
101
J9::X86::I386::CodeGenerator::lowerTreesPreTreeTopVisit(TR::TreeTop *tt, vcount_t visitCount)
102
{
103
J9::X86::CodeGenerator::lowerTreesPreTreeTopVisit(tt, visitCount);
104
105
TR::Node *node = tt->getNode();
106
107
// On IA32 there are a reduced number of registers available on system
108
// linkage dispatch sequences, so some kinds of expressions can't be
109
// evaluated at that point. We must extract them into their own treetops
110
// to satisfy the required register dependencies.
111
//
112
if (node->getOpCodeValue() == TR::treetop)
113
{
114
TR::Node *child = node->getFirstChild();
115
116
if ((child->getOpCode().isCall() && child->getSymbol()->getMethodSymbol() &&
117
(child->isPreparedForDirectJNI() ||
118
child->getSymbol()->getMethodSymbol()->isSystemLinkageDispatch())))
119
{
120
self()->setRemoveRegisterHogsInLowerTreesWalk();
121
}
122
}
123
124
}
125
126
127
void
128
J9::X86::I386::CodeGenerator::lowerTreesPostTreeTopVisit(TR::TreeTop *tt, vcount_t visitCount)
129
{
130
J9::X86::CodeGenerator::lowerTreesPostTreeTopVisit(tt, visitCount);
131
132
TR::Node *node = tt->getNode();
133
134
// On IA32 there are a reduced number of registers available on system
135
// linkage dispatch sequences, so some kinds of expressions can't be
136
// evaluated at that point. We must extract them into their own treetops
137
// to satisfy the required register dependencies.
138
//
139
if (node->getOpCodeValue() == TR::treetop)
140
{
141
TR::Node *child = node->getFirstChild();
142
143
if ((child->getOpCode().isCall() && child->getSymbol()->getMethodSymbol() &&
144
(child->isPreparedForDirectJNI() ||
145
child->getSymbol()->getMethodSymbol()->isSystemLinkageDispatch())))
146
{
147
self()->resetRemoveRegisterHogsInLowerTreesWalk();
148
}
149
}
150
151
}
152
153
154
void
155
J9::X86::I386::CodeGenerator::lowerTreesPreChildrenVisit(TR::Node * parent, TR::TreeTop * treeTop, vcount_t visitCount)
156
{
157
J9::X86::CodeGenerator::lowerTreesPreChildrenVisit(parent, treeTop, visitCount);
158
159
}
160
161
162
void
163
J9::X86::I386::CodeGenerator::lowerTreesPostChildrenVisit(TR::Node * parent, TR::TreeTop * treeTop, vcount_t visitCount)
164
{
165
J9::X86::CodeGenerator::lowerTreesPostChildrenVisit(parent, treeTop, visitCount);
166
167
}
168
169