From b4b10fd350852e321624d74983cca286091b55a1 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 1 Jan 2015 23:30:53 +0000 Subject: py: Put all global state together in state structures. This patch consolidates all global variables in py/ core into one place, in a global structure. Root pointers are all located together to make GC tracing easier and more efficient. --- py/nlr.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'py/nlr.h') diff --git a/py/nlr.h b/py/nlr.h index 824ed6dd6..f414588a5 100644 --- a/py/nlr.h +++ b/py/nlr.h @@ -64,14 +64,14 @@ struct _nlr_buf_t { #endif }; -extern nlr_buf_t *nlr_top; - #if MICROPY_NLR_SETJMP +#include "py/mpstate.h" + NORETURN void nlr_setjmp_jump(void *val); // nlr_push() must be defined as a macro, because "The stack context will be // invalidated if the function which called setjmp() returns." -#define nlr_push(buf) ((buf)->prev = nlr_top, nlr_top = (buf), setjmp((buf)->jmpbuf)) -#define nlr_pop() { nlr_top = nlr_top->prev; } +#define nlr_push(buf) ((buf)->prev = MP_STATE_VM(nlr_top), MP_STATE_VM(nlr_top) = (buf), setjmp((buf)->jmpbuf)) +#define nlr_pop() { MP_STATE_VM(nlr_top) = MP_STATE_VM(nlr_top)->prev; } #define nlr_jump(val) nlr_setjmp_jump(val) #else unsigned int nlr_push(nlr_buf_t *); -- cgit v1.2.3