Proposal: Decoupling Int Width from Pointer Size
Summary: Define Int as a platform-dependent type with a guaranteed minimum width of 64 bits, distinct from the system’s pointer width.
Motivation
- Default Robustness: As the default type for literals and arguments,
Intrequires a generous minimum width to ensure portability and prevent overflow across platforms. - Divergent Requirements: The assumption that
size_of(Pointer) == size_of(Integer)is a legacy constraint. Future architectural needs (e.g., 128-bit contexts) may not align linearly for both types. - The 32-bit Indexing Limit: Current 32-bit constraints prevent indexing collections larger than ~2GB, a critical limitation for Wasm32 targets. Adopting a 64-bit standard eliminates this bottleneck entirely.
Performance & Implementation
- 64-bit Systems: Zero runtime overhead; maps directly to native registers.
- 32-bit Systems (inc. Wasm): Minimal impact. Modern 32-bit architectures and Wasm32 utilize efficient hardware support for 64-bit arithmetic, adhering to Mojo’s strict performance mandates while significantly improving ergonomics and safety.