Skip to content

miscellaneous performance enhancement ideas extracted from the zir-memory-layout branch #8404

Open
@andrewrk

Description

@andrewrk

Performance optimizations to look into:

  • don't store end index for blocks; rely on last instruction being noreturn
  • look into not storing the field name of field access as a string in zir
    instructions. or, look into introducing interning to string_bytes (local
    to the owner Decl), or, look into allowing field access based on a token/node
    and have it reference source code bytes. Another idea: null terminated
    string variants which avoid having to store the length.
    • Look into this for enum literals too
  • make ret_type and ret_ptr instructions be implied indexes; no need to have
    tags associated with them.
  • use a smaller encoding for the auto generated return void at the end of
    function ZIR.
  • enum literals can use small strings
  • string literals can use small strings
  • don't need the Sema coercion on condbr condition, it's done with result locations
  • astgen for loops using pointer arithmetic because it's faster and if the programmer
    wants an index capture, that will just be a convenience variable that zig sets up
    independently.
  • in astgen, if a decl_val would be to a const variable or to a function, there could be
    a special zir.Inst.Ref form that means to refer to a decl as the operand. This
    would elide all the decl_val instructions in the ZIR.
  • don't have an explicit dbg_stmt zir instruction - instead merge it with
    var decl and assignment instructions, etc.
    • make it set sema.src where appropriate
  • look into not emitting redundant dbg stmts to AIR
  • make decl references in ZIR be u32 indexes to the Decl dependencies array hash map
    instead of duplicating *Decl entries in zir.Code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.optimization

    Type

    No type

    Projects

    Status

    Uncategorized

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions