Commit Graph

2925 Commits

Author SHA1 Message Date
Alexander Aprelev 715bbe363b Revert "[vm] Share some comparison and condition code across platforms."
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>
2020-04-03 20:43:33 +00:00
Aske Simon Christensen f8ead09ba2 [vm] Distinguish between bool objects by a single bit in their pointers.
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>
2020-04-03 19:08:27 +00:00
Regis Crelier 667039de2b [VM/nnbd] Minor cleanup when checking required named parameter in strong mode.
This avoids decoding the required flag when no named parameters are declared.

Change-Id: Ife557f544493b75772d598dc06915a8b521c82e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142068
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-04-02 16:51:35 +00:00
Alexander Markov 6e53ac6e4c [vm/nnbd] Fix supertype check in GenerateSubtype1TestCacheLookup
Before calling Subtype1TestCache stub, there was a quick check if
supertype's class id matches tested class id.
Null extends Object, so supertype of Null matches Object.
However, in NNBD strong mode Null is not assignable to Object.

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

Change-Id: Icc3efaf90992b5083cbe086af81db7504724b855
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142085
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-04-02 01:39:10 +00:00
Ryan Macnak 74da2edd3d [vm] More do not allocate when evaluating arguments to StorePointer.
If the first argument is evaluated first, it is an untracked interior pointer that will be used after any GC that occurs while evaluating the second argument.

Bug: https://github.com/dart-lang/sdk/issues/41144
Bug: https://github.com/dart-lang/sdk/issues/41262
Change-Id: I2c835b55a12af8d44ac2eee431e4e24b69030600
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141910
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-04-01 16:26:05 +00:00
Teagan Strickland b55342cb3e [vm/aot] Drop some Function objects not needed at runtime.
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>
2020-03-30 18:33:48 +00:00
Ryan Macnak 0ce39a7c10 [vm] Do not allocate when evaluating arguments to StorePointer.
If the first argument is evaluated first, it is an untracked interior pointer that will be used after any GC that occurs while evaluating the second argument.

Bug: https://github.com/dart-lang/sdk/issues/41144
Change-Id: If504da5ea6192d7937bfb9f6857e0169674231e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141203
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-03-28 00:59:31 +00:00
Siva Annamalai ba389f9061 Revert "[VM] - Delete non-nullable-flag() function and adjust code that was"
This reverts commit 1178f96600.

Reason for revert: "Gets an error VM initialization failed: To use --null-safety, please enable --enable-experiment=non-nullable"

Original change's description:
> [VM] - Delete non-nullable-flag() function and adjust code that was
>        using it.
> 
> Change-Id: Ibaf439fbef5e5e183f16240c4ee02b7031bc35c4
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140882
> Commit-Queue: Siva Annamalai <asiva@google.com>
> Reviewed-by: Régis Crelier <regis@google.com>

TBR=kevmoo@google.com,asiva@google.com,regis@google.com

Change-Id: Ia651ec60f8ecfc82a305bcff855a6ca6c2ab9e27
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141026
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2020-03-26 03:32:56 +00:00
asiva 1178f96600 [VM] - Delete non-nullable-flag() function and adjust code that was
using it.

Change-Id: Ibaf439fbef5e5e183f16240c4ee02b7031bc35c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140882
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2020-03-25 22:57:46 +00:00
Regis Crelier 33cafef25e [VM/nnbd] Do not check nullability of LHS too early in strong mode (fixes #41160).
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>
2020-03-25 20:26:26 +00:00
Daco Harkes 55659b0372 [vm] Make our AOT pipeline work independent of the FLAG_precompiled_mode
Closes: https://github.com/dart-lang/sdk/issues/36521

Change-Id: I8f56d7bc9f3bfc7f4a6f0dcbee66f99838dde3cb
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-release-simarm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136622
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2020-03-25 11:58:20 +00:00
Teagan Strickland 34742535d6 [vm] Look up dynamic symbols in DWARF stack traces.
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>
2020-03-23 10:13:43 +00:00
asiva 1bab476834 [VM/NNBD] - Make the null safety flag be isolate specific.
Change-Id: I73a1e8a22db770ca14af6d53707a335bbbcdabcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139029
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2020-03-20 02:09:29 +00:00
Liam Appelbe 347793ec70 [vm] Fix a bug in required param function subtyping
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>
2020-03-19 20:37:38 +00:00
Regis Crelier eca06cd299 [VM/nnbd] Normalize FutureOr<T> when loading kernel file.
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>
2020-03-19 00:19:10 +00:00
Regis Crelier a94fb21f08 [VM/nnbd] Fix normalization of FutureOr<T> after instantiation (fixes #41005).
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>
2020-03-18 16:02:11 +00:00
Martin Kustermann 8acd25a2e8 [vm/reload] Use CFEs Class::hasConstConstructor flag
The CFE has added this flag (on VM's request) in [0]. We can now use it
instead of our approximation of all fields are final (i.e. this is a
follow-up to [1])

[0] https://dart-review.googlesource.com/c/sdk/+/134292
[1] https://dart-review.googlesource.com/c/sdk/+/133228

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

Change-Id: I3975ef84f29cd47d56b5a3211c649d42da654f53
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139620
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-03-17 17:33:02 +00:00
Regis Crelier 7953996d4c [VM/nnbd] Print non-nullable Object as bound in strong mode only.
Change-Id: I030ca9e1f8dd5f1a764ba83d7949fc596cbaded3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139687
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-03-16 22:02:26 +00:00
Regis Crelier cfc006a8f4 [VM/nnbd] Fix sharing of type argument vectors (fixes #40451).
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>
2020-03-13 22:29:47 +00:00
Victor Lima 8fd8fec185 [vm/aot] Add support to instance calls with unboxed parameters
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>
2020-03-06 19:47:23 +00:00
Victor Lima b951498903 [vm/aot] Allow static methods to have unboxed args and return
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>
2020-03-05 15:17:04 +00:00
Régis Crelier 5701c4fd3b [VM/nnbd] Remove propagation of library mode to runtime after spec change.
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>
2020-03-03 20:30:32 +00:00
Liam Appelbe 149b799ae4 [vm] Check required flag during function resolution.
Bug: https://github.com/dart-lang/sdk/issues/39660
Bug: https://github.com/dart-lang/sdk/issues/38843
Change-Id: I2eb5f5ac38d7b1896db5c57399c42cdb41b16094
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137737
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2020-03-02 23:05:16 +00:00
Alexander Markov af4f3a720c [vm/nnbd] Eliminate 'Undetermined' nullability from the VM
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>
2020-03-02 19:06:33 +00:00
Martin Kustermann 619e9202b7 [vm] Do not call MSAN_CHECK_INITIALIZED for ExternalData created via dart:ffi
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>
2020-03-02 12:11:20 +00:00
Vyacheslav Egorov 9f2455796f [vm/snapshot] Make references between code and pool entries explicit in snapshot profile.
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>
2020-02-28 10:40:33 +00:00
Régis Crelier 63e36183ae [VM/nnbd] Follow-up to earlier commit acd7b83.
Revert some changes from https://dart-review.googlesource.com/c/sdk/+/137460
Avoid handle allocations in Instance::NullIsInstanceOf()

Change-Id: I66c8d960333270bd79b2b39c0c67dad754112e0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137654
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-02-27 23:24:43 +00:00
Ryan Macnak f3031b6b79 Reland "[vm] Handle sentinel in the IL serializer and Array-backed hash maps."
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>
2020-02-27 23:21:23 +00:00
Régis Crelier acd7b8367e [VM/nnbd] Nullability of FutureOr and of its type arg do not necessarily match.
Change-Id: Ie1cb6287cdfa852c8ac73868b571b422fbc9dc0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137460
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-02-27 21:08:24 +00:00
Régis Crelier 21bc1ed76c [VM/nnbd] Allow instantiation of a non-nullable type parameter to a nullable type.
Change-Id: Icc3413cd5c285fa40ee5188f39837625d78b9e67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137427
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-02-27 19:48:23 +00:00
Ryan Macnak 02f69a713e Revert "[vm] Handle sentinel in the IL serializer and Array-backed hash maps."
This reverts commit 62396cac55.

Reason for revert: Code size regressions likely due to the hash map change

Original change's description:
> [vm] Handle sentinel in the IL serializer and Array-backed hash maps.
> 
> Fixes crashes in vm/dart when use_nnbd = true.
> 
> Change-Id: Ieeb45227208cc6219f536130df38249d902dfe7f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137462
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com,liama@google.com

Change-Id: I789bd219a7ab335771fcc0b39f25e9d0104945e0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137640
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-02-27 18:08:43 +00:00
Ryan Macnak 95f87f321a [vm, io] Fix some MemorySanitizer issues.
Change-Id: Id6e085563b05861351c431a9c067387b4b01270b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137380
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-02-27 17:50:43 +00:00
Alexander Markov 77e1c72d04 [vm/nnbd] Type testing stubs in NNBD strong mode
Issue: https://github.com/dart-lang/sdk/issues/38845
Change-Id: I82e7a1b3c4220abdd2a215529230fbb158adbe9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135627
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2020-02-27 04:36:24 +00:00
Ryan Macnak 62396cac55 [vm] Handle sentinel in the IL serializer and Array-backed hash maps.
Fixes crashes in vm/dart when use_nnbd = true.

Change-Id: Ieeb45227208cc6219f536130df38249d902dfe7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137462
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-02-27 01:43:24 +00:00
Régis Crelier 432fa1b4e8 [VM/nnbd] Implement pre-nnbd language changes (see lang/#807).
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>
2020-02-26 21:32:51 +00:00
Liam Appelbe 9e03c2c506 [vm] Add required flag to parameters, and implement subtyping rules.
This CL only covers AST mode, and doesn't address function resolution.

Bug: https://github.com/dart-lang/sdk/issues/39755
Change-Id: I19280fb0d373aa9eb17da13677fd5bb1230385da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131701
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2020-02-26 00:38:54 +00:00
Régis Crelier d10ffdb4c3 [VM/nnbd] Check nullability of function types in strong mode (fixes #39820).
Also added "// Requirements=nnbd-strong" to test (correctly fails in weak mode).

Change-Id: If375b912b03c50cf968fcc45bd78be3d9bc1cb33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137241
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-02-26 00:05:53 +00:00
Alexander Markov 55cc495451 [vm/nnbd] Rename --strong-non-nullable-type-checks to --null-safety and pass it to CFE
Issue: https://github.com/dart-lang/sdk/issues/38845
Change-Id: I9baeb4a384a6b2de79df9f97e82c127ae4f611c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137120
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2020-02-25 20:05:39 +00:00
Régis Crelier baa0bc0d8e [VM/nnbd] Fix type parameter comparison used in type equality.
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>
2020-02-25 02:31:50 +00:00
Ryan Macnak 388c91df04 [vm] Remove the "compilation allowed" bit.
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>
2020-02-21 17:50:13 +00:00
Alexander Markov 1ec87d1770 [vm/nnbd] Fix TypeArguments::IsUninstantiatedIdentity for NNBD
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>
2020-02-20 23:39:46 +00:00
Régis Crelier fd20c7b92b [VM/nnbd] Print nullability of types by default.
Only '?' is shown by default.
To print '*' and '%', use debugging flag --show-internal-names.
Fix expectations in tests.

Change-Id: Idc60fbfb4d477602eb0c713f4bdcc1e573a3328a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135790
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
2020-02-20 21:43:25 +00:00
Martin Kustermann dae308461c [vm/concurrency] Share [Heap] and [SharedClassTable] between all isolates within one isolate group
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>
2020-02-20 21:08:35 +00:00
Régis Crelier f7a901751b Reland "[VM/runtime] Fix type tests with LHS FutureOr (fixes #38906)."
This is a reland of 3ef5270f71

Original change's description:
> [VM/runtime] Fix type tests with LHS FutureOr (fixes #38906).
> 
> Fixes tests/language_2/subtyping_static/future_or_subtype_test
> Also simplifies code making use of TypeAtNullSafe().
> 
> Change-Id: I045a030b2ece9d6980f7a9ba785948f0c10f697b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135625
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

Change-Id: Ie3254f6aca3d47a00aead0ac34f3a6b9f301d8dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136680
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-02-20 21:01:25 +00:00
Régis Crelier 088e31036b Revert "[VM/runtime] Fix type tests with LHS FutureOr (fixes #38906)."
This reverts commit 3ef5270f71.

Reason for revert: precomp not tested by CQ and failing

Original change's description:
> [VM/runtime] Fix type tests with LHS FutureOr (fixes #38906).
> 
> Fixes tests/language_2/subtyping_static/future_or_subtype_test
> Also simplifies code making use of TypeAtNullSafe().
> 
> Change-Id: I045a030b2ece9d6980f7a9ba785948f0c10f697b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135625
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=alexmarkov@google.com,asiva@google.com,regis@google.com,liama@google.com

Change-Id: Ie6399e6c6cfd602dc7388a1a9ef5a7c335e70c65
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136528
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-02-20 01:47:45 +00:00
Régis Crelier 3ef5270f71 [VM/runtime] Fix type tests with LHS FutureOr (fixes #38906).
Fixes tests/language_2/subtyping_static/future_or_subtype_test
Also simplifies code making use of TypeAtNullSafe().

Change-Id: I045a030b2ece9d6980f7a9ba785948f0c10f697b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135625
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-02-20 01:14:15 +00:00
Victor Lima 7eedaf192f [vm/aot] Fix broken benchmarks
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>
2020-02-19 20:49:29 +00:00
Samir Jindel 1fbc71da0f Re-land "[vm] AOT blobs snapshots are obsolete. Remove dead code."
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>
2020-02-17 11:12:15 +00:00
Alexander Markov c1616f92ef [vm] Introduce FutureOr class in the VM
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>
2020-02-14 21:40:17 +00:00
Teagan Strickland 6d04a0db25 [vm] Clean up interfaces/encoding for CompressedStackMaps.
Change-Id: Ie897f44fc02e1e9ae37f2625f3cb0ac4df1595d6
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/+/135651
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-02-14 17:57:47 +00:00