Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/z/codegen/S390AOTRelocation.cpp
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 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
#include "z/codegen/S390AOTRelocation.hpp"
24
25
#include "env/CompilerEnv.hpp"
26
#include "env/IO.hpp"
27
#include "env/jittypes.h"
28
#include "il/Node.hpp"
29
#include "il/Node_inlines.hpp"
30
#include "il/StaticSymbol.hpp"
31
#include "z/codegen/S390Instruction.hpp"
32
#include "env/VMJ9.h"
33
34
void TR::S390PairedRelocation::mapRelocation(TR::CodeGenerator *cg)
35
{
36
if (cg->comp()->compileRelocatableCode())
37
{
38
cg->addExternalRelocation(
39
new (cg->trHeapMemory()) TR::ExternalOrderedPair32BitRelocation(
40
getSourceInstruction()->getBinaryEncoding(),
41
getSource2Instruction()->getBinaryEncoding(),
42
getRelocationTarget(),
43
getKind(), cg),
44
__FILE__, __LINE__, getSourceInstruction()->getNode());
45
}
46
}
47
48
void TR::S390EncodingRelocation::addRelocation(TR::CodeGenerator *cg, uint8_t *cursor, char* file, uintptr_t line, TR::Node* node)
49
{
50
TR::Compilation *comp = cg->comp();
51
TR_J9VMBase *fej9 = (TR_J9VMBase *)(comp->fe());
52
53
if (_reloType==TR_ClassAddress)
54
{
55
AOTcgDiag2( comp, "TR_ClassAddress cursor=%x symbolReference=%x\n", cursor, _symbolReference);
56
if (comp->getOption(TR_UseSymbolValidationManager))
57
{
58
TR_OpaqueClassBlock *clazz = (TR_OpaqueClassBlock*)(*((uintptr_t*)cursor));
59
TR_ASSERT_FATAL(clazz, "TR_ClassAddress relocation : cursor = %x, clazz can not be null", cursor);
60
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(cursor,
61
(uint8_t *)clazz,
62
(uint8_t *) TR::SymbolType::typeClass,
63
TR_SymbolFromManager,
64
cg),
65
file, line, node);
66
67
}
68
else
69
{
70
*((uintptr_t*)cursor)=fej9->getPersistentClassPointerFromClassPointer((TR_OpaqueClassBlock*)(*((uintptr_t*)cursor)));
71
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(cursor, (uint8_t *) _symbolReference, (uint8_t *)_inlinedSiteIndex, TR_ClassAddress, cg),
72
file, line, node);
73
}
74
}
75
else if (_reloType==TR_RamMethod)
76
{
77
AOTcgDiag1( comp, "TR_RamMethod cursor=%x\n", cursor);
78
if (comp->getOption(TR_UseSymbolValidationManager))
79
{
80
TR::ResolvedMethodSymbol *methodSym = (TR::ResolvedMethodSymbol*) _symbolReference->getSymbol();
81
uint8_t * j9Method = (uint8_t *) (reinterpret_cast<intptr_t>(methodSym->getResolvedMethod()->resolvedMethodAddress()));
82
TR_ASSERT_FATAL(j9Method, "TR_RamMethod relocation : cursor = %x, j9Method can not be null", cursor);
83
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(cursor,
84
j9Method,
85
(uint8_t *) TR::SymbolType::typeMethod,
86
TR_SymbolFromManager,
87
cg),
88
file, line, node);
89
}
90
else
91
{
92
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(cursor, NULL, TR_RamMethod, cg), file, line, node);
93
}
94
}
95
else if (_reloType==TR_HelperAddress)
96
{
97
AOTcgDiag1( comp, "TR_HelperAddress cursor=%x\n", cursor);
98
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(cursor, (uint8_t *) _symbolReference, TR_HelperAddress, cg),
99
file, line, node);
100
}
101
else if (_reloType==TR_AbsoluteHelperAddress)
102
{
103
AOTcgDiag1( comp, "TR_AbsoluteHelperAddress cursor=%x\n", cursor);
104
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(cursor, (uint8_t *) _symbolReference, TR_AbsoluteHelperAddress, cg),
105
file, line, node);
106
}
107
else if (_reloType==TR_ConstantPool)
108
{
109
AOTcgDiag1( comp, "TR_ConstantPool cursor=%x\n", cursor);
110
if (comp->target().is64Bit())
111
{
112
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(cursor, (uint8_t *) *((uint64_t*) cursor), (uint8_t *)_inlinedSiteIndex, TR_ConstantPool, cg),
113
file, line, node);
114
}
115
else
116
{
117
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(cursor, (uint8_t *)(intptr_t) *((uint32_t*) cursor), (uint8_t *)_inlinedSiteIndex, TR_ConstantPool, cg),
118
file, line, node);
119
}
120
}
121
else if (_reloType==TR_MethodObject)
122
{
123
AOTcgDiag1( comp, "TR_MethodObject cursor=%x\n", cursor);
124
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(cursor, (uint8_t *) _symbolReference, (uint8_t *)_inlinedSiteIndex, TR_MethodObject, cg),
125
file, line, node);
126
}
127
else if (_reloType==TR_DataAddress)
128
{
129
if (cg->needRelocationsForStatics())
130
{
131
AOTcgDiag1( comp, "TR_DataAddress cursor=%x\n", cursor);
132
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(cursor, (uint8_t *) _symbolReference, (uint8_t *)_inlinedSiteIndex, TR_DataAddress, cg),
133
file, line, node);
134
}
135
}
136
else if (_reloType==TR_BodyInfoAddress)
137
{
138
AOTcgDiag1( comp, "TR_BodyInfoAddress cursor=%x\n", cursor);
139
if (comp->target().is64Bit())
140
{
141
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(cursor, (uint8_t *) *((uint64_t*) cursor), TR_BodyInfoAddress, cg),
142
file, line, node);
143
}
144
else
145
{
146
cg->addExternalRelocation(new (cg->trHeapMemory()) TR::ExternalRelocation(cursor, (uint8_t *)(intptr_t) *((uint32_t*) cursor), TR_BodyInfoAddress, cg),
147
file, line, node);
148
}
149
}
150
else if (_reloType==TR_DebugCounter)
151
{
152
TR::DebugCounterBase *counter = comp->getCounterFromStaticAddress(_symbolReference);
153
if (counter == NULL)
154
{
155
comp->failCompilation<TR::CompilationException>("Could not generate relocation for debug counter in TR::S390EncodingRelocation::addRelocation\n");
156
}
157
TR::DebugCounter::generateRelocation(comp,
158
cursor,
159
node,
160
counter);
161
}
162
else
163
{
164
TR_ASSERT(0,"relocation type [%d] not handled yet", _reloType);
165
}
166
}
167
168