Skip to content

Commit

Permalink
Remove allocator name fields
Browse files Browse the repository at this point in the history
Unused in OMR and known downstream projects.

Signed-off-by: Daryl Maier <maier@ca.ibm.com>
  • Loading branch information
0xdaryl committed Mar 2, 2021
1 parent 67ddc28 commit 3710496
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 43 deletions.
3 changes: 1 addition & 2 deletions compiler/compile/OMRCompilation.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 @@ -220,7 +220,6 @@ OMR::Compilation::Compilation(
_method(compilee),
_arenaAllocator(TR::Allocator(self()->allocator("Arena"))),
_aliasRegion(heapMemoryRegion),
_allocatorName(NULL),
_ilGenerator(0),
_ilValidator(NULL),
_optimizer(0),
Expand Down
2 changes: 0 additions & 2 deletions compiler/compile/OMRCompilation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ class OMR_EXTENSIBLE Compilation
TR::Allocator allocator(const char *name = NULL) { return TR::Allocator(_allocator); }

TR_ArenaAllocator *arenaAllocator() { return &_arenaAllocator; }
void setAllocatorName(const char *name) { _allocatorName = name; }

TR_OpaqueMethodBlock *getMethodFromNode(TR::Node * node);
int32_t getLineNumber(TR::Node *);
Expand Down Expand Up @@ -1186,7 +1185,6 @@ class OMR_EXTENSIBLE Compilation
private:
TR_ResolvedMethod *_method; // must be declared before _flowGraph
TR_ArenaAllocator _arenaAllocator;
const char * _allocatorName;
TR::Region _aliasRegion;


Expand Down
54 changes: 27 additions & 27 deletions compiler/cs2/allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ namespace CS2 {
// objects will share the same memory pool
class malloc_allocator {
public:
void *allocate(size_t size, const char *name=NULL) {
void *allocate(size_t size) {
return malloc(size);
}
void deallocate(void *pointer, size_t size, const char *name=NULL) {
void deallocate(void *pointer, size_t size) {
free(pointer);
}
void *reallocate(size_t newsize, void *pointer, size_t size, const char *name=NULL) {
void *reallocate(size_t newsize, void *pointer, size_t size) {
return realloc(pointer, newsize);
}

Expand Down Expand Up @@ -218,15 +218,15 @@ namespace CS2 {
}
}

Segment *new_segment(Segment *next, const char *name) {
void *ret = base_allocator::allocate(segmentsize, name);
Segment *new_segment(Segment *next) {
void *ret = base_allocator::allocate(segmentsize);
return new (ret) Segment(next);
}

void *allocate(size_t size, const char *name=NULL) {
void *allocate(size_t size) {
uint32_t ix = Segment::segment_index(size);
if (ix==0) {
return base_allocator::allocate(size, name);
return base_allocator::allocate(size);
}

for (Segment *s = segments[ix]; s; s=s->next_segment()) {
Expand All @@ -237,42 +237,42 @@ namespace CS2 {
return ret;
}
}
segments[ix] = new_segment(segments[ix], name);
segments[ix] = new_segment(segments[ix]);
return segments[ix]->allocate(ix);
}
void deallocate(void *pointer, size_t size, const char *name = NULL) {
void deallocate(void *pointer, size_t size) {
uint32_t ix = Segment::segment_index(size);
if (ix==0) {
return base_allocator::deallocate(pointer, size, name);
return base_allocator::deallocate(pointer, size);
}

for (Segment *s = segments[ix]; s; s=s->next_segment()) {
if (s->holds_address(pointer)) {
s->deallocate(pointer);
if (s->is_empty()) {
segments[ix] = s->unlink(segments[ix]);
base_allocator::deallocate(s, segmentsize, name);
base_allocator::deallocate(s, segmentsize);
} else if (s!=segments[ix])
segments[ix]= s->move_to_head(segments[ix]);
return;
}
}
CS2Assert(false, ("Could not find pointer to delete: %p", pointer));
}
void *reallocate(size_t newsize, void *pointer, size_t size, const char *name = NULL) {
void *reallocate(size_t newsize, void *pointer, size_t size) {
uint32_t ix = Segment::segment_index(size);
uint32_t nix = Segment::segment_index(newsize);

if (ix==nix) {
if (ix==0) {
return base_allocator::reallocate(newsize, pointer, size, name);
return base_allocator::reallocate(newsize, pointer, size);
}
return pointer;
}

void * npointer = allocate(newsize, name);
void * npointer = allocate(newsize);
memcpy(npointer, pointer, newsize<size?newsize:size);
deallocate(pointer, size, name);
deallocate(pointer, size);

return npointer;
}
Expand All @@ -284,16 +284,16 @@ namespace CS2 {
public:
shared_allocator(base_allocator &b = base_allocator::instance()) : base(b) {}

void *allocate(size_t size, const char *name = NULL) {
return base.allocate(size, name);
void *allocate(size_t size) {
return base.allocate(size);
}

void deallocate(void *pointer, size_t size, const char *name = NULL) {
return base.deallocate(pointer, size, name);
void deallocate(void *pointer, size_t size) {
return base.deallocate(pointer, size);
}

void *reallocate(size_t newsize, void *pointer, size_t size, const char *name=NULL) {
return base.reallocate(newsize, pointer, size, name);
void *reallocate(size_t newsize, void *pointer, size_t size) {
return base.reallocate(newsize, pointer, size);
}

template <class ostr, class allocator> ostr& stats(ostr &o, allocator &a) { return base.stats(o, a);}
Expand Down Expand Up @@ -334,20 +334,20 @@ namespace CS2 {

static size_t arena_size() { return segmentsize - sizeof(Segment);}

void *allocate(size_t size, const char *name=NULL) {
void *allocate(size_t size) {
if (size % sizeof(size_t)) size = (size/sizeof(size_t)+1)*sizeof(size_t);

void *ret;
if (segment && size>=arena_size()) {
Segment *new_segment = (Segment *)base_allocator::allocate(sizeof(Segment)+size, name);
Segment *new_segment = (Segment *)base_allocator::allocate(sizeof(Segment)+size);
new_segment->size = sizeof(Segment)+size;
new_segment->next = segment->next;
segment->next=new_segment;

ret = (void *)((char *)new_segment + sizeof(Segment));
} else if (segment==NULL || allocated+size>arena_size()) {

Segment *new_segment = (Segment *)base_allocator::allocate(segmentsize, name);
Segment *new_segment = (Segment *)base_allocator::allocate(segmentsize);
new_segment->size = segmentsize;
new_segment->next = segment;

Expand All @@ -361,13 +361,13 @@ namespace CS2 {
return ret;
}

void deallocate(void *pointer, size_t size, const char *name=NULL) {
void deallocate(void *pointer, size_t size) {
// no deallocation
}

void *reallocate(size_t newsize, void *pointer, size_t size, const char *name=NULL) {
void *reallocate(size_t newsize, void *pointer, size_t size) {
if (newsize<=size) return pointer;
void *ret = allocate(newsize, name);
void *ret = allocate(newsize);
memcpy(ret, pointer, size);
return ret;
}
Expand Down
2 changes: 0 additions & 2 deletions compiler/optimizer/OMROptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1975,7 +1975,6 @@ int32_t OMR::Optimizer::performOptimization(const OptimizationStrategy *optimiza
#endif
LexicalTimer t(manager->name(), comp()->phaseTimer());
TR::LexicalMemProfiler mp(manager->name(), comp()->phaseMemProfiler());
comp()->setAllocatorName(manager->name());

int32_t origSymRefCount = comp()->getSymRefCount();
int32_t origNodeCount = comp()->getNodeCount();
Expand Down Expand Up @@ -2079,7 +2078,6 @@ int32_t OMR::Optimizer::performOptimization(const OptimizationStrategy *optimiza
if (!isIlGenOpt())
comp()->invalidateAliasRegion();
breakForTesting(-optNum);
comp()->setAllocatorName(NULL);

if (comp()->compilationShouldBeInterrupted((TR_CallingContext)optNum))
{
Expand Down
14 changes: 6 additions & 8 deletions compiler/optimizer/UseDefInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
#define REACHING_DEFS_LIMIT (25000000) // 25 Million


const char* const TR_UseDefInfo::allocatorName = "UseDefInfo";

/**
* Constructs TR_UseDefInfo instance. Note that this should not be called directly.
* Instead construction is handled by OMR::Optimizer::createUseDefInfo() method.
Expand All @@ -100,13 +98,13 @@ TR_UseDefInfo::TR_UseDefInfo(TR::Compilation *comp, TR::CFG *cfg, TR::Optimizer
_optimizer(optimizer),
_atoms(0, std::make_pair<TR::Node *, TR::TreeTop *>(NULL, NULL), _region),
_useDefForMemorySymbols(false),
_useDefInfo(0, TR_UseDefInfo::BitVector(comp->allocator(allocatorName)), _region),
_useDefInfo(0, TR_UseDefInfo::BitVector(comp->allocator()), _region),
_isUseDefInfoValid(false),
_infoCache(_region),
_EMPTY(comp->allocator(allocatorName)),
_EMPTY(comp->allocator()),
_useDerefDefInfo(0, static_cast<const BitVector *>(NULL), _region),
_defUseInfo(0, TR_UseDefInfo::BitVector(comp->allocator(allocatorName)), _region),
_loadDefUseInfo(0, TR_UseDefInfo::BitVector(comp->allocator(allocatorName)), _region),
_defUseInfo(0, TR_UseDefInfo::BitVector(comp->allocator()), _region),
_loadDefUseInfo(0, TR_UseDefInfo::BitVector(comp->allocator()), _region),
_tempsOnly(false),
_trace(comp->getOption(TR_TraceUseDefs)),
_hasLoadsAsDefs(loadsShouldBeDefs),
Expand Down Expand Up @@ -306,7 +304,7 @@ void TR_UseDefInfo::prepareUseDefInfo(bool requiresGlobals, bool prefersGlobals,
_defsChecklist = new (_region) TR_BitVector(getTotalNodes(), _region);

// traceMsg(comp(), "Growing useDefInfo to %d\n",getNumUseNodes());
_useDefInfo.resize(getNumUseNodes(), TR_UseDefInfo::BitVector(comp()->allocator(allocatorName)));
_useDefInfo.resize(getNumUseNodes(), TR_UseDefInfo::BitVector(comp()->allocator()));
// for (i = getNumUseNodes()-1; i >= 0; --i)
// _useDefInfo[i].GrowTo(getNumDefNodes());
_isUseDefInfoValid = true;
Expand Down Expand Up @@ -2926,7 +2924,7 @@ void TR_UseDefInfo::buildDefUseInfo(bool loadAsDef)
((_loadDefUseInfo.size() > 0) || !loadAsDef))
return;

_defUseInfo.resize(getNumDefNodes(), TR_UseDefInfo::BitVector(comp()->allocator(allocatorName)));
_defUseInfo.resize(getNumDefNodes(), TR_UseDefInfo::BitVector(comp()->allocator()));

if (loadAsDef)
_loadDefUseInfo.resize(getNumDefNodes(), TR_UseDefInfo::BitVector(allocator()));
Expand Down
3 changes: 1 addition & 2 deletions compiler/optimizer/UseDefInfo.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2019 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 @@ -235,7 +235,6 @@ class TR_UseDefInfo
bool skipAnalyzingForCompileTime(TR::Node *node, TR::Block *block, TR::Compilation *comp, AuxiliaryData &aux);

private:
static const char* const allocatorName;

void findTrivialSymbolsToExclude(TR::Node *node, TR::TreeTop *treeTop, AuxiliaryData &aux);
bool isTrivialUseDefNode(TR::Node *node, AuxiliaryData &aux);
Expand Down

0 comments on commit 3710496

Please sign in to comment.