Skip to content

Commit aa0ce98

Browse files
committed
Fix the initial state and polish a couple comments.
1 parent da330f0 commit aa0ce98

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

py/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void gc_init(void *start, void *end) {
147147
#endif
148148

149149
// Set first free ATB index to the start of the heap.
150-
MP_STATE_MEM(gc_last_free_atb_index) = 0;
150+
MP_STATE_MEM(gc_first_free_atb_index) = 0;
151151
// Set last free ATB index to the end of the heap.
152152
MP_STATE_MEM(gc_last_free_atb_index) = MP_STATE_MEM(gc_alloc_table_byte_len) - 1;
153153
// Set the lowest long lived ptr to the end of the heap to start. This will be lowered as long

py/gc_long_lived.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ mp_obj_fun_bc_t *make_fun_bc_long_lived(mp_obj_fun_bc_t *fun_bc, uint8_t max_dep
4646
mp_raw_code_t* raw_code = MP_OBJ_TO_PTR(fun_bc->const_table[i]);
4747
if (raw_code->kind == MP_CODE_BYTECODE) {
4848
raw_code->data.u_byte.bytecode = gc_make_long_lived((byte*) raw_code->data.u_byte.bytecode);
49-
// TODO(tannewt): Do we actually want to recurse here?
5049
raw_code->data.u_byte.const_table = gc_make_long_lived((byte*) raw_code->data.u_byte.const_table);
5150
}
5251
((mp_uint_t *) fun_bc->const_table)[i] = (mp_uint_t) make_obj_long_lived(
@@ -56,6 +55,8 @@ mp_obj_fun_bc_t *make_fun_bc_long_lived(mp_obj_fun_bc_t *fun_bc, uint8_t max_dep
5655
fun_bc->const_table = gc_make_long_lived((mp_uint_t*) fun_bc->const_table);
5756
// extra_args stores keyword only argument default values.
5857
size_t words = gc_nbytes(fun_bc) / sizeof(mp_uint_t*);
58+
// Functions (mp_obj_fun_bc_t) have four pointers (base, globals, bytecode and const_table)
59+
// before the variable length extra_args so remove them from the length.
5960
for (size_t i = 0; i < words - 4; i++) {
6061
if (fun_bc->extra_args[i] == NULL) {
6162
continue;

0 commit comments

Comments
 (0)