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 Platform Agnostic TM Query #3846

Merged
merged 2 commits into from
May 15, 2019
Merged
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
6 changes: 6 additions & 0 deletions compiler/env/OMRCPU.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ class CPU
bool isI386() { return _minorArch == TR::m_arch_i386; }
bool isAMD64() { return _minorArch == TR::m_arch_amd64; }

Copy link
Contributor

Choose a reason for hiding this comment

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

This API should have the same Doxygen comment as the platform-specific ones. It is the API used by architectures that don't have TM support yet (e.g., ARM32, AArch64).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, missed that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

/** @brief Determines whether the Transactional Memory (TM) facility is available on the current processor.
*
* @return false; this is the default answer unless overridden by an extending class.
*/
bool supportsTransactionalMemoryInstructions() { 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::supportsTransactionalMemoryInstructions()
{
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 supportsTransactionalMemoryInstructions();

/**
* @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::supportsTransactionalMemoryInstructions()
{
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 supportsTransactionalMemoryInstructions();

/**
* @brief Answers whether the distance between a target and source address
* is within the reachable RIP displacement range.
Expand Down
10 changes: 8 additions & 2 deletions compiler/z/env/OMRCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#pragma csect(STATIC,"OMRZCPUBase#S")
#pragma csect(TEST,"OMRZCPUBase#T")

#include "compiler/z/env/OMRCPU.hpp"
#include "env/CPU.hpp"

const char*
OMR::Z::CPU::getProcessorName(int32_t machineId)
Expand Down Expand Up @@ -207,6 +207,12 @@ OMR::Z::CPU::getSupportsTransactionalMemoryFacility()
return _flags.testAny(S390SupportsTM);
}

bool
OMR::Z::CPU::supportsTransactionalMemoryInstructions()
{
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 supportsTransactionalMemoryInstructions();

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