Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/arm/codegen/J9UnresolvedDataSnippet.cpp
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
#include "codegen/CodeGenerator.hpp"
24
#include "codegen/MemoryReference.hpp"
25
#include "codegen/UnresolvedDataSnippet.hpp"
26
#include "codegen/Relocation.hpp"
27
#include "il/Node.hpp"
28
#include "il/Node_inlines.hpp"
29
#include "il/StaticSymbol.hpp"
30
#include "il/StaticSymbol_inlines.hpp"
31
#include "il/Symbol.hpp"
32
33
TR_RuntimeHelper
34
J9::ARM::UnresolvedDataSnippet::getHelper()
35
{
36
if (getDataSymbol()->getShadowSymbol() != NULL) // instance data
37
{
38
if (resolveForStore())
39
return TR_ARMinterpreterUnresolvedInstanceDataStoreGlue;
40
else
41
return TR_ARMinterpreterUnresolvedInstanceDataGlue;
42
}
43
if (getDataSymbol()->isClassObject()) // class object
44
{
45
if (getDataSymbol()->addressIsCPIndexOfStatic())
46
return TR_ARMinterpreterUnresolvedClassGlue2;
47
return TR_ARMinterpreterUnresolvedClassGlue;
48
}
49
50
if (getDataSymbol()->isConstString()) // const string
51
return TR_ARMinterpreterUnresolvedStringGlue;
52
53
if (getDataSymbol()->isConstMethodType())
54
return TR_interpreterUnresolvedMethodTypeGlue;
55
56
if (getDataSymbol()->isConstMethodHandle())
57
return TR_interpreterUnresolvedMethodHandleGlue;
58
59
if (getDataSymbol()->isCallSiteTableEntry())
60
return TR_interpreterUnresolvedCallSiteTableEntryGlue;
61
62
if (getDataSymbol()->isMethodTypeTableEntry())
63
return TR_interpreterUnresolvedMethodTypeTableEntryGlue;
64
65
if (resolveForStore())
66
return TR_ARMinterpreterUnresolvedStaticDataStoreGlue;
67
else
68
return TR_ARMinterpreterUnresolvedStaticDataGlue;
69
70
}
71
72
uint8_t *
73
J9::ARM::UnresolvedDataSnippet::emitSnippetBody()
74
{
75
uint8_t *cursor = cg()->getBinaryBufferCursor();
76
77
getSnippetLabel()->setCodeLocation(cursor);
78
79
*(int32_t *)cursor = encodeHelperBranchAndLink(cg()->symRefTab()->findOrCreateRuntimeHelper(getHelper()), cursor, getNode(), cg()); // BL resolve
80
cursor += 4;
81
82
*(int32_t *)cursor = (intptr_t)getAddressOfDataReference(); // Code Cache RA
83
cg()->addExternalRelocation(new (cg()->trHeapMemory()) TR::ExternalRelocation(
84
cursor,
85
NULL,
86
TR_AbsoluteMethodAddress, cg()), __FILE__, __LINE__, getNode());
87
cursor += 4;
88
89
if (getDataSymbol()->isCallSiteTableEntry())
90
{
91
*(int32_t *)cursor = getDataSymbol()->castToCallSiteTableEntrySymbol()->getCallSiteIndex();
92
}
93
else if (getDataSymbol()->isMethodTypeTableEntry())
94
{
95
*(int32_t *)cursor = getDataSymbol()->castToMethodTypeTableEntrySymbol()->getMethodTypeIndex();
96
}
97
else
98
{
99
*(int32_t *)cursor = getDataSymbolReference()->getCPIndex(); // CP index
100
}
101
cursor += 4;
102
103
*(int32_t *)cursor = (intptr_t)getDataSymbolReference()->getOwningMethod(cg()->comp())->constantPool(); // CP
104
cg()->addExternalRelocation(new (cg()->trHeapMemory()) TR::ExternalRelocation(
105
cursor,
106
*(uint8_t **)cursor,
107
getNode() ? (uint8_t *)getNode()->getInlinedSiteIndex() : (uint8_t *)-1,
108
TR_ConstantPool, cg()), __FILE__, __LINE__, getNode());
109
cursor += 4;
110
111
*(int32_t *)cursor = getMemoryReference()->getOffset(); // offset
112
if (getDataSymbol()->isConstObjectRef())
113
{
114
// reset the offset to NULL
115
// the resolve + picbuilder will fully provide the addr to use
116
*(int32_t *)cursor = 0;
117
}
118
cursor += 4;
119
120
*(int32_t *)cursor = 0xE3A00000; // Template (mov immed)
121
toRealRegister(getMemoryReference()->getModBase())->setRegisterFieldRD((uint32_t *)cursor);
122
return cursor+4;
123
}
124
125
uint32_t
126
J9::ARM::UnresolvedDataSnippet::getLength(int32_t estimatedSnippetStart)
127
{
128
return 6 * 4;
129
}
130
131
132