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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
* 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>
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>
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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>