Commit Graph

2925 Commits

Author SHA1 Message Date
Ryan Macnak 6b91f92154 [vm] Move megamorphic miss handling into the megamorphic call stub.
This removes the only stub code with a function owner.

Change-Id: I629eb3a1b231430afaf0a2777032bba8eaddd2aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148124
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-05-15 20:28:21 +00:00
Alexander Aprelev 2472741ba0 [vm] Fix instance hash calculation to accommodate unboxed fields during cross compilation.
Instance hash calculation on host and on target should produce same
results(like when you use simarm_x64/gen_snapshot to produce arm snapshot).
It was not producing same results because of how unboxed fields could be
taking more than one word(on 32-bit arm they are taking two words).
Hash calculation was done in terms of words so simarm_x64/gen_snapshot
saw one word unboxed field, but same calculation saw two words.

The fix is to pay special attention when iterating over unboxed field
during hash calculation and accommodate host and target word size
difference.

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

Change-Id: Ib280736fa458a3954ca1f9994734ad04ee8db80a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/148040
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-05-15 01:28:55 +00:00
Vyacheslav Egorov 467ba2f3fb [vm/compiler] Include tests for parsing of --print_instruction_sizes_to output
These were supposed to be included into d959f4290e
but were accidentally left behind.

Readding these tests revealed a bug in the main commit - where
async/async*/sync* bodies were not properly disambiguated. There is a
change included here which fixes that.

Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: I1fff57c8d7b16ee72dd670f1a309dd756a2b2653
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147580
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2020-05-13 11:37:21 +00:00
Alexander Aprelev 3df9baeb06 [vm] Fix typo in calculation of native wrapper class size in precompiler configuration.
At present there is difference in assembly output from SIMARM/gen_snapshot and SIMARM_X64/gen_snapshot around classes that extend native wrappers(for example, dart:io NativeSocket).

See dartbug.com/41824.

Change-Id: I944901ff4cccde972623c490d1d67d894fb03595
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147808
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-05-12 22:31:39 +00:00
Ryan Macnak 40d876382a [vm] Fix various UBSan failures: AOT.
Bug: https://github.com/dart-lang/sdk/issues/39427
Change-Id: I2594e28a277f1d9f838aa93d546714d4f300b5b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147682
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-12 20:28:11 +00:00
Aske Simon Christensen 14103a366d [vm] Add _allocate and _setAt methods to _TwoByteString.
Also base these and the corresponding methods in _OneByteString on
functions in dart:_internal, so they can be used in other patches.

Change-Id: Ibced31758db2959c111a01cdaa46df2971ae4a6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146784
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-05-12 17:33:50 +00:00
Zichang Guo 9a60982089 [dart:io] serialize UnmodifiableListView to Uint8List for file write
Bug: https://github.com/dart-lang/sdk/issues/41029
Change-Id: I5902f01a22787922439f0918b6e845eb004b8984
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139881
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2020-05-12 00:19:01 +00:00
Tess Strickland a6d06b59ec Reland "[vm] Mark snapshots that were compiled directly to ELF.
Since the virtual addresses in ELF snapshots are the same as in
separately saved debugging information, print the virtual address in
non-symbolic frames again when running from a snapshot compiled directly
to ELF."

Storing the relocated address as an extra field in the Image header,
which requires increasing the Image header size on 64-bit platforms,
means Image pages cannot be used reliably as HeapPages as objects no
longer start after kMaxObjectAlignment bytes.

Instead, we return to an older design that just uses the lowest bit
in the BSS offset to store whether the instructions in an Image were
compiled directly to ELF.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-precomp-ffi-qemu-linux-release-arm-try
Change-Id: I3819b0dc2719d69f5e8764ca8be8c6ae7171a7bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146560
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2020-05-11 08:41:17 +00:00
Ryan Macnak 5241586246 [vm, gc] Rename HeapPage to OldPage for symmetry.
Change-Id: I282eaf894fad17a731dbfc76873468b04117cebd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147324
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-05-08 18:28:06 +00:00
Regis Crelier eae248cc41 [VM/compiler] Emit a throw NoSuchMethodError for bad arity rather than aborting compilation.
The bad arity maybe detected after an isolate reload or when using strong mode with a mix of opted in and opted out libraries.
The thrown NoSuchMethodError contains enough information to be useful, but does not mirror the complete invocation (e.g. arguments).

This CL does not fix https://github.com/dart-lang/sdk/issues/37517 where the target is missing after a reload (not just bad arity).

The VM implementation of NoSuchMethodError is cleaned up, but the deprecated constructor 'NoSuchMethodError(...)' is not yet removed, since it is still documented.

Change-Id: I0306971c59cb510d21cb1b1acc3545c8817dfea7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146986
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-05-08 18:08:26 +00:00
Alexander Markov dd2d040ccb [vm] Cleanup flags which disable argument type checks and strong mode types
The following options are removed:
--use_strong_mode_types
--experimental_unsafe_mode_use_at_your_own_risk

The following flags and predicates are removed:

Dart_IsolateFlags::unsafe_trust_strong_mode_types
Isolate::argument_type_checks()
Isolate::can_use_strong_mode_types()
Isolate::should_emit_strong_mode_checks()

Also, everything depending on these flags is cleaned up.

Change-Id: I9328009ad5a42ea2173842386d612c465e3ebec1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147325
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-05-08 15:53:09 +00:00
Ryan Macnak 2707880f1b [vm] Fix various UBSan failures.
Bug: https://github.com/dart-lang/sdk/issues/39427
Change-Id: I74e0eee623d88005fb2893d03e284a87daa09260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146696
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-05-07 19:40:18 +00:00
Vyacheslav Egorov d959f4290e [vm/compiler] Disambiguate Code names when emitting instruction sizes info.
Previously the output used scrubbed qualified names which hides some
of the information and causes names of various synthetic functions
collide. We change it to use internal qualified names instead and add
additional information for disambiguation:

- For functions this means adding a prefix for various synthetic
methods;
- For anonymous closures we add their token position;
- For types we prefix type parameters with their owner's name.

We also add a unit test covering parsing of
--print-instructions-sizes-to output.

As part of adding a test dart2native was changed to support passing
extra arguments to gen_snapshot binary.

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

Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-try,pkg-win-release-try,pkg-mac-release-try
Change-Id: I299ab0fb5993c8af9b51246483608d1e65970d67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146581
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2020-05-07 12:39:27 +00:00
Tess Strickland 049949fdf4 Revert "[vm] Mark snapshots that were compiled directly to ELF."
This reverts commit 250b84987d.

Reason for revert: Failures on FFI CI tests.

Original change's description:
> [vm] Mark snapshots that were compiled directly to ELF.
> 
> Since the virtual addresses in ELF snapshots are the same as in
> separately saved debugging information, print the virtual address in
> non-symbolic frames again when running from a snapshot compiled directly
> to ELF.
> 
> Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try
> Change-Id: Ie531953da7edd024cea02c0571e1e1dd7d7427eb
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145840
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>

TBR=vegorov@google.com,rmacnak@google.com,dacoharkes@google.com,sstrickl@google.com

Change-Id: I1c5f58e9d9e11b994c1016970839f95b92885d43
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try, vm-kernel-precomp-linux-product-x64-try, vm-kernel-precomp-linux-debug-x64-try, vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146220
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2020-05-04 09:52:25 +00:00
Tess Strickland 250b84987d [vm] Mark snapshots that were compiled directly to ELF.
Since the virtual addresses in ELF snapshots are the same as in
separately saved debugging information, print the virtual address in
non-symbolic frames again when running from a snapshot compiled directly
to ELF.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try
Change-Id: Ie531953da7edd024cea02c0571e1e1dd7d7427eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145840
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2020-05-04 09:19:23 +00:00
asiva c740bbc161 [VM] Set up Isolate specific null safety mode
- change the null_safety flag to be a tri state flag (unspecified, no
  null safety and null safety)
- added logic to set the null safety mode of an isolate based on the
  value specified in the kernel file (.dill file) if the null safety
  flag is not specified on the command line
- added logic to auto detect the null safety mode based on the language
  version API provided by CFE
- added logic to pass the correct null safety option to CFE when
  invoking it for compilation based on the null-safety flag setting
- Delete non-nullable-flag() function and adjust code that was using it.
- Remove 'nnbd-experiment' from the snapshot string.

https://github.com/dart-lang/sdk/issues/41206
https://github.com/dart-lang/sdk/issues/41207

Change-Id: I006bf3c9229980fc7986faac6a5850d3722aec92
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143160
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-05-01 04:03:04 +00:00
Alexander Markov 8d16dbb17f [vm/nnbd] Revise IsTopType* predicates
IsTopTypeForAssignability is renamed to IsTopTypeForSubtyping to better
reflect that it works both for subtyping and assignability.

Most uses of IsTopType() are changed to IsTopTypeForSubtyping().

The remaining uses of IsTopType() are checking for top types in
instance-of ('is') tests, so IsTopType is renamed to IsTopTypeForInstanceOf.

Also, Instance::IsFutureOrInstanceOf is renamed to RuntimeTypeIsSubtypeOfFutureOr
to align it with RuntimeTypeIsSubtypeOf and reflect that it is
calculating subtyping and not instance-of.

Change-Id: Ib8d3574edc1b90d80f5528330bd84b099b37d2b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145446
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2020-04-30 19:35:32 +00:00
Ryan Macnak 77a496427d [vm] Speed up reload in debug mode by avoiding costly checks in ~HandleScope.
Change-Id: Ic8fd16444b510829490935e64cc9393eed519150
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145305
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-04-29 01:23:03 +00:00
Alexander Markov 5ed0385777 [vm/nnbd] Fix A<dynamic> <: A<Object> subtyping in weak mode
In weak mode dynamic is a subtype of Object and
A<dynamic> is A<Object> should evaluate to true, as
LEGACY_SUBTYPE treats Object as legacy.

This change fixes language/constructor/constructor12_weak_test in weak mode.

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

Change-Id: Ie02888841a5cea9f6a8ccd38df504d6c938e58f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144992
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-04-28 17:59:12 +00:00
Ryan Macnak 6fe15f6df9 [vm] Represent tagged pointers as C++ value types instead of C++ pointer types.
This works around bugs in UndefinedBehaviorSanitizer and Clang.

Bug: b/28638298
Change-Id: I6be595f9664516019d28017d24559583a1ae3a21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144354
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-04-25 05:21:27 +00:00
Liam Appelbe 216e3df452 [vm] Handle required params in bytecode mode
Change-Id: I9e6b62969012bf2e0d9fce6bfe894a2367f240c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138664
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-04-24 20:52:27 +00:00
Ben Konyi 1f60f431e3 [ VM / Service ] Allow for dart:_* libraries to be set debuggable
Fixes https://github.com/dart-lang/sdk/issues/29813

Change-Id: I995177314dc92dcfc9f5850c68addb48c4e09f9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144621
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-04-23 21:28:20 +00:00
Tess Strickland 2d865dc69b [vm] Fix non-symbolic stack traces with --lazy-async-stacks.
Symbolic and non-symbolic stack traces had separate ToCString
implementations with the same general structure, but those
implementations diverged enough to cause issues in certain async stack
modes. They are now merged, with the --dwarf-stack-traces-mode flag
checked where appropriate within the merged method.

Also, now non-symbolic stack traces do not include frames for Code with
invisible Function owners unless the flag --show-invisible-frames is
enabled. With this change, pkg/native_stack_traces no longer needs to
guess at which frames corresponding to Dart code should be treated as
internal.

Tested by adding --dwarf-stack-traces version of the tests
in runtime/tests/vm/dart/causal_stacks.

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

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try
Change-Id: I41a887129616c88acd7729492addf7364d95df33
Bug: 41578
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143816
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-23 09:31:08 +00:00
Alexander Markov 53860a5822 [vm/nnbd] Take Never type out of the VM isolate
Never type in the VM isolate causes bootstrapping problems when
null-safety mode is auto-detected. We cannot initialize its type
testing stub without knowing null-safety mode and we cannot patch it
after figuring out null-safety mode because VM isolate is read-only.

The solution is to move Never type (and Never class) out of the VM
isolate and make them per isolate.

Issue: https://github.com/dart-lang/sdk/issues/41206
Change-Id: Iede937aa5becd5f1f7b029db836c25a1b20fbc5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144488
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-04-23 01:31:57 +00:00
Ryan Macnak cb32f0e9eb [vm] Remove change of return type in override of AbstractType::InstantiateFrom.
This override will become an error after switching tagged pointers from C++ pointers to C++ values.

Change-Id: Ic225c36bd5942cf00617053597d3a7aa95613b94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144463
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-04-23 00:34:34 +00:00
Ryan Macnak 160046f44c [vm] Move CID predicates out of RawObject.
When using C++ value types to represent tagged pointers, we cannot use forward declarations for tagged pointers. This helps to break include cycles when attempting to keep IsXYZ predicates as tagged pointer member functions.

class_id.h also seems like a more natural place for these predicates, which were written before there was a class_id.h.

Change-Id: I0677560a794ed084d10f844606e202feb0c3820a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144321
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-04-21 20:09:55 +00:00
Alexander Markov 69791c50f8 [vm/nnbd] Use InitInstanceField instruction for late instance fields
Fixes https://github.com/dart-lang/sdk/issues/41299
Issue https://github.com/dart-lang/sdk/issues/41417

Change-Id: I1219ddaffcf3a2b17226305eeea8455c73f4ca78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143189
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-04-20 23:30:14 +00:00
Aske Simon Christensen 5b78cb8fb5 [vm/aot] Handle tearoffs in dispatch table.
Adds another interface target to instance calls, pointing to the torn
off method for tearoff getter calls. This is then used to direct the
call to the method extractor for the method.

Increases the fraction of dynamically dispatched instance calls in
Flutter Gallery that are handled by the dispatch table from 95.8% to
98.4%. The remaining 92 IC calls are all on static receiver type
dynamic or Function (34 function calls, 22 method calls, 21 operator
calls, 14 getter calls and 1 setter call).

Change-Id: I0bde1a8271c8563f4631534bd39d1254cd779380
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142155
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-20 12:42:46 +00:00
Tess Strickland 4859de9f09 [vm] Make --dwarf-stack-traces only have effects in precompiled mode.
Currently, turning on --dwarf-stack-traces can cause the flow graph
compiler to fail in JIT mode. In addition, non-symbolic stack traces can
be useless in JIT mode if recompilation happens and thus there's no
DWARF information for the new code.

Thus, change code that uses the flag to also check for precompiled mode,
so it doesn't change compilation or serialization for JIT snapshots, and
only produce non-symbolic stack traces in the precompiled runtime when
it is on.

Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try
Change-Id: Iedae16d1391416de63bc2bdbd19428f607c34fed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143802
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
2020-04-20 10:54:16 +00:00
Tess Strickland bd4fc89060 [vm] Drop virtual addresses from non-symbolic stack frames.
Virtual addresses are only guaranteed to be valid for the original
shared library that was loaded as a snapshot. This can lead to confusion
if someone attempts to use the virtual address with separately saved
debugging information. This information may not include all the same
sections as the snapshot or include them in the same order and thus may
have different virtual addresses for the instructions sections.

In fact, this happens right now: we don't include a .bss section in the
debugging information, as there's no code in the text sections that
needs relocation. Since the .bss section comes before the .text
sections, this means the (empty) .text sections in the debugging
information have different virtual offsets than the .text sections in
the snapshot.

At this point, we print enough information in non-symbolic stack traces
that the virtual address can be calculated from the absolute address if
truly needed, whether the snapshot was loaded by the OS or by our
non-native ELF loader, so stop printing it to avoid this confusion.

Change-Id: I7949524cc3bb2f510d6812d226b66806939d0da7
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143801
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2020-04-20 09:00:06 +00:00
Martin Kustermann bc59a40918 [vm/compiler] Use PC-relative calls in AssertAssignable when calling TTS
Additionally the TTS itself will also use pc-relative tail-call to the
slow path.

This reduces AssertAssignable by 1 instruction and generated
type testing stubs by 2 instructions.

Flutter gallery total size:

  armv8: -0.3%
  armv7: -0.27%

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

Change-Id: Ib29ff9afd1df4034c8fa47f66c80c22e226c0979
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142988
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2020-04-18 20:27:38 +00:00
Alexander Markov 085e22dd72 [vm/nnbd] Change type of sentinel values to Never
Special sentinel values which are used for lazy initialization can be
stored in variables of any type. In NNBD world Null is no longer a
bottom type as null cannot be assigned into variables of non-nullable
types. The new universal bottom type is Never, so type of sentinel
values is changed from Null to Never.

This also allows to make late fields non-nullable in the type
propagation and avoid extra updates to field guards.

This change also adds special handling of comparisons with sentinel
values into constant propagation as it can constant fold comparisons
of values with different cids.

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

Change-Id: I8266cfba0cc434b78ffa9570c30d434d4380d4af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143864
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-04-17 18:32:28 +00:00
Alexander Aprelev 9c4a322b08 Reland "[vm/isolates] Introduce fast isolate spawn in AOT."
This reverts commit 922ea3e9b6 in patchset 1, fix for assertion triggered in https://ci.chromium.org/b/8883214567628884960 in patchset 2, fix for deadlock around symbols table mutex in patchset 4.

Original commit description:

Speed up is achieved by sharing most of the dart code, object store
and class table between isolates in single isolate group. So
instead of bootstrapping isolate from the snapshot, isolate is
initialized by setting pointers to existing data structures already
set up for first isolate, and only few isolate-specific structures (moved
to newly introducted isolate_object_store) are created.

To allow for safe cross-isolate switchable call site, type test cache
mutations additional synchronization via RunWithStoppedMutators(that
relies on safepoints) was added.
Besides switchable call sites, no other mutation to the dart code is
done in AOT, which allows such sharing.

Bug: https://github.com/dart-lang/sdk/issues/37835
Bug: https://github.com/dart-lang/sdk/issues/36097
Change-Id: I655e337198214c9dfacbe76f7852b941b5a7e910
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143462
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-04-17 03:02:27 +00:00
Vyacheslav Egorov a41a1dc917 [vm/compiler] Split compiler sources out of normal VM sources.
Make them form its own source set (libdart_compiler) and completely exclude
them from AOT runtime targets.

Previously we had some inconsistencies, with some files were using
DART_PRECOMPILED_RUNTIME to fully or partially exclude either contents
from their headers or from implementation, while other files did nothing
and relied on linker to throw their contents away.

This change tries to address this inconsistency.

A follow up change would include a check in most compiler headers which
would prohibit to use them while building AOT runtime.

Change-Id: Ief11b11cbc518b301d3e93fce80580a31bbad151
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142993
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-16 22:59:03 +00:00
Teagan Strickland 17f62d3f3a [vm/aot] Drop more Function objects not needed at runtime when possible.
Before, use of a function in the static calls table of a Code object
would cause it to be retained. Now, like dispatch table use, we only
retain such functions if there are other uses like dynamic function
lookup that needs the function object or if the
--retain-function-objects flag is enabled.

In most modes, --retain-function-objects is enabled by default.
It is only disabled by default in product mode when
--dwarf-stack-traces is enabled, since otherwise the removed
function objects may be needed for debugging platforms like the
Observatory or when creating symbolic stack traces.

Changes on flutter gallery in release mode:

Default:
  arm7: isolate: +6.65%, total: +1.30%
  arm8: isolate: +6.67%, total: +1.28%

(The increase is due to changing back to all function objects
being retained as the default when using symbolic stack traces.)

With --no-retain-function-objects:
  arm7: isolate:  -9.95%, total: -1.73%
  arm8: isolate: -10.04%, total: -1.77%

(This measures how much dropping static call function objects
when possible affects the size compared to just dropping
function objects for dispatch table entries when possible.)

Bug: https://github.com/dart-lang/sdk/issues/41052
Change-Id: I3c834b14b0c58ccfdbaca3f154df536df29c13ef
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142146
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-16 14:26:04 +00:00
Alexander Markov d5c38cd354 [vm/nnbd] Use InitStaticField instruction for late static fields
Issue: https://github.com/dart-lang/sdk/issues/41299
Issue: https://github.com/dart-lang/sdk/issues/41417
Issue: https://github.com/dart-lang/sdk/issues/40796
Change-Id: Ibcc0ea55c6262ccafdda6c3fb1b28f357297c1de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143100
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Benchmark: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-04-15 20:04:34 +00:00
Alexander Aprelev 922ea3e9b6 Revert "Reland "[vm/isolates] Introduce fast isolate spawn in AOT.""
This reverts commit fdd7a2c616 as there
seem to be sporadic dartkp crashes like https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-linux-product-x64/7454

Change-Id: I4218b8ff629630991ad1ff94f217489bb16228d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143383
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-04-14 20:37:29 +00:00
Alexander Aprelev fdd7a2c616 Reland "[vm/isolates] Introduce fast isolate spawn in AOT."
Original revert in patchset 1, fix for deadlock issue in patchset 2: avoid reentrant calls to RunWithStoppedMutator.
Further review comments addressed in successive patchsets.

This reverts commit 8ef508ba36.

Original commit description:

Speed up is achieved by sharing most of the dart code, object store
and class table between isolates in single isolate group. So
instead of bootstrapping isolate from the snapshot, isolate is
initialized by setting pointers to existing data structures already
set up for first isolate, and only few isolate-specific structures (moved
to newly introducted isolate_object_store) are created.

To allow for safe cross-isolate switchable call site, type test cache
mutations additional synchronization via RunWithStoppedMutators(that
relies on safepoints) was added.
Besides switchable call sites, no other mutation to the dart code is
done in AOT, which allows such sharing.

Change-Id: I6a0279d9812020ad7a5c2b7851980b6a29b95b9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143327
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-14 18:42:45 +00:00
Alexander Aprelev 8ef508ba36 Revert "[vm/isolates] Introduce fast isolate spawn in AOT."
This reverts commit 61c0960a8b as it broke
vm-kernel-win-release-ia32 buildbot test https://ci.chromium.org/b/8883214567628884960

Change-Id: I6377fd622a3c7d808f46fd9c541c64d343ecc269
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143260
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-04-12 15:59:41 +00:00
Alexander Aprelev 61c0960a8b [vm/isolates] Introduce fast isolate spawn in AOT.
Speed up is achieved by sharing most of the dart code, object store
and class table between isolates in single isolate group. So
instead of bootstrapping isolate from the snapshot, isolate is
initialized by setting pointers to existing data structures already
set up for first isolate, and only few isolate-specific structures (moved
to newly introducted isolate_object_store) are created.

To allow for safe cross-isolate switchable call site, type test cache
mutations additional synchronization via RunWithStoppedMutators(that
relies on safepoints) was added.
Besides switchable call sites, no other mutation to the dart code is
done in AOT, which allows such sharing.

Bug: https://github.com/dart-lang/sdk/issues/37835
Bug: https://github.com/dart-lang/sdk/issues/36097
Change-Id: I64c86525f4ef9cb30567a49a106bfe700355942b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136780
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-04-12 14:57:09 +00:00
Alexander Markov bbbabcdacd [vm/nnbd] Take non-nullability of types into account in the VM
This change assumes that NNBD strong mode is sound.

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

Change-Id: I5f20fff05196abd4ae183a747865d3dec5a6ccda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143021
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-04-10 20:08:14 +00:00
Ryan Macnak 4978dcc928 Reland "[vm, gc] Parallel scavenge."
Fix ScavengeVisitorBase::HasWork to account for undone allocations.

Bug: b/153524644
Change-Id: Ifc30017a411c5b65716d4e38752f2edeeb80a77e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142908
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-04-10 19:27:04 +00:00
Martin Kustermann 13c84d8794 Revert "Reland "[vm, gc] Parallel scavenge.""
This reverts commit 898b080d09.

Reason for revert: Seems to cause crashes in g3, see b/153524644.

Original change's description:
> Reland "[vm, gc] Parallel scavenge."
> 
> Remove header access from typed data case in RawObject::HeapSizeFromClass.
> 
> Address data race between visiting remembered cards and allocating new large pages for promotion.
> 
> Change-Id: I92cc4604ed38ab8f42b87b140a26a8118e7030d4
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142565
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=kustermann@google.com,aam@google.com,rmacnak@google.com,asiva@google.com

Change-Id: I3ef7bd5c3d0ca575f33cf5f712f58476037d2d90
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142861
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-04-08 14:21:32 +00:00
Regis Crelier fdcb246d9e [VM/nnbd] Verify that constants in core snapshots are mode agnostic.
Change-Id: I2c58070f36ad043c08f9c2862ef8dc5b829ed0b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142320
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-04-07 19:37:47 +00:00
Ryan Macnak 898b080d09 Reland "[vm, gc] Parallel scavenge."
Remove header access from typed data case in RawObject::HeapSizeFromClass.

Address data race between visiting remembered cards and allocating new large pages for promotion.

Change-Id: I92cc4604ed38ab8f42b87b140a26a8118e7030d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142565
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-04-07 17:07:06 +00:00
Clement Skau 01d9d1ca81 [Compiler] Adds a set of generic AllocateObject stubs.
- AllocateObjectStub
- AllocateObjectParameterizedStub
- AllocateObjectSlowStub

Benchmark results:
- flutter-release
  - android-armv8
    - flutter_gallery_instructions_size (Pixel 2)  -5.322%
    - flutter_gallery_vmisolate_size (Pixel 2)  +0.8471%
    - flutter_gallery_total_size (Pixel 2)  -3.118%
    - flutter_gallery_apk_size (Pixel 2)  -0.0948%
  - android-armv7
    - flutter_gallery_instructions_size (Moto G4)  -4.289%
    - flutter_gallery_vmisolate_size (Moto G4)  +0.8475%
    - flutter_gallery_total_size (Moto G4)  -2.736%
    - flutter_gallery_apk_size (Moto G4)  -0.0845%

Cq-Include-Trybots: luci.dart.try:vm-canary-linux-debug-try,vm-dartkb-linux-release-simarm64-try,vm-kernel-linux-debug-x64-try,vm-kernel-linux-release-simarm64-try,vm-kernel-optcounter-threshold-linux-release-ia32-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-product-x64-try,vm-kernel-win-release-ia32-try,vm-kernel-win-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try
Bug: https://github.com/dart-lang/sdk/issues/41175
Change-Id: Ic768dc809abf38ae64dbb1273f0d4846e4e7989d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137979
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-04-07 06:55:58 +00:00
Ryan Macnak bb95f88139 Revert "[vm, gc] Parallel scavenge."
This reverts commit 9209f522d6.

Reason for revert: Flaky analyzer crashes

Original change's description:
> [vm, gc] Parallel scavenge.
> 
> Run N tasks that compete to copy or promote survivors. Installation of the forwarding pointer uses a CAS.
> Tasks do not share the list of copied objects to be processed.
> Tasks do share the list of promoted objects to be processed.
> Divide the freelist in N copies. Each scavenger task uses one without locking. The sweeper inserts into the freelists round-robin.
> 
> Change-Id: I54c7839ac5f15829462b3be7cf8c9635c01b785f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135962
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,aam@google.com,rmacnak@google.com,asiva@google.com

Change-Id: I0d97b8d9148b2a81cabafde4602512e423eba223
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142554
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-04-06 22:51:08 +00:00
Ryan Macnak 9209f522d6 [vm, gc] Parallel scavenge.
Run N tasks that compete to copy or promote survivors. Installation of the forwarding pointer uses a CAS.
Tasks do not share the list of copied objects to be processed.
Tasks do share the list of promoted objects to be processed.
Divide the freelist in N copies. Each scavenger task uses one without locking. The sweeper inserts into the freelists round-robin.

Change-Id: I54c7839ac5f15829462b3be7cf8c9635c01b785f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135962
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-06 20:14:54 +00:00
Aske Simon Christensen 1210d27678 [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.

This is a reland of f8ead09ba2

Change-Id: Iadb2169f80d3731153df3a93772f6142c3197260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142375
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
2020-04-06 10:36:50 +00:00
Alexander Aprelev 80ae6ed91d [vm/aot-switchable-calls] Introduce single runtime entry for all switchable calls
Bug: https://github.com/dart-lang/sdk/issues/37835
Bug: https://github.com/dart-lang/sdk/issues/36097
Change-Id: I0198fd0328945b04e4f2254bacac25b41038e78c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138361
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-04-04 15:03:48 +00:00