Skip to content

Pre-multiply Slot indices by 8 #1737

@Robbepop

Description

@Robbepop

Currently Slot is a thin-wrapper around a u16 value representing indices into a functions stack slots.
During execution Wasmi has to multiply those stack slot indices with 8 to get the byte offset.
This usually isn't a big deal on most platforms as machine instructions such as lea provide multiplies of power-of-tows out of the box (up to a limit).

This will also necessitate having u32 indices for Slots since otherwise their index values will likely go out of range for common Wasm functions.

However, there might still be the case that I-cache pressure will drop due to the following reasons:

  • u16 values have to be zero-extended on most platforms before being used.
  • Dropping the multiply-by-8 might actually give room to an improved instruction selection.
  • Some micro architectures (e.g. embedded devices) might not have the same capabilities such as modern x86 or ARM and thus might see considerably better performance.

This issue tracks progress of this potential optimization.

Metadata

Metadata

Assignees

No one assigned

    Labels

    optimizationAn performance optimization issue.researchResearch intense work item.

    Type

    No type

    Projects

    Status

    Open

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions