Commit 5f0e0f63 authored by Florian Sattler's avatar Florian Sattler Committed by Commit Bot

[heap] Small refactoring to tidy up heap.

Bug: v8:8015
Change-Id: I6b1283f893944ca45ff7816d51e0c7fb26c8a8e1
Reviewed-on: https://chromium-review.googlesource.com/1209785Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Florian Sattler <sattlerf@google.com>
Cr-Commit-Position: refs/heads/master@{#55693}
parent 8c1e0383
...@@ -2488,8 +2488,8 @@ void Heap::ProcessWeakListRoots(WeakObjectRetainer* retainer) { ...@@ -2488,8 +2488,8 @@ void Heap::ProcessWeakListRoots(WeakObjectRetainer* retainer) {
set_allocation_sites_list(retainer->RetainAs(allocation_sites_list())); set_allocation_sites_list(retainer->RetainAs(allocation_sites_list()));
} }
void Heap::ForeachAllocationSite(Object* list, void Heap::ForeachAllocationSite(
std::function<void(AllocationSite*)> visitor) { Object* list, const std::function<void(AllocationSite*)>& visitor) {
DisallowHeapAllocation disallow_heap_allocation; DisallowHeapAllocation disallow_heap_allocation;
Object* current = list; Object* current = list;
while (current->IsAllocationSite()) { while (current->IsAllocationSite()) {
......
...@@ -567,8 +567,8 @@ class Heap { ...@@ -567,8 +567,8 @@ class Heap {
// Traverse all the allocaions_sites [nested_site and weak_next] in the list // Traverse all the allocaions_sites [nested_site and weak_next] in the list
// and foreach call the visitor // and foreach call the visitor
void ForeachAllocationSite(Object* list, void ForeachAllocationSite(
std::function<void(AllocationSite*)> visitor); Object* list, const std::function<void(AllocationSite*)>& visitor);
// Number of mark-sweeps. // Number of mark-sweeps.
int ms_count() const { return ms_count_; } int ms_count() const { return ms_count_; }
......
...@@ -58,7 +58,7 @@ ItemParallelJob::~ItemParallelJob() { ...@@ -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); DCHECK_GT(tasks_.size(), 0);
const size_t num_items = items_.size(); const size_t num_items = items_.size();
const size_t num_tasks = tasks_.size(); const size_t num_tasks = tasks_.size();
......
...@@ -137,7 +137,7 @@ class V8_EXPORT_PRIVATE ItemParallelJob { ...@@ -137,7 +137,7 @@ class V8_EXPORT_PRIVATE ItemParallelJob {
// Runs this job. Reporting metrics in a thread-safe manner to // Runs this job. Reporting metrics in a thread-safe manner to
// |async_counters|. // |async_counters|.
void Run(std::shared_ptr<Counters> async_counters); void Run(const std::shared_ptr<Counters>& async_counters);
private: private:
std::vector<Item*> items_; std::vector<Item*> items_;
......
...@@ -3426,8 +3426,9 @@ void MarkCompactCollector::MarkingWorklist::PrintWorklist( ...@@ -3426,8 +3426,9 @@ void MarkCompactCollector::MarkingWorklist::PrintWorklist(
count[obj->map()->instance_type()]++; count[obj->map()->instance_type()]++;
}); });
std::vector<std::pair<int, InstanceType>> rank; std::vector<std::pair<int, InstanceType>> rank;
for (auto i : count) { rank.reserve(count.size());
rank.push_back(std::make_pair(i.second, i.first)); for (const auto& i : count) {
rank.emplace_back(i.second, i.first);
} }
std::map<InstanceType, std::string> instance_type_name; std::map<InstanceType, std::string> instance_type_name;
#define INSTANCE_TYPE_NAME(name) instance_type_name[name] = #name; #define INSTANCE_TYPE_NAME(name) instance_type_name[name] = #name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment