summaryrefslogtreecommitdiffstatshomepage
path: root/py/emitnative.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-01-13 15:55:54 +0000
committerDamien George <damien.p.george@gmail.com>2015-01-13 15:55:54 +0000
commitdab1385177558f1d27c03b59e443b6fa25a2cdc0 (patch)
treeda284535f901727c739266c2bf50ed5bbec88f1a /py/emitnative.c
parentd710cef6610eff758e96f351e6b91c1c9d8df9f6 (diff)
downloadmicropython-dab1385177558f1d27c03b59e443b6fa25a2cdc0.tar.gz
micropython-dab1385177558f1d27c03b59e443b6fa25a2cdc0.zip
py: Add load_const_obj to emitter, add LOAD_CONST_OBJ to bytecode.
This allows to directly load a Python object to the Python stack. See issue #722 for background.
Diffstat (limited to 'py/emitnative.c')
-rw-r--r--py/emitnative.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/py/emitnative.c b/py/emitnative.c
index 494f89093d..211d2895a3 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -1172,6 +1172,12 @@ STATIC void emit_native_load_const_str(emit_t *emit, qstr qst, bool bytes) {
}
}
+STATIC void emit_native_load_const_obj(emit_t *emit, void *obj) {
+ emit_native_pre(emit);
+ ASM_MOV_ALIGNED_IMM_TO_REG(emit->as, (mp_uint_t)obj, REG_RET);
+ emit_post_push_reg(emit, VTYPE_PYOBJ, REG_RET);
+}
+
STATIC void emit_native_load_null(emit_t *emit) {
emit_native_pre(emit);
emit_post_push_imm(emit, VTYPE_PYOBJ, 0);
@@ -2274,6 +2280,7 @@ const emit_method_table_t EXPORT_FUN(method_table) = {
emit_native_load_const_int,
emit_native_load_const_dec,
emit_native_load_const_str,
+ emit_native_load_const_obj,
emit_native_load_null,
emit_native_load_fast,
emit_native_load_deref,