Closed Bug 1676441 Opened 4 years ago Closed 3 years ago

Allow Wasm memories to grow past 2GB on 64-bit systems

Categories

(Core :: JavaScript: WebAssembly, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
89 Branch
Tracking Status
firefox89 --- fixed

People

(Reporter: lth, Assigned: lth)

References

Details

Attachments

(4 files, 8 obsolete files)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Various test cases for wasm memories > 2GB, and tweaks and infrastructure to make them pass.

Summary: Test infrastructure and test cases for wasm memories > INT32_MAX → Test infrastructure and test cases and tweaks for wasm memories > INT32_MAX

Depends on D96602

Attachment #9186999 - Attachment description: Bug 1676441 - Going from 65544 to 65536 is hard, WIP → Bug 1676441 - Going from 65534 to 65536 is hard, WIP
Attachment #9186961 - Attachment description: Bug 1676441 - Scaffolding + test WIP → Bug 1676441 - Allow up to 65534 pages + test cases
Priority: P3 → P2
Summary: Test infrastructure and test cases and tweaks for wasm memories > INT32_MAX → Tweaks, test infrastructure and test cases for wasm memories > INT32_MAX

Depends on D98970

The plan for asm.js is to restrict it to 2GB, so that we do not have to vet the semantics + the implementation to handle more. This has been implemented as a check during linking, and iiuc a link failure means we'll just fall back to JS, so asm.js programs will be able to use the larger heaps, but they will be run as JS, not translated to wasm.

Make the bounds check limit field platform-dependent and tidy up some
naming.

Make sure asm.js tests are run with explicit bounds checking also on
64-bit platforms.

Depends on D98970

Add wasmBoundsCheck64() APIs that will take a 64-bit index and 64-bit
limit, to be used on all 64-bit platforms.

Document how the bounds checking primitives are supposed to be used.

Depends on D99097

Use the new 64-bit API on 64-bit systems (after widening the index
appropriately) and the 32-bit API on 32-bit systems.

Depends on D99098

Update the Ion pipeline to support 64-bit bounds for wasm on 64-bit
platforms, and 32-bit bounds for asm.js everywhere and wasm on 32-bit
platforms.

Depends on D99102

Depends on D99103

Depends on: 1681684
Attachment #9186999 - Attachment is obsolete: true
Attachment #9191734 - Attachment is obsolete: true

Depends on D99104

Summary: Tweaks, test infrastructure and test cases for wasm memories > INT32_MAX → Allow Wasm memories to grow past 2GB on 64-bit systems
Attachment #9186961 - Attachment description: Bug 1676441 - Allow up to 65534 pages + test cases → Bug 1676441 - Allow up to 65534 pages + test cases. r?rhunt
Attachment #9191733 - Attachment description: Bug 1676441 - Upgrade to size_t in the easy cases → Bug 1676441 - Upgrade to BufferSize::get everywhere. r?rhunt
Attachment #9191732 - Attachment is obsolete: true
Keywords: leave-open
Pushed by lhansen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/cb02a960ee5c
Allow up to 65534 pages + test cases. r=rhunt
https://hg.mozilla.org/integration/autoland/rev/ce483363652d
Upgrade to BufferSize::get everywhere.  r=rhunt

Increase the max number of allocatable pages on 64-bit from 65534 to
65536, except when Cranelift is present (because Cranelift depends on
the bounds check limit being 32 bits and we don't want to deal with
updating Cranelift right now).

Change TlsData::boundsCheckLimit from uint32_t to uintptr_t, so that
it can be 64 bits on 64-bit systems and can represent a 4GB heapsize.

Update test cases so that boundary conditions are handled properly,
for example, i32(65536*65536) == 0, so some test cases should not be
run unless the max page count is below 64K.

Note, this patch does not update the compilers, so the bounds check
limit continues to be read as a 32-bit quantity. This results in some
failures, which go away when the compilers are updated (next patch).

Attachment #9191960 - Attachment description: Bug 1676441 - Bounds checking part 2: Add 64-bit masm api → Bug 1676441 - 64-bit bounds checking
Attachment #9193901 - Attachment is obsolete: true
Attachment #9191966 - Attachment is obsolete: true
Attachment #9191965 - Attachment is obsolete: true
Attachment #9191964 - Attachment is obsolete: true
Attachment #9191959 - Attachment is obsolete: true
Regressions: 1698984
Depends on: 1699155
Attachment #9209431 - Attachment description: Bug 1676441 - Allow 64K pages → Bug 1676441 - Allow 64K pages. r?rhunt
Attachment #9191960 - Attachment description: Bug 1676441 - 64-bit bounds checking → Bug 1676441 - Bounds checking for 4GB heaps. r?rhunt

Looking at the MIPS64 code in a little more detail, I'm not at all certain that it can handle more than 2GB heap. For index values >= 2GB, the natural 64-bit datum on MIPS64 is sign-extended, but that won't work properly when considered as an offset into the heap array. Since I'm not interested in investing more time in that platform, and since the MIPS64 simulator doesn't really work and I can't test anything, I'm going to try to tweak these patches slightly to clamp memory sizes at 2GB for MIPS64. I don't think this will be hard.

Keywords: leave-open
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
Regressions: 1711415
No longer regressions: 1711415
Regressions: 1711415
Regressions: 1735207
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: