Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 859 Bytes

File metadata and controls

18 lines (15 loc) · 859 Bytes

Optimizations in compiler

  • OPT0001: String comparison with empty string is optimized to s.len == 0
  • OPT0002: Several string concatenations are optimized to a single one
  • OPT0003: Match over constant strings is optimized to int comparisons
  • OPT0004: Removal of unnecessary mem.to_heap calls
  • OPT0005: Layout optimization for Option-like unions
  • OPT0006: Constant folding for strings
  • OPT0007: Inlining of small functions

Ideas

  • In string interpolation with integers don't clone string for integer (in int_to_str), pass string with stack-data to str_intrp. Thanks to this we can avoid extra allocation for each integer in string interpolation.
  • Optimize if expressions to if-else-if if possible, this way we can help to C compiler use jump table optimization.
  • allocate constants with an array in static memory