This reverts commit 87b4848bfc as it broke simarm, simarm64 builds.
Revert "[vm] Distinguish between bool objects by a single bit in their pointers."
This reverts commit f8ead09ba2 being collateral damage for the revert above.
Change-Id: I0a12fe8095566430823c094b294c490b59cb3c39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142404
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Allocate the canonical true and false objects right after the null
object such that their pointers are the same except for a single bit.
This enables a number of optimizations:
- Test of a bool value becomes a bit test when it is known that the
value is a bool. on ARM64, this bit test can be combined with the
branch.
- Negation of a bool value becomes an xor when it is known that the
value is a bool.
- Load of a bool value becomes an immediate add with the null register
on ARM64.
Change-Id: I70db024437e0f9cb15c401354e5e35802c354172
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137100
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
In particular, don't serialize a function if its code is used by the
dispatch table, but there's no need for the function object itself
at runtime like dynamic lookup or dynamic invocation forwarders.
However, just because the owning function is not needed at runtime,
it may be used during serialization for things like assembly label
creation. Thus, instead of just clearing out the Code's owner field,
we add a new WeakSerializationReference (WSR) object whose target is
the original contents of the owner field. The WSR allows the
serializer to access the original owner, but also signals to the
serializer that the target should not be serialized in AOT snapshots
unless there are additional strong (non-WSR) references.
If no strong references are found, then the references to the WSR
in the snapshot are replaced with a reference to a WSR that only
contains the class ID of the original target. The serializer creates
only one WSR per class ID.
If strong references are found, then the target is still serialized.
In this case, the WSR is dropped entirely and any reference to it is
replaced with a direct reference to the serialized target. Thus, WSRs
only exist in the precompiled runtime for targets with no strong
references.
Changes on the Flutter gallery in release mode:
arm7: total size -1.10%, isolate size -6.08%
arm8: total size -1.16%, isolate size -6.09%
Bug: https://github.com/dart-lang/sdk/issues/41052
Change-Id: I5b435ca71ef85f50fe3484789087471a91aa4fe2
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-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-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137104
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Nullability of left hand side in type test was checked too early, i.e. before
handling FutureOr on the right hand side.
The following tests began passing (in strong mode):
standalone/io/addlatexhash_test was fixed (RuntimeError -> Pass)
standalone/io/file_output_stream_test was fixed (RuntimeError -> Pass)
standalone/io/file_stream_test was fixed (RuntimeError -> Pass)
standalone/io/file_system_async_links_test was fixed (RuntimeError -> Pass)
standalone/io/file_system_links_test was fixed (RuntimeError -> Pass)
standalone/io/file_write_only_test was fixed (RuntimeError -> Pass)
standalone/io/pipe_server_test/0 was fixed (RuntimeError -> Pass)
standalone/io/pipe_server_test/1 was fixed (RuntimeError -> Pass)
standalone/io/pipe_server_test/2 was fixed (RuntimeError -> Pass)
standalone/io/pipe_server_test/3 was fixed (RuntimeError -> Pass)
standalone/io/pipe_server_test/4 was fixed (RuntimeError -> Pass)
standalone/io/pipe_server_test/5 was fixed (RuntimeError -> Pass)
standalone/io/stream_pipe_test/0 was fixed (RuntimeError -> Pass)
standalone/io/stream_pipe_test/1 was fixed (RuntimeError -> Pass)
standalone/io/stream_pipe_test/2 was fixed (RuntimeError -> Pass)
standalone/io/stream_pipe_test/3 was fixed (RuntimeError -> Pass)
Change-Id: I855328f101382cf5f1af9119b396aa9d0cb14e40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140776
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
If lookup succeeds, then the DWARF stack frame uses the symbol
name and offset instead of the dynamic library name. The
native_stack_traces package (once updated) can translate these
stack frames into symbolic stack frames even if given a partial
stack trace without the header.
Also, consistently use uword instead of a mix of uintptr_t and uword.
Change-Id: Ida9ba4726a306fb77b141cb9c6ad635a12a320ec
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140282
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
I missed an edge case in the subtyping rule. If the this function
has a required param, and the other function is entirely missing
that param, then we would mistakenly call that a valid subtype.
language/nnbd/required_named_parameters/required_named_args_strong_test
found the bug. This test is now passing in strong mode.
Bug: https://github.com/dart-lang/sdk/issues/40968
Change-Id: Ica13bcf4d287e13050f81652e07dcc40c155a801
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140143
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
CFE does not always normalize FutureOr<T> eagerly, e.g. it does not normalize
FutureOr<Null> parsed in the source. However, it normalizes inference or
instantiation results.
For performance reasons, the VM chooses to do it eagerly, i.e. it must also
normalize unnormalized types from a kernel file.
Change-Id: I5798333ba3c58c5b2851045ef32c345d94f58268
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139955
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Note that the remaining failure on line 28 of test
language/nnbd/type_equality/futureOr_normalization_legacy_test
is due to the CFE failing to normalize at compile time.
Change-Id: I8e982830f59cfa5cdf45314aa7a34026975ba952
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139863
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
Apply the same fix as in https://dart-review.googlesource.com/c/sdk/+/136709
to TypeArguments::CanShareInstantiatorTypeArguments and to TypeArguments::CanShareFunctionTypeArguments.
Move the inlined code performing an instantiation cache lookup to stubs in order to reduce code size.
Add stubs checking nullability of type arguments to share instantiator (or function) type arguments before looking up instantiation cache, and possibly calling into the runtime for instantiation.
Modify constant propagator to instantiate constant type arguments at compile time.
Change-Id: I72fee1a6881ac3bec55fae7d0ef5a3361544a141
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138009
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
In order to have instance calls with unboxed parameters, all
the possible targets need to be able to those parameters unboxed.
Then, the methods were partitioned according to the class hierarchy,
and the inferred types from TFA are used to determine the parameters
that could be unboxed.
This is done for non-nullable integer and double parameters, and
return value.
dart-aot linux x64:
Bench2D 8.028%
DeltaBlue 4.688%
ParticleSystemPaint 27.79%
Flutter release android-armv8:
velocity_tracker_bench -2.026% (less is better)
flutter_gallery_total_size -0.1460%
flutter_gallery_instructions_size -0.2715%
flutter_gallery_readonlydata_size 0.0539%
Issue https://github.com/dart-lang/sdk/issues/33549
Change-Id: Iedd9b4321c3d78b406ea1708e15c747754433027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138501
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
Static methods and constructors may receive unboxed parameters.
This change adds a bitmap to the RawFunction object indicating
which parameters are unboxed and their types. Also, the stack frame
bitmap was updated to include new bits for those parameters.
The ArgumentsDescriptor object was updated to store not only the number
of arguments, but also their size, since 32-bit platforms would use two
words for each int64 and double value.
In addition, static methods that return non-nullable integers
and doubles may return these values unboxed.
Dart AOT x64:
TypedData.Uint8ClampedListViewVarBench +11.73%
DeltaBlue +9.32%
Meteor (Intel Xeon) +4.64%
Flutter release android-armv8:
velocity_tracker_bench -2.32% (less is better)
flutter_gallery_readonlydata_size +0.18%
flutter_gallery_total_size +0.13%
flutter_gallery_instructions_size +0.12%
Issue https://github.com/dart-lang/sdk/issues/33549
Change-Id: I97e310f8f30213920af2333fbdedf193d03db5c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135313
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
On 1/27/20, the nnbd specification changed weak and strong mode instance checks
to make them behave uniformly across legacy and opted-in libraries.
Therefore, it is not necessary anymore to propagate the library mode in
generated code to the runtime.
Change-Id: I42d3ddc6e9a921899aeac21be6374c7893a6d27c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138111
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
VM should treat type parameters with kUndertermined and kNonNullable
nullability in the same way (both can be instantiated with a legacy
type and even nullable Null in a legacy library).
So kUndertermined nullability can be converted to kNonNullable
when reading kernel, and code which handles kUndertermined nullability
can be simplified.
Change-Id: Ib5dbd92ae9ee3754f3e64629e0a03952aadfd287
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137862
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
It is common to allocate memory via `dart:ffi`, use
`Pointer.asTypedList()` to get an external typed data and finally
initialize it in Dart.
b/150573916
Change-Id: I72ce2e3474e41d1553bc8ca2c782b61d93b97874
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137961
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Code references other objects via object pools. In bare instructions mode
individual objects pool are merged together into a global object pool,
which means that we no longer can clearly see which objects are
referenced by each individual code object.
This CL adds logic into snapshot writer to include these implicit
references into the snapshot profile. We achieve this by keeping
individual object pools around (but avoiding writing them into the
snapshot itself).
R=sjindel@google.com
Change-Id: I35b48fcfc26c0a8c0b66593139fa7ac8e627da6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136626
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
Reverse use of the backing store and transition sentinel as bookkeeping values. Use transition sentinel to mark unused entries, since it has a short object id during clustered serialization. Use the backing store to mark deleted entries; deletion seems to only be used for enum values during a hot reload.
Change-Id: I52f0edcbc7e26f73843500cd378da31ea3b1e0ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137680
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Normalize FutureOr<T> and Never? after instantiation.
Use mutual subtyping of bounds in generic function type parameters instead of structural equality.
Change-Id: I78b836d8bd2f091bd56e5a0f9c2089a411fa6f6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135787
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
This is a partial fix for issue #40733.
Handling of required named parameters is not implemented yet.
This is also fixing:
language_2/type/alias_equality_test/03 was fixed (RuntimeError -> Pass)
language_2/type/alias_equality_test/04 was fixed (RuntimeError -> Pass)
Change-Id: I97f6327fa08c6fc140c1d8805f85eaa204ebc037
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136881
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
In the early days of AOT, we performed compilation and then ran results in the same process and isolate. This bit was used to track which phase we were in. Today, these always happen in separate processes and separate binaries, distinguished by the macro DART_PRECOMPILED_RUNTIME.
Change-Id: Idd97908f2e692321a6f5aba8d5738625d42f16e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134568
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
TypeArguments::IsUninstantiatedIdentity predicate is checking if
instantiator type arguments could be reused when instantiating
given type arguments (when given type arguments repeat type parameters).
This predicate was not accounting for nullable and legacy type
parameters which could change nullability of types when instantiated.
For example:
class A<T> {}
1. instantiator type arguments [int], instantiating A<T?> results in
[int?] type arguments vector, so instantiator type arguments should
not be reused.
2. instantiator type arguments [int], instantiating A<T*> results in
[int*] type arguments vector so instantiator type arguments should
not be reused.
Change-Id: I1e041486829e8ac0cfd3ce59d0ec5164a0f3724c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136709
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
This CL:
* Moves [Heap]/[SharedClassTable] from [Isolate] to [IsolateGroup], which
will make all isolates in the group use the same heap. The GC will use
the shared class table for object size information.
* Adds support for entering/leaving an isolate group as a helper thread
(e.g. via [Thread::EnterIsolateGroupAsHelper]). The current active
isolate group can be accessed via TLS `IsolateGroup::Current()` or
`Thread::isolate_group_`. When entering as a helper thread there will be
no current isolate.
* Changes the GC to use the above mechanism and ensures GC works without
a currently active isolate. The GC will use information purely available via
[IsolateGroup]. The GC will iterate all isolates within an isolate
group e.g. for scanning roots.
* Makes spawning of new isolates start in their own isolate group.
Once the isolate is fully functional it's heap will be merged into
the original isolate group
* Moves ApiState, containing persistent and weak persistent handles,
from [Isolate] to [IsolateGroup], plus adds appropriate locking.
Issue https://github.com/dart-lang/sdk/issues/36097
Change-Id: Ia8e1d8aa78750e8400864200f4825395a182c004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126646
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This CL fix an assertion inside Serializer::WriteInstructions
that was always failing in debug mode AOT 32-bit platforms
which used to happen when Utils::IsUint was called with a
signed type value was being passed.
It also fixes a bug that happens on some architectures that do not
support atomic unaligned load operations of 64-bit values.
Change-Id: Ic26cdeabccb55fcda5257da00f13dc400fa37e9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136228
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Original change is in Patchset 1. I erroneously assumed DART_PRECOMPILER
was only used AOT compilation (it is also used for JIT snapshots).
Change-Id: I77f6c463db7f2b482c9b098f353dc28f0676ea0d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135900
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Samir Jindel <sjindel@google.com>
This makes it possible to use FutureOrCid in the VM and efficiently
test if type is FutureOr. This also makes it possible to use predicates
like IsTopType very early during VM bootstrapping (before reusable
handles are initialized). The latter is needed to correctly select
type testing stub for top types.
Change-Id: I4c482143c0ebaafa1c8e13e95dc6f20e3af7059a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136000
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>