Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/codegen/PrivateLinkage.hpp
6000 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_PRIVATELINKAGE_INCL
24
#define J9_PRIVATELINKAGE_INCL
25
26
#include "codegen/Linkage.hpp"
27
#include "env/jittypes.h"
28
#include "compile/CompilationTypes.hpp"
29
#include "infra/Assert.hpp"
30
31
namespace TR { class CodeGenerator; }
32
33
namespace J9
34
{
35
36
class PrivateLinkage : public TR::Linkage
37
{
38
public:
39
40
PrivateLinkage(TR::CodeGenerator *cg) :
41
TR::Linkage(cg)
42
{
43
}
44
45
/**
46
* @class LinkageInfo
47
*
48
* @brief Helper class for encoding and decoding the linkage info word that is
49
* embedded in the code cache prior to the interpreter entry point in each
50
* compiled method body.
51
*
52
* @details
53
* Implementation restrictions:
54
* * this is a non-instantiable abstract class
55
* * this class cannot have any virtual methods
56
*/
57
class LinkageInfo
58
{
59
public:
60
static LinkageInfo *get(void *startPC) { return reinterpret_cast<LinkageInfo *>(((uint32_t*)startPC)-1); }
61
62
void setCountingMethodBody() { _word |= CountingPrologue; }
63
void setSamplingMethodBody() { _word |= SamplingPrologue; }
64
void setHasBeenRecompiled()
65
{
66
TR_ASSERT((_word & HasFailedRecompilation)==0, "Cannot setHasBeenRecompiled because method has failed recompilation");
67
_word |= HasBeenRecompiled;
68
}
69
70
void setHasFailedRecompilation()
71
{
72
TR_ASSERT((_word & HasBeenRecompiled) == 0, "Cannot setHasFailedRecompilation because method has been recompiled");
73
_word |= HasFailedRecompilation;
74
}
75
76
void setIsBeingRecompiled() { _word |= IsBeingRecompiled; }
77
void resetIsBeingRecompiled() { _word &= ~IsBeingRecompiled; }
78
79
bool isCountingMethodBody() { return (_word & CountingPrologue) != 0; }
80
bool isSamplingMethodBody() { return (_word & SamplingPrologue) != 0; }
81
bool isRecompMethodBody() { return (_word & (SamplingPrologue | CountingPrologue)) != 0; }
82
bool hasBeenRecompiled() { return (_word & HasBeenRecompiled) != 0; }
83
bool hasFailedRecompilation() { return (_word & HasFailedRecompilation) != 0; }
84
bool recompilationAttempted() { return hasBeenRecompiled() || hasFailedRecompilation(); }
85
bool isBeingCompiled() { return (_word & IsBeingRecompiled) != 0; }
86
87
inline uint16_t getReservedWord() { return (_word & ReservedMask) >> 16; }
88
inline void setReservedWord(uint16_t w) { _word |= ((w << 16) & ReservedMask); }
89
90
inline TR_ReturnInfo getReturnInfo() { return (TR_ReturnInfo)(_word & ReturnInfoMask); }
91
inline void setReturnInfo(TR_ReturnInfo w) { _word |= (w & ReturnInfoMask); }
92
93
inline uint32_t getWord() { return _word; }
94
95
int32_t getJitEntryOffset()
96
{
97
#if defined(TR_TARGET_X86) && defined(TR_TARGET_32BIT)
98
return 0;
99
#else
100
return getReservedWord();
101
#endif
102
}
103
104
enum
105
{
106
ReturnInfoMask = 0x0000000F, // bottom 4 bits
107
// The VM depends on these four bits - word to the wise: don't mess
108
109
SamplingPrologue = 0x00000010,
110
CountingPrologue = 0x00000020,
111
// NOTE: flags have to be set under the compilation monitor or during compilation process
112
HasBeenRecompiled = 0x00000040,
113
HasFailedRecompilation = 0x00000100,
114
IsBeingRecompiled = 0x00000200,
115
116
// RESERVED:
117
// non-ia32: 0xffff0000 <---- jitEntryOffset
118
// ia32: 0xffff0000 <---- Recomp/FSD save area
119
120
ReservedMask = 0xFFFF0000
121
};
122
123
uint32_t _word;
124
125
private:
126
LinkageInfo() {};
127
};
128
129
/**
130
* @brief J9 private linkage override of OMR function
131
*/
132
virtual intptr_t entryPointFromCompiledMethod();
133
134
/**
135
* @brief J9 private linkage override of OMR function
136
*/
137
virtual intptr_t entryPointFromInterpretedMethod();
138
139
virtual void mapIncomingParms(TR::ResolvedMethodSymbol *method);
140
};
141
142
}
143
144
#endif
145
146