The web compilers don't support getter/field invocation encoded as a
FunctionInvocation on an InstanceGet because it doesn't work for
getter/field invocation of js-interop properties, since the InstanceGet
wouldn't result in a Dart function but just JavaScript function.
To support this in the new method invocation encoding, a special
expression, InstanceGetterInvocation, is used to encode getter/field
invocations in dart2js and ddc.
Change-Id: I21da8e8686f66ae4ce4d44245073b9e424f975b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192181
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
The CloneVisitorNotMembers contains a mapping from variables to their
corresponding clones. The ListFactorySpecializer special cased access
to this mapping to support conditional cloning. When dart2js switchted
to used the new method invocation encoding, this left the
LocalFunctionInvocation unhandled, leading to null check error when
local functions where invoked in the closure passed to List.generate.
This CL makes this mapping private and adds getter/setter methods for
lookup and registration. The ListFactorySpecializer now instead overrides
the getter to support conditional cloning instead of handling each use
case.
Bug: b/183083319
Change-Id: I2fd3b79137c51a424f17127b502e6a945c6796a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191901
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
If a type variable T is used in an `is` or `as` expression (e.g.
`42 is T` or `42 as T`) or is part of a subtype check, then any types
which may be substituted for T via instantiation must also be treated as
participating in a type check.
This CL ensures that the RTI need computation includes type arguments
for those substituted types and that those types are included in the
list of implicit checks.
Additionally, in order for this to work, this CL fixes a bug in which
the impact transformer was failing to register generic instantiations
occurring in (partial) constants.
Fixes: https://github.com/dart-lang/sdk/issues/45046
Change-Id: I98ae0eca0adcbbb26cdd664318da0da578b289b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190460
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
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>
* Add InstanceGetterInvocation for getter/field invocation in web
backends
* Add localFunction getter to LocalFunctionInvocation
* Remove isNot from EqualsCall and EqualsNull - the encoding didn't
carry its weight.
* Remove uses of Name.name
* Remove BottomType code from VM
TEST=existing
Change-Id: I99d05d35b9ef193d092cc151c99ad472dbd60834
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188725
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
When running dart2js in its "linker scenario" on a large internal app
this saves something along the lines of 70MB of memory.
Note: Does not actually return a const object as that might introduce
polymorphism. See CL review for discussion/explanation.
Change-Id: I9f939a57d994139f0c08caab0871361c5ecd437a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185828
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This is the first part of using the new encodings of MethodInvocation,
PropertyGet and PropertySet in dart2js. In this CL the new visitors
are implemented in static_type.dart. This change is done by refactoring
the existing implementation into helpers and new registration methods
that can be used by both the old and the new encoding but lends itself
to take advance of the new encoding. The new encoding is not enabled
until all of dart2js has been migrated to the new encoding. The
refactoring is intentionally not changing the outcome of the
static_type.dart to make it easier to detect accidental regressions
introduced by the migration.
Change-Id: I93d2033969c33d4c7a5957ad7a6c0b1cdf47fe6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184220
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Most lists created when loading a dill file are growable.
That's not always needed, though, and a non-growable list is more compact than
a growable one.
When running dart2js in its "linker scenario" on a large internal app
this saves something along the lines of 90MB of memory.
Change-Id: I113a73ed150efb56a5172ac7e1daf1d28f4bc188
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185825
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This CL completes the migration of the first wave of
interdependent libraries in package:kernel, including ast.dart.
In order to ensure non-nullability on AST properties, the Transformer
has been split in 2 variants: Transformer which doesn't support
removal of nodes and RemovingTransformer which supports removal where
allowed by the context using 'removal sentinels'.
Start reviewing Transformer and RemovingTransformer in visitors.dart
since many of the changes are caused by the changes here.
Included in the migration are the mixin_deduplication.dart and
unreachable_code_elimination.dart since these needed porting to
the RemovingTransformer which was aided by opting in the libraries
which only depended on ast.dart.
TEST=existing
Change-Id: I9e63b985bd24896c25edd4ee51e37770187bcc17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184786
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
This CL:
* Makes the standard filesystem more synchronous by default.
This makes reading files for normal compiles faster.
* Adds a more asynchronous version of `exists` and `readAsBytes`.
This potentially allows for reading files faster when in a context
where the files can actually be read in parallel. The client have
to make the choise though.
* Skips `Uri.base.resolveUri` when the uri has a scheme. This makes it
slightly faster in my tests, but does not remove any `.` and `..`.
Having those when having a scheme seems sort of weird though.
If this turns out to be a problem we can add it back.
* Re-orders what the standard filesystem checks in `exists` to assume files
which seems more likely to happen. This - for files - means less checks
and should make checking for existance faster. (This was noticed by Siggi).
Using the same measurement procedure as in
https://dart-review.googlesource.com/c/sdk/+/85442
timing how long fasta spends on *reading* files when compiling dart2js
(when compiling via the VM) I get a good speedup.
Note that the measurements are in microseconds:
Before this CL (run like `out/ReleaseX64/dart pkg/compiler/bin/dart2js.dart 2>&1 | grep "Read file (total)" | tail -n 1` 10 times):
Read file (total): 94678
Read file (total): 94232
Read file (total): 91726
Read file (total): 77472
Read file (total): 95582
Read file (total): 88113
Read file (total): 89245
Read file (total): 91575
Read file (total): 96291
Read file (total): 95730
With this CL (run like `out/ReleaseX64/dart pkg/compiler/bin/dart2js.dart 2>&1 | grep "Read file (total)" | tail -n 1` 10 times):
Read file (total): 68379
Read file (total): 69320
Read file (total): 72930
Read file (total): 69692
Read file (total): 68685
Read file (total): 73548
Read file (total): 64649
Read file (total): 71951
Read file (total): 73486
Read file (total): 70621
Difference at 95.0% confidence
-21138.3 +/- 4193
-23.111% +/- 4.5843%
(Student's t, pooled s = 4462.56)
Furthermore, using an internal benchmark (discussed in an email thread)
I get these numbers (note that the measurements are in milliseconds):
before:
4453
4249
4187
4190
4216
after:
2310
2379
2449
2467
2407
Difference at 95.0% confidence
-1856.6 +/- 131.443
-43.5924% +/- 3.08625%
(Student's t, pooled s = 90.1257)
Using the asynchronous versions of exists and readAsBytes and checking for
existance and reading in parallel on the same internal benchmark it gets to
1137
1185
1067
1089
1189
For completion, comparing to using "raw" `File` (again using the internal benchmark):
sequential standard
2377
2419
2485
2373
2431
sequential io_sync
2279
2182
2237
2312
2324
io_sync faster:
-150.2 +/- 76.3122
-6.21432% +/- 3.15731%
(Student's t, pooled s = 52.3245)
sequential standardasync
4865
4915
4753
5185
4760
sequential io_async
4746
4834
4989
4840
4891
No difference proven at 95.0% confidence
parallel standard
2526
2563
2652
2616
2685
parallel io_sync
2335
2184
2244
2341
2401
io_async faster
Difference at 95.0% confidence
-307.4 +/- 111.037
-11.785% +/- 4.25691%
(Student's t, pooled s = 76.1341)
parallel standardasync
1137
1185
1067
1089
1189
parallel io_async
1105
1088
1145
1048
1113
No difference proven at 95.0% confidence
TEST=Existing tests.
Change-Id: I8ba56ab0768df8672bcdb693782d3f1eec86b683
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185101
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
Since the flag is now enabled by default, there should be no mention of it.
There are still some uses in front_end/testcases that are not just removable
(it also uses `no-non-nullable`). There migth be more uses that are not
as easily found as grepping for `--enable-experiment
Removes two VM tests where fixing them meant they were just duplicating
the corresponding non *_2/ tests.
Fixes#44941
TEST= Large number of tests chaged.=(no-)?non-nullable`.
Change-Id: Ief755981ccde9a5482fcdf408c2929c74433a710
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183688
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
This is in preparation to migrate package:kernel to null safety.
For the visitor interfaces to support non-nullable return types, the
implementations must avoid using `null` as return value in its base case.
TEST=Refactoring
Change-Id: Ie8fa5d41b99850d9e4abb59634c72920c64128d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183691
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@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>
This is in preparation to migrate package:kernel to null safety.
For the visitor interfaces to support non-nullable return types, the
implementations must avoid using `null` as return value in its base case.
TEST=Refactoring
Change-Id: Ie5e4153f8d3779d94957bb13b3d2d2a942040ff2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179760
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
JSDouble represents doubles that are not integers. It is usually wrong
to use JSDouble, so use JSNumber instead where we mean 'all double
values'.
This fixes#44818 by not mistakenly pretending that division cannot
have an integral result.
Will follow up with a CL to rename JSDouble.
Fixed: 44818
Change-Id: Ic324df2ee1f2c7434bc0b064c0dbd7b6800ad93b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183360
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This CL avoids creating locals using KernelToLocalsMap when computing
closure data for the J-model. Instead the closure data uses
ir.VariableDeclaration, JTypeVariable, and internal locals (ThisLocal
and BoxLocal) internally, and the accessor function require passes
a KernelToLocalsMap to convert the internal model to a Locals upon use.
The converted Locals are cached internal for performance only.
This prepares for splitting the GlobalLocalsMap and KernelToLocalsMap
from the JClosedWorld.
Previously landed in https://dart-review.googlesource.com/c/sdk/+/180820
but reverted.
Change-Id: Ic6a2ab63de7cb31c89dd50ca2af3f205a792fd74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183000
Reviewed-by: Sigmund Cherem <sigmund@google.com>
- Added support for --define to the VM and dart2js
- Added support for -D and --define for `dart run` and `dart compile js`
Remaining improvements:
- Add support for providing multiple comma separated values for `dart
run`, `dart`, and `dart2js`
Related issue: https://github.com/dart-lang/sdk/issues/44562
TEST=Updated CLI tests and added new dart2js tests.
This reverts commit e49937769f.
Change-Id: I5f9275b829665eb5e8695403d67f230e752ab0e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183180
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This CL ensures that the member environment for the enclosing class
of a live member is computed.
Static members and mixed in members a member can be become live
through static access and mixin application, respectively, which does
not require lookup into the class members.
Since the J-model class environment is computed from the K-model
environment, not ensuring the computation of the class members, can
result in a live member being present in the J-model but unavailable
when queried as a member of its enclosing class.
Closes#44754
Change-Id: I5a735f4605737947cca082450803c35887b0b7a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181801
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>