MiniQuake

src/miniquake/memory.ml

Package
miniquake.memory
Reachable
Yes

Imports

Declarations

align16

inline function align16(value)

Implements the `align16` operation for `miniquake.memory` (align16).

ParameterTypeDefaultDescription
valuedynamic—Value consumed by `align16`.

View source

allocate

function allocate(state, size, name, kind)

Implements the `allocate` operation for `miniquake.memory` (allocate).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `allocate`.
sizedynamic—Size of the requested data or resource.
namedynamic—Stable name that identifies the requested object or option.
kinddynamic—The kind input consumed by `allocate`.

View source

Cache_Alloc

function Cache_Alloc(state, user, size, name)

Mirror Quake's Cache_Alloc routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Cache_Alloc`.
userdynamic—The user input consumed by `Cache_Alloc`.
sizedynamic—Size of the requested data or resource.
namedynamic—Stable name that identifies the requested object or option.

View source

Cache_Check

function Cache_Check(state, user)

Implements the `Cache_Check` operation for `miniquake.memory` (cache check).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Cache_Check`.
userdynamic—The user input consumed by `Cache_Check`.

View source

Cache_Compact

function Cache_Compact(state)

Mirror Quake's Cache_Compact routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Cache_Compact`.

View source

Cache_Flush

function Cache_Flush(state)

Mirror Quake's Cache_Flush routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Cache_Flush`.

View source

Cache_Free

function Cache_Free(user)

Mirror Quake's Cache_Free routine and its observable state changes.

ParameterTypeDefaultDescription
userdynamic—The user input consumed by `Cache_Free`.

View source

Cache_FreeHigh

function Cache_FreeHigh(state, newHighHunk)

Mirror Quake's Cache_FreeHigh routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Cache_FreeHigh`.
newHighHunkdynamic—The new high hunk input consumed by `Cache_FreeHigh`.

View source

Cache_FreeLow

function Cache_FreeLow(state, newLowHunk)

Mirror Quake's Cache_FreeLow routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Cache_FreeLow`.
newLowHunkdynamic—The new low hunk input consumed by `Cache_FreeLow`.

View source

CACHE_HEADER_SIZE

const CACHE_HEADER_SIZE = 40

Defines the cache header size value used by `miniquake.memory`.

View source

Cache_Init

function Cache_Init(state)

Mirror Quake's Cache_Init routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Cache_Init`.

View source

Cache_MakeLRU

function Cache_MakeLRU(block)

Mirror Quake's Cache_MakeLRU routine and its observable state changes.

ParameterTypeDefaultDescription
blockdynamic—The block input consumed by `Cache_MakeLRU`.

View source

Cache_Move

function Cache_Move(block)

Mirror Quake's Cache_Move routine and its observable state changes.

ParameterTypeDefaultDescription
blockdynamic—The block input consumed by `Cache_Move`.

View source

Cache_Print

function Cache_Print(state)

Mirror Quake's Cache_Print routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Cache_Print`.

View source

Cache_Report

function Cache_Report(state)

Mirror Quake's Cache_Report routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Cache_Report`.

View source

Cache_TryAlloc

function Cache_TryAlloc(state, size, noBottom)

Mirror Quake's Cache_TryAlloc routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Cache_TryAlloc`.
sizedynamic—Size of the requested data or resource.
noBottomdynamic—The no bottom input consumed by `Cache_TryAlloc`.

View source

Cache_UnlinkLRU

function Cache_UnlinkLRU(block)

Mirror Quake's Cache_UnlinkLRU routine and its observable state changes.

ParameterTypeDefaultDescription
blockdynamic—The block input consumed by `Cache_UnlinkLRU`.

View source

cacheAlloc

function cacheAlloc(state, size, name)

Implements the `cacheAlloc` operation for `miniquake.memory` (cache alloc).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cacheAlloc`.
sizedynamic—Size of the requested data or resource.
namedynamic—Stable name that identifies the requested object or option.

View source

cacheAllocUser

function cacheAllocUser(state, user, size, name)

Implements the `cacheAllocUser` operation for `miniquake.memory` (cache alloc user).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cacheAllocUser`.
userdynamic—The user input consumed by `cacheAllocUser`.
sizedynamic—Size of the requested data or resource.
namedynamic—Stable name that identifies the requested object or option.

View source

miniquake.memory.CacheBlock struct

cacheCheck

function cacheCheck(state, user)

Implements the `cacheCheck` operation for `miniquake.memory` (cache check).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cacheCheck`.
userdynamic—The user input consumed by `cacheCheck`.

View source

cacheCompact

function cacheCompact(state)

Implements the `cacheCompact` operation for `miniquake.memory` (cache compact).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cacheCompact`.

View source

cacheFlush

function cacheFlush(state)

Implements the `cacheFlush` operation for `miniquake.memory` (cache flush).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cacheFlush`.

View source

cacheFree

function cacheFree(user)

Implements the `cacheFree` operation for `miniquake.memory` (cache free).

ParameterTypeDefaultDescription
userdynamic—The user input consumed by `cacheFree`.

View source

cacheFreeHigh

function cacheFreeHigh(state, newHighHunk)

Implements the `cacheFreeHigh` operation for `miniquake.memory` (cache free high).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cacheFreeHigh`.
newHighHunkdynamic—The new high hunk input consumed by `cacheFreeHigh`.

View source

cacheFreeLow

function cacheFreeLow(state, newLowHunk)

Implements the `cacheFreeLow` operation for `miniquake.memory` (cache free low).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cacheFreeLow`.
newLowHunkdynamic—The new low hunk input consumed by `cacheFreeLow`.

View source

cacheInit

function cacheInit(state)

Update subsystem state for cache init.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cacheInit`.

View source

cacheMove

function cacheMove(block)

Implements the `cacheMove` operation for `miniquake.memory` (cache move).

ParameterTypeDefaultDescription
blockdynamic—The block input consumed by `cacheMove`.

View source

cachePayloadUsed

function cachePayloadUsed(state)

Implements the `cachePayloadUsed` operation for `miniquake.memory` (cache payload used).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cachePayloadUsed`.

View source

cachePrint

function cachePrint(state)

Implements the `cachePrint` operation for `miniquake.memory` (cache print).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cachePrint`.

View source

cacheReport

function cacheReport(state)

Implements the `cacheReport` operation for `miniquake.memory` (cache report).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cacheReport`.

View source

cacheStartIndex

function cacheStartIndex(state, block)

Return cache start index derived from the active module state.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cacheStartIndex`.
blockdynamic—The block input consumed by `cacheStartIndex`.

View source

cacheTryAlloc

function cacheTryAlloc(state, span, noBottom)

Implements the `cacheTryAlloc` operation for `miniquake.memory` (cache try alloc).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cacheTryAlloc`.
spandynamic—The span input consumed by `cacheTryAlloc`.
noBottomdynamic—The no bottom input consumed by `cacheTryAlloc`.

View source

cacheTryAllocBlock

function cacheTryAllocBlock(state, span, noBottom)

Cache_TryAlloc itself creates and links a cache header. Cache_Alloc uses the lower-level position search because it must fill the user/name/payload fields atomically before exposing the new block.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `cacheTryAllocBlock`.
spandynamic—The span input consumed by `cacheTryAllocBlock`.
noBottomdynamic—The no bottom input consumed by `cacheTryAllocBlock`.

View source

miniquake.memory.CacheUser struct

create

function create(capacity)

Implements the `create` operation for `miniquake.memory` (create).

ParameterTypeDefaultDescription
capacitydynamic—Maximum number of entries the destination can hold.

View source

freeHunkBytes

inline function freeHunkBytes(state)

Release state for free hunk bytes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `freeHunkBytes`.

View source

freeToHighMark

function freeToHighMark(state, mark)

Release state for free to high mark.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `freeToHighMark`.
markdynamic—The mark input consumed by `freeToHighMark`.

View source

freeToLowMark

function freeToLowMark(state, mark)

Release state for free to low mark.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `freeToLowMark`.
markdynamic—The mark input consumed by `freeToLowMark`.

View source

highMark

function highMark(state)

Implements the `highMark` operation for `miniquake.memory` (high mark).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `highMark`.

View source

Hunk_Alloc

function Hunk_Alloc(state, size)

Mirror Quake's Hunk_Alloc routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Hunk_Alloc`.
sizedynamic—Size of the requested data or resource.

View source

Hunk_AllocName

function Hunk_AllocName(state, size, name)

Mirror Quake's Hunk_AllocName routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Hunk_AllocName`.
sizedynamic—Size of the requested data or resource.
namedynamic—Stable name that identifies the requested object or option.

View source

Hunk_Check

function Hunk_Check(state)

Explicit zone.c entry points. MemoryManager replaces the original global hunk/cache variables, while marks remain byte offsets as in MiniQuake.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Hunk_Check`.

View source

Hunk_FreeToHighMark

function Hunk_FreeToHighMark(state, mark)

Mirror Quake's Hunk_FreeToHighMark routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Hunk_FreeToHighMark`.
markdynamic—The mark input consumed by `Hunk_FreeToHighMark`.

View source

Hunk_FreeToLowMark

function Hunk_FreeToLowMark(state, mark)

Mirror Quake's Hunk_FreeToLowMark routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Hunk_FreeToLowMark`.
markdynamic—The mark input consumed by `Hunk_FreeToLowMark`.

View source

HUNK_HEADER_SIZE

const HUNK_HEADER_SIZE = 16

Defines the hunk header size value used by `miniquake.memory`.

View source

Hunk_HighAllocName

function Hunk_HighAllocName(state, size, name)

Mirror Quake's Hunk_HighAllocName routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Hunk_HighAllocName`.
sizedynamic—Size of the requested data or resource.
namedynamic—Stable name that identifies the requested object or option.

View source

Hunk_HighMark

function Hunk_HighMark(state)

Mirror Quake's Hunk_HighMark routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Hunk_HighMark`.

View source

Hunk_LowMark

function Hunk_LowMark(state)

Mirror Quake's Hunk_LowMark routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Hunk_LowMark`.

View source

Hunk_Print

function Hunk_Print(state, all)

Mirror Quake's Hunk_Print routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Hunk_Print`.
alldynamic—The all input consumed by `Hunk_Print`.

View source

HUNK_SENTINEL

const HUNK_SENTINEL = 502268397

Defines the hunk sentinel value used by `miniquake.memory`.

View source

Hunk_TempAlloc

function Hunk_TempAlloc(state, size)

Mirror Quake's Hunk_TempAlloc routine and its observable state changes.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `Hunk_TempAlloc`.
sizedynamic—Size of the requested data or resource.

View source

hunkAlloc

function hunkAlloc(state, size)

Implements the `hunkAlloc` operation for `miniquake.memory` (hunk alloc).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `hunkAlloc`.
sizedynamic—Size of the requested data or resource.

View source

hunkAllocName

function hunkAllocName(state, size, name)

Return hunk alloc name derived from the active module state.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `hunkAllocName`.
sizedynamic—Size of the requested data or resource.
namedynamic—Stable name that identifies the requested object or option.

View source

miniquake.memory.HunkBlock struct

hunkCheck

function hunkCheck(state)

Implements the `hunkCheck` operation for `miniquake.memory` (hunk check).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `hunkCheck`.

View source

hunkHighAllocName

function hunkHighAllocName(state, size, name)

Return hunk high alloc name derived from the active module state.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `hunkHighAllocName`.
sizedynamic—Size of the requested data or resource.
namedynamic—Stable name that identifies the requested object or option.

View source

hunkPayloadUsed

function hunkPayloadUsed(state)

Implements the `hunkPayloadUsed` operation for `miniquake.memory` (hunk payload used).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `hunkPayloadUsed`.

View source

hunkPrint

function hunkPrint(state, all)

Implements the `hunkPrint` operation for `miniquake.memory` (hunk print).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `hunkPrint`.
alldynamic—The all input consumed by `hunkPrint`.

View source

hunkTempAlloc

function hunkTempAlloc(state, size, name)

Implements the `hunkTempAlloc` operation for `miniquake.memory` (hunk temp alloc).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `hunkTempAlloc`.
sizedynamic—Size of the requested data or resource.
namedynamic—Stable name that identifies the requested object or option.

View source

insertCacheSorted

function insertCacheSorted(state, block)

Add state for insert cache sorted.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `insertCacheSorted`.
blockdynamic—The block input consumed by `insertCacheSorted`.

View source

leastRecentlyUsed

function leastRecentlyUsed(state)

Implements the `leastRecentlyUsed` operation for `miniquake.memory` (least recently used).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `leastRecentlyUsed`.

View source

lowMark

function lowMark(state)

Implements the `lowMark` operation for `miniquake.memory` (low mark).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `lowMark`.

View source

makeLru

function makeLru(block)

Create and initialize lru.

ParameterTypeDefaultDescription
blockdynamic—The block input consumed by `makeLru`.

View source

Memory_Init

function Memory_Init(capacity, zoneSize)

Mirror Quake's Memory_Init routine and its observable state changes.

ParameterTypeDefaultDescription
capacitydynamic—Maximum number of entries the destination can hold.
zoneSizedynamic—Size of the requested data or resource.

View source

memoryInit

function memoryInit(capacity, zoneSize)

Update subsystem state for memory init.

ParameterTypeDefaultDescription
capacitydynamic—Maximum number of entries the destination can hold.
zoneSizedynamic—Size of the requested data or resource.

View source

memoryInitArguments

function memoryInitArguments(capacity, commandLine)

Implements the `memoryInitArguments` operation for `miniquake.memory` (memory init arguments).

ParameterTypeDefaultDescription
capacitydynamic—Maximum number of entries the destination can hold.
commandLinedynamic—The command line input consumed by `memoryInitArguments`.

View source

miniquake.memory.MemoryManager struct

newCacheUser

function newCacheUser(state)

Create and initialize cache user.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `newCacheUser`.

View source

newHunkBlock

function newHunkBlock(state, requestedSize, name, kind, side, start, span)

Create and initialize hunk block.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `newHunkBlock`.
requestedSizedynamic—Size of the requested data or resource.
namedynamic—Stable name that identifies the requested object or option.
kinddynamic—The kind input consumed by `newHunkBlock`.
sidedynamic—The side input consumed by `newHunkBlock`.
startdynamic—The start input consumed by `newHunkBlock`.
spandynamic—The span input consumed by `newHunkBlock`.

View source

removeCacheAt

function removeCacheAt(state, index)

Release state for remove cache at.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `removeCacheAt`.
indexdynamic—Zero-based index of the requested entry.

View source

truncateName

function truncateName(name, count)

Return truncate name derived from the active module state.

ParameterTypeDefaultDescription
namedynamic—Stable name that identifies the requested object or option.
countdynamic—Number of entries or units to process.

View source

unlinkLru

function unlinkLru(block)

Implements the `unlinkLru` operation for `miniquake.memory` (unlink lru).

ParameterTypeDefaultDescription
blockdynamic—The block input consumed by `unlinkLru`.

View source

used

function used(state)

Implements the `used` operation for `miniquake.memory` (used).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `used`.

View source

zoneCheck

function zoneCheck(state)

Implements the `zoneCheck` operation for `miniquake.memory` (zone check).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `zoneCheck`.

View source

zoneDumpHeap

function zoneDumpHeap(state)

Implements the `zoneDumpHeap` operation for `miniquake.memory` (zone dump heap).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `zoneDumpHeap`.

View source

zoneFree

function zoneFree(block)

Implements the `zoneFree` operation for `miniquake.memory` (zone free).

ParameterTypeDefaultDescription
blockdynamic—The block input consumed by `zoneFree`.

View source

zoneFreeMemory

function zoneFreeMemory(state)

Implements the `zoneFreeMemory` operation for `miniquake.memory` (zone free memory).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `zoneFreeMemory`.

View source

zoneMalloc

function zoneMalloc(state, size, name)

Implements the `zoneMalloc` operation for `miniquake.memory` (zone malloc).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `zoneMalloc`.
sizedynamic—Size of the requested data or resource.
namedynamic—Stable name that identifies the requested object or option.

View source

zonePayloadUsed

function zonePayloadUsed(state)

Implements the `zonePayloadUsed` operation for `miniquake.memory` (zone payload used).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `zonePayloadUsed`.

View source

zonePrint

function zonePrint(state)

Implements the `zonePrint` operation for `miniquake.memory` (zone print).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `zonePrint`.

View source

zoneState

function zoneState(state)

Return zone state derived from the active module state.

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `zoneState`.

View source

zoneTagMalloc

function zoneTagMalloc(state, size, tag, name)

Implements the `zoneTagMalloc` operation for `miniquake.memory` (zone tag malloc).

ParameterTypeDefaultDescription
statedynamic—Mutable `miniquake.memory` state used by `zoneTagMalloc`.
sizedynamic—Size of the requested data or resource.
tagdynamic—The tag input consumed by `zoneTagMalloc`.
namedynamic—Stable name that identifies the requested object or option.

View source