Commit Graph

38 Commits

Author SHA1 Message Date
Ryan Macnak 8fba2ea2b6 Use OOB messages to schedule compaction for Dart_NotifyLowMemory.
This ensures any finalizers that run during compaction happen on a thread the embedder knows about.

Bug: https://github.com/dart-lang/sdk/issues/31662
Change-Id: If1ca39fe72937ad2bc4607f7cacc4dc82e49be01
Reviewed-on: https://dart-review.googlesource.com/30040
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2017-12-19 22:38:34 +00:00
Ryan Macnak 5e07efa547 [vm, gc] Add Dart_NotifyLowMemory.
Move updating class table allocation stats before/after GC to inside the GC's safepoint.

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: Ia15665397ae9f455c5e7e4526d3575932246bbcc
Reviewed-on: https://dart-review.googlesource.com/22805
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2017-12-06 22:45:31 +00:00
Ryan Macnak b247090c9e [vm] Align old-space pages.
Allows quick access to the page header for any old-space object, which is a convenient place to keep forwarding information.

Also combine the reserve and commit operations of VirtualMemory.

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: Id3fe06932f7bef882bb1cc29d72441b0a3602eb6
Reviewed-on: https://dart-review.googlesource.com/17046
Reviewed-by: Erik Corry <erikcorry@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
2017-10-30 22:02:20 +00:00
Ryan Macnak 5a76000b98 [vm] Maintain image pages on a separate list.
Neither the sweeper nor the compactor may modify these pages.

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: I9b41bbb626560f5e68f1c189cf3eeb2d5d9e39ca
Reviewed-on: https://dart-review.googlesource.com/14902
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2017-10-19 01:11:05 +00:00
Ryan Macnak 7af0a05a2e [vm] Compute per-HeapPage usage during sweeping.
To be used by compacting GC.

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

Review-Url: https://codereview.chromium.org/2993383002 .
2017-08-11 13:06:36 -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 cec963f028 The current growth strategy for growable arrays allocates a backing array of size 2 at (empty) creation and doubles the size whenever the capacity is insufficient while adding elements.
I collected statistics for the sizes and capacities of growable arrays which are promoted to old-space or survive an old-space gc when running dart2js and Fasta. For these applications, the vast majority of arrays stay empty. More than half of the total object size of promoted backing arrays is backing for empty growable arrays.

Furthermore, since the overhead for an array is 3 words (header, type parameters and length), and object sizes are rounded up to an even number of words, we waste one word for all even-sized arrays.

This CL changes the growth strategy so that empty growable arrays are created with a shared, zero-sized array as backing, avoiding the allocation of a backing array if no elements are added. When the array needs to grow, it starts out at 3 and grows to double size plus one each time: 7, 15, 31, ...

A few places in the VM code need to handle these shared, zero-sized arrays specially. In particular, the Array::MakeArray function needs to allocate a new, empty array if its result is to be returned to Dart code.

Benchmarks suggest that the change improves memory usage by a few percent overall and does not significantly affect run time.

BUG=
R=erikcorry@google.com

Review-Url: https://codereview.chromium.org/2949803002 .
2017-06-22 10:51:54 +02:00
Ryan Macnak 8b217ec519 Rename references to "external pages" as "image pages" to avoid confusion with the kind of external memory associated with finalizers.
R=asiva@google.com

Review-Url: https://codereview.chromium.org/2654183002 .
2017-01-26 09:53:06 -08:00
Ryan Macnak b46af1e75f Refactor snapshots pieces to include a section for loading instructions into the heap of a regular isolate.
Progress toward allowing each isolate to load a different snapshot.

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2622053002 .
2017-01-23 10:25:02 -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
Florian Schneider 9f00ce2b6e VM: Fix for deadlock with background tasks.
We have to do NotifyAll whenever a task finishes.

Also, remove thread notifications when a task is created, since we only ever wait for tasks to finish.

BUG=#27365
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/2349853002 .
2016-09-16 15:03:36 -07:00
Ryan Macnak d28744b8d2 Both the mutator and the background compiler may be waiting on the sweeper task.
BUG=http://dartbug.com/26891
R=fschneider@google.com

Review URL: https://codereview.chromium.org/2153763004 .
2016-07-15 12:12:44 -07:00
John McCutchan 41d9f2d107 Add Thread TaskKind
BUG=
R=asiva@google.com, turnidge@google.com

Review URL: https://codereview.chromium.org/1814243002 .
2016-03-21 09:41:47 -07:00
Siva Annamalai bb62e8c702 Fix to ensure the product mode builds again.
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1813053005 .
2016-03-18 14:27:35 -07:00
Ryan Macnak 366f1f1ed1 Collect samples for background threads.
- Don't tick vm tags for background threads so the Observatory's summary pie chart reflects how the mutator spent its time.
 - Similarly, don't factor background samples in the CPU profile view.
 - Do include background samples in the timeline view.

Use a different event name for background compilations.

Add timeline events for the mark and sweep tasks.

Reload the isolate list when refreshing the timeline view so it includes profile ticks when the page is loading directly (e.g., F5) instead of only after visiting the vm page.

Fix loading the timeline when profiling is disabled.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1814813003 .
2016-03-18 10:18:38 -07:00
Siva Annamalai e72c1fb47d Implement safepointing of threads :
- uses thread execution status transition to track when a thread is in a safepoint or needs to block for a safepoint
 - introduces a monitor per Thread object
 - uses a per thread safepoint handshake between the thread requesting a safepoint and the requested thread.

The ThreadRegistry class now contains only the thread list for an isolate and the functionality of scheduling a thread onto an Isolate and unscheduling it from teh isolate. We could fold this functionality into the Isolate class in a different CL.

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

Review URL: https://codereview.chromium.org/1541073002 .
2016-02-01 10:57:34 -08:00
Siva Annamalai b40775549f Fix for issue 25236
- Ensure that no new OSThreads are created once the VM is in shutdown mode
- Do not query thread_list_head_ without a lock (this leads to the race which causes two threads to delete the lock and TLS at the same time)

BUG=25236
R=zra@google.com

Review URL: https://codereview.chromium.org/1537543002 .
2015-12-18 10:16:28 -08:00
Daniel Andersson cab0033667 Add safepointing to the GC
BUG=
R=iposva@google.com

Review URL: https://codereview.chromium.org//1292353004 .
2015-08-25 18:20:27 -07:00
Daniel Andersson 868d2c6c3e The sweeper must not be running during isolate shutdown.
In release mode, there seems to be nothing to prevent this.
In debug mode, the "Verify" call waits for the sweeper, but there is still a race between the task count update and the ExitIsolateAsHelper call, which could cause problems.

Fix both of these, and add more assertions and verbose error messages.

- make sweeper task cleanly exit isolate *before* notifying
- wait for sweeper before shutting down isolate
- verbose pthread failures

BUG=
R=asiva@google.com

Review URL: https://codereview.chromium.org//1233563004 .
2015-07-13 17:49:49 -07:00
koda@google.com 0e04456696 Remove fake isolate from concurrent sweeper and extend lifetime of VM threads.
* Use real isolate in concurrent sweeper rather than shallow copy.

The only part of the isolate, other than the page being swept, used by the sweeper is the class table (via RawObject::Size), which is now safe to read concurrently (copy-on-write).

* Do not eagerly destroy a VM thread whenever it exits an isolate.

This extends the lifetime of a VM thread across entering/exiting multiple isolates. This is necessary in case an embedder callback executes during
compilation and switches/spawns isolates.

For embedder threads, since there is no API to signal "I'm done using the VM in this thread", this means we leak the (small) Thread structure.

For our own ThreadPool threads, we explicitly clean up.

BUG=23153
R=iposva@google.com

Review URL: https://codereview.chromium.org//1136143003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45810 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-15 12:48:49 +00:00
koda@google.com f4419287aa Prepares for multiple threads by further decoupling Thread from Isolate.
- Replace Isolate::SetCurrent with more explicit Thread::Enter/ExitIsolate.
- Lazily initialize Thread instances when entering an isolate, to avoid new API calls for embedders.

R=asiva@google.com

Review URL: https://codereview.chromium.org//1041523002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44835 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-01 17:48:11 +00:00
koda@google.com 0311c0eac9 Revert "Eliminate fake-Isolate workaround from concurrent sweeper."
The ARM simulator still needs a current isolate for its atomics.

TBR=iposva@google.com

Review URL: https://codereview.chromium.org//1027243003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44637 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-23 17:17:41 +00:00
koda@google.com b7e1dcac19 Eliminate fake-Isolate workaround from concurrent sweeper.
Add RawObject::Size(ClassTable*) to avoid remaning calls to Isolate::Current.

R=iposva@google.com

Review URL: https://codereview.chromium.org//1024063003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44611 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-20 20:37:38 +00:00
koda@google.com 600cd31660 Distinguish between initialization and updates to object fields. Currently only for DEBUG mode verification, but will be needed for deletion barrier.
Split up initialization flag in StoreInstanceFieldInstr for needed more precise semantics.

Zap swept old space with same value as uninitialized new in debug mode.

R=fschneider@google.com

Review URL: https://codereview.chromium.org//836593002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@42717 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-08 20:45:39 +00:00
iposva@google.com 1cae9b9c40 - Fine grain locking of free list when sweeping concurrently.
Review URL: https://codereview.chromium.org//649743002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41049 260f80e4-7a28-3924-810f-c04153c831b5
2014-10-10 19:44:41 +00:00
koda@google.com e1e6e676ff Lazy walkability of old-space bump allocation block.
Do not write a freelist-element header into remainder on every allocation.

Add ExclusivePageIterator that locks and ensures walkability, and reduces code duplication.

R=iposva@google.com

Review URL: https://codereview.chromium.org//571133002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40505 260f80e4-7a28-3924-810f-c04153c831b5
2014-09-19 17:25:13 +00:00
iposva@google.com 2ee3263277 - Add and enable concurrent sweeper.
- Keep separate lists for normal sized executable and data pages.

R=koda@google.com

Review URL: https://codereview.chromium.org//503363005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39593 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-27 13:37:55 +00:00
iposva@google.com 131a381020 - Stop-the-world sweep uses pre-locked free list access.
Review URL: https://codereview.chromium.org//488943002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39399 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-20 07:11:17 +00:00
koda@google.com 6c4eff32c9 If a large object is truncated, also truncate the page.
If GC sweeper finds a truncated large object, the page is shrunk to fit.

Allows reclaiming memory when a large string is externalized.

R=iposva@google.com

Review URL: https://codereview.chromium.org//355123002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37842 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-30 22:59:07 +00:00
koda@google.com b23b4ddd52 Verify that GC can handle trailing fillers in large pages.
Assert that filler objects created by String::MakeExternal and Array::MakeArray in large pages are never marked.

Add unit test that exercises the verification code.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org//344913003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37577 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-22 00:49:41 +00:00
iposva@google.com 69fcc15576 - Account for live size in marker.
R=koda@google.com

Review URL: https://codereview.chromium.org//253493002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@35413 260f80e4-7a28-3924-810f-c04153c831b5
2014-04-24 23:20:48 +00:00
iposva@google.com f2cfdc25d0 - Disassociate old page size from new allocatable size.
- Have a different cutoff for large page allocations
  and default old page size.
- Do not align old pages to old page size.
- Do not track used space during marking.

Review URL: https://codereview.chromium.org//14190014

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@22064 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-26 06:57:29 +00:00
iposva@google.com 6c4ac09cb9 - Remove heap tracing.
Review URL: https://codereview.chromium.org//14179015

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@21844 260f80e4-7a28-3924-810f-c04153c831b5
2013-04-22 21:43:57 +00:00
cshapiro@google.com 49f6f9f36d Merge the Merlin heap tracing to top-of-trunk.
Review URL: https://codereview.chromium.org//11428067

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16199 260f80e4-7a28-3924-810f-c04153c831b5
2012-12-15 19:58:45 +00:00
iposva@google.com dc2c8b3707 - Consolidate code into the old generation.
- Record pointers between code objects.
- Collect unreferenced code objects.
Review URL: https://codereview.chromium.org//11265026

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14113 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-25 23:46:01 +00:00
iposva@google.com 5e9f303d5d - Do not bump allocate in old-space pages. Always use
the freelist in preparation for chunked allocation.
Review URL: https://codereview.chromium.org//11186013

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@13792 260f80e4-7a28-3924-810f-c04153c831b5
2012-10-18 17:40:12 +00:00
iposva@google.com 0d25bce528 - Trigger old-gen GCs when needed.
- Sweep large pages.
- Handle free list elements when calculating sizes.
Review URL: http://codereview.chromium.org//8996011

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2593 260f80e4-7a28-3924-810f-c04153c831b5
2011-12-19 19:29:10 +00:00
iposva@google.com 5e1e9534db - Implement the old sweeper.
Review URL: http://codereview.chromium.org//8898034

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2485 260f80e4-7a28-3924-810f-c04153c831b5
2011-12-15 22:37:35 +00:00