Path: blob/master/runtime/compiler/env/J9CPU.cpp
6000 views
/*******************************************************************************1* Copyright (c) 2000, 2021 IBM Corp. and others2*3* This program and the accompanying materials are made available under4* the terms of the Eclipse Public License 2.0 which accompanies this5* distribution and is available at https://www.eclipse.org/legal/epl-2.0/6* or the Apache License, Version 2.0 which accompanies this distribution and7* is available at https://www.apache.org/licenses/LICENSE-2.0.8*9* This Source Code may also be made available under the following10* Secondary Licenses when the conditions for such availability set11* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU12* General Public License, version 2 with the GNU Classpath13* Exception [1] and GNU General Public License, version 2 with the14* OpenJDK Assembly Exception [2].15*16* [1] https://www.gnu.org/software/classpath/license.html17* [2] http://openjdk.java.net/legal/assembly-exception.html18*19* 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-exception20*******************************************************************************/2122#if defined(J9ZOS390)23#pragma csect(CODE,"J9J9CPU#C")24#pragma csect(STATIC,"J9J9CPU#S")25#pragma csect(TEST,"J9J9CPU#T")26#endif2728#include "env/CPU.hpp"29#include "env/VMJ9.h"30#include "infra/Assert.hpp" // for TR_ASSERT3132OMRProcessorDesc J9::CPU::_supportedFeatureMasks = {OMR_PROCESSOR_UNDEFINED, OMR_PROCESSOR_UNDEFINED, {}};33bool J9::CPU::_isSupportedFeatureMasksEnabled = false;3435const char *36J9::CPU::getProcessorVendorId()37{38TR_ASSERT_FATAL(false, "Vendor ID not defined for this platform!");39return NULL;40}4142uint32_t43J9::CPU::getProcessorSignature()44{45TR_ASSERT_FATAL(false, "Processor Signature not defined for this platform!");46return 0;47}4849void50J9::CPU::enableFeatureMasks()51{52// Assume all features will be utilized by default53memset(_supportedFeatureMasks.features, ~0, OMRPORT_SYSINFO_FEATURES_SIZE*sizeof(uint32_t));54_isSupportedFeatureMasksEnabled = true;55}5657TR::CPU58J9::CPU::customize(OMRProcessorDesc processorDescription)59{60if (_isSupportedFeatureMasksEnabled)61{62// mask out any cpu features that the compiler doesn't care about63for (size_t i = 0; i < OMRPORT_SYSINFO_FEATURES_SIZE; i++)64{65processorDescription.features[i] &= _supportedFeatureMasks.features[i];66}67}68return TR::CPU(processorDescription);69}7071TR::CPU72J9::CPU::detect(OMRPortLibrary * const omrPortLib)73{74if (omrPortLib == NULL)75return TR::CPU();7677OMRPORT_ACCESS_FROM_OMRPORT(omrPortLib);78OMRProcessorDesc processorDescription;79omrsysinfo_get_processor_description(&processorDescription);8081TR::CPU::enableFeatureMasks();82return TR::CPU::customize(processorDescription);83}8485bool86J9::CPU::supportsFeature(uint32_t feature)87{88OMRPORT_ACCESS_FROM_OMRPORT(TR::Compiler->omrPortLib);8990static bool disableCPUDetectionTest = feGetEnv("TR_DisableCPUDetectionTest");91if (!disableCPUDetectionTest && _isSupportedFeatureMasksEnabled)92{93TR_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);94}9596return TRUE == omrsysinfo_processor_has_feature(&_processorDescription, feature);97}9899100