|
|
|
|
|
by rezonant
875 days ago
|
|
> But since we are compiling AOT and not JIT, we cannot de-opt/undo that guess if it becomes wrong - instead we would just crash.
>
> But we could define the type using type annotations (TS)!
>
> Now we have to do 0 checks of the type of a, since we already know it at compile-time. This can allow for some big speedups :) This comes with a big caveat that if the type assertion is wrong at runtime that the AOT'ed app will crash. Also I get the sense that the author assumes type "string" always means non-null and non-undefined but this is only true if the strictNullChecks compiler option is enabled. Nonetheless, cool to see folks experimenting in the JS engine arena, especially around AOT! |
|
There's a lot of poorly-explored room in compiler design to take generalized invariants/preconditions/postconditions into consideration (explicit ones are useful for opaque functions defined in a different TU), not just things considered "types" (the problem with types is that they have different lifetime/allocation concerns than assertions).