Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/z/env/J9CPU.cpp
6004 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2022 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
#pragma csect(CODE,"J9ZJ9CPU#C")
24
#pragma csect(STATIC,"J9ZJ9CPU#S")
25
#pragma csect(TEST,"J9ZJ9CPU#T")
26
27
28
#include <ctype.h>
29
#include <string.h>
30
#include "control/Options.hpp"
31
#include "control/CompilationRuntime.hpp"
32
#include "env/CompilerEnv.hpp"
33
#include "env/CPU.hpp"
34
#include "infra/Assert.hpp"
35
#include "j9.h"
36
#include "j9port.h"
37
#include "j9jitnls.h"
38
39
#if defined(J9ZOS390) || defined (J9ZTPF)
40
#include <sys/utsname.h>
41
#endif /* defined(J9ZOS390) || defined (J9ZTPF) */
42
43
#include "control/Options_inlines.hpp"
44
45
extern J9JITConfig * jitConfig;
46
47
TR::CPU
48
J9::Z::CPU::detectRelocatable(OMRPortLibrary * const omrPortLib)
49
{
50
OMRPORT_ACCESS_FROM_OMRPORT(omrPortLib);
51
OMRProcessorDesc processorDescription;
52
omrsysinfo_get_processor_description(&processorDescription);
53
54
if (processorDescription.processor > OMR_PROCESSOR_S390_Z10)
55
{
56
processorDescription.processor = OMR_PROCESSOR_S390_Z10;
57
processorDescription.physicalProcessor = OMR_PROCESSOR_S390_Z10;
58
}
59
60
return TR::CPU::customize(processorDescription);
61
}
62
63
TR::CPU
64
J9::Z::CPU::customize(OMRProcessorDesc processorDescription)
65
{
66
OMRPORT_ACCESS_FROM_OMRPORT(TR::Compiler->omrPortLib);
67
if (processorDescription.processor < OMR_PROCESSOR_S390_Z10)
68
{
69
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_DFP, FALSE);
70
}
71
72
if (processorDescription.processor < OMR_PROCESSOR_S390_Z196)
73
{
74
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_HIGH_WORD, FALSE);
75
}
76
77
if (processorDescription.processor < OMR_PROCESSOR_S390_ZEC12)
78
{
79
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_TE, FALSE);
80
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_RI, FALSE);
81
}
82
83
if (processorDescription.processor < OMR_PROCESSOR_S390_Z13)
84
{
85
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_FACILITY, FALSE);
86
}
87
88
if (processorDescription.processor < OMR_PROCESSOR_S390_Z14)
89
{
90
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_MISCELLANEOUS_INSTRUCTION_EXTENSION_2, FALSE);
91
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL, FALSE);
92
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_FACILITY_ENHANCEMENT_1, FALSE);
93
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_GUARDED_STORAGE, FALSE);
94
}
95
96
if (processorDescription.processor < OMR_PROCESSOR_S390_Z15)
97
{
98
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_MISCELLANEOUS_INSTRUCTION_EXTENSION_3, FALSE);
99
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_FACILITY_ENHANCEMENT_2, FALSE);
100
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL_ENHANCEMENT_FACILITY, FALSE);
101
}
102
103
if (processorDescription.processor < OMR_PROCESSOR_S390_ZNEXT)
104
{
105
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL_ENHANCEMENT_FACILITY_2, FALSE);
106
}
107
108
// This variable is used internally by the j9sysinfo macros below and cannot be folded away
109
J9PortLibrary* privatePortLibrary = TR::Compiler->portLib;
110
111
#if defined(LINUX)
112
if (TRUE == omrsysinfo_processor_has_feature(&processorDescription, OMR_FEATURE_S390_RI))
113
{
114
if (0 != j9ri_enableRISupport())
115
{
116
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_RI, FALSE);
117
}
118
}
119
#endif
120
121
if (TRUE == omrsysinfo_processor_has_feature(&processorDescription, OMR_FEATURE_S390_GUARDED_STORAGE))
122
{
123
if (TR::Compiler->javaVM->memoryManagerFunctions->j9gc_software_read_barrier_enabled(TR::Compiler->javaVM))
124
{
125
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_GUARDED_STORAGE, FALSE);
126
}
127
}
128
129
if (_isSupportedFeatureMasksEnabled)
130
{
131
// mask out any cpu features that the compiler doesn't care about
132
for (size_t i = 0; i < OMRPORT_SYSINFO_FEATURES_SIZE; i++)
133
{
134
processorDescription.features[i] &= _supportedFeatureMasks.features[i];
135
}
136
}
137
138
return TR::CPU(processorDescription);
139
}
140
141
142
void
143
J9::Z::CPU::enableFeatureMasks()
144
{
145
// Only enable the features that compiler currently uses
146
const uint32_t utilizedFeatures [] = {OMR_FEATURE_S390_DFP, OMR_FEATURE_S390_TE, OMR_FEATURE_S390_FPE,
147
OMR_FEATURE_S390_RI, OMR_FEATURE_S390_VECTOR_FACILITY, OMR_FEATURE_S390_HIGH_WORD,
148
OMR_FEATURE_S390_MISCELLANEOUS_INSTRUCTION_EXTENSION_2,
149
OMR_FEATURE_S390_GUARDED_STORAGE, OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL,
150
OMR_FEATURE_S390_VECTOR_FACILITY_ENHANCEMENT_1,
151
OMR_FEATURE_S390_VECTOR_FACILITY_ENHANCEMENT_2,
152
OMR_FEATURE_S390_MISCELLANEOUS_INSTRUCTION_EXTENSION_3,
153
OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL_ENHANCEMENT_FACILITY,
154
OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL_ENHANCEMENT_FACILITY_2};
155
156
memset(_supportedFeatureMasks.features, 0, OMRPORT_SYSINFO_FEATURES_SIZE*sizeof(uint32_t));
157
OMRPORT_ACCESS_FROM_OMRPORT(TR::Compiler->omrPortLib);
158
for (size_t i = 0; i < sizeof(utilizedFeatures)/sizeof(uint32_t); i++)
159
{
160
omrsysinfo_processor_set_feature(&_supportedFeatureMasks, utilizedFeatures[i], TRUE);
161
}
162
_isSupportedFeatureMasksEnabled = true;
163
}
164
165
bool
166
J9::Z::CPU::isCompatible(const OMRProcessorDesc& processorDescription)
167
{
168
if (!self()->isAtLeast(processorDescription.processor))
169
{
170
return false;
171
}
172
for (int i = 0; i < OMRPORT_SYSINFO_FEATURES_SIZE; i++)
173
{
174
// Check to see if the current processor contains all the features that code cache's processor has
175
if ((processorDescription.features[i] & self()->getProcessorDescription().features[i]) != processorDescription.features[i])
176
return false;
177
}
178
return true;
179
}
180
181