Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
3bb8bd89
Commit
3bb8bd89
authored
Apr 14, 2014
by
Damien George
Browse files
Make USE_COMPUTED_GOTO a config option in mpconfig.h.
Disabled by default. Enabled in unix port.
parent
0ae9c704
Changes
5
Hide whitespace changes
Inline
Side-by-side
py/mpconfig.h
View file @
3bb8bd89
...
...
@@ -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
...
...
py/objstr.c
View file @
3bb8bd89
...
...
@@ -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"
));
}
...
...
py/vm.c
View file @
3bb8bd89
...
...
@@ -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)
#if
def
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:
#if
def
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
;
#if
ndef
MICROPY_USE_COMPUTED_GOTO
#if
!
MICROPY_USE_COMPUTED_GOTO
}
#endif
}
...
...
unix/Makefile
View file @
3bb8bd89
...
...
@@ -11,7 +11,7 @@ QSTR_DEFS = qstrdefsport.h
include
../py/py.mk
# compiler settings
CFLAGS
=
-I
.
-I
$(PY_SRC)
-Wall
-Werror
-ansi
-std
=
gnu99
-DUNIX
$(CFLAGS_MOD)
$(COPT)
-DMICROPY_USE_COMPUTED_GOTO
CFLAGS
=
-I
.
-I
$(PY_SRC)
-Wall
-Werror
-ansi
-std
=
gnu99
-DUNIX
$(CFLAGS_MOD)
$(COPT)
UNAME_S
:=
$(
shell
uname
-s
)
ifeq
($(UNAME_S),Darwin)
...
...
unix/mpconfigport.h
View file @
3bb8bd89
...
...
@@ -14,6 +14,7 @@
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
#define MICROPY_PATH_MAX (PATH_MAX)
#define MICROPY_USE_COMPUTED_GOTO (1)
#define MICROPY_MOD_SYS_STDFILES (1)
// type definitions for the specific machine
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment