Path: blob/master/runtime/compiler/z/env/J9CPU.cpp
6004 views
/*******************************************************************************1* Copyright (c) 2000, 2022 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#pragma csect(CODE,"J9ZJ9CPU#C")23#pragma csect(STATIC,"J9ZJ9CPU#S")24#pragma csect(TEST,"J9ZJ9CPU#T")252627#include <ctype.h>28#include <string.h>29#include "control/Options.hpp"30#include "control/CompilationRuntime.hpp"31#include "env/CompilerEnv.hpp"32#include "env/CPU.hpp"33#include "infra/Assert.hpp"34#include "j9.h"35#include "j9port.h"36#include "j9jitnls.h"3738#if defined(J9ZOS390) || defined (J9ZTPF)39#include <sys/utsname.h>40#endif /* defined(J9ZOS390) || defined (J9ZTPF) */4142#include "control/Options_inlines.hpp"4344extern J9JITConfig * jitConfig;4546TR::CPU47J9::Z::CPU::detectRelocatable(OMRPortLibrary * const omrPortLib)48{49OMRPORT_ACCESS_FROM_OMRPORT(omrPortLib);50OMRProcessorDesc processorDescription;51omrsysinfo_get_processor_description(&processorDescription);5253if (processorDescription.processor > OMR_PROCESSOR_S390_Z10)54{55processorDescription.processor = OMR_PROCESSOR_S390_Z10;56processorDescription.physicalProcessor = OMR_PROCESSOR_S390_Z10;57}5859return TR::CPU::customize(processorDescription);60}6162TR::CPU63J9::Z::CPU::customize(OMRProcessorDesc processorDescription)64{65OMRPORT_ACCESS_FROM_OMRPORT(TR::Compiler->omrPortLib);66if (processorDescription.processor < OMR_PROCESSOR_S390_Z10)67{68omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_DFP, FALSE);69}7071if (processorDescription.processor < OMR_PROCESSOR_S390_Z196)72{73omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_HIGH_WORD, FALSE);74}7576if (processorDescription.processor < OMR_PROCESSOR_S390_ZEC12)77{78omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_TE, FALSE);79omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_RI, FALSE);80}8182if (processorDescription.processor < OMR_PROCESSOR_S390_Z13)83{84omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_FACILITY, FALSE);85}8687if (processorDescription.processor < OMR_PROCESSOR_S390_Z14)88{89omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_MISCELLANEOUS_INSTRUCTION_EXTENSION_2, FALSE);90omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL, FALSE);91omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_FACILITY_ENHANCEMENT_1, FALSE);92omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_GUARDED_STORAGE, FALSE);93}9495if (processorDescription.processor < OMR_PROCESSOR_S390_Z15)96{97omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_MISCELLANEOUS_INSTRUCTION_EXTENSION_3, FALSE);98omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_FACILITY_ENHANCEMENT_2, FALSE);99omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL_ENHANCEMENT_FACILITY, FALSE);100}101102if (processorDescription.processor < OMR_PROCESSOR_S390_ZNEXT)103{104omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL_ENHANCEMENT_FACILITY_2, FALSE);105}106107// This variable is used internally by the j9sysinfo macros below and cannot be folded away108J9PortLibrary* privatePortLibrary = TR::Compiler->portLib;109110#if defined(LINUX)111if (TRUE == omrsysinfo_processor_has_feature(&processorDescription, OMR_FEATURE_S390_RI))112{113if (0 != j9ri_enableRISupport())114{115omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_RI, FALSE);116}117}118#endif119120if (TRUE == omrsysinfo_processor_has_feature(&processorDescription, OMR_FEATURE_S390_GUARDED_STORAGE))121{122if (TR::Compiler->javaVM->memoryManagerFunctions->j9gc_software_read_barrier_enabled(TR::Compiler->javaVM))123{124omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_S390_GUARDED_STORAGE, FALSE);125}126}127128if (_isSupportedFeatureMasksEnabled)129{130// mask out any cpu features that the compiler doesn't care about131for (size_t i = 0; i < OMRPORT_SYSINFO_FEATURES_SIZE; i++)132{133processorDescription.features[i] &= _supportedFeatureMasks.features[i];134}135}136137return TR::CPU(processorDescription);138}139140141void142J9::Z::CPU::enableFeatureMasks()143{144// Only enable the features that compiler currently uses145const uint32_t utilizedFeatures [] = {OMR_FEATURE_S390_DFP, OMR_FEATURE_S390_TE, OMR_FEATURE_S390_FPE,146OMR_FEATURE_S390_RI, OMR_FEATURE_S390_VECTOR_FACILITY, OMR_FEATURE_S390_HIGH_WORD,147OMR_FEATURE_S390_MISCELLANEOUS_INSTRUCTION_EXTENSION_2,148OMR_FEATURE_S390_GUARDED_STORAGE, OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL,149OMR_FEATURE_S390_VECTOR_FACILITY_ENHANCEMENT_1,150OMR_FEATURE_S390_VECTOR_FACILITY_ENHANCEMENT_2,151OMR_FEATURE_S390_MISCELLANEOUS_INSTRUCTION_EXTENSION_3,152OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL_ENHANCEMENT_FACILITY,153OMR_FEATURE_S390_VECTOR_PACKED_DECIMAL_ENHANCEMENT_FACILITY_2};154155memset(_supportedFeatureMasks.features, 0, OMRPORT_SYSINFO_FEATURES_SIZE*sizeof(uint32_t));156OMRPORT_ACCESS_FROM_OMRPORT(TR::Compiler->omrPortLib);157for (size_t i = 0; i < sizeof(utilizedFeatures)/sizeof(uint32_t); i++)158{159omrsysinfo_processor_set_feature(&_supportedFeatureMasks, utilizedFeatures[i], TRUE);160}161_isSupportedFeatureMasksEnabled = true;162}163164bool165J9::Z::CPU::isCompatible(const OMRProcessorDesc& processorDescription)166{167if (!self()->isAtLeast(processorDescription.processor))168{169return false;170}171for (int i = 0; i < OMRPORT_SYSINFO_FEATURES_SIZE; i++)172{173// Check to see if the current processor contains all the features that code cache's processor has174if ((processorDescription.features[i] & self()->getProcessorDescription().features[i]) != processorDescription.features[i])175return false;176}177return true;178}179180181