Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/x/codegen/J9UnresolvedDataSnippet.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 J9_X86UNRESOLVEDDATASNIPPET_INCL
24
#define J9_X86UNRESOLVEDDATASNIPPET_INCL
25
26
/*
27
* The following #define and typedef must appear before any #includes in this file
28
*/
29
#ifndef J9_UNRESOLVEDDATASNIPPET_CONNECTOR
30
#define J9_UNRESOLVEDDATASNIPPET_CONNECTOR
31
namespace J9 { namespace X86 { class UnresolvedDataSnippet; } }
32
namespace J9 { typedef J9::X86::UnresolvedDataSnippet UnresolvedDataSnippetConnector; }
33
#else
34
#error J9::X86::UnresolvedDataSnippet expected to be a primary connector, but a J9 connector is already defined
35
#endif
36
37
38
#include "compiler/codegen/J9UnresolvedDataSnippet.hpp"
39
40
#include <stdint.h>
41
#include "codegen/CodeGenerator.hpp"
42
#include "il/Symbol.hpp"
43
#include "il/SymbolReference.hpp"
44
#include "runtime/J9Runtime.hpp"
45
#include "infra/Flags.hpp"
46
#include "env/CompilerEnv.hpp"
47
48
namespace TR { class Node; }
49
50
51
namespace J9
52
{
53
54
namespace X86
55
{
56
57
class UnresolvedDataSnippet : public J9::UnresolvedDataSnippet
58
{
59
60
public:
61
62
UnresolvedDataSnippet(TR::CodeGenerator *cg, TR::Node *node, TR::SymbolReference *symRef, bool isStore, bool isGCSafePoint);
63
64
Kind getKind() { return J9::X86::UnresolvedDataSnippet::cg()->comp()->target().is64Bit() ? IsUnresolvedDataAMD64 : IsUnresolvedDataIA32; }
65
66
virtual uint8_t *emitSnippetBody();
67
68
virtual uint32_t getLength(int32_t estimatedSnippetStart);
69
70
TR_RuntimeHelper getHelper();
71
72
uint8_t *emitResolveHelperCall(uint8_t *cursor);
73
uint8_t *emitUnresolvedInstructionDescriptor(uint8_t *cursor);
74
uint32_t getUnresolvedStaticStoreDeltaWithMemBarrier();
75
uint8_t *emitConstantPoolAddress(uint8_t *cursor);
76
uint8_t *emitConstantPoolIndex(uint8_t *cursor);
77
uint8_t *fixupDataReferenceInstruction(uint8_t *cursor);
78
79
TR::SymbolReference * getGlueSymRef() { return _glueSymRef; }
80
void setGlueSymRef(TR::SymbolReference * glueSymRef) { _glueSymRef = glueSymRef; }
81
82
TR::Symbol *getDataSymbol() {return getDataSymbolReference()->getSymbol();}
83
84
bool resolveMustPatch8Bytes()
85
{
86
// On 64-bit, only unresolved fields require 4-byte patching.
87
//
88
return J9::X86::UnresolvedDataSnippet::cg()->comp()->target().is64Bit() && !getDataSymbol()->isShadow();
89
}
90
91
uint8_t setNumLiveX87Registers(uint8_t live)
92
{
93
// If the unresolved data snippet call is for a floating point
94
// load then the register assigner will free up one register on
95
// the fp stack, however the live count isn't changed at that point
96
// in which case we'll still have 8 live FPR, which we'll spill and reload
97
// in PicBuilder. However, if we are doing floating point load and the
98
// live count is 8 we'll do total of 9 pushes on the fp stack, 8 in the
99
// runtime code + 1 for the load, which will cause fp stack overflow and
100
// incorrect load. The fix is to adjust the number of live registers to 7
101
// when we are doing floating load in the unresolved snippet.
102
// See JCK: api.java.awt.geom.AffineTransform.CreateInverseTest
103
//
104
if (!isUnresolvedStore() && isFloatData() && (live == 8))
105
{
106
live--;
107
}
108
109
return (_numLiveX87Registers = live);
110
}
111
112
uint8_t getNumLiveX87Registers() {return _numLiveX87Registers;}
113
114
/*
115
* Flags to be passed to the resolution runtime. These flags piggyback on
116
* the unused bits of the cpIndex.
117
*
118
* Move to J9 FE.
119
*/
120
enum
121
{
122
cpIndex_hasLiveXMMRegisters = 0x10000000,
123
cpIndex_doNotPatchSnippet = 0x00200000,
124
cpIndex_longPushTag = 0x00800000,
125
cpIndex_isStaticResolution = 0x20000000,
126
cpIndex_patch8ByteResolution = 0x40000000, // OVERLOADED: 64-BIT only
127
cpIndex_checkVolatility = 0x00080000,
128
cpIndex_procAsLongLow = 0x00040000,
129
cpIndex_procAsLongHigh = 0x00020000,
130
cpIndex_isHighWordOfLongPair = 0x40000000, // OVERLOADED: 32-BIT only
131
cpIndex_extremeStaticMemBarPos = 0x80000000,
132
cpIndex_genStaticMemBarPos = 0x00000000,
133
cpIndex_isFloatStore = 0x00040000, // OVERLOADED: 64-BIT only
134
cpIndex_isCompressedPointer = 0x40000000, // OVERLOADED: multiTenancy perform load/store
135
cpIndex_isOwningObjectNeeded = 0x00040000, // OVERLOADED: multiTenancy refrence type store needs owning object register
136
};
137
138
bool isFloatData() {return _flags.testAll(TO_MASK32(IsFloatData));}
139
void setIsFloatData() {_flags.set(TO_MASK32(IsFloatData));}
140
void resetFloatData() {_flags.reset(TO_MASK32(IsFloatData));}
141
142
bool hasLiveXMMRegisters() {return _flags.testAll(TO_MASK32(HasLiveXMMRegisters));}
143
void setHasLiveXMMRegisters(bool b) {_flags.set(TO_MASK32(HasLiveXMMRegisters), b);}
144
void resetHasLiveXMMRegisters() {_flags.reset(TO_MASK32(HasLiveXMMRegisters));}
145
146
protected:
147
148
enum
149
{
150
IsFloatData = J9::UnresolvedDataSnippet::NextSnippetFlag,
151
HasLiveXMMRegisters,
152
DoNotPatchMainline,
153
NextSnippetFlag
154
};
155
156
static_assert((int32_t)NextSnippetFlag <= (int32_t)J9::UnresolvedDataSnippet::MaxSnippetFlag,
157
"J9::X86::UnresolvedDataSnippet too many flag bits for flag width");
158
159
160
private:
161
162
TR::SymbolReference *_glueSymRef;
163
164
uint8_t _numLiveX87Registers;
165
166
};
167
168
}
169
170
}
171
172
#endif
173
174