mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
support immortal heap area in heap.cpp
This commit is contained in:
parent
b8056d905c
commit
702525fd32
20
src/heap.cpp
20
src/heap.cpp
@ -509,6 +509,9 @@ class Context {
|
|||||||
lowMemoryThreshold(limit / 2),
|
lowMemoryThreshold(limit / 2),
|
||||||
lock(0),
|
lock(0),
|
||||||
|
|
||||||
|
immortalHeapStart(0),
|
||||||
|
immortalHeapEnd(0),
|
||||||
|
|
||||||
ageMap(&gen1, max(1, log(TenureThreshold)), 1, 0, false),
|
ageMap(&gen1, max(1, log(TenureThreshold)), 1, 0, false),
|
||||||
gen1(this, &ageMap, 0, 0),
|
gen1(this, &ageMap, 0, 0),
|
||||||
|
|
||||||
@ -577,6 +580,9 @@ class Context {
|
|||||||
unsigned lowMemoryThreshold;
|
unsigned lowMemoryThreshold;
|
||||||
|
|
||||||
System::Mutex* lock;
|
System::Mutex* lock;
|
||||||
|
|
||||||
|
void* immortalHeapStart;
|
||||||
|
void* immortalHeapEnd;
|
||||||
|
|
||||||
Segment::Map ageMap;
|
Segment::Map ageMap;
|
||||||
Segment gen1;
|
Segment gen1;
|
||||||
@ -948,7 +954,9 @@ update3(Context* c, void* o, bool* needsVisit)
|
|||||||
void*
|
void*
|
||||||
update2(Context* c, void* o, bool* needsVisit)
|
update2(Context* c, void* o, bool* needsVisit)
|
||||||
{
|
{
|
||||||
if (c->mode == Heap::MinorCollection and c->gen2.contains(o)) {
|
if ((o < c->immortalHeapEnd and o > c->immortalHeapStart)
|
||||||
|
or (c->mode == Heap::MinorCollection and c->gen2.contains(o)))
|
||||||
|
{
|
||||||
*needsVisit = false;
|
*needsVisit = false;
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
@ -1669,6 +1677,11 @@ class MyHeap: public Heap {
|
|||||||
c.client = client;
|
c.client = client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void setImmortalHeap(uintptr_t* start, unsigned sizeInWords) {
|
||||||
|
c.immortalHeapStart = start;
|
||||||
|
c.immortalHeapEnd = start + sizeInWords;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void* tryAllocate(unsigned size) {
|
virtual void* tryAllocate(unsigned size) {
|
||||||
return ::tryAllocate(&c, size);
|
return ::tryAllocate(&c, size);
|
||||||
}
|
}
|
||||||
@ -1698,8 +1711,9 @@ class MyHeap: public Heap {
|
|||||||
Fixie(sizeInWords, objectMask, &(c.fixies), false))->body();
|
Fixie(sizeInWords, objectMask, &(c.fixies), false))->body();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void* allocateImmortal(Allocator* allocator, unsigned sizeInWords,
|
virtual void* allocateImmortalFixed(Allocator* allocator,
|
||||||
bool objectMask, unsigned* totalInBytes)
|
unsigned sizeInWords, bool objectMask,
|
||||||
|
unsigned* totalInBytes)
|
||||||
{
|
{
|
||||||
*totalInBytes = Fixie::totalSize(sizeInWords, objectMask);
|
*totalInBytes = Fixie::totalSize(sizeInWords, objectMask);
|
||||||
return (new (allocator->allocate(*totalInBytes))
|
return (new (allocator->allocate(*totalInBytes))
|
||||||
|
@ -52,11 +52,13 @@ class Heap: public Allocator {
|
|||||||
};
|
};
|
||||||
|
|
||||||
virtual void setClient(Client* client) = 0;
|
virtual void setClient(Client* client) = 0;
|
||||||
|
virtual void setImmortalHeap(uintptr_t* start, unsigned sizeInWords) = 0;
|
||||||
virtual void collect(CollectionType type, unsigned footprint) = 0;
|
virtual void collect(CollectionType type, unsigned footprint) = 0;
|
||||||
virtual void* allocateFixed(Allocator* allocator, unsigned sizeInWords,
|
virtual void* allocateFixed(Allocator* allocator, unsigned sizeInWords,
|
||||||
bool objectMask, unsigned* totalInBytes) = 0;
|
bool objectMask, unsigned* totalInBytes) = 0;
|
||||||
virtual void* allocateImmortal(Allocator* allocator, unsigned sizeInWords,
|
virtual void* allocateImmortalFixed(Allocator* allocator,
|
||||||
bool objectMask, unsigned* totalInBytes) = 0;
|
unsigned sizeInWords, bool objectMask,
|
||||||
|
unsigned* totalInBytes) = 0;
|
||||||
virtual bool needsMark(void* p) = 0;
|
virtual bool needsMark(void* p) = 0;
|
||||||
virtual bool needsMark(void* p, unsigned offset) = 0;
|
virtual bool needsMark(void* p, unsigned offset) = 0;
|
||||||
virtual void mark(void* p, unsigned offset, unsigned count) = 0;
|
virtual void mark(void* p, unsigned offset, unsigned count) = 0;
|
||||||
|
@ -1512,6 +1512,8 @@ boot(Thread* t, BootImage* image)
|
|||||||
(heapMapSize(image->heapSize), BytesPerWord);
|
(heapMapSize(image->heapSize), BytesPerWord);
|
||||||
uintptr_t* heap = heapMap + heapMapSizeInWords;
|
uintptr_t* heap = heapMap + heapMapSizeInWords;
|
||||||
|
|
||||||
|
t->m->heap->setImmortalHeap(heap, image->heapSize);
|
||||||
|
|
||||||
for (unsigned word = 0; word < heapMapSizeInWords; ++word) {
|
for (unsigned word = 0; word < heapMapSizeInWords; ++word) {
|
||||||
uintptr_t w = heapMap[word];
|
uintptr_t w = heapMap[word];
|
||||||
if (w) {
|
if (w) {
|
||||||
@ -2170,7 +2172,7 @@ allocate3(Thread* t, Allocator* allocator, Machine::AllocationType type,
|
|||||||
case Machine::ImmortalAllocation: {
|
case Machine::ImmortalAllocation: {
|
||||||
unsigned total;
|
unsigned total;
|
||||||
object o = static_cast<object>
|
object o = static_cast<object>
|
||||||
(t->m->heap->allocateImmortal
|
(t->m->heap->allocateImmortalFixed
|
||||||
(allocator, ceiling(sizeInBytes, BytesPerWord), objectMask, &total));
|
(allocator, ceiling(sizeInBytes, BytesPerWord), objectMask, &total));
|
||||||
|
|
||||||
cast<uintptr_t>(o, 0) = FixedMark;
|
cast<uintptr_t>(o, 0) = FixedMark;
|
||||||
|
Loading…
Reference in New Issue
Block a user