Skip to content

Commit

Permalink
Merge pull request eclipse-omr#1836 from 0dvictor/RCT
Browse files Browse the repository at this point in the history
Introducing Recognized Call Transformer
  • Loading branch information
vijaysun-omr authored Dec 14, 2017
2 parents ce93f8c + 5e8c1a3 commit 34b0b3e
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/control/OMROptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ TR::OptionTable OMR::Options::_jitOptions[] = {
{"disableProloguePushes", "O\tuse stores instead of pushes in x86 prologues", SET_OPTION_BIT(TR_DisableProloguePushes), "P"},
{"disableRampupImprovements", "M\tDisable various changes that improve rampup", SET_OPTION_BIT(TR_DisableRampupImprovements), "F", NOT_IN_SUBSET},
{"disableReadMonitors", "O\tdisable read monitors", SET_OPTION_BIT(TR_DisableReadMonitors), "F"},
{"disableRecognizedCallTransformer", "O\tdisable recognized call transformer", TR::Options::disableOptimization, recognizedCallTransformer, 0, "P"},
{"disableRecognizedMethods", "O\tdisable recognized methods", SET_OPTION_BIT(TR_DisableRecognizedMethods), "F"},
{"disableReducedPriorityForCustomMethodHandleThunks", "R\tcompile custom MethodHandle invoke exact thunks at the same priority as normal java methods", SET_OPTION_BIT(TR_DisableReducedPriorityForCustomMethodHandleThunks), "F", NOT_IN_SUBSET},
{"disableRedundantAsyncCheckRemoval", "O\tdisable redundant async check removal", TR::Options::disableOptimization, redundantAsyncCheckRemoval, 0, "P"},
Expand Down Expand Up @@ -1227,6 +1228,7 @@ TR::OptionTable OMR::Options::_jitOptions[] = {
{"traceRA=", "L{regex}\tlist of additional register assignment traces to enable: deps, details, preRA, states",
TR::Options::setBitsFromStringSet, offsetof(OMR::Options, _raTrace), 0, "F"},
{"traceReachability", "L\ttrace all analyses based on the reachability engine", SET_OPTION_BIT(TR_TraceReachability), "P"},
{"traceRecognizedCallTransformer", "L\ttrace recognized call transformer", TR::Options::traceOptimization, recognizedCallTransformer, 0, "P"},
{"traceRedundantAsyncCheckRemoval", "L\ttrace redundant async check removal", TR::Options::traceOptimization, redundantAsyncCheckRemoval, 0, "P"},
{"traceRedundantGotoElimination", "L\ttrace redundant goto elimination", TR::Options::traceOptimization, redundantGotoElimination, 0, "P"},
{"traceRedundantMonitorElimination", "L\ttrace redundant monitor elimination", TR::Options::traceOptimization, redundantMonitorElimination, 0, "P"},
Expand Down
1 change: 1 addition & 0 deletions compiler/optimizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ compiler_library(optimizer
${CMAKE_CURRENT_SOURCE_DIR}/PrefetchInsertion.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Reachability.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ReachingDefinitions.cpp
${CMAKE_CURRENT_SOURCE_DIR}/OMRRecognizedCallTransformer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/RedundantAsyncCheckRemoval.cpp
${CMAKE_CURRENT_SOURCE_DIR}/RegisterAnticipatability.cpp
${CMAKE_CURRENT_SOURCE_DIR}/RegisterAvailability.cpp
Expand Down
4 changes: 4 additions & 0 deletions compiler/optimizer/OMROptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
#include "optimizer/FieldPrivatizer.hpp"
#include "optimizer/ReorderIndexExpr.hpp"
#include "optimizer/GlobalRegisterAllocator.hpp"
#include "optimizer/RecognizedCallTransformer.hpp"
#include "env/RegionProfiler.hpp"

#if defined (_MSC_VER) && _MSC_VER < 1900
Expand Down Expand Up @@ -541,6 +542,7 @@ static const OptimizationStrategy ilgenStrategyOpts[] =
#ifdef J9_PROJECT_SPECIFIC
{ varHandleTransformer, MustBeDone },
{ unsafeFastPath },
{ recognizedCallTransformer },
{ coldBlockMarker },
{ allocationSinking, IfNews },
{ invariantArgumentPreexistence, IfNotClassLoadPhaseAndNotProfiling },
Expand Down Expand Up @@ -860,6 +862,8 @@ OMR::Optimizer::Optimizer(TR::Compilation *comp, TR::ResolvedMethodSymbol *metho
new (comp->allocator()) TR::OptimizationManager(self(), TR_LiveRangeSplitter::create, OMR::liveRangeSplitter);
_opts[OMR::loopSpecializer] =
new (comp->allocator()) TR::OptimizationManager(self(), TR_LoopSpecializer::create, OMR::loopSpecializer);
_opts[OMR::recognizedCallTransformer] =
new (comp->allocator()) TR::OptimizationManager(self(), TR::RecognizedCallTransformer::create, OMR::recognizedCallTransformer);

// NOTE: Please add new OMR optimizations here!

Expand Down
61 changes: 61 additions & 0 deletions compiler/optimizer/OMRRecognizedCallTransformer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*******************************************************************************
* Copyright (c) 2017, 2017 IBM Corp. and others
*
* 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 http://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] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/

#include "optimizer/RecognizedCallTransformer.hpp"

#include "il/Node.hpp"
#include "il/Node_inlines.hpp"
#include "il/TreeTop.hpp"
#include "il/TreeTop_inlines.hpp"
#include "infra/Checklist.hpp" // for NodeChecklist, etc
#include "codegen/CodeGenerator.hpp" // for CodeGenerator

TR::Optimization* OMR::RecognizedCallTransformer::create(TR::OptimizationManager *manager)
{
return new (manager->allocator()) TR::RecognizedCallTransformer(manager);
}

int32_t OMR::RecognizedCallTransformer::perform()
{
TR::NodeChecklist visited(comp());
for (auto treetop = comp()->getMethodSymbol()->getFirstTreeTop(); treetop != NULL; treetop = treetop->getNextTreeTop())
{
if (treetop->getNode()->getNumChildren() > 0)
{
auto node = treetop->getNode()->getFirstChild();
if (node && node->getOpCode().isCall() && !visited.contains(node))
{
if (isInlineable(treetop) &&
performTransformation(comp(), "%s Transforming recognized call node [" POINTER_PRINTF_FORMAT "]\n", optDetailString(), node))
{
visited.add(node);
transform(treetop);
}
}
}
}
return 0;
}

const char* OMR::RecognizedCallTransformer::optDetailString() const throw()
{
return "O^O RECOGNIZED CALL TRANSFORMER:";
}
51 changes: 51 additions & 0 deletions compiler/optimizer/OMRRecognizedCallTransformer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*******************************************************************************
* Copyright (c) 2017, 2017 IBM Corp. and others
*
* 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 http://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] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/

#ifndef OMRRECOGNIZEDCALLTRANSFORMER_INCL
#define OMRRECOGNIZEDCALLTRANSFORMER_INCL

#include <stdint.h> // for int32_t, uint32_t, etc
#include "il/Node.hpp" // for Node
#include "optimizer/Optimization.hpp" // for Optimization
#include "optimizer/OptimizationManager.hpp" // for OptimizationManager

namespace OMR
{

class RecognizedCallTransformer : public TR::Optimization
{
public:

RecognizedCallTransformer(TR::OptimizationManager* manager)
: TR::Optimization(manager)
{}
static TR::Optimization* create(TR::OptimizationManager* manager);
virtual int32_t perform();
virtual const char * optDetailString() const throw();

protected:

virtual bool isInlineable(TR::TreeTop* treetop) { return false; }
virtual void transform(TR::TreeTop* treetop) {}
};

}
#endif
1 change: 1 addition & 0 deletions compiler/optimizer/Optimizations.enum
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
OPTIMIZATION(compactLocals)
OPTIMIZATION(varHandleTransformer)
OPTIMIZATION(unsafeFastPath)
OPTIMIZATION(recognizedCallTransformer)
OPTIMIZATION(coldBlockMarker)
OPTIMIZATION(coldBlockOutlining)
OPTIMIZATION(basicBlockPeepHole)
Expand Down
42 changes: 42 additions & 0 deletions compiler/optimizer/RecognizedCallTransformer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2017, 2017 IBM Corp. and others
*
* 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 http://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] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/

#ifndef TR_RECOGNIZEDCALLTRANSFORMER_INCL
#define TR_RECOGNIZEDCALLTRANSFORMER_INCL

#include "optimizer/OMRRecognizedCallTransformer.hpp"

namespace TR { class OptimizationManager; }

namespace TR
{

class RecognizedCallTransformer : public OMR::RecognizedCallTransformer
{
public:

RecognizedCallTransformer(TR::OptimizationManager *manager) :
OMR::RecognizedCallTransformer(manager) {}
};

}

#endif
1 change: 1 addition & 0 deletions fvtest/compilertest/build/files/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ JIT_PRODUCT_BACKEND_SOURCES+=\
$(JIT_OMR_DIRTY_DIR)/optimizer/PrefetchInsertion.cpp \
$(JIT_OMR_DIRTY_DIR)/optimizer/Reachability.cpp \
$(JIT_OMR_DIRTY_DIR)/optimizer/ReachingDefinitions.cpp \
$(JIT_OMR_DIRTY_DIR)/optimizer/OMRRecognizedCallTransformer.cpp \
$(JIT_OMR_DIRTY_DIR)/optimizer/RedundantAsyncCheckRemoval.cpp \
$(JIT_OMR_DIRTY_DIR)/optimizer/RegisterAnticipatability.cpp \
$(JIT_OMR_DIRTY_DIR)/optimizer/RegisterAvailability.cpp \
Expand Down
1 change: 1 addition & 0 deletions jitbuilder/build/files/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ JIT_PRODUCT_BACKEND_SOURCES+=\
$(JIT_OMR_DIRTY_DIR)/optimizer/PrefetchInsertion.cpp \
$(JIT_OMR_DIRTY_DIR)/optimizer/Reachability.cpp \
$(JIT_OMR_DIRTY_DIR)/optimizer/ReachingDefinitions.cpp \
$(JIT_OMR_DIRTY_DIR)/optimizer/OMRRecognizedCallTransformer.cpp \
$(JIT_OMR_DIRTY_DIR)/optimizer/RedundantAsyncCheckRemoval.cpp \
$(JIT_OMR_DIRTY_DIR)/optimizer/RegisterAnticipatability.cpp \
$(JIT_OMR_DIRTY_DIR)/optimizer/RegisterAvailability.cpp \
Expand Down

0 comments on commit 34b0b3e

Please sign in to comment.