| Commit message (Collapse) | Author | Age |
|
|
|
|
|
|
|
|
|
|
| |
This fixes a long standing problem that viper code generation gave
terrible error messages, and actually no errors on pyboard where
assertions are disabled.
Now all compile-time errors are raised as proper Python exceptions, and
are of type ViperTypeError.
Addresses issue #940.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previous to this patch the printing mechanism was a bit of a tangled
mess. This patch attempts to consolidate printing into one interface.
All (non-debug) printing now uses the mp_print* family of functions,
mainly mp_printf. All these functions take an mp_print_t structure as
their first argument, and this structure defines the printing backend
through the "print_strn" function of said structure.
Printing from the uPy core can reach the platform-defined print code via
two paths: either through mp_sys_stdout_obj (defined pert port) in
conjunction with mp_stream_write; or through the mp_plat_print structure
which uses the MP_PLAT_PRINT_STRN macro to define how string are printed
on the platform. The former is only used when MICROPY_PY_IO is defined.
With this new scheme printing is generally more efficient (less layers
to go through, less arguments to pass), and, given an mp_print_t*
structure, one can call mp_print_str for efficiency instead of
mp_printf("%s", ...). Code size is also reduced by around 200 bytes on
Thumb2 archs.
|
|
|
|
|
|
| |
This simplifies the API for objects and reduces code size (by around 400
bytes on Thumb2, and around 2k on x86). Performance impact was measured
with Pystone score, but change was barely noticeable.
|
|
|
|
| |
This is so all memory requests go through the same interface.
|
|
|
|
|
|
|
|
| |
This makes exception traceback info self contained (ie doesn't rely on
list object, which was a bit of a hack), reduces code size, and reduces
RAM footprint of exception by eliminating the list object.
Addresses part of issue #1126.
|
|
|
|
|
| |
Still too shy to implement UnicodeEncodeError which was really needed for
micropython-lib case.
|
|
|
|
|
|
| |
Traceback allocation for exception will now never lead to recursive
MemoryError exception - if there's no memory for traceback, it simply
won't be created.
|
|
|
|
|
| |
They are directly cast to str object, skipping allocation of formatting
buffer.
|
|
|
|
|
|
|
|
| |
This patch allows to reuse vstr memory when creating str/bytes object.
This improves memory usage.
Also saves code ROM: 128 bytes on stmhal, 92 bytes on bare-arm, and 88
bytes on unix x64.
|
|
|
|
| |
Reduces stmhal code size by about 250 bytes.
|
|
|
|
|
|
| |
This patch consolidates all global variables in py/ core into one place,
in a global structure. Root pointers are all located together to make
GC tracing easier and more efficient.
|
|
|
|
| |
Addresses issue #1022.
|
|
|
|
|
|
| |
gc.enable/disable are now the same as CPython: they just control whether
automatic garbage collection is enabled or not. If disabled, you can
still allocate heap memory, and initiate a manual collection.
|
|
|
|
|
|
|
|
|
|
|
| |
This allows to implement KeyboardInterrupt on unix, and a much safer
ctrl-C in stmhal port. First ctrl-C is a soft one, with hope that VM
will notice it; second ctrl-C is a hard one that kills anything (for
both unix and stmhal).
One needs to check for a pending exception in the VM only for jump
opcodes. Others can't produce an infinite loop (infinite recursion is
caught by stack check).
|
|
|
|
|
| |
It's purpose is for internal errors that are not catastrophic (ie not as
bad as RuntimeError). Since we don't use it, we don't need it.
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
In CPython IOError (and EnvironmentError) is deprecated and aliased to
OSError. All modules that used to raise IOError now raise OSError (or a
derived exception).
In Micro Python we never used IOError (except 1 place, incorrectly) and
so don't need to keep it.
See http://legacy.python.org/dev/peps/pep-3151/ for background.
|
|
|
|
| |
Addresses issue #864.
|
|
|
|
| |
Part of code cleanup, working towards resolving issue #50.
|
|
|
|
| |
Part of code cleanup, to resolve issue #50.
|
|
|
|
| |
Addressing issue #50, still some way to go yet.
|
|
|
|
|
|
|
|
|
|
|
|
| |
These functions are generally 1 machine instruction, and are used in
critical code, so makes sense to have them inline.
Also leave these functions uninverted (ie 0 means enable, 1 means
disable) and provide macro constants if you really need to distinguish
the states. This makes for smaller code as well (combined with
inlining).
Applied to teensy port as well.
|
|
|
|
| |
Factored irq functions into a separate file.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The user code should call micropython.alloc_emergency_exception_buf(size)
where size is the size of the buffer used to print the argument
passed to the exception.
With the test code from #732, and a call to
micropython.alloc_emergenncy_exception_buf(100) the following error is
now printed:
```python
>>> import heartbeat_irq
Uncaught exception in Timer(4) interrupt handler
Traceback (most recent call last):
File "0://heartbeat_irq.py", line 14, in heartbeat_cb
NameError: name 'led' is not defined
```
|
|
|
|
| |
See discussion in issue #50.
|
| |
|
|
|
|
|
|
| |
handling.
Step 1 fixes #732
|
| |
|
|
|
|
|
| |
This removes need for some casts (at least, more than it adds need
for new casts!).
|
|
|
|
| |
Addresses issue #598.
|
|\
| |
| | |
Allow compilation of unix port under clang on OS X
|
| |
| |
| |
| | |
override in vmentrytable.h
|
|/ |
|
|
|
|
|
| |
Likely there are other functions that should be renamed, but this is a
start.
|
|
|
|
|
|
|
| |
Blanket wide to all .c and .h files. Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.
Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
|
|
|
|
| |
Specifically, nlr.h does.
|
| |
|
|
|
|
| |
This is ugly, just as expected.
|
|
|
|
| |
To avoid pointer-to-field GC problem.
|
| |
|
|
|
|
|
|
| |
Previously, a failed malloc/realloc would throw an exception, which was
not caught. I think it's better to keep the parser free from NLR
(exception throwing), hence this patch.
|
| |
|
|
|
|
|
|
| |
This does not affect code size or performance when debugging turned off.
To address issue #420.
|
|
|
|
| |
A malloc/realloc fail now throws MemoryError.
|
|
|
|
|
|
|
| |
One of the reason for separate "message" (besides still unfulfilled desire to
optimize memory usage) was apparent special handling of exception with
messages by CPython. Well, the message is still just an exception argument,
it just printed specially. Implement that with PRINT_EXC printing format.
|
|
|
|
|
|
|
| |
Mostly just a global search and replace. Except rt_is_true which
becomes mp_obj_is_true.
Still would like to tidy up some of the names, but this will do for now.
|
| |
|
|
|
|
| |
Addresses issue #388.
|
|
|
|
|
| |
To comply with Python semantics and allow use of mp_obj_is_subclass_fast()
for exception matching.
|