Skip to content

Commit

Permalink
Merge pull request #3779 from fjeremic/xplink-zos-pr
Browse files Browse the repository at this point in the history
Implement z/OS XPLINK system linkage
  • Loading branch information
0xdaryl authored May 11, 2019
2 parents ca47815 + 0c66434 commit 3befa3f
Show file tree
Hide file tree
Showing 44 changed files with 3,498 additions and 2,893 deletions.
1 change: 0 additions & 1 deletion compiler/codegen/FrontEnd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ class TR_FrontEnd : public TR_Uncopyable
// Codegen
// --------------------------------------------------------------------------

virtual void generateBinaryEncodingPrologue(TR_BinaryEncodingData *beData, TR::CodeGenerator *cg) { return; }
virtual uint8_t * allocateRelocationData(TR::Compilation *, uint32_t numBytes);

// --------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion compiler/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ void OMR::CodeGenerator::apply32BitLabelTableRelocation(int32_t * cursor, TR::La

void OMR::CodeGenerator::addSnippet(TR::Snippet *s)
{
_snippetList.push_front(s);
_snippetList.push_back(s);
}

void OMR::CodeGenerator::setCurrentBlock(TR::Block *b)
Expand Down
19 changes: 19 additions & 0 deletions compiler/codegen/OMRSnippet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,22 @@ OMR::Snippet::prepareSnippetForGCSafePoint()
self()->setBlock(self()->cg()->getCurrentEvaluationBlock());
self()->setNeedsExceptionTableEntry();
}

void
OMR::Snippet::print(TR::FILE* f, TR_Debug* debug)
{
uint8_t* cursor = self()->getSnippetLabel()->getCodeLocation();

debug->printSnippetLabel(f, self()->getSnippetLabel(), cursor, "<Unknown Snippet>");

for (auto i = 0; i < self()->getLength(0) / sizeof(uint64_t); ++i)
{
debug->printPrefix(f, NULL, cursor, sizeof(uint64_t));
cursor += sizeof(uint64_t);
}

if (self()->getLength(0) % sizeof(uint64_t) != 0)
{
debug->printPrefix(f, NULL, cursor, self()->getLength(0) % sizeof(uint64_t));
}
}
5 changes: 1 addition & 4 deletions compiler/codegen/OMRSnippet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ class OMR_EXTENSIBLE Snippet
virtual uint32_t getLength(int32_t estimatedSnippetStart) = 0;
virtual uint8_t *emitSnippetBody() = 0;

virtual void print(TR::FILE *, TR_Debug *debug)
{
// temporary until this becomes pure virtual
}
virtual void print(TR::FILE *, TR_Debug *debug);

void prepareSnippetForGCSafePoint();

Expand Down
60 changes: 60 additions & 0 deletions compiler/codegen/Relocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,66 @@ void TR::LabelAbsoluteRelocation::apply(TR::CodeGenerator *codeGen)
*cursor = (intptrj_t)getLabel()->getCodeLocation();
}

TR::InstructionLabelRelative16BitRelocation::InstructionLabelRelative16BitRelocation(TR::Instruction* cursor, int32_t offset, TR::LabelSymbol* l, int32_t divisor)
:
TR::LabelRelocation(NULL, l),
_cursor(cursor),
_offset(offset),
_divisor(divisor)
{
}

uint8_t*
TR::InstructionLabelRelative16BitRelocation::getUpdateLocation()
{
uint8_t* updateLocation = TR::LabelRelocation::getUpdateLocation();

if (updateLocation == NULL && _cursor->getBinaryEncoding() != NULL)
{
updateLocation = setUpdateLocation(_cursor->getBinaryEncoding() + _offset);
}

return updateLocation;
}

void
TR::InstructionLabelRelative16BitRelocation::apply(TR::CodeGenerator* cg)
{
uint8_t* p = getUpdateLocation();

*reinterpret_cast<int16_t*>(p) = static_cast<int16_t>(getLabel()->getCodeLocation() - p) / _divisor;
}

TR::InstructionLabelRelative32BitRelocation::InstructionLabelRelative32BitRelocation(TR::Instruction* cursor, int32_t offset, TR::LabelSymbol* l, int32_t divisor)
:
TR::LabelRelocation(NULL, l),
_cursor(cursor),
_offset(offset),
_divisor(divisor)
{
}

uint8_t*
TR::InstructionLabelRelative32BitRelocation::getUpdateLocation()
{
uint8_t* updateLocation = TR::LabelRelocation::getUpdateLocation();

if (updateLocation == NULL && _cursor->getBinaryEncoding() != NULL)
{
updateLocation = setUpdateLocation(_cursor->getBinaryEncoding() + _offset);
}

return updateLocation;
}

void
TR::InstructionLabelRelative32BitRelocation::apply(TR::CodeGenerator* cg)
{
uint8_t* p = getUpdateLocation();

*reinterpret_cast<int32_t*>(p) = static_cast<int32_t>(getLabel()->getCodeLocation() - p) / _divisor;
}

void TR::InstructionAbsoluteRelocation::apply(TR::CodeGenerator *codeGen)
{
intptrj_t *cursor = (intptrj_t*)getUpdateLocation();
Expand Down
74 changes: 74 additions & 0 deletions compiler/codegen/Relocation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,80 @@ class LabelRelative32BitRelocation : public TR::LabelRelocation
virtual void apply(TR::CodeGenerator *codeGen);
};

/** \brief
*
* Represents a 16-bit relocation from an offset into the binary encoding location of an instruction to a label by a
* specified width (bytes, half-words, words, double-words, etc.).
*/
class InstructionLabelRelative16BitRelocation : public TR::LabelRelocation
{
public:

/** \brief
* Initializes the InstructionLabelRelative16BitRelocation relocation using a \c NULL base target pointer.
*
* \param cursor
* The instruction whose binary encoding location will be used for the relocation.
*
* \param offset
* The offset from the binary encoding of \p cursor where the relocation will be encoded
*
* \param l
* The label whose distance from \p cursor will be encoded
*
* \param divisor
* The width of each unit of the encoding. For example if \p divisor is 2 then the value which will be encoded
* at \p cursor + \p offset will be the number of half-words between \p cursor and \p l
*/
InstructionLabelRelative16BitRelocation(TR::Instruction* cursor, int32_t offset, TR::LabelSymbol* l, int32_t divisor);

virtual uint8_t* getUpdateLocation();
virtual void apply(TR::CodeGenerator* cg);

private:

TR::Instruction* _cursor;
int32_t _offset;
int32_t _divisor;
};

/** \brief
*
* Represents a 32-bit relocation from an offset into the binary encoding location of an instruction to a label by a
* specified width (bytes, half-words, words, double-words, etc.).
*/
class InstructionLabelRelative32BitRelocation : public TR::LabelRelocation
{
public:

/** \brief
* Initializes the InstructionLabelRelative16BitRelocation relocation using a \c NULL base target pointer.
*
* \param cursor
* The instruction whose binary encoding location will be used for the relocation.
*
* \param offset
* The offset from the binary encoding of \p cursor where the relocation will be encoded
*
* \param l
* The label whose distance from \p cursor will be encoded
*
* \param divisor
* The width of each unit of the encoding. For example if \p divisor is 2 then the value which will be encoded
* at \p cursor + \p offset will be the number of half-words between \p cursor and \p l
*/
InstructionLabelRelative32BitRelocation(TR::Instruction* cursor, int32_t offset, TR::LabelSymbol* l, int32_t divisor);

virtual uint8_t* getUpdateLocation();
virtual void apply(TR::CodeGenerator* cg);

private:

TR::Instruction* _cursor;
int32_t _offset;
int32_t _divisor;
};

class InstructionAbsoluteRelocation : public TR::Relocation
{
public:
Expand Down
1 change: 0 additions & 1 deletion compiler/control/OMROptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,6 @@ TR::OptionTable OMR::Options::_jitOptions[] = {
{"enableLabelTargetNOPs", "O\tenable inserting NOPs before label targets", SET_OPTION_BIT(TR_EnableLabelTargetNOPs), "F"},
{"enableLargeCodePages", "C\tenable large code pages", SET_OPTION_BIT(TR_EnableLargeCodePages), "F"},
{"enableLastRetrialLogging", "O\tenable fullTrace logging for last compilation attempt. Needs to have a log defined on the command line", SET_OPTION_BIT(TR_EnableLastCompilationRetrialLogging), "F"},
{"enableLinkagePreserveStrategy2", "O\tenable linkage strategy 2", SET_OPTION_BIT(TR_LinkagePreserveStrategy2), "F"},
{"enableLocalVPSkipLowFreqBlock", "O\tSkip processing of low frequency blocks in localVP", SET_OPTION_BIT(TR_EnableLocalVPSkipLowFreqBlock), "F" },
{"enableLoopEntryAlignment", "O\tenable loop Entry alignment", SET_OPTION_BIT(TR_EnableLoopEntryAlignment), "F"},
{"enableLoopVersionerCountAllocFences", "O\tallow loop versioner to count allocation fence nodes on PPC toward a profiled guard's block total", SET_OPTION_BIT(TR_EnableLoopVersionerCountAllocationFences), "F"},
Expand Down
2 changes: 1 addition & 1 deletion compiler/control/OMROptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ enum TR_CompilationOptions
TR_PerfTool = 0x00010000 + 25,
// Available = 0x00020000 + 25,
TR_DisableBranchOnCount = 0x00040000 + 25,
TR_LinkagePreserveStrategy2 = 0x00080000 + 25,
// Available = 0x00080000 + 25,
TR_DisableLoopEntryAlignment = 0x00100000 + 25,
TR_EnableLoopEntryAlignment = 0x00200000 + 25,
TR_DisableLeafRoutineDetection = 0x00400000 + 25,
Expand Down
5 changes: 5 additions & 0 deletions compiler/z/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ compiler_library(z
${CMAKE_CURRENT_LIST_DIR}/codegen/S390Peephole.cpp
${CMAKE_CURRENT_LIST_DIR}/codegen/OMRLinkage.cpp
${CMAKE_CURRENT_LIST_DIR}/codegen/SystemLinkage.cpp
${CMAKE_CURRENT_LIST_DIR}/codegen/SystemLinkageLinux.cpp
${CMAKE_CURRENT_LIST_DIR}/codegen/SystemLinkagezOS.cpp
${CMAKE_CURRENT_LIST_DIR}/codegen/S390OutOfLineCodeSection.cpp
${CMAKE_CURRENT_LIST_DIR}/codegen/OMRRegisterDependency.cpp
${CMAKE_CURRENT_LIST_DIR}/codegen/OMRSnippet.cpp
Expand All @@ -52,6 +54,9 @@ compiler_library(z
${CMAKE_CURRENT_LIST_DIR}/codegen/OMRRealRegister.cpp
${CMAKE_CURRENT_LIST_DIR}/codegen/OMRCodeGenPhase.cpp
${CMAKE_CURRENT_LIST_DIR}/codegen/OMRCodeGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/codegen/snippet/PPA1Snippet.cpp
${CMAKE_CURRENT_LIST_DIR}/codegen/snippet/PPA2Snippet.cpp
${CMAKE_CURRENT_LIST_DIR}/codegen/snippet/XPLINKCallDescriptorSnippet.cpp
${CMAKE_CURRENT_LIST_DIR}/env/OMRCPU.cpp
${CMAKE_CURRENT_LIST_DIR}/env/OMRDebugEnv.cpp
)
Loading

0 comments on commit 3befa3f

Please sign in to comment.