Commit Graph

478 Commits

Author SHA1 Message Date
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
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
Alexander Aprelev 715bbe363b Revert "[vm] Share some comparison and condition code across platforms."
This reverts commit 87b4848bfc as it broke simarm, simarm64 builds.

Revert "[vm] Distinguish between bool objects by a single bit in their pointers."

This reverts commit f8ead09ba2 being collateral damage for the revert above.

Change-Id: I0a12fe8095566430823c094b294c490b59cb3c39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142404
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2020-04-03 20:43:33 +00:00
Aske Simon Christensen f8ead09ba2 [vm] Distinguish between bool objects by a single bit in their pointers.
Allocate the canonical true and false objects right after the null
object such that their pointers are the same except for a single bit.

This enables a number of optimizations:

- Test of a bool value becomes a bit test when it is known that the
  value is a bool. on ARM64, this bit test can be combined with the
  branch.
- Negation of a bool value becomes an xor when it is known that the
  value is a bool.
- Load of a bool value becomes an immediate add with the null register
  on ARM64.

Change-Id: I70db024437e0f9cb15c401354e5e35802c354172
Cq-Do-Not-Cancel-Tryjobs: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137100
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-03 19:08:27 +00:00
Siva Annamalai ba389f9061 Revert "[VM] - Delete non-nullable-flag() function and adjust code that was"
This reverts commit 1178f96600.

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

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

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

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

Change-Id: Ibaf439fbef5e5e183f16240c4ee02b7031bc35c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140882
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
2020-03-25 22:57:46 +00:00
Alexander Markov ae28b143b5 [vm/nnbd] Run kernel-service and vm-service isolates in NNBD weak mode
Also, add null-safety compatibility flag to snapshots with code.

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

Change-Id: I74d2ad6d4f0850b7cc64e082309a425c683a573c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140240
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2020-03-20 17:48:27 +00:00
Ryan Macnak 5ba84ae6f7 [vm] Restore invariant that all application isolates shut down before the kernel isolate.
Bug: https://github.com/dart-lang/sdk/issues/40894
Change-Id: I22795b9afb9f370da11344c91b214be0fd1ff6bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139521
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-03-14 00:07:27 +00:00
Martin Kustermann 767943850f [vm] Enable check_initialization_order for ASAN, ensure tools/test.py always passes ASAN options, make Random be initialized during VM startup
Running tools/test.py locally behaves differently than on the bots
because the bots will have special environment variables set.

=> We want also local runs of tools/test.py to report ASAN errors, so
   this CL moves the setting of environment variables to tools/test.py

Furthermore we enable "additional check_initialization_order=true" asan
option to detect ordering issues when initializing global state.

Make the IsolateGroup::isolate_group_random_ heap allocated on VM
startup to avoid initialization ordering issue (turns out our `Random`
can depend on embedder entropy source callback being available)

Also add locking around assigning of isolate group ids -- without it we
could have two threads racing and possibly getting the same id.

See b/149978682

Change-Id: I41b9a34c66934dcc0d3804233f5acf09004ba3bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136630
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-02-25 10:32:01 +00:00
Ryan Macnak 388c91df04 [vm] Remove the "compilation allowed" bit.
In the early days of AOT, we performed compilation and then ran results in the same process and isolate. This bit was used to track which phase we were in. Today, these always happen in separate processes and separate binaries, distinguished by the macro DART_PRECOMPILED_RUNTIME.

Change-Id: Idd97908f2e692321a6f5aba8d5738625d42f16e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134568
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-02-21 17:50:13 +00:00
Martin Kustermann dae308461c [vm/concurrency] Share [Heap] and [SharedClassTable] between all isolates within one isolate group
This CL:

  * Moves [Heap]/[SharedClassTable] from [Isolate] to [IsolateGroup], which
    will make all isolates in the group use the same heap. The GC will use
    the shared class table for object size information.

  * Adds support for entering/leaving an isolate group as a helper thread
    (e.g. via [Thread::EnterIsolateGroupAsHelper]). The current active
    isolate group can be accessed via TLS `IsolateGroup::Current()` or
    `Thread::isolate_group_`. When entering as a helper thread there will be
    no current isolate.

  * Changes the GC to use the above mechanism and ensures GC works without
    a currently active isolate. The GC will use information purely available via
    [IsolateGroup]. The GC will iterate all isolates within an isolate
    group e.g. for scanning roots.

  * Makes spawning of new isolates start in their own isolate group.
    Once the isolate is fully functional it's heap will be merged into
    the original isolate group

  * Moves ApiState, containing persistent and weak persistent handles,
    from [Isolate] to [IsolateGroup], plus adds appropriate locking.

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

Change-Id: Ia8e1d8aa78750e8400864200f4825395a182c004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126646
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-02-20 21:08:35 +00:00
Martin Kustermann 355d443b5f Reland "[vm/concurrency] Remove redundant isolates list, ensure shutdown procedure waits until the isolates actually got deleted"
The memory leak as well as OOM seems to be unrelated to this CL, see
discussion on https://github.com/dart-lang/sdk/issues/40627

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

Change-Id: I95cc27370b816fdc79eba1a35b11fd6ca072a4e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136225
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-02-20 20:52:00 +00:00
Siva Annamalai fcf88fe6fa Revert "[vm/concurrency] Remove redundant isolates list, ensure shutdown procedure waits until the isolates actually got deleted"
This reverts commit 40eaf81834.

Reason for revert: This CL seems to cause an OOM error in Flutter tests, the Flutter HHH bot also shows failures starting with this CL. Please see https://github.com/dart-lang/sdk/issues/40627 which has an ASAN dump indicating a double free.

Original change's description:
> [vm/concurrency] Remove redundant isolates list, ensure shutdown procedure waits until the isolates actually got deleted
> 
> Issue https://github.com/dart-lang/sdk/issues/36097
> 
> Change-Id: If24affbb838eff8d80e5d448eac7455b3ffcb3a1
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135062
> Commit-Queue: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Alexander Aprelev <aam@google.com>

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

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

Change-Id: I7329a9cccc788e7ae2794639e0c76071fd4d9aa2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135792
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2020-02-14 00:29:38 +00:00
Martin Kustermann e441b9fa9b [vm/concurrency] Add locking to ApiState as preparation for multiple isolates using the same api state
Once multiple isolates share one heap we'll start sharing the set of
weak/persistent handles present in the ApiState.

This is split out of the shared heap cl to make it smaller.

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

Change-Id: I3b8eb1ebd9361ff56f5272042ae002f57fa61ddd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135308
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-02-11 22:19:45 +00:00
Martin Kustermann 40eaf81834 [vm/concurrency] Remove redundant isolates list, ensure shutdown procedure waits until the isolates actually got deleted
Issue https://github.com/dart-lang/sdk/issues/36097

Change-Id: If24affbb838eff8d80e5d448eac7455b3ffcb3a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135062
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2020-02-11 15:45:33 +00:00
Teagan Strickland d854375bc0 [vm] Make dedup-instructions a global VM flag.
Also check the flag in all code that possibly deduplicate instructions
or needs to know whether instructions may have been deduplicated, so we
can test this code in non-product builds by turning on the flag.

Change-Id: Iefd1aa13a0f5a8a1cd51b547d554c9ae8e7410ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134820
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-02-07 15:15:32 +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
Victor Lima 3fa4194008 [vm] Update offsets
Make the offsets extracted reflect changes in classes that have
fields that do not exist in product mode, since it affects the
entity size.

Change-Id: I0ec277663ba3ddc956ca651ccc0395e39ba185f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133229
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Victor Agnez Lima <victoragnez@google.com>
2020-01-27 15:59:56 +00:00
asiva ac4b43f0a8 [VM/runtime] - Remove DART_NO_SNAPSHOT
- Remove the define DART_NO_SNAPSHOT in all the build configs
- Remove all conditional code under DART_NO_SNAPSHOT

Change-Id: Ia01d09de7c4b1813a5e172a630950e637e476713
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130566
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-01-08 18:56:21 +00:00
Teagan Strickland 3dd8a3b2f3 [vm] Populate VM isolate group source data and instruction pointers.
Change-Id: I1fcdf4a58c4a9b6bd24b4b90fa7048031ec3af12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130702
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>
2020-01-08 15:15:08 +00:00
Martin Kustermann 16697697d4 [vm] Read causal-async-stacks/lazy-async-stacks from snapshot (instead of requiring AOT runtime to pass same flags as in compiler)
We already do this for "use-bare-instructions" and "dwarf-stack-traces". This
CL does the same for "causal-async-stacks" and "lazy-async-stacks".

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

Change-Id: I44136299858b3b72e8a3a176234f5051d6b61c1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130364
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2020-01-06 12:15:59 +00:00
asiva 8e4421a95e [VM/runtime] Conditionally include kernel/service isolate code
- Do not include the kernel isolate code in the precompiled runtime
- Do not include the service isolate code in PRODUCT mode

Change-Id: I6c49a9d4b3523205d1d70d1c6e5743b809ef3212
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129807
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-12-27 19:46:15 +00:00
yuanhuihui fe9f30c389 [timeline] support vm events available to systrace
more detail: https://github.com/dart-lang/sdk/issues/39757

Signed-off-by: yuanhuihui <gityuan@gmail.com>
Bug: https://github.com/dart-lang/sdk/issues/39757
Change-Id: I6174500796289ffcfb7a53d3f897c5d7f82932ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128200
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-12-13 00:41:46 +00:00
Liam Appelbe e1ef70fad4 [vm] Add nnbd-experiment to the snapshot feature string
This means that when snapshots are loaded, the nnbd experiment flag they
were compiled with must match the flag the VM currently has.

Bug: https://github.com/dart-lang/sdk/issues/37479
Change-Id: I907a68f49c7c1ac4467c4c39ce033075eba457a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127961
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2019-12-10 19:04:15 +00:00
Clement Skau d5dbf10672 [SDK] Adds non-eager async stack frame collector.
This is done by collecting all frames on the current stack until an async/async* frame is hit
which has yielded before (i.e. is not in sync-async case).
From there on it finds the closure of the async/async* frame and starts traversing the listeners:
  while (closure != null) {
    yield_index = closure.context[Context::kAsyncJumpVarIndex]
    pc = closure.function.code.pc_descriptors.LookupPcFromYieldIndex(yield_index);
    <emit pc in frame>
    closure = closure.context[Context::kAsyncCompleterVarIndex]._future._resultOrListeners.callback;
  }

Bug: https://github.com/dart-lang/sdk/issues/37668
Change-Id: I97030d22e529bf8a74ecd30a8a2589cfe57ad330
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122644
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-26 11:51:27 +00:00
Martin Kustermann 20962e656b [vm/concurrency] Split up IsolateReloadContext into IsolateReloadContext/IsolateGroupReloadContext
Similar to the split of ClassTable into ClassTable/SharedClassTable,
this CL splits up the IsolateReloadContext into:

  * IsolateGroupReloadContext: Consists of reload-related information across all
    isolates. The [Reload()] method is split up in phases that are
    performed on all isolates before the next phase is started.

    => This allows each isolate to add reasons for rolling back, if no
       reasons are found the reload will be accepted atomically.

  * IsolateReloadContext: Constists of reload-related information for a
    particular isolate (e.g. mappings of old to new classes)

The assumption is that all isolates have the same source (and therefore
the same libraries). For certain things, e.g. discovering which libraries
changed, it is necessary to examine the object store. We use the first
isolate in a group (but could use any of them) to do so, since the
isolate group does not have this information atm.

This is a preparation CL for supporting hot-reloading multiple isolates
within one isolate group. Though the support in this CL stays at having
only a single isolate in a group.

  => This CL turns off FLAG_enable_isolate_groups in JIT mode.

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

Change-Id: I7f4d536d4f5ab4a2a73fb0c7618ba967c9b77234
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123254
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2019-11-15 14:08:45 +00:00
Samir Jindel dd7760a07d [vm] Support disassembling snapshot code at runtime for JIT and AOT snapshots.
--code-comments should be passed both at compile/training-time and run-time to get
comments in the disassembled instructions.

The required --disassemble-* flags need only be passed at run-time. Flow-graph printing
is not yet supported because we don't save flow-graph like assembly comments.

This functionality is excluded from product builds.

Change-Id: If35fbb08cff6eae40069f916ecec9c6f589c0cad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124989
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-11-14 14:09:21 +00:00
asiva a7472ba4c6 Cache value of "non-nullable" flag so it can be used in the VM code without having to search through the array of experimental flags array.
Change-Id: I297dca48711ef2bdd80a102086dea1bb075ea357
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125081
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2019-11-13 01:40:36 +00:00
Ryan Macnak 79c7d3d8bc [vm] Always use bytecode when it is present in a kernel file. Let FLAG_use_bytecode_compiler only control whether the kernel isolate generates bytecode.
We no longer generate kernel files containing both AST and bytecode, so we don't need a flag to choose between them.

Change-Id: I1a4f7df507c649019c9fe254fa18a5826e2006aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122402
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-11-01 17:06:02 +00:00
Ryan Macnak b34f11adbd [vm, gc] Remove expensive, low-value GC verification flags.
--verify_gc_contains is roughly O(heap^2) and gives false errors in some cases involving remembered cards
--verify_on_transition takes over 30 minutes for even hello world

Change-Id: Idee7e535bb96b11f0fa620532debbd21ca9d7135
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123329
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-10-29 19:25:16 +00:00
Samir Jindel c885bdde1d [vm] DBC is obsolete. Remove dead code.
Change-Id: Ica33af158cca53c8e951e4b2582de83660e8a60d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121851
Commit-Queue: Samir Jindel <sjindel@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-10-27 18:18:29 +00:00
Aart Bik 434dc832c6 Revert "[vm] Avoid allocating monitors globally - embedders in certain situations will run into reported leakes due to them"
This reverts commit d9a306fc59.

Reason for revert:

=================================================================
==176913==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 13 byte(s) in 1 object(s) allocated from:
    #0 0x55d94882d540 in __interceptor_strdup /b/s/w/ir/kitchen-workdir/llvm-project/compiler-rt/lib/asan/asan_interceptors.cc:447:3
    #1 0x55d9491abcd7 in dart::KernelIsolate::AddExperimentalFlag(char const*) ../../out/DebugX64/../../runtime/vm/kernel_isolate.cc:382:28
    #2 0x55d9490af7d2 in dart::Flags::SetFlagFromString(dart::Flag*, char const*) ../../out/DebugX64/../../runtime/vm/flags.cc:338:7
    #3 0x55d9490b0221 in dart::Flags::Parse(char const*) ../../out/DebugX64/../../runtime/vm/flags.cc:399:12
    #4 0x55d9490b0538 in dart::Flags::ProcessCommandLineFlags(int, char const**) ../../out/DebugX64/../../runtime/vm/flags.cc:438:5
    #5 0x55d9488885df in dart::bin::main(int, char**) ../../out/DebugX64/../../runtime/bin/main.cc:1149:11
    #6 0x55d94888ad9a in main ../../out/DebugX64/../../runtime/bin/main.cc:1245:3
    #7 0x7f5ccc4a452a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2352a)

SUMMARY: AddressSanitizer: 13 byte(s) leaked in 1 allocation(s).


Original change's description:
> [vm] Avoid allocating monitors globally - embedders in certain situations will run into reported leakes due to them
> 
> Change-Id: Ied0446aebfdd8fb7e15c510cdf4160ff9ad013a6
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122148
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>

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

Change-Id: I2c98bf7e0e565c6f8c016b4832d5587868c65a83
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122680
Reviewed-by: Aart Bik <ajcbik@google.com>
Commit-Queue: Aart Bik <ajcbik@google.com>
2019-10-23 19:34:28 +00:00
Martin Kustermann d9a306fc59 [vm] Avoid allocating monitors globally - embedders in certain situations will run into reported leakes due to them
Change-Id: Ied0446aebfdd8fb7e15c510cdf4160ff9ad013a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122148
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2019-10-22 20:31:56 +00:00
Ryan Macnak 6a65ea9cad [vm] Remove shared snapshot and reused instructions features.
Shared snapshots have been disused by Fuchsia deduping.
Reused instruction has been disused by Flutter code push.

Change-Id: Ia4cb570935c233a9365d521ca04a477c5550ef83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122421
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-10-22 19:02:26 +00:00
asiva cd95fcc810 [VM] Start the kernel isolate only when compilations are needed
- Start the kernel isolate only when a compilation is needed
- Remove some dead code and state in the loader path

Change-Id: I39e14cd79cda18b155af6334a11635c44e2fc11f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121923
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2019-10-18 00:27:16 +00:00
Alexander Aprelev 9e636b5ab4 Reland "[vm/service] Introduce IsolateGroup entity to vm service api.""
This reverts commit f020ce5d23 with patchset 1 having original revert, rest - fixes
for calling destructors on unlinked IntrusiveDL elements and for assuming int is int64(which breaks down on simarm, ia32 bots).

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

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

Change-Id: I867526c7de3786806670d1f43dbff07228f80028
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121870
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-10-17 03:45:41 +00:00
Alexander Aprelev f020ce5d23 Revert "[vm/service] Introduce IsolateGroup entity to vm service api."
This reverts commit f219e5152d as it breaks few bots.

Change-Id: I8d1d42d1ac662c2dba9ea9270c7a6cdc4f0621bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121886
Reviewed-by: Ben Konyi <bkonyi@google.com>
2019-10-16 19:45:23 +00:00
Alexander Aprelev f219e5152d [vm/service] Introduce IsolateGroup entity to vm service api.
This is to enable vm clients to ask how much memory is consumed by isolate group.

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

Change-Id: I4f1c499bf02c20b80e9802d8ad60e7ea65cfb375
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119724
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-10-16 18:05:06 +00:00
Ryan Macnak 20dd7c88e9 [vm] Use VirtualMemory with a cache for small Zone::Segements.
tcmalloc and jemalloc have both been observed to hold onto lots of free'd zone segments (jemalloc to the point of causing OOM), so instead of using malloc to allocate segments, we allocate directly from mmap/zx_vmo_create/VirtualAlloc, and cache a small number of the normal sized segments.

flutter doctor at exit ("idle")
Process::MaxRSS()     261009408 -> 258756608 (-0.86%)
Process::CurrentRSS() 252932096 -> 205881344 (-18.6%)

Bug: https://github.com/dart-lang/sdk/issues/38820
Change-Id: I319069678b9d44383a9921ec03a963517991dd11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121264
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2019-10-11 22:25:23 +00:00
Teagan Strickland ff1a3f7e3a [vm/compiler] Add a snapshot-serialized function pool.
Like the constant pool, this pool is populated when the flag
`--populate-llvm-constant-pool` is used. This pool contains the `Function`
objects that were compiled, and each `FlowGraph` node in the serialized flow
graphs will contain extra information labeled by `llvm-index` which is the
index of its corresponding `Function` object in the pool.

Also fix up printing of the constant and function pools when the flag
`--print-llvm-constant-pool` is used so that the output is buffered to avoid
overlapping output from concurrently running isolates.

Bug: https://github.com/dart-lang/sdk/issues/38297
Change-Id: I67739500c665e509ed16becc2e6bca7fe4928eb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/119543
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-10-02 11:52:39 +00:00
Teagan Strickland 0e8b94feb8 [vm/compiler] Add snapshot-serialized constant pool.
Bug: https://github.com/dart-lang/sdk/issues/38297
Change-Id: I6a8f1d0a727816e8d7e9cec9d62cc21f9dd7412a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118045
Commit-Queue: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2019-09-24 10:01:47 +00:00
Ryan Macnak 03b195164b Revert "[vm, snapshot] Use data image pages for kFull snapshots."
This reverts commit c8f3f132ad.

Revert "[vm] Fix CoreSnapshotSize and StandaloneSnapshotSize to account for the image page size."

This reverts commit 1d6ab52f38.

Bug: b/140791872
Change-Id: I34c42310e3ec4a09048967f34a0e1ddc6a67ea93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116688
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-09-10 23:52:52 +00:00
Ryan Macnak c8f3f132ad [vm, snapshot] Use data image pages for kFull snapshots.
- Enables writing bytecode's PcDescriptors on when IA32 writes app snapshots.
 - Breaks word-size portability of kFull snapshots.

Change-Id: I896d104260593b146ad15e1845e391ae765e60e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115341
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-09-06 18:24:19 +00:00
Clement Skau 201addc553 [typo] SUPPORT_TIMLINE -> SUPPORT_TIMELINE in dart.cc
Change-Id: I5ad181ff5a6a68d8b8426c50f8f3a9eca214dead
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115023
Auto-Submit: Clement Skau <cskau@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2019-09-04 09:01:17 +00:00
Ryan Macnak fdbc2920c7 [vm, bytecode] Use the global lookup cache for dynamic calls.
Removes all ICData from bytecode, avoding the need to clear bytecode when CIDs are reassigned.

Change-Id: I185f9f7acef6a32ef46adb73c6d2652bc1231bab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114053
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2019-08-22 21:43:43 +00:00
Alexander Aprelev baebba06af [vm/isolate] Fix type name typo in Dart::Init method declaration
Change-Id: I68bc114aff645a41e8eb4aaa8af9ae79fd536b4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112640
Auto-Submit: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2019-08-12 19:55:50 +00:00
Clement Skau 844626c4e6 [VM] Copies Dart_CodeObserver in Init to prevent use-after-free.
Dart_CodeObserver is a struct (in dart_api.h) with two pointers:
  void* data;
  void (*Dart_OnNewCodeCallback)(...) on_new_code;

Change-Id: I556b73e0e3488a10f9fd162af24e36ad4f240fa1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111723
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2019-08-05 10:46:29 +00:00
Martin Kustermann 4c5028d139 [vm/concurrency] Make an IsolateGroup object which will contain group-specific resources
The isolate group object will keep a doubly-linked list of all isolates
within it's group. This will allow us to later on iterate all isolates
within a group for e.g. GC purposes.

The isolate group object will eventually hold the shared heap, thread registry
and other resources. This CL is only the start.

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

Change-Id: I32103bbb4830cd4f16665c4032d47dabdf3594dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108407
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2019-07-11 12:13:43 +00:00