From 6546bfe316d29a713c432dfc4aceb8ef676c099b Mon Sep 17 00:00:00 2001 From: Michael Lippautz Date: Mon, 15 May 2017 14:43:00 +0200 Subject: [PATCH] [heap] Factor out NumberOfAvailableCores Bug: chromium:651354 Change-Id: Ie940c8715a33e5fc8e8859c4660ab14ecc6f9233 Reviewed-on: https://chromium-review.googlesource.com/505488 Reviewed-by: Hannes Payer Commit-Queue: Michael Lippautz Cr-Commit-Position: refs/heads/master@{#45302} --- src/heap/mark-compact.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index 71cb4a1925..cec2526312 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -335,20 +335,19 @@ class YoungGenerationEvacuationVerifier : public EvacuationVerifier { // MarkCompactCollectorBase, MinorMarkCompactCollector, MarkCompactCollector // ============================================================================= -int MarkCompactCollectorBase::NumberOfParallelCompactionTasks(int pages) { - if (!FLAG_parallel_compaction) return 1; - const int available_cores = Max( +static int NumberOfAvailableCores() { + return Max( 1, static_cast( V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads())); - return Min(available_cores, pages); +} + +int MarkCompactCollectorBase::NumberOfParallelCompactionTasks(int pages) { + return FLAG_parallel_compaction ? Min(NumberOfAvailableCores(), pages) : 1; } int MarkCompactCollectorBase::NumberOfPointerUpdateTasks(int pages) { - if (!FLAG_parallel_pointer_update) return 1; - const int available_cores = Max( - 1, static_cast( - V8::GetCurrentPlatform()->NumberOfAvailableBackgroundThreads())); - return Min(available_cores, pages); + return FLAG_parallel_pointer_update ? Min(NumberOfAvailableCores(), pages) + : 1; } MarkCompactCollector::MarkCompactCollector(Heap* heap)