Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add classes for building IDT and performing abstract interpretation. #17813

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions runtime/compiler/build/files/common.mk.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ JIT_PRODUCT_BACKEND_SOURCES+=\
omr/compiler/optimizer/VPConstraint.cpp \
omr/compiler/optimizer/VPHandlers.cpp \
omr/compiler/optimizer/VPHandlersCommon.cpp \
omr/compiler/optimizer/BenefitInliner.cpp \
omr/compiler/optimizer/abstractinterpreter/AbsValue.cpp \
omr/compiler/optimizer/abstractinterpreter/AbsOpArray.cpp \
omr/compiler/optimizer/abstractinterpreter/AbsOpStack.cpp \
omr/compiler/optimizer/abstractinterpreter/IDT.cpp \
omr/compiler/optimizer/abstractinterpreter/IDTNode.cpp \
omr/compiler/optimizer/abstractinterpreter/OMRIDTBuilder.cpp \
omr/compiler/optimizer/abstractinterpreter/InliningMethodSummary.cpp \
omr/compiler/optimizer/abstractinterpreter/InliningProposal.cpp \
omr/compiler/ras/CallStack.cpp \
omr/compiler/ras/CFGChecker.cpp \
omr/compiler/ras/Debug.cpp \
Expand Down Expand Up @@ -350,6 +359,9 @@ JIT_PRODUCT_SOURCE_FILES+=\
compiler/optimizer/J9EstimateCodeSize.cpp \
compiler/optimizer/J9Inliner.cpp \
compiler/optimizer/InterpreterEmulator.cpp \
compiler/optimizer/abstractinterpreter/AbsStackMachineState.cpp \
compiler/optimizer/abstractinterpreter/J9IDTBuilder.cpp \
compiler/optimizer/abstractinterpreter/AbsInterpreter.cpp \
compiler/ras/HashTable.cpp \
compiler/ras/InternalFunctions.cpp \
compiler/ras/kca_offsets_generator.cpp \
Expand Down
3 changes: 3 additions & 0 deletions runtime/compiler/optimizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,7 @@ j9jit_files(
optimizer/VectorAPIExpansion.cpp
optimizer/VPBCDConstraint.cpp
optimizer/TreeLowering.cpp
optimizer/abstractinterpreter/J9IDTBuilder.cpp
optimizer/abstractinterpreter/AbsInterpreter.cpp
optimizer/abstractinterpreter/AbsStackMachineState.cpp
)
25 changes: 25 additions & 0 deletions runtime/compiler/optimizer/J9EstimateCodeSize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,27 @@ TR_J9EstimateCodeSize::estimateCodeSize(TR_CallTarget *calltarget, TR_CallStack
return false;
}

TR::CFG *
TR_J9EstimateCodeSize::generateCFG(TR_CallTarget *calltarget, TR::Region &region)
{
TR::ResolvedMethodSymbol* methodSymbol = TR::ResolvedMethodSymbol::create(comp()->trHeapMemory(), calltarget->_calleeMethod, comp());
TR_J9ByteCodeIterator bci(methodSymbol, static_cast<TR_ResolvedJ9Method*>(methodSymbol->getResolvedMethod()), static_cast<TR_J9VMBase*>(comp()->fe()), comp());

NeedsPeekingHeuristic nph(calltarget, bci, methodSymbol, comp());

int32_t maxIndex = bci.maxByteCodeIndex() + 5;

TR::Block * * blocks = (TR::Block * *) comp()->trMemory()->allocateStackMemory(maxIndex * sizeof(TR::Block *));
memset(blocks, 0, maxIndex * sizeof(TR::Block *));

flags8_t * flags = (flags8_t *) comp()->trMemory()->allocateStackMemory(maxIndex * sizeof(flags8_t));
memset(flags, 0, maxIndex * sizeof(flags8_t));

processBytecodeAndGenerateCFG(calltarget, region, bci, nph, blocks, flags);

return calltarget->_cfg;
}

TR::CFG&
TR_J9EstimateCodeSize::processBytecodeAndGenerateCFG(TR_CallTarget *calltarget, TR::Region &cfgRegion, TR_J9ByteCodeIterator& bci, NeedsPeekingHeuristic &nph, TR::Block** blocks, flags8_t * flags)
{
Expand Down Expand Up @@ -1136,13 +1157,17 @@ TR_J9EstimateCodeSize::processBytecodeAndGenerateCFG(TR_CallTarget *calltarget,
calltarget->_calleeMethod, i + bci.relativeBranch(),
cfg));
addFallThruEdge = true;
if (bci.relativeBranch() < 0)
cfg.setHasBackEdges();
break;
}
case J9BCgoto:
case J9BCgotow:
setupLastTreeTop(currentBlock, bc, i, getBlock(comp(), blocks, calltarget->_calleeMethod, i + bci.relativeBranch(), cfg), calltarget->_calleeMethod, comp());
cfg.addEdge(currentBlock, getBlock(comp(), blocks, calltarget->_calleeMethod, i + bci.relativeBranch(), cfg));
addFallThruEdge = false;
if (bci.relativeBranch() < 0)
cfg.setHasBackEdges();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lookupswitch and tableswitch should also be checked for negative branch offsets

break;
case J9BCReturnC:
case J9BCReturnS:
Expand Down
2 changes: 2 additions & 0 deletions runtime/compiler/optimizer/J9EstimateCodeSize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class TR_J9EstimateCodeSize : public TR_EstimateCodeSize
uint32_t bcIndex, TR::Block *destinationBlock, TR_ResolvedMethod *feMethod,
TR::Compilation *comp);

TR::CFG* generateCFG(TR_CallTarget *calltarget, TR::Region &region);

protected:
bool estimateCodeSize(TR_CallTarget *, TR_CallStack * , bool recurseDown = true);

Expand Down
4 changes: 3 additions & 1 deletion runtime/compiler/optimizer/J9Optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
#include "optimizer/MethodHandleTransformer.hpp"
#include "optimizer/VectorAPIExpansion.hpp"
#include "optimizer/CatchBlockProfiler.hpp"
#include "optimizer/SelectOpt.hpp"
#include "optimizer/BenefitInliner.hpp"


static const OptimizationStrategy J9EarlyGlobalOpts[] =
Expand Down Expand Up @@ -826,7 +828,7 @@ J9::Optimizer::Optimizer(TR::Compilation *comp, TR::ResolvedMethodSymbol *method
// initialize additional J9 optimizations

_opts[OMR::inlining] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_Inliner::create, OMR::inlining);
new (comp->allocator()) TR::OptimizationManager(self(), comp->getOption(TR_EnableBenefitInliner) ? TR::BenefitInlinerWrapper::create : TR_Inliner::create, OMR::inlining);
_opts[OMR::targetedInlining] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_Inliner::create, OMR::targetedInlining);
_opts[OMR::targetedInlining]->setOptPolicy(new (comp->allocator()) TR_J9JSR292InlinerPolicy(comp));
Expand Down
Loading