From 24f7d75049e52c1e7f0c4e4112a7dec3911a709c Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Mon, 29 Mar 2021 16:28:39 +0900 Subject: [PATCH] wip --- gc_sections.cc | 14 +++++++------- main.cc | 2 +- mold.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gc_sections.cc b/gc_sections.cc index ef2865b0..f6d7d998 100644 --- a/gc_sections.cc +++ b/gc_sections.cc @@ -63,7 +63,7 @@ static void visit(InputSection *isec, Feeder &feeder, i64 depth) { } } -static tbb::concurrent_vector collect_root_set() { +static tbb::concurrent_vector collect_root_set(Context &ctx) { Timer t("collect_root_set"); tbb::concurrent_vector roots; @@ -134,7 +134,7 @@ static void mark(tbb::concurrent_vector &roots) { } // Remove unreachable sections -static void sweep() { +static void sweep(Context &ctx) { Timer t("sweep"); static Counter counter("garbage_sections"); @@ -154,7 +154,7 @@ static void sweep() { // Non-alloc section fragments are not subject of garbage collection. // This function marks such fragments. -static void mark_nonalloc_fragments() { +static void mark_nonalloc_fragments(Context &ctx) { Timer t("mark_nonalloc_fragments"); tbb::parallel_for_each(ctx.objs, [](ObjectFile *file) { @@ -164,12 +164,12 @@ static void mark_nonalloc_fragments() { }); } -void gc_sections() { +void gc_sections(Context &ctx) { Timer t("gc"); - mark_nonalloc_fragments(); + mark_nonalloc_fragments(ctx); - tbb::concurrent_vector roots = collect_root_set(); + tbb::concurrent_vector roots = collect_root_set(ctx); mark(roots); - sweep(); + sweep(ctx); } diff --git a/main.cc b/main.cc index ff234c79..609335be 100644 --- a/main.cc +++ b/main.cc @@ -1209,7 +1209,7 @@ int main(int argc, char **argv) { // Garbage-collect unreachable sections. if (ctx.arg.gc_sections) - gc_sections(); + gc_sections(ctx); // Merge identical read-only sections. if (ctx.arg.icf) diff --git a/mold.h b/mold.h index cd6cb19b..39190359 100644 --- a/mold.h +++ b/mold.h @@ -1031,7 +1031,7 @@ private: // gc_sections.cc // -void gc_sections(); +void gc_sections(Context &ctx); // // icf.cc