Skip to content

Commit

Permalink
lib/utils/pyexec: Condition-out GC calls from pyexec.
Browse files Browse the repository at this point in the history
A port which uses lib/utils/pyexec.c but which does not enable garbage
collection should not need to implement the gc_collect function.

This patch also moves the gc_collect call to after printing the qstr
info.  Since qstrs cannot be collected it should not make any difference
to the printed statistics.
  • Loading branch information
Colin Hogben authored and dpgeorge committed Apr 19, 2016
1 parent 97f88ee commit 8aa3cbf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 0 additions & 3 deletions bare-arm/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ int main(int argc, char **argv) {
return 0;
}

void gc_collect(void) {
}

mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
return NULL;
}
Expand Down
6 changes: 4 additions & 2 deletions lib/utils/pyexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,18 @@ STATIC int parse_compile_execute(void *source, mp_parse_input_kind_t input_kind,
if ((exec_flags & EXEC_FLAG_ALLOW_DEBUGGING) && repl_display_debugging_info) {
mp_uint_t ticks = mp_hal_ticks_ms() - start; // TODO implement a function that does this properly
printf("took " UINT_FMT " ms\n", ticks);
gc_collect();
// qstr info
{
mp_uint_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes;
qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes);
printf("qstr:\n n_pool=" UINT_FMT "\n n_qstr=" UINT_FMT "\n n_str_data_bytes=" UINT_FMT "\n n_total_bytes=" UINT_FMT "\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes);
}

// GC info
#if MICROPY_ENABLE_GC
// run collection and print GC info
gc_collect();
gc_dump_info();
#endif
}

if (exec_flags & EXEC_FLAG_PRINT_EOF) {
Expand Down

0 comments on commit 8aa3cbf

Please sign in to comment.