Commit Graph

83 Commits

Author SHA1 Message Date
Martin Kustermann 55d1c95e08 [vm] Fix instruction deduplication for bare-AOT mode
Though we disable deduplication for instance methods because switchable
calls rely on a unique PC -> Code mapping atm.

Change-Id: I80915e97f5e06c3f1251ea3176d5c4f8413a81ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/120041
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2019-10-09 19:45:42 +00:00
Martin Kustermann 7376167b2a Revert "[vm/compiler] Fix Code equality comparison in DedupInstructions."
This reverts commit 4cd5d773de.

Reason for revert: Broke flutter benchmarks (e.g. animation, build benchmark).

Original change's description:
> [vm/compiler] Fix Code equality comparison in DedupInstructions.
> 
> Change-Id: Ide07e8dd174cec407b2f19346330985b612f098e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119844
> Auto-Submit: Teagan Strickland <sstrickl@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Teagan Strickland <sstrickl@google.com>

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

Change-Id: I5ab180ddd40fecf769d544184dfffeb034bc2eeb
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119941
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2019-10-03 19:43:15 +00:00
Teagan Strickland 4cd5d773de [vm/compiler] Fix Code equality comparison in DedupInstructions.
Change-Id: Ide07e8dd174cec407b2f19346330985b612f098e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119844
Auto-Submit: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
2019-10-03 16:49:13 +00:00
Teagan Strickland a2bb7301c5 [vm/compiler] Lift PC offsets out of StackMaps.
Instead of storing the PC offset inside the StackMap object, store it instead
in the `Array` containing `StackMap`s in `Code` objects. That is, the `Array`
provided by `Code::stackmaps()` no longer contains just `StackMap` objects, but
instead contains `Smi`s and `StackMap` objects in alternating fashion.  Each
`Smi` is the PC offset for the `StackMap` object that follows.

This ends up changing very little code outside of `StackMap`,
`Code::GetStackMap`, and `StackMapTableBuilder`, as there are only two types of
`StackMap` users:

* Users that call `Code::GetStackMap` already have the PC offset.
* Users that call Code::stackmaps() can just fetch the PC offset from the
  returned `Array` instead.

On 64-bit architectures, we will use more space to represent the PC offset
as a Smi in the Array than the old uint32_t field. However, the drop in total
number of StackMap objects due to an increased ability to canonicalize
them should offset this. On 32-bit architectures, we can only represent
30 bit PC offsets, not 32 bit PC offsets, but that shouldn't be a problem
in practice except for pathological cases.

_Numbers from building the Flutter gallery in android_release mode_

Since PC offsets are no longer in the `StackMap` objects, this enables
a lot more canonicalization than before. Previously, we generated
49379 `StackMap`s, but now we only generate 16139 `StackMap`s, just under
a third of the original number. This is because there were a lot of
`StackMap`s that differed only in their PC offset, and now they can
be canonicalized into the same `StackMap` object.

When building the Flutter gallery with android_release, the app.so size
drops from 11276896 bytes to 10908256 bytes, a difference of 368640
bytes, or 3.27%.

Using the AOT snapshot profiling support, we see the following drops:

Heap snapshot size drops from 10.7 MB to 10.4 MB.

`Code`              | Before  | After   | Difference
---------------------------------------------------------
Shallow size        | 352363  | 352363  | 0
Retained size       | 9114801 | 8796064 | -318737
Percent of snapshot | 81.2%   | 80.7%   | -0.5%

`(RO)StackMap`      | Before  | After   | Difference
---------------------------------------------------------
Shallow size        | 49381   | 16141   | -33240
Retained size       | 893965  | 286613  | -607352
Percent of snapshot | 7.97%   | 2.63%   | -5.34%

`StackMap`          | Before  | After   | Difference
---------------------------------------------------------
Shallow size        | 844584  | 270472  | -574112
Retained size       | 844584  | 270472  | -574112
Percent of snapshot | 7.53%   | 2.48%   | -5.05%

As we'd expect from the `StackMap` numbers above, we end up using a little
under a third of the space for `StackMap`s. We actually use even less space
(32.0% of the original) than the drop in `StackMap` numbers (32.7%), because
each `RawStackMap` instance is 32 bits smaller due to dropping the `pc_offset_`
field. Note that even though these PC offsets now show up in the
`Code::stackmaps()` `Array`, we can see this is still a net drop in space used
by looking at the retained size of `Code` objects.

Bug: https://github.com/dart-lang/sdk/issues/35274
Change-Id: I0910a43e7a5a7e2e721676209196be1884c5a71c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119147
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-10-01 09:12:22 +00:00
Régis Crelier 4403c58640 [vm] Delete obsolete await_token_positions_ from Code object and flow graph.
Change-Id: I80fff049c8d0b45ec7276b1d0ae71f492ad97b9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106564
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2019-06-19 23:38:02 +00:00
Matthew Dempsky 4ce3aa7af1 [vm] Replace ^= assignments with = where possible
Change-Id: I04ac2e9c4b8bb654b7c660e728be3867aa4e1513
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100923
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Matthew Dempsky <mdempsky@google.com>
2019-05-01 00:04:44 +00:00
Jens Johansen 1555594ddb Include a per-library index of owned sources in kernel
This for instance allows the VM to include all patches
(e.g. the previously missing `runtime/lib/date_patch.dart`)
in what's returned from `LoadedScripts()`.

Over time this also allows for `LoadedScripts()` to be simplified and
become faster (it's currently something like O(m + m*n) where m is the
number of results in DictionaryIterator(*this) and n is the number of
returned scripts).

Change-Id: I4b5a6a0fe666b774fc0987d099ed02e81ac97b43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98660
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2019-04-11 12:40:49 +00:00
Alexander Aprelev 59b8a9c4bb [vm] Free readonly header bit so it can be used for other uses.
This is reland of https://dart-review.googlesource.com/c/sdk/+/97340 rebased on top of removal of GraphMarked bit, which was not compatible with this ReadOnly->InVMIsolateHeap change(due to how write-pages are not covered by Contains check)

Change-Id: I34c6421afb4baeafa5a449787020dab9fa800d05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97545
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2019-03-22 23:46:51 +00:00
Ryan Macnak 298dacfef5 [vm] Avoid main thread compilation of implicit accessors.
Main thread compilations: 337 functions / 87.8 ms -> 111 functions / 45.5ms

Change-Id: I64ed6c2aca98c0b3849a9142d698a8a94ed418cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97405
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-03-21 20:18:32 +00:00
Alexander Aprelev 34af8b95e5 Revert "[vm] Free readonly header bit so it can be used for other uses."
This reverts commit 59931e3340 as it
breaks jitk and optcounter bots.

Change-Id: If87ce52ac3d4015608436bfd7ee661ea1414dc7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97480
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2019-03-21 06:23:50 +00:00
Alexander Aprelev 59931e3340 [vm] Free readonly header bit so it can be used for other uses.
Rely on vm_isolate()->heap()->Contains() instead of header bit check.

Change-Id: Ibf66b9910aea5003dd3dee539704deeb72c61ada
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97340
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-03-21 00:02:56 +00:00
Zichang Guo 4ec72c1eb1 [VM-Runtime]Fix source report coverage to not include field without function initializer
Fix issue created by 89173. Also rename HasInitializer to HasInitializerFunction to distinguish from has_initializer.

Bug= https://github.com/flutter/flutter/issues/28542

Change-Id: Id9f898937c2f4f350a6d619019dc12611505801f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95680
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2019-03-07 02:04:41 +00:00
Ryan Macnak 980e5c7b57 [vm] Mark VM isolate objects at heap finalization instead of allocation.
Avoids unnecessary branching in allocation.

Also, rename the VMHeap bit to ReadOnly to reflect its current usage.

Change-Id: Ic6060eec263cef0a3fc92f253dff976cea45bdb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/95063
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2019-03-07 00:20:30 +00:00
Zichang Guo 7e81f56ad7 Save Initializer for field and pass into debugger to enable breakpoint setting.
Change-Id: I9f7afcdd057f161873d3c6e47cb0ce171806f301
Reviewed-on: https://dart-review.googlesource.com/c/91120
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zichang Guo <zichangguo@google.com>
2019-02-06 03:20:35 +00:00
Ryan Macnak e717ecdc92 [vm] Maintain view-ness of bytecode instructions in snapshots.
Change-Id: Ieb032d55e5b8bab08e7eb3445a356068384dca28
Reviewed-on: https://dart-review.googlesource.com/c/91682
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-01-31 20:10:58 +00:00
Ryan Macnak c34f1b4890 [vm] Bind static calls before saving JIT snapshots.
Change-Id: I11bbd7168513d2edf5b3ef4c77236e647bc9941c
Reviewed-on: https://dart-review.googlesource.com/c/88902
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-01-10 22:33:22 +00:00
Martin Kustermann f205292227 [VM] Bare instructions - Part 4: Add --use-bare-instructions flag to AOT compiler & runtime
This is the final CL which adds a new --use-bare-instructions flag to
the VM.

If this flag is set during AOT compilation, we will:

  * Build one global object pool (abbr: GOP) which all code objects
    share. This gop will be stored in the object store.  The PP register
    is populated in the enter dart stub and it is restored when
    returning from native calls.

  * Gets rid of the CODE_REG/PP slots from the dart frames. Instead the
    compiled code uses the global object pool, which is always in PP.

  * Starts emitting pc-relative calls for calls between two dart
    functions or when invoking a stub.
    Limitation: We only emit pc-relative calls between two code objects
    in the same isolate (this is because the image writer is writing
    instruction objects for vm-isolate/main-isolate seperately)

  * We do compile-time relocation of those static calls after the
    precompiler has finished its work, but before writing the snapshot.
    This patches all the instruction objects with pc-relative calls to
    have the right .text distance.

  * We emit a sorted list of code objects in ObjectStore::reverse_code_table,
    which will be used by the AOT runtime to go back from PC to Code
    objects (where all metadata, e.g. stack maps, catch entry moves, pc
    descriptors are available).

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

Change-Id: I6c5dd2b1571e3a889b27e804a24c2986c71e03b6
Reviewed-on: https://dart-review.googlesource.com/c/85769
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2018-12-14 16:03:04 +00:00
Vyacheslav Egorov 229d793602 [vm/compiler] Support materializing unboxed variables when entering catch.
Previously we tried to rely on the assumption that all variables would be
boxed - so the machinery for setting correct catch-entry state only
supported tagged values and constants. However this both leads to worse code
and is not entirely correct assumption.

This also:

- renames various confusingly named classes: we move away from talking
about "catch entry state" to "catch entry moves" - because we only
record a subset of moves that needs to be performed and that does
not describe the whole state;
- refactors a bunch of associated code to be more readable and maintainable;
- adds documentation about catch implementation in optimized code
to runtime/docs/compiler;

Fixes https://github.com/flutter/flutter/issues/21685.

Change-Id: I03ae361a1bb7710acbd9f661ae014e663a163c59
Reviewed-on: https://dart-review.googlesource.com/74860
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2018-09-14 17:39:12 +00:00
Ryan Macnak dd3ec65af8 [vm] Hash canonical objects by content instead of address.
Bug: https://github.com/dart-lang/sdk/issues/31427
Change-Id: Iad02b152887576f8fbdcbed6892464a0c2ffa09c
Reviewed-on: https://dart-review.googlesource.com/54662
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2018-05-14 20:11:27 +00:00
Alexander Markov 97bbe2f20b [vm] Avoid using objects in VM isolate heap for de-duplication
Parameter types in application isolate could be modified during
execution, so it is incorrect to de-duplicate them with
read-only objects from VM isolate.

Fixes crash in pkg/front_end/tool/incremental_perf.dart
benchmark running from appjit snapshot. This crash appears after
https://dart-review.googlesource.com/c/sdk/+/45747 is applied.

Change-Id: I42a2007d02e04e0720c7e5d15224fcb6994bc515
Reviewed-on: https://dart-review.googlesource.com/45752
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2018-03-09 01:53:17 +00:00
Ryan Macnak 65990d5d7e Don't use heap iteration order when seeding the VM isolate.
Bug: https://github.com/dart-lang/sdk/issues/31427
Change-Id: I74c5c9f6e992bf68913178a49916892c0ef808c9
Reviewed-on: https://dart-review.googlesource.com/26440
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2017-12-06 22:24:25 +00:00
Ryan Macnak 344a9d546b [vm] Deduplicate catch entry state maps.
Flutter gallery ARM32:
TypedData          74349 ->    22701 (-69.5%)
Total snapshot  10741228 -> 10689108 (-0.49%)

Bug: https://github.com/dart-lang/sdk/issues/31302
Change-Id: I759147e4a9cd532eb338d96558a423e675358790
Reviewed-on: https://dart-review.googlesource.com/20562
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2017-11-14 23:06:05 +00:00
Ryan Macnak a2695ad29b When deduplicating program metadata, try to use objects from the VM isolate.
Expands the mechanism that moves token streams to the VM isolate to include instructions and code metadata.

Allow the isolate snapshot to reference Instructions in the VM isolate.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2909403002 .
2017-09-01 13:26:29 -07:00
Ryan Macnak f8e47a9e26 Reapply "[vm] Don't enable the profiler by default. Enable the profiler at startup with --observe, or later through Observatory."
Ensure we still start NativeSymbolResolver even if the profiler is off, since it is also used name weak handler finalizer functions and to produce stack traces for crashes.

R=bkonyi@google.com

Review-Url: https://codereview.chromium.org/2992893002 .
2017-08-09 11:20:58 -07:00
Dmitry Stefantsov eddc456f29 Revert "[vm] Don't enable the profiler by default. Enable the profiler at startup with --observe, or later through Observatory."
This reverts commit cc08f2ddd8.

R=whesse@google.com

Review-Url: https://codereview.chromium.org/2990173002 .
2017-08-02 11:30:16 +02:00
Ryan Macnak cc08f2ddd8 [vm] Don't enable the profiler by default. Enable the profiler at startup with --observe, or later through Observatory.
Note there is no option to disable the profiler. The profiler on Mac, Linux, and Android is based on SIGPROF, and there is no way to wait for all the outstanding signals as required to be able to safely free the sample buffer.

Saves ~20MB on 64-bit VMs.

R=cbernaschina@google.com, zra@google.com

Review-Url: https://codereview.chromium.org/2989093002 .
2017-08-01 17:57:08 -07:00
Zachary Anderson 6cd8a79078 VM: Re-format to use at most one newline between functions
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2974233002 .
2017-07-13 08:08:37 -07:00
Aske Simon Christensen ab7d9a5720 Omit JIT compiler from precompiled runtime on ARM, ARM64 and IA32.
Saves about a megabyte on the size of the precompiled runtime VM.

Next step will be to eliminate the assemblers and code stubs as well. This requires some more disentangling.

Until then, the X64 build still includes the compiler, since its assembler has a dependency on locations.cc, which is part of the compiler.

BUG= https://github.com/dart-lang/sdk/issues/30045
R=rmacnak@google.com, zra@google.com

Review-Url: https://codereview.chromium.org/2960413002 .
2017-07-11 12:01:49 +02:00
Ryan Macnak 39040a8a15 Never erase parameter types in the JIT.
Even in unchecked mode with mirrors disabled, we need to be able to forward parameter types to lazily generated implicit closure functions.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2808763008 .
2017-04-12 15:40:42 -07:00
Ryan Macnak 5cffc591aa Refactor AOT deduplication steps so they can run before an app-jit snapshot as well.
Additionally dedup PcDescriptors, deopt entries, deopt lists, and await token position lists.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2815533003 .
2017-04-12 14:23:49 -07:00
Ryan Macnak 4607e38d28 Reapply "Save and restore feedback from JIT."
Ensure ICData is attached to the callee flow graph in the inliner when built from kernel IR, not just from source.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2572423004 .
2016-12-16 16:00:17 -08:00
Ryan Macnak 176d732cc3 Revert "Save and restore feedback from JIT."
This reverts commit 31ee20297e.

Review-Url: https://codereview.chromium.org/2579413002 .
2016-12-16 13:53:20 -08:00
Ryan Macnak 31ee20297e Save and restore feedback from JIT.
- Adjust fingerprints to be independent of the library's private key, which varies with load order.
 - Use usage_counter in AOT inlining decisions if JIT feedback is available.
 - Reduce inlining in cold functions.

dart2js product aot snapshot 15841351 -> 14436273 (-8.86%)

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2562693003 .
2016-12-16 10:21:40 -08:00