Commit graph

125 commits

Author SHA1 Message Date
Robert Nystrom 56eaffb392 [flip-patterns] Enable "records" and "patterns" experiment flags.
This turns on the flags for these two language features and makes
them generally accessible.

Doing so causes a number of tests to fail, but the failures are
approved and there are filed issues for them. Most of the
failures are minor or only affect code using the new language
features.

This CL:

- Enables the features in experimental_features.yaml.
- Re-generates all of the various files generated from that.
- Makes some analyzer and front end changes that this CL
  inherited from Paul's original CL flipping all of the 3.0
  feature flags. I don't know what these changes are about, but
  I assume they are necessary.
- Pins a couple of tests to 2.19 since they deliberately test
  behavior that is specific to 2.19. (For most test changes, I've
  landed them separately, but there are a couple of stragglers
  in this CL.)

This doesn't enable "class-modifiers" or "sealed-types" and doesn't
include the core lib changes related to those.

TEST=On bots

Change-Id: Id387753772286a958e20a3589a6e983995f2e4a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286344
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-03-10 20:02:23 +00:00
Jake Macdonald 737b6f7356 [flip-modifiers]: flip the flags for sealed classes and class modifiers
Includes several updates to tests that needed to land with this flip, as well as some other tests that needed to be updated and could land separately, but are being included here to expedite things.

Removes some unnecessary experimental release versions, as well as bringing up to date the generated files, which were previously out of sync with the yaml file.

TEST=bots

Change-Id: I71a86d7a86190069b504bd27d687f62b97a7251e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/285080
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-03-10 05:27:57 +00:00
Robert Nystrom 2496c1a69a [flip-patterns] Fix web switch tests.
Update two tests to Dart 3.0 semantics:

- Switch case constants can be types that don't have primitive equality.
- Switch cases don't need breaks.

Change-Id: Icdea5b66cf12f675580a85b9d49c09db589e29d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287400
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-03-09 01:13:09 +00:00
Jake Macdonald af6e1bf5a4 [flip-modifiers]: prep more tests for the class modifiers flag flip
TEST=only test changes

Change-Id: I725bd897e9e749ab6010c99ee74c20ee64e61500
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286981
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2023-03-06 20:52:03 +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
Jake Macdonald 7910eac426 [flip-modifiers]: opt out failing ddc tests from class modifiers
Change-Id: Ib9187cd63be39b155cd78b1e213b1a5e9cdb3be9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286560
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-03-02 20:27:25 +00:00
Jake Macdonald b83359599e [flip-modifiers]: prep dart2js language tests for class modifiers flag flip
Change-Id: I3eccd65b982628fa9775a94b1ac61b48d8732f80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286540
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2023-03-02 19:09:45 +00:00
Stephen Adams cfa6d0f735 [dart2js] Fix #51558 - skip abstract getters
Improve 'enum switch' optimization to not be confused by abstract
getters.

Bug: 51558
Change-Id: Iac4e5238c1884df6afd1611aecc9f158b1a8b167
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286102
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-03-01 16:41:38 +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
Nicholas Shahan b9699971dc [test_runner] Unify name for passing DDC options
Use "ddcOptions" in test files to closer resemble the name 'ddc-options'
from the test matrix or command line option.

I don't like that this option is in camelCase when written in a test
file but uses a dash when passed on the command line but that matches 
all the other implementations (dart2jsOptions, sharedOptionn, etc). 
Hopefully it is the most discoverable or least surprising choice.

Change-Id: I8f0d53d50416b952c9ea74406c18bb9c700f98dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281820
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-02-14 20:13:57 +00:00
Mayank Patke aa0a7e7083 [ddc] Add dart.web.assertions_enabled environment variable.
Change-Id: If28f2f1404f02c5d757774188a5a006137c8734f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273284
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
2023-02-14 01:35:05 +00:00
Mayank Patke 61b2ec77e1 [dart2js] Automatically set dart.web.assertions_enabled=true.
When (user) assertions are enabled in dart2js, we automatically update
the environment as if -Ddart.web.assertions_enabled=true were
passed. This allows dev-only code to be gated behind
`const bool.fromEnvironment('dart.web.assertions_enabled')` without
having to supply a redundant option manually.

Change-Id: I40d670b6fe87d5e27b2b8d50599261cca8a79a42
Bug: b/254543452
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270301
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-02-14 01:35:05 +00:00
Srujan Gaddam c50a40988a [dart:js_interop/pkg:js] Allow interop on typed_data, errors, and Array
Closes https://github.com/dart-lang/sdk/issues/50899

Allows users to interop with types that have been bound to @Native
types on the JS backends, error types that have been bound in DDC,
and the JS Array type.

Change-Id: Ic28a60127e558eb8bb017595ac54a43920a500c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282483
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-02-13 19:47:25 +00:00
Joshua Litt 130903685d [dart2wasm] Avoid implicitly internalizing WasmExternRef.
CoreLibraryReviewExempt: Wasm only changes.
Change-Id: I0e0a6cddffa1c7f2d7c74779f480dd10bf509c1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279268
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-02-10 16:22:47 +00:00
Mayank Patke 397ed8673c [dart2js] Add phase 1 kernel transformer to simplify const conditionals.
Suppose we have code like

if (isDevMode) {
  // do foo
} else {
  // do bar
}

where isDevMode is const (or can be evaluated as const). In particular,
isDevMode can be controlled by compile-time options, like
bool.fromEnvironment.

We currently eliminate the dead branch during SSA, but that means we do
the work of compiling dead code in the previous phases. Instead, we can
recognize that the condition is const (or effectively const) and
eliminate the dead AST subtree directly.

Change-Id: Ia91da5ebc7fa496a1b963308c6e02d572cab936e
Bug: b/254543452
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270281
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-02-07 20:07:57 +00:00
Aske Simon Christensen bc31fe4903 [dart2wasm] Enable values to be returned from void functions.
Since Dart `void` can actually carry values, functions with `void`
return type are translated into Wasm functions returning the Dart
object top type instead of an empty output type list.

Only constructors, setters and imports/exports with void return type
are now given empty output type lists in their Wasm signatures. A new
low-level `WasmVoid` type is added to the internal Wasm types for
specifying explicitly that a Wasm function should have an empty list
of outputs.

Fixes https://github.com/dart-lang/sdk/issues/50458

CoreLibraryReviewExempt: Only changes Wasm-specific libraries.
Change-Id: I9562248f94e75a60142fd1af0136183aa288b98b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279971
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2023-02-02 12:08:30 +00:00
Stephen Adams 5164ecd5ec [dart2js] Add test for issue 51179
http://dartbug.com/51179 - the defaulted value of `s1` is `null` instead of the correct string `'default value'`.

Bug: 51179
Change-Id: I437d95d8a4a273fd014a005f6c40a9be05f45d2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280138
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-02-01 03:29:49 +00:00
Ahmed Ashour 63180b95ed Remove superfluous words.
Fixes #51095

TEST=ci

CoreLibraryReviewExempt: There are no API changes, just removal of superfluous words in the comments.
Change-Id: Ib1020c62fe6baed5ca68f0074323f025cc90e9f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279500
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-01-30 15:58:38 +00:00
Aske Simon Christensen e805b776bc [dart2wasm] Use status files for defining which tests to run
This makes it easier to run tests locally, just specifying the suites
`co19 corelib language lib web` to `test.py`.

It also make it easier to change which tests we run going forward.

Change-Id: I3a4765c18ee105055fdb9a6b59036da11b956e1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279973
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
2023-01-30 10:42:22 +00:00
Jackson Gardner 4dff36345e [dart2wasm] Use the asset in @Native annotations to specify the module name.
Change-Id: I5e3644a904917a375486acd47830f311fe19a5ce
Tested: Running unit tests in this repo as well as running against coming web engine changes that use the @Native annotation: https://github.com/flutter/engine/pull/39072
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279479
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2023-01-28 00:03:07 +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
Josh Soref 01b28894e7 Spelling pkg dev compiler
Closes https://github.com/dart-lang/sdk/pull/50861

GitOrigin-RevId: 71005e6f5bf5a151cb5c1aefb6a2a300fc40f592
Change-Id: Iadfafb5787a62e9a379437f6a3763d31f99ba7c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277743
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-01-26 09:12:41 +00:00
Joshua Litt abae306239 [dart2wasm] Add more test coverage for int in static interop APIs.
Change-Id: I6f77eeefb14e557be65c09a56ed814ab1702fac2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278804
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-01-19 04:46:47 +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
Aske Simon Christensen b8f0fda3dd [dart2wasm] Switch to the new WasmGC test/cast instructions
Also implements various related changes to the WasmGC spec:
- Remove `dataref` and add `structref` and `arrayref`.
- Use new encoding for `array.len` without immediate.

Change-Id: Ic1ba67fad694c453fbdae277f5a7e4c94695977f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266200
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2023-01-12 14:08:56 +00:00
Joshua Litt 20a07e8073 [dart2wasm] 'Fix' hashCode for JSValue.
Change-Id: I2b071a24be8b2254ed2a696f901a5aacb034a4b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278813
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-01-11 02:27:43 +00:00
Josh Soref 1ab011a2a7 Spelling tests web
Closes https://github.com/dart-lang/sdk/pull/50879

TEST=only changes to spelling to comments and internal string messages
GitOrigin-RevId: 3fa4104fa17054ea2247118a1b6213c62f2749e0
Change-Id: I776120bb2492c662dd32612dd2f6a670b5891e42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278060
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-01-05 01:26:52 +00:00
Nate Biggs 398d47cd10 [dart2js] Add priority to dartDeferredLibraryLoader hook.
Change-Id: Ib77b20fc56aa67b4f3318f9dcd8fa65b62c56509
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275800
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-12-20 15:39:09 +00:00
Josh Soref df97aca1fa Spelling tests
Closes https://github.com/dart-lang/sdk/pull/50764

GitOrigin-RevId: ee2fe9a75d50e877f4ad2fe3743acdbc04f186ef
Change-Id: Ia73cd22da4e6ec95e84772aa4e1345ce2dbde215
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276360
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2022-12-19 12:56:47 +00:00
Jackson Gardner 81a63dafe5 [ffi] Convert ABI-specific integers to fixed-width integers when doing wasm FfiNative transformation.
It's a bug if a class has more than one `@AbiSpecificIntegerMapping`
annotation. Reflect this in the return type of method for getting the
annotation and issue a diagnostic if the invariant doesn't hold.

The invariant is checked by `_FfiDefinitionTransformer`.

Change-Id: Iadf4636090c6ec814f623c9245b3a1fe8b466b4b
Tested: Unit tests written with all ABI specific integer types.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268105
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2022-11-08 22:16:28 +00:00
Joshua Litt d4db1e8f8e [dart2wasm] Disable disallowed external check.
Bug: 50381
Change-Id: I2344a4d5c5b91acc44efb5d0c1ee10386eedd12c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268061
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2022-11-04 21:17:55 +00:00
Joshua Litt d43dd08a26 [dart2wasm] Add regression test for js interop method rename.
Change-Id: I90867d6a3d14e0fb8c2fdbe94ae1390af0544ffd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267880
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2022-11-04 02:06:49 +00:00
Joshua Litt 1686e88a31 [dart2wasm] Add regression test for non-external factory constructor.
Change-Id: I1e29f28b98ad360e7cd65703d27fa47e49e339e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267768
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2022-11-03 22:47:23 +00:00
Joshua Litt bf9c703186 [dart2wasm] Support tearoffs of generic classes in JS interop.
Change-Id: I6e01e2cadc8f92a6f6ab2d1e4e794dfd083f900d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266302
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2022-10-28 18:31:04 +00:00
Alexander Thomas 0b26f4816b [testing] Remove --compiler=none from test.py
* Use dartk as the default compiler for runtime=vm.
* Status file entries for checking for the `none` compiler now either
  use dartk or are deleted.

Tested: Standard CQ and local testing.
Fixes: https://github.com/dart-lang/sdk/issues/50241
Change-Id: I7a08d3e491ae1c82a0348fb66ea7b557398f97e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264682
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2022-10-19 08:09:58 +00:00
Srujan Gaddam b6526beeab [pkg:js] Disallow staticInterop generative constructors
Fixes https://github.com/dart-lang/sdk/issues/48730

Change-Id: I4c7f687ec8d2724de0e031aa5ebe887f93843761
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254101
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-18 17:47:29 +00:00
Sigmund Cherem 770c9d77c5 [typed_data] Fix breakage introduced in recent change.
This fixes a regression introduced by
https://dart-review.googlesource.com/c/sdk/+/254501. The change
accidentally excluded some  clauses. This was not detected by the
CFE (it should be a static error), and as a result unsound
optimizations were made by dart2js.

Fixes https://dart-review.googlesource.com/c/sdk/+/254501

Change-Id: Iff52cba277546f2a9fab3c2c2736410d272dad7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264601
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2022-10-18 01:16:27 +00:00
Joshua Litt 29de68d38e [dart2wasm] Correctly handle null when jsifying maps.
Change-Id: Ibda04bf6012447dcab86079da8d4d41771e8e9bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262102
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2022-09-30 21:09:29 +00:00
Joshua Litt c6b141e9e5 [dart2wasm] Fix bug in dartify.
Change-Id: Ia922d3ac6e3849db13877259c65c7d8d884c5828
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262100
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2022-09-30 18:14:07 +00:00
Ömer Sinan Ağacan affc3392a0 [dart2wasm] Implement Wasm FfiNative support
This CL introduces a new kernel-to-kernel pass in Wasm backend to
compile `FfiNative`-annotated external functions to external functions
with `wasm:import` pragmas.

The new pass `WasmFfiNativeTransformer` extends `FfiNativeTransformer`.
Some `FfiNativeTransformer` methods made public to allow reuse in the
pass.

The conversion works like this: when we see a member like:

    @FfiNative<Int8 Function(Int8, Int8)>("ffi.addInt8")
    external int addInt8(int a, int b);

We generate a Wasm import using Wasm ABI types according to emscripten
calling conventions:

    @pragma('wasm:import', 'ffi.addInt8')
    external static WasmI32 addInt8_$import(WasmI32 a, WasmI32 b);

and convert the original member (`addInt8()`) to a wrapper function that
calls the Wasm import, converting the arguments and return values to
Dart types:

    static int addInt8(int a, int b) {
      return WasmI32.toIntSigned(
        addInt8_$import(
            WasmI32::int8FromInt(a),
            WasmI32::int8FromInt(b),
        ));
    }

Build, test, and CI changes:

- Test runner now uses `// SharedObjects=...` lines in dart2wasm tests
  to pass extra Wasm modules to d8 command used to run the tests.

  Support for `// SharedObjects=...` lines were already used in
  native/AOT FFI tests, not added in this CL. We just start to use those
  lines in dart2wasm tests.

- dart2wasm gn file updated with a target "test_wasm_modules" that
  builds FFI test Wasm modules to Wasm using emcc (emscripten C
  compiler).

- CI dart2wasm_hostasserts configuration updated to copy the Wasm files
  generated by the "test_wasm_modules" target to the shards.

TEST=tests/web/wasm/ffi_native_test

Change-Id: I6527fe4e2ca2b582e16d84fee244e9cbe6dee307
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252822
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2022-09-23 09:41:22 +00:00
Joshua Litt fea406591e [dart2wasm] Fix for tearoffs in allowInterop.
Change-Id: Ic753bb22af345e4825f2a142fa262504a562e7c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260283
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-22 03:04:17 +00:00
Joshua Litt 8429f01593 [dart2wasm] Implement optional parameters for JS interop callbacks.
Also added tests of optional parameters for static interop functions.

Change-Id: Id23237b96d0de5a4a4b948b3f23fd1bfe40b218e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259101
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-14 22:33:02 +00:00
Joshua Litt 6c36674dd8 [dart2wasm] Support returning ints from JS via static interop.
Change-Id: I20e08d9afcd567edf34de0cd9b9ad95a3e2663d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258501
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2022-09-09 21:21:34 +00:00
Joshua Litt 014818bf8e [dart2wasm] Implement js_util.instanceof.
Also fixes performanceNow for Chrome.

Change-Id: I1b70610a8a1a44c0f0e3ce7b166f32f9915324c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258504
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-09 20:40:34 +00:00
Aske Simon Christensen 9af959c167 [dart2wasm] Coerce types on imports/exports to externref or funcref
Change-Id: Id7fe0775e14b7ed16c925819ffc9c41dea863e4d
Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258001
Auto-Submit: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-09 18:10:34 +00:00
Joshua Litt b04641f37d [dart2wasm] Fix @JS name parsing for factory constructors.
Change-Id: Iad6886a794b6ed5395177a3e45f69f10484fc703
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258382
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-09 17:29:47 +00:00
Joshua Litt eb540194ad [dart2wasm] Implement promiseToFuture.
Change-Id: I265441c5c78933f8bdace53f956d22677442d7fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257803
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-07 17:56:17 +00:00
Joshua Litt 2b85e02c5d [dart2wasm] Implement == for JSValue.
Change-Id: I45af5bdabfb0dfa12b6b39094843b9394f4fe510
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257923
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-07 16:37:17 +00:00
Lasse R.H. Nielsen 5642199dd0 Remove uses of : as default value separator in some tests/ directories.
Change-Id: I35bb926e53e92fd02e264fb5b14feadf063fb8db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257961
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2022-09-07 14:49:17 +00:00