Files
sdk/pkg/compiler/lib
Stephen Adams 4c31413f1a [dart2js] Insert HNullCheck ahead of HGetLength
HNullCheck is inserted before HGetLength when the receiver might be null.
This makes HGetLength and HFieldGet use the same pattern.
HNullCheck supports strengthening of dominated uses, which allows
specialization of string and array interceptors, leading to better code
in some cases. An example improvement is:

      if (aLocale.length < 2)
        return aLocale;
      return J.substring$2$s(aLocale, 0, 2).toLowerCase();

-->

      if (aLocale.length < 2)
        return aLocale;
      return B.JSString_methods.substring$2(aLocale, 0, 2).toLowerCase();

Here `aLocale` has the type String*, and the explicit null check before
`aLocale.length` strengthens the receiver at the call to `substring`.

There is very little code size change.

The inconsistency between the handling of HFieldGet and HGetlength came
to light when investigating an unexpected difference in Uri.parse between two
apps.

Change-Id: I6e76de2070ab2c0058a109896c738ea2a09b322a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221028
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2021-11-23 21:11:31 +00:00
..