[python] Enable PYSTACK for emscripten platform: this "fixes" bug

probably due to gc_collect (we suspect that transpiled C does not have
access to javascript variables preventing it from collecting all
required roots and leading to deleting objects prematuraly). Enabling
PyStack reduces the use of the heap and fixes the bug.
This commit is contained in:
Émilie Feral
2020-01-31 11:44:57 +01:00
committed by Léa Saviot
parent 58acedfd34
commit de74aa7e59
3 changed files with 28 additions and 0 deletions

View File

@@ -102,6 +102,11 @@ extern "C" {
}
void MicroPython::init(void * heapStart, void * heapEnd) {
#if __EMSCRIPTEN__
static mp_obj_t pystack[1024];
mp_pystack_init(pystack, &pystack[MP_ARRAY_SIZE(pystack)]);
#endif
volatile int stackTop;
void * stackTopAddress = (void *)(&stackTop);
/* We delimit the stack part that will be used by Python. The stackTop is the