Commit graph

163 commits

Author SHA1 Message Date
Srujan Gaddam eb8e3d549a [dart:js_interop] Add new diagnostic reporter so we can avoid transforms
Adds a delegating reporter so we can keep track of whether there are
interop errors. If there are, we do not do the transforms on the JS
backends.

Change-Id: Ib0f36b748443cb7fe8f8bb427692d653557d59fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304261
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-05-18 18:53:03 +00:00
Zach Anderson 1b9198c679 Revert "[dart:js_interop] Disallow ffi and JS interop in the same library"
This reverts commit 1c5d23e8a2.

Reason for revert: https://github.com/flutter/flutter/issues/127027

Original change's description:
> [dart:js_interop] Disallow ffi and JS interop in the same library
>
> dart2wasm can use both dart:ffi and JS interop libraries. To avoid
> confusion around external members, this disallows JS interop from
> being used in the same library as dart:ffi.
>
> Change-Id: I53e0426306be99c43b2bbfc14d65075128f0d5c5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301200
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Joshua Litt <joshualitt@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

Change-Id: I1fd872e6d0cd679ec9c1842557745647385ec3af
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304100
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-05-17 16:15:36 +00:00
Srujan Gaddam 1c5d23e8a2 [dart:js_interop] Disallow ffi and JS interop in the same library
dart2wasm can use both dart:ffi and JS interop libraries. To avoid
confusion around external members, this disallows JS interop from
being used in the same library as dart:ffi.

Change-Id: I53e0426306be99c43b2bbfc14d65075128f0d5c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301200
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-05-16 22:50:46 +00:00
Srujan Gaddam 5225b3d408 [ddc] Remove @staticInterop runtime type in favor of erasure
While we can't modify the kernel ASTs due to modular compilations, we
can change the type we emit instead of using a runtime @staticInterop
type. This CL refactors the erasure so that DDC can use it to emit
JavaScriptObject instead of StaticInteropType.

Change-Id: I9cbeaa2127e50702d2bdf6aeedb2744b7ece33c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295392
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-05-16 01:37:28 +00:00
Nicholas Shahan d7fc9ca3cc [ddc] Add get and set proto inlined helpers
The helper methods make it easier to call the JS version of
`Object.getPrototypeOf()` and `Object.getPrototypeOf()` from the
SDK libraries. The body gets inlined directly to avoid extra method 
calls in potentially hot code paths.

Start using the setter when setting base and extension classes.

Issue:https://github.com/dart-lang/sdk/issues/52372
Change-Id: I6ca70cbf1936f76f24c8843e51c1c47e9bfe659c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303009
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-05-12 23:38:38 +00:00
Jackson Gardner 48346c458a Static interop stuff might also be in ui_web, so it needs to be added
to the list.

This should fix https://github.com/dart-lang/sdk/issues/52364

Change-Id: Id6ab25ee48da4027adee89e91868bde5b07b4ac2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303002
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
Reviewed-by: Mouad Debbar <mdebbar@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-05-12 18:25:59 +00:00
Srujan Gaddam 29e814357c [pkg:js] Lower external @staticInterop and extension members using invocation-level semantics
We've changed the semantics for these members using dart:js_interop
so that not passing in optionals on the Dart side is equivalent to
not passing in optionals on the JS side. This CL makes that consistent
with package:js as well.

Modifies CHANGELOG to announce breaking change.

Change-Id: Ic5c33c9c797983a72edec9bc59f60fc1f29240b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300400
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-05-09 23:12:58 +00:00
Srujan Gaddam 8cbd946338 [dart:js_interop] Disallow tear-offs of external members
Disallows tear-offs for all interop members when using
dart:js_interop, and disallow tear-offs of @staticInterop and
extension external members. Creates tear-off indexes in
InlineExtensionIndex to keep track of tear-off methods that
the CFE generates.

Modifies the CHANGELOG to communicate the breaking change.

Change-Id: I900fdfd6ee6b198f2f34e9d9fd5f3d9c964680e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299800
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-05-09 23:12:58 +00:00
Joshua Litt 85afd7bf30 [js] Add proper error message for incorrect usage of Function.toJS.
Change-Id: Id38166f9e9a2c56a73840de212f2e3f6388ad2ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298240
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-05-02 15:25:38 +00:00
Srujan Gaddam c4d354dc2a Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations"
This reverts commit 4919729f00.

This CL also adds back in logic to handle older package:js versions to avoid
failures in our static checking. It also supports dart:js_interop's @JS
annotation since it can now be used for @staticInterop classes.

CoreLibraryReviewExempt: Reland of backend-specific library changes.
Change-Id: I104653a9a6b2593f6bab658808287e2074c18550
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294130
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-02 15:24:18 +00:00
Joshua Litt 47b7c1f31d [js] Add js_interop_unsafe library.
CoreLibraryReviewExempt: Web only library.
Change-Id: I4d6007e0731ecae81fcc614168baee7d5e662fd8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293743
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-04-27 18:51:49 +00:00
Srujan Gaddam 1d28f8e821 [dart:js_interop/ddc/dart2js] Implement JS types using @staticInterop
Currently, dart:_js_types types are all typedefs in the web backends.
This leads to inconsistent semantics, since you can statically pass
Strings to JSString, for example. You cannot do this in dart2wasm.
In order to ensure consistent semantics, we reify these types using
a custom @staticInterop lowering. They all get erased to their
respective Dart type. When we have inline classes, these types
should be implemented using inline classes.

Note that Interceptor will not work for this use case. The reified
type of JS primitives are Dart types e.g. String, bool, and therefore
can not be casted to Interceptor.

In order to do this, the eraser is refactored and the JS backends use
shared erasure code to either erase/emit types.

Tests are added to make sure you need to go through a conversion or
cast to pass Dart objects to JS types.

CoreLibraryReviewExempt: Backend-specific internal library changes.
Change-Id: I5942be628102919ec167f094cfe10fced606363c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295105
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-04-26 15:55:54 +00:00
Srujan Gaddam 91f2d6a621 [dart:js_interop] InlineExtensionIndex should handle multiple libraries
Since we no longer only do lowerings at the declaration site, the
InlineExtensionIndex class needs to handle libraries besides the
current library. This is because when lowering at the invocation
site, the target might not be in the current library.

Change-Id: Ifcf6cc63ce7e6f86b3408c9830e1244215598bf6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296381
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-04-19 20:18:47 +00:00
Joshua Litt c4167766f2 [js] Restrict imports in strict mode.
Change-Id: I90cdf408e60cf8115c6321448623cf363dc92f66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292960
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-04-18 17:21:27 +00:00
Srujan Gaddam 568469b896 Reland "[dart:js_interop] Export some package:js annotations and check them"
This reverts commit df761ba9e7.

This also rebases the original CL onto HEAD so it can be landed first.

CoreLibraryReviewExempt: Reland of backend-specific library changes.
Change-Id: I4f9a017be3ec1924c021f941291d79d7aee06663
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294131
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-04-12 18:15:00 +00:00
Zach Anderson 4919729f00 Revert "Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations""
This reverts commit 9e1997971e.

Reason for revert: Breaks Dart -> Engine roll?

See:
https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20linux_web_engine/1821/overview
https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20Engine%20Drone/666824/overview

Original change's description:
> Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations"
>
> This is a reland of commit fbe9c21972
>
> This fixes the issue with the duplicate allowPlatformPrivateLibraryAccess.
>
> Original change's description:
> > [pkg:js/dart:js_interop] Move annotations to dart:_js_annotations
> >
> > This moves package:js annotations to the internal library that
> > Flutter has been using already. This gives us a single location
> > for all package:js annotations. We also introduce a @JS annotation
> > in dart:js_interop since we can no longer use dart:_js_annotations
> > to avoid the breaking change in semantics.
> >
> > CoreLibraryReviewExempt: Backend-specific internal library.
> > Change-Id: I9ca55c807d7d192004a6da99f63a72d598fe4f12
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284760
> > Commit-Queue: Srujan Gaddam <srujzs@google.com>
> > Reviewed-by: Samuel Rawlins <srawlins@google.com>
> > Reviewed-by: Johnni Winther <johnniwinther@google.com>
> > Reviewed-by: Joshua Litt <joshualitt@google.com>
>
> CoreLibraryReviewExempt: Relanding.
> Change-Id: I40ff2a00682fccbd7dd44a364b5046aaac0f3bac
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293203
> Reviewed-by: Joshua Litt <joshualitt@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>

Change-Id: Ide8609575c73d714f3ae4f9ea9ffc74e228fa189
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293962
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2023-04-06 14:43:18 +00:00
Zach Anderson df761ba9e7 Revert "[dart:js_interop] Export some package:js annotations and check them"
This reverts commit ef7d8d3f9a.

Reason for revert: Breaks Dart -> Engine roll?

See:
https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20linux_web_engine/1821/overview
https://ci.chromium.org/ui/p/flutter/builders/try/Linux%20Engine%20Drone/666824/overview

Original change's description:
> [dart:js_interop] Export some package:js annotations and check them
>
> To disallow package:js on dart2wasm, we need to export @staticInterop
> and @anonymous through dart:js_interop. However, users should not mix
> the two @JS annotations, so we add some static checks for that. We also
> export @JSExport to support export classes with dart:js_interop.
>
> CoreLibraryReviewExempt: Reexporting annotations through backend-specific library.
> Change-Id: I54610965da332320170d991d785192341049607e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293500
> Reviewed-by: Joshua Litt <joshualitt@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

Change-Id: I2af0755e054a1b0452a5fc617a93257209703793
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293961
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Zach Anderson <zra@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2023-04-06 14:42:36 +00:00
Srujan Gaddam ef7d8d3f9a [dart:js_interop] Export some package:js annotations and check them
To disallow package:js on dart2wasm, we need to export @staticInterop
and @anonymous through dart:js_interop. However, users should not mix
the two @JS annotations, so we add some static checks for that. We also
export @JSExport to support export classes with dart:js_interop.

CoreLibraryReviewExempt: Reexporting annotations through backend-specific library.
Change-Id: I54610965da332320170d991d785192341049607e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293500
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-04-06 00:29:12 +00:00
Srujan Gaddam 9e1997971e Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations"
This is a reland of commit fbe9c21972

This fixes the issue with the duplicate allowPlatformPrivateLibraryAccess.

Original change's description:
> [pkg:js/dart:js_interop] Move annotations to dart:_js_annotations
>
> This moves package:js annotations to the internal library that
> Flutter has been using already. This gives us a single location
> for all package:js annotations. We also introduce a @JS annotation
> in dart:js_interop since we can no longer use dart:_js_annotations
> to avoid the breaking change in semantics.
>
> CoreLibraryReviewExempt: Backend-specific internal library.
> Change-Id: I9ca55c807d7d192004a6da99f63a72d598fe4f12
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284760
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Joshua Litt <joshualitt@google.com>

CoreLibraryReviewExempt: Relanding.
Change-Id: I40ff2a00682fccbd7dd44a364b5046aaac0f3bac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293203
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-04-05 23:20:15 +00:00
Srujan Gaddam 55e60cb982 Revert "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations"
This reverts commit fbe9c21972.

Reason for revert: Rebase leads to additional definitions of allowPlatformPrivateLibraryAccess in dart2wasm.

Original change's description:
> [pkg:js/dart:js_interop] Move annotations to dart:_js_annotations
>
> This moves package:js annotations to the internal library that
> Flutter has been using already. This gives us a single location
> for all package:js annotations. We also introduce a @JS annotation
> in dart:js_interop since we can no longer use dart:_js_annotations
> to avoid the breaking change in semantics.
>
> CoreLibraryReviewExempt: Backend-specific internal library.
> Change-Id: I9ca55c807d7d192004a6da99f63a72d598fe4f12
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284760
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Joshua Litt <joshualitt@google.com>

Change-Id: I87c5510f7ec9bc059d4c17a354188222ac7e8cba
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293201
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-04-04 16:41:28 +00:00
Srujan Gaddam fbe9c21972 [pkg:js/dart:js_interop] Move annotations to dart:_js_annotations
This moves package:js annotations to the internal library that
Flutter has been using already. This gives us a single location
for all package:js annotations. We also introduce a @JS annotation
in dart:js_interop since we can no longer use dart:_js_annotations
to avoid the breaking change in semantics.

CoreLibraryReviewExempt: Backend-specific internal library.
Change-Id: I9ca55c807d7d192004a6da99f63a72d598fe4f12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284760
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-04-04 15:55:29 +00:00
Srujan Gaddam 21926e8aec [dart:js_interop] Use InlineExtensionIndex in js_interop_checks
Removes unnecessary helpers now that we have InlineExtensionIndex.
Also removes a bug where we couldn't declare interop members
without a library declaration and adds a test. Comments out a
tear-off test that works now that they're supported by the CFE.

Change-Id: I7821c9976e4d155e3c38326691769c400a2b9844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292240
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-04-04 00:22:24 +00:00
Aske Simon Christensen 7196bb2d03 [dart2wasm] Allow non-strict JS interop in the flute benchmark
Change-Id: I3cc270b9deace30f95ee44f2603af26aca81ce38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292023
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2023-03-31 07:59:48 +00:00
Joshua Litt 04896c7f90 [js] Add strict mode checks.
This CL adds support for strict mode, but disables it in tests and
allowed packages.

Change-Id: I834bc5a0e88868b282c3901361f7a90e1f9eeb3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289621
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-03-22 14:07:43 +00:00
Srujan Gaddam 65e0bd3fca Reland "[dart:js_interop] Add literal constructors for inline classes"
This reverts commit 49f85335d5.

Reason for revert: Fixes the original breakage by adding an explicit
cast for the map function that's used to compute positional args
of the stub. Adds refactoring to better separate out the logic
between procedure-level and invocation-level lowering configs.

Also refactors optional argument functions so that they can use the
invocation-level lowering configs created in this CL. Also fixes
a small issue where object literal constructors wouldn't work in
dart2js if the surrounding library didn't have a @JS annotation.

Original change's description:
> Revert "[dart:js_interop] Add literal constructors for inline classes"
>
> This reverts commit 1f6d4ae1a8.
>
> Reason for revert: Broke Flutter with dart2wasm
>
> Original change's description:
> > [dart:js_interop] Add literal constructors for inline classes
> >
> > Adds @ObjectLiteral annotation to denote object literal constructors,
> > and implements it in all the backends. For dart2js, this involves
> > modifying the SSA and for dart2wasm, we create a one-per-shape
> > forwarding procedure to a specialized JS method that returns the
> > literal. This also modifies @anonymous semantics in dart2wasm to
> > be consistent with the other backends.
> >
> > CoreLibraryReviewExempt: Backend-specific, just adding annotation.
> > Change-Id: I4d7a9ea9ed097f4f378709b40f8bd74f02e26b23
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283922
> > Commit-Queue: Srujan Gaddam <srujzs@google.com>
> > Reviewed-by: Joshua Litt <joshualitt@google.com>
>
> Change-Id: Ifce611e1150d8aa275f9e312743bded56a572176
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285342
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Reviewed-by: Joshua Litt <joshualitt@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>

CoreLibraryReviewExempt: Reland.
Change-Id: Iac52e9ff152dc06788d78b7b18549c7005921b74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285346
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-03-20 17:41:49 +00:00
Joshua Litt c828440c79 [js] Erase types in _skwasm_impl.
Change-Id: If6375a383b84c4eeb2ad90a8bf544d725d9502a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289025
Auto-Submit: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
2023-03-16 17:04:17 +00:00
Johnni Winther f17cf33c6d [kernel] Move Pattern nodes to package:kernel
These AST nodes were so far internal to the CFE, but since we need to
move the pattern lowering to the constant evaluator we need to support them in the AST defined in package:kernel.

TEST=existing

Change-Id: Ie6c5f0f8ad75a866c5d965fdf506bc869ffaf654
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288241
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-03-13 08:43:07 +00:00
Johnni Winther 04e6f4c282 [kernel] Add VariableDeclaration.isSynthesized
This adds an [isSynthesized] flag to the [VariableDeclaration] the
signal when the variable doesn't correspond to a variable in the
source code.

The name of a variable can only be `null` if it is synthesized.

Partially in response to
https://github.com/dart-lang/sdk/issues/51554

TEST=existing

Change-Id: I94591971f11da09d210c8b25a2d05e22ca05dc62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286961
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-03-10 11:13:36 +00:00
Joshua Litt c36862af90 [js] Specialize optional arguments at call sites.
Change-Id: I59b10242a5d85907c21fc99eaf1eff15b39d7191
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285701
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-03-06 19:59:32 +00:00
Srujan Gaddam 49f85335d5 Revert "[dart:js_interop] Add literal constructors for inline classes"
This reverts commit 1f6d4ae1a8.

Reason for revert: Broke Flutter with dart2wasm

Original change's description:
> [dart:js_interop] Add literal constructors for inline classes
>
> Adds @ObjectLiteral annotation to denote object literal constructors,
> and implements it in all the backends. For dart2js, this involves
> modifying the SSA and for dart2wasm, we create a one-per-shape
> forwarding procedure to a specialized JS method that returns the
> literal. This also modifies @anonymous semantics in dart2wasm to
> be consistent with the other backends.
>
> CoreLibraryReviewExempt: Backend-specific, just adding annotation.
> Change-Id: I4d7a9ea9ed097f4f378709b40f8bd74f02e26b23
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283922
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Joshua Litt <joshualitt@google.com>

Change-Id: Ifce611e1150d8aa275f9e312743bded56a572176
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285342
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-02-24 20:42:14 +00:00
Srujan Gaddam 1f6d4ae1a8 [dart:js_interop] Add literal constructors for inline classes
Adds @ObjectLiteral annotation to denote object literal constructors,
and implements it in all the backends. For dart2js, this involves
modifying the SSA and for dart2wasm, we create a one-per-shape
forwarding procedure to a specialized JS method that returns the
literal. This also modifies @anonymous semantics in dart2wasm to
be consistent with the other backends.

CoreLibraryReviewExempt: Backend-specific, just adding annotation.
Change-Id: I4d7a9ea9ed097f4f378709b40f8bd74f02e26b23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283922
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-02-23 01:14:39 +00:00
Devon Carew f39365c8e5 [pkg/_js_interop_checks] use package:lints/recommended.yaml
Change-Id: Ia8024f6f5a2185c1ac6d6dc666c9e246f5131c52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282391
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2023-02-14 19:17:26 +00:00
Joshua Litt ff43c6e1f0 [js] Add limited support for operators.
Change-Id: I40f8ea6666272a68afd867c095066de2c6416816
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282620
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-02-14 18:03:42 +00:00
Srujan Gaddam 2fc8685a4d [dart:js_interop] Add support for external inline and extension instance members
External inline instance members can be lowered the same way as
external extension instance members on interop classes. Similarly,
code is refactored so that external extension members can exist
on inline interop classes and are lowered accordingly.

Change-Id: I341bfeef3f1b74b54a63c963553af9230c4a10c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280621
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-02-11 00:03:57 +00:00
Srujan Gaddam e6e1040afc [dart:js_interop] Expose dart:_js_interop
Types still need to be sealed, so this library is exposed with a
disclaimer that users should not subtype any types.

CoreLibraryReviewExempt: Backend-specific library for JS and Wasm.
Change-Id: I2ed8b0db6b2de60932a551047c6c9eae4a34ce2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281343
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-02-10 01:41:50 +00:00
Joshua Litt bd79be0e19 [js] Move allowInterop functions to dart:js_util.
CoreLibraryReviewExempt: Has core library owners approval.
Change-Id: Iea2f2e707c69c9082e158b48b50dcaf4a7b01067
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279740
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-02-08 17:16:20 +00:00
Srujan Gaddam ff01414b8f [dart:_js_interop] Add support for statically resolvable inline class interop members
Amends lowerings on dart2wasm and JS backends to work for external
constructors/factories and static members. Tests members with and
without renaming of members/classes/libraries. Note that this does
not add support for object literal factories yet.

Change-Id: I149bef7249c1a13a31eed9f3510256d407b1d3e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280056
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-07 18:47:23 +00:00
Joshua Litt 99a9f3d516 [js_types] MVP of JS types.
Change-Id: Ic329146a270ff32fc2cdb32febc6f574bc81792f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280131
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-02-02 21:29:01 +00:00
Srujan Gaddam 50602e581a [pkg:js] Only lower external extension members on interop classes
We have a static check to avoid users using these members on
other types, but patch files need to support these, so we need
to avoid lowering in some cases. Note that this supports both @JS
and @Native classes.

Change-Id: I6503c4dd24793381f4a16131ab99d376c637bb66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280125
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-01-31 06:03:28 +00:00
Joshua Litt a64b34d3f3 [dart2wasm] Use static interop to implement regexp helpers.
This CL also adds changes how static interop objects are interpreted at the interop boundary. Previously, static interop objects were dartified / jsified like everything else. Now, they are simply boxed.

With this approach, users can now use `Object` when they want conversions and static interop objects when they don't(assuming these objects originate in JS, Dart objects are always fully converted).

Change-Id: I40b31bfb826e4963a34eaa373574c136e13b9009
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279451
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-01-26 17:03:40 +00:00
Srujan Gaddam 45817fd9c7 [Reland][pkg:js] Lower @staticInterop non-anonymous constructors
This is a reland of https://dart-review.googlesource.com/c/sdk/+/279180.
This removes the anonymous constructor lowering, as the jsify
semantics are not the same as what we have today, since we do no
conversions today. This avoids the breakage in Flutter where we
convert a Uint8List in jsify.

Change-Id: I7eb4ffbd3258abdf6c1aea2035f7dab0336d4851
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279231
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-01-25 18:50:27 +00:00
Srujan Gaddam 34ab46ab33 [pkg:js] Add dart:_engine to denylist for top-level lowerings
Along with dart:ui, dart:_engine also uses dart:_js_annotations
and therefore needs to be in this denylist to avoid a breaking
change.

Change-Id: Id60d278a9a3d8bc20c05ac895152d2aaacfb36de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279260
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
2023-01-18 21:38:50 +00:00
Srujan Gaddam f93b5482af [pkg:js] Transform childen in export creator
We should visit the children of StaticInvocations, as they may
contain calls to createDartExport.

Change-Id: Ib2d91a60c48f3d2ddb5c6ef385114ea343d591ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279071
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2023-01-18 21:34:35 +00:00
Srujan Gaddam 75f2db6337 Revert "[pkg:js] Lower @staticInterop external anonymous and non-anonymous constructors"
This reverts commit 9c8051b3ee.

Reason for revert: b/265769171, broke a number of google3 targets

Original change's description:
> [pkg:js] Lower @staticInterop external anonymous and non-anonymous constructors
>
> Lowers external factories on non-anonymous classes to a callConstructor
> invocation and lowers external anonymous factory invocations to a jsify
> call taking in only the arguments that were passed. In a future CL,
> tear-offs of external anonymous factories will be disallowed.
>
> Change-Id: I288230f24435fac8a15079f54bddce1c2c1a6521
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277049
> Reviewed-by: Sigmund Cherem <sigmund@google.com>

TBR=sigmund@google.com,srujzs@google.com,rileyporter@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: Ice0718b169aa1cdc3bc1d1ad5bcab1d6a88e3149
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279180
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-01-17 17:29:07 +00:00
Srujan Gaddam 0673894cd9 [pkg:js] Disallow @staticInterop synthetic and @anonymous constructor tear-offs
Generative synthetic constructors of @staticInterop classes are already
disallowed, but this adds errors for tear-offs of such members as well.
This also disallows tear-offs of @anonymous @staticInterop factory
tear-offs. This aligns with what we want to do with object literal
constructors going forward, as tear-offs will implicitly have different
semantics than direct invocations. To avoid that inconsistency, we
disallow tear-offs here.

Change-Id: Ifc9e4a9251743613ee1ea2eca6e42e36c3b20461
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278645
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-01-16 22:31:33 +00:00
Srujan Gaddam 9c8051b3ee [pkg:js] Lower @staticInterop external anonymous and non-anonymous constructors
Lowers external factories on non-anonymous classes to a callConstructor
invocation and lowers external anonymous factory invocations to a jsify
call taking in only the arguments that were passed. In a future CL,
tear-offs of external anonymous factories will be disallowed.

Change-Id: I288230f24435fac8a15079f54bddce1c2c1a6521
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277049
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-01-16 22:31:33 +00:00
Srujan Gaddam bb2092368c [pkg:js] Lower external top-level package:js members
Lowers top-level external package:js members to their respective
js_util transformation, taking into account any namespacing in the
member's name. We only do this transformation for code that uses the
@JS annotation from dart:_js_annotations and isn't from dart:ui. This
is to avoid a breaking change for Dart 3. As such, we allow
dart:_js_annotations to be used in some test paths. In the future, we
will export the dart:_js_annotations @JS annotation through
dart:js_interop instead.

Change-Id: I3b92a3a8cd1340c50913b9df6fdc743e2790259e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277048
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-01-16 22:31:33 +00:00
Srujan Gaddam 1e06e37e18 [pkg:js] Lower external static @staticInterop class members
Lowers external static class members (fields, getters, setters, methods)
on a @staticInterop class to their respective js_util transformations.
Tests are added for a non-namespaced and a namespaced library.

Change-Id: Ife0b53c05310e924ebfbcf2059f6048ae8447c2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277047
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-01-16 22:31:33 +00:00
Joshua Litt f9cd2e2158 [dart2wasm] Specialize JS methods based on receiver.
Change-Id: I48f1841e51ef8b67802909254d4a30b83c700e52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273010
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-01-13 14:41:09 +00:00
Josh Soref 46ee7eb873 Spelling samples
Closes https://github.com/dart-lang/sdk/pull/50919

TEST=ci

GitOrigin-RevId: 5ac389ee109d6a06f89d405da916945c36e1d24d
Change-Id: Ica078a14e87234459c0703c41c8bae5157132b14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278532
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-01-09 17:44:29 +00:00