Fix instance checks for types that are internal to the type system.
Fixes: #40610
Change-Id: I0c6c1bb4d64f25a97c53bd64a3940cf3e9f45c88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135580
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
dartdevc_native tests also have to be updated to not wrap/unwrap generic function types.
Change-Id: I4115db483bb6668c171ec29ca7483dfabc470df5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133285
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
The constructor was wrapping the onData handler to hide the type-mismatch. This
copies the same logic to the onData handler.
In non-nnbd code this code was not exercised. The migration of dart:async
made this code reachable on our tests. That's because Stream.first used to
do:
var subscription;
this.listen(() => ... cancel subscription here, ...)
it now avoids making subscription nullable by registering the onData handler
later:
var subscrition = stream.listen(null, ...);
subscription.onData(() => ... cancel subscription here);
This change fixes the following 6 html tests under nnbd:
html/history_test/history/history
html/transferables_test
html/transition_event_test
html/websocket_test
html/worker_test/functional/functional
html/xhr_test
Change-Id: I095ea8d545e65b047504af0367586884bba84d72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134120
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
A new instruction, HInvokeExternal, codes a variety of calls to JavaScript.
'native' and js-interop calls use this instruction instead of
HForeignCode. This leads to fewer places generating similar JavaScript
patterns, and slightly better scheduling around call sites.
More js-interop calls are now lowered to direct JavaScript calls rather
than interceptor calls.
Change-Id: I8d30827bb099d27f4cc2ad469449769418ccb6da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133021
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This seems to happen in a check-chain when the input is unnamed. I'd
rather name something than do this, since it interferes with counting
occurrences for sharing constants.
Fixed: 40349
Change-Id: I6a077707b172cee7505130119e41f856244f9424
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133624
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Fixes a missing case where DDC allows unwrapped functions to flow to
JavaScript through constructor calls or anonymous object instantiation.
- Pass the `Member` through to `_emitArgumentList` in the case of
constructor calls and object literals so that `isJsInterop` can be
determined.
- Pass an optional `isJsArgument` member through for emitting named
expressions. Previously I thought that no named arguments would be
used for javascript calls, but they are used to create object literals
for anonymous JS types.
- Add both anonymous and non-anonymous constructor invocation examples
to the JS interop test.
Change-Id: I004642f3b2caccc0d8c26786f2bdcb081d135898
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131462
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
... and use it fix perf_test on Windows
`currentDirectory` is replaced by `Uri.base` (the former sounded more magical than it was!)
Change-Id: I5fb8dc5dba004ebad221d4b39d213d51964c5ea2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131622
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Wrapping a legacy type will cause the legacy-ness to be stripped off by design.
This causes confusion when trying to unit test the runtime subtype checks so we
are now simply avoiding it here.
Introduce a `unwrap()` helper method that will attempt to upwrap any type that
isn't legacy. Legacy types are simply returned unchanged because they are
already unwrapped.
Copies the other helper methods from runtime_utils.dart to
runtime_utils_nnbd.dart so they can be updated with the special unwrapping logic
for legacy types.
Change-Id: I21ff24b766a1f7a569181a2e1c47233320751c66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131707
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
This is prep for nnbd port to ensure APIs remain consistent across DDC and Dart2JS.
Change-Id: I8ec6c5b152eb87868038570f2275e82af3325fb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131000
Commit-Queue: Vijay Menon <vsm@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This also reverts the use of indirection for `==` during global inference, as it
turns out the bulk of edges from that selector were added because of the missing
static type data.
Change-Id: I970fea214983c7b2350466fc932ef45d6f7ad96e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130501
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Use NullCheck for inlining and remove 'isNullCheck' from HFieldGet.
Change-Id: Ic9908739a26367243002c1c71f9193660a8c08e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130222
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
This supports skipping tests per configuration, for instance to add
nnbd-only tests and skip these in non-nnbd configurations.
Change-Id: I7eaebaa16d67129ce60cffa3594c766ff5e5bc66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130376
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
This change:
* adds the `--use-old-rti` flag to revert to the old behavior
* enables the new behavior by default
* changes the -rti- builders to run the old rti instead of the new rti
* documents the change in CHANGELOG.md
I've kept around the logic as `useNewRti` to avoid swapping all the conditions
in the compiler.
Change-Id: I773ac33b658cb60f72e0b6beef83375abec31bad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127492
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Add support for generating annotations from actual data using
option -g
Change-Id: I88d9cdb62a38d579234b15097c9e9bb3d81ebe8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129708
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
The resolution-world-builder and impact transformer were holding onto a
class-hierarchy-builder in dart2js, which uses a lot of space.
On a some artificial sample apps with thousands of classes this
reduces the overall memory capacity by 25%. On a large internal app
this reduced the overall memory capacity from 13G to 11G.
Change-Id: I5d0d40764649364f2cd2411ef1346812beb411c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129544
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Fixes#39074
DDC emits Dart code that can usually be called with the same semantics
as JS there is no guarantee that a function passed to JS and then
invoked successfully was wrapped with `allowInterop`. The wrapping is
always required in Dart2JS. To make DDC more strict, add interceptors
that check for the usage of `allowInterop`.
Whenever a JS interop function or setter is passed an argument which is
statically typed as a Function, but not wrapped with `allowInterop` at
the call site, wrap it with `assertInterop` which will check the
argument at call time and fail with a clear error if it was not wrapped.
Whenever a JS interop function is torn off, either at the top level or
from an instance, wrap it with a function that will also inject these
checks at runtime.
There are still holes where we can't catch the mistake:
- An argument which is statically dynamic and a Function at runtime
won't be caught.
- A Function which is stored in a collection won't be caught.
- A JS interop definition where a getter returns a Function which takes
a Function as an argument is not checked.
- A dynamic call through to javascript is not checked.
Changes:
- Refactor `_isJsLibrary` and add `isJsMember`, and `isAllowInterop`
utilities to determine what needs wrapping.
- Update `assertInterop` to give a more clear error when it fails, and
to ignore non function arguments.
- Add `tearoffInterop` to wrap a function an ensure that any function
typed arguments are wrapped.
- Inject `assertInterop` around Function arguments passed to JS methods.
- Inject `assertInterop` around Function arguments passed to static or
instance JS setters.
- Inject a runtime wrapper around static or instance Function tearoffs.
- Add a test covering all flavors of checks that are supported.
- Change the interop expando to an `Expando<dynamic>` in the NNBD SDK to work
around a stricter type check. https://github.com/dart-lang/sdk/issues/39971
Potential improvements:
If the `tearoffInterop` turns out to be too heavy, we could loosen it so
that we only wrap methods if any of their argument types are statically
declared to be a Function.
Change-Id: Ibc92df5b54e1a041b4102a07b8398b774b6bd1d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128462
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Vijay Menon <vsm@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
All of these tests are now running under the regular test infrastructure.
The only reason they were created as modular tests was because we wanted more
control over the SDK sources used.
Change-Id: I2ad5aa616ff8bccd10cfac2d49bfaa39ab50c192
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128801
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
The CFE recently changed the name of the top-level deferred load library method
from `__loadLibrary` to `_#loadLibrary` (see #39682)
We were properly escaping this name when generating the method itself, but we
didn't properly escape the name when creating tearoff closures derived from it.
This is why the issue was not detected earlier.
Change-Id: Ic1487a10f521a86a3466608b1825a2b632a191be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128260
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Type relations to be implemented in a later CL.
Also discovered some visitors were missing support for FutureOr.
Fixes: https://github.com/dart-lang/sdk/issues/38821
Change-Id: Iee494cfa2eff3b320a3fd1a2e7ffbf3f969b40e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125880
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>