Commit graph

16578 commits

Author SHA1 Message Date
Daco Harkes a71d60c1cf [vm/ffi] Support Linux on Arm 32-bit (hardfp)
Implement the hardfp calling convention.

Tested QEMU locally as the bots are not online yet.

tools/test.py -m debug -a arm -c dartkp --use-qemu ffi_2 ; tools/test.py -m debug -a arm -c dartk --use-qemu ffi_2
Test configuration:
    custom configuration(architecture: arm, compiler: dartkp, mode: debug, runtime: dart_precompiled, system: linux, use-qemu)
Suites tested: ffi_2
[00:45 | 100% | +  189 | -    0]
Test configuration:
    custom configuration(architecture: arm, compiler: dartk, mode: debug, runtime: vm, system: linux, use-qemu)
Suites tested: ffi_2
[09:52 | 100% | +  189 | -    0]

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

Change-Id: Ic34175bdf9b9f359f1126aeb157362e76443921a
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124136
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-02-05 14:22:59 +00:00
Daco Harkes 8408232522 [vm/ffi] Replace FFI compiler pipeline
Introduces NativeRepresentation and NativeLocation for the compilation of FFI.

NativeRepresentations are able to express all representations (or types) of the native ABIs we bind to with FFI, this is more representations that than that are used in Dart itself.
NativeLocations are able to express all locations of the native ABIs we bind to with FFI, this is more types of locations than that are used for the Dart calling convention.
See the documentation in the respective files.

These NativeLocations and NativeRepresentations are computed by the NativeCallingConvention and consumed by the Marshaller and Assemblers.

This reenginering is required for go/dart-ffi-by-value, hardfp (Arm S and D fpu registers), and iOS 64 bit (non-word-aligned stack arguments).

In addition, by using the NativeRepresentations we also get slightly reduced code size:

* The tracking of sizes is improved, so less sign/zero-extension operations are required.
* UnboxedWidthExtenderInstr is fully removed, the size extension is done inside the native moves, coalescing moves and size extension when possible.
* BitCastInstr is only used when really needed. This reduces code-size on arm32 softfp.

This fixes the iOS arm64 calling convention, manually tested with https://github.com/flutter/flutter/pull/46078 and https://dart-review.googlesource.com/c/sdk/+/131074.

Fixes: https://github.com/dart-lang/sdk/issues/39637
Issue: https://github.com/dart-lang/sdk/issues/36309
Issue: https://github.com/dart-lang/sdk/issues/36730

Change-Id: I8878bc0f314277bab4ca22f417c6295ecc017720
Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129081
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-02-05 08:46:07 +00:00
Daco Harkes 3284ef81a6 [vm] Clean up constants namespacing
This commit undoes https://dart-review.googlesource.com/c/sdk/+/97325 because we removed DBC.

Fixes: https://github.com/dart-lang/sdk/issues/40457
Change-Id: I873a8c6daa2ef79f7b0a5dff00d52f12d5770476
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134298
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-02-05 08:46:07 +00:00
Daco Harkes 43fe0b35d8 [vm] Clean up Location templating
This commit undoes https://dart-review.googlesource.com/c/sdk/+/97312 because we removed DBC.

Fixes: https://github.com/dart-lang/sdk/issues/40458
Change-Id: I7e08544e4c57d34c6f4bfc10aeed8ab87ed31953
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134297
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-02-05 08:46:07 +00:00
Ben Konyi 37f4a44a27 Revert "[ VM / Service ] Added getClientName, setClientName and requireResumeApproval RPCs"
This reverts commit 48808f7dce.

Reason for revert: Unable to approve failures.

Original change's description:
> [ VM / Service ] Added `getClientName`, `setClientName` and `requireResumeApproval` RPCs
> 
> Add support for naming VM service clients which allows for resume
> permissions to be set for all clients of the same name. If a client
> name requires resume approval, an isolate won't be resumed until all
> clients which require resume approval have called the `resume` RPC.
> 
> Resume approvals can be set for the following pause events:
> - PauseOnStart
> - PausePostRequest (issued after `reloadSources(pause: true)`)
> - PauseOnExit
> 
> Change-Id: I7dde3d8aaeccfcf47fa84f1f92159846f1560e16
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133621
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Reviewed-by: Gary Roumanis <grouma@google.com>

TBR=jacobr@google.com,bkonyi@google.com,rmacnak@google.com,asiva@google.com,grouma@google.com

Change-Id: I8e60416ad8cbec9ad93f4e34e9bf9af5a516c6dc
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134465
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-02-05 01:13:17 +00:00
Ben Konyi 48808f7dce [ VM / Service ] Added getClientName, setClientName and requireResumeApproval RPCs
Add support for naming VM service clients which allows for resume
permissions to be set for all clients of the same name. If a client
name requires resume approval, an isolate won't be resumed until all
clients which require resume approval have called the `resume` RPC.

Resume approvals can be set for the following pause events:
- PauseOnStart
- PausePostRequest (issued after `reloadSources(pause: true)`)
- PauseOnExit

Change-Id: I7dde3d8aaeccfcf47fa84f1f92159846f1560e16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133621
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Gary Roumanis <grouma@google.com>
2020-02-05 00:02:17 +00:00
Ryan Macnak 68d178f223 [vm] Remove FLAG_support_service and FLAG_support_reload, superseded by PRODUCT define.
When these were originally added, we thought we would be able to use them in place of ifdefs and rely on the compiler optimizations and linker GC to remove things. This turned out not to reliably remove what we wanted removed, so we ended up with the ifdefs anyway.

Change-Id: I62e74d60d92b18a688b9dffaf77b1440c10a07ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134402
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-02-04 23:31:17 +00:00
Ben Konyi bbe0e3b768 [ DartFuzz ] Quality of life improvements in log output
- Updated reproduction commands to not include bot paths (should be
copy-pasteable and runnable from $SDK_ROOT now).
- Fixed issue where Dart SDK revision wasn't being printed on the bots

Change-Id: Ia53986332eb7997d5b3911c5de4e5ce1d61e6eb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134420
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-02-04 22:06:30 +00:00
Martin Kustermann e171ff4a6d [vm/concurrency] Speed up isolate communication via normal snapshotting
Do not lock forwarding table during snapshot writing:

This is a follow-up to [0], which made the [WeakTable] used during
snapshot writing per isolate. Since each isolate has it's own table
now, there's not reason to lock it during snapshot writing.

Furthermore we speed up RawObject::InVMIsolateHeap() which was super slow
due to locking "vm-isolate"'s page space and walking all pages.

[0] https://dart-review.googlesource.com/c/sdk/+/114858


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

Change-Id: I783ea6083c199058e76895fcde38dc06af6991d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134299
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-02-04 20:46:36 +00:00
Régis Crelier dfce72bbf9 [VM/nnbd] Fix canonicalization of type 'Never' (fixes #40249).
Change-Id: Ib3dc4fc6d31aeadb331fda017fc8b4f1a8ae8221
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134382
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-02-04 20:31:56 +00:00
Ryan Macnak 7c472c396c [vm] Speed-up the stack overflow check as used by reload stress testing.
Avoid calling Function::ToFullyQualifiedCString when it is not needed.

Change-Id: I7d8ed879bb47e5e06c456bec73e4e00ae0181cd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134241
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-02-04 18:16:59 +00:00
Teagan Strickland bb24f98616 Revert "[vm/aot] Remove object wrapping of bare instructions for AOT snapshots."
This reverts commit 7475c637c3.

Reason for revert: Breakage on simarm_x64 (and thus arm_x64)

Original change's description:
> [vm/aot] Remove object wrapping of bare instructions for AOT snapshots.
> 
> Now, when writing an AOT snapshot in bare instructions mode, only
> the actual instructions in the RawInstructions payload are serialized
> instead of the entire RawInstructions object.
> 
> Since there are no longer RawInstructions objects in these AOT
> snapshots, we also change how Code objects are serialized. Instead
> of just containing a reference to the RawInstructions object, we
> serialize two pieces of information: where the instructions
> payload for this Code object begins and whether there was a single
> entry for the instructions payload. (To save space, the single
> entry bit is serialized as the low order bit of the unchecked
> offset, which was already being serialized).
> 
> While we also need the length of the instructions payload, we
> approximate it for all but the last Code object by subtracting
> the next Code object's payload start from this Code object's
> payload start. For the last Code object, we assume it extends
> to the end of the instructions image.
> 
> Changes on flutter gallery in release mode:
> armv7: instructions size -2.66%, total size -1.68%
> armv8: instructions size -5.81%, total size -3.49%
> 
> Fixes https://github.com/dart-lang/sdk/issues/38451.
> 
> Change-Id: Ia458e8d99bae18f5c3b6e849df2519027f06f574
> Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-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-android-release-arm64-try,vm-kernel-precomp-android-release-arm_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/+/131067
> Commit-Queue: Teagan Strickland <sstrickl@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,rmacnak@google.com,sstrickl@google.com

Change-Id: If2c8ca6b0993211b2509b275af7ff11a8fa2baa3
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-release-simarm-try, vm-kernel-precomp-linux-release-simarm64-try, vm-kernel-precomp-linux-release-simarm_x64-try, vm-kernel-precomp-android-release-arm64-try, vm-kernel-precomp-android-release-arm_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/+/134322
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
2020-02-04 17:32:28 +00:00
Teagan Strickland 592e59691b Revert "[gardening] Fix assert failure on (sim)arm_x64 due to 7475c63."
This reverts commit 30e80f0a64.

Reason for revert: Other failures were hiding under the ASSERT failure.

Original change's description:
> [gardening] Fix assert failure on (sim)arm_x64 due to 7475c63.
> 
> Also since we write out a target word for the
> InstructionsSection::instructions_length_ field, make that field a
> uword, not a uint32_t.
> 
> Change-Id: I8032cf49aae9528702778ee3ed717c08cb281e54
> Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-bare-linux-release-x64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134290
> Reviewed-by: Martin Kustermann <kustermann@google.com>

TBR=kustermann@google.com,dacoharkes@google.com,sstrickl@google.com

Change-Id: I694411d9e986062148888aaddedc75673039dfe0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-simarm_x64-try, vm-kernel-precomp-bare-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134321
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
2020-02-04 17:30:58 +00:00
Liam Appelbe a793c36c77 [test] Run late field tests in optimised mode
Fix the tests by disabling the optimisation that turns getter calls into
raw gets if the field is late, and by calling recording the null init
store in bytecode mode.

Change-Id: I8f12e3237cd32c890b5cef8d00c32940e937330d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134180
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-02-04 16:51:38 +00:00
Teagan Strickland 30e80f0a64 [gardening] Fix assert failure on (sim)arm_x64 due to 7475c63.
Also since we write out a target word for the
InstructionsSection::instructions_length_ field, make that field a
uword, not a uint32_t.

Change-Id: I8032cf49aae9528702778ee3ed717c08cb281e54
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-bare-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134290
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-02-04 16:01:52 +00:00
Victor Lima e076e793a7 [vm] Allow unboxed integer fields in AOT
flutter arm-v8:
  gallery instructions size: -0.46%
  gallery total size: -0.35%

  sync_star_generated (Pixel 2): -8.04% (less is better)
  velocity_tracker_bench (Pixel 2): -9.18% (less is better)

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

Change-Id: Ieb7bf426af37f77fd543ebc5314a94224da3aaeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132606
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-02-04 12:37:21 +00:00
Teagan Strickland 7475c637c3 [vm/aot] Remove object wrapping of bare instructions for AOT snapshots.
Now, when writing an AOT snapshot in bare instructions mode, only
the actual instructions in the RawInstructions payload are serialized
instead of the entire RawInstructions object.

Since there are no longer RawInstructions objects in these AOT
snapshots, we also change how Code objects are serialized. Instead
of just containing a reference to the RawInstructions object, we
serialize two pieces of information: where the instructions
payload for this Code object begins and whether there was a single
entry for the instructions payload. (To save space, the single
entry bit is serialized as the low order bit of the unchecked
offset, which was already being serialized).

While we also need the length of the instructions payload, we
approximate it for all but the last Code object by subtracting
the next Code object's payload start from this Code object's
payload start. For the last Code object, we assume it extends
to the end of the instructions image.

Changes on flutter gallery in release mode:
armv7: instructions size -2.66%, total size -1.68%
armv8: instructions size -5.81%, total size -3.49%

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

Change-Id: Ia458e8d99bae18f5c3b6e849df2519027f06f574
Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-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-android-release-arm64-try,vm-kernel-precomp-android-release-arm_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/+/131067
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-02-04 10:28:43 +00:00
Vyacheslav Egorov ab56c2f841 [runtime/docs] Add custom lexer for shell sessions in runtime wiki.
This was missing from the previous wiki related commit.

TBR=aam@google.com

Change-Id: Ib68ead3bab2841bb8e02cb93fd71bce7515ff335
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134285
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-02-04 09:16:52 +00:00
Vyacheslav Egorov 857b911f3b [vm/docs] Publish "Introduction to Dart VM" source and build tools.
Change-Id: I30068d6492bd6ec4ce42cc50d4a481960a0197fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133985
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-02-04 09:04:32 +00:00
Jens Johansen 18c281c624 [observatory] Allow to say 'break package:foo/file.dart:42'
This CL updates the parsing of "break" statements in the debug console
in observatory, as well as handling that the same script can be a part
of several libraries.

Before one could get stuff like this:
$ break package:front_end/src/fasta/scope.dart:389
Function 'package:front_end/src/fasta/scope.dart:389' not found
$ break scope.dart:389
Script 'scope.dart' is ambiguous

The first one is fixes by this CL: We now allow package uris and thus
no longer think it's a function. In this case it wouldn't have mattered
though, it would just say it was ambiguous, as the last case.
This is caused by the same script being found twice. By using a set
instead of a list, that's fixed too.

Change-Id: I3931c8f2abc0a3a5a77cff516da8767037196bf2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133593
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-02-04 08:57:01 +00:00
Jens Johansen c6aa3a22a7 [vm] [debugger] Fix for not breaking in library with mixin
In the VM, a single script can belong to several libraries because of
mixins.

Previously, when setting a breakpoint, it found the function to set the
breakpoint in by taking the "scripts library" (script.FindLibrary) and
then tried to find a function in that library that matched.
Sometimes it found the "wrong" library and the breakpoint thus wasn't
set.

This CL changes that so it goes though all libraries, finds all maching
libraries and tries all of them.

This solves the issue at hand, but might not solve all corner-cases.

This added test demonstrates the resolved case where before it would
just say that it couldn't add the breakpoint on line 13.

Change-Id: Ie44b0dfb4ea3e8de767d1867ec432b2aef429b76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133592
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-02-04 08:43:21 +00:00
Martin Kustermann 83d7048600 [vm/concurrency] Disable isolate groups in AOT mode
This is a preparation for landing the shared heap CL (it will
temporarily regress the isolate spawning time and memory use).

Once the shared heap CL is in, we can make a follow-up change to actually take
advantage of it by sharing the entire program structure (cl in
preparation by aam@). Once that lands we will enable the isolate groups
in AOT and reduce spawning latency by 10x :)

Regarding testing: We have already made all our isolate related tests in the
SDK run with/without isolate groups (irrespective of the default), so we
should continue to have test coverage in both modes.

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

Change-Id: Ib7e5101dfe8527948cd9ceed09d50051b04fb874
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134280
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-02-04 07:58:01 +00:00
Ben Konyi 8f7d3fca69 [ VM / dart:typed_data ] Change fmaxf/fminf to fmax/fmin for Float64x2.clamp
Fixes https://github.com/dart-lang/sdk/issues/40446

Change-Id: Ic610ecd024a6fc9bab3095ceb049139e21a519f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134242
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-02-04 01:06:19 +00:00
Ben Konyi 30f25ba735 [ VM / typed_data ] Fixed inconsistent results for -Float32x4.zero().clamp and -Float64x2.zero().clamp
The fuzzer found an issue where clamping negative zero would result in
conflicting answers depending on whether or not the clamp operation had
been optimized in JIT mode.

The MINPS and MAXPS instructions will always return the second operand
if the values being compared are -0 and 0, which is the opposite of what
the C implementation of clamp was doing.

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

Change-Id: I3afb725bd0c8643758dbe753d863ba93c86ad747
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134093
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-02-03 21:59:48 +00:00
Alexander Markov e1e2604ff1 [vm/nnbd] Use NNBD flags from AsExpression, IsExpression
This is the VM-specific follow-up to
https://dart-review.googlesource.com/c/sdk/+/133100

Change-Id: Iaa8728d2e0afebf421f9c65c3b3a48b286af5970
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134200
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-02-03 20:20:26 +00:00
Ryan Macnak 1efba58d22 Reapply "[vm] Initialize large typed arrays only once."
Change-Id: I92eb6c96db97e0951ae34315ad8d744e06064b3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133764
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-02-03 17:22:05 +00:00
Ryan Macnak 24418e6c6d [vm, gc] Remove BumpAllocationScope.
This scope can sneak objects larger than kAllocatablePageSize directly into non-large heap pages.

This scope also holds a heap lock outside of the GC, which is likely to create issues when multiple isolates run on the same heap.

Change-Id: Ic56277c83ffccfe2e1396ed773dd30b8d172bbba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134040
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-02-03 17:22:05 +00:00
Ryan Macnak d9a0359843 [vm, gc] Document safepointing.
Change-Id: I35eca64eb6be8cd72f527644ef8fd644f30287a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134109
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-02-03 16:58:22 +00:00
Martin Kustermann ce27d1a539 [vm] Specialize TTS stubs only for legacy types
This is a follow-up to 62835950d which was using the condition
`type.IsNullable()` for determining whether to generate TTS stubs.

It turns out `type.IsNullable()` is false for legacy types (for whatever
reason, because legacy types are nulable).

Instead we'll change the condition to `type.IsLegacy()`.

Issue https://github.com/flutter/flutter/issues/49893

Change-Id: I4c8a728382c7b7c65ddb6bff41778b384634d83d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134164
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-02-03 14:07:55 +00:00
Victor Lima d3b7909769 [vm] Remove flag unbox_numeric_fields
Change-Id: I57899b239fb942650460377ec0a6cecbb48c6926
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133995
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
2020-02-03 12:43:05 +00:00
Aske Simon Christensen 76c6282de6 [vm/aot] Use a global dispatch table for instance calls in AOT.
This is a Dart-tailored implementation of the "row-displacement
dispatch table" technique for closed-world instance calls:

All interface targets in the program are grouped into selectors such
that all targets that could potentially be called from the same call
site have the same selector (currently just grouped by name).

Each selector is assigned a selector offset such that offset + classid
is unique for all selector/classid combinations where the class
implements the selector.

At every instance call site that has an interface target (i.e. where
the static type of the receiver is not dynamic), the selector offset +
receiver classid is computed and used as index into a global table of
entry points.

If the receiver can be null (as determined by the front-end TFA and the
VM type propagation), a null check is inserted before the call.

An arguments descriptor is provided (only) for selectors that need it
(those which have type parameters or optional/named parameters).

The dispatch table calls don't need the monomorphic entry code, so for
functions that are only called via dispatch table calls (i.e. never
called dynamically), the monomorphic entry code is left out.


Some future improvements to the table dispatch implementation are
mentioned in https://github.com/dart-lang/sdk/issues/40188


The table dispatch flag is disabled by default in this commit. A
separate commit enables the flag.

Change-Id: Ic2911742b4a2c9a8d3bc7df60605454cbe4c0714
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126648
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-02-03 11:04:15 +00:00
Aske Simon Christensen de0ed1bd4e [vm] Share implementation of LoadClassIdInstr across architectures.
Also avoid executing the tagging instruction in the Smi case for
some LoadTaggedClassIdMayBeSmi implementations.

Change-Id: I067b06ce404ffbba1981539ed3bfef72c4215e8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133584
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-02-03 11:04:15 +00:00
Mayank Patke ed441e48d0 Update all Slow tests to be Slow, Pass.
Change-Id: I610b272355b045eab80cf941210774fb12d775eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134103
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2020-02-01 00:17:42 +00:00
Liam Appelbe b504faaefc [vm] Stop storing to temp in LoadLateField
Use an expression temp instead.

Change-Id: Ifa1de272a90448f376bdcac88b0c458c0ddd21b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134088
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-01-31 23:45:42 +00:00
Martin Kustermann 4650e22088 [vm/compiler] Mark Box instructions as non-speculative (since the inputs are always unboxed values and dont need to be checked)
Change-Id: I9f5cd0d1dcbc2164b74783cc7ba12e56c0d7a685
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133998
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-01-31 21:46:42 +00:00
Martin Kustermann 7a6233ad51 [vm] Set Class::is_const() based on final fields instead of generative constructors (which can be shaken by TFA)
This fixes debug assertions in AOT.

Change-Id: Ib688164498ad98d2b7bb4ce574cf6859922df3a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133999
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-01-31 21:38:37 +00:00
Johnni Winther 54c8066f6f [cfe] Add new flags to AsExpression and IsExpression
Change-Id: I31eba9b4ced051a1067945fd68e60a09b1fa6ed7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133100
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-01-31 19:55:22 +00:00
Zichang Guo 0ed9f7179d [vm] seperate error and unknown types for getStdioHandletype
Infer other types as kPipe which is sync with Win platform.

Bug: https://github.com/dart-lang/sdk/issues/40354
Change-Id: I8bf40a143573685833a689ff2c724a421b308234
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133623
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2020-01-31 17:07:22 +00:00
Martin Kustermann bada62ba7b [vm/reload] Fix crash in scavneger / GC after reload on ia32
If generated code refers to a constant object (which are old and canonical), a pointer
to it will be embedded in the instruction stream on ia32.

If we now reload and morph this constant object and allocate the
morph'ed copy in new space, the become operation will make RX writable
and the slot in the instruction stream gets updated to point to a new
space object and the code gets added to the remembered set.

The next scavenge operation will scan the remembered set as roots, see
the poitner to a new object, move the object and updates the pointer in
the instruction stream.
  => We hit a SEGV trying to write the RX memory

We can avoid this problem by ensuring to morph old+canonical instances
always into old space on ia32.

Change-Id: Id63eb6ee1735bbb661dbeceb1e8d0c6ac92225ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133228
Auto-Submit: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-01-31 16:42:42 +00:00
Martin Kustermann 5ae5aff640 [vm/embedder] Add documentation to Dart_CompileToKernel
Change-Id: Ic858a010f77a05c47430ce13d2bd7ef80535a538
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133990
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Martin Kustermann <kustermann@google.com>
Reviewed-by: Clement Skau <cskau@google.com>
2020-01-31 15:03:42 +00:00
Victor Lima b68d95ec9e [vm] Reland support for real unboxed floating point fields in AOT
Issue https://github.com/dart-lang/sdk/issues/40404

Change-Id: Icfa801ff0640a6b27bb3c13d0b737c40452cbf7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133983
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-01-31 12:56:31 +00:00
Clement Skau 26ada4363a [SDK] Fixes remaining issues with --lazy-async-stacks on.
- Handle bytecode for e.g. dartkb-simarm64 does not have source position.
- Use existing GetCallerSp() instead of working across frames.
- Nit: Adds clarifying comments to test.
- Nit: Updates name of non-async-stack test to clarify flags used.

Tested:
- CQ with --lazy-async-stacks on by default.
- vm/dart/causal_stacks and language_2/vm/causal_async_exception_stack_test with current flags.

Bug: https://github.com/dart-lang/sdk/issues/39525
Change-Id: Ie6581a734cdcafbd4fb641bd86bffc03ed241532
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133063
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-01-31 10:45:21 +00:00
Ryan Macnak 38eed7f6d5 [vm, service] Create a treemap from very large heap snapshots outside of the browser.
Usage:
$ dart runtime/observatory/bin/heap_snapshot.dart http://127.0.0.1:8181/q8Zq2o7rEJc=/
...
Wrote file:///tmp/heap-snapshotZWSNFF/merged-dominator.html

Change-Id: I187296b643cdad884209e459f639cfe8bcae6fe4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133861
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2020-01-31 02:09:17 +00:00
Liam Appelbe 00e481aab0 [vm] Reland the flag flip behind the --nnbd build flag
Bug: https://github.com/dart-lang/sdk/issues/40409
Bug: https://github.com/dart-lang/sdk/issues/40179
Change-Id: Ib84926ef15068d23dcac7b89843c454b8446b28e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134062
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2020-01-30 23:41:19 +00:00
Liam Appelbe bf5278bdd4 Revert "[vm] Set non_nullable_flag() to true"
This reverts commit 61b4bbcb6b.

Reason for revert: Performance regressions

Original change's description:
> [vm] Set non_nullable_flag() to true
> 
> We'll leave the deletion and cleanup of this function until later, so
> that this CL is as easy to rollback as possible.
> 
> Bug: https://github.com/dart-lang/sdk/issues/40179
> Change-Id: Ie583aaabd117ae06ea27a539c3bc904240a0e6bc
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133429
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Liam Appelbe <liama@google.com>

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

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

Bug: https://github.com/dart-lang/sdk/issues/40179
Change-Id: I7e1d81286d769faeacec7dc17612ff18d157f114
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134060
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2020-01-30 20:51:23 +00:00
Zichang Guo 162d6c5634 Revert "[vm] Add support for real unboxed floating point fields in AOT"
This reverts commit 9eb531bde4.

Reason for revert: Bots are red. Some tests are failing.

https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-obfuscate-linux-release-x64/6039

https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-android-release-arm_x64/957

Original change's description:
> [vm] Add support for real unboxed floating point fields in AOT
> 
> Non-nullable floating point fields (double, Float32x4, Float64x2)
> are fully unboxed in their classes.
> 
> A bitmap for each class was added to the shared class table in order to keep
> track of the pointers of the classes. Since all classes in Flutter Gallery
> have less than 64 fields, the bitmap is represented by a 64 bit integer and
> fields whose offset is more than 64 words are not unboxed.
> 
> The instance sizes and field offsets might change between target and host
> in cross-compilation, since the number of words used to store unboxed fields
> may differ.
> 
> dart-aot Xeon
> 
>   SplayLatency               -4.62%
>   SplayHarderLatency         -4.17%
>   NavierStokes               -2.20%
>   Tracer                      8.72%
>   ParticleSystemPaint         2.90%
>   NBodySIMD                   8.35%
>   NBody                      25.59%
> 
> With hack TFA to make doubles in Rect/Offset/Size classes in flutter non-nullable:
> 
> flutter arm-v8:
> 
>   gallery total size: -1%
> 
>   matrix_utils_transform_rect_perspective   -16.70% (less is better)
>   matrix_utils_transform_rect_affine        -31.82% (less is better)
>   matrix_utils_transform_point_perspective  -24.90% (less is better)
>   matrix_utils_transform_point_affine)      -27.26% (less is better)
>   rrect_contains_bench                      -4.719% (less is better)
> 
> Change-Id: I9ae09c9c3167d99f9efd071a92937aa51093fd1d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131824
> Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Samir Jindel <sjindel@google.com>

TBR=kustermann@google.com,rmacnak@google.com,sjindel@google.com,victoragnez@google.com

Change-Id: Ic73858f6adb7f55c4129d4f46ff4731b378cb634
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134020
Reviewed-by: Zichang Guo <zichangguo@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2020-01-30 18:13:28 +00:00
Ryan Macnak d67fbe525b [vm, gc] Base the growth policy on usage instead of capacity.
With concurrent sweeping, the amount of capacity freed by a major GC is not known at the time growth is evaluated. This consistently biases the policy into growing more than it would with an accurate capacity from stop-the-world sweeping.

This is more interesting for larger heaps and when there is a tighter memory limit.

For a very large dart2js compile
Max Heap Capacity: 13.057 -> 11.861 GB
     Compile Time:    545 -> 472 seconds

For dart2js self-compile
Max Heap Capacity: 1.343 -> 1.385 GB
     Compile Time:  43.4 -> 43.5 seconds

Bug: https://github.com/dart-lang/sdk/issues/21364
Change-Id: If047e22a9cd9da6b34c8e499a39fde97427a69b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133660
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-01-30 17:54:08 +00:00
Martin Kustermann 62835950d1 [vm/nnbd] Disable usage of specialized type testing stubs for NonNullable/NNBD types
The following issue can happen:

  When we performa a type-test against a type parameter the TTS stub for
  the type parameter will call the TTS stub for the type argument of the
  parameter (by loading it from the instantiator type arguments).

  The (instantiated) type argument does not yet have a specialized TTS but
  rather the lazy TTS stub, which will got to the runtime.

  The runtime will instantiate the type parameter using the instantiator tav,
  which will give it a non-nullable 'String!'. Though the NNBD mode used
  for instnatiation is kLegacy, which means the instantiation will
  actually return 'String*'.

  Now we generate a specialized TTS and install it on 'String*'.

  => The original 'String!' will still have the lazy TTS installed and we
     will therefore always go to runtime.

Example:

  This code is massively slowed down after 61b4bbcb6b "[vm] Set non_nullable_flag() to true"

    main(List<String> args) {
      args = args.toList();
      while (args.isNotEmpty) {
        args.removeAt(0);
      }
    }

  The embedder creates the List<String> when calling main. The embedder
  API uses effectively `ObjectStore::string_type`, which is initialized,
  after 61b4bbcb6b to 'String!' (which might be a bug because we do
  have a specific `ObjectStore::non_nullablestring_type`).

=> For now we disable lazy specialization of non-nullable types - which
   makes us fall back to subtype test cache searches in this case (which is
   significantly slower).

See b/148528639

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

Change-Id: I715fe2a9ee22932ae2d949b5cef93d6afb3176d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133981
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-01-30 16:41:58 +00:00
Alexander Markov c307d38af8 [vm/nnbd] Draft support for TypeRefs in CheckInstantiatedNullability
TypeRefs which are used to represent recursive types are now skipped
and removed when we need to change nullability of  type after
instantiation. This change assumes that we only need to change
nullability of a top-level type and not inner types.

Change-Id: I5e92493991f0e2a1ebeb16535ef9d507054017b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133841
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-01-30 16:38:58 +00:00
Victor Lima 9eb531bde4 [vm] Add support for real unboxed floating point fields in AOT
Non-nullable floating point fields (double, Float32x4, Float64x2)
are fully unboxed in their classes.

A bitmap for each class was added to the shared class table in order to keep
track of the pointers of the classes. Since all classes in Flutter Gallery
have less than 64 fields, the bitmap is represented by a 64 bit integer and
fields whose offset is more than 64 words are not unboxed.

The instance sizes and field offsets might change between target and host
in cross-compilation, since the number of words used to store unboxed fields
may differ.

dart-aot Xeon

  SplayLatency               -4.62%
  SplayHarderLatency         -4.17%
  NavierStokes               -2.20%
  Tracer                      8.72%
  ParticleSystemPaint         2.90%
  NBodySIMD                   8.35%
  NBody                      25.59%

With hack TFA to make doubles in Rect/Offset/Size classes in flutter non-nullable:

flutter arm-v8:

  gallery total size: -1%

  matrix_utils_transform_rect_perspective   -16.70% (less is better)
  matrix_utils_transform_rect_affine        -31.82% (less is better)
  matrix_utils_transform_point_perspective  -24.90% (less is better)
  matrix_utils_transform_point_affine)      -27.26% (less is better)
  rrect_contains_bench                      -4.719% (less is better)

Change-Id: I9ae09c9c3167d99f9efd071a92937aa51093fd1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131824
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Samir Jindel <sjindel@google.com>
2020-01-30 13:45:08 +00:00