Skip to content

feat: implement full WASM memory mapping simulation#39

Open
tmc wants to merge 2 commits intoedsrzf:mainfrom
tmc:main
Open

feat: implement full WASM memory mapping simulation#39
tmc wants to merge 2 commits intoedsrzf:mainfrom
tmc:main

Conversation

@tmc
Copy link

@tmc tmc commented Jun 9, 2025

Replace stub implementation with complete memory mapping simulation for WASM environments. The new implementation:

  • Supports both anonymous and file-backed mappings
  • Handles read-only and read-write modes
  • Implements proper flush and unmap operations
  • Maintains mapping state with synchronization

This can be tested with:

export PATH="$$PATH:$$(go env GOROOT)/lib/wasm" && \
	GOOS=js GOARCH=wasm go test -v

and

export PATH="$$PATH:$$(go env GOROOT)/lib/wasm" && \
	GOOS=wasip1 GOARCH=wasm go test -v

tmc added 2 commits June 8, 2025 18:33
Replace stub implementation with complete memory mapping simulation for WASM environments. The new implementation:
- Supports both anonymous and file-backed mappings
- Handles read-only and read-write modes
- Implements proper flush and unmap operations
- Maintains mapping state with synchronization
Remove automatic file closing during unmap to match native mmap behavior
where the caller is responsible for closing file descriptors separately
from unmapping memory.
@edsrzf
Copy link
Owner

edsrzf commented Jun 11, 2025

I'm not sure whether I want to add this kind of emulation. Can you explain more about your use case?

Also, if we do decide to do this, maybe it'd make sense to add it as a general fallback rather than specifically for WASM. (I think it'd only apply to Plan 9 at the moment.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants