[heap] Small refactoring to tidy up heap.

Bug: v8:8015
Change-Id: I6b1283f893944ca45ff7816d51e0c7fb26c8a8e1
Reviewed-on: https://chromium-review.googlesource.com/1209785
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Florian Sattler <sattlerf@google.com>
Cr-Commit-Position: refs/heads/master@{#55693}
This commit is contained in:
Florian Sattler 2018-09-06 16:29:22 +02:00 committed by Commit Bot
parent 8c1e038322
commit 5f0e0f63b7
5 changed files with 9 additions and 8 deletions

View File

@ -2488,8 +2488,8 @@ void Heap::ProcessWeakListRoots(WeakObjectRetainer* retainer) {
set_allocation_sites_list(retainer->RetainAs(allocation_sites_list()));
}
void Heap::ForeachAllocationSite(Object* list,
std::function<void(AllocationSite*)> visitor) {
void Heap::ForeachAllocationSite(
Object* list, const std::function<void(AllocationSite*)>& visitor) {
DisallowHeapAllocation disallow_heap_allocation;
Object* current = list;
while (current->IsAllocationSite()) {

View File

@ -567,8 +567,8 @@ class Heap {
// Traverse all the allocaions_sites [nested_site and weak_next] in the list
// and foreach call the visitor
void ForeachAllocationSite(Object* list,
std::function<void(AllocationSite*)> visitor);
void ForeachAllocationSite(
Object* list, const std::function<void(AllocationSite*)>& visitor);
// Number of mark-sweeps.
int ms_count() const { return ms_count_; }

View File

@ -58,7 +58,7 @@ ItemParallelJob::~ItemParallelJob() {
}
}
void ItemParallelJob::Run(std::shared_ptr<Counters> async_counters) {
void ItemParallelJob::Run(const std::shared_ptr<Counters>& async_counters) {
DCHECK_GT(tasks_.size(), 0);
const size_t num_items = items_.size();
const size_t num_tasks = tasks_.size();

View File

@ -137,7 +137,7 @@ class V8_EXPORT_PRIVATE ItemParallelJob {
// Runs this job. Reporting metrics in a thread-safe manner to
// |async_counters|.
void Run(std::shared_ptr<Counters> async_counters);
void Run(const std::shared_ptr<Counters>& async_counters);
private:
std::vector<Item*> items_;

View File

@ -3426,8 +3426,9 @@ void MarkCompactCollector::MarkingWorklist::PrintWorklist(
count[obj->map()->instance_type()]++;
});
std::vector<std::pair<int, InstanceType>> rank;
for (auto i : count) {
rank.push_back(std::make_pair(i.second, i.first));
rank.reserve(count.size());
for (const auto& i : count) {
rank.emplace_back(i.second, i.first);
}
std::map<InstanceType, std::string> instance_type_name;
#define INSTANCE_TYPE_NAME(name) instance_type_name[name] = #name;