Don't convert Dart `double`s to `externref`s when calling JS interop
functions, pass them as `double`.
We pass other unboxed values (`int`s and `bool`s) as `externref`s, as
before:
- `int`s are most efficiently passed as `externref`s, as small integers
can be converted to `i31ref` and externalized without allocation.
- `bool`s passed as `i32` mostly work because JS treats 0 as false and
everything else as true, but the values can still be observed as
numbers rather than bools, which causes some test failures.
Changes:
- Make raw interop procedures take `double` as argument, when the Dart
type for the interop function argument is non-nullable `double`.
- Pass static type of the value and expected type (by the interop
function) to `jsifyValue`.
- `jsifyValue` then takes the static type and expected type into account
to avoid conversions when both are `double`s.
- `jsifyValue` is refactored to avoid the type conversion mapping
allocation on every call.
New benchmark result before the changes:
WasmJSInterop.call.void.1ArgsDouble(RunTimeRaw): 0.018275229357798167 ns.
After:
WasmJSInterop.call.void.1ArgsDouble(RunTimeRaw): 0.014034965034965034 ns.
Issue: https://github.com/dart-lang/sdk/issues/60357
Change-Id: Ia70671f9a8e14f359f1119beda123e94aacdd2cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422480
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
In V8, the only way to pass a Wasm integer or float to JS without
allocation is by passing it as a 31-bit integer.
This can be done by:
1. Passing as `i32`. If the integer fits into 31 bits it's passed
without allocation.
2. Passing as externalized `i31ref`.
(1) requires importing the JS function with different signatures: for
each `int` argument we would need a signature with the `i32` as the Wasm
argument type, and another with `externref` (or `f64` if we want to pass
large integers as `f64`).
This is not feasible as with a JS function with N `int` arguments we
would need `2^N` imports. So we implement (2): we import each interop
function with one signature, passing `externref` as the argument, as
before. When the number fits into 31 bits we convert it to an `i31ref`
and externalize it. Otherwise we convert the number to `externref` as
before, by calling the JS function `(o) => o` imported with type `[f64]
-> [externref]`.
New benchmark checks `int` passing for small (31 bit) and large (larger
than 31 bit) integers. Results before:
WasmJSInterop.call.void.1ArgsSmi(RunTimeRaw): 0.020 ns.
WasmJSInterop.call.void.1ArgsInt(RunTimeRaw): 0.018 ns.
After:
WasmJSInterop.call.void.1ArgsSmi(RunTimeRaw): 0.014 ns.
WasmJSInterop.call.void.1ArgsInt(RunTimeRaw): 0.018 ns.
Issue: https://github.com/dart-lang/sdk/issues/60357
Change-Id: I749001e0e7e9784114415439298c2f3e0fb974b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419880
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
The "new" rti library has been standard for years now and no one should
be passing `--experiment-new-rti` or `--use-old-rti`. We can now clean
up any references to different versions of rtis.
Change-Id: I4421b8943fe5034ed4d259477e8112b25ba0c763
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416326
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
This reverts commit 74c5aa3a7a.
Reason for revert: Fix golem breakage by not changing the script dart_precompiled_runtime2
TEST=ci
Original change's description:
> Revert ""[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory""
>
> This reverts commit f81a402aa1.
>
> Reason for revert: golem benchmarks are failing to run
>
> TEST=ci
>
> Original change's description:
> > "[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory"
> >
> > Fixed golem breakage by temporarily copying dartaotruntime to dart_precompiled_runtime
> >
> > This reverts commit 75e6a748f7.
> >
> > TEST=ci
> >
Change-Id: I9efe40643c59bc617f6fb484b89b038deaffbb93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393941
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
This reverts commit f81a402aa1.
Reason for revert: golem benchmarks are failing to run
TEST=ci
Original change's description:
> "[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory"
>
> Fixed golem breakage by temporarily copying dartaotruntime to dart_precompiled_runtime
>
> This reverts commit 75e6a748f7.
>
> TEST=ci
>
> Original change's description:
> > Revert "[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory"
> >
> > This reverts commit 1b331d05c2.
> >
> > Reason for revert: golem builds are failing
> >
> > Original change's description:
> > > [SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory
> > >
> > > TEST=ci
> > >
>
> Change-Id: Id0f383eabb496c06c0acebc639c8e3b056ba82d0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393781
> Commit-Queue: Siva Annamalai <asiva@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
Change-Id: Iec494940412aa31dbefdc5280e35ae99e8cecb26
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393764
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Fixed golem breakage by temporarily copying dartaotruntime to dart_precompiled_runtime
This reverts commit 75e6a748f7.
TEST=ci
Original change's description:
> Revert "[SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory"
>
> This reverts commit 1b331d05c2.
>
> Reason for revert: golem builds are failing
>
> Original change's description:
> > [SDK/VM] - Rename dart_precompiled_runtime to dartaotruntime, ensures we have a uniform name for the executable between the build directories and the SDK directory
> >
> > TEST=ci
> >
Change-Id: Id0f383eabb496c06c0acebc639c8e3b056ba82d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393781
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
The dynamic invocations `sink1.codeUnits` and `sink2.isEven` can be slow
on dart2wasm.
They are done once in a few iterations, but the noise can still be
eliminated with a `if (runtimeFalse)` guard around the code that makes
sure the benchmarked code won't be optimized away.
Change-Id: Id85013fa4be1912d1c710cd119e9f6f1e77bcff4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373040
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Golem config expects RunTimeRaw metric (as we want to see not runs per
second but a more meaningful benchmark, i.e. how much transferring 1KB
of data takes)
=> Golem cannot just display it in different form, we have to make the
benchmark report it also as RunTimeRaw.
=> This CL should fix the golem benchmarks.
Change-Id: I91301930941986771eb0725fd0d85424bb07dc3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372640
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Adds a benchmark to test converting Dart functions to and
from JS as well as calling them.
Specifically, tests some combinations of the following:
- Converting vs calling functions
- JS vs Dart functions
- Calling instance methods vs static methods vs closure vs
closures stored in fields
Change-Id: I8f5b63781201042c4068437fe84c3043d6dfb446
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368064
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
This relands "Add copy of ObjectHash benchmark that uses hardware performance counters"
It lands a roll of benchmark_harness to a new version without
the breaking change in the previous, reverted, roll.
It adds a copy of a benchmark that uses
the new features in benchmark_harness.
Reason for reland: The breaking change is removed from benchmark harness.
Original change's description:
> Revert "Add copy of ObjectHash benchmark that uses hardware performance counters"
>
> This reverts commit faee649175.
>
> Reason for revert: The new version of benchmark_harness breaks cbuild.
>
> Original change's description:
> > Add copy of ObjectHash benchmark that uses hardware performance counters
> >
> > Bug: b/320440992
> > Change-Id: Ia504a59861b2de32c0b82d6bb38491600a37e9ff
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363703
> > Reviewed-by: Jonas Termansen <sortie@google.com>
>
> Bug: b/320440992
> Change-Id: I19bd814c1641243ab0b75f45bc55cdfe27d4bff3
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/363740
> Auto-Submit: Alexander Thomas <athom@google.com>
> Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
> Reviewed-by: Emmanuel Pellereau <emmanuelp@google.com>
> Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Bug: b/320440992
Change-Id: I101a7ca756a5da5ddf934818325177501c370f23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/364180
Reviewed-by: Jonas Termansen <sortie@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
The benchmarks were using a range of antipatterns that did not do what
the authors thought they did. It seems that the authors thought the
warmup method has to run for a while and do the full warmup, but the
truth is that the harness will do that for you by running the warmup
function in a timed loop. Instead these patterns just wasted time by
making the warmup more expensive and complex than needed.
This change just removes the warmup overrides since none of them do
anything positive. This change prepares us for future improvements to
the benchmark harness.
Fixes: b/324874055
Change-Id: Ib7c282123a2151614bc95a105a30e67221f11315
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352022
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Jonas Termansen <sortie@google.com>
We want dart2wasm be comparable to dart2js / dart2aot, the ladder two
are much more conservative with inlining compared to current dart2wasm.
The -O3 is described in the binaryen sources as agressive for
performance and therefore willing to compromise code size.
The -Os is more nuanced: It will perform many optimizations that are
done in -O3 (and e.g. not in -O2) but it will make inlining less
agressive.
This reduces flute compile-time by 10% and code size by 10%
This benchmark results are mixed (some things get faster, some things
slower). Naturally there'll be specialized micro benchmarks that
get hit hard by this.
Where performance matters we should rather make dart2wasm use better
inlining heuristics and annotate code with
`@pragma('wasm:prefer-inline')`
Change-Id: Idf7e75e4e385629c9cec66359efe0afe50db3e72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352523
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
This benckmark complements the existing `Utf8Decode` benchmarks by exploring different scenarios. There are three axes of variation - input complexity, conversion type, and polymorphism.
Change-Id: I06706e8efd1b254d65c7abee9f29e6d0b10923ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335504
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Publish some TypedData and ForLoop benchmarks to the Dart sdk repo.
The benchmarks, authored by the Dart project, were previously
in the benchmark-internal repository.
Bug: b/298617448
Change-Id: I3327553ac5feca51a2f978e7d9b9c96fac2af121
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323840
Commit-Queue: William Hesse <whesse@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
While our benchmarks don't involve overlapping memory between source
and destination, general methods for copying between TypedData must.
Thus, our benchmark for using the C interface via FFI must use memmove
instead of memcpy.
To avoid having to update our benchmark configurations, the name of
that benchmark is unchanged.
In addition, this CL adds filtering for benchmark names and turning on
and off specific outputs for quick comparisons when running manually.
Change-Id: I20616549d8bc9ab481884846d3f13df20a3c854e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319981
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
The legacy Dart 2.9 benchmarks that used the default List(int size)
constructor are changed to use the equivalent List.filled(size, null)
constructor, because the default List constructor is removed.
Bug: b/280275041
Change-Id: I2813537ae22e19d473abde70d677368940585423
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304700
Reviewed-by: Jonas Termansen <sortie@google.com>
Commit-Queue: William Hesse <whesse@google.com>