Commit graph

10697 commits

Author SHA1 Message Date
Daco Harkes 1d567c888f [vm] Remove use of CastError
`CastError` is replaced by `TypeError`.

Also makes the fields of TypeError nullable. See:
https://github.com/dart-lang/sdk/issues/49279

TEST=build SDK and run default suites.

Bug: https://github.com/dart-lang/sdk/issues/49529
Change-Id: I7e880ff2d8b18c4bffdd7a942efd743244a12734
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274381
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-12-08 17:07:33 +00:00
Aske Simon Christensen a22e0ac5ea [dart2wasm] Compute correct type for generic function instantiation
Change-Id: I3811e37002ed6ae458600513bff3ac29482a6af3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271104
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-12-08 13:54:57 +00:00
Aske Simon Christensen ad06d73ace [dart2wasm] Use a flat index space for function type parameters
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>
2022-12-08 13:54:57 +00:00
Ömer Sinan Ağacan 636232628b [dart2wasm] Implement missing features in dynamic invocations
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>
2022-12-08 10:45:12 +00:00
Stephen Adams 2dbd64bb29 [dart2js, js_runtime] Make JSNull.== an external method
Change-Id: I5a69b4f085a1d418fe60af7a8726bc713b54a0bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273462
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-12-08 02:14:00 +00:00
Nicholas Shahan 1edc2ecd3f [ddc] Support warnings/errors in weak mode
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>
2022-12-08 00:52:18 +00:00
Alexander Markov 66f1dee48c [vm] Runtime type check in await
'await e' should check that e is a Future<flatten(S)>, where S is a
static type of e before awaiting e. If e is not a Future<flatten(S)>,
then 'await e' should await Future.value(e) instead of e. So futures
of incompatible type are not awaited and soundness is not violated.

TEST=tests/language/async/await_type_check_test.dart
(Based on https://dart-review.git.corp.google.com/c/sdk/+/267422.)

Fixes https://github.com/dart-lang/sdk/issues/50529
Part of https://github.com/dart-lang/sdk/issues/49396

Change-Id: Ia418db1be6736710abc9be87d95584c50cbc677e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273002
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-12-07 22:46:22 +00:00
Alexander Aprelev efaad34a46 [vm/simd] Recognize TypedData Float64x2 getter/setters
```
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>
2022-12-07 22:25:25 +00:00
Mark Zhou d9ea7207e8 [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>
2022-12-07 20:47:17 +00:00
Nate Bosch 2f864c0a5d Use async/await for readAsString
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>
2022-12-07 20:39:15 +00:00
asiva 606a64a743 [3.0 alpha][VM/Runtime] - Flip flag to make strong null safety the default.
- 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>
2022-12-06 04:04:23 +00:00
Kallen Tu 7e4d4bfef6 [corelib] _RawSecureSocket implements _RawSocketBase to avoid dynamic call in _Socket
Change-Id: Iaca38bcc5df51636016b2833c10f1bb7200ce708
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273021
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2022-12-05 23:05:54 +00:00
Nicholas Shahan a464fc354b [ddc] Support more complicated subtype checks
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>
2022-12-03 00:37:41 +00:00
Nicholas Shahan bf548e788a [ddc] Clarify class vs type references for records
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>
2022-12-03 00:26:58 +00:00
Nate Bosch b64f84d695 Mention late errors in Future.timeout doc
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>
2022-12-02 20:05:26 +00:00
Joshua Litt b493cdfc1b [dart2wasm] Add runner script to streamline running wasm in d8.
Change-Id: I0f891d28419d0df55f94e0229ff33e87b791e7d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273280
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-12-02 19:55:16 +00:00
Nate Biggs e48df2f7f3 [dart2js] Carry library load priorty through to script tag creation.
Change-Id: Ie05b5ffe0f2e1638faf8b784a2e8c5535ec0d76a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272760
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-12-02 05:19:53 +00:00
Ömer Sinan Ağacan ddbc111067 [dart2wasm] Fix range checks in codeUnitAt methods
New passing tests:

- co19/LibTest/core/String/codeUnitAt_A02_t01
- co19/LibTest/core/String/operator_subscript_A02_t01
- corelib/string_codeunits_test
- language/optimize/string_charat_test
- language/string/charcode_test

Change-Id: I27fe1bc080be8d70d4a33763cbfb737e6c837a50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273143
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2022-12-01 16:19:10 +00:00
Brian Quinlan 8df8bbf0de Add PathExistsException and PathAccessException FileSystemException subclasses.
Bug:https://github.com/dart-lang/sdk/issues/50436
Change-Id: Ie2954f162c01189cd0d817f58606529acdc13416
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269240
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-11-30 04:54:52 +00:00
Marya f8a0d65c70 runZoned to runZonedGuarded in docs
Closes https://github.com/dart-lang/sdk/pull/50577

GitOrigin-RevId: 5dd34da55ba6ecab73966d753ef275ddd4b4b2d8
Change-Id: Ie60ce8e57fa5cad532b776f35b82ab5470fe6d4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272488
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2022-11-29 20:28:59 +00:00
Mark Zhou 8b48d7839b [ddc] Adding checks to expando setters, and extending checks to records
Change-Id: I7cd1244806fa63b880d5f6c842d1995207330db9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272462
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2022-11-29 19:51:37 +00:00
Ben Konyi af1536d463 [ dart:developer ] Deprecate Metrics related functionality
See https://github.com/dart-lang/sdk/issues/50231

Change-Id: I8f5196f90dd7a03c08d413d381bf093cc1f309eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272381
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2022-11-28 23:03:18 +00:00
Coaspe 091a292d82 Fix typo in wasm_types.dart
Closes https://github.com/dart-lang/sdk/pull/50555

GitOrigin-RevId: 5bdce7c315236c33be893c525f1fa063c71b95ea
Change-Id: I0267dc19610746323abab067b1957e9ca32ad61c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272340
Reviewed-by: Michael Thomsen <mit@google.com>
2022-11-28 09:29:36 +00:00
Aske Simon Christensen ca131dbf6f [dart2wasm] Fix some errors in FutureOr normalization
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>
2022-11-25 09:31:37 +00:00
Lasse R.H. Nielsen b7b45eb421 Deprecate NullThrownError and CyclicInitializetionError.
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>
2022-11-24 15:05:13 +00:00
Anna Gringauze 72493a75c6 Make records inherit from core.Object
Towards: https://github.com/dart-lang/sdk/issues/49717
Change-Id: Ie32704a21db51dd713a2f03ce78532ed67fe1792
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270821
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2022-11-23 21:03:58 +00:00
Ömer Sinan Ağacan a76a43f451 [dart2wasm] Make WasmTable a _WasmBase subclass
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>
2022-11-23 11:18:17 +00:00
Martin Kustermann 7be0af20f0 [gardening] Make dart:vmservice_ios _serveObservatory only entrypoint in non-product mode
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>
2022-11-22 12:41:07 +00:00
Anna Gringauze 112c93863b Add record types
Towards: https://github.com/dart-lang/sdk/issues/49717
Change-Id: Ib2df16184d1db7d191a22305dacaeb1efe595e5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270581
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2022-11-21 20:49:10 +00:00
Ahmed Ashour 9bea89246a Fix grammar
Fixes #50509

TEST=ci

Change-Id: I7ca115bbe6f436e9df126afddcc08eaba79af2f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270740
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-11-21 20:07:29 +00:00
Ben Konyi 3602351df0 [ VM Service ] Add support for '--[no-]serve-observatory'
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>
2022-11-21 17:47:31 +00:00
Aske Simon Christensen 2518307779 [dart2wasm] Generic function types
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>
2022-11-21 10:40:20 +00:00
Ryan Macnak 9a5dd4707f [vm] Remove "Impl" suffix from VM implementation classes.
This makes things nicer to read in places that display implementation names, such as stack traces, debuggers, profilers and inspectors.

TEST=ci
Change-Id: I959f70d9e51be59801c4455f8c5ccac3c214c21a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270502
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-11-18 21:42:59 +00:00
Stephen Adams b8d85b7ad3 [dart2js] loadLibrary priority annotation
Add annotations

    @pragma('dart2js:load-priority:normal')
    @pragma('dart2js:load-priority:high')

The test shows that these annotations are scoped.

This CL is just plumbing the annotation through as an argument to the runtime call to the code that implements `loadLibrary()`. Actual prioritization is not yet implemented.

Change-Id: Iff1404baf34192139dab95e2dbb01c2d4e8dae45
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270283
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-11-18 19:22:29 +00:00
Lasse R.H. Nielsen 70b88ca80d Make LineSplitter.split not use sync*.
Since dart2wasm doesn't support `sync*` yet,
this removes the only use of `sync*` in the *platform libraries*,
which should make things a little easier.

Change-Id: I9f2936b503ab488b85b869bb4e20de1ff47ca4c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267700
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2022-11-18 15:34:22 +00:00
Ömer Sinan Ağacan 50c5e8f47b [dart2wasm] Fix double.pow
Handle these two edge cases documented in `pow`:

- if x is 1.0, the result is always 1.0
- if y is Infinity and x is -1, the result is 1.0

New passing tests:

- co19/LibTest/math/pow_A04_t01
- co19/LibTest/math/pow_A14_t01
- co19/LibTest/math/pow_A16_t01
- lib/math/double_pow_test

Fixes #50505

Change-Id: I42266e9b52edd853133db8aeaafe9d5aa73a1449
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268960
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2022-11-18 13:04:16 +00:00
Lasse R.H. Nielsen 942a7ff6d7 Add performance warnings to RegExp class.
Fixes #50321

Bug: https://github.com/dart-lang/sdk/issues/50321
Change-Id: Ie13851ddce8c609fbd31f6b72aa69ab6e948f255
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266390
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-11-17 16:38:29 +00:00
Alexander Aprelev a83cfa0990 [vm] Replace Double_hashCode native method with graph intrinsic implementation.
Bug: https://github.com/dart-lang/sdk/issues/50265
TEST=ci
Change-Id: Icae87ce3871bb44599e0f1fa19d8becb3a6fcdec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264240
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-11-17 02:28:37 +00:00
Ömer Sinan Ağacan 891e708a0f [dart2wasm] Check for length changes in _ListBase.forEach
New passing tests:

- corelib/list_concurrent_modify_test
- corelib/list_for_each_test

Change-Id: I3e8637806ee37d39a51a257d997a16e61af64bec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270141
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2022-11-16 20:07:30 +00:00
Ömer Sinan Ağacan ef23a1d81c [dart2wasm] Implement function equality
New passing tests:

- co19/Language/Expressions/Property_Extraction/conditional_t05
- co19/LanguageFeatures/Constructor-tear-offs/equality_A05_t01
- co19/LanguageFeatures/Constructor-tear-offs/equality_A05_t02
- co19/LanguageFeatures/Constructor-tear-offs/equality_A07_t01
- co19/LanguageFeatures/Constructor-tear-offs/object_member_A01_t02
- language/call/method_implicit_tear_off_test/01
- language/call/method_implicit_tear_off_test/02
- language/call/method_implicit_tear_off_test/03
- language/call/method_implicit_tear_off_test/04
- language/call/method_implicit_tear_off_test/05
- language/call/method_implicit_tear_off_test/06
- language/call/method_implicit_tear_off_test/13

The failing test co19/LanguageFeatures/Extension-methods/tearoffs_t02 is
about extension method tear-offs, which will be fixed separately.

Change-Id: I4fe46e5afdb79af4123eeda8671f968a4b86d254
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269882
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2022-11-16 07:57:51 +00:00
Joshua Litt f6c07e62db [dart2wasm] Trivial fix for _parseDouble.
Change-Id: I77c152219b614aab5b2efe106db75226553efbd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270021
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Auto-Submit: Joshua Litt <joshualitt@google.com>
2022-11-16 07:48:02 +00:00
Mark Zhou f443f7e213 [ddc] Removing extraneous hashCode calls and stubbing runtimeType property
Change-Id: I97ef5caab82a035fda2e88d9d18d48280e82cc3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270024
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Mark Zhou <markzipan@google.com>
2022-11-16 02:13:19 +00:00
Mark Zhou f504ad2a20 [dartdevc] Adding support for more Record nodes and core methods
- Supports: RecordGet, RecordIndexGet, RecordConstant
- Adds methods: hashCode, toString, ==

Change-Id: I512978a0ccf2eb58e24baf8462cc93ff98bd9105
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269745
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-11-15 22:15:25 +00:00
Ryan Macnak a2de36e708 [vm] Rename the default implementation classes of Map and Set.
_InternalLinkedHashMap => _Map
_InternalImmutableLinkedHashMap => _ConstMap
_InternalLinkedHashSet => _Set
_InternalImmutableLinkedHashSet => _ConstSet

This makes things nicer to read in places that display implementation names, such as stack traces, debuggers, profilers and inspectors.

TEST=ci
Change-Id: Iec851c80ea2086cbe79934565dbf35f04809a836
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266303
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-11-15 17:15:58 +00:00
Ömer Sinan Ağacan a2adab7dfd Update Function class documentation:
Language spec does not require that evaluations of the same function
literal should create distinct objects. Remove the parts in `Function`
documentation to reflect that.

Also fixes formatting of markdown.

Invalid test file (with Dart 2 and 3 versions) removed: the tests assume
function literals won't be lifted to top-level.

Change-Id: Ib7a9464ad992cf461e77ef2d8ef336c7b0f4875a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269721
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2022-11-15 15:41:49 +00:00
Aske Simon Christensen a9cfad4e1f [dart2wasm] Move low-level int/double intrinsics to base classes
Change-Id: I9900286e0f4538d887226ffbaa6dc739174b37af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269001
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2022-11-14 15:50:20 +00:00
Nicholas Shahan 1ad3b1c45a [ddc] Add support for new function types
Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: I0a338e672467b8fec5158f5959da01fa100f3ae8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266541
Reviewed-by: Anna Gringauze <annagrin@google.com>
2022-11-11 23:49:34 +00:00
Nicholas Shahan 52d70ed2cf [ddc] Add support for new generic interface types
- Introduce type environments in the compiler used for evaluating type
  parameters from generic classes and generic function types.

Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: Ib5641eb666527acc3b7f13a4a00dea34e0122b52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266540
Reviewed-by: Mark Zhou <markzipan@google.com>
2022-11-11 23:49:34 +00:00
Joshua Litt ea100af998 [dart2wasm] Wire up async stack trace.
Change-Id: I2c738d91f4b75f0e1ea537eaa0750a0acae6897c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268106
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2022-11-11 16:54:48 +00:00
Chloe Stefantsova e25e532900 [cfe] Allow 'new' as constructor name on enum elements
Additionally, add some missing compile-time errors and adjust error
text expectations.

Closes https://github.com/dart-lang/sdk/issues/49327

TEST=Covered by existing tests.

Change-Id: Ie62211650633beb26abdf735e0dd36c4de4e24c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266740
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2022-11-11 11:13:35 +00:00