Closed Bug 1804310 Opened 1 year ago Closed 1 year ago

Implement memory.discard instruction

Categories

(Core :: JavaScript: WebAssembly, task, P3)

task

Tracking

()

RESOLVED FIXED
112 Branch
Tracking Status
firefox112 --- fixed

People

(Reporter: rhunt, Assigned: bvisness)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Implement the memory.discard [1] in Ion/Baseline. Both of them will likely just perform a call to a builtin to do the real work.

The semantics of this instruction are not firmly pinned down yet, we can make something up or coordinate with V8 to see if they've chosen something yet. A reasonable start would be memory.discard $memIndex : [i32:offset, i32:length] -> [].

The idea for the instruction is roughly a semantic zero'ing of some range of memory, with the hint provided to the OS that this memory is not likely needed anytime soon. The OS would likely free the backing pages then, and provide a fresh zero-page back on-demand if the memory is touched in the future.

For Linux (OSX too?), this would be done with madvise(MADV_DONTNEED)
For Windows, this might be VirtualFree(MEM_DECOMMIT);VirtualAlloc(MEM_COMMIT). We'll need to double check the atomicity of that for threading.

[1] https://github.com/WebAssembly/memory-control/blob/main/proposals/memory-control/Overview.md#proposed-changes

memory.discard stuff from windows

Rearrange discard code (and scaffold for M64)

Get the JS API working, bounds checks and all

Visual cleanup

Assignee: nobody → ben
Status: NEW → ASSIGNED

Depends on D167324

Blocks: 1814924
Pushed by rhunt@eqrion.net:
https://hg.mozilla.org/integration/autoland/rev/73c05bcb4c1f
Implement memory.discard wasm instruction. r=rhunt,supply-chain-reviewers
https://hg.mozilla.org/integration/autoland/rev/893e8d9462ad
Add wasm memory control pref. r=rhunt
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch
Regressions: 1816882
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: