Skip to content

Commit

Permalink
[refactor] Rename GC_EVERY_ALLOC -> GC_ALWAYS
Browse files Browse the repository at this point in the history
And the build variant: gcevery -> gcalways
  • Loading branch information
Andy C committed Dec 21, 2022
1 parent 5422c1b commit d651470
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion asdl/TEST.sh
Expand Up @@ -27,7 +27,7 @@ unit() {
echo

# use-after-free detected
# run-one-test 'asdl/gc_test' '' gcevery
# run-one-test 'asdl/gc_test' '' gcalways
# echo
}

Expand Down
2 changes: 1 addition & 1 deletion asdl/gc_test.cc
Expand Up @@ -27,7 +27,7 @@ TEST pretty_print_test() {
#endif

// Note: this segfaults with 1000 iterations, because it hit GC.
// TODO: GC_EVERY_ALLOC and make it pass.
// TODO: GC_ALWAYS and make it pass.
for (int i = 0; i < 2; ++i) {
hnode_t* t1 = b->PrettyTree();
ASSERT_EQ(hnode_e::Record, t1->tag_());
Expand Down
8 changes: 4 additions & 4 deletions build/ninja-rules-cpp.sh
Expand Up @@ -100,13 +100,13 @@ setglobal_compile_flags() {
flags="$flags -O0 -g -fsanitize=address -D GC_VERBOSE"
;;

(gcevery)
flags="$flags -g -D GC_EVERY_ALLOC -fsanitize=address"
(gcalways)
flags="$flags -g -D GC_ALWAYS -fsanitize=address"
;;

# Just like GCEVERY
(rvroot)
flags="$flags -g -D RET_VAL_ROOTING -D GC_EVERY_ALLOC -fsanitize=address"
flags="$flags -g -D RET_VAL_ROOTING -D GC_ALWAYS -fsanitize=address"
;;

(opt)
Expand Down Expand Up @@ -174,7 +174,7 @@ setglobal_link_flags() {
;;

# Must REPEAT these flags, otherwise we lose sanitizers / coverage
(asan|gcevery|gcverbose|rvroot)
(asan|gcalways|gcverbose|rvroot)
link_flags='-fsanitize=address'
;;
(tsan)
Expand Down
2 changes: 1 addition & 1 deletion build/ninja_lib.py
Expand Up @@ -71,7 +71,7 @@ def log(msg, *args):
COMPILERS_VARIANTS = COMPILERS_VARIANTS_LEAKY + [
# mainly for unit tests
('cxx', 'gcverbose'),
('cxx', 'gcevery'),
('cxx', 'gcalways'),
]

SMALL_TEST_MATRIX = [
Expand Down
2 changes: 1 addition & 1 deletion cpp/NINJA_subgraph.py
Expand Up @@ -13,7 +13,7 @@
('cxx', 'dbg', '-D CPP_UNIT_TEST'),
('cxx', 'asan', '-D CPP_UNIT_TEST'),
('cxx', 'ubsan', '-D CPP_UNIT_TEST'),
#('cxx', 'gcevery', '-D CPP_UNIT_TEST'),
#('cxx', 'gcalways', '-D CPP_UNIT_TEST'),
#('cxx', 'rvroot', '-D CPP_UNIT_TEST'),
('clang', 'coverage', '-D CPP_UNIT_TEST'),
]
Expand Down
2 changes: 1 addition & 1 deletion cpp/TEST.sh
Expand Up @@ -67,7 +67,7 @@ unit() {
# Tests that pass with the garbage collector on.
# TODO: Move all tests here

for variant in ubsan gcevery; do
for variant in ubsan gcalways; do
run-one-test cpp/obj_layout_test '' $variant

run-test-in-dir cpp/core_test '' $variant # has testdata
Expand Down
2 changes: 1 addition & 1 deletion frontend/TEST.sh
Expand Up @@ -15,7 +15,7 @@ unit() {
#run-one-test 'frontend/syntax_asdl_test' '' asan

run-one-test 'frontend/arg_types_test' '' asan
run-one-test 'frontend/arg_types_test' '' gcevery
run-one-test 'frontend/arg_types_test' '' gcalways
}

"$@"
4 changes: 2 additions & 2 deletions mycpp/NINJA_subgraph.py
Expand Up @@ -220,7 +220,7 @@ def TranslatorSubgraph(ru, translator, ex):
else:
# pea just has one variant for now
example_matrix = [
('cxx', 'gcevery')
('cxx', 'gcalways')
]

if translator == 'mycpp':
Expand Down Expand Up @@ -383,7 +383,7 @@ def NinjaGraph(ru):

# minimal
MATRIX = [
('test', 'asan'), # TODO: gcevery is better!
('test', 'asan'), # TODO: gcalways is better!
('benchmark', 'opt'),
]

Expand Down
20 changes: 10 additions & 10 deletions mycpp/TEST.sh
Expand Up @@ -26,7 +26,7 @@ examples-variant() {
### Run all examples using a variant -- STATS only

local compiler=${1:-cxx}
local variant=${2:-gcevery}
local variant=${2:-gcalways}
local do_benchmark=${3:-}

banner "$0 examples-variant $compiler $variant"
Expand Down Expand Up @@ -87,7 +87,7 @@ examples-variant() {
log ''

# TODO: fix failure and remove this
if test $variant = 'gcevery'; then
if test $variant = 'gcalways'; then
return 0
fi

Expand All @@ -103,15 +103,15 @@ examples-variant() {
# 3 Variants x {test, benchmark}
#

ex-gcevery() {
ex-gcalways() {
local compiler=${1:-}
examples-variant "$compiler" gcevery
examples-variant "$compiler" gcalways
}

# TOO SLOW to run. It's garbage collecting all the time.
ex-gcevery-bench() {
ex-gcalways-bench() {
local compiler=${1:-}
examples-variant "$compiler" gcevery '.BENCHMARK'
examples-variant "$compiler" gcalways '.BENCHMARK'
}

ex-asan() {
Expand All @@ -120,7 +120,7 @@ ex-asan() {
}

# 2 of 18 tests failed: cartesian, parse
# So it does not catch the 10 segfaults that 'gcevery' catches with a few
# So it does not catch the 10 segfaults that 'gcalways' catches with a few
# iterations!
ex-asan-bench() {
local compiler=${1:-}
Expand Down Expand Up @@ -159,7 +159,7 @@ unit() {
### Run by test/cpp-unit.sh

local compiler=${1:-cxx}
local variant=${2:-gcevery}
local variant=${2:-gcalways}

log ''
log "$0 unit $compiler $variant"
Expand Down Expand Up @@ -238,7 +238,7 @@ test-runtime() {

unit '' asan
unit '' gcverbose
unit '' gcevery
unit '' gcalways
# unit '' rvroot
}

Expand All @@ -252,7 +252,7 @@ test-translator() {
examples-variant '' asan

# Test with more collections
examples-variant '' gcevery
examples-variant '' gcalways

run-test-func test-invalid-examples _test/mycpp/test-invalid-examples.log

Expand Down
2 changes: 1 addition & 1 deletion mycpp/cheney_heap.cc
Expand Up @@ -240,7 +240,7 @@ void* CheneyHeap::Allocate(int num_bytes) {
// it went to forward the pointer.
assert(n >= static_cast<int>(sizeof(LayoutForwarded)));

#if GC_EVERY_ALLOC
#if GC_ALWAYS
Collect(); // force collection to find problems early
#endif

Expand Down
2 changes: 1 addition & 1 deletion mycpp/cheney_heap.h
Expand Up @@ -91,7 +91,7 @@

// #defines for degbugging:
//
// GC_EVERY_ALLOC: Collect() on every Allocate(). Exposes many bugs!
// GC_ALWAYS: Collect() on every Allocate(). Exposes many bugs!
// GC_VERBOSE: Log when we collect

// Silly definition for passing types like GlobalList<T, N> and initializer
Expand Down
1 change: 1 addition & 0 deletions mycpp/demo/hash_table.cc
Expand Up @@ -18,6 +18,7 @@ TEST unordered_set_bucket_test() {
int h = hasher(p);
// This is just the low bits!
// log("std::hash<void*>(pp) = %x", h);
(void)h;

set.insert(p);
log("bucket %d", set.bucket(p));
Expand Down
2 changes: 1 addition & 1 deletion mycpp/mark_sweep_heap.cc
Expand Up @@ -60,7 +60,7 @@ int MarkSweepHeap::MaybeCollect() {

int MarkSweepHeap::MaybeCollect() {
// Maybe collect BEFORE allocation, because the new object won't be rooted
#if GC_EVERY_ALLOC
#if GC_ALWAYS
int result = Collect();
#else
int result = -1;
Expand Down
2 changes: 1 addition & 1 deletion mycpp/mark_sweep_heap_test.cc
Expand Up @@ -6,7 +6,7 @@ TEST string_collection_test() {

{
// NOTE(Jesse): This causes a crash when this gets compiled against the
// cheney collector w/ GC_EVERY_ALLOC. I did verify it doesn't crash with
// cheney collector w/ GC_ALWAYS. I did verify it doesn't crash with
// the marksweep allocator but didn't want to figure out how to tell the
// build system to not compile these tests against the cheney collector
//
Expand Down
2 changes: 1 addition & 1 deletion test/cpp-unit.sh
Expand Up @@ -20,7 +20,7 @@ all-tests() {

frontend/TEST.sh unit

# uses Ninja to run (cxx, gcevery) variant. Could also run (clang, ubsan),
# uses Ninja to run (cxx, gcalways) variant. Could also run (clang, ubsan),
# which finds more bugs.
mycpp/TEST.sh test-runtime
}
Expand Down

0 comments on commit d651470

Please sign in to comment.