Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/x/codegen/CheckFailureSnippet.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 X86CHECKFAILURESNIPPET_INCL
24
#define X86CHECKFAILURESNIPPET_INCL
25
26
#include "codegen/Snippet.hpp"
27
28
#include <stdint.h>
29
#include "codegen/Instruction.hpp"
30
#include "compile/Compilation.hpp"
31
#include "control/Options.hpp"
32
#include "il/SymbolReference.hpp"
33
34
namespace TR { class CodeGenerator; }
35
namespace TR { class LabelSymbol; }
36
namespace TR { class Symbol; }
37
38
#define TR_BREAKONTHROW_NPE 1
39
#define TR_BREAKONTHROW_AIOB 2
40
41
namespace TR {
42
43
class X86CheckFailureSnippet : public TR::Snippet
44
{
45
TR::SymbolReference *_destination;
46
TR::Instruction *_checkInstruction;
47
bool _requiresFPstackPop;
48
uint8_t _breakOnThrowType;
49
50
public:
51
52
X86CheckFailureSnippet(
53
TR::CodeGenerator * cg,
54
TR::SymbolReference * dest,
55
TR::LabelSymbol * lab,
56
TR::Instruction * checkInstruction,
57
bool popFPstack = false,
58
uint8_t breakOnThrowType = 0)
59
: TR::Snippet(cg, checkInstruction->getNode(), lab, dest->canCauseGC()),
60
_destination(dest),
61
_checkInstruction(checkInstruction),
62
_requiresFPstackPop(popFPstack),
63
_breakOnThrowType(breakOnThrowType)
64
{
65
// No registers preserved at this call
66
//
67
gcMap().setGCRegisterMask(0);
68
checkBreakOnThrowOption();
69
}
70
71
virtual Kind getKind() { return IsCheckFailure; }
72
73
TR::SymbolReference *getDestination() {return _destination;}
74
TR::SymbolReference *setDestination(TR::SymbolReference *s) {return (_destination = s);}
75
76
TR::Instruction *getCheckInstruction() {return _checkInstruction;}
77
TR::Instruction *setCheckInstruction(TR::Instruction *ci) {return (_checkInstruction = ci);}
78
79
bool getRequiredFPstackPop() { return _requiresFPstackPop; }
80
81
virtual uint8_t *emitSnippetBody();
82
uint8_t *emitCheckFailureSnippetBody(uint8_t *buffer);
83
84
virtual uint32_t getLength(int32_t estimatedSnippetStart);
85
void checkBreakOnThrowOption();
86
87
};
88
89
90
class X86BoundCheckWithSpineCheckSnippet : public TR::X86CheckFailureSnippet
91
{
92
TR::LabelSymbol *_restartLabel;
93
94
public:
95
96
X86BoundCheckWithSpineCheckSnippet(
97
TR::CodeGenerator *cg,
98
TR::SymbolReference *bndchkSymRef,
99
TR::LabelSymbol *snippetLabel,
100
TR::LabelSymbol *restartLabel,
101
TR::Instruction *checkInstruction,
102
bool popFPstack = false) :
103
TR::X86CheckFailureSnippet(
104
cg,
105
bndchkSymRef,
106
snippetLabel,
107
checkInstruction,
108
popFPstack),
109
_restartLabel(restartLabel)
110
{
111
}
112
113
virtual Kind getKind() { return IsBoundCheckWithSpineCheck; }
114
115
virtual uint8_t *emitSnippetBody();
116
117
virtual uint32_t getLength(int32_t estimatedSnippetStart);
118
119
};
120
121
122
// This is not the final shape of this snippet. Its just here to
123
// make everything compile.
124
//
125
class X86SpineCheckSnippet : public TR::X86CheckFailureSnippet
126
{
127
TR::LabelSymbol *_restartLabel;
128
129
public:
130
131
X86SpineCheckSnippet(
132
TR::CodeGenerator *cg,
133
TR::SymbolReference *bndchkSymRef,
134
TR::LabelSymbol *snippetLabel,
135
TR::LabelSymbol *restartLabel,
136
TR::Instruction *checkInstruction,
137
bool popFPstack = false) :
138
TR::X86CheckFailureSnippet(
139
cg,
140
bndchkSymRef,
141
snippetLabel,
142
checkInstruction,
143
popFPstack),
144
_restartLabel(restartLabel)
145
{
146
}
147
148
virtual Kind getKind() { return IsSpineCheck; }
149
150
virtual uint8_t *emitSnippetBody();
151
152
virtual uint32_t getLength(int32_t estimatedSnippetStart);
153
154
};
155
156
157
class X86CheckFailureSnippetWithResolve : public TR::X86CheckFailureSnippet
158
{
159
TR::SymbolReference *_dataSymbolReference;
160
flags8_t _flags;
161
TR_RuntimeHelper _helper;
162
uint8_t _numLiveX87FPRs;
163
164
enum
165
{
166
hasLiveXMMRs = 0x04
167
};
168
169
public:
170
171
X86CheckFailureSnippetWithResolve(
172
TR::CodeGenerator *cg,
173
TR::SymbolReference *dest,
174
TR::SymbolReference *dataSymbolRef,
175
TR_RuntimeHelper resolverCall,
176
TR::LabelSymbol *snippetLabel,
177
TR::Instruction *checkInstruction,
178
bool popFPstack = false) :
179
TR::X86CheckFailureSnippet(
180
cg,
181
dest,
182
snippetLabel,
183
checkInstruction),
184
_dataSymbolReference(dataSymbolRef),
185
_helper(resolverCall),
186
_numLiveX87FPRs(0),
187
_flags(0)
188
{
189
}
190
191
virtual Kind getKind() { return IsCheckFailureWithResolve; }
192
193
TR::Symbol *getDataSymbol() {return _dataSymbolReference->getSymbol();}
194
195
TR::SymbolReference *getDataSymbolReference() {return _dataSymbolReference;}
196
TR::SymbolReference *setDataSymbolReference(TR::SymbolReference *sr) {return (_dataSymbolReference = sr);}
197
198
TR_RuntimeHelper getHelper() { return _helper; }
199
200
virtual uint8_t *emitSnippetBody();
201
202
virtual uint32_t getLength(int32_t estimatedSnippetStart);
203
204
bool getHasLiveXMMRs() {return _flags.testAny(hasLiveXMMRs);}
205
void setHasLiveXMMRs() {_flags.set(hasLiveXMMRs);}
206
void resetHasLiveXMMRs() {_flags.reset(hasLiveXMMRs);}
207
void setHasLiveXMMRs(bool b) {_flags.set(hasLiveXMMRs, b);}
208
209
uint8_t setNumLiveX87Registers(uint8_t l) {return (_numLiveX87FPRs = l);}
210
uint8_t getNumLiveX87Registers() {return _numLiveX87FPRs;}
211
212
};
213
214
}
215
216
#endif
217
218