summaryrefslogtreecommitdiffstatshomepage
path: root/py/emitcpy.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-13 11:04:33 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-13 11:04:33 +0100
commitdf8127a17eeb3057e820180e318ec3d915111b6a (patch)
tree55fa023ce2de910492c9c713bfa15f6e6df475c2 /py/emitcpy.c
parent68e7c5146ce24a593889df67d50d8f9c0cfa528e (diff)
downloadmicropython-df8127a17eeb3057e820180e318ec3d915111b6a.tar.gz
micropython-df8127a17eeb3057e820180e318ec3d915111b6a.zip
py: Remove unique_codes from emitglue.c. Replace with pointers.
Attempt to address issue #386. unique_code_id's have been removed and replaced with a pointer to the "raw code" information. This pointer is stored in the actual byte code (aligned, so the GC can trace it), so that raw code (ie byte code, native code and inline assembler) is kept only for as long as it is needed. In memory it's now like a tree: the outer module's byte code points directly to its children's raw code. So when the outer code gets freed, if there are no remaining functions that need the raw code, then the children's code gets freed as well. This is pretty much like CPython does it, except that CPython stores indexes in the byte code rather than machine pointers. These indices index the per-function constant table in order to find the relevant code.
Diffstat (limited to 'py/emitcpy.c')
-rw-r--r--py/emitcpy.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/py/emitcpy.c b/py/emitcpy.c
index 5866d474e9..010219d12f 100644
--- a/py/emitcpy.c
+++ b/py/emitcpy.c
@@ -9,6 +9,8 @@
#include "qstr.h"
#include "lexer.h"
#include "parse.h"
+#include "obj.h"
+#include "emitglue.h"
#include "scope.h"
#include "runtime0.h"
#include "emit.h"