From 4597c74d1a58f1c84b293069ebed120a48a7e863 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 17 Jan 2022 16:32:37 +0200 Subject: [PATCH] markused: fix `v -gc boehm -skip-unused cmd/vls` --- .github/workflows/ci.yml | 6 ++++++ vlib/v/markused/markused.v | 29 ++++++----------------------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ae0c07d47..e75b5fcab7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -829,6 +829,8 @@ jobs: run: pushd vls; v cmd/vls ; popd - name: Build VLS with -prod run: pushd vls; v -prod cmd/vls; popd + - name: Build VLS with -gc boehm -skip-unused + run: pushd vls; v -gc boehm -skip-unused cmd/vls; popd ## vsl - name: Clone VSL @@ -863,6 +865,8 @@ jobs: run: git clone --depth 1 https://github.com/vlang/vab - name: Build vab run: cd vab; ../v ./vab.v ; cd .. + - name: Build vab with -gc boehm -skip-unused + run: cd vab; ../v -gc boehm -skip-unused ./vab.v ; cd .. ## gitly - name: Install markdown @@ -885,6 +889,8 @@ jobs: run: mkdir -p ~/.vmodules/nedpals; git clone https://github.com/nedpals/vex ~/.vmodules/nedpals/vex - name: Compile the simple Vex example run: ./v ~/.vmodules/nedpals/vex/examples/simple_example.v + - name: Compile the simple Vex example with -gc boehm -skip-unused + run: ./v -gc boehm -skip-unused ~/.vmodules/nedpals/vex/examples/simple_example.v - name: Run Vex Tests run: ./v test ~/.vmodules/nedpals/vex diff --git a/vlib/v/markused/markused.v b/vlib/v/markused/markused.v index d3fae9d800..e0ecce0a34 100644 --- a/vlib/v/markused/markused.v +++ b/vlib/v/markused/markused.v @@ -131,34 +131,17 @@ pub fn mark_used(mut table ast.Table, pref &pref.Preferences, ast_files []&ast.F ] } - if pref.gc_mode in [.boehm_full_opt, .boehm_incr_opt] { - all_fn_root_names << [ - 'memdup_noscan', - '__new_array_noscan', - '__new_array_with_default_noscan', - '__new_array_with_array_default_noscan', - 'new_array_from_c_array_noscan', - '22.clone_static_to_depth_noscan', - '22.clone_to_depth_noscan', - '22.reverse_noscan', - '22.repeat_to_depth_noscan', - '65558.pop_noscan', - '65558.push_noscan', - '65558.push_many_noscan', - '65558.insert_noscan', - '65558.insert_many_noscan', - '65558.prepend_noscan', - '65558.prepend_many_noscan', - '65558.reverse_noscan', - '65558.grow_cap_noscan', - '65558.grow_len_noscan', - ] - } + is_noscan_whitelisted := pref.gc_mode in [.boehm_full_opt, .boehm_incr_opt] for k, mut mfn in all_fns { $if trace_skip_unused_all_fns ? { println('k: $k | mfn: $mfn.name') } + // _noscan functions/methods are selected when the `-gc boehm` is on: + if is_noscan_whitelisted && mfn.name.ends_with('_noscan') { + all_fn_root_names << k + continue + } mut method_receiver_typename := '' if mfn.is_method { method_receiver_typename = table.type_to_str(mfn.receiver.typ)