From 12fb965b46882887318192a23395ed658dd95e48 Mon Sep 17 00:00:00 2001 From: Daryl Maier Date: Sat, 2 Nov 2024 21:50:42 -0400 Subject: [PATCH 1/6] Remove unnecessary JitConfig dependency Signed-off-by: Daryl Maier --- compiler/x/env/OMRCPU.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/x/env/OMRCPU.cpp b/compiler/x/env/OMRCPU.cpp index ea931a89fd6..476e14ea7f3 100644 --- a/compiler/x/env/OMRCPU.cpp +++ b/compiler/x/env/OMRCPU.cpp @@ -23,7 +23,6 @@ #include #include "env/CPU.hpp" #include "env/CompilerEnv.hpp" -#include "env/JitConfig.hpp" #include "env/ProcessorInfo.hpp" #include "infra/Flags.hpp" #include "x/runtime/X86Runtime.hpp" From db47ef3f24d43f46c86d6a177a7c552386df924f Mon Sep 17 00:00:00 2001 From: Daryl Maier Date: Thu, 21 Dec 2023 08:04:39 -0500 Subject: [PATCH 2/6] Make JitConfig a proper extensible class Signed-off-by: Daryl Maier --- compiler/env/CMakeLists.txt | 2 +- compiler/env/JitConfig.hpp | 46 ++-------- .../env/{JitConfig.cpp => OMRJitConfig.cpp} | 10 ++- compiler/env/OMRJitConfig.hpp | 84 +++++++++++++++++++ 4 files changed, 101 insertions(+), 41 deletions(-) rename compiler/env/{JitConfig.cpp => OMRJitConfig.cpp} (90%) create mode 100644 compiler/env/OMRJitConfig.hpp diff --git a/compiler/env/CMakeLists.txt b/compiler/env/CMakeLists.txt index 457b0fba5f1..29182f91c21 100644 --- a/compiler/env/CMakeLists.txt +++ b/compiler/env/CMakeLists.txt @@ -45,7 +45,7 @@ compiler_library(env # (for compiler test, but not jitbuilder). # TODO: figure out why and move if required ${CMAKE_CURRENT_LIST_DIR}/FEBase.cpp - ${CMAKE_CURRENT_LIST_DIR}/JitConfig.cpp + ${CMAKE_CURRENT_LIST_DIR}/OMRJitConfig.cpp ${CMAKE_CURRENT_LIST_DIR}/OMRIO.cpp ${CMAKE_CURRENT_LIST_DIR}/OMRKnownObjectTable.cpp ${CMAKE_CURRENT_LIST_DIR}/Globals.cpp diff --git a/compiler/env/JitConfig.hpp b/compiler/env/JitConfig.hpp index 9a83ee6338a..db07b537903 100644 --- a/compiler/env/JitConfig.hpp +++ b/compiler/env/JitConfig.hpp @@ -19,50 +19,20 @@ * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 *******************************************************************************/ -#ifndef JITCONFIG_HPP_BThFwv -#define JITCONFIG_HPP_BThFwv +#ifndef TR_JITCONFIG_INCL +#define TR_JITCONFIG_INCL -#include -#include -#include "env/IO.hpp" +#include "env/OMRJitConfig.hpp" namespace TR { - -class JitConfig +class OMR_EXTENSIBLE JitConfig : public OMR::JitConfigConnector { - protected: - JitConfig(); - - public: - - static JitConfig *instance(); - - // possibly temporary place for options to be stored? - struct - { - int32_t codeCacheKB; - char * vLogFileName; - TR::FILE * vLogFile; - uint64_t verboseFlags; - } options; - - void setInterpreterTOC(size_t interpreterTOC) { _interpreterTOC = interpreterTOC; } - size_t getInterpreterTOC() { return _interpreterTOC; } +public: - void *getPseudoTOC() { return _pseudoTOC; } - void setPseudoTOC(void *pseudoTOC) { _pseudoTOC = pseudoTOC; } + JitConfig() : OMR::JitConfigConnector() {} - private: - char _eyecatcher[8]; - - void * _processorInfo; - - size_t _interpreterTOC; - - void * _pseudoTOC; // only used on POWER, otherwise should be NULL }; +} -} /* namespace TR */ - -#endif /* JITCONFIG_HPP_BThFwv */ +#endif diff --git a/compiler/env/JitConfig.cpp b/compiler/env/OMRJitConfig.cpp similarity index 90% rename from compiler/env/JitConfig.cpp rename to compiler/env/OMRJitConfig.cpp index 09494ec9bbc..e836c7b69d0 100644 --- a/compiler/env/JitConfig.cpp +++ b/compiler/env/OMRJitConfig.cpp @@ -23,14 +23,20 @@ #include #include "env/ConcreteFE.hpp" -TR::JitConfig::JitConfig() +TR::JitConfig * +OMR::JitConfig::self() + { + return static_cast(this); + } + +OMR::JitConfig::JitConfig() : _processorInfo(0), _interpreterTOC(0), _pseudoTOC(0) { memcpy(_eyecatcher, "JITCONF" /* 7 bytes + null */, sizeof(this->_eyecatcher)); } TR::JitConfig * -TR::JitConfig::instance() +OMR::JitConfig::instance() { return OMR::FrontEnd::singleton().jitConfig(); } diff --git a/compiler/env/OMRJitConfig.hpp b/compiler/env/OMRJitConfig.hpp new file mode 100644 index 00000000000..fd8ec9acc98 --- /dev/null +++ b/compiler/env/OMRJitConfig.hpp @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright IBM Corp. and others 2000 + * + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which accompanies this + * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ + * or the Apache License, Version 2.0 which accompanies this distribution + * and is available at https://www.apache.org/licenses/LICENSE-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License, v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception [1] and GNU General Public + * License, version 2 with the OpenJDK Assembly Exception [2]. + * + * [1] https://www.gnu.org/software/classpath/license.html + * [2] https://openjdk.org/legal/assembly-exception.html + * + * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 + *******************************************************************************/ + +#ifndef OMR_JITCONFIG_INCL +#define OMR_JITCONFIG_INCL + +/* + * The following #define and typedef must appear before any #includes in this file + */ +#ifndef OMR_JITCONFIG_CONNECTOR +#define OMR_JITCONFIG_CONNECTOR +namespace OMR { class JitConfig; } +namespace OMR { typedef OMR::JitConfig JitConfigConnector; } +#endif + +namespace TR { class JitConfig; } + +#include +#include +#include "infra/Annotations.hpp" +#include "env/IO.hpp" + +namespace OMR +{ + +class OMR_EXTENSIBLE JitConfig + { +protected: + + JitConfig(); + +public: + + static TR::JitConfig *instance(); + + TR::JitConfig *self(); + + // possibly temporary place for options to be stored? + struct + { + int32_t codeCacheKB; + char *vLogFileName; + TR::FILE *vLogFile; + uint64_t verboseFlags; + } options; + + void setInterpreterTOC(size_t interpreterTOC) { _interpreterTOC = interpreterTOC; } + size_t getInterpreterTOC() { return _interpreterTOC; } + + void *getPseudoTOC() { return _pseudoTOC; } + void setPseudoTOC(void *pseudoTOC) { _pseudoTOC = pseudoTOC; } + +private: + + char _eyecatcher[8]; + + void *_processorInfo; + + size_t _interpreterTOC; + + void *_pseudoTOC; // only used on POWER, otherwise should be NULL + }; + +} + +#endif From 002867d61e2a15a185d71bd2bd7b35ca0d8c3625 Mon Sep 17 00:00:00 2001 From: Daryl Maier Date: Thu, 21 Dec 2023 08:28:01 -0500 Subject: [PATCH 3/6] Use TR::JitConfig in JitBuilder and compilertest Use the proper extensible class for JitConfig rather than the version in FETraits. Remove FETraits. Signed-off-by: Daryl Maier --- compiler/env/FEBase.cpp | 2 +- compiler/env/FEBase.hpp | 12 ++---- fvtest/compilertest/control/TestJit.cpp | 4 +- fvtest/compilertest/env/FrontEnd.hpp | 12 ------ .../runtime/TestCodeCacheManager.hpp | 1 - fvtest/compilertest/runtime/TestJitConfig.hpp | 42 ------------------- jitbuilder/CMakeLists.txt | 1 - jitbuilder/control/Jit.cpp | 6 +-- jitbuilder/env/FrontEnd.hpp | 12 ------ jitbuilder/runtime/JBJitConfig.cpp | 33 --------------- jitbuilder/runtime/JBJitConfig.hpp | 42 ------------------- 11 files changed, 9 insertions(+), 158 deletions(-) delete mode 100644 fvtest/compilertest/runtime/TestJitConfig.hpp delete mode 100644 jitbuilder/runtime/JBJitConfig.cpp delete mode 100644 jitbuilder/runtime/JBJitConfig.hpp diff --git a/compiler/env/FEBase.cpp b/compiler/env/FEBase.cpp index e5e7e3ed2b8..3316fa5bdc5 100644 --- a/compiler/env/FEBase.cpp +++ b/compiler/env/FEBase.cpp @@ -108,7 +108,7 @@ char *feGetEnv(const char *s) TR::OptionTable OMR::Options::_feOptions[] = { {"code=", "C\tsize of a single code cache, in KB", - TR::Options::set32BitNumericInJitConfig, offsetof(OMR::FrontEnd::JitConfig, options.codeCacheKB), 0, " %d (KB)"}, + TR::Options::set32BitNumericInJitConfig, offsetof(TR::JitConfig, options.codeCacheKB), 0, " %d (KB)"}, {"exclude=", "D{regexp}\tdo not compile methods matching regexp", TR::Options::limitOption, 1, 0, "P%s"}, {"limit=", "D{regexp}\tonly compile methods matching regexp", TR::Options::limitOption, 0, 0, "P%s"}, {"limitfile=", "D\tfilter methods as defined in filename. " diff --git a/compiler/env/FEBase.hpp b/compiler/env/FEBase.hpp index f09be6daa6e..be3ac1eca69 100644 --- a/compiler/env/FEBase.hpp +++ b/compiler/env/FEBase.hpp @@ -25,11 +25,11 @@ #include "compiler/env/FrontEnd.hpp" #include "compile/CompilationTypes.hpp" -#include "env/JitConfig.hpp" #include "env/jittypes.h" #include "runtime/CodeCache.hpp" #include "runtime/CodeCacheManager.hpp" #include "env/CompilerEnv.hpp" +#include "env/JitConfig.hpp" class TR_ResolvedMethod; @@ -61,17 +61,11 @@ class FECommon : public ::TR_FrontEnd virtual uintptr_t getOffsetOfIndexableSizeField() { return -1; } }; -template struct FETraits {}; - template class FEBase : public FECommon { - public: - // Define our types in terms of the Traits - typedef typename TR::FETraits::JitConfig JitConfig; - private: - JitConfig _config; + TR::JitConfig _config; TR::CodeCacheManager _codeCacheManager; // this is deprecated in favour of TR::Allocator @@ -89,7 +83,7 @@ class FEBase : public FECommon static Derived &singleton() { return *(Derived::instance()); } - JitConfig *jitConfig() { return &_config; } + TR::JitConfig *jitConfig() { return &_config; } TR::CodeCacheManager &codeCacheManager() { return _codeCacheManager; } virtual uint8_t * allocateRelocationData(TR::Compilation* comp, uint32_t size); diff --git a/fvtest/compilertest/control/TestJit.cpp b/fvtest/compilertest/control/TestJit.cpp index ef10fa46328..99d017e5791 100644 --- a/fvtest/compilertest/control/TestJit.cpp +++ b/fvtest/compilertest/control/TestJit.cpp @@ -27,13 +27,13 @@ #include "env/CompilerEnv.hpp" #include "env/FrontEnd.hpp" #include "env/IO.hpp" +#include "env/JitConfig.hpp" #include "compile/ResolvedMethod.hpp" #include "env/RawAllocator.hpp" #include "ilgen/IlGeneratorMethodDetails_inlines.hpp" #include "ilgen/MethodBuilder.hpp" #include "runtime/CodeCache.hpp" #include "runtime/Runtime.hpp" -#include "runtime/TestJitConfig.hpp" #include "control/CompilationController.hpp" extern TR_RuntimeHelperTable runtimeHelpers; @@ -54,7 +54,7 @@ initHelper(void *helper, TR_RuntimeHelper id) } static void -initializeAllHelpers(TestCompiler::JitConfig *jitConfig, TR_RuntimeHelper *helperIDs, void **helperAddresses, int32_t numHelpers) +initializeAllHelpers(TR::JitConfig *jitConfig, TR_RuntimeHelper *helperIDs, void **helperAddresses, int32_t numHelpers) { initializeJitRuntimeHelperTable(false); diff --git a/fvtest/compilertest/env/FrontEnd.hpp b/fvtest/compilertest/env/FrontEnd.hpp index 2cea18fc927..aaaa300b05f 100644 --- a/fvtest/compilertest/env/FrontEnd.hpp +++ b/fvtest/compilertest/env/FrontEnd.hpp @@ -26,23 +26,11 @@ #include "compiler/env/FrontEnd.hpp" #include "env/FEBase.hpp" #include "env/jittypes.h" -#include "runtime/TestJitConfig.hpp" namespace TR { class GCStackAtlas; } namespace OMR { struct MethodMetaDataPOD; } class TR_ResolvedMethod; -namespace TR -{ - -template <> struct FETraits - { - typedef TestCompiler::JitConfig JitConfig; - static const size_t DEFAULT_SEG_SIZE = (128 * 1024); // 128kb - }; - -} - namespace TestCompiler { diff --git a/fvtest/compilertest/runtime/TestCodeCacheManager.hpp b/fvtest/compilertest/runtime/TestCodeCacheManager.hpp index 1b0308938a5..39682a29a5b 100644 --- a/fvtest/compilertest/runtime/TestCodeCacheManager.hpp +++ b/fvtest/compilertest/runtime/TestCodeCacheManager.hpp @@ -39,7 +39,6 @@ namespace TR { class CodeCacheManager; } namespace TestCompiler { -class JitConfig; class FrontEnd; class OMR_EXTENSIBLE CodeCacheManager : public OMR::CodeCacheManagerConnector diff --git a/fvtest/compilertest/runtime/TestJitConfig.hpp b/fvtest/compilertest/runtime/TestJitConfig.hpp deleted file mode 100644 index 13be9edc02d..00000000000 --- a/fvtest/compilertest/runtime/TestJitConfig.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright IBM Corp. and others 2000 - * - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which accompanies this - * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution - * and is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License, v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception [1] and GNU General Public - * License, version 2 with the OpenJDK Assembly Exception [2]. - * - * [1] https://www.gnu.org/software/classpath/license.html - * [2] https://openjdk.org/legal/assembly-exception.html - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 - *******************************************************************************/ - -#ifndef TEST_JITCONFIG_HPP -#define TEST_JITCONFIG_HPP - -#include "env/TRMemory.hpp" -#include "env/FEBase.hpp" -#include "env/JitConfig.hpp" - -namespace TestCompiler { class FrontEnd; } - -// Singleton JitConfig. The only instance of this is TestCompiler::FrontEnd::_jitConfig -namespace TestCompiler -{ -class JitConfig : public TR::JitConfig - { - private: - friend class TR::FEBase; - JitConfig() : TR::JitConfig() {} - }; -} // namespace TestCompiler - -#endif diff --git a/jitbuilder/CMakeLists.txt b/jitbuilder/CMakeLists.txt index 97fd864cff3..a0978e8da4a 100644 --- a/jitbuilder/CMakeLists.txt +++ b/jitbuilder/CMakeLists.txt @@ -34,7 +34,6 @@ set(JITBUILDER_OBJECTS optimizer/JBOptimizer.cpp optimizer/Optimizer.hpp runtime/JBCodeCacheManager.cpp - runtime/JBJitConfig.cpp ) if(OMR_ARCH_X86) diff --git a/jitbuilder/control/Jit.cpp b/jitbuilder/control/Jit.cpp index 494bfe9e0b2..11518e4601b 100644 --- a/jitbuilder/control/Jit.cpp +++ b/jitbuilder/control/Jit.cpp @@ -28,13 +28,13 @@ #include "env/CompilerEnv.hpp" #include "env/FrontEnd.hpp" #include "env/IO.hpp" +#include "env/JitConfig.hpp" #include "env/RawAllocator.hpp" #include "ilgen/IlGeneratorMethodDetails_inlines.hpp" #include "ilgen/MethodBuilder.hpp" #include "ilgen/TypeDictionary.hpp" #include "runtime/CodeCache.hpp" #include "runtime/Runtime.hpp" -#include "runtime/JBJitConfig.hpp" #include "control/CompilationController.hpp" #if defined(AIXPPC) @@ -59,7 +59,7 @@ initHelper(void *helper, TR_RuntimeHelper id) } static void -initializeAllHelpers(JitBuilder::JitConfig *jitConfig, TR_RuntimeHelper *helperIDs, void **helperAddresses, int32_t numHelpers) +initializeAllHelpers(TR::JitConfig *jitConfig, TR_RuntimeHelper *helperIDs, void **helperAddresses, int32_t numHelpers) { initializeJitRuntimeHelperTable(false); @@ -103,7 +103,7 @@ initializeCodeCache(TR::CodeCacheManager & codeCacheManager) codeCacheConfig._largeCodePageFlags = 0; codeCacheConfig._maxNumberOfCodeCaches = 96; codeCacheConfig._canChangeNumCodeCaches = true; - codeCacheConfig._emitExecutableELF = TR::Options::getCmdLineOptions()->getOption(TR_PerfTool) + codeCacheConfig._emitExecutableELF = TR::Options::getCmdLineOptions()->getOption(TR_PerfTool) || TR::Options::getCmdLineOptions()->getOption(TR_EmitExecutableELFFile); codeCacheConfig._emitRelocatableELF = TR::Options::getCmdLineOptions()->getOption(TR_EmitRelocatableELFFile); diff --git a/jitbuilder/env/FrontEnd.hpp b/jitbuilder/env/FrontEnd.hpp index a237370f04a..db1e2f789b3 100644 --- a/jitbuilder/env/FrontEnd.hpp +++ b/jitbuilder/env/FrontEnd.hpp @@ -27,23 +27,11 @@ #include "compiler/env/FrontEnd.hpp" #include "env/FEBase.hpp" #include "env/jittypes.h" -#include "runtime/JBJitConfig.hpp" namespace TR { class GCStackAtlas; } namespace OMR { struct MethodMetaDataPOD; } class TR_ResolvedMethod; -namespace TR -{ - -template <> struct FETraits - { - typedef JitBuilder::JitConfig JitConfig; - static const size_t DEFAULT_SEG_SIZE = (128 * 1024); // 128kb - }; - -} - namespace JitBuilder { diff --git a/jitbuilder/runtime/JBJitConfig.cpp b/jitbuilder/runtime/JBJitConfig.cpp deleted file mode 100644 index d2454620989..00000000000 --- a/jitbuilder/runtime/JBJitConfig.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright IBM Corp. and others 2000 - * - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which accompanies this - * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution and - * is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * This Source Code may also be made available under the following - * Secondary Licenses when the conditions for such availability set - * forth in the Eclipse Public License, v. 2.0 are satisfied: GNU - * General Public License, version 2 with the GNU Classpath - * Exception [1] and GNU General Public License, version 2 with the - * OpenJDK Assembly Exception [2]. - * - * [1] https://www.gnu.org/software/classpath/license.html - * [2] https://openjdk.org/legal/assembly-exception.html - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 - *******************************************************************************/ - -#include "runtime/JBJitConfig.hpp" -#include "env/FrontEnd.hpp" -#include "runtime/CodeCache.hpp" - -#if defined(TR_HOST_POWER) -//#include "p/codegen/PPCTableOfConstants.hpp" -#endif - - - - diff --git a/jitbuilder/runtime/JBJitConfig.hpp b/jitbuilder/runtime/JBJitConfig.hpp deleted file mode 100644 index 07ca7905ffd..00000000000 --- a/jitbuilder/runtime/JBJitConfig.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright IBM Corp. and others 2014 - * - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which accompanies this - * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution and - * is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * This Source Code may also be made available under the following - * Secondary Licenses when the conditions for such availability set - * forth in the Eclipse Public License, v. 2.0 are satisfied: GNU - * General Public License, version 2 with the GNU Classpath - * Exception [1] and GNU General Public License, version 2 with the - * OpenJDK Assembly Exception [2]. - * - * [1] https://www.gnu.org/software/classpath/license.html - * [2] https://openjdk.org/legal/assembly-exception.html - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 - *******************************************************************************/ - -#ifndef JITBUILDER_JITCONFIG_HPP -#define JITBUILDER_JITCONFIG_HPP - -#include "env/TRMemory.hpp" -#include "env/FEBase.hpp" -#include "env/JitConfig.hpp" - -namespace JitBuilder { class FrontEnd; } - -// Singleton JitConfig. The only instance of this is JitBuilder::FrontEnd::_jitConfig -namespace JitBuilder -{ -class JitConfig : public TR::JitConfig - { - friend class TR::FEBase; - JitConfig() : TR::JitConfig() {} - }; -} // namespace JitBuilder - -#endif // !defined(JITBUILDER_JITCONFIG_HPP) From 8b39ee4620900920d736ef26031f10a1a7ca7bca Mon Sep 17 00:00:00 2001 From: Daryl Maier Date: Thu, 21 Dec 2023 15:12:05 -0500 Subject: [PATCH 4/6] Prepare to make FrontEnd an extensible class * Eliminate FEBase, FECommon, and ConcreteFE * Remove unused Z FrontEnd function generateBinaryEncodingPrologue() * Eliminate some unnecessary #includes FrontEnd is not a true extensible class yet because of downstream dependencies on the existing compiler/env/FrontEnd.hpp. Signed-off-by: Daryl Maier --- compiler/control/CompileMethod.cpp | 9 +- compiler/control/CompileMethod.hpp | 4 +- compiler/env/CMakeLists.txt | 2 +- compiler/env/FEBase_t.hpp | 92 ------------- compiler/env/{FEBase.cpp => OMRFrontEnd.cpp} | 128 ++++++++++++++++--- compiler/env/{FEBase.hpp => OMRFrontEnd.hpp} | 93 +++++++------- compiler/env/OMRJitConfig.cpp | 4 +- compiler/runtime/Trampoline.cpp | 5 +- fvtest/compilertest/CMakeLists.txt | 1 - fvtest/compilertest/build/files/common.mk | 5 +- fvtest/compilertest/control/TestJit.cpp | 4 +- fvtest/compilertest/env/ConcreteFE.hpp | 29 ----- fvtest/compilertest/env/FrontEnd.cpp | 83 ------------ fvtest/compilertest/env/FrontEnd.hpp | 49 +------ fvtest/compilertest/tests/FooBarTest.cpp | 2 +- fvtest/compilertest/z/codegen/Evaluator.cpp | 41 +----- fvtest/compilerunittest/CompilerUnitTest.hpp | 8 +- jitbuilder/CMakeLists.txt | 1 - jitbuilder/build/files/common.mk | 6 +- jitbuilder/control/Jit.cpp | 4 +- jitbuilder/env/ConcreteFE.hpp | 31 ----- jitbuilder/env/FrontEnd.cpp | 84 ------------ jitbuilder/env/FrontEnd.hpp | 65 ++-------- jitbuilder/z/codegen/Evaluator.cpp | 43 +------ 24 files changed, 200 insertions(+), 593 deletions(-) delete mode 100644 compiler/env/FEBase_t.hpp rename compiler/env/{FEBase.cpp => OMRFrontEnd.cpp} (63%) rename compiler/env/{FEBase.hpp => OMRFrontEnd.hpp} (50%) delete mode 100644 fvtest/compilertest/env/ConcreteFE.hpp delete mode 100644 fvtest/compilertest/env/FrontEnd.cpp delete mode 100644 jitbuilder/env/ConcreteFE.hpp delete mode 100644 jitbuilder/env/FrontEnd.cpp diff --git a/compiler/control/CompileMethod.cpp b/compiler/control/CompileMethod.cpp index 9e6ae4a9dd3..ade9825e382 100644 --- a/compiler/control/CompileMethod.cpp +++ b/compiler/control/CompileMethod.cpp @@ -41,7 +41,6 @@ #include "control/Options_inlines.hpp" #include "env/CPU.hpp" #include "env/CompilerEnv.hpp" -#include "env/ConcreteFE.hpp" #include "env/IO.hpp" #include "env/JitConfig.hpp" #include "env/PersistentInfo.hpp" @@ -133,7 +132,7 @@ generatePerfToolEntry(uint8_t *startPC, uint8_t *endPC, const char *sig, const c #include "p/codegen/PPCTableOfConstants.hpp" #endif -int32_t commonJitInit(OMR::FrontEnd &fe, char *cmdLineOptions) +int32_t commonJitInit(TR::FrontEnd &fe, char *cmdLineOptions) { auto jitConfig = fe.jitConfig(); @@ -180,7 +179,7 @@ int32_t commonJitInit(OMR::FrontEnd &fe, char *cmdLineOptions) int32_t init_options(TR::JitConfig *jitConfig, char *cmdLineOptions) { - OMR::FrontEnd *fe = OMR::FrontEnd::instance(); + TR::FrontEnd *fe = TR::FrontEnd::instance(); if (cmdLineOptions) { @@ -212,7 +211,7 @@ int32_t init_options(TR::JitConfig *jitConfig, char *cmdLineOptions) return 0; } -static bool methodCanBeCompiled(OMR::FrontEnd *fe, TR_ResolvedMethod &method, TR_FilterBST *&filter, TR_Memory *trMemory) +static bool methodCanBeCompiled(TR::FrontEnd *fe, TR_ResolvedMethod &method, TR_FilterBST *&filter, TR_Memory *trMemory) { if (!method.isCompilable(trMemory)) return false; @@ -274,7 +273,7 @@ compileMethodFromDetails( int32_t &rc) { uint64_t translationStartTime = TR::Compiler->vm.getUSecClock(); - OMR::FrontEnd &fe = OMR::FrontEnd::singleton(); + TR::FrontEnd &fe = TR::FrontEnd::singleton(); auto jitConfig = fe.jitConfig(); TR::RawAllocator rawAllocator; TR::SystemSegmentProvider defaultSegmentProvider(1 << 16, rawAllocator); diff --git a/compiler/control/CompileMethod.hpp b/compiler/control/CompileMethod.hpp index 983c62c1265..bcad9f03572 100644 --- a/compiler/control/CompileMethod.hpp +++ b/compiler/control/CompileMethod.hpp @@ -21,14 +21,14 @@ #include #include "compile/CompilationTypes.hpp" -#include "env/ConcreteFE.hpp" struct OMR_VMThread; class TR_ResolvedMethod; +namespace TR { class FrontEnd; } namespace TR { class IlGeneratorMethodDetails; } namespace TR { class JitConfig; } int32_t init_options(TR::JitConfig *jitConfig, char * cmdLineOptions); -int32_t commonJitInit(OMR::FrontEnd &fe, char * cmdLineOptions); +int32_t commonJitInit(TR::FrontEnd &fe, char * cmdLineOptions); uint8_t *compileMethod(OMR_VMThread *omrVMThread, TR_ResolvedMethod &compilee, TR_Hotness hotness, int32_t &rc); uint8_t *compileMethodFromDetails(OMR_VMThread *omrVMThread, TR::IlGeneratorMethodDetails &details, TR_Hotness hotness, int32_t &rc); diff --git a/compiler/env/CMakeLists.txt b/compiler/env/CMakeLists.txt index 29182f91c21..6ba52fe0147 100644 --- a/compiler/env/CMakeLists.txt +++ b/compiler/env/CMakeLists.txt @@ -44,7 +44,7 @@ compiler_library(env # The following are listed under JIT_PRODUCT_SOURCE_FILES # (for compiler test, but not jitbuilder). # TODO: figure out why and move if required - ${CMAKE_CURRENT_LIST_DIR}/FEBase.cpp + ${CMAKE_CURRENT_LIST_DIR}/OMRFrontEnd.cpp ${CMAKE_CURRENT_LIST_DIR}/OMRJitConfig.cpp ${CMAKE_CURRENT_LIST_DIR}/OMRIO.cpp ${CMAKE_CURRENT_LIST_DIR}/OMRKnownObjectTable.cpp diff --git a/compiler/env/FEBase_t.hpp b/compiler/env/FEBase_t.hpp deleted file mode 100644 index 5c9719e7087..00000000000 --- a/compiler/env/FEBase_t.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/******************************************************************************* - * Copyright IBM Corp. and others 2000 - * - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which accompanies this - * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution - * and is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License, v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception [1] and GNU General Public - * License, version 2 with the OpenJDK Assembly Exception [2]. - * - * [1] https://www.gnu.org/software/classpath/license.html - * [2] https://openjdk.org/legal/assembly-exception.html - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 - *******************************************************************************/ - -#if defined(OMR_OS_WINDOWS) -#include -#else -#include -#endif /* OMR_OS_WINDOWS */ -#include "codegen/CodeGenerator.hpp" -#include "compile/Compilation.hpp" -#include "env/FEBase.hpp" -#include "env/jittypes.h" -#include "runtime/CodeCache.hpp" -#include "runtime/CodeCacheExceptions.hpp" -#include "runtime/CodeCacheManager.hpp" - -namespace TR -{ - -// This code does not really belong here (along with allocateRelocationData, really) -// We should be relying on the port library to allocate memory, but this connection -// has not yet been made, so as a quick workaround for platforms like OS X <= 10.9, -// where MAP_ANONYMOUS is not defined, is to map MAP_ANON to MAP_ANONYMOUS ourselves -#if defined(__APPLE__) - #if !defined(MAP_ANONYMOUS) - #define NO_MAP_ANONYMOUS - #if defined(MAP_ANON) - #define MAP_ANONYMOUS MAP_ANON - #else - #error unexpectedly, no MAP_ANONYMOUS or MAP_ANON definition - #endif - #endif -#endif /* defined(__APPLE__) */ - -template -uint8_t * -FEBase::allocateRelocationData(TR::Compilation* comp, uint32_t size) - { - /* FIXME: using an mmap without much thought into whether that is the best - way to allocate this */ - if (size == 0) return 0; - TR_ASSERT(size >= 2048, "allocateRelocationData should be used for whole-sale memory allocation only"); - -#if defined(OMR_OS_WINDOWS) - return reinterpret_cast( - VirtualAlloc(NULL, - size, - MEM_COMMIT, - PAGE_READWRITE)); -// TODO: Why is there no OMR_OS_ZOS? Or any other OS for that matter? -#elif defined(J9ZOS390) - // TODO: This is an absolute hack to get z/OS JITBuilder building and even remotely close to working. We really - // ought to be using the port library to allocate such memory. This was the quickest "workaround" I could think - // of to just get us off the ground. - return reinterpret_cast( - __malloc31(size)); -#else - return reinterpret_cast( - mmap(0, - size, - PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, - -1, - 0)); -#endif /* OMR_OS_WINDOWS */ - } - -// keep the impact of this fix localized -#if defined(NO_MAP_ANONYMOUS) - #undef MAP_ANONYMOUS - #undef NO_MAP_ANONYMOUS -#endif - -} /* namespace TR */ diff --git a/compiler/env/FEBase.cpp b/compiler/env/OMRFrontEnd.cpp similarity index 63% rename from compiler/env/FEBase.cpp rename to compiler/env/OMRFrontEnd.cpp index 3316fa5bdc5..a61c246677a 100644 --- a/compiler/env/FEBase.cpp +++ b/compiler/env/OMRFrontEnd.cpp @@ -20,37 +20,131 @@ *******************************************************************************/ #include -#include "codegen/CodeGenerator.hpp" -#include "compile/CompilationTypes.hpp" +#include "compile/Compilation.hpp" +#include "compile/Method.hpp" #include "compile/ResolvedMethod.hpp" #include "control/CompileMethod.hpp" #include "control/Options.hpp" #include "control/OptionsUtil.hpp" #include "control/Options_inlines.hpp" #include "env/CompilerEnv.hpp" -#include "env/ConcreteFE.hpp" -#include "env/FEBase.hpp" -#include "env/IO.hpp" +#include "env/FrontEnd.hpp" #include "env/JitConfig.hpp" #include "env/VerboseLog.hpp" #include "env/jittypes.h" -#include "compile/CompilationException.hpp" -#include "il/ILOps.hpp" -#include "il/ILOps.hpp" -#include "il/Node.hpp" -#include "il/Node_inlines.hpp" +#include "infra/Assert.hpp" +#include "runtime/CodeCacheManager.hpp" -TR::FECommon::FECommon() - : TR_FrontEnd() - {} +#if defined(OMR_OS_WINDOWS) +#include +#else +#include +#endif /* OMR_OS_WINDOWS */ +TR::FrontEnd *OMR::FrontEnd::_instance = NULL; + +OMR::FrontEnd::FrontEnd() : + ::TR_FrontEnd(), + _config(), + _codeCacheManager(TR::Compiler->rawAllocator), + _persistentMemory(jitConfig(), TR::Compiler->persistentAllocator()) + { + TR_ASSERT_FATAL(!_instance, "FrontEnd must be initialized only once"); + _instance = static_cast(this); + ::trPersistentMemory = &_persistentMemory; + } + +TR::FrontEnd & +OMR::FrontEnd::singleton() + { + return *_instance; + } + +TR::FrontEnd * +OMR::FrontEnd::instance() + { + TR_ASSERT_FATAL(_instance, "FrontEnd not initialized"); + return _instance; + } + TR_Debug * -TR::FECommon::createDebug( TR::Compilation *comp) +OMR::FrontEnd::createDebug(TR::Compilation *comp) { return createDebugObject(comp); } +void +OMR::FrontEnd::reserveTrampolineIfNecessary(TR::Compilation *comp, TR::SymbolReference *symRef, bool inBinaryEncoding) + { + // Do we handle trampoline reservations? return here for now. + return; + } + +TR_ResolvedMethod * +OMR::FrontEnd::createResolvedMethod( + TR_Memory *trMemory, + TR_OpaqueMethodBlock *aMethod, + TR_ResolvedMethod *owningMethod, + TR_OpaqueClassBlock *classForNewInstance) + { + return new (trMemory->trHeapMemory()) TR::ResolvedMethod(aMethod); + } + +// This code does not really belong here (along with allocateRelocationData, really) +// We should be relying on the port library to allocate memory, but this connection +// has not yet been made, so as a quick workaround for platforms like OS X <= 10.9, +// where MAP_ANONYMOUS is not defined, is to map MAP_ANON to MAP_ANONYMOUS ourselves +#if defined(__APPLE__) + #if !defined(MAP_ANONYMOUS) + #define NO_MAP_ANONYMOUS + #if defined(MAP_ANON) + #define MAP_ANONYMOUS MAP_ANON + #else + #error unexpectedly, no MAP_ANONYMOUS or MAP_ANON definition + #endif + #endif +#endif /* defined(__APPLE__) */ + +uint8_t * +OMR::FrontEnd::allocateRelocationData(TR::Compilation *comp, uint32_t size) + { + /* FIXME: using an mmap without much thought into whether that is the best + way to allocate this */ + if (size == 0) return 0; + TR_ASSERT(size >= 2048, "allocateRelocationData should be used for whole-sale memory allocation only"); + +#if defined(OMR_OS_WINDOWS) + return reinterpret_cast( + VirtualAlloc(NULL, + size, + MEM_COMMIT, + PAGE_READWRITE)); +// TODO: Why is there no OMR_OS_ZOS? Or any other OS for that matter? +#elif defined(J9ZOS390) + // TODO: This is an absolute hack to get z/OS JITBuilder building and even remotely close to working. We really + // ought to be using the port library to allocate such memory. This was the quickest "workaround" I could think + // of to just get us off the ground. + return reinterpret_cast( + __malloc31(size)); +#else + return reinterpret_cast( + mmap(0, + size, + PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, + -1, + 0)); +#endif /* OMR_OS_WINDOWS */ + } + +// keep the impact of this fix localized +#if defined(NO_MAP_ANONYMOUS) + #undef MAP_ANONYMOUS + #undef NO_MAP_ANONYMOUS +#endif + + extern "C" { // use libc for all this stuff @@ -91,10 +185,6 @@ char *feGetEnv(const char *s) } -// Options stuff -#include "control/Options.hpp" -#include "control/Options_inlines.hpp" - #if defined(LINUX) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Winvalid-offsetof" @@ -134,7 +224,7 @@ TR::OptionTable OMR::Options::_feOptions[] = #include "control/Recompilation.hpp" -// S390 specific fucntion - FIXME: make this only be a problem when HOST is s390. Also, use a better +// S390 specific function - FIXME: make this only be a problem when HOST is s390. Also, use a better // name for this void setDllSlip(const char *CodeStart, const char *CodeEnd, const char *dllName, TR::Compilation *comp) { TR_UNIMPLEMENTED(); } diff --git a/compiler/env/FEBase.hpp b/compiler/env/OMRFrontEnd.hpp similarity index 50% rename from compiler/env/FEBase.hpp rename to compiler/env/OMRFrontEnd.hpp index be3ac1eca69..bffda7f9c80 100644 --- a/compiler/env/FEBase.hpp +++ b/compiler/env/OMRFrontEnd.hpp @@ -19,80 +19,77 @@ * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 *******************************************************************************/ -#ifndef FEBASE_HPP_JniLXw -#define FEBASE_HPP_JniLXw - -#include "compiler/env/FrontEnd.hpp" +#ifndef OMR_FRONTEND_INCL +#define OMR_FRONTEND_INCL + +/* + * The following #define and typedef must appear before any #includes in this file + */ +#ifndef OMR_FRONTEND_CONNECTOR +#define OMR_FRONTEND_CONNECTOR +namespace OMR { class FrontEnd; } +namespace OMR { typedef OMR::FrontEnd FrontEndConnector; } +#endif #include "compile/CompilationTypes.hpp" +#include "compiler/env/FrontEnd.hpp" +#include "env/CompilerEnv.hpp" +#include "env/JitConfig.hpp" #include "env/jittypes.h" +#include "infra/Annotations.hpp" #include "runtime/CodeCache.hpp" #include "runtime/CodeCacheManager.hpp" -#include "env/CompilerEnv.hpp" -#include "env/JitConfig.hpp" +namespace TR { class FrontEnd; } class TR_ResolvedMethod; -namespace TR +namespace OMR +{ + +class OMR_EXTENSIBLE FrontEnd : public ::TR_FrontEnd { -// ::TR_FrontEnd: defines the API that can be used across the codebase for both TR and OMR -// FECommon: is a repository of code and data that is common to all OMR frontends but not all TR frontends -// FEBase: is a repository of code and data that is specific to a single frontend, but described as an abstract templat -// based on the type D -// D: concrete frontend. Stuff that is not common with other frontends. +public: -class FECommon : public ::TR_FrontEnd - { - protected: - FECommon(); + FrontEnd(); + static TR::FrontEnd &singleton(); - public: - virtual TR_PersistentMemory * persistentMemory() = 0; + static TR::FrontEnd *instance(); virtual TR_Debug *createDebug(TR::Compilation *comp = NULL); - virtual TR_OpaqueClassBlock * getClassFromSignature(const char * sig, int32_t length, TR_ResolvedMethod *method, bool isVettedForAOT=false) { return NULL; } - virtual TR_OpaqueClassBlock * getClassFromSignature(const char * sig, int32_t length, TR_OpaqueMethodBlock *method, bool isVettedForAOT=false) { return NULL; } - virtual const char * sampleSignature(TR_OpaqueMethodBlock * aMethod, char *buf, int32_t bufLen, TR_Memory *memory) { return NULL; } + virtual TR_OpaqueClassBlock *getClassFromSignature(const char *sig, int32_t length, TR_ResolvedMethod *method, bool isVettedForAOT=false) { return NULL; } + virtual TR_OpaqueClassBlock *getClassFromSignature(const char *sig, int32_t length, TR_OpaqueMethodBlock *method, bool isVettedForAOT=false) { return NULL; } + virtual const char *sampleSignature(TR_OpaqueMethodBlock *aMethod, char *buf, int32_t bufLen, TR_Memory *memory) { return NULL; } // need this so z codegen can create a sym ref to compare to another sym ref it cannot possibly be equal to virtual uintptr_t getOffsetOfIndexableSizeField() { return -1; } - }; -template -class FEBase : public FECommon - { - private: - TR::JitConfig _config; - TR::CodeCacheManager _codeCacheManager; + TR::JitConfig *jitConfig() { return &_config; } + TR::CodeCacheManager &codeCacheManager() { return _codeCacheManager; } - // this is deprecated in favour of TR::Allocator - TR_PersistentMemory _persistentMemory; // global memory + virtual uint8_t *allocateRelocationData(TR::Compilation *comp, uint32_t size); - public: - FEBase() - : FECommon(), - _config(), - _codeCacheManager(TR::Compiler->rawAllocator), - _persistentMemory(jitConfig(), TR::Compiler->persistentAllocator()) - { - ::trPersistentMemory = &_persistentMemory; - } + virtual TR_PersistentMemory *persistentMemory() { return &_persistentMemory; } + virtual TR::PersistentInfo *getPersistentInfo() { return _persistentMemory.getPersistentInfo(); } - static Derived &singleton() { return *(Derived::instance()); } + virtual void reserveTrampolineIfNecessary(TR::Compilation *comp, TR::SymbolReference *symRef, bool inBinaryEncoding); - TR::JitConfig *jitConfig() { return &_config; } - TR::CodeCacheManager &codeCacheManager() { return _codeCacheManager; } + TR_ResolvedMethod *createResolvedMethod(TR_Memory *trMemory, TR_OpaqueMethodBlock *aMethod, + TR_ResolvedMethod *owningMethod, TR_OpaqueClassBlock *classForNewInstance); + +private: - virtual uint8_t * allocateRelocationData(TR::Compilation* comp, uint32_t size); + TR::JitConfig _config; + TR::CodeCacheManager _codeCacheManager; - virtual TR_PersistentMemory * persistentMemory() { return &_persistentMemory; } - virtual TR::PersistentInfo * getPersistentInfo() { return _persistentMemory.getPersistentInfo(); } + // this is deprecated in favour of TR::Allocator + TR_PersistentMemory _persistentMemory; // global memory - }; + static TR::FrontEnd *_instance; +}; -} /* namespace TR */ +} -#endif /* FEBASE_HPP_JniLXw */ +#endif diff --git a/compiler/env/OMRJitConfig.cpp b/compiler/env/OMRJitConfig.cpp index e836c7b69d0..f8b8d2dc925 100644 --- a/compiler/env/OMRJitConfig.cpp +++ b/compiler/env/OMRJitConfig.cpp @@ -21,7 +21,7 @@ #include "env/JitConfig.hpp" #include -#include "env/ConcreteFE.hpp" +#include "env/FrontEnd.hpp" TR::JitConfig * OMR::JitConfig::self() @@ -38,5 +38,5 @@ OMR::JitConfig::JitConfig() TR::JitConfig * OMR::JitConfig::instance() { - return OMR::FrontEnd::singleton().jitConfig(); + return TR::FrontEnd::singleton().jitConfig(); } diff --git a/compiler/runtime/Trampoline.cpp b/compiler/runtime/Trampoline.cpp index 9236d327370..018099ba94b 100644 --- a/compiler/runtime/Trampoline.cpp +++ b/compiler/runtime/Trampoline.cpp @@ -33,9 +33,6 @@ #include "runtime/Runtime.hpp" #include "env/CompilerEnv.hpp" -#if defined(JITTEST) -#include "env/ConcreteFE.hpp" -#endif namespace TR { class CodeGenerator; } @@ -76,7 +73,7 @@ extern void registerTrampoline(uint8_t *start, uint32_t size, const char *name); void ppcCreateHelperTrampolines(uint8_t *trampPtr, int32_t numHelpers) { - TR::CodeCacheManager &manager = OMR::FrontEnd::singleton().codeCacheManager(); + TR::CodeCacheManager &manager = TR::FrontEnd::singleton().codeCacheManager(); TR::CodeCacheConfig &config = manager.codeCacheConfig(); char name[256]; diff --git a/fvtest/compilertest/CMakeLists.txt b/fvtest/compilertest/CMakeLists.txt index 8e5a91439d7..20d38fe1775 100644 --- a/fvtest/compilertest/CMakeLists.txt +++ b/fvtest/compilertest/CMakeLists.txt @@ -24,7 +24,6 @@ include(OmrCompilerSupport) set(COMPILERTEST_FILES compile/ResolvedMethod.cpp control/TestJit.cpp - env/FrontEnd.cpp ilgen/IlInjector.cpp ilgen/TestIlGeneratorMethodDetails.cpp runtime/TestCodeCacheManager.cpp diff --git a/fvtest/compilertest/build/files/common.mk b/fvtest/compilertest/build/files/common.mk index faa8909db28..0a40aa0141a 100644 --- a/fvtest/compilertest/build/files/common.mk +++ b/fvtest/compilertest/build/files/common.mk @@ -29,6 +29,8 @@ JIT_PRODUCT_BACKEND_SOURCES+=\ $(JIT_OMR_DIRTY_DIR)/control/OMRRecompilation.cpp \ $(JIT_OMR_DIRTY_DIR)/env/ExceptionTable.cpp \ $(JIT_OMR_DIRTY_DIR)/env/FrontEnd.cpp \ + $(JIT_OMR_DIRTY_DIR)/env/OMRFrontEnd.cpp \ + $(JIT_OMR_DIRTY_DIR)/env/OMRJitConfig.cpp \ $(JIT_OMR_DIRTY_DIR)/infra/Assert.cpp \ $(JIT_OMR_DIRTY_DIR)/infra/BitVector.cpp \ $(JIT_OMR_DIRTY_DIR)/infra/Checklist.cpp \ @@ -242,8 +244,6 @@ JIT_PRODUCT_SOURCE_FILES+=\ $(JIT_PRODUCT_DIR)/tests/TestDriver.cpp \ $(JIT_PRODUCT_DIR)/tests/X86OpCodesTest.cpp \ $(JIT_PRODUCT_DIR)/tests/main.cpp \ - $(JIT_OMR_DIRTY_DIR)/env/FEBase.cpp \ - $(JIT_OMR_DIRTY_DIR)/env/JitConfig.cpp \ $(JIT_OMR_DIRTY_DIR)/control/CompilationController.cpp \ $(JIT_OMR_DIRTY_DIR)/control/OMRCompilationStrategy.cpp \ $(JIT_OMR_DIRTY_DIR)/optimizer/FEInliner.cpp \ @@ -280,7 +280,6 @@ JIT_PRODUCT_SOURCE_FILES+=\ $(JIT_OMR_DIRTY_DIR)/runtime/OMRRSSReport.cpp \ $(JIT_PRODUCT_DIR)/compile/ResolvedMethod.cpp \ $(JIT_PRODUCT_DIR)/control/TestJit.cpp \ - $(JIT_PRODUCT_DIR)/env/FrontEnd.cpp \ $(JIT_PRODUCT_DIR)/ilgen/IlInjector.cpp \ $(JIT_PRODUCT_DIR)/ilgen/TestIlGeneratorMethodDetails.cpp \ $(JIT_PRODUCT_DIR)/runtime/TestCodeCacheManager.cpp diff --git a/fvtest/compilertest/control/TestJit.cpp b/fvtest/compilertest/control/TestJit.cpp index 99d017e5791..e72dd065aaa 100644 --- a/fvtest/compilertest/control/TestJit.cpp +++ b/fvtest/compilertest/control/TestJit.cpp @@ -165,7 +165,7 @@ initializeTestJit(TR_RuntimeHelper *helperIDs, void **helperAddresses, int32_t n TR::Compiler->initialize(); // -------------------------------------------------------------------------- - static TestCompiler::FrontEnd fe; + static TR::FrontEnd fe; auto jitConfig = fe.jitConfig(); initializeAllHelpers(jitConfig, helperIDs, helperAddresses, numHelpers); @@ -196,7 +196,7 @@ extern "C" void shutdownJit() { - auto fe = TestCompiler::FrontEnd::instance(); + auto fe = TR::FrontEnd::instance(); TR::CodeCacheManager &codeCacheManager = fe->codeCacheManager(); codeCacheManager.destroy(); diff --git a/fvtest/compilertest/env/ConcreteFE.hpp b/fvtest/compilertest/env/ConcreteFE.hpp deleted file mode 100644 index 22d08b6e74a..00000000000 --- a/fvtest/compilertest/env/ConcreteFE.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright IBM Corp. and others 2000 - * - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which accompanies this - * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution - * and is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License, v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception [1] and GNU General Public - * License, version 2 with the OpenJDK Assembly Exception [2]. - * - * [1] https://www.gnu.org/software/classpath/license.html - * [2] https://openjdk.org/legal/assembly-exception.html - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 - *******************************************************************************/ - -#include "env/FrontEnd.hpp" - -// translate TestCompiler::FrontEnd into the OMR namespace as the frontend so that everyone -// can use that -namespace OMR -{ -typedef TestCompiler::FrontEnd FrontEnd; -} diff --git a/fvtest/compilertest/env/FrontEnd.cpp b/fvtest/compilertest/env/FrontEnd.cpp deleted file mode 100644 index 8c317d1bf77..00000000000 --- a/fvtest/compilertest/env/FrontEnd.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright IBM Corp. and others 2000 - * - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which accompanies this - * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution - * and is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * This Source Code may also be made available under the following Secondary - * Licenses when the conditions for such availability set forth in the - * Eclipse Public License, v. 2.0 are satisfied: GNU General Public License, - * version 2 with the GNU Classpath Exception [1] and GNU General Public - * License, version 2 with the OpenJDK Assembly Exception [2]. - * - * [1] https://www.gnu.org/software/classpath/license.html - * [2] https://openjdk.org/legal/assembly-exception.html - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 - *******************************************************************************/ - -#include "env/FrontEnd.hpp" - -#include -#include -#include "codegen/CodeGenerator.hpp" -#include "codegen/GCStackAtlas.hpp" -#include "codegen/GCStackMap.hpp" -#include "compile/ResolvedMethod.hpp" -#include "compile/Compilation.hpp" -#include "env/FEBase_t.hpp" -#include "env/Processors.hpp" -#include "env/jittypes.h" -#include "il/DataTypes.hpp" -#include "il/ILOps.hpp" -#include "runtime/CodeMetaDataPOD.hpp" -#include "runtime/StackAtlasPOD.hpp" - -//#include "util_api.h" - -#define RANGE_NEEDS_FOUR_BYTE_OFFSET(r) (((r) >= (USHRT_MAX )) ? 1 : 0) - -namespace TestCompiler -{ - -FrontEnd *FrontEnd::_instance = 0; - -FrontEnd::FrontEnd() - : TR::FEBase() - { - TR_ASSERT(!_instance, "FrontEnd must be initialized only once"); - _instance = this; - } - -void -FrontEnd::reserveTrampolineIfNecessary(TR::Compilation *comp, TR::SymbolReference *symRef, bool inBinaryEncoding) - { - // Do we handle trampoline reservations? return here for now. - return; - } - -TR_ResolvedMethod * -FrontEnd::createResolvedMethod(TR_Memory * trMemory, TR_OpaqueMethodBlock * aMethod, - TR_ResolvedMethod * owningMethod, TR_OpaqueClassBlock *classForNewInstance) - { - return new (trMemory->trHeapMemory()) ResolvedMethod(aMethod); - } - -intptr_t -FrontEnd::methodTrampolineLookup(TR::Compilation *comp, TR::SymbolReference *symRef, void *callSite) - { - TR_UNIMPLEMENTED(); - return 0; - } - - -// ----------------------------------------------------------------------------- - - - - - -} //namespace TestCompiler diff --git a/fvtest/compilertest/env/FrontEnd.hpp b/fvtest/compilertest/env/FrontEnd.hpp index aaaa300b05f..d9eadd1f946 100644 --- a/fvtest/compilertest/env/FrontEnd.hpp +++ b/fvtest/compilertest/env/FrontEnd.hpp @@ -19,55 +19,20 @@ * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 *******************************************************************************/ -#ifndef TESTFE_INCL -#define TESTFE_INCL +#ifndef TR_FRONTEND_INCL +#define TR_FRONTEND_INCL -#include -#include "compiler/env/FrontEnd.hpp" -#include "env/FEBase.hpp" -#include "env/jittypes.h" +#include "env/OMRFrontEnd.hpp" -namespace TR { class GCStackAtlas; } -namespace OMR { struct MethodMetaDataPOD; } -class TR_ResolvedMethod; - -namespace TestCompiler +namespace TR { - -class FrontEnd : public TR::FEBase +class OMR_EXTENSIBLE FrontEnd : public OMR::FrontEndConnector { - private: - static FrontEnd *_instance; /* singleton */ - public: - FrontEnd(); - static FrontEnd *instance() { TR_ASSERT(_instance, "bad singleton"); return _instance; } - - virtual void reserveTrampolineIfNecessary(TR::Compilation *comp, TR::SymbolReference *symRef, bool inBinaryEncoding); - -#if defined(TR_TARGET_S390) - virtual void generateBinaryEncodingPrologue(TR_BinaryEncodingData *beData, TR::CodeGenerator *cg); -#endif - - virtual intptr_t methodTrampolineLookup(TR::Compilation *comp, TR::SymbolReference *symRef, void *currentCodeCache); - - TR_ResolvedMethod * createResolvedMethod(TR_Memory * trMemory, TR_OpaqueMethodBlock * aMethod, - TR_ResolvedMethod * owningMethod, TR_OpaqueClassBlock *classForNewInstance); - + FrontEnd() : OMR::FrontEndConnector() {} }; - -} // namespace TestCompiler - -namespace TR -{ -class FrontEnd : public TestCompiler::FrontEnd - { - public: - FrontEnd(); - }; - -} // namespace TR +} #endif diff --git a/fvtest/compilertest/tests/FooBarTest.cpp b/fvtest/compilertest/tests/FooBarTest.cpp index df873eff334..d37c6dc4328 100644 --- a/fvtest/compilertest/tests/FooBarTest.cpp +++ b/fvtest/compilertest/tests/FooBarTest.cpp @@ -128,7 +128,7 @@ FooBarTest::invokeTests() // This test will get assertion on S390-64, because of // "compiler/codegen/FrontEnd.cpp" TR_FrontEnd::methodTrampolineLookup is unimplemented and -// "test/env/FrontEnd.cpp" TestCompiler::FrontEnd::methodTrampolineLookup is "methodTrampolineLookup not implemented yet". +// "test/env/FrontEnd.cpp" TR::FrontEnd::methodTrampolineLookup is "methodTrampolineLookup not implemented yet". // This test also failed intermittent (segfault) on PPCLE, temporarily disabled this test on PPCLE, under track of Work Item // Please remove this #ifdef after those functions are implemented. #if defined(TR_TARGET_X86) || defined(TR_TARGET_S390) && !defined(TR_TARGET_64BIT) && !defined(J9ZOS390) diff --git a/fvtest/compilertest/z/codegen/Evaluator.cpp b/fvtest/compilertest/z/codegen/Evaluator.cpp index 634f4732586..e2b5bd7c79f 100644 --- a/fvtest/compilertest/z/codegen/Evaluator.cpp +++ b/fvtest/compilertest/z/codegen/Evaluator.cpp @@ -20,7 +20,7 @@ *******************************************************************************/ #include "codegen/CodeGenerator.hpp" -#include "env/ConcreteFE.hpp" +#include "env/FrontEnd.hpp" #include "z/codegen/S390GenerateInstructions.hpp" #include "z/codegen/SystemLinkage.hpp" #include "codegen/S390Snippets.hpp" @@ -47,42 +47,3 @@ TR_Debug::print(TR::FILE *pOutFile, TR::S390RestoreGPR7Snippet *snippet) { TR_UNIMPLEMENTED(); } - -void -TestCompiler::FrontEnd::generateBinaryEncodingPrologue( - TR_BinaryEncodingData *beData, - TR::CodeGenerator *cg) - { - TR::Compilation* comp = cg->comp(); - TR_S390BinaryEncodingData *data = (TR_S390BinaryEncodingData *)beData; - - data->cursorInstruction = cg->getFirstInstruction(); - data->estimate = 0; - data->preProcInstruction = data->cursorInstruction; - data->jitTojitStart = data->cursorInstruction; - data->cursorInstruction = NULL; - - TR::Instruction * preLoadArgs, * endLoadArgs; - preLoadArgs = data->preProcInstruction; - endLoadArgs = preLoadArgs; - - TR::Instruction * oldFirstInstruction = data->cursorInstruction; - - data->cursorInstruction = cg->getFirstInstruction(); - - static char *disableAlignJITEP = feGetEnv("TR_DisableAlignJITEP"); - - // Padding for JIT Entry Point - if (!disableAlignJITEP) - { - data->estimate += 256; - } - - while (data->cursorInstruction && data->cursorInstruction->getOpCodeValue() != TR::InstOpCode::proc) - { - data->estimate = data->cursorInstruction->estimateBinaryLength(data->estimate); - data->cursorInstruction = data->cursorInstruction->getNext(); - } - - cg->getLinkage()->createPrologue(data->cursorInstruction); - } diff --git a/fvtest/compilerunittest/CompilerUnitTest.hpp b/fvtest/compilerunittest/CompilerUnitTest.hpp index cb2a749333f..e63f352f93e 100644 --- a/fvtest/compilerunittest/CompilerUnitTest.hpp +++ b/fvtest/compilerunittest/CompilerUnitTest.hpp @@ -28,7 +28,7 @@ #include "Jit.hpp" #include "codegen/CodeGenerator.hpp" #include "compile/Compilation.hpp" -#include "env/ConcreteFE.hpp" +#include "env/FrontEnd.hpp" #include "env/SystemSegmentProvider.hpp" #include "ilgen/IlGenRequest.hpp" #include "ilgen/IlGeneratorMethodDetails.hpp" @@ -57,7 +57,7 @@ class NullIlGenRequest : public TR::IlGenRequest { virtual void print(TR_FrontEnd *fe, TR::FILE *file, const char *suffix) {} - + }; class JitInitializer { @@ -81,12 +81,12 @@ class CompilerUnitTest : public ::testing::Test { _rawAllocator(), _segmentProvider(1 << 16, _rawAllocator), _dispatchRegion(_segmentProvider, _rawAllocator), - _trMemory(*OMR::FrontEnd::singleton().persistentMemory(), _dispatchRegion), + _trMemory(*TR::FrontEnd::singleton().persistentMemory(), _dispatchRegion), _types(), _options(), _ilGenRequest(), _method("compunittest", "0", "test", 0, NULL, _types.NoType, NULL, NULL), - _comp(0, NULL, &OMR::FrontEnd::singleton(), &_method, _ilGenRequest, _options, _dispatchRegion, &_trMemory, TR_OptimizationPlan::alloc(warm)) { + _comp(0, NULL, &TR::FrontEnd::singleton(), &_method, _ilGenRequest, _options, _dispatchRegion, &_trMemory, TR_OptimizationPlan::alloc(warm)) { _symbol = TR::ResolvedMethodSymbol::create(_comp.trStackMemory(), &_method, &_comp); TR::CFG* cfg = new (region()) TR::CFG(&_comp, _symbol, region()); _symbol->setFlowGraph(cfg); diff --git a/jitbuilder/CMakeLists.txt b/jitbuilder/CMakeLists.txt index a0978e8da4a..2b891284543 100644 --- a/jitbuilder/CMakeLists.txt +++ b/jitbuilder/CMakeLists.txt @@ -26,7 +26,6 @@ find_package(PythonInterp REQUIRED) # JitBuilder Files set(JITBUILDER_OBJECTS - env/FrontEnd.cpp compile/ResolvedMethod.cpp control/Jit.cpp ilgen/JBIlGeneratorMethodDetails.cpp diff --git a/jitbuilder/build/files/common.mk b/jitbuilder/build/files/common.mk index cb12979003c..4d22966fa02 100644 --- a/jitbuilder/build/files/common.mk +++ b/jitbuilder/build/files/common.mk @@ -84,6 +84,8 @@ JIT_PRODUCT_BACKEND_SOURCES+=\ $(JIT_OMR_DIRTY_DIR)/env/TRPersistentMemory.cpp \ $(JIT_OMR_DIRTY_DIR)/env/VerboseLog.cpp \ $(JIT_OMR_DIRTY_DIR)/env/FrontEnd.cpp \ + $(JIT_OMR_DIRTY_DIR)/env/OMRFrontEnd.cpp \ + $(JIT_OMR_DIRTY_DIR)/env/OMRJitConfig.cpp \ $(JIT_OMR_DIRTY_DIR)/il/OMRDataTypes.cpp \ $(JIT_OMR_DIRTY_DIR)/il/OMRTreeTop.cpp \ $(JIT_OMR_DIRTY_DIR)/il/OMRILOps.cpp \ @@ -213,8 +215,6 @@ JIT_PRODUCT_BACKEND_SOURCES+=\ $(JIT_OMR_DIRTY_DIR)/codegen/OMRInstruction.cpp \ $(JIT_OMR_DIRTY_DIR)/codegen/ELFGenerator.cpp \ $(JIT_OMR_DIRTY_DIR)/codegen/OMRELFRelocationResolver.cpp \ - $(JIT_OMR_DIRTY_DIR)/env/FEBase.cpp \ - $(JIT_OMR_DIRTY_DIR)/env/JitConfig.cpp \ $(JIT_OMR_DIRTY_DIR)/control/CompilationController.cpp \ $(JIT_OMR_DIRTY_DIR)/control/OMRCompilationStrategy.cpp \ $(JIT_OMR_DIRTY_DIR)/optimizer/FEInliner.cpp \ @@ -251,11 +251,9 @@ JIT_PRODUCT_BACKEND_SOURCES+=\ $(JIT_OMR_DIRTY_DIR)/env/PersistentAllocator.cpp \ $(JIT_PRODUCT_DIR)/compile/ResolvedMethod.cpp \ $(JIT_PRODUCT_DIR)/control/Jit.cpp \ - $(JIT_PRODUCT_DIR)/env/FrontEnd.cpp \ $(JIT_PRODUCT_DIR)/ilgen/JBIlGeneratorMethodDetails.cpp \ $(JIT_PRODUCT_DIR)/optimizer/JBOptimizer.cpp \ $(JIT_PRODUCT_DIR)/runtime/JBCodeCacheManager.cpp \ - $(JIT_PRODUCT_DIR)/runtime/JBJitConfig.cpp \ CPP_GENERATED_SOURCE_DIR=$(JIT_PRODUCT_DIR)/client/cpp CPP_GENERATED_API_SOURCES+=\ diff --git a/jitbuilder/control/Jit.cpp b/jitbuilder/control/Jit.cpp index 11518e4601b..ba95308b3f9 100644 --- a/jitbuilder/control/Jit.cpp +++ b/jitbuilder/control/Jit.cpp @@ -136,7 +136,7 @@ initializeJitBuilder(TR_RuntimeHelper *helperIDs, void **helperAddresses, int32_ TR::Compiler->initialize(); // -------------------------------------------------------------------------- - static JitBuilder::FrontEnd fe; + static TR::FrontEnd fe; auto jitConfig = fe.jitConfig(); initializeAllHelpers(jitConfig, helperIDs, helperAddresses, numHelpers); @@ -214,7 +214,7 @@ internal_compileMethodBuilder(TR::MethodBuilder *m, void **entry) void internal_shutdownJit() { - auto fe = JitBuilder::FrontEnd::instance(); + auto fe = TR::FrontEnd::instance(); TR::CodeCacheManager &codeCacheManager = fe->codeCacheManager(); codeCacheManager.destroy(); diff --git a/jitbuilder/env/ConcreteFE.hpp b/jitbuilder/env/ConcreteFE.hpp deleted file mode 100644 index b43eac4085f..00000000000 --- a/jitbuilder/env/ConcreteFE.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright IBM Corp. and others 2014 - * - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which accompanies this - * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution and - * is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * This Source Code may also be made available under the following - * Secondary Licenses when the conditions for such availability set - * forth in the Eclipse Public License, v. 2.0 are satisfied: GNU - * General Public License, version 2 with the GNU Classpath - * Exception [1] and GNU General Public License, version 2 with the - * OpenJDK Assembly Exception [2]. - * - * [1] https://www.gnu.org/software/classpath/license.html - * [2] https://openjdk.org/legal/assembly-exception.html - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 - *******************************************************************************/ - -#include "env/FrontEnd.hpp" - -// translate JitBuilder::FrontEnd into the OMR namespace as the frontend so that everyone -// can use that -namespace OMR -{ -typedef JitBuilder::FrontEnd FrontEnd; -} - diff --git a/jitbuilder/env/FrontEnd.cpp b/jitbuilder/env/FrontEnd.cpp deleted file mode 100644 index 8ca9f170f0a..00000000000 --- a/jitbuilder/env/FrontEnd.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright IBM Corp. and others 2000 - * - * This program and the accompanying materials are made available under - * the terms of the Eclipse Public License 2.0 which accompanies this - * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution and - * is available at https://www.apache.org/licenses/LICENSE-2.0. - * - * This Source Code may also be made available under the following - * Secondary Licenses when the conditions for such availability set - * forth in the Eclipse Public License, v. 2.0 are satisfied: GNU - * General Public License, version 2 with the GNU Classpath - * Exception [1] and GNU General Public License, version 2 with the - * OpenJDK Assembly Exception [2]. - * - * [1] https://www.gnu.org/software/classpath/license.html - * [2] https://openjdk.org/legal/assembly-exception.html - * - * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 - *******************************************************************************/ - -#include "env/FrontEnd.hpp" - -#include -#include -#include -#include "codegen/CodeGenerator.hpp" -#include "codegen/GCStackAtlas.hpp" -#include "codegen/GCStackMap.hpp" -#include "compile/ResolvedMethod.hpp" -#include "compile/Compilation.hpp" -#include "compile/Method.hpp" -#include "env/FEBase_t.hpp" -#include "env/Processors.hpp" -#include "env/jittypes.h" -#include "il/DataTypes.hpp" -#include "il/ILOps.hpp" -#include "runtime/CodeMetaDataPOD.hpp" -#include "runtime/StackAtlasPOD.hpp" - -//#include "util_api.h" - -#define RANGE_NEEDS_FOUR_BYTE_OFFSET(r) (((r) >= (USHRT_MAX )) ? 1 : 0) - -namespace JitBuilder -{ - -FrontEnd *FrontEnd::_instance = 0; - -FrontEnd::FrontEnd() - : TR::FEBase() - { - TR_ASSERT(!_instance, "FrontEnd must be initialized only once"); - _instance = this; - } - -void -FrontEnd::reserveTrampolineIfNecessary(TR::Compilation *comp, TR::SymbolReference *symRef, bool inBinaryEncoding) - { - // Do we handle trampoline reservations? return here for now. - return; - } - - -TR_ResolvedMethod * -FrontEnd::createResolvedMethod(TR_Memory * trMemory, TR_OpaqueMethodBlock * aMethod, - TR_ResolvedMethod * owningMethod, TR_OpaqueClassBlock *classForNewInstance) - { - return new (trMemory->trHeapMemory()) ResolvedMethod(aMethod); - } - -intptr_t -FrontEnd::methodTrampolineLookup(TR::Compilation *comp, TR::SymbolReference *symRef, void *callSite) - { - TR_UNIMPLEMENTED(); - return 0; - } - -// ----------------------------------------------------------------------------- - - - -} //namespace JitBuilder diff --git a/jitbuilder/env/FrontEnd.hpp b/jitbuilder/env/FrontEnd.hpp index db1e2f789b3..d9eadd1f946 100644 --- a/jitbuilder/env/FrontEnd.hpp +++ b/jitbuilder/env/FrontEnd.hpp @@ -4,15 +4,14 @@ * This program and the accompanying materials are made available under * the terms of the Eclipse Public License 2.0 which accompanies this * distribution and is available at https://www.eclipse.org/legal/epl-2.0/ - * or the Apache License, Version 2.0 which accompanies this distribution and - * is available at https://www.apache.org/licenses/LICENSE-2.0. + * or the Apache License, Version 2.0 which accompanies this distribution + * and is available at https://www.apache.org/licenses/LICENSE-2.0. * - * This Source Code may also be made available under the following - * Secondary Licenses when the conditions for such availability set - * forth in the Eclipse Public License, v. 2.0 are satisfied: GNU - * General Public License, version 2 with the GNU Classpath - * Exception [1] and GNU General Public License, version 2 with the - * OpenJDK Assembly Exception [2]. + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License, v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception [1] and GNU General Public + * License, version 2 with the OpenJDK Assembly Exception [2]. * * [1] https://www.gnu.org/software/classpath/license.html * [2] https://openjdk.org/legal/assembly-exception.html @@ -20,56 +19,20 @@ * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0 *******************************************************************************/ -#ifndef TESTFE_INCL -#define TESTFE_INCL +#ifndef TR_FRONTEND_INCL +#define TR_FRONTEND_INCL -#include -#include "compiler/env/FrontEnd.hpp" -#include "env/FEBase.hpp" -#include "env/jittypes.h" +#include "env/OMRFrontEnd.hpp" -namespace TR { class GCStackAtlas; } -namespace OMR { struct MethodMetaDataPOD; } -class TR_ResolvedMethod; - -namespace JitBuilder +namespace TR { - -class FrontEnd : public TR::FEBase +class OMR_EXTENSIBLE FrontEnd : public OMR::FrontEndConnector { - private: - static FrontEnd *_instance; /* singleton */ - public: - FrontEnd(); - static FrontEnd *instance() { TR_ASSERT(_instance, "bad singleton"); return _instance; } - - virtual void reserveTrampolineIfNecessary(TR::Compilation *comp, TR::SymbolReference *symRef, bool inBinaryEncoding); - -#if defined(TR_TARGET_S390) - virtual void generateBinaryEncodingPrologue(TR_BinaryEncodingData *beData, TR::CodeGenerator *cg); -#endif - - virtual intptr_t methodTrampolineLookup(TR::Compilation *comp, TR::SymbolReference *symRef, void *currentCodeCache); - - TR_ResolvedMethod * createResolvedMethod(TR_Memory * trMemory, TR_OpaqueMethodBlock * aMethod, - TR_ResolvedMethod * owningMethod, TR_OpaqueClassBlock *classForNewInstance); - + FrontEnd() : OMR::FrontEndConnector() {} }; - -} // namespace JitBuilder - -namespace TR -{ -class FrontEnd : public JitBuilder::FrontEnd - { - public: - FrontEnd(); - }; - -} // namespace TR +} #endif - diff --git a/jitbuilder/z/codegen/Evaluator.cpp b/jitbuilder/z/codegen/Evaluator.cpp index c1a8a205a4a..b1e34240f38 100644 --- a/jitbuilder/z/codegen/Evaluator.cpp +++ b/jitbuilder/z/codegen/Evaluator.cpp @@ -21,7 +21,7 @@ *******************************************************************************/ #include "codegen/CodeGenerator.hpp" -#include "env/ConcreteFE.hpp" +#include "env/FrontEnd.hpp" #include "z/codegen/S390GenerateInstructions.hpp" #include "z/codegen/SystemLinkage.hpp" #include "codegen/S390Snippets.hpp" @@ -48,44 +48,3 @@ TR_Debug::print(TR::FILE *pOutFile, TR::S390RestoreGPR7Snippet *snippet) { TR_UNIMPLEMENTED(); } - -void -JitBuilder::FrontEnd::generateBinaryEncodingPrologue( - TR_BinaryEncodingData *beData, - TR::CodeGenerator *cg) - { - TR::Compilation* comp = cg->comp(); - TR_S390BinaryEncodingData *data = (TR_S390BinaryEncodingData *)beData; - - data->cursorInstruction = cg->getFirstInstruction(); - data->estimate = 0; - data->preProcInstruction = data->cursorInstruction; - data->jitTojitStart = data->cursorInstruction; - data->cursorInstruction = NULL; - - TR::Instruction * preLoadArgs, * endLoadArgs; - preLoadArgs = data->preProcInstruction; - endLoadArgs = preLoadArgs; - - TR::Instruction * oldFirstInstruction = data->cursorInstruction; - - data->cursorInstruction = cg->getFirstInstruction(); - - static char *disableAlignJITEP = feGetEnv("TR_DisableAlignJITEP"); - - // Padding for JIT Entry Point - if (!disableAlignJITEP) - { - data->estimate += 256; - } - - while (data->cursorInstruction && data->cursorInstruction->getOpCodeValue() != TR::InstOpCode::proc) - { - data->estimate = data->cursorInstruction->estimateBinaryLength(data->estimate); - data->cursorInstruction = data->cursorInstruction->getNext(); - } - - cg->getLinkage()->createPrologue(data->cursorInstruction); - } - - From b017dbf79e79e64b266fdbe6e0cb0d59a940793d Mon Sep 17 00:00:00 2001 From: Daryl Maier Date: Wed, 13 Nov 2024 15:22:46 -0500 Subject: [PATCH 5/6] Update GitHub permalink to renamed OMRFrontEnd.cpp Signed-off-by: Daryl Maier --- doc/compiler/CompilerOptions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/compiler/CompilerOptions.md b/doc/compiler/CompilerOptions.md index 9011fecb20b..86873ddca61 100644 --- a/doc/compiler/CompilerOptions.md +++ b/doc/compiler/CompilerOptions.md @@ -105,7 +105,7 @@ or their categories. To see all of the available options to control the compiler please see the options listed in [`/compiler/control/OMROptions.cpp`](https://github.com/eclipse-omr/omr/blob/e2f65411e67d21ef04e2062a8945e604d82cb19e/compiler/control/OMROptions.cpp#L98) and -[`/compiler/env/FEBase.cpp`](https://github.com/eclipse-omr/omr/blob/e2f65411e67d21ef04e2062a8945e604d82cb19e/compiler/env/FEBase.cpp#L235) +[`/compiler/env/OMRFrontEnd.cpp`](https://github.com/eclipse-omr/omr/blob/8b39ee4620900920d736ef26031f10a1a7ca7bca/compiler/env/OMRFrontEnd.cpp#L198) The purpose of listing the options in this document is to give you an insight into the level of control you have over the compiler through the options rather From beda3916e55b701c9ae703b78716f57bc4ad652a Mon Sep 17 00:00:00 2001 From: Daryl Maier Date: Thu, 28 Nov 2024 09:12:27 -0500 Subject: [PATCH 6/6] Remove FrontEnd::singleton() in lieu of FrontEnd::instance() `instance()` is the more consistent name for single class instances in the code base. Signed-off-by: Daryl Maier --- compiler/control/CompileMethod.cpp | 14 +++++++------- compiler/env/OMRFrontEnd.cpp | 6 ------ compiler/env/OMRFrontEnd.hpp | 2 -- compiler/env/OMRJitConfig.cpp | 2 +- compiler/runtime/Trampoline.cpp | 2 +- fvtest/compilerunittest/CompilerUnitTest.hpp | 4 ++-- 6 files changed, 11 insertions(+), 19 deletions(-) diff --git a/compiler/control/CompileMethod.cpp b/compiler/control/CompileMethod.cpp index ade9825e382..acb21f3e0c2 100644 --- a/compiler/control/CompileMethod.cpp +++ b/compiler/control/CompileMethod.cpp @@ -273,8 +273,8 @@ compileMethodFromDetails( int32_t &rc) { uint64_t translationStartTime = TR::Compiler->vm.getUSecClock(); - TR::FrontEnd &fe = TR::FrontEnd::singleton(); - auto jitConfig = fe.jitConfig(); + TR::FrontEnd *fe = TR::FrontEnd::instance(); + auto jitConfig = fe->jitConfig(); TR::RawAllocator rawAllocator; TR::SystemSegmentProvider defaultSegmentProvider(1 << 16, rawAllocator); TR::DebugSegmentProvider debugSegmentProvider(1 << 16, rawAllocator); @@ -283,7 +283,7 @@ compileMethodFromDetails( static_cast(debugSegmentProvider) : static_cast(defaultSegmentProvider); TR::Region dispatchRegion(scratchSegmentProvider, rawAllocator); - TR_Memory trMemory(*fe.persistentMemory(), dispatchRegion); + TR_Memory trMemory(*(fe->persistentMemory()), dispatchRegion); TR_ResolvedMethod & compilee = *((TR_ResolvedMethod *)details.getMethod()); TR::CompileIlGenRequest request(details); @@ -295,7 +295,7 @@ compileMethodFromDetails( TR_FilterBST *filterInfo = 0; TR_OptimizationPlan *plan = 0; - if (!methodCanBeCompiled(&fe, compilee, filterInfo, &trMemory)) + if (!methodCanBeCompiled(fe, compilee, filterInfo, &trMemory)) { if (TR::Options::getCmdLineOptions()->getVerboseOption(TR_VerboseCompileExclude)) TR_VerboseLog::writeLineLocked(TR_Vlog_INFO, "%s cannot be translated", compilee.signature(&trMemory)); @@ -328,7 +328,7 @@ compileMethodFromDetails( // FIXME: perhaps use stack memory instead TR_ASSERT(TR::comp() == NULL, "there seems to be a current TLS TR::Compilation object %p for this thread. At this point there should be no current TR::Compilation object", TR::comp()); - TR::Compilation compiler(0, omrVMThread, &fe, &compilee, request, options, dispatchRegion, &trMemory, plan); + TR::Compilation compiler(0, omrVMThread, fe, &compilee, request, options, dispatchRegion, &trMemory, plan); TR_ASSERT(TR::comp() == &compiler, "the TLS TR::Compilation object %p for this thread does not match the one %p just created.", TR::comp(), &compiler); try @@ -369,7 +369,7 @@ compileMethodFromDetails( { // not ready yet... - //OMR::MethodMetaDataPOD *metaData = fe.createMethodMetaData(&compiler); + //OMR::MethodMetaDataPOD *metaData = fe->createMethodMetaData(&compiler); startPC = (uint8_t*)compiler.getMethodSymbol()->getMethodAddress(); uint64_t translationTime = TR::Compiler->vm.getUSecClock() - translationStartTime; @@ -403,7 +403,7 @@ compileMethodFromDetails( || compiler.getOption(TR_EmitRelocatableELFFile) ) { - TR::CodeCacheManager &codeCacheManager(fe.codeCacheManager()); + TR::CodeCacheManager &codeCacheManager(fe->codeCacheManager()); TR::CodeGenerator &codeGenerator(*compiler.cg()); codeCacheManager.registerCompiledMethod(compiler.externalName(), startPC, codeGenerator.getCodeLength()); if (compiler.getOption(TR_EmitRelocatableELFFile)) diff --git a/compiler/env/OMRFrontEnd.cpp b/compiler/env/OMRFrontEnd.cpp index a61c246677a..94d0881e6b8 100644 --- a/compiler/env/OMRFrontEnd.cpp +++ b/compiler/env/OMRFrontEnd.cpp @@ -55,12 +55,6 @@ OMR::FrontEnd::FrontEnd() : ::trPersistentMemory = &_persistentMemory; } -TR::FrontEnd & -OMR::FrontEnd::singleton() - { - return *_instance; - } - TR::FrontEnd * OMR::FrontEnd::instance() { diff --git a/compiler/env/OMRFrontEnd.hpp b/compiler/env/OMRFrontEnd.hpp index bffda7f9c80..83b04b90890 100644 --- a/compiler/env/OMRFrontEnd.hpp +++ b/compiler/env/OMRFrontEnd.hpp @@ -53,8 +53,6 @@ class OMR_EXTENSIBLE FrontEnd : public ::TR_FrontEnd FrontEnd(); - static TR::FrontEnd &singleton(); - static TR::FrontEnd *instance(); virtual TR_Debug *createDebug(TR::Compilation *comp = NULL); diff --git a/compiler/env/OMRJitConfig.cpp b/compiler/env/OMRJitConfig.cpp index f8b8d2dc925..a8aaba67834 100644 --- a/compiler/env/OMRJitConfig.cpp +++ b/compiler/env/OMRJitConfig.cpp @@ -38,5 +38,5 @@ OMR::JitConfig::JitConfig() TR::JitConfig * OMR::JitConfig::instance() { - return TR::FrontEnd::singleton().jitConfig(); + return TR::FrontEnd::instance()->jitConfig(); } diff --git a/compiler/runtime/Trampoline.cpp b/compiler/runtime/Trampoline.cpp index 018099ba94b..5ec603129f8 100644 --- a/compiler/runtime/Trampoline.cpp +++ b/compiler/runtime/Trampoline.cpp @@ -73,7 +73,7 @@ extern void registerTrampoline(uint8_t *start, uint32_t size, const char *name); void ppcCreateHelperTrampolines(uint8_t *trampPtr, int32_t numHelpers) { - TR::CodeCacheManager &manager = TR::FrontEnd::singleton().codeCacheManager(); + TR::CodeCacheManager &manager = TR::FrontEnd::instance()->codeCacheManager(); TR::CodeCacheConfig &config = manager.codeCacheConfig(); char name[256]; diff --git a/fvtest/compilerunittest/CompilerUnitTest.hpp b/fvtest/compilerunittest/CompilerUnitTest.hpp index e63f352f93e..cead3189125 100644 --- a/fvtest/compilerunittest/CompilerUnitTest.hpp +++ b/fvtest/compilerunittest/CompilerUnitTest.hpp @@ -81,12 +81,12 @@ class CompilerUnitTest : public ::testing::Test { _rawAllocator(), _segmentProvider(1 << 16, _rawAllocator), _dispatchRegion(_segmentProvider, _rawAllocator), - _trMemory(*TR::FrontEnd::singleton().persistentMemory(), _dispatchRegion), + _trMemory(*(TR::FrontEnd::instance()->persistentMemory()), _dispatchRegion), _types(), _options(), _ilGenRequest(), _method("compunittest", "0", "test", 0, NULL, _types.NoType, NULL, NULL), - _comp(0, NULL, &TR::FrontEnd::singleton(), &_method, _ilGenRequest, _options, _dispatchRegion, &_trMemory, TR_OptimizationPlan::alloc(warm)) { + _comp(0, NULL, TR::FrontEnd::instance(), &_method, _ilGenRequest, _options, _dispatchRegion, &_trMemory, TR_OptimizationPlan::alloc(warm)) { _symbol = TR::ResolvedMethodSymbol::create(_comp.trStackMemory(), &_method, &_comp); TR::CFG* cfg = new (region()) TR::CFG(&_comp, _symbol, region()); _symbol->setFlowGraph(cfg);