Right now a JS interop callback works like this:
* Each wasm module that gets instantiated will be given it's module
instance (JS calls Dart to set it) via `setThisModule`
* When Dart code calls JS and gives it a callback to invoke, it gave it
this module instance. It will also make the callback wasm function
weakly exported.
* The JS trampoline code, when invoked, would then call the weakly
exported wasm function from the module instance.
We simplify this now by making the Dart code simply give the wasm
function reference to JS, then JS can later on invoke it. No need to
weakly export a function and call back via
`module.exports.<weaklyExportedCallback>`
To ensure binaryen is aware that the wasm function may be called from
JS, we annotate it via the `(@binaryen.js.called)` annotation.
Change-Id: I828dd0cf8d3b36db338792c4e277a4bb94c76faf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/511080
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Path exclusions should ideally be defined inside a project's
`analysis_options.yaml` file, rather than being added programatically.
Plus, there's a bug with the constructor that causes this parameter to
be completely ignored anyways, so it's been obsolete and non-functional
for a while now. `getExcludedGlobs` in the `_ContextLocator` handles
parsing and adding excluded paths from the analysis server already, so
we should look into deprecating and removing this parameter.
Change-Id: I6c023041c7bb5fa4cb9dedc629afa4ea6ecb63d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/511160
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This is an attempt to fix the following build failure which appears
on Flutter bots but not Dart CI bots:
```
../../../flutter/third_party/dart/runtime/vm/os_win.cc(260,13): error: no matching function for call to 'ReadProcessMemory'
260 | BOOL ok = ReadProcessMemory(GetCurrentProcess(), address, buffer,
| ^~~~~~~~~~~~~~~~~
../../../flutter/third_party/depot_tools/win_toolchain/vs_files/27370823e7\Windows Kits\10\Include\10.0.22621.0\um\memoryapi.h(152,1): note: candidate function not viable: no known conversion from 'size_t *' (aka 'unsigned int *') to 'SIZE_T *' (aka 'unsigned long *') for 5th argument
152 | ReadProcessMemory(
| ^
153 | _In_ HANDLE hProcess,
154 | _In_ LPCVOID lpBaseAddress,
155 | _Out_writes_bytes_to_(nSize,*lpNumberOfBytesRead) LPVOID lpBuffer,
156 | _In_ SIZE_T nSize,
157 | _Out_opt_ SIZE_T* lpNumberOfBytesRead
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
```
TEST=ci
Change-Id: Ic32a5f7750c92850e23c7a8e0e77b1d385e8fc17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/511440
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Migrates vmspecific_enable_ffi_test.dart and
abi_specific_int_incomplete_aot_test.dart away from legacy multi-test
markers. Since these tests verify VM/gen_snapshot compile-time errors
(not CFE errors), they cannot use // [cfe] expectations. Instead, they
now spawn a subprocess and verify the expected error is produced.
- vmspecific_enable_ffi_test: Runs helper with --enable-ffi=false, checks for error
- abi_specific_int_incomplete_aot_test: Compiles helper with `dart compile aot-snapshot`, checks for error
Both tests self-spawn AOT tooling (gen_snapshot) or the JIT `dart` CLI,
so they only run on the dartkp host bots and are skipped elsewhere
(ia32, android, fuchsia, qemu) via tests/ffi/ffi.status.
Fixes https://github.com/dart-lang/sdk/issues/60212
Change-Id: Ib2482c3172b20a4366f984da33544fc515b540c4
Cq-Include-Trybots: dart/try:vm-aot-android-debug-arm64c-try,vm-aot-android-debug-arm_x64-try,vm-aot-linux-debug-arm64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-debug-arm64-try,vm-aot-mac-debug-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-asan-mac-release-arm64-try,vm-asan-win-release-x64-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-tsan-mac-release-arm64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-ubsan-mac-release-arm64-try,vm-ubsan-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508020
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Auto-Submit: Ankit Ranjan <ankitranjandev@gmail.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
If a script uses `Platform.script` running it with as `dart
<script.dart>` and `dart run <script.dart>` would give the correct
script ("<script.dart>"), but running it with `dart run -r
<script.dart>` would report a dill file in the temp directory which is
not only surprising, but also breaking and for instance running the CFEs
strong_suite.dart via `dart run -r` didn't work.
This CL introduces --script_uri_override to the VM and makes the
resident compiler setup pass it so that when running `dart run -r
<script.dart>`, even though the vm is actually launched from a dill file
that resides in temp, `Platform.script` will actually return
`<script.dart>` - and running the CFEs strong_suite.dart via `dart run
-r` now actually works.
Tested: Added pkg/dartdev/test/commands/run_test.dart and manual testing.
Change-Id: Ia65c01834485fe06af63584baf0448dd5b9ffdb4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510343
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This removes the initializer property on InternalVariable together with various other internal delegations to the astVariable to make sure the InternalVariable is behaving has a normal InternalTreeNode.
Change-Id: I1f8469eeb3f80d815f3bb5676bf43e66067b82ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510841
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Recognize a second operand if its `ToUint32` is `0xFFFFFFFF`,
not just the exact value. This includes fx `& -1`, which is output
by `toUnsigned(32)`.
Change-Id: Ieccb42591efd72b4aae62a7c6e678f05510abdc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510960
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
This updates the InternalVariable hierarchy to be based on a sealed base class InternalVariable with no connection to IVariable. IVariable is removed and unused properties of InternalVariable are removed.
TEST=existing
Change-Id: Iacfbe9ab21d1c9aab043712099cd1ee6e4cee174
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510825
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
This adds an InternalLegacyVariable the doesn't derive from LegacyVariable. This fully separates InternalVariable from Variable and assigned variable tracking and flow analysis is now changed to used InternalVariable instead.
TEST=existing
Change-Id: Ida9dc78d4f0e3fab3baf7a965273e1ddf68a80b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510341
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Now that we have a way to tell binaryen to inline functions (see [0],
which added support for `(@binaryen.inline <0...127>)` annotations) we
can tell it to inline functions that were annotated with
`@pragma('wasm:prefer-inline')`
Since binaryen sometimes can devirtualize call sites that TFA cannot, it
can then inline those devirtualized calls.
[0] https://github.com/WebAssembly/binaryen/issues/7972
Change-Id: I139bd43976a1ddb83afe756d4fbac09419f7199e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510822
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Binaryen introduced `binaryen.inline` which allows us to tell it
inlining hints now, including "never inline" hint (see [0])
This allows us to remove the ugly mangling of wasm function names with
`<noInline>` postfix.
We also now pass `--strip-toolchain-annotations`: The annotations
occupy size in the wasm binary and wasm runtimes ignore them (they are
for `wams-opt` only).
Except for IR tests: Here we want to see the annotations, so we keep
them there.
We also rename the package:wasm_builder classes to clearly indicate
those are binaryen specific sections.
We also make the ir_test.dart put it's options first, allowing the IR
tests to override options if needed.
[0] https://github.com/WebAssembly/binaryen/commit/3c25487214600a9
Change-Id: I96688bfaeba403a39cd5e7376f8d2889bcbae030
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510000
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
This makes tests more reproducible, and makes it easier to copy commands between workspaces, or between a failing bot and a local workspace.
Change-Id: Ic8dd10a3540f314a406e5c5b0a23d97032e5d01d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/508364
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>