<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/py/vm.c, branch 0.8.3</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=0.8.3</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=0.8.3'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2016-11-19T00:17:56+00:00</updated>
<entry>
<title>py: Fix typo in comment.</title>
<updated>2016-11-19T00:17:56+00:00</updated>
<author>
<name>Scott Shawcroft</name>
<email>scott@chickadee.tech</email>
</author>
<published>2016-11-05T00:57:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=84edec4fad653b914ea2a3b56f0bc5c0548a68e4'/>
<id>urn:sha1:84edec4fad653b914ea2a3b56f0bc5c0548a68e4</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py/vm: Use MP_OBJ_FROM_PTR to cast a type to an object.</title>
<updated>2016-09-27T03:21:23+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-09-27T03:21:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=71fec076dc596409d85a8bfaf64bc2598c5578a2'/>
<id>urn:sha1:71fec076dc596409d85a8bfaf64bc2598c5578a2</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py: Only store the exception instance on Py stack in bytecode try block.</title>
<updated>2016-09-27T02:37:21+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-09-27T02:37:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=f040685b0cbec18feb981fdad96389a3b28b676d'/>
<id>urn:sha1:f040685b0cbec18feb981fdad96389a3b28b676d</id>
<content type='text'>
When an exception is raised and is to be handled by the VM, it is stored
on the Python value stack so the bytecode can access it.  CPython stores
3 objects on the stack for each exception: exc type, exc instance and
traceback.  uPy followed this approach, but it turns out not to be
necessary.  Instead, it is enough to store just the exception instance on
the Python value stack.  The only place where the 3 values are needed
explicitly is for the __exit__ handler of a with-statement context, but
for these cases the 3 values can be extracted from the single exception
instance.

This patch removes the need to store 3 values on the stack, and instead
just stores the exception instance.

Code size is reduced by about 50-100 bytes, the compiler and VM are
slightly simpler, generate bytecode is smaller (by 2 bytes for each try
block), and the Python value stack is reduced in size for functions that
handle exceptions.
</content>
</entry>
<entry>
<title>py: Combine 3 comprehension opcodes (list/dict/set) into 1.</title>
<updated>2016-09-19T02:28:03+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-09-18T22:46:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=adaf0d865cd6c81fb352751566460506392ed55f'/>
<id>urn:sha1:adaf0d865cd6c81fb352751566460506392ed55f</id>
<content type='text'>
With the previous patch combining 3 emit functions into 1, it now makes
sense to also combine the corresponding VM opcodes, which is what this
patch does.  This eliminates 2 opcodes which simplifies the VM and reduces
code size, in bytes: bare-arm:44, minimal:64, unix(NDEBUG,x86-64):272,
stmhal:92, esp8266:200.  Profiling (with a simple script that creates many
list/dict/set comprehensions) shows no measurable change in performance.
</content>
</entry>
<entry>
<title>py: Rename struct mp_code_state to mp_code_state_t.</title>
<updated>2016-08-27T13:21:00+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-08-27T13:21:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=581a59a456654e881a228a99f135777e0335f1e1'/>
<id>urn:sha1:581a59a456654e881a228a99f135777e0335f1e1</id>
<content type='text'>
Also at _t to mp_exc_stack pre-declaration in struct typedef.
</content>
</entry>
<entry>
<title>py: Implement a simple global interpreter lock.</title>
<updated>2016-06-28T10:28:50+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-05-26T10:42:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=4cec63a9dbed86c4332b9e7fcd56d092046193e4'/>
<id>urn:sha1:4cec63a9dbed86c4332b9e7fcd56d092046193e4</id>
<content type='text'>
This makes the VM/runtime thread safe, at the cost of not being able to
run code in parallel.
</content>
</entry>
<entry>
<title>py/vm: "yield from" didn't handle MP_OBJ_STOP_ITERATION optimization.</title>
<updated>2016-04-27T23:08:43+00:00</updated>
<author>
<name>Paul Sokolovsky</name>
<email>pfalcon@users.sourceforge.net</email>
</author>
<published>2016-04-27T22:54:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=eff85bb1dcca0602cef055986ea3b8192dea1d71'/>
<id>urn:sha1:eff85bb1dcca0602cef055986ea3b8192dea1d71</id>
<content type='text'>
E.g. crashed when yielding from already stopped generators.
</content>
</entry>
<entry>
<title>py/vm: Add macros to hook into various points in the VM.</title>
<updated>2016-02-17T09:02:19+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-02-15T22:46:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=40d8430ee3f62d48482439c080f3a058bcc7fd64'/>
<id>urn:sha1:40d8430ee3f62d48482439c080f3a058bcc7fd64</id>
<content type='text'>
These can be used to insert arbitrary checks, polling, etc into the VM.
They are left general because the VM is a highly tuned loop and it should
be up to a given port how that port wants to modify the VM internals.

One common use would be to insert a polling check, but only done after
a certain number of opcodes were executed, so as not to slow down the VM
too much.  For example:

 #define MICROPY_VM_HOOK_COUNT (30)
 #define MICROPY_VM_HOOK_INIT static uint vm_hook_divisor = MICROPY_VM_HOOK_COUNT
 #define MICROPY_VM_HOOK_POLL if (--vm_hook_divisor == 0) { \
     vm_hook_divisor = MICROPY_VM_HOOK_COUNT;
     extern void vm_hook_function(void);
     vm_hook_function();
 }
 #define MICROPY_VM_HOOK_LOOP MICROPY_VM_HOOK_POLL
 #define MICROPY_VM_HOOK_RETURN MICROPY_VM_HOOK_POLL
</content>
</entry>
<entry>
<title>py/vm: Fix popping of exception block in UNWIND_JUMP opcode.</title>
<updated>2016-02-01T16:07:21+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-02-01T16:07:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=93bb7dffd2a655dd8522114ed014077fb6b7ada7'/>
<id>urn:sha1:93bb7dffd2a655dd8522114ed014077fb6b7ada7</id>
<content type='text'>
Fixes issue #1812.
</content>
</entry>
<entry>
<title>py: Change exception traceback data to use size_t instead of mp_uint_t.</title>
<updated>2016-01-02T22:04:12+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-01-02T22:04:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=3d2daa2d03e300ac64005b8659c31f04a0f7fd53'/>
<id>urn:sha1:3d2daa2d03e300ac64005b8659c31f04a0f7fd53</id>
<content type='text'>
The traceback array stores qstrs and line numbers.  qstrs are typed as
size_t, and line numbers should safely fit in size_t as well.
</content>
</entry>
</feed>
