Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/compiler/env/J9CPU.cpp
6000 views
1
/*******************************************************************************
2
* Copyright (c) 2000, 2021 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
#if defined(J9ZOS390)
24
#pragma csect(CODE,"J9J9CPU#C")
25
#pragma csect(STATIC,"J9J9CPU#S")
26
#pragma csect(TEST,"J9J9CPU#T")
27
#endif
28
29
#include "env/CPU.hpp"
30
#include "env/VMJ9.h"
31
#include "infra/Assert.hpp" // for TR_ASSERT
32
33
OMRProcessorDesc J9::CPU::_supportedFeatureMasks = {OMR_PROCESSOR_UNDEFINED, OMR_PROCESSOR_UNDEFINED, {}};
34
bool J9::CPU::_isSupportedFeatureMasksEnabled = false;
35
36
const char *
37
J9::CPU::getProcessorVendorId()
38
{
39
TR_ASSERT_FATAL(false, "Vendor ID not defined for this platform!");
40
return NULL;
41
}
42
43
uint32_t
44
J9::CPU::getProcessorSignature()
45
{
46
TR_ASSERT_FATAL(false, "Processor Signature not defined for this platform!");
47
return 0;
48
}
49
50
void
51
J9::CPU::enableFeatureMasks()
52
{
53
// Assume all features will be utilized by default
54
memset(_supportedFeatureMasks.features, ~0, OMRPORT_SYSINFO_FEATURES_SIZE*sizeof(uint32_t));
55
_isSupportedFeatureMasksEnabled = true;
56
}
57
58
TR::CPU
59
J9::CPU::customize(OMRProcessorDesc processorDescription)
60
{
61
if (_isSupportedFeatureMasksEnabled)
62
{
63
// mask out any cpu features that the compiler doesn't care about
64
for (size_t i = 0; i < OMRPORT_SYSINFO_FEATURES_SIZE; i++)
65
{
66
processorDescription.features[i] &= _supportedFeatureMasks.features[i];
67
}
68
}
69
return TR::CPU(processorDescription);
70
}
71
72
TR::CPU
73
J9::CPU::detect(OMRPortLibrary * const omrPortLib)
74
{
75
if (omrPortLib == NULL)
76
return TR::CPU();
77
78
OMRPORT_ACCESS_FROM_OMRPORT(omrPortLib);
79
OMRProcessorDesc processorDescription;
80
omrsysinfo_get_processor_description(&processorDescription);
81
82
TR::CPU::enableFeatureMasks();
83
return TR::CPU::customize(processorDescription);
84
}
85
86
bool
87
J9::CPU::supportsFeature(uint32_t feature)
88
{
89
OMRPORT_ACCESS_FROM_OMRPORT(TR::Compiler->omrPortLib);
90
91
static bool disableCPUDetectionTest = feGetEnv("TR_DisableCPUDetectionTest");
92
if (!disableCPUDetectionTest && _isSupportedFeatureMasksEnabled)
93
{
94
TR_ASSERT_FATAL(TRUE == omrsysinfo_processor_has_feature(&_supportedFeatureMasks, feature), "New processor feature usage detected, please add feature %d to _supportedFeatureMasks via TR::CPU::enableFeatureMasks()\n", feature);
95
}
96
97
return TRUE == omrsysinfo_processor_has_feature(&_processorDescription, feature);
98
}
99
100