Commit graph

13595 commits

Author SHA1 Message Date
Clement Skau 22652a3b49 [vm/ffi] Privatizes dart:nativewrappers' getNativeField(..)
TEST=Updated dart_api_impl_test.

Change-Id: Ib72667b2a20adc342f724a6eff7d326e2e106257
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214401
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-24 13:13:55 +00:00
Johnni Winther 5b7968346d [kernel] Add Field.fieldReference
This adds a third reference to Field declaration, so that we know have
three references, one for each use case:

1) fieldReference used for initialization; in FieldInitializer and as
   the key in the InstanceConstant.fieldValues map.
2) getterReference used for reading; in InstanceGet, StaticGet and
   SuperPropertyGet
3) setterReference used for writing; in InstanceSet, StaticSet and
   SuperPropertySet

TEST=existing

Change-Id: I223f130e808e7f19a831c1fe5e3a4725d1bcdc3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203770
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-09-24 12:01:08 +00:00
Bruno Leroux 2481cf76f5 [ VM / Service ] Fix 'dart:' scripts lookup
Bug: VM service `addBreakpointWithScriptUri` and `addBreakpoint` don't add valid breakpoints for code in `dart:` libraries. See #47204

This PR contains :
- a new test : 'service/break_on_dart_colon_test.dart', that checks several URIs to register breakpoints in `dart:` libs.
- a fix in `Debugger::SetBreakpointAtLineCol` to make it calls `Library::LookupScript'` with the right value for `useResolvedUri` parameter.

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

TEST=runtime/observatory/tests/service/break_on_dart_colon_test.dart

Change-Id: Id3d6722c278e3238202a9d84a0d34612b957035c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213766
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-09-24 01:20:38 +00:00
Alexander Markov e7ce24744b [vm] Take number of base type parameters into account when checking equivalence of function type parameters
When checking if type parameters are equivalent for subtyping,
check both base and index of the type parameter to avoid matching
type parameters from different levels. For example, consider
the following function types:

  void Function<S>(S val) Function<T>(T val)
  void Function<S>(T val) Function<T>(T val)

Also, when instantiating a signature of a closure, correct
base/index of type parameters even if they are not instantiated.

TEST=language/function_subtype/nested_function_type_test
TEST=language/closure/nested_generic_closure_test

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

Change-Id: I6f75a4ee70435f42afeb772e7ecc680ab75a7520
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214136
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-09-23 18:47:58 +00:00
Chloe Stefantsova 65184a9ff4 [cfe] Don't serialize an empty show/hide clause
TEST=existing

Change-Id: Ie63444c4dbeaa45b38fd195e554780f14fed878e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213767
Commit-Queue: Chloe Stefantsova <dmitryas@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-09-23 14:01:54 +00:00
asiva b7de66efd3 [Runtime/VM - Enable SUPPORT_TIMELINE even in product mode for Android
Please see https://github.com/dart-lang/sdk/issues/47264

The Flutter team would like to turn this on in product mode for being
able to systrace release applications.
This change could have potential size and performance regressions and
will be monitored as it rolls into Flutter. If the impact is not within
acceptable ranges it can be rolled back.

TEST=ci

Change-Id: Iad6f9b831eaf60d15f03e368702fb25bc9ebc76c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214241
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Dan Field <dnfield@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-09-22 22:35:32 +00:00
Ryan Macnak 9854a04210 [vm] Remove dead Thread::pending_functions_.
Cf. c9f5c3a79e.

TEST=build
Change-Id: I9edff8afaf277b03c4dfdcdbea9ba244dde577ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213740
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-09-22 17:16:36 +00:00
Ryan Macnak 306718fe1e [vm, compiler] Fix FFI callbacks on ARM64C.
HEAP_BITS must be initialized before any variant of LoadCompressed is used.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47259
Change-Id: I01ebb4e6c2eee1e61e15c1d8cc2913d0db27c2bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214124
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-09-22 17:11:36 +00:00
Lasse R.H. Nielsen 18f37dd8f3 Add extension name getter on Enum.
We use an extension getter instead of an instance getter because
it doesn't conflict with any potential existing or future enums
which want an element named `name`.
Keeping the namespace for enum elements open is a priority.
We currently only reserve `index` and `values`.

BUG: https://github.com/dart-lang/language/issues/1511

Fixes language issue #1511, which is a long-standing request,
and should replace a number of alternative implementations
which are based on parsing the `toString()`.


This version has two fields on the shared superclass, the index
and private name, and has a separate `toString` for each `enum` class
which hard-codes that enum's class name.

An earlier version had both `"name"` and `"ClassName.name"` as fields
to be able to reuse the same `toString` method on all enum classes,
but that cost too much for JS compiled code.
Even having just `ClassName.` as a field and then combining inside
`toString` requires more code to create the enum instances.
Instead this version hardcodes the `ClassName.` string once
in the `toString` method, which means each enum class has its own
toString (which can *potentially* be tree-shaken then.)

This still tree-shakes slightly worse than the previous implementation
where every enum class had its own `index` and `_name` fields
independent of each other, which could then be tree-shaken independently.
However, the `index` was already made an interface member with the
addition of the `Enum` interface, so code which accesses `.index`
on something of the `Enum` supertype could prevent tree-shaking of
all enum classes' `index` fields.
Likewise any general access to the "name" of an enum would necessarily
do the same for the name.
This CL makes up for some of that by sharing more implementation
between enum classes.

DartVM AOT CodeSize impact: ~0.15% regression on gallery (little less on big g3 app)

TEST= New tests added to enum_test.dart

Change-Id: Id25334e6c987f470f558de3c141d0e3ff542b020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210480
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-22 14:20:16 +00:00
Ryan Macnak 2d207f49cc [vm, compiler] Adjust the write barrier stub to no longer assume there is no race when setting the remembered bit.
Failure to check for losing the race can result in the same object being added to the remembered set twice, and processing the remembered set is not idempotent.

Previously there could be no such race, but the combination of lazy initialized const maps/sets and isolate groups means that now more than one Dart thread can be writing to the same object.

TEST=cfe and fuzzer bots, flaky
Bug: https://github.com/dart-lang/sdk/issues/47233
Change-Id: I7684ea6ba90941bb174c35ae040372aa331ac4c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214077
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-09-22 00:16:58 +00:00
Siva Annamalai a433fc3e13 Revert "[ VM ] Properly shutdown non-core system isolates when cleaning up the"
This reverts commit 58c58af3e8.

Reason for revert: The code can cause a deadlock, see https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8835779319093894049/+/u/vm_tests_shard_2/task_stdout_stderr:_vm_tests_shard_2

Original change's description:
> [ VM ] Properly shutdown non-core system isolates when cleaning up the
> VM
>
> Speculative fix for https://github.com/dart-lang/sdk/issues/45771
>
> TEST=CQ + vm/cc tests
>
> Change-Id: I3f05d78666ee78afca5af6047df96d7841cd1e02
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213561
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>

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

Change-Id: I606d805e173b59dcb6651658a194a58d63afcc48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214065
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-09-21 18:52:58 +00:00
Ben Konyi 58c58af3e8 [ VM ] Properly shutdown non-core system isolates when cleaning up the
VM

Speculative fix for https://github.com/dart-lang/sdk/issues/45771

TEST=CQ + vm/cc tests

Change-Id: I3f05d78666ee78afca5af6047df96d7841cd1e02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213561
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-09-17 13:45:49 +00:00
Ryan Macnak 78b9f54957 [vm] Fix initialization of Contexts in object graph copy's fast-path bailout.
Cf. 179c96cd60.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47235
Change-Id: I9f6aef564286f6b239d697072ed5405085269add
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213681
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-09-16 22:17:24 +00:00
Ryan Macnak d30a43d464 [vm] Allow for long jumps during reusable handle scopes.
Such long jumps may occur due to Out Of Memory exceptions.

TEST=run test harness with low heap limit
Change-Id: Ifc8d062d4325ea3cdb4ea1f1ad1877f2dc83229e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213534
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-09-16 19:40:05 +00:00
Ryan Macnak e7201752dc [vm, gc] Fix double-free when we hit Out Of Memory.
TryReleaseReservation could insert an element into the freelist before the concurrent sweeper visited that page it was on.

TEST=run test harness with low heap limit
Change-Id: I482c820756ea3dbfe6d16c8bdef998e843c576dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213536
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-09-16 18:27:35 +00:00
Ryan Macnak 790d0b601c [vm] Account for Out Of Memory during isolate message deserialization.
TEST=run test harness with low heap limit
Change-Id: I75d3b2e8461bcf99cc41eb3ad76173bc1976bbd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213538
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-09-16 17:18:37 +00:00
Ryan Macnak 5110d828d0 [vm] Fix error notification when unable to print the stacktrace.
TEST=run test harness with low heap limit
Change-Id: I8084c50c3aab1c0cbfa32bbcc5df100abe4211bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213537
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-09-16 17:13:35 +00:00
Ben Konyi c51f885613 [ Debugger ] Allow for setting breakpoints on conditional statements
with simple boolean conditions

Fixes https://github.com/flutter/devtools/issues/3289

TEST=runtime/observatory/tests/service/breakpoint_on_simple_conditions_test.dart

Change-Id: I5ed0b78b4e462615d0d0c7dff1581b38dcf00aee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213421
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-09-16 16:12:17 +00:00
Alexander Markov 15b499b8b2 [vm] Allow Symbol constants _foo without a library
Since Symbol constructor started accepting arbitrary string as argument
(https://github.com/dart-lang/sdk/issues/46207), front-end can generate
Symbol constants with names starting with '_' but without a library.

TEST=language/vm/symbols_test
TEST=corelib/symbol_test

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

Change-Id: Ic416122785444a59bf6b469d2b42491f62810258
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213535
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-09-16 15:56:24 +00:00
Ben Konyi 4759cd95da [ Profiler ] Add safepoint checks in profiler code to improve sample
streaming performance

TEST=CI

Change-Id: Iae536901a41f4b34207e022ec1e6321cfc2d74b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213380
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-09-16 13:58:45 +00:00
Ryan Macnak d89e42bef5 [vm] Rename clustered_snapshot.h/cc to app_snapshot.h/cc.
Since bbefc05748, both serialization formats in the VM are based on clustering. The distinguishing feature of the older clustered serializer is that it represents apps/programs rather than messages.

TEST=ci
Change-Id: If3185c21c6aadeec61a940b12ba23d17f2752761
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211501
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-09-16 00:13:34 +00:00
Ryan Macnak 179c96cd60 [vm] Switch Context to compressed pointers.
TEST=ci
Change-Id: I2511dcc9234dbe29dcbc3abf3db7a8a080dc5436
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213112
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-09-15 22:32:04 +00:00
Alexander Markov 2765b7c911 [vm/compiler] Cleanup passing of try_index
FlowGraphCompiler::CurrentTryIndex() always returns correct try_index,
even when generating slow path code. So we can cleanup passing of
try_index for slow paths.

Also, removed unnecessary arguments from EmitMegamorphicInstanceCall as
it is no longer called on slow paths.

TEST=ci

Change-Id: I2fc29914c0c45068c1732eac27f3da3fd4da6823
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213411
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-09-15 16:51:17 +00:00
Ryan Macnak 5c79501a64 [vm] Remove Dart_GetImportsOfScheme.
Dead since bda70c8489.

TEST=build
Change-Id: I0aed3d9d30a2b01f57f5d6a6bd02105fa89e3095
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213405
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-09-14 21:18:37 +00:00
Alexander Markov d90b297166 [vm/compiler] Refactor Precompiler::AddCalleesOfHelper to use switch
This is a follow-up to review comment
https://dart-review.googlesource.com/c/sdk/+/213288/1/runtime/vm/compiler/aot/precompiler.cc#998

TEST=ci

Change-Id: I59b7b03eb1a9b90bd107fc07906c333d3d63283d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213292
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-09-14 18:52:47 +00:00
Ryan Macnak b32bde155d [vm] Label virtual memory allocations on Android.
TEST=examine /proc/pid/smaps and Observatory's "process memory" page
Change-Id: I03922c9c604ceef8901a8946481d0ccc31110b72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213289
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2021-09-14 16:10:10 +00:00
Alexander Markov 4744f66f6f [vm/compiler] Minor improvements for AOT compilation time
* When testing for pragmas in the inliner, call function.has_pragma()
  early to avoid more expensive Library::FindPragma query.

* When scanning through object pool entries in
  Precompiler::AddCalleesOfHelper, skip over OneByteString and null
  objects quickly. They are leaf and there could be a huge number of
  those objects.

AOT gen_snapshot time of a large Flutter application built in
flutter/release mode for arm64 (best of 5 runs):
Before: 81.589s
After:  74.415s (-8.79%)

TEST=ci

Issue: https://github.com/dart-lang/sdk/issues/43299
Change-Id: I960451c73b42dab9845f0e0eafacaa9bb23720e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213288
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-09-13 21:25:30 +00:00
Ryan Macnak 700969604a [vm] Require C11 thread_local support.
Thus requiring iOS 9+.

TEST=build
Change-Id: I40062753ae030231d4e4ae428c9145f4370cb9a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213283
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Chinmay Garde <chinmaygarde@google.com>
2021-09-13 19:30:30 +00:00
Alexander Markov 125482c0c6 [vm/compiler] Skip AOT unit test vm/cc/TypePropagator_NonNullableLoadStaticField on ia32
TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/47183

Change-Id: I775f4a60debef5856e273f284b9a0f236b03f24d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213103
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-09-13 17:59:29 +00:00
Alexander Markov 30abce99f3 [vm] Treat static final fields with trivial initializers as const
When loading a value of a static final field with trivial initializer
generate a Constant instruction instead of LoadStaticField.

Initializer of a static field is considered trivial if it is null, int,
double, String or bool literal.

TEST=vm/cc/StreamingFlowGraphBuilder_StaticGetFinalFieldWithTrivialInitializer
Fixes https://github.com/dart-lang/sdk/issues/47120

Change-Id: Id2bfc3da8c14376f7f1ef829265cca29a018bad1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212873
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-09-13 16:51:59 +00:00
Chloe Stefantsova 2048ab37f1 [cfe] Add shown and hidden elements to Extension Kernel node
TEST=existing

Change-Id: I8271cb7f4731dea289c855b0c5384f8e181530c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212761
Commit-Queue: Chloe Stefantsova <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-09-13 13:18:19 +00:00
Clement Skau 7d467e8933 [vm] Adds args_n to FFI resolver.
This makes it more closely mirror the Dart_NativeEntryResolver,
and acts as an extra sanity check that signatures (roughly)
align between the FfiNative decl. and the native function.

TEST=Updated runtime/vm/dart_api_impl_test.cc

Change-Id: I40799dc583ec14db14dc453afed4e2d1eb06fced
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212566
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-09-13 07:57:00 +00:00
Ryan Macnak f51fe8fca4 [vm] Reimplement BaseDirectChainedHashMap to use less memory.
gen_snapshot dart2js.dill ...
Maximum resident set size (kbytes): 432920 -> 412908 (-4.6%)

gen_snapshot dart2js.dill --write-v8-snapshot-profile-to=...
Maximum resident set size (kbytes): 904756 -> 662024 (-26.8%)

Also shrinks the VM's binary size by ~100k.

TEST=ci
Bug: b/196510517
Change-Id: I73ea0f87b75e3c1dacb5f31a687effe293e5a350
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212920
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-09-10 22:21:36 +00:00
asiva c8040131c6 [VM/Runtime] - Switch DartInitializationState to use atomic operations instead of mutex/condition variables
TEST=ci

Change-Id: Ifbcbfdba4874930e83e17de4882b535dc3e76a7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212865
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-09-10 22:18:20 +00:00
Ryan Macnak 802dfdfd62 [vm, compiler] Restore the performance of LoadUniqueObject.
The purpose of LoadUniqueObject (77c206f231) is to avoid the cost searching for matching object pool entries. Pass kPatchable to AddObject to skip the work of inserting / rehashing. This also fixes incorrect use of DirectChainedHashMap::Insert with an already-present key.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/23249
Bug: https://github.com/dart-lang/sdk/issues/38018
Change-Id: I30cc3212720d3ddfc9bc515b092a4cd6f6879b8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/213027
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-09-10 21:53:26 +00:00
Jens Johansen 48d8225b17 [VM] [CFE]: Expression compilation inside extension method
This CL handles expression compilation inside extension methods better.
It is now possible to evaluate "this" and other methods defined in the
extension.

https://github.com/dart-lang/sdk/issues/46757

TEST=service tests added.

Change-Id: I3c71eb23117e26b01961f32103f4046f0b537976
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212286
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-09-10 12:02:57 +00:00
Ryan Macnak 9ab7c09356 [vm, compiler] Fix incorrect merging of doubles that are equal but not identical.
TEST=implicit_double_context_test (flaky)
Change-Id: I1c4d285897fb4dd3aae15323ab4e671bec88c564
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212870
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-09-09 20:26:35 +00:00
Alexander Markov d69828ee2f [vm/compiler] Fix nullability of LoadStaticField
TEST=vm/cc/TypePropagator_NonNullableLoadStaticField
Fixes https://github.com/dart-lang/sdk/issues/47119

Change-Id: I67b62895cbd8e79a19405b441ecca1f3ca4c9047
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212661
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-09-09 17:44:31 +00:00
Alexander Markov be06aef0f9 [vm] Fix VM unit tests for sound null safety
This change fixes vm/cc/** unit tests for sound null safety.

Also, type propagation is slightly improved for int operations to
help AOT unit tests which don't run TFA and don't have type feedback.

TEST=tested with sound null safety enabled

Change-Id: I6c42b377d4fa8035c99e5fabf1de2ae52272b994
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212862
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-09-09 17:22:01 +00:00
Alexander Markov c547e3e104 [vm/compiler] Improve elimination of dead CatchBlockEntry Parameters
This change improves elimination of dead ParameterInstr instructions
by skiping over Unbox instructions when tracing for real uses.

Previously, ParameterInstr were removed if they we used only by other
dead Parameters or as inputs to dead phis. Now, Unbox instructions
are also allowed as long as they are also dead.

TEST=vm/cc/TryCatchOptimizer_DeadParameterElimination_Cyclic1
(with sound null safety)

Change-Id: Iba807ce43d10ff6e400abd614cc749d60f2454e1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212900
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-09-09 17:20:11 +00:00
asiva 2785fe9996 [VM/Runtime] Check for valid values specified for old_gen_heap_size and
new_gen_semi_max_size

TEST=new unit test

Change-Id: I3dd985baf28c1e876c128252c15b8566d22b170d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212267
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-09-09 02:39:03 +00:00
Ryan Macnak 2f8e129713 [vm, gc] Make the generational barriers in the runtime multi-thread safe.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/46909
Change-Id: I85b1cd2a7fe7aa835b2dc6b6232dee412219f3ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212029
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-09-09 01:13:32 +00:00
Ryan Macnak 31a1fd4b6b [vm, gc] Fix a bug handling WeakProperties under the combination of concurrent marking and write-barrier elimination.
The compiler will in certain cases eliminate write barriers and the runtime will compensate by adding certain objects to a deferred marking stack. These objects will be revisited when marking is finalized. There is no header bit indicating an object has already been added to the deferred marking stack. The same object may be seen by markers multiple times: once as part of ordinary marking and several times as part of deferred marking.

When visiting a WeakProperty, if the fate of its key is not yet known, it is placed in a (worker-local) delayed weak properties list, which is a linked list threaded through the WeakProperties themselves. If more than one worker adds the same WeakProperty to its list, or a single worker does so multiple times, the lists will be corrupted. A previous fix (40cd5fc5f6) attempted to avoid this by ensuring only the worker which marked the WeakProperty would add it to a delayed weak properties list, but this can result in no worker adding the WeakProperty if the WeakProperty is allocated marked and added to the deferred marking stack.

This CL changes the processing of the deferred marking stack to treat WeakProperties as strong references. This ensures a WeakProperty will only be added to a delayed weak properties list by the single worker that encounters it during ordinary marking. This is also very similar to what would happen if the write barrier had not been eliminated: the writes into the marked WeakProperty would cause the new key and value to also become marked.

This CL also fixes another bug where when processing the delayed weak properties lists, the worker would try to ask whether a new-space object was marked.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/47128
Change-Id: Id9abaeb4dd52538ebc22ac58e48abcb7ed760854
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212612
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-09-08 17:40:19 +00:00
Ryan Macnak f9b7ed74dc [vm] Remove dead library references from the object store.
- dart:_builtin is only available in the standalone embedder, and should have never been referenced by the VM proper.
 - dart:profiler was long ago renamed to dart:developer.

TEST=build
Change-Id: I0743f52efc3331a8500494b2d87f621190566b62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212680
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-09-08 16:29:19 +00:00
Vyacheslav Egorov d8d7af15ce [vm] Migrate away from native 'name' syntax.
As part of deprecating support for native extensions we are also
migrating away from legacy VM-specific `native 'name'` syntax
towards metadata based encoding which does not require any special
syntax.

This CL is a step 1 in migration:

- introduces support for `@pragma('vm:external-name', 'name')`
which serves as a direct replacement for `native 'name'`;
- all core libraries and tests are migrated to use the annotation;

Once this CL lands and rolls we will edit internal and external embedders
to eliminate uses of the native keyword (step 2) and finally remove
support for native keyword across our parsers (step 3).

TEST=ci

Bug: https://github.com/dart-lang/sdk/issues/28791
Change-Id: Id6dea878db82dd4fd81149243c425b5c5dc6df86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212461
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2021-09-08 13:39:34 +00:00
Martin Kustermann ebcf042ed2 [vm] Remove kFfiPointerCid/kFfiDynamicLibraryCid
There have been duplicate cids

  * kPointerCid / kFfiPointerCid
  * kDynamicLibraryCid / kFfiDynamicLibraryCid

Only one of each made sense. This CL ensures we have only the former.

TEST=ci

Change-Id: Icdcef40c80ed09815da6074a774a02c707f6be37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212592
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2021-09-08 11:58:55 +00:00
Ryan Macnak bc43e97b74 [vm] Place only Dart heap pages in the 4GB compressible region.
Don't allocate zones, timeline events or profile samples in the compressible region, since these allocations don't yeild compressed pointers and are competing for a limited resource.

TEST=ci
Bug: b/196510517
Change-Id: I4fc2f0d67060f927fa10d241b15b1cae3b73d919
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212400
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2021-09-08 01:16:57 +00:00
Ryan Macnak 77467fe2f7 [vm] Remove excess types from the object store that were needed by the old serializer.
Many of these types were added by 93c5134a69 so that they would be serialized by reference and easier to skip over in the API message deserializer. With the new deserializer, any type can be successfully skipped over.

TEST=ci
Change-Id: Ie8150e382c69ee5d2e575bc16b42f8d80b9b0969
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208682
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2021-09-08 00:37:46 +00:00
Alexander Markov 16e8dc257e [vm] Faster double.floor()/ceil()/truncate() in AOT mode (x64, arm64)
1) double.truncate() now simply calls toInt(), omitting
truncateToDouble() call.

2) double.floor() and ceil() are now intrinsified on arm64 and AOT/x64
and generated using DoubleToInteger instruction.

3) DoubleToInteger instruction is extended to support floor and ceil.
On arm64 DoubleToInteger is implemented using fcvtms and fcvtps
instructions. On x64 DoubleToInteger is implemented using roundsd
under a check if it is supported (with a fallback to a stub and a
runtime call).

AOT/x64:
Before: BenchFloor(RunTime): 318.82148549569655 us.
After:  BenchFloor(RunTime): 133.29430189936687 us.

TEST=ci
Closes https://github.com/dart-lang/sdk/issues/46876
Closes https://github.com/dart-lang/sdk/issues/46650

Change-Id: I16ca18faf97954f8e8e25f0b72a2bbfac5bdc672
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212381
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2021-09-07 19:52:04 +00:00
Alexander Markov 74dc879d25 [vm/compiler] Optimize 'double == int' in AOT
TEST=vm/cc/IRTest_DoubleEqualsSmi
Fixes https://github.com/dart-lang/sdk/issues/47031

Change-Id: I6395ae50806b238971872b375c495962cb868cb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212484
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2021-09-07 17:06:43 +00:00