Skip to content

Commit

Permalink
Merge pull request #4679 from AidanHa/Issue4649
Browse files Browse the repository at this point in the history
Add TR::Region::reset helper function
  • Loading branch information
Leonardo2718 authored Jan 9, 2020
2 parents 254885c + 071ded8 commit 85fd3d4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
3 changes: 1 addition & 2 deletions compiler/compile/OMRCompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2722,8 +2722,7 @@ void OMR::Compilation::invalidateAliasRegion()
{
if (self()->_aliasRegion.bytesAllocated() > (ALIAS_REGION_LOAD_FACTOR) * TR::Region::initialSize())
{
self()->_aliasRegion.~Region();
new (&self()->_aliasRegion) TR::Region(_heapMemoryRegion);
TR::Region::reset(self()->_aliasRegion, _heapMemoryRegion);
}
}

Expand Down
6 changes: 6 additions & 0 deletions compiler/env/Region.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ class Region

void deallocate(void * allocation, size_t = 0) throw();

static void reset(TR::Region& targetRegion, TR::Region& prototypeRegion)
{
targetRegion.~Region();
new (&targetRegion) TR::Region(prototypeRegion);
}

friend bool operator ==(const TR::Region &lhs, const TR::Region &rhs)
{
return &lhs == &rhs;
Expand Down
3 changes: 1 addition & 2 deletions compiler/il/NodePool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ TR::NodePool::NodePool(TR::Compilation * comp, const TR::Allocator &allocator) :
void
TR::NodePool::cleanUp()
{
_nodeRegion.~Region();
new (&_nodeRegion) TR::Region(_comp->trMemory()->heapMemoryRegion());
TR::Region::reset(_nodeRegion, _comp->trMemory()->heapMemoryRegion());
}

TR::Node *
Expand Down
3 changes: 1 addition & 2 deletions compiler/infra/OMRCfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,7 @@ TR_Structure *
OMR::CFG::invalidateStructure()
{
setStructure(NULL);
_structureRegion.~Region();
new (&_structureRegion) TR::Region(comp()->trMemory()->heapMemoryRegion());
TR::Region::reset(_structureRegion, comp()->trMemory()->heapMemoryRegion());
return getStructure();
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/optimizer/RegisterCandidate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ class TR_RegisterCandidates
TR_RegisterCandidate *newCandidate(TR::SymbolReference *ref);

void releaseCandidates() {
_candidateRegion.~Region();
new (_candidateRegion) TR::Region(_trMemory->heapMemoryRegion());
TR::Region::reset(_candidateRegion, _trMemory->heapMemoryRegion());
}

void collectCfgProperties(TR::Block **, int32_t);
Expand Down

0 comments on commit 85fd3d4

Please sign in to comment.