Merge branch 'master' into f7

This commit is contained in:
Émilie Feral
2019-06-14 13:38:02 -04:00
2 changed files with 8 additions and 7 deletions

View File

@@ -138,9 +138,9 @@ void gc_collect(void) {
/* On the device, the stack is stored in reverse order, but it might not be
* the case on a computer. We thus have to take the absolute value of the
* addresses difference. */
size_t stackLength;
size_t stackLengthInByte;
void ** scanStart;
if ((uintptr_t)python_stack_top > (uintptr_t)&regs) {
if ((uintptr_t)python_stack_top > (uintptr_t)regs_ptr) {
/* To compute the stack length:
* regs
@@ -149,7 +149,7 @@ void gc_collect(void) {
* ^&regs ^python_stack_top
* */
stackLength = ceil((float)((uintptr_t)python_stack_top - (uintptr_t)&regs) / (float)sizeof(uintptr_t));
stackLengthInByte = (uintptr_t)python_stack_top - (uintptr_t)regs_ptr;
scanStart = regs_ptr;
} else {
@@ -161,12 +161,13 @@ void gc_collect(void) {
* ^python_stack_top ^&regs
* */
size_t sizeOfRegs = ceil(((float)sizeof(regs))/(float)sizeof(uintptr_t));
stackLength = (size_t)ceil(((float)((uintptr_t)(&regs) - (uintptr_t)python_stack_top)) / (float)sizeof(uintptr_t)) + sizeOfRegs;
stackLengthInByte = (uintptr_t)regs_ptr - (uintptr_t)python_stack_top + sizeof(regs);
scanStart = (void **)python_stack_top;
}
gc_collect_root(scanStart, stackLength);
/* Memory error detectors might find an error here as they might split regs
* and stack memory zones. */
gc_collect_root(scanStart, stackLengthInByte/sizeof(void *));
gc_collect_end();
}