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

Remove wantToPatchClassPointer() and the hcrPatchClassPointers option #16481

Merged
merged 1 commit into from
Feb 4, 2023
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
4 changes: 2 additions & 2 deletions runtime/compiler/aarch64/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4089,7 +4089,7 @@ static void VMarrayStoreCHKEvaluator(TR::Node *node, TR::Register *srcReg, TR::R
cg->generateDebugCounter(TR::DebugCounter::debugCounterName(comp, "ArrayStoreCHKEvaluator:010VMarrayStoreCHKEvaluator:02JavaLangObjectCheck"), *srm);

TR::Register *javaLangObjectClassReg = srm->findOrCreateScratchRegister();
if (cg->wantToPatchClassPointer(objectClass, node) || cg->needClassAndMethodPointerRelocations())
if (cg->needClassAndMethodPointerRelocations())
{
loadAddressConstantInSnippet(cg, node, reinterpret_cast<intptr_t>(objectClass), javaLangObjectClassReg, TR_ClassPointer);
}
Expand Down Expand Up @@ -4135,7 +4135,7 @@ static void VMarrayStoreCHKEvaluator(TR::Node *node, TR::Register *srcReg, TR::R
TR_OpaqueClassBlock *arrayComponentClass = node->getArrayComponentClassInNode();
cg->generateDebugCounter(TR::DebugCounter::debugCounterName(comp, "ArrayStoreCHKEvaluator:010VMarrayStoreCHKEvaluator:06ArrayComponentClassCheck"), *srm);

if (cg->wantToPatchClassPointer(arrayComponentClass, node) || cg->needClassAndMethodPointerRelocations())
if (cg->needClassAndMethodPointerRelocations())
{
loadAddressConstantInSnippet(cg, node, reinterpret_cast<intptr_t>(arrayComponentClass), arrayComponentClassReg, TR_ClassPointer);
}
Expand Down
20 changes: 0 additions & 20 deletions runtime/compiler/codegen/J9CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4689,26 +4689,6 @@ J9::CodeGenerator::setUpForInstructionSelection()
}
}

bool
J9::CodeGenerator::wantToPatchClassPointer(TR::Compilation *comp,
const TR_OpaqueClassBlock *allegedClassPointer,
const uint8_t *inCodeAt)
{
return TR::CodeGenerator::wantToPatchClassPointer(comp, allegedClassPointer, "in code at", inCodeAt);
}

bool
J9::CodeGenerator::wantToPatchClassPointer(const TR_OpaqueClassBlock *allegedClassPointer, const uint8_t *inCodeAt)
{
return TR::CodeGenerator::wantToPatchClassPointer(self()->comp(), allegedClassPointer, inCodeAt);
}

bool
J9::CodeGenerator::wantToPatchClassPointer(const TR_OpaqueClassBlock *allegedClassPointer, const TR::Node *forNode)
{
return TR::CodeGenerator::wantToPatchClassPointer(self()->comp(), allegedClassPointer, "for node", forNode);
}

bool
J9::CodeGenerator::supportsJitMethodEntryAlignment()
{
Expand Down
39 changes: 0 additions & 39 deletions runtime/compiler/codegen/J9CodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,37 +346,6 @@ void addMonClass(TR::Node* monNode, TR_OpaqueClassBlock* clazz);

uint16_t changeParmLoadsToRegLoads(TR::Node*node, TR::Node **regLoads, TR_BitVector *globalRegsWithRegLoad, TR_BitVector &killedParms, vcount_t visitCount); // returns number of RegLoad nodes created

static bool wantToPatchClassPointer(TR::Compilation *comp,
const TR_OpaqueClassBlock *allegedClassPointer,
const char *locationDescription,
const void *location)
{
// If we have a class pointer to consider, it should look like one.
const uintptr_t j9classEyecatcher = 0x99669966;
#if defined(J9VM_OPT_JITSERVER)
if (allegedClassPointer != NULL && !comp->isOutOfProcessCompilation())
#else
if (allegedClassPointer != NULL)
#endif /* defined(J9VM_OPT_JITSERVER) */
{
TR_ASSERT(*(const uintptr_t*)allegedClassPointer == j9classEyecatcher,
"expected a J9Class* for omitted runtime assumption");
}

// Class pointer patching is restricted to HCR mode.
if (!comp->getOption(TR_EnableHCR))
return false;

// -Xjit:HCRPatchClassPointers re-enables all class pointer assumptions
if (comp->getOption(TR_HCRPatchClassPointers))
return true;

return !performTransformation(comp,
"O^O OMIT HCR CLASS POINTER ASSUMPTION: class=" POINTER_PRINTF_FORMAT ", %s " POINTER_PRINTF_FORMAT "\n", allegedClassPointer,
locationDescription,
location);
}

uint32_t _stackLimitOffsetInMetaData;

/*
Expand Down Expand Up @@ -408,14 +377,6 @@ void addMonClass(TR::Node* monNode, TR_OpaqueClassBlock* clazz);

public:

static bool wantToPatchClassPointer(TR::Compilation *comp,
const TR_OpaqueClassBlock *allegedClassPointer,
const uint8_t *inCodeAt);

bool wantToPatchClassPointer(const TR_OpaqueClassBlock *allegedClassPointer, const uint8_t *inCodeAt);

bool wantToPatchClassPointer(const TR_OpaqueClassBlock *allegedClassPointer, const TR::Node *forNode);

bool getSupportsBigDecimalLongLookasideVersioning() { return _flags3.testAny(SupportsBigDecimalLongLookasideVersioning);}
void setSupportsBigDecimalLongLookasideVersioning() { _flags3.set(SupportsBigDecimalLongLookasideVersioning);}

Expand Down
87 changes: 29 additions & 58 deletions runtime/compiler/p/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,7 @@ static void genInlineTest(TR::Node * node, TR_OpaqueClassBlock* castClassAddr, T
for (i = 0; i < num_PICS - 1; i++)
{
// Load the cached value in scratch1Reg
// HCR in genInlineTest for checkcast and instanceof
if (cg->wantToPatchClassPointer(guessClassArray[i], node))
{
iCursor = loadAddressConstantInSnippet(cg, node, (intptr_t) (guessClassArray[i]), scratch1Reg, scratch2Reg,TR::InstOpCode::Op_load, true, iCursor);
}
else if (comp->compileRelocatableCode() && comp->getOption(TR_UseSymbolValidationManager))
if (comp->compileRelocatableCode() && comp->getOption(TR_UseSymbolValidationManager))
{
TR::StaticSymbol *sym = TR::StaticSymbol::create(comp->trHeapMemory(), TR::Address);
sym->setStaticAddress(guessClassArray[i]);
Expand All @@ -216,11 +211,7 @@ static void genInlineTest(TR::Node * node, TR_OpaqueClassBlock* castClassAddr, T
}

// Load the cached value in scratch1Reg
if (cg->wantToPatchClassPointer(guessClassArray[num_PICS - 1], node))
{
iCursor = loadAddressConstantInSnippet(cg, node, (intptr_t) (guessClassArray[num_PICS - 1]), scratch1Reg, scratch2Reg,TR::InstOpCode::Op_load, true, iCursor);
}
else if (comp->compileRelocatableCode() && comp->getOption(TR_UseSymbolValidationManager))
if (comp->compileRelocatableCode() && comp->getOption(TR_UseSymbolValidationManager))
{
TR::StaticSymbol *sym = TR::StaticSymbol::create(comp->trHeapMemory(), TR::Address);
sym->setStaticAddress(guessClassArray[num_PICS - 1]);
Expand Down Expand Up @@ -2980,10 +2971,7 @@ static void VMoutlinedHelperArrayStoreCHKEvaluator(TR::Node *node, TR::Register
deps.addDependency(cg, rootClassReg, TR::RealRegister::gr11);

TR_OpaqueClassBlock *rootClass = fej9->getSystemClassFromClassName("java/lang/Object", 16);
if (cg->wantToPatchClassPointer(rootClass, node))
loadAddressConstantInSnippet(cg, node, (intptr_t) rootClass, rootClassReg, scratchReg,TR::InstOpCode::Op_load, false, NULL);
else
loadAddressConstant(cg, comp->compileRelocatableCode(), node, (intptr_t) rootClass, rootClassReg);
loadAddressConstant(cg, comp->compileRelocatableCode(), node, (intptr_t) rootClass, rootClassReg);

TR_CCPreLoadedCode helper = TR_arrayStoreCHK;
uintptr_t helperAddr = (uintptr_t) codeCache->getCCPreLoadedCodeAddress(helper, cg);
Expand Down Expand Up @@ -3119,11 +3107,7 @@ static void VMarrayStoreCHKEvaluator(TR::Node *node, TR::Register *src, TR::Regi
{
TR_OpaqueClassBlock *rootClass = fej9->getSystemClassFromClassName("java/lang/Object", 16);

if (cg->wantToPatchClassPointer(rootClass, node))
{
loadAddressConstantInSnippet(cg, node, (intptr_t) rootClass, t3Reg, t4Reg, TR::InstOpCode::Op_load, false, NULL);
}
else if (comp->compileRelocatableCode())
if (comp->compileRelocatableCode())
{
TR::StaticSymbol *sym = TR::StaticSymbol::create(comp->trHeapMemory(), TR::Address);
sym->setStaticAddress(rootClass);
Expand Down Expand Up @@ -3155,12 +3139,7 @@ static void VMarrayStoreCHKEvaluator(TR::Node *node, TR::Register *src, TR::Regi
if ((!comp->getOption(TR_DisableArrayStoreCheckOpts)) && node->getArrayComponentClassInNode())
{
TR_OpaqueClassBlock *castClass = (TR_OpaqueClassBlock *) node->getArrayComponentClassInNode();

if (cg->wantToPatchClassPointer(castClass, node))
loadAddressConstantInSnippet(cg, node, (intptr_t) castClass, t3Reg, t4Reg,TR::InstOpCode::Op_load, false, NULL);
else
loadAddressConstant(cg, comp->compileRelocatableCode(), node, (intptr_t) castClass, t3Reg);

loadAddressConstant(cg, comp->compileRelocatableCode(), node, (intptr_t) castClass, t3Reg);
generateTrg1Src2Instruction(cg,TR::InstOpCode::Op_cmpl, node, cndReg, t1Reg, t3Reg);
generateConditionalBranchInstruction(cg, TR::InstOpCode::beq, node, toWB, cndReg);
}
Expand Down Expand Up @@ -6105,48 +6084,40 @@ static void genInitObjectHeader(TR::Node *node, TR::Instruction *&iCursor, TR_Op
// Store the class
if (clzReg == NULL)
{
// HCR in genInitObjectHeader
if (cg->wantToPatchClassPointer(clazz, node))
{
iCursor = loadAddressConstantInSnippet(cg, node, (int64_t) clazz, temp1Reg, temp2Reg,TR::InstOpCode::Op_load, false, iCursor);
iCursor = generateTrg1Src1ImmInstruction(cg, TR::InstOpCode::ori, node, temp1Reg, temp1Reg, orFlag, iCursor);
}
else
{
#ifdef TR_TARGET_64BIT
int32_t offset;
intptr_t classPtr = (intptr_t)clazz;
int32_t offset;
intptr_t classPtr = (intptr_t)clazz;

offset = TR_PPCTableOfConstants::lookUp((int8_t *)&classPtr, sizeof(intptr_t), true, 0, cg);
offset = TR_PPCTableOfConstants::lookUp((int8_t *)&classPtr, sizeof(intptr_t), true, 0, cg);

if (offset != PTOC_FULL_INDEX)
if (offset != PTOC_FULL_INDEX)
{
offset *= TR::Compiler->om.sizeofReferenceAddress();
if (TR_PPCTableOfConstants::getTOCSlot(offset) == 0)
TR_PPCTableOfConstants::setTOCSlot(offset, (int64_t)clazz);
if (offset<LOWER_IMMED||offset>UPPER_IMMED)
{
offset *= TR::Compiler->om.sizeofReferenceAddress();
if (TR_PPCTableOfConstants::getTOCSlot(offset) == 0)
TR_PPCTableOfConstants::setTOCSlot(offset, (int64_t)clazz);
if (offset<LOWER_IMMED||offset>UPPER_IMMED)
{
TR_ASSERT_FATAL_WITH_NODE(node, 0x00008000 != HI_VALUE(offset), "TOC offset (0x%x) is unexpectedly high. Can not encode upper 16 bits into an addis instruction.", offset);
iCursor = generateTrg1Src1ImmInstruction(cg, TR::InstOpCode::addis, node, temp1Reg, cg->getTOCBaseRegister(), HI_VALUE(offset), iCursor);
iCursor = generateTrg1MemInstruction(cg,TR::InstOpCode::Op_load, node, temp1Reg, TR::MemoryReference::createWithDisplacement(cg, temp1Reg, LO_VALUE(offset), TR::Compiler->om.sizeofReferenceAddress()), iCursor);
}
else
{
iCursor = generateTrg1MemInstruction(cg,TR::InstOpCode::Op_load, node, temp1Reg, TR::MemoryReference::createWithDisplacement(cg, cg->getTOCBaseRegister(), offset, TR::Compiler->om.sizeofReferenceAddress()), iCursor);
}
if (orFlag != 0)
{
iCursor = generateTrg1Src1ImmInstruction(cg, TR::InstOpCode::ori, node, temp1Reg, temp1Reg, orFlag, iCursor);
}
TR_ASSERT_FATAL_WITH_NODE(node, 0x00008000 != HI_VALUE(offset), "TOC offset (0x%x) is unexpectedly high. Can not encode upper 16 bits into an addis instruction.", offset);
iCursor = generateTrg1Src1ImmInstruction(cg, TR::InstOpCode::addis, node, temp1Reg, cg->getTOCBaseRegister(), HI_VALUE(offset), iCursor);
iCursor = generateTrg1MemInstruction(cg,TR::InstOpCode::Op_load, node, temp1Reg, TR::MemoryReference::createWithDisplacement(cg, temp1Reg, LO_VALUE(offset), TR::Compiler->om.sizeofReferenceAddress()), iCursor);
}
else
{
iCursor = loadConstant(cg, node, (int64_t)clazz|(int64_t)orFlag, temp1Reg, iCursor);
iCursor = generateTrg1MemInstruction(cg,TR::InstOpCode::Op_load, node, temp1Reg, TR::MemoryReference::createWithDisplacement(cg, cg->getTOCBaseRegister(), offset, TR::Compiler->om.sizeofReferenceAddress()), iCursor);
}
if (orFlag != 0)
{
iCursor = generateTrg1Src1ImmInstruction(cg, TR::InstOpCode::ori, node, temp1Reg, temp1Reg, orFlag, iCursor);
}
}
else
{
iCursor = loadConstant(cg, node, (int64_t)clazz|(int64_t)orFlag, temp1Reg, iCursor);
}
#else
iCursor = loadConstant(cg, node, (int32_t) clazz | (int32_t) orFlag, temp1Reg, iCursor);
iCursor = loadConstant(cg, node, (int32_t) clazz | (int32_t) orFlag, temp1Reg, iCursor);
#endif /* TR_TARGET_64BIT */
}

if (TR::Compiler->om.compressObjectReferences())
// must store only 32 bits
iCursor = generateMemSrc1Instruction(cg, TR::InstOpCode::stw, node,
Expand Down
7 changes: 1 addition & 6 deletions runtime/compiler/p/codegen/J9UnresolvedDataSnippet.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2020 IBM Corp. and others
* Copyright (c) 2000, 2022 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 @@ -145,11 +145,6 @@ uint8_t *J9::Power::UnresolvedDataSnippet::emitSnippetBody()
__FILE__,
__LINE__,
getNode());
if (getDataSymbol()->isClassObject() && cg()->wantToPatchClassPointer(NULL, getAddressOfDataReference()))
{
uintptr_t dis = cursor - getAddressOfDataReference();
cg()->jitAddUnresolvedAddressMaterializationToPatchOnClassRedefinition((void *) getAddressOfDataReference());
}
cursor += 4;

*(intptr_t *)cursor = (intptr_t)getAddressOfDataReference(); // Code Cache RA
Expand Down
19 changes: 1 addition & 18 deletions runtime/compiler/runtime/RelocationRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2213,13 +2213,6 @@ TR_RelocationRecordClassAddress::applyRelocation(TR_RelocationRuntime *reloRunti

if (!newAddress) return TR_RelocationErrorCode::classValidationFailure;

if (TR::CodeGenerator::wantToPatchClassPointer(reloRuntime->comp(), newAddress, reloLocation))
{
createClassRedefinitionPicSite((void *)newAddress, (void *)reloLocation, sizeof(UDATA), 0,
getMetadataAssumptionList(reloRuntime->exceptionTable()));
RELO_LOG(reloRuntime->reloLogger(), 6, "\t\tapplyRelocation: hcr enabled, registered class redefinition site\n");
}

reloTarget->storeAddressSequence((uint8_t *)newAddress, reloLocation, reloFlags(reloTarget));
return TR_RelocationErrorCode::relocationOK;
}
Expand All @@ -2233,14 +2226,6 @@ TR_RelocationRecordClassAddress::applyRelocation(TR_RelocationRuntime *reloRunti

if (!newAddress) return TR_RelocationErrorCode::classValidationFailure;

if (TR::CodeGenerator::wantToPatchClassPointer(reloRuntime->comp(), newAddress, reloLocationHigh))
{
// This looks wrong
createClassRedefinitionPicSite((void *)newAddress, (void *)reloLocationHigh, sizeof(UDATA), 0,
getMetadataAssumptionList(reloRuntime->exceptionTable()));
RELO_LOG(reloRuntime->reloLogger(), 6, "\t\tapplyRelocation: hcr enabled, registered class redefinition site\n");
}

reloTarget->storeAddress((uint8_t *) newAddress, reloLocationHigh, reloLocationLow, reloFlags(reloTarget));
return TR_RelocationErrorCode::relocationOK;
}
Expand Down Expand Up @@ -5480,7 +5465,7 @@ TR_RelocationRecordSymbolFromManager::needsRedefinitionAssumption(TR_RelocationR
switch (symbolType)
{
case TR::SymbolType::typeClass:
needsAssumptions = TR::CodeGenerator::wantToPatchClassPointer(reloRuntime->comp(), clazz, reloLocation);
needsAssumptions = false;
break;

case TR::SymbolType::typeMethod:
Expand Down Expand Up @@ -5780,8 +5765,6 @@ TR_RelocationRecordClassPointer::activatePointer(TR_RelocationRuntime *reloRunti
TR_RelocationRecordPointer::activatePointer(reloRuntime, reloTarget, reloLocation);
TR_RelocationRecordPointerPrivateData *reloPrivateData = &(privateData()->pointer);
TR_ASSERT((void*)reloPrivateData->_pointer == (void*)reloPrivateData->_clazz, "Pointer differs from class pointer");
if (TR::CodeGenerator::wantToPatchClassPointer(reloRuntime->comp(), reloPrivateData->_clazz, reloLocation))
registerHCRAssumption(reloRuntime, reloLocation);
}

// TR_ArbitraryClassAddress
Expand Down
17 changes: 0 additions & 17 deletions runtime/compiler/x/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6752,10 +6752,6 @@ static void genInitObjectHeader(TR::Node *node,
{
instr = generateMemImmInstruction(TR::InstOpCode::S4MemImm4, node, generateX86MemoryReference(objectReg, TR::Compiler->om.offsetOfObjectVftField(), cg), (int32_t)((uintptr_t)clazz|orFlagsClass), cg);
}

// HCR in genInitObjectHeader
if (instr && cg->wantToPatchClassPointer(clazz, node))
comp->getStaticHCRPICSites()->push_front(instr);
}
else
{
Expand Down Expand Up @@ -8200,10 +8196,6 @@ J9::X86::TreeEvaluator::VMarrayStoreCHKEvaluator(

generateLabelInstruction(TR::InstOpCode::JE4, node, wrtbarLabel, cg);

// HCR in VMarrayStoreCHKEvaluator
if (cg->wantToPatchClassPointer(objectClass, node))
comp->getStaticHCRPICSites()->push_front(instr);

// here we may have to convert the TR_OpaqueClassBlock into a J9Class pointer
// and store it in destComponentClassReg
// ..
Expand Down Expand Up @@ -8303,10 +8295,6 @@ J9::X86::TreeEvaluator::VMarrayStoreCHKEvaluator(
}

generateLabelInstruction(TR::InstOpCode::JE4, node, wrtbarLabel, cg);

// HCR in VMarrayStoreCHKEvaluator
if (cg->wantToPatchClassPointer(objectClass, node))
comp->getStaticHCRPICSites()->push_front(instr);
*/


Expand Down Expand Up @@ -8359,11 +8347,6 @@ J9::X86::TreeEvaluator::VMarrayStoreCHKEvaluator(
}

generateLabelInstruction(TR::InstOpCode::JE4, node, wrtbarLabel, cg);

// HCR in VMarrayStoreCHKEvaluator
if (cg->wantToPatchClassPointer(arrayComponentClass, node))
comp->getStaticHCRPICSites()->push_front(instr);

}


Expand Down
10 changes: 1 addition & 9 deletions runtime/compiler/x/i386/codegen/IA32PrivateLinkage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,7 @@ TR::Register *J9::X86::I386::PrivateLinkage::pushIntegerWordArg(TR::Node *child)
{
// Must pass symbol reference so that aot can put out a relocation for it
//
TR::Instruction *instr = generateImmSymInstruction(TR::InstOpCode::PUSHImm4, child, (uintptr_t)sym->getStaticAddress(), symRef, cg());

// HCR register the class passed as a parameter
//
if ((sym->isClassObject() || sym->isAddressOfClassObject())
&& cg()->wantToPatchClassPointer((TR_OpaqueClassBlock*)sym->getStaticAddress(), child))
{
comp()->getStaticHCRPICSites()->push_front(instr);
}
generateImmSymInstruction(TR::InstOpCode::PUSHImm4, child, (uintptr_t)sym->getStaticAddress(), symRef, cg());
}

cg()->decReferenceCount(child);
Expand Down
Loading