Commit graph

46 commits

Author SHA1 Message Date
Martin Kustermann ef9d699f07 [vm/concurrency] Move all information except for the class pointers out of [ClassTable] into [SharedClassTable]
This CL moves heap related information (namely instance sizes and
allocation stats) out of the [ClassTable] into a [SharedClassTable].
Both classes are always in sync (i.e. they have the same number of entries).

This CL also changes GC related code to start using the size information
from the new [SharedClassTable].

In a futher step we will move the heap as well as this shared class
table out of the [Isolate] and into [IsolateGroup].

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

Change-Id: Id54a89c9251ad3bbc13e60d32dc4f7bcc7f1d805
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116064
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-09-10 12:48:16 +00:00
Martin Kustermann f5c0e2e362 [vm/concurrency] Ensure instance size in class table is either 0 or the correct size
Until now it was possible to register classes with a default size (16 bytes on 64-bit)
and later on change the size for the cid.

This CL changes this to ensure the size information in the class table
for a given cid is either 0 or the final instance size (and adds an
ASSERT for it)

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

Change-Id: I94c61c6a1566c13dec7b9eb80c9ae0dadf0e6b6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115861
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-09-06 22:06:30 +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
Ryan Macnak 6e2b3f0326 [vm] Greatly reduce handle allocation during reload.
Saves 10ms from non-empty reloads of Flutter Gallery.

Change-Id: If9a1f9970d562f8fd7996de875dfe231350efaa9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113282
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2019-08-20 00:49:52 +00:00
Alexander Aprelev cbff5cff2f [vm/reload] Fix scenario when class removed during hot reload stays unpatched.
Fixes https://github.com/dart-lang/sdk/issues/36838

Change-Id: I73aa25e4ab5d7fac13fcc6953fa6c3a6c4c10ab4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101625
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2019-05-07 23:13:27 +00:00
Alexander Aprelev 7a02066c30 [vm] Report kernel program stats for hot-reload request.
Change-Id: I73de5869bea60153ffb416a2a05cd7de538b0f59
Reviewed-on: https://dart-review.googlesource.com/c/87706
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-12-20 23:14:16 +00:00
Liam Appelbe f8a680e511 Revert "Remove kernel isolate API from the public dart_api.h"
This reverts commit 9906819fb7.

Reason for revert: Follow up CLs are more complicated than I thought, so I don't want to leave it in an inconsistent state.

Original change's description:
> Remove kernel isolate API from the public dart_api.h
> 
> This is the first step in moving the kernel isolate out
> of the VM and into the standalone embedder.
> 
> Bug: https://github.com/dart-lang/sdk/issues/33433
> Change-Id: Ie8d9ac1c27efe2661f0441b75275119966d197af
> Reviewed-on: https://dart-review.googlesource.com/c/84829
> Commit-Queue: Liam Appelbe <liama@google.com>
> Reviewed-by: Ryan Macnak <rmacnak@google.com>

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

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

Bug: https://github.com/dart-lang/sdk/issues/33433
Change-Id: Iaf753c210e918df167364b50ee823b2557896628
Reviewed-on: https://dart-review.googlesource.com/c/87623
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2018-12-18 20:20:42 +00:00
Liam Appelbe 9906819fb7 Remove kernel isolate API from the public dart_api.h
This is the first step in moving the kernel isolate out
of the VM and into the standalone embedder.

Bug: https://github.com/dart-lang/sdk/issues/33433
Change-Id: Ie8d9ac1c27efe2661f0441b75275119966d197af
Reviewed-on: https://dart-review.googlesource.com/c/84829
Commit-Queue: Liam Appelbe <liama@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-11-26 22:47:20 +00:00
Zach Anderson c4df463ba9 [vm] Reland kernel data library and class caches.
This is the same code as the previous commit, but it needs a fix
for issue #34953 to land first.

Change-Id: Id586f5e8a5ee498716e58ff44bb8a344822f73df
Reviewed-on: https://dart-review.googlesource.com/c/81840
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-11-01 20:25:59 +00:00
Ryan Macnak 2085277771 [vm, reload] On the path for no shape changes, defer freeing the old class table until the next safepoint.
Compare the reload rollback path.

Bug: https://github.com/dart-lang/sdk/issues/34888
Change-Id: I5b9e7cd8392f9c9d61df31481956a9fa67435b33
Reviewed-on: https://dart-review.googlesource.com/c/81940
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-10-30 21:53:54 +00:00
Martin Kustermann 12fe255ff5 Revert "Reland: [vm] Add a library and class cache to KernelProgramInfo"
This reverts commits
  - 47c55605b8
  - c362e4862f.

Reason for revert:

Very likely the cause for flaky crashes where mutator and BG compiler are accessing the program info class cache concurrently without proper locking.

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

Original change's description:
> Reland: [vm] Add a library and class cache to KernelProgramInfo
>
> Relands with locks to protect the caches.
>
> Original message:
> Also create fewer handles in the KernelLoader.
>
> GenKernelKernelReadAllBytecode improves a further
> 15-20% after removing the timeline event argument
> in the bytecode reader.
>
> Change-Id: I6d796986a7773938e528271033385465e4f13468
> Reviewed-on: https://dart-review.googlesource.com/c/79380
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Zach Anderson <zra@google.com>

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

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

Change-Id: Ib242ecc9ece8a233441fc4d5512e4a20ce3e0d11
Reviewed-on: https://dart-review.googlesource.com/c/81601
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2018-10-26 11:32:34 +00:00
Zach Anderson c362e4862f [vm] Invalidate KernelProgramInfo caches on a reload
Change-Id: I911ce057d7a35f0d9b087669dba52bb01b4719fc
Reviewed-on: https://dart-review.googlesource.com/c/79880
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-10-15 21:11:36 +00:00
Ben Konyi 6f3de544ed [ VM / Hot Reload ] Fixed tests which were crashing periodically. Fixes issue #34599
Change-Id: I053701122f4a95ae3d9f27b91134433201bfe8aa
Reviewed-on: https://dart-review.googlesource.com/77004
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
2018-09-27 21:47:39 +00:00
Alexander Aprelev cf055d6b88 [vm] Fix isolate reload tests so that they can pass kernel files for isolate reload.
Change-Id: I695761a790354eacc0d617cb914d7a4ea2b652aa
Reviewed-on: https://dart-review.googlesource.com/76300
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-09-26 14:10:53 +00:00
Martin Kustermann 4c455e7876 [VM] During hot-reload check if .packages was modified, tell IKG to re-load it if so
Change-Id: Ice7bbe0ccd98e450ec9c90a22259ec7b406b2c83
Reviewed-on: https://dart-review.googlesource.com/68360
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2018-08-03 11:03:08 +00:00
Erik Corry c8ad75d44a [VM] Make classes movable in sliding compactor
Store class sizes off heap so we can determine the size
of their instances even while the classes are moving.

R=rmacnak@google.com

Change-Id: I7b935114f76eb8b6aaa57d65e5b7cc0070afa75f
Bug: https://github.com/dart-lang/sdk/issues/30978
Reviewed-on: https://dart-review.googlesource.com/52104
Commit-Queue: Erik Corry <erikcorry@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2018-04-26 09:38:25 +00:00
Ryan Macnak 09e1766e6c [vm] Omnibus memory leaks.
- Fix leak of IsolateReloadContext.
 - Fix leak kernel compilation request arguments.
 - Fix leak kernel compilation result errors in reload harness.
 - Fix leak of class table when a schema changes but there are no instances.
 - Fix leak of kernel::Reader during inlining bailout.

Bug: https://github.com/dart-lang/sdk/issues/32187
Bug: https://github.com/dart-lang/sdk/issues/28349
Change-Id: I9ccc65e018c30a3254e928a43b9727ae8d9314d6
Reviewed-on: https://dart-review.googlesource.com/49547
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-04-05 18:12:11 +00:00
Ryan Macnak 3a3d2c0167 Revert "[vm, reload] Fix leak when shape changes but there are no instances."
This reverts commit deed9b0653.

Reason for revert: Debug Windows failures

Original change's description:
> [vm, reload] Fix leak when shape changes but there are no instances.
> 
> Fix leak of reload context when used by the test harness.
> 
> Bug: https://github.com/dart-lang/sdk/issues/28349
> Change-Id: I2d1bda5537befddbd1e615b355654a9fefc08273
> Reviewed-on: https://dart-review.googlesource.com/49321
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=bkonyi@google.com,rmacnak@google.com

Change-Id: I6f351645e1c9af4c2cbf1bbffdc339b68a11dbd5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/28349
Reviewed-on: https://dart-review.googlesource.com/49620
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-04-04 23:23:56 +00:00
Ryan Macnak deed9b0653 [vm, reload] Fix leak when shape changes but there are no instances.
Fix leak of reload context when used by the test harness.

Bug: https://github.com/dart-lang/sdk/issues/28349
Change-Id: I2d1bda5537befddbd1e615b355654a9fefc08273
Reviewed-on: https://dart-review.googlesource.com/49321
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-04-04 18:10:05 +00:00
Ben Konyi 6338914d31 - Removed dead code (pulled from review 36121)
- Enabled incremental compiler in the dart frontend for the command-line VM
- Added method to update in-memory file system with in-memory sources provided by tests

Change-Id: Ica26b7235383185dbb6b4b41064193d432dfcba0
Reviewed-on: https://dart-review.googlesource.com/36126
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-02-07 19:35:39 +00:00
Ben Konyi 6be8d47b49 Fixed incorrect condition in FileModifiedCallback which reported all libs as being modified since last reload.
Bug:
Change-Id: I2dfc9b73db960763ac60dd626d683afae09c398f
Reviewed-on: https://dart-review.googlesource.com/34021
Reviewed-by: Siva Annamalai <asiva@google.com>
2018-01-12 00:04:31 +00:00
Ryan Macnak d965998d1c [vm] Begin a sliding compactor.
Improves the space overhead of compaction from O(size of live objects) to O(number of live objects).

Future work includes: 
 - a smaller, faster representation the forwarding table via a bitmap of used allocation units
 - sorting class sizes off-heap to allow sliding classes
 - running forwarding in parallel

Removes unnecessary sweep from evacuating compactor.

Change-Id: If0991bfb75573201c6e8feed142ca0cc69fccab4
Bug: https://github.com/dart-lang/sdk/issues/30978
Reviewed-on: https://dart-review.googlesource.com/15988
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Erik Corry <erikcorry@google.com>
2017-10-25 21:57:08 +00:00
Siva Annamalai 8039138f39 Move all the isolate reload code under !defined(DART_PRECOMPILED_RUNTIME)
R=zra@google.com

Review-Url: https://codereview.chromium.org/2997243002 .
2017-08-24 09:25:55 -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
Erik Corry aa6353b6da Dart SDK Spelling b, c, and d.
R=kmillikin@google.com
BUG=

Review-Url: https://codereview.chromium.org/2850783002 .
2017-05-01 08:28:10 +02:00
Ryan Macnak 8b96a31c7f Move runtime functions to the more logical runtime_entry.cc.
Make --trace-runtime-calls respect the isolate filter.

R=johnmccutchan@google.com

Review-Url: https://codereview.chromium.org/2827873002 .
2017-04-19 10:22:04 -07:00
Ryan Macnak 781fd36086 Add an option to gen_snapshot for creating a Makefile describing a snapshot's dependencies. This option may be used when generating any snapshot kind, or without generating a snapshot.
- Factor out MallocGrowableArray from vm to platform.
 - Add File::Print.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2715463003 .
2017-02-23 12:40:48 -08:00
John McCutchan f43b48e34d Support reloading from source on top of a script snapshot.
- [x] Add arguments `rootLibUri` and `packagesUri` to the reload service rpc. These allow the uri of the root library and the .packages files to be overridden.
- [x] When pairing libraries during reload, support the base url changing.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2512483002 .
2016-11-17 11:29:12 -08:00
John McCutchan 2e197df37d Rehash canonical constants table for each class that can be affected by the 'become' operation
Fixes #27803

Rehashing all classes canonical constant's takes 3milliseconds for gallery on an Nexus 7.

BUG=
R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2497673004 .
2016-11-17 07:41:24 -08:00
John McCutchan a776600362 Run field initializers for new instance fields after a reload
- [x] When performing a reload, track new fields with initializing expressions.
- [x] After a reload, run the initializing expressions for each new field on all instances of the class.
- [x] Unit tests (heart beat, throwing, and syntax errors)
- [x] Add some utility methods to Function, Field, and Script.
- [x] Fix a major bug in instance morphing and class hierarchy traversal.

Fixes #27666

BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2489723003 .
2016-11-14 13:33:19 -08:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
Zachary Anderson 103881d01c Make header include guards great again
i.e. #ifndef VM_WHATEVER -> #ifndef RUNTIME_VM_WHATEVER

This lets us remove a hack from the PRESUBMIT.py script that existed
for reasons that are no longer valid, and sets us up to add some
presubmit checks for the GN build.

R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2450713004 .
2016-10-26 00:26:03 -07:00
Siva Annamalai 690d6d74f8 Fix for heap corruption issue when patch https://codereview.chromium.org/2225243003/ is applied.
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2255553002 .
2016-08-16 13:01:10 -07:00
John McCutchan 35146c688e Fix reload handling of unwind / stackoverflow errors
BUG=

Review URL: https://codereview.chromium.org/2201283002 .
2016-08-02 18:27:35 -07:00
John McCutchan a6114c23cd Simplify reload error reporting
- [x] Rationalize the load failure code path.
- [x] Remove support for reload to be aborted via a callback.
- [x] If a reload fails due to an unwind error, ignore it as the isolate is dead anyway.
- [x] Move more allocations into the zone.

Review URL: https://codereview.chromium.org/2208553002 .
2016-08-02 16:11:30 -07:00
John McCutchan 059470cf85 Make all reload zone allocations use the same zone
- [x] Use a single outer zone for all zone allocations done during a reload. This fixes an issue where we were allocating  objects in different zones that were destroyed before we expected them to be.
- [x] Rename some methods.
- [x] Made most methods on IsolateReloadContext private.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2201093002 .
2016-08-02 09:36:46 -07:00
John McCutchan 501c9896c1 Refactor how we report reload results
- [x] Give the IsolateReloadContext a JSONStream.
- [x] Remove the sticky reload error from the isolate.
- [x] Print all reasons for cancelling when we fail.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/2196723002 .
2016-08-01 12:30:39 -07:00
Todd Turnidge 1166f83bf6 Only reload libraries when they may have been modified.
We now check all of the scripts which make up a library.  If any
script is modified, then we consider that library to be modified.  We
also consider any library which imports a modified library to be
modified.  To propagate this info efficiently, we build and discard
the imported-by graph when beginning a reload.

The embedder must provide a FileModifiedCallback in order to support
the detection of modified scripts.

In order to detect changes to package: libraries, we have modified the
embedder interface to provide the resolved url when possible, so that
we don't need to re-resolve package uris when checking for reload.
This change is incompatible and all embedders will need to be updated.

We now support a "force" flag when reloading sources.  This causes all
libraries to be reloaded regardless of whether the underlying scripts
have been updated.

Closes #26919

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2186423002 .
2016-07-29 11:23:18 -07:00
Lars Bak b38b2f7071 Added JSON reporting to reload.
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2186303002 .
2016-07-28 11:07:15 -07:00
Lars Bak 293c6116e9 Implemented schema change for the isolate reload operation.
I'll add more tests to isolate_reload_test.cc while waiting for the first round of comments.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2179983002 .
2016-07-26 11:13:28 -07:00
Florian Schneider 25070b85b1 Fix for use-after-free of reload context
Delete the reload context after the last use. My first attempt did not work
with our unit test framework for reload cc tests.  When running unit tests
the reload context is needed for longer, and deleted separately.

BUG=#26895
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2164703003 .
2016-07-19 18:28:56 -07:00
John McCutchan c692a64e5a Rework how enums are implemented and reloaded
- Enum instances now hold their index and their label. Before the labels were held in a static array to the side and the index was used to look up the label.

- Before and after reload enum instances are now paired (by label) and put into the 'become' table.

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

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2153143002 .
2016-07-15 10:52:20 -07:00
Todd Turnidge 62ccff992f Cache compile-time constants on the script object, sometimes.
When a script is not in the vm heap, we now cache compile time
constants on the script object itself.  During isolate reload we may
have both an old and a new version of a script being compiled at the
same time and they need to cache their constants separately.  This
also means that compile time constants from old scripts can be
collected when the script is collected, which is good.

When a script is in the vm heap, we continue to use the old system of
employing a shared per-isolate cache stored in the object store.

Closes #26833

BUG=
R=fschneider@google.com, johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2126393003 .
2016-07-11 14:15:37 -07:00
John McCutchan 0e286e2fdd Fix library private key stability during reload
- [x] When allocating a library private key during reload, give the reload context an opportunity to provide a private key from the original library.
- [x] In identity reload mode, ensure that we pair all libraries as well as classes.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/2054833002 .
2016-06-13 12:42:17 -07:00
Todd Turnidge 9e3ac930d7 Fix tests by removing broken (and unneeded) code from isolate_reload.cc
BUG=

Review URL: https://codereview.chromium.org/1988763004 .
2016-05-17 15:32:58 -07:00
John McCutchan 48c8ffa7f3 Initial isolate reload support
This is a cut of the work that Todd and I collaborated on in the reload branch.

In this CL, we've dropped the loader port hacks, in other words, on stack reloading in the standalone embedder does not work yet.

- [x] Support for hot reloading of isolate source code
- [x] Unit test harness and many tests
- [x] Service protocol and Observatory support
- [x] Product build does not include support for hot reloading.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1965823002 .
2016-05-17 12:19:06 -07:00