Fuzion Logo
flang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

Fuzion Optimizer


The goal of specialization is to avoid overhead for dynamic binding and heap allocation. Take this example:

  x i32 = ...;

  stdout.println("x is " + x)


  println(s ref string) is
    for b : s.asBytes


  string.infix + (s ref string) is
    .. create iterator over string.this followed by iterator over s

The performance issues here are:

to solve this, we need

Data Flow Analysis

With DFA, we can avoid the dynamic call at stdout.println, we could even inline this call


Specialization for Parameters

Once we have no dynamic binding, we can specialize calls for concrete values of parameters. In this case, we know that println is called with an instance of string.infix +, which does not need to be heap allocated.


Now that println was specialized for string.infix +, we can inline string.infix + and directly call the iterators of the string and i32.


Finally, we can continue this specialization and inlining for the string and the i32 and completely avoid any heap allocation and dynamic binding

Allocation of Closures: Funarg problem.

Fuom should provide a solution to the Funarg problem: It should find what inner fields in a feature are part of a closure and what is the lifespan of this closure? If the lifespan does not exceed the lifespan of the call of the outer feature of these fields, they can be stack allocated. Otherwise, it might be possible to allocate them in the stack frame of outer features, place copies of immutable fields into the funarg instance (which might itself be a value type and stack allocated), or, as a last resort, heap allocate the memory for these fields.