Commit Graph

206 Commits

Author SHA1 Message Date
Zach Anderson b0f622a143 [vm] Fix GC assert
Saw this assert hit on the bots, so switching back to max with 0.

Change-Id: Idafcd55d99dd441131dd3ac9aeb57ec102f28569
Reviewed-on: https://dart-review.googlesource.com/58323
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-06-04 19:07:39 +00:00
Zach Anderson 0bec11a4f2 [vm] Control growth of external allocations
Previously, GC would only be triggered by external allocations on
reaching a limit indicated by a flag. This limit was too large
and not set thoughtfully by anyone.

This CL triggers GC when external allocations in old gen grow
larger than some limit based on results of previous GC, similar
to how Dart heap growth triggers GC. GC is triggered for new gen
when external allocations reach 4x the current new gen
capacity.

FL-61

Change-Id: I1d4da467bc2aab64058f25296aefdd73eebc38e6
Reviewed-on: https://dart-review.googlesource.com/58100
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
2018-06-04 17:24:18 +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
Ryan Macnak 670038cd5b [vm, gc] Remove time component from growth policy.
Instead, rely on idle GC to avoid waste.

Change-Id: I071da3c9e9c4dbb52a6eb732b5291e707e4bb379
Reviewed-on: https://dart-review.googlesource.com/35541
Reviewed-by: Erik Corry <erikcorry@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-01-18 18:17:15 +00:00
Ryan Macnak 15082ccbcd [vm, gc] Discount two pages when calculating if a heap is fragmented.
The most recently allocated data and code pages may be partially used without indicating fragmentation. Discount two pages when calculating the usage ratio to avoid pathological detection of "fragmentation" in small heaps.

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: Ib3168fbdd6393c98c8c1cf88937a345339fad196
Reviewed-on: https://dart-review.googlesource.com/34500
Reviewed-by: Erik Corry <erikcorry@google.com>
2018-01-16 21:24:35 +00:00
Ryan Macnak c3fc0dbb0d [vm, gc] Extend idle GC logic to compaction.
Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: I49509c139ad1ad809dbf626492882c7fd29aff5c
Reviewed-on: https://dart-review.googlesource.com/34080
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Erik Corry <erikcorry@google.com>
2018-01-11 19:44:30 +00:00
Ryan Macnak e14b3a86f0 Report errno on mprotect failure.
Bug: b/70275153
Change-Id: I81b868b25428b39835935846ba2c9f9f67b3e84d
Reviewed-on: https://dart-review.googlesource.com/33665
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-01-10 01:37:49 +00:00
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 62ae8cda0a Parallel compaction.
Divide the heap by pages into k tasks. Use ThreadBarrier to ensure
planning -> sliding and non-stack forwarding -> stack forwarding.

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: I2c9fcec0a0794bfea96ca1a0fb509a9f93242b65
Reviewed-on: https://dart-review.googlesource.com/29444
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Erik Corry <erikcorry@google.com>
2017-12-15 01:38:42 +00:00
Ryan Macnak 996e9e9a6a Remove image pages checks made unnecessary by keeping a separate image page list.
Change-Id: I0180f2083d49e563b1913465f1c4a3598ad2ed3e
Reviewed-on: https://dart-review.googlesource.com/29001
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2017-12-13 18:09:05 +00:00
Ryan Macnak ac966ba4c3 Split planning and sliding in the compactor.
With forwarding blocks fully computed before sliding, we can update pointers as we slide.

Towards parallel compaction.

Reduces compaction time in dart2js hello (without marking):
33036 us -> 30685 us (-7.1%) N=10

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: Ied800ea60233bc8a87880f92092ee078a95be2e5
Reviewed-on: https://dart-review.googlesource.com/27781
Reviewed-by: Erik Corry <erikcorry@google.com>
2017-12-11 21:16:52 +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 104336699d Make the compactor invokable from Observatory's heap map page.
Add GCReason to timeline events.

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: Ie4514ca3fb0fa6197a895e54618dfcba1dfe3a8d
Reviewed-on: https://dart-review.googlesource.com/25120
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2017-11-30 22:55:56 +00:00
Ryan Macnak e4d01aa323 [vm, gc] Remove the evacuating compactor.
This was a temporary measure to verify the VM could handle moving old-space objects before we had the sliding compactor.

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: I4ffec413918481c0af4828d126930455f620935d
Reviewed-on: https://dart-review.googlesource.com/22663
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Erik Corry <erikcorry@google.com>
2017-11-22 18:12:02 +00:00
Ryan Macnak 204f7f6ffa [vm] Visit DBC interpreter's pp and argdesc slot.
Enables compaction with DBC.

dart-simdbc-checked linux-armvhf (closest to Flutter's usage):
ParticleSystemPaint (Odroid-C2)  -3.454% (-0.3 noise)
ParticleSystemUpdate (Odroid-C2) -9.009% (-0.2 noise)
DeltaBlue (Odroid-C2)            -1.655% (-0.1 noise)
DeltaBlueClosures (Odroid-C2)    -2.415% (-0.0 noise)
StarryStrings (Odroid-C2)        -2.445% (-0.0 noise)
Richards (Odroid-C2)            -0.9325% (-0.0 noise)
Tracer (Odroid-C2)              -0.6846% (-0.0 noise)

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: Iff7dfad25db0a1e12fd02157c7c4f970ea88779d
Reviewed-on: https://dart-review.googlesource.com/16689
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2017-11-15 22:07:14 +00:00
Ryan Macnak a4497945b6 [vm, gc] Handle image pages in the sliding compactor via range checks.
This allows running the sliding compactor for AOT and App-JIT.

The loaders on Mac and Linux do not respect alignments greater than the virtual page size, and we must use the system loader on iOS to get the executable image page. In the future, we might try to organize instructions for AOT/App-JIT off of an image page.

dart2js hello compaction time (without marking):
30249 us -> 31351 us (+3.6%) N=10

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: I6e9ffd04df30ef0a09f1b123ae0c148f11448627
Reviewed-on: https://dart-review.googlesource.com/19140
Reviewed-by: Erik Corry <erikcorry@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2017-11-08 19:22:38 +00:00
Ryan Macnak 32a02404c9 [vm, gc] Bitvector-based sliding compactor.
With the current block size, this reduces space for forwarding information from two words per moved object to two words per (kObjectAlignment * kBitsPerWord) bytes of heap (1.6% on 64-bit, 3.1% on 32-bit).

dart2js compiling dart2js:
Compactor/Sweeper             Runtime  Max RSS
Sliding (binary search table) 105   s  1.085 GB
Sliding (bitvector)            57.8 s  998.566 MB
Evacuating                     66.2 s  1.714 GB
Concurrent sweep               53.8 s  1.183 GB
Blocking sweep                 55.0 s  1.181 GB

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: Ia6eec4f0162c3959154c5155df24cc06694ecac7
Reviewed-on: https://dart-review.googlesource.com/17721
Reviewed-by: Erik Corry <erikcorry@google.com>
2017-11-03 19:38:55 +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 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
Ryan Macnak 6d3549ed56 Reapply "[vm] Add a simple compactor."
This is a subset of the previous attempt; the other part was fixed in 2994f60298.

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: Ica22eb0d81e75378f4b528f8ca77504ef3e09c84
Reviewed-on: https://dart-review.googlesource.com/15769
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2017-10-23 18:51:47 +00:00
Ryan Macnak 80e3fed6df Revert "Reapply "[vm] Add a simple compactor.""
This reverts commit 6451ce078f.

Reason for revert: Crashes on some reload bots

Original change's description:
> Reapply "[vm] Add a simple compactor."
> 
>  - Update capacity when freeing pages to prevent confusing the growth policy.
>  - Test with fragmentation_test instead of mirrors_reader_test to fit within time limits on the reload and opt-counter-threshold bots.
> 
> Bug: https://github.com/dart-lang/sdk/issues/30978
> Change-Id: I50488230bf5a0ed3b663ce555ff6ed62f2e5acca
> Reviewed-on: https://dart-review.googlesource.com/15011
> Reviewed-by: Erik Corry <erikcorry@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

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

Change-Id: I93e57d4b0b71ce87f7ca04cd35a87d6205864bba
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/30978
Reviewed-on: https://dart-review.googlesource.com/15300
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2017-10-19 19:51:05 +00:00
Ryan Macnak 6451ce078f Reapply "[vm] Add a simple compactor."
- Update capacity when freeing pages to prevent confusing the growth policy.
 - Test with fragmentation_test instead of mirrors_reader_test to fit within time limits on the reload and opt-counter-threshold bots.

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: I50488230bf5a0ed3b663ce555ff6ed62f2e5acca
Reviewed-on: https://dart-review.googlesource.com/15011
Reviewed-by: Erik Corry <erikcorry@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2017-10-19 18:08:58 +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 e0c09211fc Revert "[vm] Add a simple compactor."
This reverts commit 5bdffcd32e.

Reason for revert: Failures on DBC, timeouts on hot reload and opt counter stress bots.

Original change's description:
> [vm] Add a simple compactor.
> 
> The compactor copies all live objects in old space to fresh pages, places forwarding pointers in the old objects, forwards all the pointers, then frees the old pages. This has a high space overhead. It is not meant for use in production, but meant to test that the VM is properly set up to handle old-space objects moving.
> 
> Large page objects and instruction objects are not moved.
> 
> Bug: https://github.com/dart-lang/sdk/issues/30978
> Change-Id: Ia42683fd5e27a33702aa5e83bece803a8b005a4b
> Reviewed-on: https://dart-review.googlesource.com/13624
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Zach Anderson <zra@google.com>
> Reviewed-by: Erik Corry <erikcorry@google.com>

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

Change-Id: I4fda673561532b604d97b9b02189c030844d969d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/30978
Reviewed-on: https://dart-review.googlesource.com/14680
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2017-10-17 21:57:19 +00:00
Ryan Macnak 5bdffcd32e [vm] Add a simple compactor.
The compactor copies all live objects in old space to fresh pages, places forwarding pointers in the old objects, forwards all the pointers, then frees the old pages. This has a high space overhead. It is not meant for use in production, but meant to test that the VM is properly set up to handle old-space objects moving.

Large page objects and instruction objects are not moved.

Bug: https://github.com/dart-lang/sdk/issues/30978
Change-Id: Ia42683fd5e27a33702aa5e83bece803a8b005a4b
Reviewed-on: https://dart-review.googlesource.com/13624
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Erik Corry <erikcorry@google.com>
2017-10-17 20:44:02 +00:00
Ryan Macnak 637a9f873b Initial idle mark-sweep.
Estimate the speed of mark-sweep (or just marking if concurrent sweep is enabled) and use it to decide if a mark-sweep would complete within an idle period.

Start considering idle mark-sweeps when old-space has grown half way to the size that will trigger a blocking GC.

Change-Id: Id03e443365c2f965b41cbc1b7787916edbe7f48f
Reviewed-on: https://dart-review.googlesource.com/3423
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2017-09-25 19:59:47 +00:00
Ryan Macnak b0f203db19 [vm-service] Include external sizes in the allocation table.
Bug: https://github.com/dart-lang/sdk/issues/30380
Change-Id: Ieec5adf13548b73bac886816d4a2174de7585880
Reviewed-on: https://dart-review.googlesource.com/7685
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Todd Turnidge <turnidge@google.com>
2017-09-25 18:33:07 +00:00
Ryan Macnak 0eb98b32b7 [vm] Remove dead flag --heap_growth_rate.
Change-Id: Ie3e9a8025786aacb83d6bb89b72ee38509943d31
Reviewed-on: https://dart-review.googlesource.com/3304
Reviewed-by: Siva Annamalai <asiva@google.com>
2017-09-05 18:23:25 +00:00
Erik Corry aa1a9ef686 [VM-GC] Add a flag to abort on allocation failure
This is added to help investigate memory usage. By setting an
old-space limit with --old-gen-heap-size and setting the new
--abort-on-oom it is possible to test whether a program can
run in a certain size. Using binary search one can determine
what the minimum size is. Without this flag the VM will slow
down to a crawl when it tries to exceed its heap limit.
R=vegorov@google.com
BUG=

Review-Url: https://codereview.chromium.org/2995063002 .
2017-09-04 12:32:30 +02:00
Ryan Macnak a914c24b43 [vm] Rename "grow_ratio" to "grow_pages" since it is an amount, not a ratio.
R=asiva@google.com

Review-Url: https://codereview.chromium.org/3009053002 .
2017-09-01 17:31:39 -07:00
Ryan Macnak 14b5782544 Remove GC prologue and epilogue callbacks.
These should have been removed along with weak reference set support in 4992bc72a0 since they serve no other purpose.

Review-Url: https://codereview.chromium.org/3001343002 .
2017-08-22 11:19:54 -07: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
Ryan Macnak 466385ceb6 [vm, gc] Require a safepoint for heap iteration.
Assert a safepoint operation can only be started from a thread in the VM state. Fix several unit tests missing a native-to-vm transition.

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

Review-Url: https://codereview.chromium.org/2995543004 .
2017-08-07 17:51:25 -07:00
Alexander Markov 69817eea18 [vm] Revert changes related to triggering the 1st GC
This is the partial revert of the
8d6bc876f0

That CL caused noticeable slowdown of gen_snapshot on Mac and Windows.
Reverting this part of the CL fixes regression.

Closes https://github.com/dart-lang/sdk/issues/30317

R=zra@google.com

Review-Url: https://codereview.chromium.org/2998473002 .
2017-08-04 13:31:59 -07:00
Zachary Anderson 8d6bc876f0 Reland "Remove fields from Isolate in Product mode"
In my reordering of the fields in Isolate, I omitted the initialization
of a few fields in the constroctor. This CL will reland the change with
the initialization added back.

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

Review-Url: https://codereview.chromium.org/2983403002 .
2017-07-25 13:24:30 -07:00
Zachary Anderson 211604d7a0 Revert "Remove fields from Isolate in Product mode"
This reverts commit 13558442ab.

The above change caused a timeout in a vm test:

FAILED: none-vm-checked release_x64 vm/cc/SafepointTestDart
Expected: Pass
Actual: Timeout
CommandOutput[run_vm_unittest]:
diagnostics: Process list including children: [28397]
    Trying to capture stack trace for pid 28397
    PID 28397 - process
    TID 28397:
    #0  0x00007efedf216404 pthread_cond_wait@@GLIBC_2.3.2
    #1  0x0000000002b9a315 dart::Monitor::WaitMicros(long)
    #2  0x0000000002af3496 dart::MonitorLocker::WaitWithSafepointCheck(dart::Thread*, long)
    #3  0x0000000002a8724d dart::Heap::AllocateOld(long, dart::HeapPage::PageType)
    #4  0x0000000002b07de3 dart::Object::Allocate(long, long, dart::Heap::Space)
    #5  0x0000000002b26eab dart::UnresolvedClass::New(dart::Object const&, dart::String const&, dart::TokenPosition)
    #6  0x0000000002be6358 dart::Parser::ParseType(dart::ClassFinalizer::FinalizationKind, bool, bool, dart::LibraryPrefix*)
    #7  0x0000000002ba9cc4 dart::Parser::ParseNewOperator(dart::Token::Kind)
    #8  0x0000000002bac7dc dart::Parser::ParsePrimary()
    #9  0x0000000002be19c1 dart::Parser::ParsePostfixExpr()
    #10 0x0000000002bdf1c4 dart::Parser::ParseUnaryExpr()
    #11 0x0000000002bb618c dart::Parser::ParseBinaryExpr(int)
    #12 0x0000000002bb869f dart::Parser::ParseConditionalExpr()
    #13 0x0000000002bae224 dart::Parser::ParseExpr(bool, bool)
    #14 0x0000000002bbeb79 dart::Parser::ParseAwaitableExpr(bool, bool, dart::SequenceNode**)
    #15 0x0000000002bd5273 dart::Parser::ParseStatement()
    #16 0x0000000002bbcce0 dart::Parser::ParseStatementSequence()
    #17 0x0000000002ba64e8 dart::Parser::ParseFunc(dart::Function const&, bool)
    #18 0x0000000002ba3e31 dart::Parser::ParseFunction(dart::ParsedFunction*)
    #19 0x00000000029e0725 dart::DartCompilationPipeline::ParseFunction(dart::ParsedFunction*)
    #20 0x00000000029e4898 dart::CompileFunctionHelper(dart::CompilationPipeline*, dart::Function const&, bool, long)
    #21 0x00000000029e5716 dart::Compiler::CompileOptimizedFunction(dart::Thread*, dart::Function const&, long)
    #22 0x0000000002c8d3a4 dart::DRT_StackOverflow(dart::NativeArguments)
    #23 0x00007efedf6ad61b
    TID 28421:
    #0  0x00007efedf2167be pthread_cond_timedwait@@GLIBC_2.3.2
    #1  0x0000000002b9a2ff dart::Monitor::WaitMicros(long)
    #2  0x0000000002cc6f8f dart::ThreadInterrupter::ThreadMain(unsigned long)
    #3  0x0000000002b999d9 dart::ThreadStart(void*)
    #4  0x00007efedf212184 start_thread
    #5  0x00007efede51737d __clone
    TID 28430:
    #0  0x00007efedf216404 pthread_cond_wait@@GLIBC_2.3.2
    #1  0x0000000002b9a315 dart::Monitor::WaitMicros(long)
    #2  0x0000000002af3496 dart::MonitorLocker::WaitWithSafepointCheck(dart::Thread*, long)
    #3  0x0000000002a8789e dart::HeapIterationScope::HeapIterationScope(bool)
    #4  0x0000000002ad4966 dart::Isolate::IterateObjectPointers(dart::ObjectPointerVisitor*, bool)
    #5  0x00000000027ed02a dart::SafepointTestTask::Run()
    #6  0x0000000002cc7cbd dart::ThreadPool::Worker::Loop()
    #7  0x0000000002cc7b6a dart::ThreadPool::Worker::Main(unsigned long)
    #8  0x0000000002b999d9 dart::ThreadStart(void*)
    #9  0x00007efedf212184 start_thread
    #10 0x00007efede51737d __clone
    TID 28431:
    #0  0x00007efedf216404 pthread_cond_wait@@GLIBC_2.3.2
    #1  0x0000000002b9a315 dart::Monitor::WaitMicros(long)
    #2  0x0000000002ad66fa dart::Isolate::ScheduleThread(bool, bool)
    #3  0x0000000002cc53ea dart::Thread::EnterIsolateAsHelper(dart::Isolate*, dart::Thread::TaskKind, bool)
    #4  0x0000000002a86317 dart::SweeperTask::Run()
    #5  0x0000000002cc7cbd dart::ThreadPool::Worker::Loop()
    #6  0x0000000002cc7b6a dart::ThreadPool::Worker::Main(unsigned long)
    #7  0x0000000002b999d9 dart::ThreadStart(void*)
    #8  0x00007efedf212184 start_thread
    #9  0x00007efede51737d __clone
    TID 28444:
    #0  0x00007efedf216404 pthread_cond_wait@@GLIBC_2.3.2
    #1  0x0000000002b9a315 dart::Monitor::WaitMicros(long)
    #2  0x0000000002af3496 dart::MonitorLocker::WaitWithSafepointCheck(dart::Thread*, long)
    #3  0x0000000002a8724d dart::Heap::AllocateOld(long, dart::HeapPage::PageType)
    #4  0x0000000002b07de3 dart::Object::Allocate(long, long, dart::Heap::Space)
    #5  0x0000000002b26eab dart::UnresolvedClass::New(dart::Object const&, dart::String const&, dart::TokenPosition)
    #6  0x0000000002be6358 dart::Parser::ParseType(dart::ClassFinalizer::FinalizationKind, bool, bool, dart::LibraryPrefix*)
    #7  0x0000000002bb19bb dart::Parser::ParseTypeOrFunctionType(bool, dart::ClassFinalizer::FinalizationKind)
    #8  0x0000000002bb204c dart::Parser::ParseFormalParameter(bool, bool, dart::ParamList*)
    #9  0x0000000002bb43b3 dart::Parser::ParseFormalParameters(bool, bool, bool, dart::ParamList*)
    #10 0x0000000002ba368b dart::Parser::ParseFormalParameterList(bool, bool, bool, dart::ParamList*)
    #11 0x0000000002ba5a8f dart::Parser::ParseFunc(dart::Function const&, bool)
    #12 0x0000000002ba3e31 dart::Parser::ParseFunction(dart::ParsedFunction*)
    #13 0x00000000029e0725 dart::DartCompilationPipeline::ParseFunction(dart::ParsedFunction*)
    #14 0x00000000029e4898 dart::CompileFunctionHelper(dart::CompilationPipeline*, dart::Function const&, bool, long)
    #15 0x00000000029e5716 dart::Compiler::CompileOptimizedFunction(dart::Thread*, dart::Function const&, long)
    #16 0x00000000029e7036 dart::BackgroundCompiler::Run()
    #17 0x0000000002cc7cbd dart::ThreadPool::Worker::Loop()
    #18 0x0000000002cc7b6a dart::ThreadPool::Worker::Main(unsigned long)
    #19 0x0000000002b999d9 dart::ThreadStart(void*)
    #20 0x00007efedf212184 start_thread
    #21 0x00007efede51737d __clone
Review-Url: https://codereview.chromium.org/2988703002 .
2017-07-24 14:17:53 -07:00
Zachary Anderson 13558442ab Remove fields from Isolate in Product mode
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2984883002 .
2017-07-24 13:22:44 -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
Zachary Anderson 1393e84863 [Fuchsia] Give VMOs names
This CL assigns names to vmos formatted as "isolate space type" where
isolate is the name of the isolate, space is "oldspace" or "newspace",
and type is "code" or "data".

R=asiva@google.com

Review-Url: https://codereview.chromium.org/2929203002 .
2017-06-09 15:33:18 -07:00
Ryan Macnak 76df24b076 CoreJIT snapshots without training.
Only include OSR and field guards in the features descriptor for JIT code to avoid gen_snapshot and dart having different default values.

Disabled since core snapshots with code break tests with non-default flags for type checks, assertions, strict errors, OSR, or field guards.

R=zra@google.com

Review-Url: https://codereview.chromium.org/2902313004 .
2017-05-31 13:49:12 -07:00
Erik Corry 2a9cb6bbb7 Some fixes to GC heuristics.
The loop intended to do a binary search for the best heap growth size
did not have any variables in it that changed the decision, so it would
make the same decision (up or down) every time around the loop.

R=kasperl@google.com, vegorov@google.com
BUG=

Review-Url: https://codereview.chromium.org/2829853007 .
2017-04-27 15:04:35 +02:00
Erik Corry c5ffe74881 DartVM: Fix rounding error causing linear instead of geometric heap growth
R=kustermann@google.com
BUG=

Review-Url: https://codereview.chromium.org/2790673004 .
2017-03-31 11:21:33 +02:00
Erik Corry fc2fcf9bc8 Add more safe points in compiler.
The Scavenge (young-gen) GCs on the main thread have to wait for other
threads to check in at a safe point. We were seeing big waits here, often
20ms, occasionally up to 180ms where the main thread is idling, waiting
for the optimizing compiler.  By adding more safe points the wait is
reduced and is now rarely over 10ms, often under 1ms.

This also changes the --verbose-gc output to be better aligned with the
column headings, and to add the time needed to get to
the safe point to the output, eg:

[ GC(784211551): Scavenge(new space), 18, 2.209, 76.009, 32768, 0, 32768, 32768, 0, 0, 144912, 154425, 152064, 154880, 0, 0, 46.984, 2.752, 7.407, 18.657, 0.033, 5421, 0, 0, 0, ]
                                                 ^^^^^^ Scavenge time                                                        ^^^^^^  safe point time.

R=vegorov@google.com
BUG=

Review-Url: https://codereview.chromium.org/2771013002 .
2017-03-31 11:19:46 +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
Martin Kustermann a9fbe2004d VM: Tell lsan about mmap()ed regions used for our heap
The mmap()ed pages hold pointers to `VirtualMemory` objects. So we tell
lsan that the mmap()ed regions are roots.

R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2646363005 .
2017-01-24 12:47:36 +01:00
Ryan Macnak 4dc2677859 Fix race in deletion of native message handlers (fixes #28484).
Fix leak of snapshot HeapPages.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2650583006 .
2017-01-23 19:45:59 -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
Siva Annamalai 793e4b89e6 1. Added new flag verify_gc_contains and moved all the asserts that do a
heap contains verification under it. This flag is turned on automatically
   when verify_before_gc, verify_after_gc or verify_on_transition is
   specified. This should speed up the debug builds on the bot.
   A dart2js build line for instance goes from 2357.526 seconds
   to 184.22 seconds

2. Verify heap on shutdown only under the flag verify_on_transition.

R=fschneider@google.com

Review-Url: https://codereview.chromium.org/2626343002 .
2017-01-12 16:03:22 -08:00
Siva Annamalai 90750551f2 1. Avoid potential dead lock due to lock-order-inversion
WARNING: ThreadSanitizer: lock-order-inversion (potential deadlock) (pid=3448)
  Cycle in lock order graph: M206 (0x7b18000006c0) => M202 (0x7b0c00000ff0) => M206

  Mutex M202 acquired here while holding mutex M206 in thread T5:
    #0 pthread_mutex_lock <null> (dart+0x00000058e8ee)
    #1 dart::Mutex::Lock() /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/os_thread_linux.cc:274 (dart+0x0000009bd79b)
    #2 MutexLocker /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/lockers.h:61 (dart+0x00000074a007)
    #3 dart::FreeList::TryAllocate(long, bool) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/freelist.cc:65 (dart+0x000000872d2c)
    #4 dart::PageSpace::TryAllocateInternal(long, dart::HeapPage::PageType, dart::PageSpace::GrowthPolicy, bool, bool) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/pages.cc:392 (dart+0x0000009c0180)
    #5 dart::PageSpace::TryAllocate(long, dart::HeapPage::PageType, dart::PageSpace::GrowthPolicy) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/pages.h:195 (dart+0x000000877158)
    #6 dart::Heap::AllocateOld(long, dart::HeapPage::PageType) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/heap.cc:92 (dart+0x000000876f45)
    #7 dart::Heap::Allocate(long, dart::Heap::Space) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/heap.h:67 (dart+0x00000092ab33)

  Mutex M206 acquired here while holding mutex M202 in thread T5:
    #0 pthread_mutex_lock <null> (dart+0x00000058e8ee)
    #1 dart::Monitor::Enter() /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/os_thread_linux.cc:380 (dart+0x0000009be02b)
    #2 MonitorLocker /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/lockers.h:139 (dart+0x000000722f17)
    #3 SweeperTask /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/gc_sweeper.cc:112 (dart+0x000000b3391f)
    #4 dart::GCSweeper::SweepConcurrent(dart::Isolate*, dart::HeapPage*, dart::HeapPage*, dart::FreeList*) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/gc_sweeper.cc:171 (dart+0x000000b336e6)
    #5 dart::PageSpace::MarkSweep(bool) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/pages.cc:952 (dart+0x0000009c1f6b)
    #6 dart::Heap::CollectOldSpaceGarbage(dart::Thread*, dart::Heap::ApiCallbacks, dart::Heap::GCReason) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/heap.cc:401 (dart+0x000000878e11)
    #7 dart::Heap::CollectAllGarbage() /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/heap.cc:444 (dart+0x000000877244)
    #8 dart::Heap::AllocateOld(long, dart::HeapPage::PageType) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/heap.cc:102 (dart+0x000000876fac)
    #9 dart::Heap::Allocate(long, dart::Heap::Space) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/heap.h:67 (dart+0x00000092ab33)

2. Remove unsafe access to usage data for an insignificant ASSERT.
WARNING: ThreadSanitizer: data race (pid=7617)
  Atomic write of size 8 at 0x7b840000fdf0 by thread T4:
    #0 __tsan_atomic64_fetch_add <null> (dart+0x0000005b59e7)
    #1 dart::AtomicOperations::IncrementBy(long*, long) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/atomic_linux.h:30 (dart+0x00000076a235)
    #2 dart::PageSpace::TryAllocateInternal(long, dart::HeapPage::PageType, dart::PageSpace::GrowthPolicy, bool, bool) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/pages.cc:398 (dart+0x0000009c0233)
    #3 dart::PageSpace::TryAllocate(long, dart::HeapPage::PageType, dart::PageSpace::GrowthPolicy) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/pages.h:195 (dart+0x000000877158)
    #4 dart::Heap::AllocateOld(long, dart::HeapPage::PageType) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/heap.cc:82 (dart+0x000000876eec)
    #5 dart::Heap::Allocate(long, dart::Heap::Space) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/heap.h:67 (dart+0x00000092ab33)
    #6 dart::Object::Allocate(long, long, dart::Heap::Space) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/object.cc:1866 (dart+0x00000092dd92)

  Previous read of size 8 at 0x7b840000fdf0 by thread T3:
    #0 dart::PageSpace::TryAllocateInternal(long, dart::HeapPage::PageType, dart::PageSpace::GrowthPolicy, bool, bool) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/pages.cc:426 (dart+0x0000009c026b)
    #1 dart::PageSpace::TryAllocate(long, dart::HeapPage::PageType, dart::PageSpace::GrowthPolicy) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/pages.h:195 (dart+0x000000877158)
    #2 dart::Heap::AllocateOld(long, dart::HeapPage::PageType) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/heap.cc:82 (dart+0x000000876eec)
    #3 dart::Heap::Allocate(long, dart::Heap::Space) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/heap.h:67 (dart+0x00000092ab33)
    #4 dart::Object::Allocate(long, long, dart::Heap::Space) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/object.cc:1866 (dart+0x00000092dd92)
    #5 dart::StackMap::New(long, dart::BitmapBuilder*, long) /usr/local/google/home/asiva/workspace/dart-ws3/sdk/out/DebugX64/../../runtime/vm/object.cc:12164 (dart+0x00000096796a)

R=vegorov@google.com

Review-Url: https://codereview.chromium.org/2609643002 .
2017-01-05 11:27:10 -08:00