Skip to content

dart2js: investigate: lazy-initialization of large constants #32943

@rakudrama

Description

@rakudrama

It might be cheaper to initialize large constants more like a lazy static initializer instead of precomputing the value during startup. This would depend on the startup cost of evaluating the expression vs the cost of creating a function that evaluates the expression.

#25230 would be useful in aggregating the non-shared sub-constants of the constant into a larger expression which might be worth deferring even though the non-aggregated parts are not.

Lazy-init constants could reference other lazy-init constants, but eager-initialized constants should not reference lazy-init constants in the same deferred part, since that would force the lazy-init to be executed early.
The lazy initialization mechanics can be much simpler that lazy static initialization since constants can neither fail in the initializer nor be assigned before being initialized.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.dart2js-optimizationtype-enhancementA request for a change that isn't a bugweb-dart2js

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions