Skip to content

Commit

Permalink
Merge pull request #7540 from 0xdaryl/frontend
Browse files Browse the repository at this point in the history
Simplify base of the FrontEnd hierarchy
  • Loading branch information
dsouzai authored Dec 2, 2024
2 parents 37e9b35 + beda391 commit 913e6ac
Show file tree
Hide file tree
Showing 33 changed files with 354 additions and 845 deletions.
21 changes: 10 additions & 11 deletions compiler/control/CompileMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -274,8 +273,8 @@ compileMethodFromDetails(
int32_t &rc)
{
uint64_t translationStartTime = TR::Compiler->vm.getUSecClock();
OMR::FrontEnd &fe = OMR::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);
Expand All @@ -284,7 +283,7 @@ compileMethodFromDetails(
static_cast<TR::SegmentAllocator &>(debugSegmentProvider) :
static_cast<TR::SegmentAllocator &>(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);
Expand All @@ -296,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));
Expand Down Expand Up @@ -329,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
Expand Down Expand Up @@ -370,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;
Expand Down Expand Up @@ -404,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))
Expand Down
4 changes: 2 additions & 2 deletions compiler/control/CompileMethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

#include <stdint.h>
#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);
4 changes: 2 additions & 2 deletions compiler/env/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ 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}/JitConfig.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
${CMAKE_CURRENT_LIST_DIR}/Globals.cpp
Expand Down
104 changes: 0 additions & 104 deletions compiler/env/FEBase.hpp

This file was deleted.

92 changes: 0 additions & 92 deletions compiler/env/FEBase_t.hpp

This file was deleted.

46 changes: 8 additions & 38 deletions compiler/env/JitConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stddef.h>
#include <stdint.h>
#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
Loading

0 comments on commit 913e6ac

Please sign in to comment.