mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-09 17:44:48 +09:00
Libs tests pass
This commit is contained in:
parent
b3656c255b
commit
11059d5efd
5 changed files with 70 additions and 38 deletions
|
@ -205,6 +205,12 @@ SatoriObject* SatoriAllocator::AllocRegular(SatoriAllocationContext* context, si
|
|||
// context->alloc_ptr = context->alloc_limit = (uint8_t*)region->AllocStart();
|
||||
// continue;
|
||||
//}
|
||||
|
||||
////TODO: VS we should not start allocating if we have no space. This will change when we do free lists.
|
||||
//if (region->IsAllocating())
|
||||
//{
|
||||
// region->StopAllocating(0);
|
||||
//}
|
||||
}
|
||||
|
||||
context->RegularRegion() = nullptr;
|
||||
|
|
|
@ -222,6 +222,17 @@ inline SatoriPage* SatoriHeap::PageForAddress(size_t address)
|
|||
return (SatoriPage *)(mapIndex << Satori::PAGE_BITS);
|
||||
}
|
||||
|
||||
//TODO: VS unused?
|
||||
SatoriRegion* SatoriHeap::RegionForAddress(size_t address)
|
||||
{
|
||||
if (IsHeapAddress(address))
|
||||
{
|
||||
return PageForAddress(address)->RegionForAddress(address);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//TODO: VS optimize this, move to inl
|
||||
SatoriObject* SatoriHeap::ObjectForAddress(size_t address)
|
||||
{
|
||||
|
|
|
@ -353,17 +353,23 @@ SatoriObject* SatoriRegion::FindObject(size_t location)
|
|||
{
|
||||
_ASSERTE(location >= (size_t)FirstObject() && location <= End());
|
||||
|
||||
// TODO: VS use index to start
|
||||
SatoriObject* obj = FirstObject();
|
||||
SatoriObject* next = obj->Next();
|
||||
SatoriObject* obj = &m_firstObject;
|
||||
if (IsAllocating() && location >= m_allocEnd)
|
||||
{
|
||||
obj = (SatoriObject*)m_allocEnd;
|
||||
}
|
||||
|
||||
while (next->Start() < location)
|
||||
// TODO: VS adjust obj using index and update index on the go
|
||||
SatoriObject* next = obj->Next();
|
||||
while (next->Start() <= location)
|
||||
{
|
||||
obj = next;
|
||||
next = next->Next();
|
||||
}
|
||||
|
||||
return obj->IsFree() ? nullptr : obj;
|
||||
_ASSERTE(!obj->IsFree());
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
void SatoriRegion::MarkFn(PTR_PTR_Object ppObject, ScanContext* sc, uint32_t flags)
|
||||
|
@ -583,7 +589,7 @@ void SatoriRegion::ThreadLocalMark()
|
|||
}
|
||||
}
|
||||
|
||||
Verify();
|
||||
Verify(/*allowMarked*/ true);
|
||||
}
|
||||
|
||||
size_t SatoriRegion::ThreadLocalPlan()
|
||||
|
@ -1124,7 +1130,7 @@ void SatoriRegion::CleanMarks()
|
|||
ZeroMemory(&m_bitmap[BITMAP_START], (BITMAP_SIZE - BITMAP_START) * sizeof(size_t));
|
||||
}
|
||||
|
||||
void SatoriRegion::Verify()
|
||||
void SatoriRegion::Verify(bool allowMarked)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
for (size_t i = m_used; i < m_committed; i++)
|
||||
|
@ -1146,7 +1152,7 @@ void SatoriRegion::Verify()
|
|||
}
|
||||
else
|
||||
{
|
||||
_ASSERTE(!obj->IsMarked());
|
||||
_ASSERTE(allowMarked || !obj->IsMarked());
|
||||
}
|
||||
|
||||
prevPrevObj = prevObj;
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
|
||||
void CleanMarks();
|
||||
|
||||
void Verify();
|
||||
void Verify(bool allowMarked = false);
|
||||
|
||||
private:
|
||||
static const int BITMAP_SIZE = Satori::REGION_SIZE_GRANULARITY / sizeof(size_t) / sizeof(size_t) / 8;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include "../gc/satori/SatoriObject.inl"
|
||||
#include "../gc/satori/SatoriRegion.inl"
|
||||
#include "../gc/satori/SatoriPage.h"
|
||||
|
||||
//========================================================================
|
||||
//
|
||||
|
@ -1271,9 +1272,21 @@ bool IsInHeapSatori(void* ptr)
|
|||
return false;
|
||||
}
|
||||
|
||||
uint8_t* pages = (uint8_t*)g_card_table;
|
||||
uint8_t* pageMap = (uint8_t*)g_card_table;
|
||||
size_t page = (size_t)ptr >> PAGE_BITS;
|
||||
return pages[page];
|
||||
return pageMap[page];
|
||||
}
|
||||
|
||||
SatoriPage* PageForAddressSatori(void* address)
|
||||
{
|
||||
size_t mapIndex = (size_t)address >> PAGE_BITS;
|
||||
uint8_t* pageMap = (uint8_t*)g_card_table;
|
||||
while (pageMap[mapIndex] > 1)
|
||||
{
|
||||
mapIndex -= ((size_t)1 << (pageMap[mapIndex] - 2));
|
||||
}
|
||||
|
||||
return (SatoriPage*)(mapIndex << PAGE_BITS);
|
||||
}
|
||||
|
||||
void CheckAndMarkEscapeSatori(Object** dst, Object* ref)
|
||||
|
@ -1299,33 +1312,29 @@ void CheckAndMarkEscapeSatori(Object** dst, Object* ref)
|
|||
void CheckAndMarkEscapeSatoriRange(void* dst, void* src, size_t len)
|
||||
{
|
||||
#if FEATURE_SATORI_GC
|
||||
////TODO: VS "same region" check may go to the outer helper, before IsInHeap check.
|
||||
//if (((size_t)dst ^ (size_t)src) >> 21)
|
||||
//{
|
||||
// //TODO: VS this is dangerous when gap is in front.
|
||||
// SatoriObject* srcObj = (SatoriObject*)GCHeapUtilities::GetGCHeap()->GetContainingObject(src, false);
|
||||
// if (srcObj)
|
||||
// {
|
||||
// SatoriRegion* srcRegion = srcObj->ContainingRegion();
|
||||
// if (srcRegion->OwnedByCurrentThread())
|
||||
// {
|
||||
// //TODO: VS escape only from ref to len
|
||||
// srcObj->ForEachObjectRef(
|
||||
// [&](SatoriObject** ref)
|
||||
// {
|
||||
// SatoriObject* child = *ref;
|
||||
// if (srcRegion == child->ContainingRegion() && !child->IsEscaped())
|
||||
// {
|
||||
// // we are escaping an object from our thread local region
|
||||
// // we can mark the object escape with an ordinary assignment,
|
||||
// // noone else should be marking this region.
|
||||
// child->SetEscaped();
|
||||
// }
|
||||
// }
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
if ((((size_t)dst ^ (size_t)src) >> 21) && IsInHeapSatori(src))
|
||||
{
|
||||
SatoriRegion* srcRegion = PageForAddressSatori(src)->RegionForAddress((size_t)src);
|
||||
if (srcRegion->OwnedByCurrentThread())
|
||||
{
|
||||
SatoriObject* containingSrcObj = srcRegion->FindObject((size_t)src);
|
||||
|
||||
// TODO: VS start iterating from src
|
||||
containingSrcObj->ForEachObjectRef(
|
||||
[&](SatoriObject** ref)
|
||||
{
|
||||
SatoriObject* child = *ref;
|
||||
if (srcRegion == child->ContainingRegion() && !child->IsEscaped())
|
||||
{
|
||||
// we are escaping an object from our thread local region
|
||||
// we can mark the object escape with an ordinary assignment,
|
||||
// noone else should be marking this region.
|
||||
child->SetEscaped();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue