-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Because we want to.
I am assuming that one has already built OpenJ9 at least once.
The optimizations for OpenJ9 live in two different places. Either under the folder omr/compiler/optimizer
or openj9/runtime/compiler/optimizer
. The difference between these two locations are whether the compilation can be done at the intermediate level only or whether the proposed optimization pass needs information available in the OpenJ9 VM. In other words if it is language independent the optimization pass should live on omr/compiler/optimizer
otherwise in openj9/runtime/compiler/optimizer
. I am assuming one is making an optimization that is language independent.
cd omr/compiler/optimizer
touch HelloWorldOpt.{cpp, hpp}
#ifndef INLINER_BENEFIT_INC
#define INLINER_BENEFIT_INC
#pragma once
#include "optimizer/Optimization.hpp" // for optimization
#include "optimizer/OptimizationManager.hpp" // for optimization manager
namespace OMR {
class HelloWorldOpt : public TR::Optimization {
public:
HelloWorldOpt(TR::OptimizationManager *m) : TR::Optimization(m) {};
static TR::Optimization *create (TR::OptimizationManager *m) {
return new (m->allocator()) InlinerBenefit(m);
};
virtual bool shouldPerform();
virtual int32_t perform();
virtual const char * optDetailString() const throw()
{
return "O^O Hello World Opt : ";
};
};
#endif
#include "env/VerboseLog.hpp"
#include "optimizer/HelloWorldOpt.hpp"
bool
OMR::HelloWorldOpt::shouldPerform() {
return true;
}
bool
OMR::HelloWorldOpt::perform() {
// Say Hello world in the verbose log.
TR_VerboseLog::vlogAcquire();
// TR_Vlog_HWO is the tag to identify one's optimization pass in the verbose log.
TR_VerboseLog::writeLine(TR_Vlog_HWO, "Hello world");
TR_VerboseLog::vlogRelease();
return true;
}
Modify the files omr/compiler/env/VerboseLog.{hpp,cpp}
.
--- a/compiler/env/VerboseLog.hpp
+++ b/compiler/env/VerboseLog.hpp
@@ -70,6 +70,7 @@ enum TR_VlogTag
TR_Vlog_RECLAMATION,
TR_Vlog_PROFILING,
TR_Vlog_JITaaS,
+ TR_Vlog_HWO,
TR_Vlog_numTags
};
--- a/compiler/env/VerboseLog.cpp
+++ b/compiler/env/VerboseLog.cpp
@@ -62,6 +62,7 @@ const char * TR_VerboseLog::_vlogTable[] =
"#RECLAMATION: ",
"#PROFILING: ",
"#JITaaS: ",
+ "#HelloWorldOpt: ",
};
void TR_VerboseLog::writeLine(TR_VlogTag tag, const char *format, ...)
Modify ./runtime/compiler/build/files/common.mk
to build HelloWorldOpt.cpp
This optimizations is now ready to be placed in a compilation strategy.