Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/x/amd64/codegen/AMD64JNILinkage.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 AMD64_JNILINKAGE_INCL
24
#define AMD64_JNILINKAGE_INCL
25
26
#ifdef TR_TARGET_64BIT
27
28
#include "x/amd64/codegen/AMD64SystemLinkage.hpp"
29
30
#include "codegen/AMD64PrivateLinkage.hpp"
31
#include "env/jittypes.h"
32
33
namespace TR { class CodeGenerator; }
34
namespace TR { class Instruction; }
35
namespace TR { class LabelSymbol; }
36
namespace TR { class Node; }
37
namespace TR { class RegisterDependencyConditions; }
38
39
#define IMCOMPLETELINKAGE "This class is only used to generate call-out sequence but no call-in sequence, so it is not used as a complete linkage."
40
41
namespace J9
42
{
43
44
namespace X86
45
{
46
47
namespace AMD64
48
{
49
50
class JNILinkage : public PrivateLinkage
51
{
52
public:
53
54
JNILinkage(TR::AMD64SystemLinkage *systemLinkage, TR::CodeGenerator *cg) :
55
PrivateLinkage(cg),
56
_systemLinkage(systemLinkage) {}
57
58
int32_t computeMemoryArgSize(TR::Node *callNode, int32_t first, int32_t last, bool passThread = true);
59
int32_t buildArgs(TR::Node *callNode, TR::RegisterDependencyConditions *deps, bool passThread = true, bool passReceiver = true);
60
TR::Register *buildVolatileAndReturnDependencies(TR::Node *callNode, TR::RegisterDependencyConditions *deps, bool omitDedicatedFrameRegister);
61
void cleanupReturnValue(TR::Node *callNode, TR::Register *linkageReturnReg, TR::Register *targetReg);
62
63
TR::Register *buildDirectDispatch(TR::Node *callNode, bool spillFPRegs);
64
65
void buildJNICallOutFrame(TR::Node *callNode, TR::LabelSymbol *returnAddrLabel);
66
void buildJNIMergeLabelDependencies(TR::Node *callNode, bool killNonVolatileGPRs = true);
67
void buildOutgoingJNIArgsAndDependencies(TR::Node *callNode, bool passThread = true, bool passReceiver = true, bool killNonVolatileGPRs = true);
68
TR::Register *processJNIReferenceArg(TR::Node *child);
69
TR::Instruction *generateMethodDispatch(TR::Node *callNode, bool isJNIGCPoint = true, uintptr_t targetAddress = 0);
70
void releaseVMAccess(TR::Node *callNode);
71
void acquireVMAccess(TR::Node *callNode);
72
#ifdef J9VM_INTERP_ATOMIC_FREE_JNI
73
void releaseVMAccessAtomicFree(TR::Node *callNode);
74
void acquireVMAccessAtomicFree(TR::Node *callNode);
75
#endif /* J9VM_INTERP_ATOMIC_FREE_JNI */
76
void checkForJNIExceptions(TR::Node *callNode);
77
void cleanupJNIRefPool(TR::Node *callNode);
78
void populateJNIDispatchInfo();
79
80
private:
81
82
TR::Register *buildDirectJNIDispatch(TR::Node *callNode);
83
TR::AMD64SystemLinkage *_systemLinkage;
84
85
class TR_JNIDispatchInfo
86
{
87
public:
88
89
int32_t numJNIFrameSlotsPushed;
90
int32_t argSize;
91
bool requiresFPstackPop;
92
93
TR::Register *JNIReturnRegister;
94
TR::Register *linkageReturnRegister;
95
TR::Register *dispatchTrampolineRegister;
96
TR::RealRegister::RegNum dedicatedFrameRegisterIndex;
97
98
TR::RegisterDependencyConditions *callPreDeps;
99
TR::RegisterDependencyConditions *callPostDeps;
100
TR::RegisterDependencyConditions *mergeLabelPostDeps;
101
} _JNIDispatchInfo;
102
103
};
104
105
}
106
107
}
108
109
}
110
111
#endif
112
113
#endif
114
115