Remove hlsf, TLSF.alloc is ok

This commit is contained in:
Youmu Liu
2026-05-11 18:08:35 +08:00
parent 5706c89563
commit b59d414e20
21 changed files with 267 additions and 1514 deletions
@@ -35,7 +35,7 @@ using System.Runtime.Intrinsics.X86;
using System.Text;
using System.Threading.Tasks;
using HlsfEntry = StgSharp.HighPerformance.Memory.HybridLayerSegregatedFitAllocator.Entry;
using Tlsf = StgSharp.HighPerformance.Memory.TwoLayerSegregatedFitAllocator;
namespace StgSharp.HighPerformance.Memory
{
@@ -87,8 +87,11 @@ namespace StgSharp.HighPerformance.Memory
int id
)
{
HlsfEntry* entry = (HlsfEntry*)(_entryManager._basePtr + id);
throw new NotImplementedException();
/*
Tlsf* entry = (Tlsf*)(_entryManager._basePtr + id);
_bufferAllocator.Free(entry);
/**/
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -105,7 +108,7 @@ namespace StgSharp.HighPerformance.Memory
int id = head->Predictor;
IL4Predict predict = predictorSpan[id] ??
throw new L4PredictUnregisteredException(id);
predict.WriteBack(head->Origin, head->Profile, new ReadOnlySpan<byte>((byte*)head->Address, (int)head->Size));
predict.WriteBack(head->Origin, head->Profile, new ReadOnlySpan<byte>((byte*)(ulong)head->Address, (int)(ulong)head->Size));
RecycleLine(index);
(*_mapCount)[index] = 0;
(*_predictCount)[index] = int.MaxValue;
@@ -121,12 +124,14 @@ namespace StgSharp.HighPerformance.Memory
)
{
if (!_bufferAllocator.TryAlloc(size, out HlsfHandle handle))
if (!_bufferAllocator.TryAlloc(size, out Tlsf.Handle handle))
{
index = 0;
return false;
}
CacheLineHead* entry = (CacheLineHead*)handle.EntryHandle;
// origin :CacheLineHead* entry = (CacheLineHead*)handle.EntryHandle;
CacheLineHead* entry = (CacheLineHead*)handle.Pointer;
index = entry->Id;
return true;
}