Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/aarch64/codegen/CallSnippet.hpp
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2019, 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
#ifndef ARM64CALLSNIPPET_INCL
24
#define ARM64CALLSNIPPET_INCL
25
26
#include "codegen/Snippet.hpp"
27
#include "env/VMJ9.h"
28
29
namespace TR { class CodeGenerator; }
30
class TR_J2IThunk;
31
32
extern void arm64CodeSync(uint8_t *codePointer, uint32_t codeSize);
33
34
namespace TR {
35
36
class ARM64CallSnippet : public TR::Snippet
37
{
38
uint8_t *callRA;
39
int32_t sizeOfArguments;
40
41
public:
42
43
ARM64CallSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s)
44
: TR::Snippet(cg, c, lab, false), sizeOfArguments(s), callRA(0)
45
{
46
}
47
48
virtual Kind getKind() { return IsCall; }
49
50
virtual uint8_t *emitSnippetBody();
51
52
virtual uint32_t getLength(int32_t estimatedSnippetStart);
53
54
int32_t getSizeOfArguments() {return sizeOfArguments;}
55
int32_t setSizeOfArguments(int32_t s) {return (sizeOfArguments = s);}
56
57
TR_RuntimeHelper getHelper();
58
59
uint8_t *getCallRA() {return callRA;}
60
uint8_t *setCallRA(uint8_t *ra) {return (callRA=ra);}
61
62
static uint8_t *generateVIThunk(TR::Node *callNode, int32_t argSize, TR::CodeGenerator *cg);
63
static TR_J2IThunk *generateInvokeExactJ2IThunk(TR::Node *callNode, int32_t argSize, TR::CodeGenerator *cg, char *signature);
64
};
65
66
class ARM64UnresolvedCallSnippet : public TR::ARM64CallSnippet
67
{
68
69
public:
70
71
ARM64UnresolvedCallSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s)
72
: TR::ARM64CallSnippet(cg, c, lab, s)
73
{
74
}
75
76
virtual Kind getKind() { return IsUnresolvedCall; }
77
78
virtual uint8_t *emitSnippetBody();
79
80
virtual uint32_t getLength(int32_t estimatedSnippetStart);
81
};
82
83
class ARM64VirtualSnippet : public TR::Snippet
84
{
85
TR::LabelSymbol *returnLabel;
86
int32_t sizeOfArguments;
87
88
public:
89
90
ARM64VirtualSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, TR::LabelSymbol *retl)
91
: TR::Snippet(cg, c, lab, true), sizeOfArguments(s), returnLabel(retl)
92
{
93
}
94
95
virtual Kind getKind() { return IsVirtual; }
96
97
virtual uint8_t *emitSnippetBody();
98
99
virtual uint32_t getLength(int32_t estimatedSnippetStart);
100
101
int32_t getSizeOfArguments() {return sizeOfArguments;}
102
int32_t setSizeOfArguments(int32_t s) {return (sizeOfArguments = s);}
103
104
TR::LabelSymbol *getReturnLabel() {return returnLabel;}
105
TR::LabelSymbol *setReturnLabel(TR::LabelSymbol *rl) {return (returnLabel=rl);}
106
};
107
108
class ARM64VirtualUnresolvedSnippet : public TR::ARM64VirtualSnippet
109
{
110
uint8_t *thunkAddress;
111
public:
112
113
ARM64VirtualUnresolvedSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, TR::LabelSymbol *retl)
114
: TR::ARM64VirtualSnippet(cg, c, lab, s, retl), thunkAddress(NULL)
115
{
116
}
117
118
ARM64VirtualUnresolvedSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, TR::LabelSymbol *retl, uint8_t *thunkPtr)
119
: TR::ARM64VirtualSnippet(cg, c, lab, s, retl), thunkAddress(thunkPtr)
120
{
121
}
122
123
virtual Kind getKind() { return IsVirtualUnresolved; }
124
125
virtual uint8_t *emitSnippetBody();
126
127
virtual uint32_t getLength(int32_t estimatedSnippetStart);
128
};
129
130
class ARM64InterfaceCallSnippet : public TR::ARM64VirtualSnippet
131
{
132
uint8_t *thunkAddress;
133
TR::LabelSymbol *_firstClassCacheSlotLabel;
134
TR::LabelSymbol *_firstBranchAddressCacheSlotLabel;
135
TR::LabelSymbol *_secondClassCacheSlotLabel;
136
TR::LabelSymbol *_secondBranchAddressCacheSlotLabel;
137
public:
138
139
ARM64InterfaceCallSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, TR::LabelSymbol *retl,
140
TR::LabelSymbol *firstClassCacheSlotLabel, TR::LabelSymbol *firstBranchAddressCacheSlotLabel,
141
TR::LabelSymbol *secondClassCacheSlotLabel, TR::LabelSymbol *secondBranchAddressCacheSlotLabel)
142
: TR::ARM64VirtualSnippet(cg, c, lab, s, retl), thunkAddress(NULL),
143
_firstClassCacheSlotLabel(firstClassCacheSlotLabel), _firstBranchAddressCacheSlotLabel(firstBranchAddressCacheSlotLabel),
144
_secondClassCacheSlotLabel(secondClassCacheSlotLabel), _secondBranchAddressCacheSlotLabel(secondBranchAddressCacheSlotLabel)
145
{
146
}
147
148
ARM64InterfaceCallSnippet(TR::CodeGenerator *cg, TR::Node *c, TR::LabelSymbol *lab, int32_t s, TR::LabelSymbol *retl,
149
TR::LabelSymbol *firstClassCacheSlotLabel, TR::LabelSymbol *firstBranchAddressCacheSlotLabel,
150
TR::LabelSymbol *secondClassCacheSlotLabel, TR::LabelSymbol *secondBranchAddressCacheSlotLabel, uint8_t *thunkPtr)
151
: TR::ARM64VirtualSnippet(cg, c, lab, s, retl), thunkAddress(thunkPtr),
152
_firstClassCacheSlotLabel(firstClassCacheSlotLabel), _firstBranchAddressCacheSlotLabel(firstBranchAddressCacheSlotLabel),
153
_secondClassCacheSlotLabel(secondClassCacheSlotLabel), _secondBranchAddressCacheSlotLabel(secondBranchAddressCacheSlotLabel)
154
{
155
}
156
157
TR::LabelSymbol *getFirstClassCacheSlotLabel() { return _firstClassCacheSlotLabel; }
158
TR::LabelSymbol *getFirstBranchAddressCacheSlotLabel() { return _firstBranchAddressCacheSlotLabel; }
159
TR::LabelSymbol *getSecondClassCacheSlotLabel() { return _secondClassCacheSlotLabel; }
160
TR::LabelSymbol *getSecondBranchAddressCacheSlotLabel() { return _secondBranchAddressCacheSlotLabel; }
161
virtual Kind getKind() { return IsInterfaceCall; }
162
163
virtual uint8_t *emitSnippetBody();
164
165
virtual uint32_t getLength(int32_t estimatedSnippetStart);
166
};
167
168
}
169
170
#endif
171
172