circuitpython/py
Damien George 66ae8c9f49 py: Tidy up variables in VM, probably fixes subtle bugs.
Things get tricky when using the nlr code to catch exceptions.  Need to
ensure that the variables (stack layout) in the exception handler are
the same as in the bit protected by the exception handler.

Prior to this patch there were a few bugs.  1) The constant
mp_const_MemoryError_obj was being preloaded to a specific location on
the stack at the start of the function.  But this location on the stack
was being overwritten in the opcode loop (since it didn't think that
variable would ever be referenced again), and so when an exception
occurred, the variable holding the address of MemoryError was corrupt.
2) The FOR_ITER opcode detection in the exception handler used sp, which
may or may not contain the right value coming out of the main opcode
loop.

With this patch there is a clear separation of variables used in the
opcode loop and in the exception handler (should fix issue (2) above).
Furthermore, nlr_raise is no longer used in the opcode loop.  Instead,
it jumps directly into the exception handler.  This tells the C compiler
more about the possible code flow, and means that it should have the
same stack layout for the exception handler.  This should fix issue (1)
above.  Indeed, the generated (ARM) assembler has been checked explicitly,
and with 'goto exception_handler', the problem with &MemoryError is
fixed.

This may now fix problems with rge-sm, and probably many other subtle
bugs yet to show themselves.  Incidentally, rge-sm now passes on
pyboard (with a reduced range of integration)!

Main lesson: nlr is tricky.  Don't use nlr_push unless you know what you
are doing!  Luckily, it's not used in many places.  Using nlr_raise/jump
is fine.
2014-04-17 16:50:23 +01:00
..
asmthumb.c
asmthumb.h
asmx64.c
asmx64.h
bc.h
bc0.h py: Make all LOAD_FAST ops check for unbound local. 2014-04-12 18:20:40 +01:00
binary.c
binary.h
builtin.c
builtin.h
builtinevex.c
builtinimport.c
builtintables.c
builtintables.h py: Make globals and locals proper dictionary objects. 2014-04-05 22:36:42 +01:00
compile.c
compile.h
emit.h
emitbc.c
emitcommon.c
emitcpy.c
emitglue.c
emitglue.h py: Remove unique_codes from emitglue.c. Replace with pointers. 2014-04-13 11:04:33 +01:00
emitinlinethumb.c
emitnative.c
emitpass1.c
formatfloat.c
formatfloat.h
gc.c
gc.h
grammar.h
lexer.c
lexer.h
lexerstr.c
lexerunix.c py: Adjust #includes in lexerunix.c. 2014-04-13 13:25:05 +01:00
lexerunix.h
makeqstrdata.py
malloc.c
map.c py: Revert revert for allocation policy of set hash table. 2014-04-07 01:16:17 +01:00
misc.h
mkenv.mk Replace some Makefile commands with variables in py/mkenv.mk 2014-04-07 01:35:45 +01:00
mkrules.mk
modarray.c
modcollections.c
modio.c
modmath.c
modmicropython.c
modstruct.c
modsys.c
mpconfig.h
mpz.c
mpz.h Add string formatting support for longlong and mpz. 2014-04-07 11:38:45 -07:00
nlr.h
nlrthumb.S
nlrx64.S Add a check for NULL nlr_top in nlr_jump. 2014-04-08 14:08:14 +00:00
nlrx86.S Add a check for NULL nlr_top in nlr_jump. 2014-04-08 14:08:14 +00:00
obj.c
obj.h
objarray.c binary: Rename array accessors for clarity. 2014-04-11 03:58:49 +03:00
objarray.h py: Make bytearray a proper type. 2014-04-08 22:11:40 +03:00
objbool.c
objboundmeth.c Rename rt_* to mp_*. 2014-03-30 13:35:08 +01:00
objcell.c
objclosure.c
objcomplex.c
objdict.c
objenumerate.c
objexcept.c
objfilter.c
objfloat.c
objfun.c py: Fix mp_get_buffer, and use it in more places. 2014-04-13 12:08:52 +01:00
objgenerator.c
objgenerator.h
objgetitemiter.c
objint.c
objint.h
objint_longlong.c
objint_mpz.c
objlist.c
objlist.h
objmap.c
objmodule.c
objmodule.h
objnamedtuple.c
objnone.c
objobject.c
objproperty.c
objrange.c
objset.c
objslice.c
objstr.c
objstr.h py: Add builtin functions bin and oct, and some tests for them. 2014-04-15 22:03:55 +01:00
objtuple.c py: Remove useless implementations of NOT_EQUAL in binary_op's. 2014-04-12 00:20:39 +01:00
objtuple.h
objtype.c
objzip.c objzip: Use mp_identity(). 2014-03-30 23:30:15 +03:00
opmethods.c
parse.c
parse.h
parsehelper.c
parsehelper.h
parsenum.c
parsenum.h
parsenumbase.c
parsenumbase.h py: Implement bit-shift and not operations for mpz. 2014-03-01 19:50:50 +00:00
pfenv.c
pfenv.h
py-version.sh
py.mk
qstr.c qstr, objstr: Make sure that valid hash != 0, treat 0 as "not computed". 2014-04-14 01:43:01 +03:00
qstr.h
qstrdefs.h
repl.c
repl.h
runtime.c py: Don't assert but go to unsupported_op in mp_binary_op for small int. 2014-04-17 16:26:50 +01:00
runtime.h
runtime0.h
scope.c
scope.h
sequence.c
showbc.c
smallint.c
smallint.h
stream.c
stream.h stream: Add generic unbuffered iternext method. 2014-01-20 18:42:08 +02:00
unicode.c py: Make form-feed character a space (following C isspace). 2014-04-10 11:39:36 +01:00
vm.c py: Tidy up variables in VM, probably fixes subtle bugs. 2014-04-17 16:50:23 +01:00
vmentrytable.h
vstr.c