<feed xmlns='http://www.w3.org/2005/Atom'>
<title>suspect-devices/circuitpython/py/emitbc.c, branch v1.8.7</title>
<subtitle>CircuitPython - a Python implementation for teaching coding with microcontrollers</subtitle>
<id>https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=v1.8.7</id>
<link rel='self' href='https://git.suspectdevices.com/suspect-devices/circuitpython/atom?h=v1.8.7'/>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/'/>
<updated>2016-10-31T20:21:22+00:00</updated>
<entry>
<title>py: remove asserts that are always true in emitbc.c</title>
<updated>2016-10-31T20:21:22+00:00</updated>
<author>
<name>Pavol Rusnak</name>
<email>stick@gk2.sk</email>
</author>
<published>2016-10-25T09:05:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=7ffc959c00707c8328d3e8235e9c4741f227c25c'/>
<id>urn:sha1:7ffc959c00707c8328d3e8235e9c4741f227c25c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>py/emitbc: Remove/refactor unreachable code, to improve coverage.</title>
<updated>2016-09-27T05:46:50+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-09-27T05:46:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=7385b018edaca5c8cbbd1b2d8a6a10a63d93150d'/>
<id>urn:sha1:7385b018edaca5c8cbbd1b2d8a6a10a63d93150d</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: Combine 3 comprehension emit functions (list/dict/set) into 1.</title>
<updated>2016-09-19T02:23:31+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-09-18T13:59:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=a5624bf3818c573611b2b7bfc755e27de97f64e4'/>
<id>urn:sha1:a5624bf3818c573611b2b7bfc755e27de97f64e4</id>
<content type='text'>
The 3 kinds of comprehensions are similar enough that merging their emit
functions reduces code size.  Decreases in code size in bytes are:
bare-arm:24, minimal:96, unix(NDEBUG,x86-64):328, stmhal:80, esp8266:76.
</content>
</entry>
<entry>
<title>py: Combine continuous block of emit steps into with_cleanup emit call.</title>
<updated>2016-04-07T07:50:38+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-04-07T07:50:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=ce8b4e87494a11f389de7629e82043d6fb70284e'/>
<id>urn:sha1:ce8b4e87494a11f389de7629e82043d6fb70284e</id>
<content type='text'>
Because different emitters need to handle with-cleanup in different ways.
</content>
</entry>
<entry>
<title>py: Add MICROPY_DYNAMIC_COMPILER option to config compiler at runtime.</title>
<updated>2016-02-25T10:05:46+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2016-02-11T22:30:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=ea23520403777f9b026f49245d39f8be1ccdbdac'/>
<id>urn:sha1:ea23520403777f9b026f49245d39f8be1ccdbdac</id>
<content type='text'>
This new compile-time option allows to make the bytecode compiler
configurable at runtime by setting the fields in the mp_dynamic_compiler
structure.  By using this feature, the compiler can generate bytecode
that targets any MicroPython runtime/VM, regardless of the host and
target compile-time settings.

Options so far that fall under this dynamic setting are:
- maximum number of bits that a small int can hold;
- whether caching of lookups is used in the bytecode;
- whether to use unicode strings or not (lexer behaviour differs, and
  therefore generated string constants differ).
</content>
</entry>
<entry>
<title>py: Add MICROPY_ENABLE_COMPILER and MICROPY_PY_BUILTINS_EVAL_EXEC opts.</title>
<updated>2015-12-18T12:35:44+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2015-12-18T12:35:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=dd5353a4054024a411aa343a22ffcd16195a16ad'/>
<id>urn:sha1:dd5353a4054024a411aa343a22ffcd16195a16ad</id>
<content type='text'>
MICROPY_ENABLE_COMPILER can be used to enable/disable the entire compiler,
which is useful when only loading of pre-compiled bytecode is supported.
It is enabled by default.

MICROPY_PY_BUILTINS_EVAL_EXEC controls support of eval and exec builtin
functions.  By default they are only included if MICROPY_ENABLE_COMPILER
is enabled.

Disabling both options saves about 40k of code size on 32-bit x86.
</content>
</entry>
<entry>
<title>py: Make UNARY_OP_NOT a first-class op, to agree with Py not semantics.</title>
<updated>2015-12-10T22:19:48+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2015-12-08T12:28:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=bdbe8c9ae21559f6dc0b8e1ad84b7bbec2a04726'/>
<id>urn:sha1:bdbe8c9ae21559f6dc0b8e1ad84b7bbec2a04726</id>
<content type='text'>
Fixes #1684 and makes "not" match Python semantics.  The code is also
simplified (the separate MP_BC_NOT opcode is removed) and the patch saves
68 bytes for bare-arm/ and 52 bytes for minimal/.

Previously "not x" was implemented as !mp_unary_op(x, MP_UNARY_OP_BOOL),
so any given object only needs to implement MP_UNARY_OP_BOOL (and the VM
had a special opcode to do the ! bit).

With this patch "not x" is implemented as mp_unary_op(x, MP_UNARY_OP_NOT),
but this operation is caught at the start of mp_unary_op and dispatched as
!mp_obj_is_true(x).  mp_obj_is_true has special logic to test for
truthness, and is the correct way to handle the not operation.
</content>
</entry>
<entry>
<title>py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.</title>
<updated>2015-11-29T14:25:35+00:00</updated>
<author>
<name>Damien George</name>
<email>damien.p.george@gmail.com</email>
</author>
<published>2015-11-27T17:01:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.suspectdevices.com/suspect-devices/circuitpython/commit/?id=999cedb90ff0827cdb9dfe0e4faa6ebc1739d271'/>
<id>urn:sha1:999cedb90ff0827cdb9dfe0e4faa6ebc1739d271</id>
<content type='text'>
This allows the mp_obj_t type to be configured to something other than a
pointer-sized primitive type.

This patch also includes additional changes to allow the code to compile
when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of
mp_uint_t, and various casts.
</content>
</entry>
</feed>
