L4 briefly pass unit test

This commit is contained in:
Youmu Liu
2026-03-17 20:31:06 +08:00
parent 98d711a3ca
commit dccb815811
13 changed files with 1710 additions and 32 deletions
+16 -6
View File
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="L4"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -77,7 +77,7 @@ namespace StgSharp.HighPerformance.Memory
ptr += entrySize;
_prediction = (CacheLinePrediction*)ptr;
ptr += predictionSize;
_map = SwissTable.Create(_baseAddress + cacheSize + entrySize, _ => { });
_map = SwissTable.Create(ptr, _ => { });
ptr += mapSize;
_eviction = (EvictionArray*)ptr;
ptr += rrpvSize;
@@ -108,7 +108,9 @@ namespace StgSharp.HighPerformance.Memory
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public CacheLine Map(nuint origin)
public CacheLine Map(
nuint origin
)
{
if (_aheadCount < PredictionLeastAhead)
{
@@ -151,7 +153,9 @@ namespace StgSharp.HighPerformance.Memory
private partial void Prefetch();
private partial bool TestHit(nuint origin);
private partial bool TestHit(
nuint origin
);
public ref struct CacheLine : IDisposable
{
@@ -160,7 +164,11 @@ namespace StgSharp.HighPerformance.Memory
private ref int _refCount;
private nuint _handle;
internal CacheLine(nuint handle, ref int activeCount, ref int cacheRefCount)
internal CacheLine(
nuint handle,
ref int activeCount,
ref int cacheRefCount
)
{
_handle = handle;
_refCount = ref cacheRefCount;
@@ -170,6 +178,8 @@ namespace StgSharp.HighPerformance.Memory
[Obsolete("You should not create a CacheLineHandle outside a L4", true)]
public CacheLine() { }
public nuint Address => _handle;
public void Dispose()
{
if (_handle == 0) {