Fix the initial state and polish a couple comments.

This commit is contained in:
Scott Shawcroft 2018-01-24 14:13:26 -08:00
parent da330f0cab
commit aa0ce98b3e
2 changed files with 3 additions and 2 deletions

View File

@ -147,7 +147,7 @@ void gc_init(void *start, void *end) {
#endif
// Set first free ATB index to the start of the heap.
MP_STATE_MEM(gc_last_free_atb_index) = 0;
MP_STATE_MEM(gc_first_free_atb_index) = 0;
// Set last free ATB index to the end of the heap.
MP_STATE_MEM(gc_last_free_atb_index) = MP_STATE_MEM(gc_alloc_table_byte_len) - 1;
// Set the lowest long lived ptr to the end of the heap to start. This will be lowered as long

View File

@ -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
mp_raw_code_t* raw_code = MP_OBJ_TO_PTR(fun_bc->const_table[i]);
if (raw_code->kind == MP_CODE_BYTECODE) {
raw_code->data.u_byte.bytecode = gc_make_long_lived((byte*) raw_code->data.u_byte.bytecode);
// TODO(tannewt): Do we actually want to recurse here?
raw_code->data.u_byte.const_table = gc_make_long_lived((byte*) raw_code->data.u_byte.const_table);
}
((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
fun_bc->const_table = gc_make_long_lived((mp_uint_t*) fun_bc->const_table);
// extra_args stores keyword only argument default values.
size_t words = gc_nbytes(fun_bc) / sizeof(mp_uint_t*);
// Functions (mp_obj_fun_bc_t) have four pointers (base, globals, bytecode and const_table)
// before the variable length extra_args so remove them from the length.
for (size_t i = 0; i < words - 4; i++) {
if (fun_bc->extra_args[i] == NULL) {
continue;