summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-14 21:20:30 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-14 21:20:30 +0100
commit3bb8bd899b2b1e5970b5ceb822bdf3df9b2e2d13 (patch)
tree0396642ad4a39c2de561330b02b4ae1d6e9fc5b5 /py
parent0ae9c7042ae0839cea575955f36af280943cb99f (diff)
downloadmicropython-3bb8bd899b2b1e5970b5ceb822bdf3df9b2e2d13.tar.gz
micropython-3bb8bd899b2b1e5970b5ceb822bdf3df9b2e2d13.zip
Make USE_COMPUTED_GOTO a config option in mpconfig.h.
Disabled by default. Enabled in unix port.
Diffstat (limited to 'py')
-rw-r--r--py/mpconfig.h6
-rw-r--r--py/objstr.c2
-rw-r--r--py/vm.c6
3 files changed, 10 insertions, 4 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h
index f9c02a6f02..8f60c997bd 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -154,6 +154,12 @@ typedef double mp_float_t;
#define MICROPY_PATH_MAX (512)
#endif
+// Whether to use computed gotos in the VM, or a switch
+// Computed gotos are roughly 10% faster, and increase VM code size by a little
+#ifndef MICROPY_USE_COMPUTED_GOTO
+#define MICROPY_USE_COMPUTED_GOTO (0)
+#endif
+
// Additional builtin function definitions - see builtintables.c:builtin_object_table for format.
#ifndef MICROPY_EXTRA_BUILTINS
#define MICROPY_EXTRA_BUILTINS
diff --git a/py/objstr.c b/py/objstr.c
index 08db2af669..fc1e1c5695 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -662,7 +662,7 @@ mp_obj_t str_format(uint n_args, const mp_obj_t *args) {
if (arg_i > 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "cannot switch from automatic field numbering to manual field specification"));
}
- int index;
+ int index = 0;
if (str_to_int(vstr_str(field_name), &index) != vstr_len(field_name) - 1) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_KeyError, "attributes not supported yet"));
}
diff --git a/py/vm.c b/py/vm.c
index f928ad6948..6c117c7cb4 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -167,7 +167,7 @@ mp_vm_return_kind_t mp_execute_byte_code_2(const byte *code_info, const byte **i
volatile mp_obj_t inject_exc) {
// careful: be sure to declare volatile any variables read in the exception handler (written is ok, I think)
-#ifdef MICROPY_USE_COMPUTED_GOTO
+#if MICROPY_USE_COMPUTED_GOTO
# define DISPATCH() do { \
save_ip = ip; \
@@ -299,7 +299,7 @@ outer_dispatch_loop:
// loop to execute byte code
for (;;) {
dispatch_loop:
-#ifdef MICROPY_USE_COMPUTED_GOTO
+#if MICROPY_USE_COMPUTED_GOTO
DISPATCH();
#else
save_ip = ip;
@@ -1005,7 +1005,7 @@ yield:
nlr_pop();
fastn[0] = obj1;
return MP_VM_RETURN_EXCEPTION;
-#ifndef MICROPY_USE_COMPUTED_GOTO
+#if !MICROPY_USE_COMPUTED_GOTO
}
#endif
}