This reverts commit c09f790d37.
Reason for revert: CI failures
Original change's description:
> [VM/CLI] Remove dartdev.dill
>
> Incompatible VM flags will no longer break the CLI when running from an
> AppJIT snapshot, so the fallback logic is no longer required. This CL
> thus removes dartdev.dill and the fallback logic.
>
> Relevant past CLs: https://dart-review.googlesource.com/c/sdk/+/157601
> and https://dart-review.googlesource.com/c/sdk/+/178300
>
> Fixes https://github.com/dart-lang/sdk/issues/50504
>
> TEST=I tried running `out/ReleaseX64/dart --observe --sound-null-safety test.dart`
> and `out/ReleaseX64/dart --observe --no-sound-null-safety test.dart` and
> both worked.
>
> Change-Id: I5cdcfbccf71ec557964014fdb80733b4a7c76b4d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274520
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Derek Xu <derekx@google.com>
TBR=bkonyi@google.com,derekx@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com
Change-Id: I5117f990dfabf93f5a9bae56098831280845e84e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275181
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
The doc refers to the `this` as "this", "parent", "current zone", and
"forking zone". Fix a typo "current's zone" -> "parent zone's".
Change-Id: I6d61ad5c69c2cc415ce7271831c7a364715b0652
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274280
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
This reverts commit 4981cbffe2.
Reason for revert: Mac regression test failed.
Original change's description:
> [ VM Service / DDS ] Add custom service stream support
>
> Setting the `stream` parameter on `developer.postEvent` will now forward those events to a custom stream inside DDS.
>
>
> The first use of this will be for widget inspection. A navigation event will be posted to a custom stream. Our IDE DAP can listen for the Event and react to it by navigating to the desired location in the code.
>
> TEST=Updated observatory tests. Created new developer test to check assertions. Added DDS tests for new custom stream behaviour. Manually tested the postEvent and StreamListen with multiple clients
>
> https://github.com/flutter/devtools/issues/4533
>
> Change-Id: I870dc634c9a9a7d2ee3a6605319c2a18517ad197
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274061
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Dan Chevalier <danchevalier@google.com>
TBR=bkonyi@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com,danchevalier@google.com
Change-Id: Ia1dce25444a6329c0553c931c9a6dbbec65ee583
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274802
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Dan Chevalier <danchevalier@google.com>
Use the "extension type" class as the interceptor object for the
dart:_rti library. This applies to the new type system for values
that are represented as a native JavaScript type. For example:
Number, bool, String, Array, etc.
Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: Ie6214aa897d3ae8abb4f9619cd2be984eeb9c4ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266544
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Setting the `stream` parameter on `developer.postEvent` will now forward those events to a custom stream inside DDS.
The first use of this will be for widget inspection. A navigation event will be posted to a custom stream. Our IDE DAP can listen for the Event and react to it by navigating to the desired location in the code.
TEST=Updated observatory tests. Created new developer test to check assertions. Added DDS tests for new custom stream behaviour. Manually tested the postEvent and StreamListen with multiple clients
https://github.com/flutter/devtools/issues/4533
Change-Id: I870dc634c9a9a7d2ee3a6605319c2a18517ad197
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274061
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Dan Chevalier <danchevalier@google.com>
This reverts commit d9ea7207e8.
Reason for revert: b/261854137
Original change's description:
> [ddc] Wrapping loadLibrary checks in a future to obey eval order rules
>
> These checks are cosmetic right now in DDC, but the load check was happening synchronously rather than after the future returned by loadLibrary completed.
>
> Change-Id: I867779605ddfe4f63b83b47418994e0c5e68572a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274087
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Commit-Queue: Mark Zhou <markzipan@google.com>
> Reviewed-by: Anna Gringauze <annagrin@google.com>
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: If7e19644498835d0f77569ce11a2438f4d012f6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274362
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
The current two-level indexing scheme for function type parameters
(depth and index) breaks down in the case of type substitution when
the substituted type is a generic function type, since its internal
type parameter types have been encoded assuming that the function type
had nesting depth zero, but after substitution its nesting depth can
be higher.
Relative indexing schemes such as De Bruijn indices will also not
work, since function type parameter types are constant types, and the
constant infrastructure assumes that the same constant always has the
same representation.
This change introduces a flat indexing scheme where function type
parameters are indexed using a single index which is independent of
the context in which the type parameter type appears. To avoid
collisions in the case of nested generic function types, every function
type has a type parameter offset, which conceptually shifts the
indexing range of its type parameters so it doesn't necessarily start
at zero.
Looking up a function type parameter in its environment thus involves
searching outwards until a function type is found whose type parameter
index range contains the index encoded in the function type parameter
type.
Change-Id: I544056d52711ff829b170f78a7274a93871825a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272361
Reviewed-by: Joshua Litt <joshualitt@google.com>
This reimplements dynamic call code generation to add support for type
checking, named parameters (optional and required), and fixes a few
related bugs on the way.
Currently we do not try to be as efficient as possible. The goal with
this patch is to implement it correctly.
Summary of the changes:
- For every dynamic access kind and member name, we generate a new
"forwarder" function. Dynamic gets, sets, and invocations are compiled
to calls to the forwarders with the right access kind (invocation,
get, set) and member name.
For example, if the program has dynamic invocation of a member "f", we
create an "invocation forwarder for f". If it has a dynamic get of a
member "x", we generate "getter forwarder for x".
- Forwarder functions take 4 arguments:
- Receiver of the invocation, get, or set.
- A Dart list for type arguments in the invocation. For gets and sets
the list is empty.
- A Dart list for positional arguments in the invocation. For gets the
list is empty. For sets, the list only has one element.
- A Dart list for named arguments. For gets and sets the list is
empty. The list has alternating elements of type `Symbol` and
`Object?`, for the name and value of the named parameters.
- A forwarder function compares receiver class ID with the potential
targets of the call. When it finds a match, it compares the callee
"shape" with the parameters passed in the call site.
As it compares the shapes it adjusts argument lists:
- Creates default values for missing optional positional and named
arguments
- Reorders the named argument list to match order expected by the
callee
If it can't find a matching class ID and a member with the right name
and shape, it calls `noSuchMethod` on the receiver.
If it finds a matching class ID and a member, it calls the "type
checker" for the member, passing the original receiver and adjusted
argument lists.
- A "type checker" implements argument type checking for a member, and
it's a member of the same class as the member it's checking types
for. This is to allow accessing class-bound type parameters when
generating type checking code.
- Type checking is implemented using `_isSubtype` on arguments in the
lists.
- When type checking is successful a type checker calls the original
member, passing the arguments as expected by the member.
If type checking is unsuccessful it throws a type error.
Most of the changes are for generating Wasm functions that compare
shapes, adjusts argument lists, and checks types.
Changes to members:
- `Translator.dynamics` fields is renamed to
`Translator.dynamicForwarders`
- New field `Translator.dynamicForwarderFunctionType` added for the Wasm
function type of forwarder and type checker functions.
- Two new code gen utilities added:
- `Translator.indexList`: generates code that indexes a Dart list
- `Translator.getListLength`: generates code that gets length of a
Dart list
- New `Reference` extensions added to get type checker function
references of members
- New runtime library `named_parameters` implements two helper functions
for dealing with named argument lists
- The library `dynamic_dispatch` is replaced by `dynamic_forwarders`,
which consists of two classes:
- `DynamicForwarders`: maintains mapping from call kind (get, set,
invocation) and member name to forwarder functions.
- `Forwarder`: a single forwarder, implements code generation for
forwarder functions.
- `CodeGenerator` gets 3 new members:
- `_callForwader` generates call to a forwarder
- `_generateFieldSetterTypeCheckerMethod` generates code for a type
checker of a setter function.
- `_generateProcedureTypeCheckerMethod` generates code for a type
checker of a method.
Fixes#50367
Change-Id: I2b9d84237c8517bd217166d8acb67e025f0498fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272261
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
In the new runtime type system when running with weak null safety,
perform type tests multiple times to produce optional warnings or
errors when a test passes but would fail in sound null safety.
This is the same technique DDC uses with the current type system.
Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: Ic1514987a6f4ffeb127a0d2be5ec15b606016212
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266543
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
```
import 'dart:typed_data';
@pragma("vm:never-inline")
fetch(l, i) => l[i];
main() {
const n = 16*1024*1024;
final l = ByteData(16 * n).buffer.asFloat64x2List();
for (int i = 0; i < n; i++) {
fetch(l, i);
}
final sw = Stopwatch()..start();
for (int i = 0; i < n; i++) {
fetch(l, i);
}
print(sw.elapsedMilliseconds);
}
```
on x64
before 1137ms
after 101ms
BUG=https://github.com/dart-lang/sdk/issues/50636
TEST=ci
Change-Id: I90ef8ccfa1161d4d8bb076a3c1a0e3c7d6521289
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274263
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
These checks are cosmetic right now in DDC, but the load check was happening synchronously rather than after the future returned by loadLibrary completed.
Change-Id: I867779605ddfe4f63b83b47418994e0c5e68572a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274087
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
The comment mentions that this was a planned refactoring after
--sync-async became the default. Avoid eagerly reading
`StackTrace.current` and switch to an `async` method.
Change-Id: I6a8e9399fa4c282ddbd42eb93f6e19669e75ebc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274260
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
- Flip flag to make strong null safety the default
- Remove code that auto detects null safety mode from source files,
it is necessary to specify --no-strong-null-safety to opt out.
- Retains sniffing of AOT/JIT snapshots and kernel files to determine
null safety mode, the opt out has to be done when generating these
file.
TEST=ci
Change-Id: If2c9608eedb7c46d9c3cd85e261ee9640e0d28eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261140
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Generate type hierarchy rules for all interface types used in a
module. These rules are utilized by the `isSubtype()` to determine
interface subtypes.
Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: I63f64075d4947f234eca5e730ad15588e60b9e1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266542
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Preparation for separating type representation from classes.
Use `JS_CLASS_REF(_RecordImpl)` to inline a reference to the class
in JavaScript (not the type representation).
Use a standard Dart `is _RecordImpl` type test and let the compiler
produce the correct type test code.
Change-Id: I160312d61137ad0c6b2aa30b8aeba4acbe848df9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273523
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Add an example where the source future results in an error that is ignored, with
only the `TimeoutException` surfacing in a catch block.
Move some comments to the same line as the `print` call to match other
lines in the example code. Use doc comment syntax on functions in the
example code.
Change-Id: I5d3146ebe8f7edce303d76ff36822ced9b831c95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272960
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
This fixes two issues for the cases where `FutureOr` normalizes to
`Future`:
- Normalize to `Future` instead of `_Future`.
- Normalize `FutureOr<Never>?` to `Future<Never>?` instead of
`Future<Never>`.
Change-Id: I3bcf96c71a7424cecd3872255660fa1513abdfc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271882
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Both exceptions are used only in pre-null-safe code.
They can safely be removed when all code has been
migrated to null safety, and non-null-safe code is
no longer supported.
Change-Id: I13624d0da369c2241b8f6d66da01ea91bc0b45f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271920
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Auto-Submit: Lasse Nielsen <lrn@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
This fixes `isWasmType` checks for `WasmTable`. Currently this doesn't
cause any test failures, but dynamic invocations incorrectly consider
`WasmTable` as a potential receiver, which causes these warnings:
Unimplemented external member WasmTable.[] at file:///...
Change-Id: Icc2b30e21e9d5c1de3229f6d55e3a6dc962b648b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271522
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
After [0] landed the `vm/dart_2/product_aot_kernel_test` test started
failing due to addition of an additional `_saveObservatory` field which
was marked as entrypoint.
Though this field isn't needed in product mode, so we make the
entrypoint conditional on !is_product.
[0] https://dart-review.googlesource.com/c/sdk/+/267720
TEST=Fixes vm/dart_2/product_aot_kernel_test
Change-Id: I95a7c15fcbee7844be28d82ed2e7803fb6c52138
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271362
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
To prepare for the eventual removal of Observatory, we plan on disabling
Observatory by default while providing an escape hatch to manually serve
the tool for some period of time before completely removing Observatory
from the SDK. This change adds flags that can be used to configure
whether or not Observatory is served.
Currently, '--serve-observatory' is the default behavior, but will be
changed to '--no-serve-observatory' once tooling is ready to support the
escape hatch behavior.
Part of https://github.com/dart-lang/sdk/issues/50233
TEST=run_test.dart
Change-Id: Ib6d1e1587d9fbd3c61d4a4c75d90635052835844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267720
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Extend the runtime representation of function types with a list of
type parameter bounds and take these into account when doing subtype
comparisons on function types.
The implementation has a number of limitations for now:
- When converting a function type to a string, the type does not know
its nesting depth. Function types on all nesting levels thus follow
the same naming scheme for their type parameters (`X0`, `X1`, ...),
which can lead to name clashes between type parameters in the case
of nested generic function types.
- When a generic function is instantiated, the type arguments are not
substituted for the function type parameters in the type of the
resulting function object, which therefore has an incorrect type.
- The default types of function type parameters are not explicitly
represented in function types. When we implement automatic
instantiation of missing type arguments in dynamic function calls,
we need to either add the default types to the representation
somehow or compute them from the bounds.
Change-Id: Ib756d9f8f2b6959efd7ef2e6bc79c7e4793ca3e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269761
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>