Page 1 of 1

vstr_t line avoiding a sweep from GC in pyexec

Posted: Mon Feb 07, 2022 5:45 pm
by envirocoder
Forgive my potential ignorance, I'm trying to understand why

Code: Select all

vstr_t line
doesn't get swept from the garbage collector? I'm making changes elsewhere in the function and I want to make sure I don't break something.

With the non MICROPY_REPL_EVENT_DRIVEN version of

Code: Select all

pyexec_friendly_repl
I can't see

Code: Select all

vstr_t line
being referenced from a root pointers. As such, why doesn't it get cleaned by the garbage collector?

In the event_driven version it is referenced:

Code: Select all

MP_STATE_VM(repl_line) = vstr_new(32);
Thanks -- I wanted to check before I introduced a bug!

Re: vstr_t line avoiding a sweep from GC in pyexec

Posted: Mon Feb 07, 2022 7:45 pm
by stijn
Didn't check in detail, but the non-eventdriven version is one big loop hence line is on the stack as long as the program runs and as such doesn't get garbage collected because the mark phase will see it being on the stack?