Skip to content

Commit

Permalink
Add a CLI flag for incremental GC
Browse files Browse the repository at this point in the history
  • Loading branch information
jeaye committed Oct 22, 2023
1 parent 2feebd7 commit a9bedc0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/cpp/jank/util/cli.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace jank::util::cli
native_string class_path;
native_bool profiler_enabled{};
native_string profiler_file{ "jank.profile" };
native_bool gc_incremental{};

/* Compilation. */
native_string compilation_path{ "classes" };
Expand Down
3 changes: 2 additions & 1 deletion src/cpp/jank/util/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace jank::util::cli
cli.add_option("--class-path", opts.class_path, fmt::format("A {} separated list of directories, JAR files, and ZIP files to search for modules", runtime::module::loader::module_separator));
cli.add_flag("--profile", opts.profiler_enabled, "Enable compiler and runtime profiling");
cli.add_option("--profile-output", opts.profiler_file, "The file to write profile entries (will be overwritten)");
cli.add_flag("--gc-incremental", opts.gc_incremental, "Enable incremental GC collection");

/* Compilation. */
cli.add_option("--output-dir", opts.compilation_path, "The base directory where compiled modules are written");
Expand Down Expand Up @@ -41,7 +42,7 @@ namespace jank::util::cli
{
cli.parse(argc, argv);
}
catch (CLI::ParseError const &e)
catch(CLI::ParseError const &e)
{ return err(cli.exit(e)); }

if(cli.got_subcommand(&cli_run))
Expand Down
10 changes: 7 additions & 3 deletions src/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,14 @@ try
* like strings, use the GC for allocations. It can still be configured later. */
GC_set_all_interior_pointers(1);
GC_enable();
/* TODO: This crashes now, with LLVM13. Looks like it's cleaning up things it shouldn't. */
//GC_enable_incremental();

auto const opts(util::cli::parse(argc, argv).expect_ok());
auto const parse_result(util::cli::parse(argc, argv));
if(parse_result.is_err())
{ return parse_result.expect_err(); }
auto const &opts(parse_result.expect_ok());

if(opts.gc_incremental)
{ GC_enable_incremental(); }

profile::configure(opts);
profile::timer timer{ "main" };
Expand Down

0 comments on commit a9bedc0

Please sign in to comment.