aef81ef08e
Prior to this change, the SSA node stored in `PromotionModel.ssaNode` was only correct for promotion models that represented variable references. If a promotion model represented a promotable field, its `ssaNode` pointed to a bogus SSA node. This had two undesirable effects: - It meant that `FlowModel.rebaseForward` needed to contain a hack to prevent it from looking at the bogus SSA node for a promotable field, and falsely concluding that the field's value had been reassigned (which is impossible for promotable fields)--see https://dart-review.googlesource.com/c/sdk/+/321752. - It meant that if a promotable field was used as a scrutinee in a refutable pattern match, the promotion logic would look at the bogus SSA node for the field, and falsely conclude that its value had been reassigned, preventing field promotion from working during pattern matching. This change ensures that the correct SSA node is always stored in `PromotionModel.ssaNode`, and removes the hack in `FlowModel.rebaseForward`. This required some re-ordering some of the logic for control flow joins, to ensure that when a join creates a fresh promotion model for a property, it has already created the corresponding `_PropertySsaNode` (previously, it created the `_PropertySsaNode` afterwards, but that is too late since the `PromotionModel` class is immutable). Unit tests and language tests are introduced to validate the newly fixed behavior for promotable fields used as a scrutinee in a refutable pattern match. Also, the uses of `FlowModel.infoFor` in queries such as `getMatchedValueType`, `isAssigned`, `isUnassigned`, and `promotedType` were changed to simple map lookups, to prevent bogus SSA nodes from being created and then immediately discarded. This resulted in a fairly significant boost to CFE compilation speed: page-faults:u: -1.2664% +/- 0.1535% (-2531.33 +/- 306.73) instructions:u: -0.6210% +/- 0.0009% (-119891846.00 +/- 180585.35) branches:u: -0.6765% +/- 0.0014% (-26637478.67 +/- 54272.64) branch-misses:u: -0.9562% +/- 0.8909% (-548444.00 +/- 510991.65) Change-Id: I30f82e8a4ba11236735258077d61d36717fa32c2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322443 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
FE/analyzer shared code
This package contains logic that is shared between the front_end and analyzer packages. It is intended solely to facilitate development of the Dart SDK, and is not intended for use by end users. In particular, this package has no public API, so no guarantee is made of compatibility between one version of the package and the next.
End users should consider using the analyzer package to analyze Dart source code.