diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-06-05 04:32:17 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-06-05 04:32:17 +0300 |
commit | 76c8a4c91bccf27d188b5dcbc44899684d27d8da (patch) | |
tree | 7a732ebeb44cfd3cb7830091d668faa7088d874c | |
parent | 30583f58d5363657d74829160097c58aed4f3ce1 (diff) | |
download | micropython-76c8a4c91bccf27d188b5dcbc44899684d27d8da.tar.gz micropython-76c8a4c91bccf27d188b5dcbc44899684d27d8da.zip |
unix: Add setjmp-based GC register helper implementation.
As I suspected for a long time, for x86, register helper doesn't really make
any difference - there's simply not enough register to keep anything in
them for any prolonged time. Anything gets pushed on stack anyway. So, on
x86, uPy passed all tests even with empty reg helper. So, this setjmp
implementation goes as "untested".
-rw-r--r-- | unix/gccollect.c | 12 | ||||
-rw-r--r-- | unix/mpconfigport.h | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/unix/gccollect.c b/unix/gccollect.c index d934f9cae2..4f3b786e72 100644 --- a/unix/gccollect.c +++ b/unix/gccollect.c @@ -34,6 +34,17 @@ extern void *stack_top; +#if MICROPY_GCREGS_SETJMP +#include <setjmp.h> + +typedef jmp_buf regs_t; + +void gc_helper_get_regs(regs_t arr) { + setjmp(arr); +} + +#else // !MICROPY_GCREGS_SETJMP + // We capture here callee-save registers, i.e. ones which may contain // interesting values held there by our callers. It doesn't make sense // to capture caller-saved registers, because they, well, put on the @@ -112,6 +123,7 @@ void gc_helper_get_regs(regs_t arr) { arr[9] = r13; } #endif +#endif // !MICROPY_GCREGS_SETJMP void gc_collect(void) { //gc_dump_info(); diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h index 1b1d938a84..0c12101fd0 100644 --- a/unix/mpconfigport.h +++ b/unix/mpconfigport.h @@ -49,6 +49,9 @@ // Define to MICROPY_ERROR_REPORTING_DETAILED to get function, etc. // names in exception messages (may require more RAM). #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) +// Define to 1 to use untested inefficient GC helper implementation +// (if more efficient arch-specific one is not available). +#define MICROPY_GCREGS_SETJMP (0) extern const struct _mp_obj_module_t mp_module_os; extern const struct _mp_obj_module_t mp_module_time; |