Skip to content

Better representation of Int64 on platforms that support unboxed int64 integers #172

@mkustermann

Description

@mkustermann

The current implementation of Int64 stores the underlying integer as 3 integer fields:

class Int64 implements IntX { // A 64-bit integer is represented internally as three non-negative // integers, storing the 22 low, 22 middle, and 20 high bits of the // 64-bit value. final int _l, _m, _h; ... }

Operations to/from a Dart int as well as arithmetic/bitwise operations will be slow due to need to operate on the combination of three fields.

On platforms such as the Dart VM or Dart2WasmGC we have support for unboxed int64 values where this overhead can be entirely avoided.

There's two improvements

  • Use e.g. conditional imports to select better representation for Int64 on VM / Dart2WasmGC than for Dart2Js
  • Possibly avoid the creation of Int64 boxes entirely by having mechanism to pass unboxed values around

/cc @askeksa-google (since we just talked about it), @osa1 , @mraleph

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions