Commit Graph

2483 Commits

Author SHA1 Message Date
Srujan Gaddam dc3b6af33d Add location rename to locationString in test
The SecurityError was being hidden because of
https://github.com/dart-lang/sdk/issues/56772.
With this, single-stepping through the test succeeds.

Change-Id: I47a768e803598d5f918a4d2bed9aa4391377464f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386401
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-09-23 22:38:57 +00:00
Srujan Gaddam 591b774213 Add tests for cross-origin window and location
Tests that we can use JSAny? as the type without
violating cross-origin policy. This will then be
used in package:web to implement a wrapper.

Change-Id: Ic30557138b61e27e421747ead81ea2fb7f6db240
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381886
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-09-12 21:30:00 +00:00
Lasse R.H. Nielsen 7e75d881a0 Tweak test_runner.
Clean up and optimize some RegExps, and fix uses of `.group`.
Switch to a newer language version, to be able to use newer features.
Add a little documentation about why some RegExps are as they are.

Add (tentative) warning for multitests.

Change-Id: I59f73b87ce30caaeca1c0e0aa7954af1b97abd1b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382620
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-09-10 15:29:28 +00:00
Ryan Macnak 214b83c1e4 [vm] Work around C compiler bug with simulation of ARM64 vsub.
TEST=ci, dartfuzz
Bug: https://github.com/dart-lang/sdk/issues/55879
Change-Id: Iadf71b315de3462af6b739c8b49865469368b647
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384443
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-09-10 01:11:15 +00:00
Martin Kustermann 0e620b27a0 [dart2wasm] Align test outcomes of dart2wasm across configurations
Aligns exit codes of

  * `dart compile wasm` and
  * `pkg/dart2wasm/tool/compile_benchmark`

Also make them use exit codes recognized by the test runner to
distinguish CFE crashes, CFE compile-time-errors and other failures.

Also update status file entries to from D8 specific entries
to JS commandline shell entries

=> Step towards aligning D8 & JSC test results

Change-Id: I1acb8803f5db7c732ad546d5989b1c555583e7c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383660
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-09-05 11:22:18 +00:00
Rutvik Tak 1fb6869585 Adds a static from method on JSArray which helps a create a JSArray from a given JS iterable or array-like object. (Resolves #56069)
R=brianwilkerson@google.com, nshahan@google.com

Change-Id: I4b913107f5789f48af521b90052052d87453951d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382080
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Auto-Submit: Rutvik Tak <takrutvik@gmail.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-09-04 23:27:18 +00:00
Srujan Gaddam e9a72b80c1 [dart:js_interop] Clear up wording about isA requiring non-generic type argument
Closes https://github.com/dart-lang/sdk/issues/56564

CoreLibraryReviewExempt: Doc-only change.
Change-Id: I0086a0778d53d850c8d746e0474d22382d5e451c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381942
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-09-03 16:03:57 +00:00
Lasse R.H. Nielsen 310d91aee8 Make async error injection set stack trace on errors.
Also removed a bunch of `CheckNotNullable`s that shouldn't be necessary any more. Any remaining non-sound-null-safety code runs today, and no more should be written. (And if it is, it'll mostly just err somewhere else, with a worse error message.)

Tested: New test added. Removed older tests checking for unsound null-safety.
Change-Id: I28626909cd8c1f91db6c61fc2b93042ed1b085dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380780
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-08-27 12:51:26 +00:00
Sigmund Cherem e8a049fd8e [dart2wasm] Make dart.library.js false in conditional imports (attempt 2)
This change removes the implementation of `dart:js` for dart2wasm. The
code is no longer in use and the compiler already provides a static
error if you import `dart:js` internally.

By removing the implementation from the libraries.json spec, we also
show this as unaccessible on conditional imports. This will allow
developers to distinguish JS and Wasm backends

This adapts the original implementation in
https://dart-review.googlesource.com/c/sdk/+/368642 with a few small
changes, but keeps around the existing allowances on `package:js`. Those
can be addressed separately to reduce the disruption from this change.

Closes #55266.

Change-Id: I0d01a424f2fdb4f48879bd1a41c847a92439e74a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380583
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2024-08-16 16:22:50 +00:00
Nate Biggs 2f97501551 [js_interop] Fix JsInteropChecks not recursing into constructor's AST children.
The JS interop transformer assumes the entire AST has been checked and ends up trying to cast to FunctionType. If there is malformed, unvisited interop code this results opaque failure (failed type cast) rather than the useful error message from the check.

Bug: https://github.com/dart-lang/sdk/issues/56443
Change-Id: I5b911d0da7a839e3045dce61121496d464b79af9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380381
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-08-15 01:47:34 +00:00
Srujan Gaddam ac6588ba60 [dart2wasm] Optimize dartify type-checks
dartifyRaw type-checks are currently a bunch of if
cases where the check is done in JS. Instead of going
back and forth between runtimes, we can do the checks
in JS and return an enum value.

- Replaces the if cases with a externRefType method that
returns an integer that maps to some static const values.
Dart enums are slower so consts are preferred. Speeds up
type-checks by 4-5x and dartifyRaw by 1.1-1.8x for common
types using some quick local benchmarks. Also moves the
array check up as it's more common and groups the typed
array checks together.
- Reuses the externRefType helper in dartify so we don't
type-check the same value twice.
- Moves some tests from basic_test.dart to jsify_dartify_test.dart
and adds more type-checks, casts to assert types, cleans
up property getters, and adds a few missing cases.

Change-Id: Ia5fb9bfef6f9e212ea8da27362b0b4efb4cbf2fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/379144
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-08-08 16:12:17 +00:00
Srujan Gaddam be9dcae47e Add soundNullSafety checks in js_function_arity_test.dart for cases where we expect a failure when casting the this value to String
The this value can either be a JSObject or null. In JavaScript,
it's only ever null when strict mode is enabled. In DDC,
since strict mode is enabled, these parameter checks
then succeeded when we test unsound mode as null can be
successfully casted to String, and therefore the failure
expectation fails. Instead, we should only enable these tests
when sound null safety is enabled.

Change-Id: I70ab3de98fb81af5c71450d81590c0bf87a029e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378567
Reviewed-by: Nate Biggs <natebiggs@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-08-02 20:26:58 +00:00
Srujan Gaddam ae3dbcdfb1 [dart:js_interop] Add toJSCaptureThis
Closes https://github.com/dart-lang/sdk/issues/54381

- Adds an API to capture the this value so that users
can use it in the callback.
- Adds specialized stubs to dart2js similar to what was
done for toJS.
- Adds generic stub to DDC as these stubs don't get
tree-shaken away and toJSCaptureThis is less likely to be
used.
- Modifies dart2wasm lowerings to add this to the JS
function wrapper if calling toJSCaptureThis.

Change-Id: Ic0a7fd768de1dd6b491998e029ff5eb406ee7992
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377160
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-08-01 01:02:47 +00:00
Nicholas Shahan 77be340ce8 [ddc] Fix the internal type of prototype objects
Ensure that if a prototype object of a native peer class flows
into the program through JavaScript interop, it will be interpreted
as an interop object, instead of the Dart peer class.

Add some regression tests.

Fixes: https://github.com/dart-lang/sdk/issues/56322
Change-Id: Ic84bbdc4784e667a8730a9f1d578527b4bbdd198
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377763
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-07-30 15:33:28 +00:00
Nicholas Shahan 21dee0734f [js_interop] Add tests for Object literal factory
Ensures factories using named arguments to create Object literals
work as expected when the names shadow properties on the native
JavaScript Object prototype.

Issue: https://github.com/dart-lang/sdk/issues/56315
Change-Id: Iaae8390f853a6f32ac6ba891a56643296a394930
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377723
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-07-29 18:19:54 +00:00
Srujan Gaddam 4806f5cb0a [dart:js_interop] Add JSArray.length and accessors
Also cleans up some TODOs due to previous JSArray
limitations.

Change-Id: Id17e5d069538defc0f89b8f5e1a0e52d3c07ce2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373884
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-07-24 17:40:05 +00:00
Srujan Gaddam abdba89805 [dart2wasm] Fix type casts in interop lowerings
Closes https://github.com/dart-lang/sdk/issues/54314
Closes https://github.com/dart-lang/sdk/issues/56004

- Fixes calling interop members with generic return
type so that there's a cast based on the expected static
type.
- Fixes converted callbacks that take generic parameters
by passing a "cast closure" that captures the generic types
and then casts the arguments to the JS wrapper to those
generic types.
- Adds and cleans up some tests.
- Adds and cleans up documentation around callbacks.

Change-Id: I3749e9326cfa31ee759a89203d513be39019d86d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374847
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-07-24 16:57:46 +00:00
Srujan Gaddam 9e0acbc52b Reland "[dart:js_interop] Add typed array/data buffer constructors"
This reverts commit 3f77881352.

Reason for revert: Relanding with test fixes. The setting of
maxByteLength via constructor is not available on the Firefox
and Safari versions in the bots but is available in newer
versions. See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/ArrayBuffer#browser_compatibility
for more details. For now, since we're just testing whether
the constructor exists, it suffices to remove the test for the
property.

Original change's description:
> Revert "[dart:js_interop] Add typed array/data buffer constructors"
>
> This reverts commit aa48f77d44.
>
> Reason for revert: Broke Safari/Firefox bots due to maxByteLength not returning an int.
>
> Original change's description:
> > [dart:js_interop] Add typed array/data buffer constructors
> >
> > - Adds constructors for JSArrayBuffer, JSDataView, and
> >   concrete typed array types e.g. JSInt8Array.
> >
> > While JSDataView and the typed array types can also take in
> > a SharedArrayBuffer, we currently don't have a type that
> > represents that type. Therefore we keep it as JSArrayBuffer
> > and not JSObject as that would be too general.
> >
> > Change-Id: Iea1e08a9a8225accc7fc3550f0f8fe88039a1eb5
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343940
> > Reviewed-by: Leaf Petersen <leafp@google.com>
> > Commit-Queue: Srujan Gaddam <srujzs@google.com>
> > Reviewed-by: Sigmund Cherem <sigmund@google.com>
> > Reviewed-by: Ömer Ağacan <omersa@google.com>
> > Reviewed-by: Martin Kustermann <kustermann@google.com>
>
> Change-Id: I74ab5ceb4be6d51f3429703bdf4a467bf31e7f1c
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377122
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

CoreLibraryReviewExempt: Reland with just test fixes.
Change-Id: I8bc6a86aba83138ad627e299486f688e531b55a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377123
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-07-23 16:14:09 +00:00
Srujan Gaddam 3f77881352 Revert "[dart:js_interop] Add typed array/data buffer constructors"
This reverts commit aa48f77d44.

Reason for revert: Broke Safari/Firefox bots due to maxByteLength not returning an int.

Original change's description:
> [dart:js_interop] Add typed array/data buffer constructors
>
> - Adds constructors for JSArrayBuffer, JSDataView, and
>   concrete typed array types e.g. JSInt8Array.
>
> While JSDataView and the typed array types can also take in
> a SharedArrayBuffer, we currently don't have a type that
> represents that type. Therefore we keep it as JSArrayBuffer
> and not JSObject as that would be too general.
>
> Change-Id: Iea1e08a9a8225accc7fc3550f0f8fe88039a1eb5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343940
> Reviewed-by: Leaf Petersen <leafp@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Ömer Ağacan <omersa@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I74ab5ceb4be6d51f3429703bdf4a467bf31e7f1c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377122
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-07-22 23:48:57 +00:00
Srujan Gaddam aa48f77d44 [dart:js_interop] Add typed array/data buffer constructors
- Adds constructors for JSArrayBuffer, JSDataView, and
  concrete typed array types e.g. JSInt8Array.

While JSDataView and the typed array types can also take in
a SharedArrayBuffer, we currently don't have a type that
represents that type. Therefore we keep it as JSArrayBuffer
and not JSObject as that would be too general.

Change-Id: Iea1e08a9a8225accc7fc3550f0f8fe88039a1eb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343940
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-07-22 23:18:48 +00:00
Ryan Macnak 9ab5245b89 Reapply "[vm] Don't use a fuzzy lookup for recognized methods."
- Fix incorrectly named ALL_INTRINSICS_LIST to ASM_INTRINSICS_LIST and restore setting intrinsic bit for graph intrinsics.
 - Remove more dead code.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/56007
Change-Id: Iebceaab86509e34f47e3d6918706b0e69ed7dfc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374842
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-07-09 16:33:19 +00:00
Ryan Macnak b5d6c50e1a Revert "[vm] Don't use a fuzzy lookup for recognized methods."
This reverts commit 1dbb56c77a.

Reason for revert: affects Golem results

Original change's description:
> [vm] Don't use a fuzzy lookup for recognized methods.
>
> TEST=ci
> Bug: https://github.com/dart-lang/sdk/issues/56007
> Change-Id: I30debb6b9c9890739cc1b25b7b2c097551b4c2aa
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374200
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

Bug: https://github.com/dart-lang/sdk/issues/56007
Change-Id: I1b8fddb967f0189ce223aad1768477229a8a36b0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374863
Commit-Queue: Alexander Aprelev <aam@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Auto-Submit: Ryan Macnak <rmacnak@google.com>
2024-07-08 21:40:47 +00:00
Ryan Macnak 1dbb56c77a [vm] Don't use a fuzzy lookup for recognized methods.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/56007
Change-Id: I30debb6b9c9890739cc1b25b7b2c097551b4c2aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374200
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2024-07-08 18:25:48 +00:00
Srujan Gaddam f9cd24327f Put expected value first in importModule tests
Change-Id: I1e1cb720c6bcc6991ab10def235dc3b97977c6c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373402
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
2024-06-27 13:58:53 +00:00
Srujan Gaddam 1c534e5fd5 [dart2wasm/ddc/dart2js] Lower Function.toJS and JSExportedDartFunction.toDart
Lowers these extension methods to some helper functions instead of
allowInterop to improve performance and get consistent semantics.

Specifically:
- Function.toJS no longer gives you the same JSFunction when calling
toJS on the same function multiple times in the JS compilers.
- Adds fast calling syntax for functions with 0-5 args in the JS
compilers.
- Allows additional args to be passed to converted functions that
are omitted in the JS compilers.
- The static type now determines the number of args that can be
passed to the JS function in the JS compilers.
- Fixes an issue in dart2wasm where if too few arguments are
passed, the call may succeed due to conversion of undefined to
null.
- Adds throws when a user tries to wrap a JS function that
returned from Function.toJS in the JS compilers.

Closes https://github.com/dart-lang/sdk/issues/55515
Addresses https://github.com/dart-lang/sdk/issues/48186

CoreLibraryReviewExempt: Changes to docs only in API surface.
Change-Id: I41d864dc5e02b597d9f1c16c88e3c04872f28225
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368065
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-06-26 23:06:36 +00:00
Srujan Gaddam b8402f5c27 [dart:js_interop] Make ExternalDartReference generic
Closes https://github.com/dart-lang/sdk/issues/55342
Closes https://github.com/dart-lang/sdk/issues/55536
Closes https://github.com/dart-lang/sdk/issues/56015

- Adds a type parameter T that extends Object? to
ExternalDartReference to capture the type of the value
that was externalized.
-- In the JS compilers, the representation type of
ExternalDartReference is now T.
-- In dart2wasm, the representation type is now JSValue?.
- ExternalDartReference no longer implements Object.
- Return type of toDartObject is now T.
- ObjectToExternalDartReference and
ExternalDartReferenceToObject both now are on a T that is
bound to Object?.
- Internal patches for WeakReference and Finalizer are
updated.

Change-Id: Ic2dc834b17ec6a4eb2122cba3c495a6e0a1eae6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370663
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2024-06-26 21:53:53 +00:00
Srujan Gaddam 1550539558 [dart:js_interop] Make not and isTruthy return JSBoolean
Since these operators can't be written by users, prefer
to keep them as JS types.

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

Change-Id: Ifb9b581fb82e057ba14c669a5a3934f9c502d06f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359181
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-06-25 17:50:33 +00:00
Srujan Gaddam 0b761229cc [dart:js_interop] Change importModule to accept JSAny
Closes https://github.com/dart-lang/sdk/issues/55429
Closes https://github.com/dart-lang/sdk/issues/55508

Objects like TrustedScriptURLs can be passed to the dynamic import
function, and therefore importModule should accept any JS value.

Change-Id: I43ce9aeb1e8fbd628bc768a16b246ba19470b1dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363504
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-06-25 17:50:33 +00:00
Lasse R.H. Nielsen 001e5b3435 Forgotten last patch-set for landed CL
The https://dart-review.googlesource.com/c/sdk/+/371100
should have included this change, but I somehow managed
to not include it in the upload.

CoreLibraryReviewExempt: Would have been part of accepted CL
Change-Id: Ia9d133ef753413d4804d04db2478e73709e5e5ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372440
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-06-20 11:27:53 +00:00
Lasse R.H. Nielsen a505bbc6a0 Add TypedDataList superinterface on typed data lists.
Adds an interface which implements both `TypedData`
and `List`. That allows abstracting over types that are both
`List` and `TypedData` without losing access to one of the
interfaces.

Tested: typed_data_interface_test.dart
Change-Id: Idbdfc084ea5d2d9a072887973e2e9d29a5fd94ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371100
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2024-06-20 08:18:38 +00:00
Srujan Gaddam 06ec78851b [dart:js_interop] Add static error for converted functions that contain named params
Like type parameters, these parameters can't be passed from JS and
such functions already do not work as intended as there is no way
to pass named args to a JS function. These named parameters were
being silently ignored in dart2wasm when creating the function
trampoline.

Change-Id: Iebb890de05f8b242e0542c1ec8f2c0582c5232df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368062
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-06-14 19:42:10 +00:00
Stephen Adams 18994e6e46 [typed_data] Remove UnmodifiableXXXView classes
In most cases, the (now removed) SDK class was patched so that the constructor redirected to a platform-specific implementation of the unmodifiable view. Uses of the SDK class in the platform code could be rewritten to the more direct use of the implementation class.

The big +/- file changes are from moving the implementation classes from the patch file (typed_data_patch.dart), where they are no longer needed, to the internal file (typed_data.dart).

TEST=ci
Bug: #53785
Change-Id: Iaa7370de25b7fc2d26b24f7733c2892868e593cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370661
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
2024-06-13 22:18:29 +00:00
Jens Johansen c15466034e [status_files] Cleanup status files
Make tool (by default) give error when test entry specified in status
file does not exist. Make -w (by default) remove such entries.

Cleanup most status files, fixing a few entries containing `.dart` and
removing obsolete entries (i.e. entries pointing to nonexisting tests).

This should for instance have given an error in
https://dart-review.googlesource.com/c/sdk/+/370600 saying that the file
I specified didn't exist (in that I shouldn't have specified the `.dart`
part).

TEST=No tests, this is status file maintenance.

Change-Id: Ie977bf15dea2e3dad8d771fd3e99917317e975f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370886
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2024-06-12 10:21:23 +00:00
Ömer Sinan Ağacan dbcf23a5ed [dart2wasm] Disallow dart:ffi in user code
Change-Id: I1d99637e4538a183d8fa567399bfb7c55675e60e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368568
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-05-31 07:12:21 +00:00
Martin Kustermann 5963c95f47 [dart2wasm] Unskip lib/async/stream_periodic3_test
Closes https://github.com/dart-lang/sdk/issues/50901

Change-Id: If0d4cc4160fc038c93ee6d2357eb185dd42e5a17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368564
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-05-29 12:48:24 +00:00
Lasse R.H. Nielsen b06a34fc5a Don't allow completing a _Future with itself.
This never worked. It was silently accepted, at least if the future had no listeners, then any later attempt to use the future would cause a stack overflow or other impossible results.

Moves some `_Future._complete` call out of try-catch.
The `_complete` shouldn't throw (but before this fix it could).
Moving them out of the `try`/`catch` makes such errors be reported
as unhandled, instead of catching them and trying to complete the same
future again with an error, when it's possibly in an inconsistent state.

Fixes #43662.
Based on https://github.com/dart-lang/sdk/issues/43662#issuecomment-2058870247

CoreLibraryReviewExempt: No response.
Bug: http://dartbug.com/43662
Change-Id: I96a4f01bcd5b6cee93bba267299852569a9b905c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363060
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-05-14 15:44:07 +00:00
Srujan Gaddam 307d739158 [dart:js_interop] Fix lowerings of ExternalDartReferences
Closes https://github.com/dart-lang/sdk/issues/55549
Closes https://github.com/dart-lang/sdk/issues/55340

Fixes several issues around using ExternalDartReferences:
- Better inlining of interop methods is enabled when this
type is used. This also indirectly improves inlining when
using JSAny.
- Adding some missed inlining for setting properties in
general.
- Allows opaque references of Dart functions to be passed
to JS
- Allows type parameters that extend ExternalDartReference
to be used in interop methods.
- Fixes up parent pointers of nodes in transforms.

Change-Id: I8cbd163ee3c1b98e733c35a61e6e83a0787d334c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364580
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-04-26 19:08:13 +00:00
Lasse R.H. Nielsen b464fc9037 Reland "Tweak expect.dart library."
This reverts commit cd2c566bcf.

Reason for revert: Updating to not remove field used by Flutter engine.

Original change's description:
> Revert "Tweak `expect.dart` library."
>
> This reverts commit ff5f391c0a.
>
> Reason for revert: The expect library is used by Flutter engine, and some of its tests use assertStatementsEnabled. There should be a migration path that doesn't require an atomic change, like adding the replacement api before removing the old one.
>
> Original change's description:
> > Tweak `expect.dart` library.
> >
> > Make API more consistent for a few methods.
> > Reduce the number of language features used in tests:
> > * Never iterating an iterable, always converting it
> >   using `.toList()` first and iterating using indices
> >   (fx `setEquals`).
> >   Also require a `List` in places where an `Iterable`
> >   wasn't necessary.
> > * Avoid doing complicated computations that are also
> >   used for the error message. Do simple check first,
> >   then recompute to get better error messages
> >   (fx `allDistinct`).
> >
> > Renamed some rarely used members for consistency
> > (`stringContainsInOrder`->`containsInOrder`,
> > where other string-contains functions just start
> > with `contains`, and `containsOneOf` -> `containsAny`
> > to match `Iterable.any` phrasing, and also it accepts
> > if containing at least one, not precisely one.)
> >
> > Removed a function that wasn't used anywhere.
> >
> > Moved `assertStatementsEnabled` to `variations.dart` as `asserts`.
> > Removed `typeAssertionsEnabled` and `checkedModeEnabled`. The former used in one place, where it was replaced with `checkedImplicitDowncasts` from `variations.dart`, the latter wasn't used anywhere.
> >
> > Deprecates `package:expect/minitest.dart`. It was never intended
> > to be used for new tests, only as a help to convert existing tests
> > written against `package:unit_test`.
> > All existing imports marked as `// ignore: deprecated_member_use`.
> >
> > Change-Id: I07e21d4c0f3ccf11b82ee34af2668fdbb22264d2
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352360
> > Reviewed-by: Slava Egorov <vegorov@google.com>
> > Reviewed-by: Ömer Ağacan <omersa@google.com>
> > Reviewed-by: Nate Bosch <nbosch@google.com>
> > Reviewed-by: Stephen Adams <sra@google.com>
> > Commit-Queue: Lasse Nielsen <lrn@google.com>
>
> Change-Id: I360b4347470a0bb2b63c3108e2b83ee2a771bf3f
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362020
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Reviewed-by: Ömer Ağacan <omersa@google.com>
> Reviewed-by: Stephen Adams <sra@google.com>
> Reviewed-by: Leaf Petersen <leafp@google.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: William Hesse <whesse@google.com>

CoreLibraryReviewExempt: Reland
Change-Id: I53db40edc0733842a008839c3913d51c885e39ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362502
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-04-26 15:28:26 +00:00
Johnni Winther dd3fbffac7 [cfe,analyzer] Support new as identifier in metadata
The parser didn't support 'new' as identifier in this context.

The CL also adds the reporting of tear-offs as metadata for the CFE.
This was already handled by the analyzer.

Change-Id: I7ab5868fa83e5f216d0e7be7ae9cec4a2c865e80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364480
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-04-26 14:00:04 +00:00
William Hesse c10ecb8fe5 [test] Convert most lib/mirrors multitests to static error tests
Change-Id: I4f3b728a94291bf0a31a5f38af9d8b877a9900af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363702
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2024-04-23 23:33:48 +00:00
William Hesse cd2c566bcf Revert "Tweak expect.dart library."
This reverts commit ff5f391c0a.

Reason for revert: The expect library is used by Flutter engine, and some of its tests use assertStatementsEnabled. There should be a migration path that doesn't require an atomic change, like adding the replacement api before removing the old one.

Original change's description:
> Tweak `expect.dart` library.
>
> Make API more consistent for a few methods.
> Reduce the number of language features used in tests:
> * Never iterating an iterable, always converting it
>   using `.toList()` first and iterating using indices
>   (fx `setEquals`).
>   Also require a `List` in places where an `Iterable`
>   wasn't necessary.
> * Avoid doing complicated computations that are also
>   used for the error message. Do simple check first,
>   then recompute to get better error messages
>   (fx `allDistinct`).
>
> Renamed some rarely used members for consistency
> (`stringContainsInOrder`->`containsInOrder`,
> where other string-contains functions just start
> with `contains`, and `containsOneOf` -> `containsAny`
> to match `Iterable.any` phrasing, and also it accepts
> if containing at least one, not precisely one.)
>
> Removed a function that wasn't used anywhere.
>
> Moved `assertStatementsEnabled` to `variations.dart` as `asserts`.
> Removed `typeAssertionsEnabled` and `checkedModeEnabled`. The former used in one place, where it was replaced with `checkedImplicitDowncasts` from `variations.dart`, the latter wasn't used anywhere.
>
> Deprecates `package:expect/minitest.dart`. It was never intended
> to be used for new tests, only as a help to convert existing tests
> written against `package:unit_test`.
> All existing imports marked as `// ignore: deprecated_member_use`.
>
> Change-Id: I07e21d4c0f3ccf11b82ee34af2668fdbb22264d2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352360
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Reviewed-by: Ömer Ağacan <omersa@google.com>
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Reviewed-by: Stephen Adams <sra@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

Change-Id: I360b4347470a0bb2b63c3108e2b83ee2a771bf3f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/362020
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: William Hesse <whesse@google.com>
2024-04-09 18:10:57 +00:00
Lasse R.H. Nielsen ff5f391c0a Tweak expect.dart library.
Make API more consistent for a few methods.
Reduce the number of language features used in tests:
* Never iterating an iterable, always converting it
  using `.toList()` first and iterating using indices
  (fx `setEquals`).
  Also require a `List` in places where an `Iterable`
  wasn't necessary.
* Avoid doing complicated computations that are also
  used for the error message. Do simple check first,
  then recompute to get better error messages
  (fx `allDistinct`).

Renamed some rarely used members for consistency
(`stringContainsInOrder`->`containsInOrder`,
where other string-contains functions just start
with `contains`, and `containsOneOf` -> `containsAny`
to match `Iterable.any` phrasing, and also it accepts
if containing at least one, not precisely one.)

Removed a function that wasn't used anywhere.

Moved `assertStatementsEnabled` to `variations.dart` as `asserts`.
Removed `typeAssertionsEnabled` and `checkedModeEnabled`. The former used in one place, where it was replaced with `checkedImplicitDowncasts` from `variations.dart`, the latter wasn't used anywhere.

Deprecates `package:expect/minitest.dart`. It was never intended
to be used for new tests, only as a help to convert existing tests
written against `package:unit_test`.
All existing imports marked as `// ignore: deprecated_member_use`.

Change-Id: I07e21d4c0f3ccf11b82ee34af2668fdbb22264d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352360
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-04-09 14:49:17 +00:00
Srujan Gaddam 2631319edf [dart2wasm] Use node's enclosing library annotation for lowerings
Closes https://github.com/dart-lang/sdk/issues/55359

The current library's annotation is used for the interop lowerings
in dart2wasm. For most members, this is okay because we emit the
equivalent JS code for the member when we visit the procedure and
not when we visit the invocation. However, for methods, the invocation
determines the resulting JS call due to the existence of optional
parameters. In that case, if the invocation was not in the same
library as the interop member declaration, it results in using the
wrong library's annotation value.

Adds tests for this case and does some cleanup of existing tests.

Specifically:
- Adds a consistent naming scheme for test libraries that are
namespaced.
- Adds code to delete the non-namespaced declarations so that the
namespaced interop methods don't accidentally call those declarations.
- Removes differentArgsMethod which was already tested in
js_default_test.
- Removes use of js_util in favor of js_interop_unsafe.

Change-Id: Iac2abe7f11b17b149fb6726c007e1ffa434c3c5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361241
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-04-05 17:43:48 +00:00
Nicholas Shahan 5532568778 [ddc] Add configuration to compile with asserts
- Assertions are enabled in the compiler itself. DDC already enables
  assertions in the test code by default. 
- Runs tests in d8.

Change-Id: Ibdf285d9ab182c3859f4724b4c0740579d6d2377
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349361
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2024-04-04 14:40:30 +00:00
Nicholas Shahan eda91b407d [tests] Add implicit downcast requirements
Some expectations in these tests rely on implicit downcasts throwing
errors at runtime.

Fixes: https://github.com/dart-lang/sdk/issues/55353
Change-Id: Ie1923e26552b95ddb3d4199e0f8f5a2a05e2c124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361004
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-04-04 00:42:24 +00:00
Nicholas Shahan add2f411e6 [web] Add static js interop .call() tests
These tests should help:
 - avoid regressions in the existing behavior
 - highlight incremental improvements towards implementing the
   desired behavior (with corresponding changes to the expectations)
 - identify the differences between the JavaScript and wasm compilers

Change-Id: Ie95233868a13b7ffffc2688ab7c973dcd14ed721
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359246
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2024-04-02 17:03:12 +00:00
Nicholas Shahan 8ca97716cc [dart2js,ddc] Add package:js .call() tests
Some expectations in these tests do not match the language 
specification or are undefined.

These tests should help:
 - avoid regressions in the existing behavior
 - highlight incremental improvements towards implementing the 
   desired behavior (with corresponding changes to the expectations)
 - identify the differences between the JavaScript compilers

Change-Id: Icaa7371b3cf8c4221e4348176f712b3d03196720
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359245
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-04-02 00:41:23 +00:00
Srujan Gaddam d1a949a8e5 Add static tests for external extension members on extension types
We have tests for whether external extension members are allowed
on certain classes, but not extension types.

Also rewords the error to be more accurate.

Change-Id: I61c1fa4c101971986b6c8e7cc778aca94908816a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358380
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-03-26 15:43:19 +00:00
Srujan Gaddam 1232260158 [dart:js_interop] Add ExternalDartReference
Closes https://github.com/dart-lang/sdk/issues/55187

Adds a faster way for users to pass opaque Dart values to
JS without the need for boxing like in JSBoxedDartObject.
This does mean, however, that this new type can't be a JS type,
and therefore cannot have interop members declared on it.
Refactors existing code to handle that distinction.

CoreLibraryReviewExempt: Backend-specific library that's been reviewed by both dart2wasm and JS compiler teams.
Change-Id: Ia86f1fe3476512fc0e5f382e05739713b687f092
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/358224
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-03-26 15:43:19 +00:00
Srujan Gaddam 47f08fb143 [dart:js_interop] Change several operators back to JSBoolean
Related issues:
https://github.com/dart-lang/sdk/issues/55024
https://github.com/dart-lang/sdk/issues/55267

These operators were initially broken in 3.3 and were exposed
as returning JSBoolean but implemented as returning bool. They
were fixed to return bool in the public API, but we should
prefer to have them return JS types as they're likely to be used
in cases where implicit conversions are not useful.

CoreLibraryReviewExempt: Fixing type mismatch in backend-specific library.
Change-Id: I3b0e60550dcac78918f8399d11238dcfa34982cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/359180
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-03-25 17:05:36 +00:00