[core][js] gc engine: fix several bugs