mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-08 03:27:04 +09:00
do not reindex free objects if already exist
This commit is contained in:
parent
f7db0570eb
commit
0a66e3fe05
4 changed files with 33 additions and 2 deletions
|
@ -87,6 +87,25 @@ SatoriObject* SatoriObject::FormatAsFree(size_t location, size_t size)
|
|||
return o;
|
||||
}
|
||||
|
||||
SatoriObject* SatoriObject::GetFreeIfExists(size_t location, size_t size)
|
||||
{
|
||||
_ASSERTE(location == ALIGN_UP(location, Satori::OBJECT_ALIGNMENT));
|
||||
_ASSERTE(size == ALIGN_UP(size, Satori::OBJECT_ALIGNMENT));
|
||||
_ASSERTE(size >= Satori::MIN_FREE_SIZE);
|
||||
_ASSERTE(size < Satori::REGION_SIZE_GRANULARITY);
|
||||
|
||||
SatoriObject* o = (SatoriObject*)location;
|
||||
_ASSERTE(o->ContainingRegion()->m_used > (location + 2 * sizeof(size_t)));
|
||||
|
||||
// if matching values that FormatAsFree sets, then the obj is already there.
|
||||
if (o->RawGetMethodTable() != s_emptyObjectMt || ((size_t*)o)[1] != size - Satori::MIN_FREE_SIZE)
|
||||
return nullptr;
|
||||
|
||||
_ASSERTE(o->IsSyncBlockClean());
|
||||
_ASSERTE(!o->IsMarked());
|
||||
return o;
|
||||
}
|
||||
|
||||
void SatoriObject::DirtyCardsForContent()
|
||||
{
|
||||
_ASSERTE(IsMarked());
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
SatoriObject() = delete;
|
||||
~SatoriObject() = delete;
|
||||
|
||||
static SatoriObject* GetFreeIfExists(size_t location, size_t size);
|
||||
static SatoriObject* FormatAsFree(size_t location, size_t size);
|
||||
|
||||
SatoriRegion* ContainingRegion();
|
||||
|
@ -94,6 +95,7 @@ public:
|
|||
void SetLocalReloc(int32_t);
|
||||
|
||||
void CleanSyncBlock();
|
||||
bool IsSyncBlockClean();
|
||||
|
||||
void Validate();
|
||||
|
||||
|
|
|
@ -232,6 +232,11 @@ inline void SatoriObject::CleanSyncBlock()
|
|||
*((size_t*)this - 1) = 0;
|
||||
}
|
||||
|
||||
inline bool SatoriObject::IsSyncBlockClean()
|
||||
{
|
||||
return *((size_t*)this - 1) == 0;
|
||||
}
|
||||
|
||||
inline int SatoriObject::GetMarkBitAndWord(size_t* bitmapIndex)
|
||||
{
|
||||
size_t start = Start();
|
||||
|
|
|
@ -291,8 +291,13 @@ bool SatoriRegion::Sweep()
|
|||
o = SkipUnmarkedAndClear(o);
|
||||
SatoriUtil::Prefetch(o);
|
||||
size_t skipped = o->Start() - lastMarkedEnd;
|
||||
SatoriObject* free = SatoriObject::FormatAsFree(lastMarkedEnd, skipped);
|
||||
SetIndicesForObject(free, o->Start());
|
||||
SatoriObject* free = nullptr; //SatoriObject::GetFreeIfExists(lastMarkedEnd, skipped);
|
||||
if (!free)
|
||||
{
|
||||
free = SatoriObject::FormatAsFree(lastMarkedEnd, skipped);
|
||||
SetIndicesForObject(free, o->Start());
|
||||
}
|
||||
|
||||
AddFreeSpace(free, skipped);
|
||||
|
||||
if (o->Start() >= objLimit)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue