The gcc backend
In the opt mode, kdts uses a fork of Google Closure Compiler (gcc) as a backend. This fork, which is called kdts-gcc in this document, is hosted at https://github.com/KimlikDAO/gcc.
Compared to stock gcc, this fork performs more aggressive optimizations; which often means making more assumptions about the accuracy of user provided types.
Some differences between kdts-gcc and stock gcc:
Constant folding of type predicates
In kdts-gcc, type predicates such as Array.isArray(x), typeof x == y, x instanceof y are constant-folded if the declared or inferred type of the expression is enough the conclude the value of the expression.
See the commit
Color narrowing after a function inline
Stock gcc has advanced function inlining capabilities. If a function is inlined in the block mode, the body preserves the colors (types) of the original function. kdts-gcc tries to narrow the colors to ones implied by the specific parameters at the call site. This narrowing can lead to cascaded folds in the following passes.
See the commit
Last updated