Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/x/amd64/codegen/J9CodeGenerator.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/CodeGenerator_inlines.hpp"
25
#include "codegen/X86PrivateLinkage.hpp"
26
#include "compile/Compilation.hpp"
27
#include "x/codegen/X86HelperLinkage.hpp"
28
#include "codegen/AMD64PrivateLinkage.hpp"
29
#include "codegen/AMD64JNILinkage.hpp"
30
#include "codegen/AMD64J9SystemLinkage.hpp"
31
#include "codegen/Linkage_inlines.hpp"
32
#include "il/Node.hpp"
33
#include "il/Node_inlines.hpp"
34
#include "env/CompilerEnv.hpp"
35
36
void
37
J9::X86::AMD64::CodeGenerator::initialize()
38
{
39
self()->J9::X86::CodeGenerator::initialize();
40
}
41
42
43
TR::Linkage *
44
J9::X86::AMD64::CodeGenerator::createLinkage(TR_LinkageConventions lc)
45
{
46
TR::Compilation *comp = self()->comp();
47
TR::Linkage *linkage = NULL;
48
49
switch (lc)
50
{
51
case TR_CHelper:
52
linkage = new (self()->trHeapMemory()) J9::X86::HelperLinkage(self());
53
break;
54
case TR_Helper:
55
case TR_Private:
56
{
57
J9::X86::PrivateLinkage *p = NULL;
58
p = new (self()->trHeapMemory()) J9::X86::AMD64::PrivateLinkage(self());
59
p->IPicParameters.roundedSizeOfSlot = 10+3+2+5+2+2;
60
p->IPicParameters.defaultNumberOfSlots = 2;
61
p->IPicParameters.defaultSlotAddress = 0;
62
p->VPicParameters.roundedSizeOfSlot = 10+3+2+5+2+2;
63
p->VPicParameters.defaultNumberOfSlots = 1;
64
p->VPicParameters.defaultSlotAddress = 0;
65
linkage = p;
66
}
67
break;
68
69
case TR_J9JNILinkage:
70
{
71
TR::AMD64SystemLinkage *systemLinkage;
72
73
if (comp->target().isWindows())
74
{
75
systemLinkage = new (self()->trHeapMemory()) TR::AMD64J9Win64FastCallLinkage(self());
76
linkage = new (self()->trHeapMemory()) J9::X86::AMD64::JNILinkage(systemLinkage, self());
77
}
78
else if (comp->target().isLinux() || comp->target().isOSX())
79
{
80
systemLinkage = new (self()->trHeapMemory()) TR::AMD64J9ABILinkage(self());
81
linkage = new (self()->trHeapMemory()) J9::X86::AMD64::JNILinkage(systemLinkage, self());
82
}
83
else
84
{
85
TR_ASSERT(0, "linkage not supported: %d\n", lc);
86
linkage = NULL;
87
}
88
}
89
break;
90
91
case TR_System:
92
if (comp->target().isWindows())
93
{
94
linkage = new (self()->trHeapMemory()) TR::AMD64J9Win64FastCallLinkage(self());
95
}
96
else if (comp->target().isLinux() || comp->target().isOSX())
97
{
98
linkage = new (self()->trHeapMemory()) TR::AMD64J9ABILinkage(self());
99
}
100
else
101
{
102
TR_ASSERT(0, "linkage not supported: %d\n", lc);
103
linkage = NULL;
104
}
105
106
break;
107
108
default :
109
TR_ASSERT(0, "\nTestarossa error: Illegal linkage convention %d\n", lc);
110
}
111
112
self()->setLinkage(lc, linkage);
113
return linkage;
114
}
115
116