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 2 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
50 changes: 5 additions & 45 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,9 +632,7 @@ 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;
bool isLowMem = feGetEnv("TR_disableLowHeapMem") ? false : true;
fjeremic marked this conversation as resolved.
Show resolved Hide resolved

if (isLoad)
{
Expand Down Expand Up @@ -3322,8 +3313,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 +3430,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 +3490,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 +3576,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 +3706,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 +3847,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
10 changes: 1 addition & 9 deletions runtime/compiler/env/J9VMEnv.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 @@ -61,14 +61,6 @@ J9::VMEnv::maxHeapSizeInBytes()
return (int64_t) mmf->j9gc_get_maximum_heap_size(jvm);
}


UDATA
J9::VMEnv::heapBaseAddress()
{
return 0;
}


bool
J9::VMEnv::hasAccess(OMR_VMThread *omrVMThread)
{
Expand Down
4 changes: 1 addition & 3 deletions runtime/compiler/env/J9VMEnv.hpp
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 @@ -51,8 +51,6 @@ class OMR_EXTENSIBLE VMEnv : public OMR::VMEnvConnector

int64_t maxHeapSizeInBytes();

uintptr_t heapBaseAddress();

uintptr_t thisThreadGetPendingExceptionOffset();

bool hasResumableTrapHandler(TR::Compilation *comp);
Expand Down
4 changes: 2 additions & 2 deletions runtime/compiler/env/VMJ9.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 @@ -1141,7 +1141,7 @@ TR_J9VMBase::getReferenceFieldAtAddress(uintptr_t fieldAddress)
if (TR::Compiler->om.compressObjectReferences())
{
uintptr_t compressedResult = *(uint32_t*)fieldAddress;
return (compressedResult << TR::Compiler->om.compressedReferenceShift()) + TR::Compiler->vm.heapBaseAddress();
return (compressedResult << TR::Compiler->om.compressedReferenceShift());
}
return *(uintptr_t*)fieldAddress;
}
Expand Down
Loading