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

Eliminate vm.heapBaseAddress() #11688

Merged
merged 4 commits into from
Feb 5, 2021
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
92 changes: 11 additions & 81 deletions runtime/compiler/aarch64/codegen/J9TreeEvaluator.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2020 IBM Corp. and others
* Copyright (c) 2019, 2021 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 @@ -460,44 +460,12 @@ J9::ARM64::TreeEvaluator::awrtbariEvaluator(TR::Node *node, TR::CodeGenerator *c

if (comp->useCompressedPointers() && (node->getSymbolReference()->getSymbol()->getDataType() == TR::Address) && (node->getSecondChild()->getDataType() != TR::Address))
{
// pattern match the sequence
// awrtbari f awrtbari f <- node
// aload O aload O
// value l2i
// lshr <- translatedNode
// lsub
// a2l
// value <- secondChild
// lconst HB
// iconst shftKonst
//
// -or- if the field is known to be null or usingLowMemHeap
// awrtbari f
// aload O
// l2i
// a2l
// value <- secondChild
//
TR::Node *translatedNode = secondChild;
if (translatedNode->getOpCode().isConversion())
translatedNode = translatedNode->getFirstChild();
if (translatedNode->getOpCode().isRightShift()) // optional
translatedNode = translatedNode->getFirstChild();

bool usingLowMemHeap = false;
if (TR::Compiler->vm.heapBaseAddress() == 0 || secondChild->isNull())
usingLowMemHeap = true;
usingCompressedPointers = true;
fjeremic marked this conversation as resolved.
Show resolved Hide resolved

if (translatedNode->getOpCode().isSub() || usingLowMemHeap)
usingCompressedPointers = true;

if (usingCompressedPointers)
{
while (secondChild->getNumChildren() && secondChild->getOpCodeValue() != TR::a2l)
secondChild = secondChild->getFirstChild();
if (secondChild->getNumChildren())
secondChild = secondChild->getFirstChild();
}
while (secondChild->getNumChildren() && secondChild->getOpCodeValue() != TR::a2l)
secondChild = secondChild->getFirstChild();
if (secondChild->getNumChildren())
secondChild = secondChild->getFirstChild();
}

if (secondChild->getReferenceCount() > 1 && secondChild->getRegister() != NULL)
Expand Down Expand Up @@ -2615,50 +2583,12 @@ J9::ARM64::TreeEvaluator::ArrayStoreCHKEvaluator(TR::Node *node, TR::CodeGenerat
bool usingCompressedPointers = false;
if (comp->useCompressedPointers() && firstChild->getOpCode().isIndirect())
{
// pattern match the sequence
// ArrayStoreCHK ArrayStoreCHK
// awrtbari awrtbari <- firstChild
// aladd aladd
// ... ...
// value l2i
// aload lshr
// lsub
// a2l
// value <- sourceChild
// lconst HB
// iconst shftKonst
// aload <- dstNode
//
// -or- if the value is known to be null
// ArrayStoreCHK
// awrtbari
// aladd
// ...
// l2i
// a2l
// value <- sourceChild
// aload <- dstNode
//
TR::Node *translatedNode = sourceChild;
if (translatedNode->getOpCode().isConversion())
translatedNode = translatedNode->getFirstChild();
if (translatedNode->getOpCode().isRightShift()) // optional
translatedNode = translatedNode->getFirstChild();

bool usingLowMemHeap = false;
if (TR::Compiler->vm.heapBaseAddress() == 0 || sourceChild->isNull())
usingLowMemHeap = true;
usingCompressedPointers = true;
fjeremic marked this conversation as resolved.
Show resolved Hide resolved

if ((translatedNode->getOpCode().isSub()) || usingLowMemHeap)
usingCompressedPointers = true;

if (usingCompressedPointers)
{
while ((sourceChild->getNumChildren() > 0) && (sourceChild->getOpCodeValue() != TR::a2l))
sourceChild = sourceChild->getFirstChild();
if (sourceChild->getOpCodeValue() == TR::a2l)
sourceChild = sourceChild->getFirstChild();
}
while ((sourceChild->getNumChildren() > 0) && (sourceChild->getOpCodeValue() != TR::a2l))
sourceChild = sourceChild->getFirstChild();
if (sourceChild->getOpCodeValue() == TR::a2l)
sourceChild = sourceChild->getFirstChild();
}

TR::Register *srcReg;
Expand Down
108 changes: 12 additions & 96 deletions runtime/compiler/codegen/J9CodeGenerator.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, 2021 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 @@ -462,12 +462,6 @@ J9::CodeGenerator::lowerCompressedRefs(
vcount_t visitCount,
TR_BitVector *childrenToBeLowered)
{
bool isLowMem = false;
if (TR::Compiler->vm.heapBaseAddress() == 0)
{
isLowMem = true;
}

if (node->getOpCode().isCall() && childrenToBeLowered)
{
TR_BitVectorIterator bvi(*childrenToBeLowered);
Expand All @@ -484,8 +478,7 @@ J9::CodeGenerator::lowerCompressedRefs(
}

TR::Node *heapBase = TR::Node::create(node, TR::lconst, 0, 0);
heapBase->setLongInt(TR::Compiler->vm.heapBaseAddress());
lowerCASValues(node, nextChild, valueChild, self()->comp(), shftOffset, isLowMem, heapBase);
lowerCASValues(node, nextChild, valueChild, self()->comp(), shftOffset, true, heapBase);
}
}

Expand Down Expand Up @@ -639,10 +632,6 @@ J9::CodeGenerator::lowerCompressedRefs(
if (TR::Compiler->om.compressedReferenceShiftOffset() > 0)
shftOffset = TR::Node::create(loadOrStoreNode, TR::iconst, 0, TR::Compiler->om.compressedReferenceShiftOffset());

static char *pEnv = feGetEnv("TR_disableLowHeapMem");
if (pEnv)
isLowMem = false;

if (isLoad)
{
TR::Node *newLoad = TR::Node::createWithSymRef(loadOrStoreOp, 1, 1, address, symRef);
Expand All @@ -660,45 +649,16 @@ J9::CodeGenerator::lowerCompressedRefs(
//
TR::Node *iu2lNode = TR::Node::create(TR::iu2l, 1, newLoad);

if (!isLowMem && (loadOrStoreNode->getVisitCount() != visitCount))
{
TR::Node *ttNode = TR::Node::create(TR::treetop, 1, iu2lNode);
//traceMsg(comp(), "3creating treetop %p\n", ttNode);
TR::TreeTop *tt = TR::TreeTop::create(self()->comp(), ttNode);
TR::TreeTop *prevTT = treeTop->getPrevTreeTop();
prevTT->join(tt);
tt->join(treeTop);
}

TR::Node *addNode = iu2lNode;
if (loadOrStoreNode->isNonNull())
addNode->setIsNonZero(true);

// if the load is known to be null or if using lowMemHeap, do not
// generate a compression sequence
//
if (loadOrStoreNode->isNull() || isLowMem)
{
addNode = iu2lNode;
if (shftOffset)
{
addNode = TR::Node::create(TR::lshl, 2, iu2lNode, shftOffset);
addNode->setContainsCompressionSequence(true);
}
}
else
addNode = iu2lNode;
if (shftOffset)
{
if (shftOffset)
{
addNode = TR::Node::create(TR::lshl, 2, iu2lNode, shftOffset);
addNode->setContainsCompressionSequence(true);
}
if (loadOrStoreNode->isNonNull())
addNode->setIsNonZero(true);
addNode = TR::Node::create(TR::ladd, 2, addNode, heapBase);
if (loadOrStoreNode->isNonNull())
addNode->setIsNonZero(true);

addNode = TR::Node::create(TR::lshl, 2, iu2lNode, shftOffset);
addNode->setContainsCompressionSequence(true);
}

Expand Down Expand Up @@ -726,29 +686,16 @@ J9::CodeGenerator::lowerCompressedRefs(
isNonNull = true;

TR::Node *addNode = NULL;
addNode = a2lNode;

if (address->isNull() || isLowMem)
{
addNode = a2lNode;
}
else
if (shftOffset)
{
if (isNonNull)
a2lNode->setIsNonZero(true);
addNode = TR::Node::create(TR::lsub, 2, a2lNode, heapBase);
addNode = TR::Node::create(TR::lushr, 2, addNode, shftOffset);
addNode->setContainsCompressionSequence(true);
if (isNonNull)
addNode->setIsNonZero(true);
}

if (shftOffset)
{
addNode = TR::Node::create(TR::lushr, 2, addNode, shftOffset);
addNode->setContainsCompressionSequence(true);
}

if (isNonNull)
addNode->setIsNonZero(true);
if (isNonNull)
addNode->setIsNonZero(true);

l2iNode = TR::Node::create(TR::l2i, 1, addNode);
if (isNonNull)
Expand Down Expand Up @@ -3322,8 +3269,7 @@ J9::CodeGenerator::compressedReferenceRematerialization()

// no need to rematerialize for lowMemHeap
if (self()->comp()->useCompressedPointers() &&
((TR::Compiler->vm.heapBaseAddress() != 0) ||
(TR::Compiler->om.compressedReferenceShift() != 0)) &&
(TR::Compiler->om.compressedReferenceShift() != 0) &&
!disableRematforCP)
{
if (self()->comp()->getOption(TR_TraceCG))
Expand Down Expand Up @@ -3440,7 +3386,6 @@ J9::CodeGenerator::compressedReferenceRematerialization()
}

if (self()->comp()->useCompressedPointers() &&
(TR::Compiler->vm.heapBaseAddress() == 0) &&
!disableRematforCP)
{
for (tt = self()->comp()->getStartTree(); tt; tt = tt->getNextTreeTop())
Expand Down Expand Up @@ -3501,8 +3446,6 @@ J9::CodeGenerator::rematerializeCompressedRefs(
bool alreadyVisitedReferenceInNullTest = false;
bool alreadyVisitedReferenceInStore = false;

bool isLowMemHeap = (TR::Compiler->vm.heapBaseAddress() == 0);

TR::Node *reference = NULL;
TR::Node *address = NULL;

Expand Down Expand Up @@ -3589,7 +3532,6 @@ J9::CodeGenerator::rematerializeCompressedRefs(
((node->getFirstChild()->getOpCodeValue() == TR::ladd &&
node->getFirstChild()->containsCompressionSequence()) ||
((node->getFirstChild()->getOpCodeValue() == TR::lshl) &&
(self()->canFoldLargeOffsetInAddressing() || (TR::Compiler->vm.heapBaseAddress() == 0)) &&
self()->isAddressScaleIndexSupported((1 << TR::Compiler->om.compressedReferenceShiftOffset())))))
{
if (parent &&
Expand Down Expand Up @@ -3720,7 +3662,7 @@ J9::CodeGenerator::rematerializeCompressedRefs(

static bool disableBranchlessPassThroughNULLCHK = feGetEnv("TR_disableBranchlessPassThroughNULLCHK") != NULL;
if (node->getOpCode().isNullCheck() && reference &&
(!isLowMemHeap || self()->performsChecksExplicitly() || (disableBranchlessPassThroughNULLCHK && node->getFirstChild()->getOpCodeValue() == TR::PassThrough)) &&
(self()->performsChecksExplicitly() || (disableBranchlessPassThroughNULLCHK && node->getFirstChild()->getOpCodeValue() == TR::PassThrough)) &&
((node->getFirstChild()->getOpCodeValue() == TR::l2a) ||
(reference->getOpCodeValue() == TR::l2a)) &&
performTransformation(self()->comp(), "%sTransforming null check reference %p in null check node %p to be checked explicitly\n", OPT_DETAILS, reference, node))
Expand Down Expand Up @@ -3861,32 +3803,6 @@ J9::CodeGenerator::rematerializeCompressedRefs(
}
}

if (self()->materializesHeapBase() &&
!isLowMemHeap &&
parent && (!parent->getOpCode().isStore()) &&
(node->getOpCodeValue() == TR::lconst) &&
(node->getLongInt() == TR::Compiler->vm.heapBaseAddress()) &&
performTransformation(self()->comp(), "%sTransforming heap base constant node %p to auto load \n", OPT_DETAILS, node))
{
if (!autoSymRef)
{
autoSymRef = self()->comp()->getSymRefTab()->createTemporary(self()->comp()->getMethodSymbol(), node->getDataType());
TR::TreeTop *startTree = self()->comp()->getStartTree();
TR::TreeTop *nextTree = startTree->getNextTreeTop();

TR::Node *lconstNode = TR::Node::create(node, TR::lconst, 0, 0);
lconstNode->setLongInt(node->getLongInt());
TR::Node *storeNode = TR::Node::createWithSymRef(TR::lstore, 1, 1, lconstNode, autoSymRef);
TR::TreeTop *tt = TR::TreeTop::create(self()->comp(), storeNode);
startTree->join(tt);
tt->join(nextTree);
}

TR::Node::recreate(node, TR::lload);
node->setSymbolReference(autoSymRef);
}


if (address && node->getOpCode().isStoreIndirect())
{
if (address->getOpCodeValue() == TR::l2a && (address->getReferenceCount() == 1 || !alreadyVisitedReferenceInStore) &&
Expand Down
39 changes: 16 additions & 23 deletions runtime/compiler/codegen/J9TreeEvaluator.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, 2021 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 @@ -499,32 +499,25 @@ bool J9::TreeEvaluator::getIndirectWrtbarValueNode(TR::CodeGenerator *cg, TR::No
translatedNode = translatedNode->getFirstChild();
}

if (translatedNode->getOpCode().isSub() ||
TR::Compiler->vm.heapBaseAddress() == 0 || sourceChild->isNull()) /* i.e. usingLowMemHeap */
usingCompressedPointers = true;
fjeremic marked this conversation as resolved.
Show resolved Hide resolved

while ((sourceChild->getNumChildren() > 0) && (sourceChild->getOpCodeValue() != TR::a2l))
{
usingCompressedPointers = true;
sourceChild = sourceChild->getFirstChild();
}

if (usingCompressedPointers)
if (sourceChild->getOpCodeValue() == TR::a2l)
{
while ((sourceChild->getNumChildren() > 0) && (sourceChild->getOpCodeValue() != TR::a2l))
{
sourceChild = sourceChild->getFirstChild();
}
if (sourceChild->getOpCodeValue() == TR::a2l)
{
sourceChild = sourceChild->getFirstChild();
}
sourceChild = sourceChild->getFirstChild();
}

// Artificially bump up the refCount on the value so
// that different registers are allocated for the actual
// and compressed values. This is done so that the VMwrtbarEvaluator
// uses the uncompressed value. We only need to do this when the caller
// is evaluating the actual write barrier.
if (incSrcRefCount)
{
sourceChild->incReferenceCount();
}
// Artificially bump up the refCount on the value so
// that different registers are allocated for the actual
// and compressed values. This is done so that the VMwrtbarEvaluator
// uses the uncompressed value. We only need to do this when the caller
// is evaluating the actual write barrier.
if (incSrcRefCount)
{
sourceChild->incReferenceCount();
}
}
return usingCompressedPointers;
Expand Down
4 changes: 2 additions & 2 deletions runtime/compiler/env/J9ObjectModel.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, 2021 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 @@ -618,7 +618,7 @@ J9::ObjectModel::getArrayLengthInElements(TR::Compilation* comp, uintptr_t objec
uintptr_t
J9::ObjectModel::decompressReference(TR::Compilation* comp, uintptr_t compressedReference)
{
return (compressedReference << TR::Compiler->om.compressedReferenceShift()) + TR::Compiler->vm.heapBaseAddress();
return (compressedReference << TR::Compiler->om.compressedReferenceShift());
}

bool
Expand Down
Loading