Commit Graph

8596 Commits

Author SHA1 Message Date
Damien George c7e8c6f7de py/gc: Execute finaliser code in a protected environment.
If a finaliser raises an exception then it must not propagate through the
GC sweep function.  This patch protects against such a thing by running
finaliser code via the mp_call_function_1_protected call.

This patch also adds scheduler lock/unlock calls around the finaliser
execution to further protect against any possible reentrancy issues: the
memory manager is already locked when doing a collection, but we also don't
want to allow any scheduled code to run, KeyboardInterrupts to interupt the
code, nor threads to switch.
2017-04-12 13:52:04 +10:00
Damien George 08242eed26 py/nlrsetjmp: Add check for failed NLR jump.
Also optimise the function so it only needs to call the MP_STATE_THREAD
macro once (following how other nlr code is written).
2017-04-12 13:50:31 +10:00
Damien George fe79234ca0 unix: Enabled high-quality float hashing in coverage build. 2017-04-12 13:38:17 +10:00
Damien George a73501b1d6 py/objfloat: Add implementation of high-quality float hashing.
Disabled by default.
2017-04-12 13:38:17 +10:00
Damien George 816413e4b2 py: Optimise types for common case where type has a single parent type.
The common cases for inheritance are 0 or 1 parent types, for both built-in
types (eg built-in exceptions) as well as user defined types.  So it makes
sense to optimise the case of 1 parent type by storing just the type and
not a tuple of 1 value (that value being the single parent type).

This patch makes such an optimisation.  Even though there is a bit more
code to handle the two cases (either a single type or a tuple with 2 or
more values) it helps reduce overall code size because it eliminates the
need to create a static tuple to hold single parents (eg for the built-in
exceptions).  It also helps reduce RAM usage for user defined types that
only derive from a single parent.

Changes in code size (in bytes) due to this patch:

    bare-arm:       -16
    minimal (x86): -176
    unix (x86-64): -320
    unix nanbox:   -384
    stmhal:         -64
    cc3200:         -32
    esp8266:       -108
2017-04-12 13:22:21 +10:00
Damien George fc710169b7 py/obj: Clean up and add comments describing mp_obj_type_t struct. 2017-04-12 13:20:26 +10:00
Paul Sokolovsky 81d302b8f8 zephyr/modusocket: Call net_nbuf_print_frags() in recv callback if DEBUG > 1. 2017-04-11 15:25:42 +03:00
Glenn Ruben Bakke 2d7f39855b nrf5: Adding hal_gpio.c to Makefile's source list. 2017-04-11 13:59:54 +02:00
Glenn Ruben Bakke 1e79bdf0b4 nrf5/modules/machine: Updating Pin module to register a IRQ callback upon GPIO polarity change events. 2017-04-11 13:58:58 +02:00
Glenn Ruben Bakke 81aaf6e906 nrf5/hal/gpio: Adding initial gpiote implementation to handle IRQ on polarity change on a gpio. 2017-04-11 13:57:44 +02:00
Glenn Ruben Bakke fb53bdf07c nrf5: Moving initialization of pin til after uart has been initialized for debugging purposes. This will make it possible to use uart to print out debug data when adding gpio irq handlers. 2017-04-11 13:55:01 +02:00
Glenn Ruben Bakke adf316afaa nrf5/hal/gpio: Adding some new structures and functions to register irq channels to gpio's using GPIOTE peripheral 2017-04-11 13:53:37 +02:00
Damien George e31fbd9b41 py/objint: Use unsigned arithmetic when formatting an integer.
Otherwise the edge case of the most negative integer value will not convert
correctly.
2017-04-11 15:18:35 +10:00
Damien George f66df1efc8 py/objint: Extract small int value directly because type is known. 2017-04-11 15:16:09 +10:00
Damien George 6c564aa408 unix, windows: Use core-provided KeyboardInterrupt exception object. 2017-04-11 13:31:49 +10:00
Damien George 9156c8b460 stmhal: Enable parsing of all Pin constructor args by machine.Signal. 2017-04-11 13:12:54 +10:00
Paul Sokolovsky 605ff91efd extmod/machine_signal: Support all Pin's arguments to the constructor.
This implements the orginal idea is that Signal is a subclass of Pin, and
thus can accept all the same argument as Pin, and additionally, "inverted"
param. On the practical side, it allows to avoid many enclosed parenses for
a typical declararion, e.g. for Zephyr:

Signal(Pin(("GPIO_0", 1))).

Of course, passing a Pin to Signal constructor is still supported and is the
most generic form (e.g. Unix port will only support such form, as it doesn't
have "builtin" Pins), what's introduces here is just practical readability
optimization.

"value" kwarg is treated as applying to a Signal (i.e. accounts for possible
inversion).
2017-04-11 00:12:20 +03:00
Damien George 79ce664952 py/runtime: When init'ing kbd intr exc, use tuple ptr instead of object. 2017-04-10 17:07:26 +10:00
Damien George ee86de1f1a py: Make sure that static emg-exc-buffer is aligned to size of mp_obj_t.
This buffer is used to allocate objects temporarily, and such objects
require that their underlying memory be correctly aligned for their data
type.  Aligning for mp_obj_t should be sufficient for emergency exceptions,
but in general the memory buffer should aligned to the maximum alignment of
the machine (eg on a 32-bit machine with mp_obj_t being 4 bytes, a double
may not be correctly aligned).

This patch fixes a bug for certain nan-boxing builds, where mp_obj_t is 8
bytes and must be aligned to 8 bytes (even though the machine is 32 bit).
2017-04-10 16:02:56 +10:00
Glenn Ruben Bakke f8c0a51f5e nrf5/hal/gpio: Adding missing include. 2017-04-09 23:47:44 +02:00
Glenn Ruben Bakke c7c2285ab9 nrf5/modules/machine: Style fix in pin object, indention. 2017-04-09 23:19:26 +02:00
Glenn Ruben Bakke 320b9ecde7 nrf5/modules/machine: Adding placeholder for irq method to pin object class. 2017-04-09 23:18:00 +02:00
Glenn Ruben Bakke 2c90d94dc7 nrf5/modules/machine: Adding pin irq type and basic functions and structures. 2017-04-09 23:16:07 +02:00
Glenn Ruben Bakke a93d462dfd nrf5/hal/gpio: Reintroducing gpio polarity toggle event to be able to reference the short form of adding high_to_low and low_to_high together. 2017-04-09 23:02:37 +02:00
Glenn Ruben Bakke 435bc5a3d4 nrf5/hal/gpio: Updating hal_gpio.h with some tab-fixes in order to make the file a bit consistent in style. 2017-04-09 21:56:28 +02:00
Glenn Ruben Bakke 8c45aca8d2 nrf5/hal/gpio: Removing toggle event from the enumeration as that will be a combination of the rising and falling together. 2017-04-09 21:54:09 +02:00
Glenn Ruben Bakke 6446105689 nrf5/modules/machine: Removing toggle event trigger as that will be a combination of the rising and falling together. 2017-04-09 21:52:57 +02:00
Glenn Ruben Bakke 32083a9443 nrf5/modules/machine: Adding new constants to pin object for polarity change triggers using the enumerated values in hal_gpio.h. 2017-04-09 21:50:11 +02:00
Glenn Ruben Bakke 07edf4f26d nrf5/hal/gpio: Adding new enumeration for input polarity change events. 2017-04-09 21:49:02 +02:00
Glenn Ruben Bakke 3b15d33809 nrf5/hal: Moving hal_gpio functions, types and defines from mphalport.h to a new hal_gpio.h. 2017-04-09 21:39:15 +02:00
Glenn Ruben Bakke 800a399182 Revert "lib/netutils: Adding some basic parsing and formating of ipv6 address strings. Only working with full length ipv6 strings. Short forms not supported at the moment (for example FE80::1, needs to be expressed as FE80:0000:0000:0000:0000:0000:0000:0001)."
This reverts commit 4344d41b36.
2017-04-09 18:58:05 +02:00
Glenn Ruben Bakke 35f9c8f37f nrf5: Removing leftover reference to deleted display module. 2017-04-09 18:55:53 +02:00
Glenn Ruben Bakke d7cfae3639 nrf5/usocket: Removing network modules related to Bluetooth 6lowpan implementation as it depends on SDK libraries for now. Will be moved to seperate working branch. 2017-04-09 18:53:58 +02:00
Glenn Ruben Bakke 4dd86178bc nrf5: Removing custom display, framebuffer and graphics module to make branch contain core components instead of playground modules. 2017-04-09 18:25:15 +02:00
Glenn Ruben Bakke a026d3475f nrf5/modules/usocket: Updating import of netutils.h after upmerge with upstream master. 2017-04-09 17:48:48 +02:00
Glenn Ruben Bakke 360243af92 Merge branch 'master' into nrf5_no_sdk 2017-04-09 17:45:32 +02:00
Glenn Ruben Bakke 5d06aa3260 nrf5/bluetooth: Add some comment on the destination of the eddystone short-url. 2017-04-09 15:52:21 +02:00
Glenn Ruben Bakke b92b55bdd0 nrf5/bluetooth: Updating Eddystone URL to point to https://goo.gl/x46FES which hosts the MicroPython WebBluetooth application which will be able to connect to the Bluetooth LE UART service of the device and create the REPL. 2017-04-09 15:36:34 +02:00
Paul Sokolovsky b87432b8fb docs/uhashlib: Deconditionalize.
Notes on WiPy incompatibilities with the standard module API are
moved under "Known issues" to its documentation.
2017-04-09 00:57:54 +03:00
Paul Sokolovsky 2e58474580 docs/usocket: Deconditionalize.
Notes on WiPy incompatibilities with the standard socket module API are
moved under "Known issues" to its documentation.
2017-04-09 00:48:28 +03:00
Paul Sokolovsky 3acace588a docs/utime: Deconditionalize description of sleep(). 2017-04-09 00:42:32 +03:00
Paul Sokolovsky 1d74559b6b docs/library/machine.UART: Remove some conditionals. 2017-04-09 00:25:27 +03:00
Paul Sokolovsky e322b2afbf cc3200/pybuart: Make parity specifications consistent with HW API.
parity=0 means even parity, parity=1 - odd.
2017-04-09 00:19:02 +03:00
Paul Sokolovsky bcf3c8bf17 docs/library/builtins: int: Add notice on byteorder param for to/from_bytes. 2017-04-09 00:06:54 +03:00
Paul Sokolovsky 0a88b44248 zephyr/machine_pin: Implement pin protocol for machine.Signal support. 2017-04-08 14:27:36 +03:00
Paul Sokolovsky e05cb4183a zephyr/modmachine: Add Signal class. 2017-04-08 00:50:19 +03:00
Paul Sokolovsky cf70f9a474 zephyr/mpconfigport.h: Fix build if usocket module is disabled. 2017-04-08 00:38:51 +03:00
Paul Sokolovsky 8ef469f7ca zephyr/modusocket: Implement accept(). 2017-04-08 00:33:09 +03:00
Paul Sokolovsky 96166ec165 zephyr/modusocket: socket_bind: Don't set recv callback on STREAM sockets.
For stream sockets, next exected operation is listen().
2017-04-08 00:30:17 +03:00
Paul Sokolovsky f1c0676a70 zephyr/modusocket: Implement listen(). 2017-04-07 16:47:10 +03:00