Skip to content

Commit

Permalink
Add Platform Agnostic TM Query
Browse files Browse the repository at this point in the history
This commit adds a wrapper API around existing Transactional Memory (TM)
queries in order to have a single query that is common across all
platforms.

Signed-off-by: Irwin D'Souza <[email protected]>
  • Loading branch information
Irwin D'Souza committed May 13, 2019
1 parent 7c6ddd3 commit 87d07c1
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 1 deletion.
2 changes: 2 additions & 0 deletions compiler/env/OMRCPU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class CPU
bool isI386() { return _minorArch == TR::m_arch_i386; }
bool isAMD64() { return _minorArch == TR::m_arch_amd64; }

bool supportsTM() { return false; }

private:
TR_Processor _processor;

Expand Down
6 changes: 6 additions & 0 deletions compiler/p/env/OMRCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ OMR::Power::CPU::getPPCis64bit()
return (p >= TR_FirstPPC64BitProcessor)? true : false;
}

bool
OMR::Power::CPU::supportsTM()
{
return self()->getPPCSupportsTM();
}

bool
OMR::Power::CPU::isTargetWithinIFormBranchRange(intptrj_t targetAddress, intptrj_t sourceAddress)
{
Expand Down
7 changes: 7 additions & 0 deletions compiler/p/env/OMRCPU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ class CPU : public OMR::CPU
bool getPPCSupportsTM() { return false; }
bool getPPCSupportsLM() { return false; }

/** @brief Determines whether the Transactional Memory (TM) facility is available on the current processor.
* Alias of getPPCSupportsTM() as a platform agnostic query.
*
* @return true if TM is available, false otherwise.
*/
bool supportsTM();

/**
* @brief Provides the maximum forward branch displacement in bytes reachable
* with an I-Form branch instruction.
Expand Down
8 changes: 8 additions & 0 deletions compiler/x/env/OMRCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "env/CPU.hpp"
#include "env/JitConfig.hpp"
#include "env/ProcessorInfo.hpp"
#include "infra/Flags.hpp"
#include "x/runtime/X86Runtime.hpp"


Expand Down Expand Up @@ -112,3 +113,10 @@ OMR::X86::CPU::testOSForSSESupport()
{
return false;
}

bool
OMR::X86::CPU::supportsTM()
{
flags32_t processorFeatureFlags8(self()->getX86ProcessorFeatureFlags8());
return processorFeatureFlags8.testAny(TR_RTM);
}
7 changes: 7 additions & 0 deletions compiler/x/env/OMRCPU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class CPU : public OMR::CPU

bool testOSForSSESupport();


/** @brief Determines whether the Transactional Memory (TM) facility is available on the current processor.
*
* @return true if TM is available, false otherwise.
*/
bool supportsTM();

/**
* @brief Answers whether the distance between a target and source address
* is within the reachable RIP displacement range.
Expand Down
8 changes: 7 additions & 1 deletion compiler/z/env/OMRCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ OMR::Z::CPU::getSupportsTransactionalMemoryFacility()
return _flags.testAny(S390SupportsTM);
}

bool
OMR::Z::CPU::supportsTM()
{
return self()->getSupportsTransactionalMemoryFacility();
}


bool
OMR::Z::CPU::setSupportsTransactionalMemoryFacility(bool value)
Expand Down Expand Up @@ -375,4 +381,4 @@ OMR::Z::CPU::isTargetWithinBranchRelativeRILRange(intptrj_t targetAddress, intpt
{
return (targetAddress == sourceAddress + ((intptrj_t)((int32_t)((targetAddress - sourceAddress) / 2))) * 2) &&
(targetAddress % 2 == 0);
}
}
6 changes: 6 additions & 0 deletions compiler/z/env/OMRCPU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ class CPU : public OMR::CPU
* Determines whether the Transactional Memory (TM) facility is available on the current processor.
*/
bool getSupportsTransactionalMemoryFacility();

/** \brief
* Determines whether the Transactional Memory (TM) facility is available on the current processor.
* Alias of getSupportsTransactionalMemoryFacility() as a platform agnostic query.
*/
bool supportsTM();

/** \brief
* Determines whether the Transactional Memory (TM) facility is available on the current processor.
Expand Down

0 comments on commit 87d07c1

Please sign in to comment.