Commit Graph

19353 Commits

Author SHA1 Message Date
Ben Konyi f9147d933e [ Service ] Update VM service message to not reference Observatory
See https://github.com/dart-lang/sdk/issues/46756

TEST=Existing

Change-Id: Ib71bf00d667369d7438a4547ae444951ec0979df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233504
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-02-18 20:53:52 +00:00
Martin Kustermann ec9314f009 [gardening] Remove usage of AsyncThenWrapperHelper() - its unused and treeshaken in AOT
This is a folow-up to [0]

[0] https://dart-review.googlesource.com/c/sdk/+/233362

TEST=Fixes ASSERT hit in AOT.

Change-Id: Ia99a168a216ac7c5858f9773bd8df32be3016525
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233563
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-18 17:32:18 +00:00
Alexander Markov 5010df50fe [vm] Replace asm intrinsic _GrowableList._withData with flow graph implementation
_GrowableList._withData constructor can be implemented in flow graph and
inlined, instead of having an asm intrinsic implementation.

This change also adds a specialized allocation stub for _GrowableList
class to offset slower general-purpose allocation stub.

TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/48255

Change-Id: Ice0ca9156d7a504960cce1718ffd9aca24a9a3d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231527
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-02-18 16:06:12 +00:00
Martin Kustermann 22f7002240 [vm] Fix StackTrace::ToCString(): Invisible inlined frames should not be shown
Closes https://github.com/dart-lang/sdk/issues/48428

TEST=Fixes vm/dart{,_2}/invisible_function_pragma_test in AOT mode.

Change-Id: I3003e2fd5fcb98bbdef720b215afaaa4e7df1fdc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233562
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-18 13:57:41 +00:00
Martin Kustermann f50b3a52e4 [vm] Make async lowering no longer use optional parameters
This CL

  * Makes :async_op only have two parameters: We take advantage
    of the fact that errors not only have exception != null but
    also stacktrace != null.
  * Makes :async_op have no optional parameters. This reduces
    code size significantly.
  * Removes unused parameter in _awaitHelper calls
  * Wrap the then callback instead of the error callback. (needed
    to make optional parameters required)

This results in 2% code savings on a big g3 app.
The size of :async_op shrinks on average by 11%

TEST=ci

Change-Id: I38d5fba4ebebc780b48dac5aa6a250d2c7952bfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233362
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-18 12:09:42 +00:00
Clement Skau 7611d9167b [vm] Fixes implicit conversion bool -> intptr_t
Class Assembler defines its second parameter as:
`  intptr_t far_branch_level = 0`
So the previous code would implicit pass 0 or 1 from the bool
`use_far_branches`.
This is a clang-tidy presubmit error.

The error was introduced when the Assembler class was changed in:
https://dart-review.googlesource.com/c/sdk/+/217289

TEST=None
Change-Id: I69d71b4d57bdaab7be5200a6d06a751d3935e10d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233560
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2022-02-18 11:36:12 +00:00
Martin Kustermann 0a275f6e97 [vm] Add @pragma('vm:invisible') to mark functions as invisible for stacktraces
The pragma can be used to annotate functions which should not appear in
stack traces unless --show-invisible-frames is passed to the VM.

TEST=vm/dart{,_2}/invisible_function_pragma_test

Change-Id: I807359146f16b67913697f07416fbe8ce9aaa6e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233381
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-18 10:21:02 +00:00
Brian Quinlan 917ae52f70 Add the ability to log TLS keys.
TEST=unit tests
Bug: https://github.com/dart-lang/sdk/issues/47838
Change-Id: I8a64e8623022215cae261eadb25b22deb9f3d910
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231330
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-17 21:39:31 +00:00
Ryan Macnak 6cc25b013a [vm] Fix handling regex compilation errors with non-intrinsified invocation.
RISC-V: Implement regex invocation intrinsic.

TEST=regress_big_regexp_test
Bug: https://github.com/dart-lang/sdk/issues/48333
Change-Id: Id3a30a692293a428c8310861eae6b9144bd169e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233447
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-17 21:29:11 +00:00
Ryan Macnak 4577d4e013 [vm] Establish ordering between publish a new field table background store and concurrently accessing it.
TSAN doesn't understand std::atomic_thread_fence.

TEST=iso-stress, tsan
Change-Id: Icb873af1f58f111c4e69666f33a27f5a6cdf724c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233445
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-17 18:10:31 +00:00
Jens Johansen 90997b96b0 [VM] Don't inline String.==
This stops string operator == from being inlined in the VM.
When not inlining it uses an intrinsic which is faster.
For situations where String.== calls weren't inlined before this should
be a no-op.
For situations where String.== calls were inlined before this should
make it use the intrinsic instead, making it faster.

In a microbenchmark (see below) runtimes go to
"String length"   # iterations   New runtime
              1       10000000   63.68%
             10        1000000   61.92%
            100         100000   60.70%
           1000          10000   74.48%
          10000           1000   73.37%
         100000            100   100.31%

i.e. for many iterations (though seemingly fewer than one might expect)
the time it takes to compare strings is now between 60-75% of what it
was before (i.e. something like 25-40% faster).

Raw data:

Before:

$ runxtimes 10 out/ReleaseX64/dart stringCompareSpeed.dart 1 10000000
833
837
834
838
829
828
818
834
816
828

$ runxtimes 10 out/ReleaseX64/dart stringCompareSpeed.dart 10 1000000
487
452
452
457
458
452
452
455
454
453

$ runxtimes 10 out/ReleaseX64/dart stringCompareSpeed.dart 100 100000
438
422
423
421
420
421
424
420
420
420

$ runxtimes 10 out/ReleaseX64/dart stringCompareSpeed.dart 1000 10000
330
331
333
330
414
330
332
335
413
331

$ runxtimes 10 out/ReleaseX64/dart stringCompareSpeed.dart 10000 1000
342
387
341
340
341
374
342
341
341
377

$ runxtimes 10 out/ReleaseX64/dart stringCompareSpeed.dart 100000 100
247
248
249
248
279
284
249
271
250
263

$ runxtimes 10 out/ReleaseX64/dart --background_compilation=false --optimization_counter_threshold=2 stringCompareSpeed.dart 1 10000000
670
669
676
669
670
670
669
673
670
670

$ runxtimes 10 out/ReleaseX64/dart --background_compilation=false --optimization_counter_threshold=2 stringCompareSpeed.dart 10 1000000
553
554
558
553
552
555
552
553
555
551

$ runxtimes 10 out/ReleaseX64/dart --background_compilation=false --optimization_counter_threshold=2 stringCompareSpeed.dart 100 100000
502
504
504
501
502
503
503
505
503
506

$ runxtimes 10 out/ReleaseX64/dart --background_compilation=false --optimization_counter_threshold=2 stringCompareSpeed.dart 1000 10000
496
495
496
494
494
495
494
494
495
494

$ runxtimes 10 out/ReleaseX64/dart --background_compilation=false --optimization_counter_threshold=2 stringCompareSpeed.dart 10000 1000
494
502
494
495
494
495
494
499
499
494

$ runxtimes 10 out/ReleaseX64/dart --background_compilation=false --optimization_counter_threshold=2  stringCompareSpeed.dart 100000 100
572
493
494
495
495
494
497
495
494
494


With change:

$ runxtimes 10 out/ReleaseX64/dart stringCompareSpeed.dart 1 10000000
532
534
532
528
532
526
523
519
523
533

$ runxtimes 10 out/ReleaseX64/dart stringCompareSpeed.dart 10 1000000
287
291
283
283
280
280
279
281
280
287

$ runxtimes 10 out/ReleaseX64/dart stringCompareSpeed.dart 100 100000
270
257
254
255
255
255
255
255
254
257

$ runxtimes 10 out/ReleaseX64/dart stringCompareSpeed.dart 1000 10000
248
249
251
287
248
262
248
273
248
277

$ runxtimes 10 out/ReleaseX64/dart stringCompareSpeed.dart 10000 1000
268
281
247
247
247
282
251
247
247
270

$ runxtimes 10 out/ReleaseX64/dart stringCompareSpeed.dart 100000 100
248
277
256
286
248
275
247
248
254
257

$ runxtimes 10 out/ReleaseX64/dart --background_compilation=false --optimization_counter_threshold=2  stringCompareSpeed.dart 1 10000000
490
488
488
481
493
498
484
498
491
494

$ runxtimes 10 out/ReleaseX64/dart --background_compilation=false --optimization_counter_threshold=2  stringCompareSpeed.dart 10 1000000
202
202
235
226
215
206
203
232
208
202

$ runxtimes 10 out/ReleaseX64/dart --background_compilation=false --optimization_counter_threshold=2  stringCompareSpeed.dart 100 100000
173
172
184
194
203
172
177
173
192
172

$ runxtimes 10 out/ReleaseX64/dart --background_compilation=false --optimization_counter_threshold=2  stringCompareSpeed.dart 1000 10000
166
169
178
180
176
169
200
198
197
198

$ runxtimes 10 out/ReleaseX64/dart --background_compilation=false --optimization_counter_threshold=2  stringCompareSpeed.dart 10000 1000
167
180
195
195
187
180
176
196
173
195

$ runxtimes 10 out/ReleaseX64/dart --background_compilation=false --optimization_counter_threshold=2  stringCompareSpeed.dart 100000 100
190
171
173
167
166
172
166
171
166
170

where

$ type runxtimes
runxtimes is a function
runxtimes ()
{
    number=$1;
    shift;
    for i in `seq $number`;
    do
        $@;
    done
}

and `stringCompareSpeed.dart` is

```
late final String long;
late final String long1;
late final String long2;

void main(List<String> args) {
  if (args.length != 2) throw "expect 2 arguments: <string-length> <iteration count>";
  final int length = int.parse(args[0]);
  final int iterations = int.parse(args[1]);

  long = "foo" * length;
  long1 = long + "1" + long;
  long2 = long + "2" + long;

  final String localLong1 = long + "1" + long;
  final String localLong2 = long + "2" + long;

  for (int i = 0; i < iterations; i++) {
    if (compare(localLong1, localLong2) != 105) {
      throw "got ${compare(localLong1, localLong2)}";
    }
  }

  Stopwatch stopwatch = new Stopwatch()..start();
  for (int i = 0; i < iterations; i++) {
    if (compare(localLong1, localLong2) != 105) {
      throw "got ${compare(localLong1, localLong2)}";
    }
  }
  print("${stopwatch.elapsedMilliseconds}");
}

int compare(String localLong1, String localLong2) {
  int result = 0;

  if (long1 == localLong1) {
    result |= 0x01;
  }
  if (long1 != localLong1) {
    result |= 0x02;
  }
  if (long1 == localLong2) {
    result |= 0x04;
  }
  if (long1 != localLong2) {
    result |= 0x08;
  }

  if (long2 == localLong1) {
    result |= 0x10;
  }
  if (long2 != localLong1) {
    result |= 0x20;
  }
  if (long2 == localLong2) {
    result |= 0x40;
  }
  if (long2 != localLong2) {
    result |= 0x80;
  }

  return result;
}
```

TEST=Existing tests, benchmarked here.

Change-Id: Iecf6c228b3040db0e0b403241ea6380dfed6dbb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233100
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-02-17 08:58:31 +00:00
Ryan Macnak 48326ee2e2 [vm, compiler] Fix accessing unboxed double parameters in the presence of optional parameters on RV32.
Apparently LoadIndexedUnsafe expects kWordSize scaling even when accessing doubles. Cf. ARM32.

TEST=bigint_from_test
Bug: https://github.com/dart-lang/sdk/issues/48333
Change-Id: I21e300feabec28d763f2b679db5656f5dd0f0ea6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233420
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-16 23:44:30 +00:00
Ryan Macnak ef60f64d81 [vm] Annotate concrete types when creating arrays and strings.
TEST=ci
Change-Id: I8881b52f9ea8a146138127ec2fc726a79f7441be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233220
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-16 20:36:30 +00:00
Daco Harkes 0fab3fed93 [vm/test] Scavenger WeakProperty and WeakReference unit tests
The new space tests were evacuating new space, letting the scavenger
promote everything and then immediately running the marker.
This did not test the state right after running only the scavenge.

TEST=runtime/vm/object_test.cc

Change-Id: I3272f62a38ff5d38e76c83c831c3742e4951aa56
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233280
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-02-16 18:57:23 +00:00
Liam Appelbe 3a3738c6fb Revert "Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection""
This reverts commit 8d1eedca64.

Reason for revert: Broke the Fuchsia bot: https://github.com/dart-lang/sdk/issues/47950#issuecomment-1040648129

Original change's description:
> Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection"
>
> This is a reland of 19e5749308
>
> TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
>
> Original change's description:
> > [vm] Add analyze_snapshot tool for AOT snapshot inspection
> >
> > Current skeleton to allow for instrumentation snapshots that can be
> > built alongside Dart compilation artifacts and easily referenced for
> > specific versions between Snapshot hash <-> DartSDK <-> Flutter Engine
> >
> > TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
> >
> > Change-Id: Ie3757a265bbf457506c72fb62a625fea7bedcb68
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221087
> > Reviewed-by: Slava Egorov <vegorov@google.com>
> > Commit-Queue: Slava Egorov <vegorov@google.com>
>
> Change-Id: Ia1ea0071d30818440ae48484ff6c406236af5a4e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224526
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Slava Egorov <vegorov@google.com>

TBR=vegorov@google.com,cmevans@google.com

Change-Id: I1aa0404fa8af9bd31a5c1efbbe7f60d9da2b5b9d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233160
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2022-02-15 18:45:39 +00:00
Chris Evans 8d1eedca64 Reland "[vm] Add analyze_snapshot tool for AOT snapshot inspection"
This is a reland of 19e5749308

TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart

Original change's description:
> [vm] Add analyze_snapshot tool for AOT snapshot inspection
>
> Current skeleton to allow for instrumentation snapshots that can be
> built alongside Dart compilation artifacts and easily referenced for
> specific versions between Snapshot hash <-> DartSDK <-> Flutter Engine
>
> TEST=runtime/tests/vm/dart/analyze_snapshot_binary_test.dart
>
> Change-Id: Ie3757a265bbf457506c72fb62a625fea7bedcb68
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221087
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Slava Egorov <vegorov@google.com>

Change-Id: Ia1ea0071d30818440ae48484ff6c406236af5a4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224526
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-02-15 10:50:10 +00:00
Ryan Macnak 57fb2a05a2 [vm, compiler] Fix clobbered PP for callers of AOT allocation stubs on RV.
In the JIT, this PP is saved and restored in stub's Dart frame. In AOT, Dart frames do not save PP because it is a global register within Dart code. On other architectures, PP is a preserved register in the C ABI.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48333
Bug: https://github.com/dart-lang/sdk/issues/48354
Change-Id: I1b6702805a6fb556a1695197e40a89c364af3f8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232520
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-14 20:33:30 +00:00
Martin Kustermann 525e7f093f [gardening] Skip part of Isolate.spawnUri() which depends on --enable-assertions in PRODUCT mode
The --enable-assertions flag is not avaiable in PRODUCT mode, so we skip
this negative subtest.

TEST=Fixes dartkp-product on a newly added test for vm/dart{,_2}/spawn_uri_aot_test

Change-Id: Ie7be219b6eb2a2ac53ea5048a844fafeb488ba54
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232941
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-14 18:37:54 +00:00
Martin Kustermann 31ac1d26f9 [vm] Make Isolate.spawnUri() work in AOT iff the uri is compatible AOT snapshot
Right now the implementation of `Isolate.spawnUri(<uri>, ...)` in
the standalone embedder is to ignore `<uri>` and make the spawnned
isolate from the same AOT snapshot as the main isolate.

This is very confusing and very incorrect.

Instead `Isolate.spawnUri()` should work if-and-only-if the given
`<uri>` points to a valid and compatible AOT snapshot. If not, it should
throw an appropriate exception.

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

TEST=vm/dart{,_2}/spawn_uri_aot_test

Change-Id: I279ace08ac1b9a9eed3ae03ebe5d9e2336c1e5c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232603
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-14 15:18:33 +00:00
Alexander Thomas 30beab0f43 [infra] Add OWNERS to the Dart SDK
* Add team "groups" in tools/OWNERS_<group name>.
* Add top-level OWNERS as a fallback.
* Add OWNERS for all top-level directories.
* Add OWNERS to all packages.

For additional background information see go/dart-sdk-owners.

TEST=No op until code-owners is enabled.
Bug: b/200915407
Change-Id: I7fe6116cc599c749cd50ca16151d6d6a801d99d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229147
Reviewed-by: Jonas Termansen <sortie@google.com>
2022-02-14 14:06:34 +00:00
Martin Kustermann 32876877ae [gardening] Remove standalone{,_2}/io/process_run_test from iso-stress builder
The test is flakily failing with low propabililty due to a race on
executing a copy of `process_test` and having this file opened for
writing mode (so it seems).

This issue is not related to isolates and we'll therefore remove it from
the "iso-stress" builder.

TEST=Removes flakiness from "iso-stress" builder.

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

Change-Id: I1f817aed9b014b8cdd7a646f35003d40d4712d0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232624
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-11 18:29:47 +00:00
Martin Kustermann 37acae7e29 [gardening] Remove standalone/io/http_redirect_test from iso-stress builder
This test was modified (in [0]) to use `dart:mirrors` which doesn't
work in AOT mode. Only tests that work in AOT are considered for
the iso-stress builder.

[0] https://dart-review.googlesource.com/c/sdk/+/230600

TEST=Fixes "iso-stress" builder failure to compile.

Change-Id: I354784a33550d816332611747c4d41b53d44b2a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232621
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-11 15:19:07 +00:00
Brian Quinlan 98634512f2 Surface errors returned by SSL_read.
TEST=repro in bug & unit test
Bug: https://github.com/dart-lang/sdk/issues/48311
Change-Id: Ib13d0e3c2b98be85533a65532119874ca504f196
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/226607
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-11 02:07:43 +00:00
Ryan Macnak 2829bfdf25 [vm] Avoid repeating parameters from prematurely destructuring Dart_InitializeParams.
TEST=ci
Change-Id: I39288fc4d79c5933d5c8b274c0a66bdd25f6bf29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231529
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-11 00:55:11 +00:00
Daco Harkes 828dcd00e8 [vm] Implement WeakReference in the VM
This CL implements `WeakReference` in the VM.

* This reduces the size of weak references from 2 objects using 8 words
  to 1 object using 4 words.
* This makes loads of weak reference targets a single load instead of
  two.
* This avoids the fix-point in the GC and message object copying for
  weak references. (N.b. Weak references need to be processed _after_
  the fix-point for weak properties.)

The semantics of weak references in messages is that their target gets
set to `null` if the target is not included in the message by a strong
reference.

The tests take particular care to exercise the case where a weak
reference's target is only kept alive because a weak property key is
alive and it refers to the target in its value. This exercises the fact
that weak references need to be processed last.

Does not add support for weak references in the app snapshot. It would
be dead code until we start using weak references in for example the
CFE.

This CL does not try to unify weak references and weak properties in
the GC or messaging (as proposed in go/dart-vm-weakreference), because
their semantics differ enough.

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

TEST=runtime/tests/vm/dart/finalizer/weak_reference_run_gc_test.dart
TEST=runtime/tests/vm/dart/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc
TEST=tests/lib/isolate/weak_reference_message_1_test.dart
TEST=tests/lib/isolate/weak_reference_message_2_test.dart

Change-Id: I3810e919a5866f3ae8a95bd9aa23a880a0b0921c
Cq-Include-Trybots: luci.dart.try:app-kernel-linux-debug-x64-try,dart-sdk-mac-arm64-try,vm-canary-linux-debug-try,vm-fuchsia-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-debug-x64c-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-debug-simriscv64-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-release-ia32-try,vm-kernel-nnbd-linux-release-simarm64-try,vm-kernel-nnbd-linux-release-simarm-try,vm-kernel-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-win-release-ia32-try,vm-kernel-nnbd-win-release-x64-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232087
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-02-10 21:59:41 +00:00
Daco Harkes fac4d23799 [vm] Fix serial scavenge asserts in object copy
The serial scavenger was expecting the typed_data field of views.
Fast object copy leaves a null there temporarily.

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

TEST=runtime/tests/vm/dart/isolates/fast_object_copy_test.dart

Change-Id: I72a2785cd9708e72593d35179536a831193d2a44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232260
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2022-02-10 21:59:41 +00:00
Ryan Macnak 50b2a4f32e [vm, compiler] Fix allocate mint stub clobbering registers not blocked by BoxInt64Instr.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48333
Change-Id: If8e97e34c0e43a0d4cae2a6b88fba2f15ac07e37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232232
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-10 20:10:01 +00:00
Ryan Macnak 598fb44709 [vm, ffi] More support for RISC-V.
Fixes cases with passing floats, passing aggregates by value, passing scalars requiring alignment.

The remaining failing tests look like some kind of corruption or register reuse when passing very large numbers of arguments.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: Ibac32d4f291255e1c2eb8fd1b196b3e2f006f610
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231282
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-10 02:05:28 +00:00
Ryan Macnak f64fc409c7 [vm, ffi] Extend calling convention unit tests to consider large numbers of floating point arguments.
Interesting things happen after the 8th and 16th arguments in RV.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: I9e068af8a2e6de99541f8e2e9b5c407df42b4197
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232140
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-09 22:07:38 +00:00
Alexander Aprelev 6b830c4428 [vm/isolate/spawn] Ensure spawnFunction sends closure so type args are preserved.
Fixes https://github.com/dart-lang/sdk/issues/48035

TEST=spawn_generic_function_test

Change-Id: I28d0ea9123bd31cb1aa288824c3c7688fc2ca8f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232160
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-02-09 16:49:49 +00:00
Nate Bosch 33e174084a Replace Uri.scheme == with Uri.isScheme
Use `hasScheme` in place of comparing against the empty string, and
`isScheme` to compare against all other schemes.

TEST=No behavior changes.

Change-Id: Ifc9fd13c6cf37933ebd4a754c4b500dedbcb291b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231185
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2022-02-08 21:38:57 +00:00
Alexander Markov 0cf751215e [vm] Correct token position for AssertAssignable in implicit field setters
The real token position is required in case debugger stopped on
an exception thrown from AssertAssignable and trying to evaluate
an expression which uses receiver. Without token position all local
variables (including receiver) are considered out of scope
(as frame's token position is out of range).

TEST=runtime/observatory/tests/service/regress_48279_test.dart
Fixes https://github.com/dart-lang/sdk/issues/48279

Change-Id: Idb6a8e12185367ceac2034269b8f046272384006
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231748
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-02-08 19:28:36 +00:00
Brian Quinlan 085e978ce4 Fix on Windows, renaming a file using the Directory class generates an incorrect exception
TEST=unit
Bug: https://github.com/dart-lang/sdk/issues/47713
Change-Id: I603a452cece478ad5ddd85d47e9cfe02cee3f4d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231801
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2022-02-07 23:15:56 +00:00
Vyacheslav Egorov 72eb59f32a [vm/compiler] Allow WB elimination for small arrays.
Previously all arrays were excluded from WB elimination pass
to avoid invariant restoration code creating excessive work
for the GC and to avoid dealing with card marking in the
invariant restoration code.

It seems reasonable to enable this for small arrays of up to 8
elements. The cut of point of 8 elements was chosen based on the
cut of point for literal<N> specialisations provided by the
core library for creating small literal arrays.

TEST=vm/cc/IRTest_WriteBarrierElimination_Arrays

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-dwarf-linux-product-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-linux-release-x64-try
Change-Id: I2b3169865f07c3ff95820c1bc6718943e96bd33b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/229903
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-02-07 10:47:12 +00:00
Ben Konyi ad4d10a42c [ package:vm_service ] Migrate Observatory service tests to package:vm_service (Pt 2)
See https://github.com/dart-lang/sdk/issues/45037

TEST=pkg/vm_service/test/*

Change-Id: I0632744fdea0da63a47d64299cbd1f96f45dcb3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186742
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-02-05 00:12:29 +00:00
Martin Kustermann 4eaacc3df9 [vm] Improve async performance by taking advantage of static types of returned values
In general any async function can return X or Future<X>. Though the
future implementation has to do different things depending on which case
we're in. It does so by using a `<obj> is Future<T>` test. This test is very
expensive if many different classes flow into `<obj>`.

Though most functions do not return `Future` objects from async
functions. We can determine that statically by looking if any returned
expression could be a future. If not, we can bypass the `is Future<T>`
test entirely.

Issue https://github.com/dart-lang/sdk/issues/48226
Issue https://github.com/dart-lang/sdk/issues/48235

TEST=pkg/front_end/testcases/general/async_function_returns_future_or.dart

Change-Id: If655bdbdddc214dd7b12be9905b3c788252547d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230662
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-02-04 22:06:59 +00:00
Siva Annamalai 2e731c540a Revert "[tools] Replace the Chromium binary size tool, which no longer works."
This reverts commit e32d98cd06.

Reason for revert: Dart rolls into the engine are failing because there are references to run_binary_size_analysis in the "Upload artifacts android-arm64-release" step of the build

Original change's description:
> [tools] Replace the Chromium binary size tool, which no longer works.
>
> Change-Id: Id84717e21a129a392d3bc4e9b4cce84dfb4771e1
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231066
> Reviewed-by: Ben Konyi <bkonyi@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ibfbdf1e0a970ad7fae9ec1d39d24722647b38730
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231600
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-02-04 02:11:06 +00:00
Ryan Macnak 172dad5375 [vm] Fix double and mint to inherit the PostLoad for instances.
Cf. ab3aab760e.

TEST=ci, aot
Change-Id: Ia1d0b5776d9714bde94f3372824f94dd70a7ae23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231532
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-04 00:10:47 +00:00
Ryan Macnak 33a1117d62 [vm] Add missing opt-out of C instructions to vm/cc/LoadWordUnsigned_0.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/38587
Change-Id: I15460a970522044b50f98922fad559d26c5813ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231524
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 21:52:56 +00:00
Ryan Macnak ab3aab760e [vm] Remove special cases for canonicalizing doubles and mints.
dart_precompiled_runtime -7k

TEST=ci
Change-Id: I22c8254b08d9f68be02f7210aa60f7cc728f8b9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231324
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 21:13:36 +00:00
Ryan Macnak 4faf01a66c [vm] Cleanup workarounds for removed flag --throw_on_javascript_int_overflow.
TEST=ci
Change-Id: I65936b5cd6e5933eadc37f3cd6bba1f0fa1b81a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231328
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 21:10:46 +00:00
Ryan Macnak b6ab7350be [test] Inform status files about the new simulated architectures.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/37299
Bug: https://github.com/dart-lang/sdk/issues/38587
Change-Id: I6f1a749690b894b14f465d608f37acf62568cdef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231521
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 20:32:16 +00:00
Daco Harkes eacd2b3e3e [vm] WeakReference check target type
Closes: https://github.com/dart-lang/sdk/issues/48264

TEST=runtime/tests/vm/dart/finalizer/weak_reference_run_gc_test.dart

Change-Id: I16d9d9768bcef3c832960f0cd33ba54a0b689ed2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231481
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-02-03 18:29:46 +00:00
Ryan Macnak f3996e4e96 [vm] Remove some dead error entry points.
TEST=ci
Change-Id: I78e13654ba4425e07e92a5a879595cae2045ea99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231360
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 17:55:16 +00:00
Vyacheslav Egorov aeb3e1d73b [vm] Avoid creating unnecessary SafepointPosition's
Register allocator does not need to associate always-calls
safepoints with live ranges of constant values because
constant values are never actually spilled and are rematerialized
instead.

@alexmarkov has observed that SafepointPosition objects for
constants account for large chunk of the total memory eaten by
the register allocation pass and this change addresses this issue.

With this change the total memory consumed by the register allocator
decreases from 21 Gb to 8.6 Gb on one of the examples
in https://github.com/flutter/flutter/issues/94461.

TEST=ci

Change-Id: I245f2678bc6f5c1d63fd282812d1df2b2958512f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231442
Auto-Submit: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2022-02-03 15:39:06 +00:00
Ryan Macnak 08164f88c9 [vm] Add missing safepoint transition when updating or deleting API handles.
TEST=tsan, iso-stress
Change-Id: I82f8fb8ef3bbedf510e34488fdaa7d8af5902830
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231332
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-03 00:41:07 +00:00
Ryan Macnak e32d98cd06 [tools] Replace the Chromium binary size tool, which no longer works.
Change-Id: Id84717e21a129a392d3bc4e9b4cce84dfb4771e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231066
Reviewed-by: Ben Konyi <bkonyi@google.com>
2022-02-02 17:22:38 +00:00
Alexander Markov 45f42d0be8 [vm] Refactor duplicated slots and rename offsets
This change removes distinct Slots for the same field:

PointerBase_data_field -> PointerBase_data
Pointer_data_field -> PointerBase_data
TypedDataBase_data_field -> PointerBase_data

Also, the following slot is renamed to match field name:

TypedDataView_data -> TypedDataView_typed_data

The following offsets are renamed to match field names /
declarations in Untagged* classes:

PointerBase::data_field_offset -> PointerBase::data_offset
TypedData::data_offset -> TypedData::payload_offset
TypedDataView::data_offset -> TypedDataView::typed_data_offset


TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/48273

Change-Id: I602545fc43018494bcb24d8692292fdbc6a8f3e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231160
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-02-02 16:30:50 +00:00
Ryan Macnak a7faaaa148 [vm] Properly exclude the field descriptors from product builds.
TEST=ci
Change-Id: Ia9d345f7f6488b24b780979fd624d708c7038811
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231182
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-02 00:32:25 +00:00
Ryan Macnak 6f9289ca30 [vm, compiler] Avoid false positive in assertion for eliminated write barrier.
This adjusts RISC-V to match the other architectures in checking only the generational barrier.

TEST=fuzzer
Change-Id: I86965bb2caaae27aa9770769f392cffc8edb6eb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231046
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-02-01 17:17:05 +00:00