Skip to content

Commit

Permalink
Misc zOS system linkage code simplifications
Browse files Browse the repository at this point in the history
1. Simplify NOP and call descriptor generation for zOS system linkage.

2. Use the insetPad() API to insert NOP after the BASR call in system
linkage.

3. Remove createCallDescriptor() function and do the same thing inline.

4. genCallNOPAndDescriptor() does not have to be virtual. Remove the virtual
keyword.

Signed-off-by: Nigel Yu <yunigel@ca.ibm.com>
  • Loading branch information
NigelYiboYu committed Mar 25, 2018
1 parent 77c2e36 commit cc5dc68
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 64 deletions.
83 changes: 22 additions & 61 deletions runtime/compiler/trj9/z/codegen/J9S390SystemLinkage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ TR::J9S390zOSSystemLinkage::generateInstructionsForCall(TR::Node * callNode, TR:
TR::Register * systemEnvironmentRegister = javaStackRegister;
TR::Register * javaLitPoolRegister = privateLinkage->getLitPoolRealRegister();
bool passLitPoolReg = false;
TR_XPLinkCallTypes callType; // for XPLink calls

if (codeGen->isLiteralPoolOnDemandOn())
{
Expand Down Expand Up @@ -417,21 +416,9 @@ TR::J9S390zOSSystemLinkage::generateInstructionsForCall(TR::Node * callNode, TR:
if (isJNIGCPoint)
gcPoint->setNeedsGCMap(0x00000000);

callType = TR_XPLinkCallType_BASR;

generateS390LabelInstruction(codeGen, TR::InstOpCode::LABEL, callNode, returnFromJNICallLabel);

TR::Instruction * cursor = NULL;
if (TR::Compiler->target.is64Bit())
{
//In 64 bit XPLINK, the caller returns at RetAddr+2, so add 2 byte nop
cursor = new (trHeapMemory()) TR::S390NOPInstruction(TR::InstOpCode::NOP, 2, callNode, codeGen);
}
else
{
cursor = genCallNOPAndDescriptor(NULL, callNode, callNode, callType);
}
TR::Instruction * cursor = generateS390LabelInstruction(codeGen, TR::InstOpCode::LABEL, callNode, returnFromJNICallLabel);

cursor = genCallNOPAndDescriptor(cursor, callNode, callNode, TR_XPLinkCallType_BASR);
cursor->setDependencyConditions(callPostDeps);

if (cg()->supportsJITFreeSystemStackPointer())
Expand Down Expand Up @@ -526,64 +513,38 @@ TR::J9S390zOSSystemLinkage::addFECustomizedReturnRegDependency(int64_t killMask,
* General XPLink utility
*/
TR::Instruction *
TR::J9S390zOSSystemLinkage::genCallNOPAndDescriptor(TR::Instruction * cursor, TR::Node *node, TR::Node *callNode, TR_XPLinkCallTypes callType)
TR::J9S390zOSSystemLinkage::genCallNOPAndDescriptor(TR::Instruction * cursor,
TR::Node *node,
TR::Node *callNode,
TR_XPLinkCallTypes callType)
{
TR::CodeGenerator * codeGen = cg();
TR::S390NOPInstruction *nop;
// In 64 bit XPLINK, the caller returns at RetAddr+2, so add 2 byte nop
// In 31 bit XPLINK, the caller returns at RetAddr+4, so add 4 byte nop with last two bytes
// as signed offset in doublewords at or preceding NOP
uint32_t padSize = TR::Compiler->target.is64Bit() ? 2 : 4;

if (TR::Compiler->target.is64Bit())
{
//In 64 bit XPLINK, the caller returns at RetAddr+2, so add 2 byte nop
cursor = nop = new (trHeapMemory()) TR::S390NOPInstruction(TR::InstOpCode::NOP, 2, node, cursor, codeGen);
}
else
cursor = codeGen->insertPad(node, cursor, padSize, false);
TR::S390NOPInstruction *nop = static_cast<TR::S390NOPInstruction *>(cursor);

if (TR::Compiler->target.is32Bit())
{
//In 31 bit XPLINK, the caller returns at RetAddr+4, so add 4 byte nop with last two bytes
// as signed offset in doublewords at or preceding NOP
TR::S390ConstantDataSnippet *callDescSnippet ;
uint32_t callDescValues = calculateCallDescriptorFlags(callNode); // lower 32 bits

callDescSnippet = createCallDescriptor(node, (uint64_t)callDescValues);
if (cursor != NULL) // TBD: this is needed but need to understand why - problem in else case if remove this and provide NULL cursor to the following constructor
cursor = nop = new (trHeapMemory()) TR::S390NOPInstruction(TR::InstOpCode::NOP, 4, callDescSnippet, node, cursor, codeGen);
else
cursor = nop = new (trHeapMemory()) TR::S390NOPInstruction(TR::InstOpCode::NOP, 4, callDescSnippet, node, codeGen);

// Check if we are emitting warm code. Mark Snippet as warm snippet if necessary.

TR::S390ConstantDataSnippet * callDescSnippet = cg()->findOrCreate8ByteConstant(node, (int64_t)callDescValues, false);
nop->setTargetSnippet(callDescSnippet);

// Create a pseudo instruction that will generate
// BRAS 4
// DC <Call Descriptor>
// if the snippet is > 15k bytes away.
if (cursor != NULL)
{
TR::S390PseudoInstruction *pseudoCallDesc = (TR::S390PseudoInstruction *)generateS390PseudoInstruction(codeGen, TR::InstOpCode::XPCALLDESC, node, NULL, cursor);
// Assign this pseudoCallDesc to the NOP Instruction.
((TR::S390NOPInstruction *)cursor)->setCallDescInstr(pseudoCallDesc);
cursor = pseudoCallDesc;
}
else
{
TR::S390PseudoInstruction *pseudoCallDesc = (TR::S390PseudoInstruction *)generateS390PseudoInstruction(codeGen, TR::InstOpCode::XPCALLDESC, node);
// Assign this pseudoCallDesc to the NOP Instruction.
((TR::S390NOPInstruction *)cursor)->setCallDescInstr(pseudoCallDesc);
}

TR::S390PseudoInstruction *pseudoCallDesc = static_cast<TR::S390PseudoInstruction *>(generateS390PseudoInstruction(codeGen, TR::InstOpCode::XPCALLDESC, node, NULL, cursor));
// Assign this pseudoCallDesc to the NOP Instruction.
static_cast<TR::S390NOPInstruction *>(cursor)->setCallDescInstr(pseudoCallDesc);
cursor = pseudoCallDesc;
}

nop->setCallType(callType);
return cursor;
}

/**
* General XPLink utility
*
* Create the XPLink descriptor that is realized in binary as an
* 8 byte value
*/
TR::S390ConstantDataSnippet *
TR::J9S390zOSSystemLinkage::createCallDescriptor(TR::Node *node, uint64_t initialValue)
{
TR::S390ConstantDataSnippet *desc;
desc = (TR::S390ConstantDataSnippet *) cg()->findOrCreate8ByteConstant(node, (int64_t)initialValue, false);
return desc;
}
5 changes: 2 additions & 3 deletions runtime/compiler/trj9/z/codegen/J9S390SystemLinkage.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corp. and others
* Copyright (c) 2000, 2018 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
Expand Down Expand Up @@ -98,8 +98,7 @@ class J9S390zOSSystemLinkage: public TR::S390zOSSystemLinkage
virtual int32_t storeExtraEnvRegForBuildArgs(TR::Node * callNode, TR::Linkage* linkage, TR::RegisterDependencyConditions * dependencies,
bool isFastJNI, int32_t stackOffset, int8_t gprSize, uint32_t &numIntegerArgs);

virtual TR::Instruction * genCallNOPAndDescriptor(TR::Instruction * cursor, TR::Node *node, TR::Node *callNode, TR_XPLinkCallTypes callType);
virtual TR::S390ConstantDataSnippet *createCallDescriptor(TR::Node *node, uint64_t initialValue);
TR::Instruction * genCallNOPAndDescriptor(TR::Instruction * cursor, TR::Node *node, TR::Node *callNode, TR_XPLinkCallTypes callType);
};

}
Expand Down

0 comments on commit cc5dc68

Please sign in to comment.