Closed Bug 1778077 Opened 2 years ago Closed 2 years ago

Use calloc for non-Wasm SharedArrayRawBuffer

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
104 Branch
Tracking Status
firefox104 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

Attachments

(4 files)

Bug 1777231 reports our mapped-buffer-limit causing problems when using SharedArrayBuffer in JS.

A lot of the fields in SharedArrayRawBuffer are Wasm-specific. The plan is to add a WasmSharedArrayRawBuffer that contains the Wasm-specific bits. We can then also use calloc for the non-Wasm buffers, similar to what we already do for non-shared array buffers.

This is faster and will use less memory when allocating (many) SABs from JS.

This forks the non-Wasm and Wasm code paths, which will make it easier to simplify
the non-Wasm code in a later patch.

This ensures the buffer can still be used in dropRawBuffer before dropping the reference.

Depends on D151008

The Wasm-specific fields are moved from SharedArrayRawBuffer into a new derived class,
WasmSharedArrayRawBuffer. This is similar to how non-shared buffers use WasmArrayRawBuffer.

The non-Wasm allocation code now uses calloc instead of mmap. This is also more like
how non-shared buffers work.

These changes make the non-Wasm SABs a lot more lightweight. This will help fix bug 1777231
and similar issues.

Depends on D151009

Blocks: 1689948

This fixes a pre-existing issue: Mutex has a destructor so we should call it.

Depends on D151010

Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/32fcf7ae995e
part 1 - Inline SharedArrayRawBuffer::AllocateInternal into the two callers. r=sfink
https://hg.mozilla.org/integration/autoland/rev/3cc226c5c2a7
part 2 - Move dropReference call into dropRawBuffer. r=sfink
https://hg.mozilla.org/integration/autoland/rev/401aac8b1523
part 3 - Optimize non-Wasm SharedArrayBuffers. r=sfink
https://hg.mozilla.org/integration/autoland/rev/ac06b42c5b02
part 4 - Call WasmSharedArrayRawBuffer's destructor to ensure the mutex is destroyed. r=sfink
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: