Skip to content

wasm2c: big endian support moves memory on growth which will cause overheads #2599

Description

@shravanrn

@sbc100 @keithw @SoniEx2

The big endian support in wasm2c with mmaped linear memory still moves data when growing memory. This is inefficient. Where possible, it is probably simpler to rely on growing memory in place (similar to the little endian implementation)

The context here is Firefox's potential usage of RLBox + wasm2c on the s390x. Beyond the performance concern, an additional issue is that RLBox does not support using wasm2c when memory can be moved.

I believe a fix should be possible.

Approach:

  • The rough difference behind wasm's little vs. big endian implementation is the accesses to linear memory. In the little endian impl, accessing an offset i means we are accessing locationlinear_memory[i]. On big endian systems we are accessing linear_memory[linear_memory_size - i - 1]

  • Thus, we can avoid moving memories, by reserving the max memory with no page permissions, and growing the usable memory from the end of the allocation to the beginning.

I'll try to look into this soon (Any help or thoughts welcome)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions