Skip to content

Commit

Permalink
Eliminate vm.heapBaseAddress()
Browse files Browse the repository at this point in the history
This commit removes J9::VMEnv::heapBaseAddress() as this
routine always returns 0. It was introduced in the codebase
early on in the codebase and has since been superseded by
a shift-based solution. Hence it no longer needed.

Signed-off-by: Dhruv Chopra <Dhruv.C.Chopra@ibm.com>
  • Loading branch information
dchopra001 committed Jan 19, 2021
1 parent b981493 commit 8a4bb3a
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 409 deletions.
38 changes: 11 additions & 27 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 @@ -484,20 +484,12 @@ J9::ARM64::TreeEvaluator::awrtbariEvaluator(TR::Node *node, TR::CodeGenerator *c
if (translatedNode->getOpCode().isRightShift()) // optional
translatedNode = translatedNode->getFirstChild();

bool usingLowMemHeap = false;
if (TR::Compiler->vm.heapBaseAddress() == 0 || secondChild->isNull())
usingLowMemHeap = true;
usingCompressedPointers = true;

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 @@ -2645,20 +2637,12 @@ J9::ARM64::TreeEvaluator::ArrayStoreCHKEvaluator(TR::Node *node, TR::CodeGenerat
if (translatedNode->getOpCode().isRightShift()) // optional
translatedNode = translatedNode->getFirstChild();

bool usingLowMemHeap = false;
if (TR::Compiler->vm.heapBaseAddress() == 0 || sourceChild->isNull())
usingLowMemHeap = true;
usingCompressedPointers = true;

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
47 changes: 5 additions & 42 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,7 @@ J9::CodeGenerator::lowerCompressedRefs(
vcount_t visitCount,
TR_BitVector *childrenToBeLowered)
{
bool isLowMem = false;
if (TR::Compiler->vm.heapBaseAddress() == 0)
{
isLowMem = true;
}

bool isLowMem = true;
if (node->getOpCode().isCall() && childrenToBeLowered)
{
TR_BitVectorIterator bvi(*childrenToBeLowered);
Expand All @@ -484,8 +479,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 @@ -3322,8 +3316,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 +3433,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 +3493,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 +3579,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 +3709,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 +3850,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;

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

0 comments on commit 8a4bb3a

Please sign in to comment.