Files
sdk/pkg/compiler/lib/src
Stephen Adams e2fdf18b66 [dart2js] Refine types based on test with late sentinel
A small number of getters for `late final` instance fields with
initializers have better code.

When the initializing expression provably does not write to the backing
field*, the field value is re-used rather than re-loaded for the 'final'
check (that the field has not been assigned during the evaluation of the
initializer). We are testing both `value === $` and `value !== $`:

```
      value = _this.___LayoutWidgetState_firstChild_FI;
      if (value === $) {
        result = A._LayoutWidgetState__buildChild(B.ValueKey_1, _this._widget.node.firstChild);
        value !== $ && A.throwUnnamedLateFieldADI();
        _this.___LayoutWidgetState_firstChild_FI = result;
        value = result;
      }
```

In this change we refine the type of the tested value to late sentinel,
allowing the check to be removed:

```
      if (value === $)
        value = _this.___LayoutWidgetState_firstChild_FI = A._LayoutWidgetState__buildChild(B.ValueKey_1, _this._widget.node.firstChild);
```

*This effect analysis is pretty simple ('writes some field'), but if
improved, we might expect more `late final` getters to benefit.

Change-Id: I444ed157083663b848fb2f115d0575e544b47727
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430962
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2025-05-27 12:47:44 -07:00
..
2025-05-22 19:49:10 -07:00
2022-09-16 19:35:00 +00:00

Dart2JS is the Dart-to-JavaScript compiler for Dart. This compiler
will provide high-quality translation from Dart to JavaScript.

Some areas that will explored in this project are:

   * high-performance extensible scanner and parser
   * concrete type inferencing
   * fancy language tool support
   * programming environment integration
   * SSA-based intermediate representation
   * adaptive compilation on the client