Skip to content

Commit d57675e

Browse files
authored
Merge pull request #19973 from mpirvu/new_operator
Changes for new/delete used by IProfiler
2 parents 0ed928f + 96ef5c5 commit d57675e

File tree

2 files changed

+15
-54
lines changed

2 files changed

+15
-54
lines changed

runtime/compiler/runtime/IProfiler.cpp

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,7 @@ void *
562562
TR_IProfiler::operator new (size_t size) throw()
563563
{
564564
memoryConsumed += (int32_t)size;
565-
void *alloc = _allocator->allocate(size, std::nothrow);
566-
return alloc;
565+
return _allocator->allocate(size, std::nothrow);
567566
}
568567

569568
TR::PersistentAllocator *
@@ -1128,7 +1127,7 @@ TR_IProfiler::findOrCreateEntry(int32_t bucket, uintptr_t pc, bool addIt)
11281127
TR_IPBytecodeHashTableEntry *headEntry = _bcHashTable[bucket];
11291128
if (headEntry && headEntry->getPC() == pc)
11301129
{
1131-
// Note: We never delete IP entries
1130+
delete entry; // Newly allocated entry is not needed
11321131
return headEntry;
11331132
}
11341133

@@ -2623,33 +2622,17 @@ TR_IProfiler::outputStats()
26232622
checkMethodHashTable();
26242623
}
26252624

2625+
26262626
void *
2627-
TR_IPBytecodeHashTableEntry::alignedPersistentAlloc(size_t size)
2627+
TR_IPBytecodeHashTableEntry::operator new (size_t size) throw()
26282628
{
2629-
#if defined(TR_HOST_64BIT)
2630-
size += 4;
2631-
memoryConsumed += (int32_t)size;
2632-
void *address = (void *) TR_IProfiler::allocator()->allocate(size, std::nothrow);
2633-
2634-
return (void *)(((uintptr_t)address + 4) & ~0x7);
2635-
#else
26362629
memoryConsumed += (int32_t)size;
26372630
return TR_IProfiler::allocator()->allocate(size, std::nothrow);
2638-
#endif
2639-
}
2640-
2641-
2642-
2643-
void *
2644-
TR_IPBCDataCallGraph::operator new (size_t size) throw()
2645-
{
2646-
return TR_IPBytecodeHashTableEntry::alignedPersistentAlloc(size);
26472631
}
26482632

2649-
void *
2650-
TR_IPBCDataFourBytes::operator new (size_t size) throw()
2633+
void TR_IPBytecodeHashTableEntry::operator delete(void *p) throw()
26512634
{
2652-
return TR_IPBytecodeHashTableEntry::alignedPersistentAlloc(size);
2635+
TR_IProfiler::allocator()->deallocate(p);
26532636
}
26542637

26552638
#if defined(J9VM_OPT_JITSERVER)
@@ -2707,18 +2690,6 @@ TR_IPBCDataFourBytes::getSumBranchCount()
27072690
return (fallThroughCount + branchToCount);
27082691
}
27092692

2710-
void *
2711-
TR_IPBCDataAllocation::operator new (size_t size) throw()
2712-
{
2713-
return TR_IPBytecodeHashTableEntry::alignedPersistentAlloc(size);
2714-
}
2715-
2716-
void *
2717-
TR_IPBCDataEightWords::operator new (size_t size) throw()
2718-
{
2719-
return TR_IPBytecodeHashTableEntry::alignedPersistentAlloc(size);
2720-
}
2721-
27222693
void
27232694
TR_IPBCDataEightWords::createPersistentCopy(TR_J9SharedCache *sharedCache, TR_IPBCDataStorageHeader *storage, TR::PersistentInfo *info)
27242695
{
@@ -2915,7 +2886,8 @@ TR_IPBCDataCallGraph::getData(TR::Compilation *comp)
29152886
void *
29162887
TR_IPMethodHashTableEntry::operator new (size_t size) throw()
29172888
{
2918-
return TR_IPBytecodeHashTableEntry::alignedPersistentAlloc(size);
2889+
memoryConsumed += (int32_t)size;
2890+
return TR_IProfiler::allocator()->allocate(size, std::nothrow);
29192891
}
29202892

29212893
int32_t
@@ -4543,8 +4515,7 @@ void *
45434515
TR_IPHashedCallSite::operator new (size_t size) throw()
45444516
{
45454517
memoryConsumed += (int32_t)size;
4546-
void *alloc = TR_IProfiler::allocator()->allocate(size, std::nothrow);
4547-
return alloc;
4518+
return TR_IProfiler::allocator()->allocate(size, std::nothrow);
45484519
}
45494520

45504521
inline

runtime/compiler/runtime/IProfiler.hpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,13 @@ enum TR_EntryStatusInfo
190190
class TR_IPBytecodeHashTableEntry
191191
{
192192
public:
193-
static void* alignedPersistentAlloc(size_t size);
194-
TR_IPBytecodeHashTableEntry(uintptr_t pc) : _next(NULL), _pc(pc), _lastSeenClassUnloadID(-1), _entryFlags(0), _persistFlags(IPBC_ENTRY_CAN_PERSIST_FLAG) {}
193+
void * operator new (size_t size) throw();
194+
void operator delete(void *p) throw();
195+
void * operator new (size_t size, void * placement) {return placement;}
196+
void operator delete(void *p, void *) {}
195197

198+
TR_IPBytecodeHashTableEntry(uintptr_t pc) : _next(NULL), _pc(pc), _lastSeenClassUnloadID(-1), _entryFlags(0), _persistFlags(IPBC_ENTRY_CAN_PERSIST_FLAG) {}
199+
virtual ~TR_IPBytecodeHashTableEntry() {}
196200
uintptr_t getPC() const { return _pc; }
197201
TR_IPBytecodeHashTableEntry * getNext() const { return _next; }
198202
void setNext(TR_IPBytecodeHashTableEntry *n) { _next = n; }
@@ -298,10 +302,6 @@ class TR_IPBCDataFourBytes : public TR_IPBytecodeHashTableEntry
298302
{
299303
public:
300304
TR_IPBCDataFourBytes(uintptr_t pc) : TR_IPBytecodeHashTableEntry(pc), data(0) {}
301-
void * operator new (size_t size) throw();
302-
void operator delete(void *p) throw() {}
303-
void * operator new (size_t size, void * placement) {return placement;}
304-
void operator delete(void *p, void *) {}
305305

306306
static const uint32_t IPROFILING_INVALID = ~0;
307307
virtual uintptr_t getData(TR::Compilation *comp = NULL) { return (uint32_t)data; }
@@ -329,8 +329,6 @@ class TR_IPBCDataAllocation : public TR_IPBytecodeHashTableEntry
329329
{
330330
public:
331331
TR_IPBCDataAllocation(uintptr_t pc) : TR_IPBytecodeHashTableEntry(pc), clazz(0), method(0), data(0) {}
332-
void * operator new (size_t size) throw();
333-
void operator delete(void *p) throw() {}
334332
static const uint32_t IPROFILING_INVALID = ~0;
335333
virtual uintptr_t getData(TR::Compilation *comp = NULL) { return (uint32_t)data; }
336334
virtual uint32_t* getDataReference() { return &data; }
@@ -359,10 +357,6 @@ class TR_IPBCDataEightWords : public TR_IPBytecodeHashTableEntry
359357
for (int i = 0; i < SWITCH_DATA_COUNT; i++)
360358
data[i] = 0;
361359
};
362-
void * operator new (size_t size) throw();
363-
void operator delete(void *p) throw() {}
364-
void * operator new (size_t size, void * placement) {return placement;}
365-
void operator delete(void *p, void *) {}
366360
static const uint64_t IPROFILING_INVALID = ~0;
367361
virtual uintptr_t getData(TR::Compilation *comp = NULL) { /*TR_ASSERT(0, "Don't call me, I'm empty"); */return 0;}
368362
virtual int32_t setData(uintptr_t value, uint32_t freq = 1) { /*TR_ASSERT(0, "Don't call me, I'm empty");*/ return 0;}
@@ -394,10 +388,6 @@ class TR_IPBCDataCallGraph : public TR_IPBytecodeHashTableEntry
394388
{
395389
_csInfo.initialize();
396390
}
397-
void * operator new (size_t size) throw();
398-
void operator delete(void *p) throw() {}
399-
void * operator new (size_t size, void * placement) {return placement;}
400-
void operator delete(void *p, void *) {}
401391

402392
// Set the higher 32 bits to zero under compressedref to avoid assertion in
403393
// CallSiteProfileInfo::setClazz, which is called by setInvalid with IPROFILING_INVALID

0 commit comments

Comments
 (0)