aboutsummaryrefslogtreecommitdiff
path: root/py/bc0.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-04-19 09:45:59 +1000
committerDamien George <damien.p.george@gmail.com>2017-04-22 23:39:20 +1000
commitdd11af209d226b7d18d5148b239662e30ed60bad (patch)
tree8343a2ce54172f2f3304ca5dba49f352f37b5c17 /py/bc0.h
parent5335942b599d85263d3c18eb99ff5ebd04a8bc98 (diff)
py: Add LOAD_SUPER_METHOD bytecode to allow heap-free super meth calls.
This patch allows the following code to run without allocating on the heap: super().foo(...) Before this patch such a call would allocate a super object on the heap and then load the foo method and call it right away. The super object is only needed to perform the lookup of the method and not needed after that. This patch makes an optimisation to allocate the super object on the C stack and discard it right after use. Changes in code size due to this patch are: bare-arm: +128 minimal: +232 unix x64: +416 unix nanbox: +364 stmhal: +184 esp8266: +340 cc3200: +128
Diffstat (limited to 'py/bc0.h')
-rw-r--r--py/bc0.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/py/bc0.h b/py/bc0.h
index c2b019f1a..b5650abe4 100644
--- a/py/bc0.h
+++ b/py/bc0.h
@@ -37,12 +37,13 @@
#define MP_BC_LOAD_CONST_OBJ (0x17) // ptr
#define MP_BC_LOAD_NULL (0x18)
-#define MP_BC_LOAD_FAST_N (0x1a) // uint
-#define MP_BC_LOAD_DEREF (0x1b) // uint
-#define MP_BC_LOAD_NAME (0x1c) // qstr
-#define MP_BC_LOAD_GLOBAL (0x1d) // qstr
-#define MP_BC_LOAD_ATTR (0x1e) // qstr
-#define MP_BC_LOAD_METHOD (0x1f) // qstr
+#define MP_BC_LOAD_FAST_N (0x19) // uint
+#define MP_BC_LOAD_DEREF (0x1a) // uint
+#define MP_BC_LOAD_NAME (0x1b) // qstr
+#define MP_BC_LOAD_GLOBAL (0x1c) // qstr
+#define MP_BC_LOAD_ATTR (0x1d) // qstr
+#define MP_BC_LOAD_METHOD (0x1e) // qstr
+#define MP_BC_LOAD_SUPER_METHOD (0x1f) // qstr
#define MP_BC_LOAD_BUILD_CLASS (0x20)
#define MP_BC_LOAD_SUBSCR (0x21)