Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/z/codegen/S390J9CallSnippet.hpp
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
#ifndef TR_S390J9CALLSNIPPET_INCL
24
#define TR_S390J9CALLSNIPPET_INCL
25
26
#include "z/codegen/CallSnippet.hpp"
27
#include "z/codegen/ConstantDataSnippet.hpp"
28
#include "z/codegen/S390Instruction.hpp"
29
30
class TR_J2IThunk;
31
namespace TR { class CodeGenerator; }
32
namespace TR { class LabelSymbol; }
33
namespace TR { class Node; }
34
35
namespace TR {
36
37
class S390J9CallSnippet : public TR::S390CallSnippet
38
{
39
public:
40
41
S390J9CallSnippet(
42
TR::CodeGenerator *cg,
43
TR::Node *n,
44
TR::LabelSymbol *lab,
45
int32_t s) :
46
TR::S390CallSnippet(cg, n, lab, s)
47
{}
48
49
S390J9CallSnippet(
50
TR::CodeGenerator *cg,
51
TR::Node *n,
52
TR::LabelSymbol *lab,
53
TR::SymbolReference *symRef,
54
int32_t s) :
55
TR::S390CallSnippet(cg, n, lab, symRef, s) {}
56
57
58
static uint8_t *generateVIThunk(TR::Node *callNode, int32_t argSize, TR::CodeGenerator *cg);
59
static TR_J2IThunk *generateInvokeExactJ2IThunk(TR::Node *callNode, int32_t argSize, char* signature, TR::CodeGenerator *cg);
60
61
TR_RuntimeHelper getInterpretedDispatchHelper(TR::SymbolReference *methodSymRef, TR::DataType type);
62
63
uint8_t *generatePICBinary(uint8_t *cursor, TR::SymbolReference *glueRef);
64
uint32_t getPICBinaryLength();
65
virtual uint32_t getLength(int32_t estimatedSnippetStart);
66
67
virtual void print(TR::FILE *pOutFile, TR_Debug *debug);
68
69
virtual uint8_t *emitSnippetBody();
70
};
71
72
73
class S390UnresolvedCallSnippet : public TR::S390J9CallSnippet
74
{
75
76
public:
77
78
S390UnresolvedCallSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s)
79
: TR::S390J9CallSnippet(cg, c, lab, s)
80
{
81
}
82
83
virtual Kind getKind() { return IsUnresolvedCall; }
84
85
virtual uint8_t *emitSnippetBody();
86
87
virtual uint32_t getLength(int32_t estimatedSnippetStart);
88
};
89
90
91
class S390VirtualSnippet : public TR::S390J9CallSnippet
92
{
93
public:
94
95
S390VirtualSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s)
96
: TR::S390J9CallSnippet(cg, c, lab, s)
97
{
98
}
99
100
virtual Kind getKind() { return IsVirtual; }
101
102
virtual uint8_t *emitSnippetBody();
103
104
virtual uint32_t getLength(int32_t estimatedSnippetStart);
105
};
106
107
108
class S390VirtualUnresolvedSnippet : public TR::S390VirtualSnippet
109
{
110
void *thunkAddress;
111
112
public:
113
114
S390VirtualUnresolvedSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s)
115
: TR::S390VirtualSnippet(cg, c, lab, s), thunkAddress(NULL)
116
{
117
}
118
119
S390VirtualUnresolvedSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, void *thunkPtr)
120
: TR::S390VirtualSnippet(cg, c, lab, s), thunkAddress(thunkPtr)
121
{
122
}
123
124
virtual Kind getKind() { return IsVirtualUnresolved; }
125
126
virtual uint8_t *emitSnippetBody();
127
128
virtual uint32_t getLength(int32_t estimatedSnippetStart);
129
void* getJ2IThunkAddress() { return thunkAddress; }
130
131
TR::Instruction *patchVftInstruction;
132
TR::Instruction *indirectCallInstruction; // the BASR in the virtual dispatch sequence
133
134
TR::Instruction *setPatchVftInstruction(TR::Instruction *i) {return patchVftInstruction=i;}
135
TR::Instruction *getPatchVftInstruction() {return patchVftInstruction;}
136
137
TR::Instruction *setIndirectCallInstruction(TR::Instruction *i) {return indirectCallInstruction = i;}
138
TR::Instruction *getIndirectCallInstruction() {return indirectCallInstruction;}
139
};
140
141
class J9S390InterfaceCallDataSnippet : public TR::S390ConstantDataSnippet
142
{
143
TR::Instruction * _firstCLFI;
144
uint8_t _numInterfaceCallCacheSlots;
145
uint8_t* _codeRA;
146
void *_thunkAddress;
147
bool _useCLFIandBRCL;
148
149
public:
150
J9S390InterfaceCallDataSnippet(TR::CodeGenerator *,
151
TR::Node *,
152
uint8_t,
153
void *,
154
bool useCLFIandBRCL = false);
155
156
virtual Kind getKind() { return IsInterfaceCallData; }
157
virtual uint8_t *emitSnippetBody();
158
virtual uint32_t getLength(int32_t estimatedSnippetStart);
159
160
int8_t getNumInterfaceCallCacheSlots() {return _numInterfaceCallCacheSlots;}
161
162
void setUseCLFIandBRCL(bool useCLFIandBRCL) {_useCLFIandBRCL = useCLFIandBRCL;}
163
bool isUseCLFIandBRCL() {return _useCLFIandBRCL;}
164
165
void setFirstCLFI(TR::Instruction* firstCLFI) { _firstCLFI = firstCLFI; }
166
TR::Instruction* getFirstCLFI() { return _firstCLFI;}
167
168
uint8_t* getCodeRA() { return _codeRA;}
169
uint8_t* setCodeRA(uint8_t *codeRA)
170
{
171
return _codeRA = codeRA;
172
}
173
174
virtual uint32_t getCallReturnAddressOffset();
175
virtual uint32_t getSingleDynamicSlotOffset();
176
virtual uint32_t getLastCachedSlotFieldOffset();
177
virtual uint32_t getFirstSlotFieldOffset();
178
virtual uint32_t getLastSlotFieldOffset();
179
virtual uint32_t getFirstSlotOffset();
180
virtual uint32_t getLastSlotOffset();
181
};
182
183
class S390JNICallDataSnippet : public TR::S390ConstantDataSnippet
184
{
185
/** Base register for this snippet */
186
TR::Register * _baseRegister;
187
188
//for JNI Callout frame
189
uintptr_t _ramMethod;
190
uintptr_t _JNICallOutFrameFlags;
191
TR::LabelSymbol * _returnFromJNICallLabel; //for savedCP slot
192
uintptr_t _savedPC; // This is unused, and hence zero
193
uintptr_t _tagBits;
194
195
// VMThread setup
196
uintptr_t _pc;
197
uintptr_t _literals;
198
uintptr_t _jitStackFrameFlags;
199
200
//for releaseVMaccess
201
uintptr_t _constReleaseVMAccessMask;
202
uintptr_t _constReleaseVMAccessOutOfLineMask;
203
204
/** For CallNativeFunction */
205
uintptr_t _targetAddress;
206
207
208
public:
209
210
S390JNICallDataSnippet(TR::CodeGenerator *,
211
TR::Node *);
212
213
virtual Kind getKind() { return IsJNICallData; }
214
virtual uint8_t *emitSnippetBody();
215
virtual void print(TR::FILE *, TR_Debug*);
216
void setBaseRegister(TR::Register * aValue){ _baseRegister = aValue; }
217
TR::Register * getBaseRegister() { return _baseRegister; }
218
219
void setRAMMethod(uintptr_t aValue){ _ramMethod = aValue; }
220
void setJNICallOutFrameFlags(uintptr_t aValue){ _JNICallOutFrameFlags = aValue; }
221
void setReturnFromJNICall( TR::LabelSymbol * aValue){ _returnFromJNICallLabel = aValue; }
222
void setSavedPC(uintptr_t aValue){ _savedPC = aValue; }
223
void setTagBits(uintptr_t aValue){ _tagBits = aValue; }
224
225
void setPC(uintptr_t aValue){ _pc = aValue; }
226
void setLiterals(uintptr_t aValue){ _literals = aValue; }
227
void setJitStackFrameFlags(uintptr_t aValue){ _jitStackFrameFlags = aValue; }
228
229
void setConstReleaseVMAccessMask(uintptr_t aValue){ _constReleaseVMAccessMask = aValue; }
230
void setConstReleaseVMAccessOutOfLineMask(uintptr_t aValue){ _constReleaseVMAccessOutOfLineMask = aValue; }
231
void setTargetAddress(uintptr_t aValue){ _targetAddress = aValue; }
232
233
uint32_t getJNICallOutFrameDataOffset(){ return 0; }
234
uint32_t getRAMMethodOffset(){ return 0; }
235
uint32_t getJNICallOutFrameFlagsOffset();
236
uint32_t getReturnFromJNICallOffset();
237
uint32_t getSavedPCOffset();
238
uint32_t getTagBitsOffset();
239
240
uint32_t getPCOffset();
241
uint32_t getLiteralsOffset();
242
uint32_t getJitStackFrameFlagsOffset();
243
244
uint32_t getConstReleaseVMAccessMaskOffset();
245
uint32_t getConstReleaseVMAccessOutOfLineMaskOffset();
246
247
uint32_t getTargetAddressOffset();
248
249
uint32_t getLength(int32_t estimatedSnippetStart);
250
};
251
252
253
class S390InterfaceCallSnippet : public TR::S390VirtualSnippet
254
{
255
TR::J9S390InterfaceCallDataSnippet * _dataSnippet;
256
int8_t _numInterfaceCallCacheSlots;
257
bool _useCLFIandBRCL;
258
259
public:
260
261
S390InterfaceCallSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, int8_t n, void *thunkPtr, bool useCLFIandBRCL = false);
262
263
virtual Kind getKind() { return IsInterfaceCall; }
264
int8_t getNumInterfaceCallCacheSlots() {return _numInterfaceCallCacheSlots;}
265
void setUseCLFIandBRCL(bool useCLFIandBRCL) {
266
_useCLFIandBRCL = useCLFIandBRCL;
267
if (getDataConstantSnippet() != NULL)
268
{
269
getDataConstantSnippet()->setUseCLFIandBRCL(useCLFIandBRCL);
270
}
271
}
272
bool isUseCLFIandBRCL() {return _useCLFIandBRCL;}
273
274
TR::J9S390InterfaceCallDataSnippet *getDataConstantSnippet() { return _dataSnippet; }
275
TR::J9S390InterfaceCallDataSnippet *setDataConstantSnippet(TR::J9S390InterfaceCallDataSnippet *snippet)
276
{
277
return _dataSnippet = snippet;
278
}
279
280
virtual uint32_t getLength(int32_t estimatedSnippetStart);
281
virtual uint8_t *emitSnippetBody();
282
283
};
284
}
285
286
#endif
287
288