In the inferrer code like `local == null` would use the type information
for the operands to determine whether the call was `o == null` or
`null == o`. This had the side effect that if the left operand was a
local variable known to have value `null` the case would be treated as
`null == o` and the local would not be promoted to non-null on the false
branch.
Change-Id: I5fa08f8c891578f4c8e337e6cf5882fc2383063f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189210
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
JSDouble was really "double *excluding integral values*".
This was confusing, with JSDouble sometimes used assuming it was all doubles.
Rename JSDouble to JSNumNotInt to avoid future errors like #44818
Change-Id: I96bf33d5531b94aaf33b582e584702f47ed50395
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183201
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Improved inferrer to handle some cases of JS-fragments.
The JS-fragment to copy the array caused the inferrer to be too
pessimistic about list-tracing into List.of.
Change-Id: I0cb4f7610d971d7927d973bd2b0b532d4cef9a7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173883
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
This should cause no change in behavior, but the layer of indirection
keeps us from assuming that typemasks are the underlying implementation
of the abstract value domain.
Change-Id: I2b51b0da489407de86d5638b2eda9541fdd0276e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171780
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
Simple calls to `List.generate` are expanded into a list allocation
and a loop. This generates better code for several reasons:
- There is no overhead for the function argument (closure allocation,
closure type, closure class)
- Global type inference is more precise since each List.generate list
is tracked separately, and the assignments in the loop give better
inference to the collection's element type.
To get precise element type inference, there are two new JSArray
constructors. Global type inference starts with the element type being
bottom for these elements, avoiding spurious nulls in the inferred
type.
Change-Id: I5efb90651ae3f9eb2e81af556704960cdf0b75c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168770
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
`List.of` avoids per-element checks and no longer forwards to
the more expensive `List.from`.
Global type inference infers `List.of` and `List.from` as new
list allocations.
Bug: 40211
Bug: 32937
Change-Id: I54746610a1b0089ec54e43459301720105f872ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170127
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Use the 'growable:' argument or its absence to pick a better type for
List.of, List.from, List.generate, List.empty and List.filled.
Fixes a bug where it was assumed that List.filled was always fixed length.
Slightly better type analysis on some apps, but nothing that is measurable on benchmarks.
Change-Id: Ibe029a93488412956273fc981f626d33bd295386
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163132
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Added a ClassInfo struct that stores bits for class, strict subclasses and strict subtypes.
This map is initialized empty and lazily computes the bits using the method computeClassInfo.
This function recursively traverses the class hierarchy only when needed, computes the bits on the fly and stores it.
Since the class hierarchy is a DAG, this recursive method terminates.
This map will also be used for some queries, which are now exercised in the new test
Change-Id: I0b8b0b34b5c7d5cc3c1608266c9795033351e650
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160040
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Christian Altamirano <coam@google.com>
Use abstract type of constant for BoolConstantTypeInformation
as the AbstractValueDomain may have something more precise than 'bool'
for a true/false constant.
Evaluate short-circuit `&&` and `||` for constant inputs.
This can occur with named and -Dxxx= defined constants.
TODO: we should consider adding a node like a guarded-phi to
select an input, with possible boolean conversions on inputs.
Change-Id: I7f54503db87f6a6d2034ca59c16b4f1ff69ebbb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159323
Reviewed-by: Christian Altamirano <coam@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Pass the CommonMasks abstract value domain instead of the JClosedWorld to TypeMask methods that need access to *their* abstract value domain. It is wrong to get the abstract value domain from the JClosedWorld because when we try to wrap abstract values, the abstract value domain in the JClosedWorld is the wrapper domain, not the domain being wrapped.
Change-Id: I5bbd0f4c56abe45714dd0a2657f73ef240efae0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155640
Commit-Queue: Christian Altamirano <coam@google.com>
Reviewed-by: Stephen Adams <sra@google.com>