Skip to content

Commit

Permalink
RTS: address warnings and enable -Werror
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoparkar committed Dec 28, 2023
1 parent fdf6c03 commit e1f14d6
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 22 deletions.
2 changes: 1 addition & 1 deletion gibbon-rts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

CC := gcc
AR := gcc-ar
CFLAGS := -Wall -Wextra -Wpedantic -Wshadow -std=gnu11 -flto
CFLAGS := -Wall -Wextra -Wpedantic -Wshadow -Werror -std=gnu11 -flto
RSC := cargo
RSFLAGS := -v
VERBOSITY := 1
Expand Down
36 changes: 19 additions & 17 deletions gibbon-rts/rts-c/gibbon_rts.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ GibSym gib_read_gensym_counter(void)
#ifdef _GIBBON_POINTER

#ifdef _GIBBON_BUMPALLOC_HEAP
#warning "Using bump allocator."
#pragma message "Using bump allocator."

static __thread char *gib_global_ptr_bumpalloc_heap_ptr = (char *) NULL;
static __thread char *gib_global_ptr_bumpalloc_heap_ptr_end = (char *) NULL;
Expand Down Expand Up @@ -706,7 +706,7 @@ double gib_sum_timing_array(GibVector *times)

#ifdef _GIBBON_BUMPALLOC_LISTS
// #define _GIBBON_DEBUG
#warning "Using bump allocator."
#pragma message "Using bump allocator."

static __thread char *gib_global_list_bumpalloc_heap_ptr = (char *) NULL;
static __thread char *gib_global_list_bumpalloc_heap_ptr_end = (char *) NULL;
Expand Down Expand Up @@ -1036,26 +1036,26 @@ void gib_print_gc_config(void) {
printf("C config\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");

#if defined _GIBBON_GENGC && _GIBBON_GENGC == 0
#warning "Generational GC is disabled."
#pragma message "Generational GC is disabled."
printf("Generational GC is disabled.\n");
#else
#warning "Generational GC is enabled."
#pragma message "Generational GC is enabled."
printf("Generational GC is enabled.\n");
#endif

#if defined _GIBBON_EAGER_PROMOTION && _GIBBON_EAGER_PROMOTION == 0
#warning "Eager promotion is disabled."
#pragma message "Eager promotion is disabled."
printf("Eager promotion is disabled.\n");
#else
#warning "Eager promotion is enabled."
#pragma message "Eager promotion is enabled."
printf("Eager promotion is enabled.\n");
#endif

#if defined _GIBBON_SIMPLE_WRITE_BARRIER && _GIBBON_SIMPLE_WRITE_BARRIER == 0
#warning "Simple write barrier is disabled."
#pragma message "Simple write barrier is disabled."
printf("Simple write barrier is disabled.\n");
#else
#warning "Simple write barrier is enabled."
#pragma message "Simple write barrier is enabled."
printf("Simple write barrier is enabled.\n");
#endif

Expand Down Expand Up @@ -1316,8 +1316,8 @@ void gib_print_global_region_count(void)
*/

// Initialize nurseries, shadow stacks and generations.
static void gib_storage_initialize(void);
static void gib_storage_free(void);
UNUSED_IN_POINTER_BAK static void gib_storage_initialize(void);
UNUSED_IN_POINTER_BAK static void gib_storage_free(void);
static void gib_nursery_initialize(GibNursery *nursery, size_t nsize);
static void gib_nursery_free(GibNursery *nursery);
static void gib_oldgen_initialize(GibOldgen *oldgen);
Expand All @@ -1328,7 +1328,7 @@ static void gib_gc_stats_initialize(GibGcStats *stats);
static void gib_gc_stats_free(GibGcStats *stats);

// Initialize nurseries, shadow stacks and generations.
static void gib_storage_initialize(void)
UNUSED_IN_POINTER_BAK static void gib_storage_initialize(void)
{
if (gib_storage_initialized) {
return;
Expand All @@ -1339,7 +1339,7 @@ static void gib_storage_initialize(void)
gib_gc_stats_initialize(gib_global_gc_stats);

// Initialize nurseries.
int n;
uint64_t n;
gib_global_nurseries = (GibNursery *) gib_alloc(gib_global_num_threads *
sizeof(GibNursery));
for (n = 0; n < gib_global_num_threads; n++) {
Expand All @@ -1351,7 +1351,7 @@ static void gib_storage_initialize(void)
gib_oldgen_initialize(gib_global_oldgen);

// Initialize shadow stacks.
int ss;
uint64_t ss;
gib_global_read_shadowstacks =
(GibShadowstack *) gib_alloc(gib_global_num_threads *
sizeof(GibShadowstack));
Expand All @@ -1368,14 +1368,14 @@ static void gib_storage_initialize(void)
return;
}

static void gib_storage_free(void)
UNUSED_IN_POINTER_BAK static void gib_storage_free(void)
{
if (!gib_storage_initialized) {
return;
}

// Free nurseries.
int n;
uint64_t n;
for (n = 0; n < gib_global_num_threads; n++) {
gib_nursery_free(&(gib_global_nurseries[n]));
}
Expand All @@ -1386,7 +1386,7 @@ static void gib_storage_free(void)
gib_free(gib_global_oldgen);

// Free shadow-stacks.
int ss;
uint64_t ss;
for (ss = 0; ss < gib_global_num_threads; ss++) {
gib_shadowstack_free(&(gib_global_read_shadowstacks[ss]));
gib_shadowstack_free(&(gib_global_write_shadowstacks[ss]));
Expand Down Expand Up @@ -1599,6 +1599,7 @@ static void gib_gc_stats_free(GibGcStats *stats)
gib_free(stats);
}

#ifdef _GIBBON_GCSTATS
static void gib_gc_stats_print(GibGcStats *stats)
{
printf("\nGC statistics\n----------------------------------------\n");
Expand Down Expand Up @@ -1652,6 +1653,7 @@ static void gib_gc_stats_print(GibGcStats *stats)
printf("Skipover env inserts:\t\t %ld\n", stats->skipover_env_inserts);
printf("Root set size:\t\t\t %ld\n", stats->rootset_size);
}
#endif // ifdef _GIBBON_GCSTATS


/*
Expand Down Expand Up @@ -1929,7 +1931,7 @@ int gib_init(int argc, char **argv)
}
#endif

int got_numargs = argc; // How many numeric arguments have we got.
// int got_numargs = argc; // How many numeric arguments have we got.

int i;
for (i = 1; i < argc; ++i)
Expand Down
13 changes: 11 additions & 2 deletions gibbon-rts/rts-c/gibbon_rts.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,16 @@ typedef uint64_t GibThreadId;
#define ATTR_ALWAYS_INLINE __attribute__((always_inline))
#define ATTR_HOT __attribute__((hot))

#ifdef _GIBBON_POINTER
#define UNUSED_IN_POINTER_BAK __attribute__((unused))
#else
#define UNUSED_IN_POINTER_BAK
#endif

#define LIKELY(x) __builtin_expect((bool) (x), 1)
#define UNLIKELY(x) __builtin_expect((bool) (x), 0)
#define IGNORE(x) (void) (x)


/*
* Inlining macros taken from GHC:
Expand Down Expand Up @@ -1069,9 +1077,9 @@ INLINE_HEADER void gib_indirection_barrier(
{

#if defined _GIBBON_SIMPLE_WRITE_BARRIER && _GIBBON_SIMPLE_WRITE_BARRIER == 1
#warning "Simple write barrier is enabled."
#pragma message "Simple write barrier is enabled."
#else
#warning "Simple write barrier is disabled."
#pragma message "Simple write barrier is disabled."
{
// Optimization: don't create long chains of indirection pointers.
GibPackedTag pointed_to_tag = *(GibPackedTag *) to;
Expand Down Expand Up @@ -1105,6 +1113,7 @@ INLINE_HEADER void gib_indirection_barrier(
// old-to-old indirections.

#if defined _GIBBON_GENGC && _GIBBON_GENGC == 0
IGNORE(datatype);
gib_add_old_to_old_indirection(from_footer, to_footer);
return;
#else
Expand Down
5 changes: 3 additions & 2 deletions gibbon-rts/rts-ng/src/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ pub fn cleanup(
(*((*oldgen).old_zct)).insert((*footer).reg_info);
}
}
for reg_info in (*((*oldgen).old_zct)).drain() {
// free_region((*reg_info).first_chunk_footer, null_mut())?;
for _reg_info in (*((*oldgen).old_zct)).drain() {
// Enable this again after ensuring that everything works.
// // free_region((*reg_info).first_chunk_footer, null_mut())?;
}
}
// Free ZCTs associated with the oldest generation.
Expand Down
4 changes: 4 additions & 0 deletions gibbon-rts/rts-ng/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//! Next generation runtime system for the Gibbon compiler.

// Erroring on every warning is OK for now, but can be refined in the future:
// https://rust-unofficial.github.io/patterns/anti_patterns/deny-warnings.html
#![deny(warnings)]

pub use ffi::c::*;
pub use ffi::rs::*;
pub use gc::ValueStats;
Expand Down

0 comments on commit e1f14d6

Please sign in to comment.