-
Notifications
You must be signed in to change notification settings - Fork 391
/
ConstantDataSnippet.hpp
321 lines (251 loc) · 10.9 KB
/
ConstantDataSnippet.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at http://eclipse.org/legal/epl-2.0
* or the Apache License, Version 2.0 which accompanies this distribution
* and is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License, v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception [1] and GNU General Public
* License, version 2 with the OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* 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
*******************************************************************************/
#ifndef S390CONSTANTDATASNIPPET_INCL
#define S390CONSTANTDATASNIPPET_INCL
#include "codegen/Snippet.hpp"
#include <stddef.h> // for NULL
#include <stdint.h> // for uint32_t, uint8_t, int32_t, etc
#include "compile/Compilation.hpp" // for comp, Compilation (ptr only)
#include "env/jittypes.h" // for uintptrj_t
#include "infra/Assert.hpp" // for TR_ASSERT
#include "OMRCodeGenerator.hpp"
class TR_Debug;
namespace TR { class CodeGenerator; }
namespace TR { class Instruction; }
namespace TR { class LabelSymbol; }
namespace TR { class Node; }
namespace TR { class Register; }
namespace TR { class Symbol; }
namespace TR { class SymbolReference; }
namespace TR { class UnresolvedDataSnippet; }
namespace TR {
/**
* ConstantDataSnippet is used to hold shared data
*/
class S390ConstantDataSnippet : public TR::Snippet
{
protected:
uint8_t _value[1<<TR_DEFAULT_DATA_SNIPPET_EXPONENT];
uint32_t _length;
TR::UnresolvedDataSnippet *_unresolvedDataSnippet;
TR::SymbolReference* _symbolReference;
uint32_t _reloType;
public:
S390ConstantDataSnippet(TR::CodeGenerator *cg, TR::Node *, void *c, uint16_t size);
virtual Kind getKind() { return IsConstantData; }
virtual uint32_t getConstantSize() { return _length; }
virtual int32_t getDataAs1Byte() { return *((int8_t *) &_value); }
virtual int32_t getDataAs2Bytes() { return *((int16_t *) &_value); }
virtual int32_t getDataAs4Bytes() { return *((int32_t *) &_value); }
virtual int64_t getDataAs8Bytes() { return *((int64_t *) &_value); }
virtual uint8_t * getRawData()
{
return _value;
}
void addMetaDataForCodeAddress(uint8_t *cursor);
virtual uint8_t *emitSnippetBody();
virtual uint32_t getLength(int32_t estimatedSnippetStart);
virtual uint32_t setLength(uint32_t length) { return _length=length; }
TR::UnresolvedDataSnippet* getUnresolvedDataSnippet() { return _unresolvedDataSnippet;}
TR::UnresolvedDataSnippet* setUnresolvedDataSnippet(TR::UnresolvedDataSnippet* uds)
{
return _unresolvedDataSnippet = uds;
}
TR::SymbolReference* getSymbolReference() { return _symbolReference;}
TR::SymbolReference* setSymbolReference(TR::SymbolReference* sr)
{
return _symbolReference = sr;
}
uint32_t getReloType() { return _reloType;}
uint32_t setReloType(uint32_t rt)
{
return _reloType = rt;
}
TR::Compilation* comp() { return TR::comp(); }
};
class S390ConstantInstructionSnippet : public TR::S390ConstantDataSnippet
{
TR::Instruction * _instruction;
public:
S390ConstantInstructionSnippet(TR::CodeGenerator *cg, TR::Node *, TR::Instruction *);
TR::Instruction * getInstruction() { return _instruction; }
Kind getKind() { return IsConstantInstruction; }
virtual uint32_t getLength(int32_t estimatedSnippetStart) { return 8; }
uint32_t getConstantSize() { return 8; }
virtual int64_t getDataAs8Bytes();
uint8_t * emitSnippetBody();
};
/**
* Create constant data snippet with method ep and complete method signature
*/
class S390EyeCatcherDataSnippet : public TR::S390ConstantDataSnippet
{
uint8_t * _value;
public:
S390EyeCatcherDataSnippet(TR::CodeGenerator *cg, TR::Node *);
uint8_t *emitSnippetBody();
Kind getKind() { return IsEyeCatcherData; }
};
/**
* WritableDataSnippet is used to hold patchable data
*/
class S390WritableDataSnippet : public TR::S390ConstantDataSnippet
{
public:
S390WritableDataSnippet(TR::CodeGenerator *cg, TR::Node *, void *c, uint16_t size);
virtual Kind getKind() { return IsWritableData; }
};
/**
* TargetAddress Snippet is used to hold address of snippet which exceed the branch limit
*/
class S390TargetAddressSnippet : public TR::Snippet
{
uintptrj_t _targetaddress;
TR::Snippet *_targetsnippet;
TR::Symbol *_targetsym;
TR::LabelSymbol *_targetlabel;
public:
S390TargetAddressSnippet(TR::CodeGenerator *cg, TR::Node *, TR::LabelSymbol *targetLabel);
S390TargetAddressSnippet(TR::CodeGenerator *cg, TR::Node *, TR::Snippet *s);
S390TargetAddressSnippet(TR::CodeGenerator *cg, TR::Node *, uintptrj_t addr);
S390TargetAddressSnippet(TR::CodeGenerator *cg, TR::Node *, TR::Symbol *sym);
TR::Snippet *getTargetSnippet() { return _targetsnippet; }
uintptrj_t getTargetAddress() { return _targetaddress; }
TR::Symbol *getTargetSym() { return _targetsym; }
TR::LabelSymbol *getTargetLabel() { return _targetlabel; }
virtual Kind getKind() { return IsTargetAddress; }
virtual uint8_t *emitSnippetBody();
virtual uint32_t getLength(int32_t estimatedSnippetStart);
};
class S390LookupSwitchSnippet : public TR::S390TargetAddressSnippet
{
public:
S390LookupSwitchSnippet(TR::CodeGenerator *cg, TR::Node* switchNode);
virtual Kind getKind() { return IsLookupSwitch; }
virtual uint8_t *emitSnippetBody();
virtual uint32_t getLength(int32_t estimatedSnippetStart);
};
class S390InterfaceCallDataSnippet : public TR::S390ConstantDataSnippet
{
TR::Instruction * _firstCLFI;
uint8_t _numInterfaceCallCacheSlots;
uint8_t* _codeRA;
uint8_t *thunkAddress;
bool _useCLFIandBRCL;
public:
S390InterfaceCallDataSnippet(TR::CodeGenerator *,
TR::Node *,
uint8_t,
bool useCLFIandBRCL = false);
S390InterfaceCallDataSnippet(TR::CodeGenerator *,
TR::Node *,
uint8_t,
uint8_t *,
bool useCLFIandBRCL = false);
virtual Kind getKind() { return IsInterfaceCallData; }
virtual uint8_t *emitSnippetBody();
virtual uint32_t getLength(int32_t estimatedSnippetStart);
int8_t getNumInterfaceCallCacheSlots() {return _numInterfaceCallCacheSlots;}
void setUseCLFIandBRCL(bool useCLFIandBRCL) {_useCLFIandBRCL = useCLFIandBRCL;}
bool isUseCLFIandBRCL() {return _useCLFIandBRCL;}
void setFirstCLFI(TR::Instruction* firstCLFI) { _firstCLFI = firstCLFI; }
TR::Instruction* getFirstCLFI() { return _firstCLFI;}
uint8_t* getCodeRA() { return _codeRA;}
uint8_t* setCodeRA(uint8_t *codeRA)
{
return _codeRA = codeRA;
}
virtual uint32_t getCallReturnAddressOffset();
virtual uint32_t getSingleDynamicSlotOffset();
virtual uint32_t getLastCachedSlotFieldOffset();
virtual uint32_t getFirstSlotFieldOffset();
virtual uint32_t getLastSlotFieldOffset();
virtual uint32_t getFirstSlotOffset();
virtual uint32_t getLastSlotOffset();
};
class S390JNICallDataSnippet : public TR::S390ConstantDataSnippet
{
/** Base register for this snippet */
TR::Register * _baseRegister;
//for JNI Callout frame
uintptrj_t _ramMethod;
uintptrj_t _JNICallOutFrameFlags;
TR::LabelSymbol * _returnFromJNICallLabel; //for savedCP slot
uintptrj_t _savedPC; // This is unused, and hence zero
uintptrj_t _tagBits;
// VMThread setup
uintptrj_t _pc;
uintptrj_t _literals;
uintptrj_t _jitStackFrameFlags;
//for releaseVMaccess
uintptrj_t _constReleaseVMAccessMask;
uintptrj_t _constReleaseVMAccessOutOfLineMask;
/** For CallNativeFunction */
uintptrj_t _targetAddress;
public:
S390JNICallDataSnippet(TR::CodeGenerator *,
TR::Node *);
virtual Kind getKind() { return IsJNICallData; }
virtual uint8_t *emitSnippetBody();
virtual void print(TR::FILE *, TR_Debug*);
void setBaseRegister(TR::Register * aValue){ _baseRegister = aValue; }
TR::Register * getBaseRegister() { return _baseRegister; }
void setRAMMethod(uintptrj_t aValue){ _ramMethod = aValue; }
void setJNICallOutFrameFlags(uintptrj_t aValue){ _JNICallOutFrameFlags = aValue; }
void setReturnFromJNICall( TR::LabelSymbol * aValue){ _returnFromJNICallLabel = aValue; }
void setSavedPC(uintptrj_t aValue){ _savedPC = aValue; }
void setTagBits(uintptrj_t aValue){ _tagBits = aValue; }
void setPC(uintptrj_t aValue){ _pc = aValue; }
void setLiterals(uintptrj_t aValue){ _literals = aValue; }
void setJitStackFrameFlags(uintptrj_t aValue){ _jitStackFrameFlags = aValue; }
void setConstReleaseVMAccessMask(uintptrj_t aValue){ _constReleaseVMAccessMask = aValue; }
void setConstReleaseVMAccessOutOfLineMask(uintptrj_t aValue){ _constReleaseVMAccessOutOfLineMask = aValue; }
void setTargetAddress(uintptrj_t aValue){ _targetAddress = aValue; }
uint32_t getJNICallOutFrameDataOffset(){ return 0; }
uint32_t getRAMMethodOffset(){ return 0; }
uint32_t getJNICallOutFrameFlagsOffset();
uint32_t getReturnFromJNICallOffset();
uint32_t getSavedPCOffset();
uint32_t getTagBitsOffset();
uint32_t getPCOffset();
uint32_t getLiteralsOffset();
uint32_t getJitStackFrameFlagsOffset();
uint32_t getConstReleaseVMAccessMaskOffset();
uint32_t getConstReleaseVMAccessOutOfLineMaskOffset();
uint32_t getTargetAddressOffset();
uint32_t getLength(int32_t estimatedSnippetStart);
};
class S390LabelTableSnippet : public TR::S390ConstantDataSnippet
{
public:
S390LabelTableSnippet(TR::CodeGenerator *cg, TR::Node *node, uint32_t size);
virtual Kind getKind() { return IsLabelTable; }
virtual uint8_t *emitSnippetBody();
virtual uint32_t getLength(int32_t estimatedSnippetStart);
int32_t getSize() { return _size; }
TR::LabelSymbol *getLabel(int32_t index) { TR_ASSERT(index < _size, "out of range, index %d, size %d",index,_size); return _labelTable[index]; }
TR::LabelSymbol *setLabel(int32_t index, TR::LabelSymbol *label) { TR_ASSERT(index < _size, "out of range, index %d, size %d",index,_size); return _labelTable[index] = label; }
private:
int32_t _size;
TR::LabelSymbol **_labelTable;
};
}
#endif