XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESystem

【Rust】XFE系统,基于Rust和汇编

公开
关注 0 Fork 0 Star 0
UTF-8
using System.Runtime.InteropServices;

namespace XFESystem.Kernel;

/// <summary>Allocation-free raw page counts, independent of the managed GC's freed-object count.</summary>
internal static class NativeRuntimeMemoryDiagnostics
{
    // "*" declares direct NativeAOT linkage to the matching project-owned UCO exports.
    // Tools/GcRuntimePatch emits these into the pinned Cosmos runtime before ILC runs.
    [DllImport("*", EntryPoint = "XfeRuntimeRawFreePageCount")]
    [SuppressGCTransition]
    internal static extern ulong FreePages();
    [DllImport("*", EntryPoint = "XfeRuntimeRawTotalPageCount")]
    [SuppressGCTransition]
    internal static extern ulong TotalPages();
    [DllImport("*", EntryPoint = "XfeRuntimeRawLargestFreeRunPages")]
    [SuppressGCTransition]
    internal static extern ulong LargestFreeRunPages();

    // Completed-GC snapshots, rather than concurrent walks over mutable segments.
    [DllImport("*", EntryPoint = "XfeRuntimeLastGcHeapSpanBytes")]
    [SuppressGCTransition]
    internal static extern ulong LastGcHeapSpanBytes();
    [DllImport("*", EntryPoint = "XfeRuntimeLastGcFragmentedBytes")]
    [SuppressGCTransition]
    internal static extern ulong LastGcFragmentedBytes();
    [DllImport("*", EntryPoint = "XfeRuntimeLastGcCommittedBytes")]
    [SuppressGCTransition]
    internal static extern ulong LastGcCommittedBytes();
    [DllImport("*", EntryPoint = "XfeRuntimeLastGcCollectionIndex")]
    [SuppressGCTransition]
    internal static extern ulong LastGcCollectionIndex();

    [DllImport("*", EntryPoint = "XfeRuntimeDependentHandleCount")]
    [SuppressGCTransition]
    internal static extern ulong DependentHandleCount();

    [DllImport("*", EntryPoint = "XfeRuntimeValidateFrozenRange")]
    [SuppressGCTransition]
    internal static extern int ValidateFrozenRange(ulong start, ulong reservedSize, ulong allocatedEnd, ulong committedEnd);
    [DllImport("*", EntryPoint = "XfeRuntimeRegisteredFrozenRangesValid")]
    [SuppressGCTransition]
    internal static extern int RegisteredFrozenRangesValid();
}