feat(memory): PlatformStorage — common door to platform storage kinds; Kotlin/Native malloc/mmap; JS/Wasm heap fallback (SKEEP-003 P2, S1.1c) - #1064
Merged
Conversation
…ge kinds; Kotlin/Native malloc/mmap bindings; JS/Wasm heap fallback (SKEEP-003 P2) Milestone M1 (#1002). SKEEP-003 §4.8: where bytes live is a policy decision; each target binds the kinds to what it has. - commonMain expect object PlatformStorage: supports(domain), supportsMappedFiles, allocate(bytes, domain, scope, origin, sink), mapFile(path, offset, length, scope, origin, sink); PlatformStorageInfo. - jvmMain actual: HOST_OFFHEAP → SegmentStorage, HOST_HEAP → Heap, mapFile → MappedFileStorage. androidMain actual: DirectBufferStorage / MappedBufferStorage. nativeMain actual: NativeMallocStorage (malloc + memset, free on close; borrow(pointer) never freed) and NativeMappedStorage (mmap PROT_READ/MAP_PRIVATE with page-aligned offset handling, munmap on close). jsMain / wasmJsMain / wasmWasiMain actuals: linear memory only — off-heap requests resolve to the heap (supports() says so for the planner), mapFile throws UnsupportedOperationException. - PlatformStorageTest (commonTest, every target: heap everywhere, off-heap or fallback, non-allocatable domains, mapped-file capability); PlatformStorageJvmTest. BCV: lang-core jvm dump regenerated. Closes #1020 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
Local gate Targeted: JVM 49/49 and linuxX64 40/40 |
Base automatically changed from
feature/1019-storage-jvm-offheap-mapped
to
develop
August 23, 2026 12:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SKEEP-003 slice S1.1c (milestone M1 #1002):
PlatformStorage— the one common door to the platform's storage kinds (§4.8: where bytes live is a policy decision; how long they live is a scope decision; neither is made by a layer, a loader or a kernel), plus the Kotlin/Native and JS/Wasm bindings.commonMainexpect object PlatformStorage:supports(domain),supportsMappedFiles,allocate(bytes, domain, scope, origin, sink),mapFile(path, offset, length, scope, origin, sink);PlatformStorageInfofordescribe()/planner notes.SegmentStorage/MappedFileStorage; Android →DirectBufferStorage/MappedBufferStorage; Kotlin/Native → newNativeMallocStorage(malloc+memset,freeon close;borrow(pointer)never freed; rawpointer()is what a C kernel receives) andNativeMappedStorage(mmapPROT_READ/MAP_PRIVATEwith page-aligned offsets,munmapon close); JS / Wasm → linear memory only: off-heap requests resolve to the heap andsupports()says so (the planner records the fallback),mapFilethrowsUnsupportedOperationException(weights arrive via thesuspendsource into heap slabs, [S2.4] P5: IO as a pipeline —quantPolicy×staging = MAPPED|HEAPin one loader;suspendRandomAccessSource in io-core #1037).PlatformStorageTest(commonTest — runs on every target: heap everywhere, off-heap or documented fallback, non-allocatable domains, mapped-file capability) andPlatformStorageJvmTest. Compiles for linuxX64, JVM, JS, wasmJs, wasmWasi; JVM 49/49 and linuxX64 40/40 memory tests.Stacked on #1063 (#1019); retarget to
developas the chain merges. Apple/iOS and androidNative are covered by the samenativeMaincode (POSIX) but only linuxX64 runs in CI.Test plan
Full local gate (
scripts/pr-gate.sh, JDK 25); results in the first comment.Closes #1020
🤖 Generated with Claude Code