aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-10-17unix/modusocket: Finish socket.settimeout() implementation.Paul Sokolovsky
1. Return correct error code for non-blocking vs timed out socket (POSIX returns EAGAIN for both, we want ETIMEDOUT in case of timed out socket). To achieve this, blocking/non-blocking flag is added to the mp_obj_socket_t, to avoid issuing fcntl() syscall each time EAGAIN occurs. (mp_obj_socket_t used to be 8 bytes, having some room in a standard 16-byte alloc block.) 2. Handle socket.settimeout(0) properly - in Python, that means non-blocking mode, but SO_RCVTIMEO/SO_SNDTIMEO of 0 is infinite timeout. 3. Overall, make sure that socket.settimeout() call switches blocking state as expected.
2018-10-17unix/modusocket: Initial implementation of socket.settimeout().Danielle Madeley
2018-10-15stm32/usbd_cdc_interface: Refactor USB CDC tx code to not use SOF IRQ.Damien George
Prior to this commit the USB CDC used the USB start-of-frame (SOF) IRQ to regularly check if buffered data needed to be sent out to the USB host. This wasted resources (CPU, power) if no data needed to be sent. This commit changes how the USB CDC transmits buffered data: - When new data is first available to send the data is queued immediately on the USB IN endpoint, ready to be sent as soon as possible. - Subsequent additions to the buffer (via usbd_cdc_try_tx()) will wait. - When the low-level USB driver has finished sending out the data queued in the USB IN endpoint it calls usbd_cdc_tx_ready() which immediately queues any outstanding data, waiting for the next IN frame. The benefits on this new approach are: - SOF IRQ does not need to run continuously so device has a better chance to sleep for longer, and be more responsive to other IRQs. - Because SOF IRQ is off, current consumption is reduced by a small amount, roughly 200uA when USB is connected (measured on PYBv1.0). - CDC tx throughput (USB IN) on PYBv1.0 is about 2.3 faster (USB OUT is unchanged). - When USB is connected, Python code that is executing is slightly faster because SOF IRQ no longer interrupts continuously. - On F733 with USB HS, CDC tx throughput is about the same as prior to this commit. - On F733 with USB HS, Python code is about 5% faster because of no SOF. As part of this refactor, the serial port should no longer echo initial characters when the serial port is first opened (this only used to happen rarely on USB FS, but on USB HS is was more evident).
2018-10-15stm32/usbd_cdc_interface: Handle disconnect IRQ to set VCP disconnected.Damien George
pyb.USB_VCP().isconnected() will now return False if the USB is disconnected after having previously been connected. See issue #4210.
2018-10-15py/emitnative: Put None/False/True in global native const table.Damien George
So these constant objects can be loaded by dereferencing the REG_FUN_TABLE pointer instead of loading immediate values. This reduces the size of generated native code (when such constants are used), and means that pointers to these constants are no longer stored in the assembly code.
2018-10-15py/emitnative: Push internal None rather than const obj where possible.Damien George
This shifts the work of loading the constant None object on to load_reg_stack_imm(), making the handling of None more centralised.
2018-10-15py/emitnative: Simplify viper mode handling in emit_native_import_name.Damien George
2018-10-15py/emitnative: Consolidate use of stacked immediate values to one func.Damien George
This commit adds the helper function load_reg_stack_imm() which deals with constant immediate values and converting them to Python objects if needed.
2018-10-15docs/machine.Pin: Document "hard" argument of Pin.irq method.Peter Hinch
2018-10-13docs/machine.Pin: Add note regarding irq handler argument.Peter Hinch
2018-10-13lib/utils/pyexec: Forcefully unlock the heap if locked and REPL active.Damien George
Otherwise there is really nothing that can be done, it can't be unlocked by the user because there is no way to allocate memory to execute the unlock. See issue #4205 and #4209.
2018-10-13tests/uctypes_sizeof_od: Test for using OrderedDict as struct descriptorPaul Sokolovsky
Just a copy of uctypes_sizeof.py with minimal changes.
2018-10-13extmod/moductypes: Accept OrderedDict as a structure description.Paul Sokolovsky
Using OrderedDict (i.e. stable order of fields) would for example allow to automatically calculate field offsets in structures.
2018-10-13py/emitnative: Remove unused ptr argument from ASM_CALL_IND macro.Damien George
2018-10-13py/asmthumb: Remove unused fun_ptr arg from asm_thumb_bl_ind function.Damien George
2018-10-13py/asmarm: Simplify asm_arm_bl_ind to only load via index, not literal.Damien George
The maximum index into mp_fun_table is currently less than 1024 and should stay that way to keep things efficient for all architectures, so there is no need to handle loading the pointer directly via a literal in this function.
2018-10-13py/emitnative: Load native fun table ptr from const table for all archs.Damien George
All architectures now have a dedicated register to hold the pointer to the native function table mp_fun_table, and so they all need to load this register at the start of the native function. This commit makes the loading of this register uniform across architectures by passing the pointer in the constant table for the native function, and then loading the register from the constant table. Doing it this way means that the pointer is not stored in the assembly code, helping to make the code more portable.
2018-10-13py/asmx86: Change indirect calls to load fun ptr from the native table.Damien George
Instead of storing the function pointer directly in the assembly code. This makes the generated code more independent of the runtime (so easier to relocate the code), and reduces the generated code size.
2018-10-13py/asmx86: Change stack management to reference locals by esp not ebp.Damien George
The esp register is always a fixed distance below ebp, and using esp to reference locals on the stack frees up the ebp register for general purpose use (which is important for an architecture with only 8 user registers).
2018-10-13py/asmx64: Change indirect calls to load fun ptr from the native table.Damien George
Instead of storing the function pointer directly in the assembly code. This makes the generated code more independent of the runtime (so easier to relocate the code), and reduces the generated code size.
2018-10-13py/asmx64: Change stack management to reference locals by rsp not rbp.Damien George
The rsp register is always a fixed distance below rbp, and using rsp to reference locals on the stack frees up the rbp register for general purpose use.
2018-10-11nrf/bluetooth: Set GAP_ADV_MAX_SIZE to 31 (s132/s140).Glenn Ruben Bakke
For s132 and s140, GAP_ADV_MAX_SIZE was currently set to BLE_GATT_ATT_MTU_DEFAULT, which is 23. The correct value should have been 31, but there are no define for this in the s132/s140 header files as for s110. Updating define in ble_drv.c to the correct value of 31.
2018-10-05stm32/main: Add configuration macros for board to set heap start/end.Andrew Leech
The macros are MICROPY_HEAP_START and MICROPY_HEAP_END, and if not defined by a board then the default values will be used (maximum heap from SRAM as defined by linker symbols). As part of this commit the SDRAM initialisation is moved to much earlier in main() to potentially make it available to other peripherals and avoid re-initialisation on soft-reboot. On boards with SDRAM enabled the heap has been set to use that.
2018-10-05windows/msvc: Implement file/directory type query.stijn
Add some more POSIX compatibility by adding a d_type field to the dirent structure and defining corresponding macros so listdir_next in the unix' port modos.c can use it, end result being uos.ilistdir now reports the file type.
2018-10-05windows/msvc: Fix incorrect indentation in dirent.c.stijn
2018-10-05extmod/moductypes: Remove BITFIELD from aggregate types enum.Paul Sokolovsky
This value is unused. It was an artifact of early draft design, but bitfields were optimized to use scalar one-word encoding, to allow compact encoding of typical multiple bitfields in MCU control registers.
2018-10-05docs/uselect: Describe more aspects of poll.register/modify behavior.Paul Sokolovsky
E.g., register() can be called again for the same object, while modify() will raise exception if object was not register()ed before.
2018-10-05tests/uselect_poll_basic: Add basic test for uselect.poll invariants.Paul Sokolovsky
This test doesn't check the actual I/O behavior, just "static" invariants like behavior on duplicate calls or calls when I/O object is not registered with poller.
2018-10-05unix/moduselect: Raise OSError(ENOENT) if obj to modify is not in pollerPaul Sokolovsky
Previously, the function silently succeeded. The new behavior is consistent with both baremetal uselect implementation and CPython 3.
2018-10-05tests/unix/ffi_float: Skip if strtof() is not available.Paul Sokolovsky
As the case for e.g. Android's Bionic Libc.
2018-10-02py/emitnative: Clean up unused macro and forward function declarations.Damien George
2018-10-01py/obj.h: Use uint64_t instead of mp_int_t in repr-D MP_OBJ_IS_x macros.Damien George
This follows how it's already done in MP_OBJ_IS_OBJ: the objects are considered 64-bit unsigned ints for the purpose of bitwise manipulation.
2018-10-01py/runtime: Remove comment in mp_import_name about level being 0.Damien George
A non-zero level has been supported for some time now.
2018-10-01py/runtime: Use mp_import_name to implement tail of mp_import_from.Damien George
2018-10-01docs/wipy: Fix links to network.Server, and markup for boot.py.Damien George
2018-10-01docs: Remove sphinx_selective_exclude, it's no longer used.Damien George
2018-10-01docs: Unify all the ports into one set of documentation.Damien George
With this commit there is now only one entry point into the whole documentation, which describes the general MicroPython language, and then from there there are links to information about specific platforms/ports. This commit doesn't change content (almost, it does fix a few internal links), it just reorganises things.
2018-10-01tests/run-tests: Enabled native tests that pass now that yield works.Damien George
2018-10-01py/emitnative: Implement yield and yield-from in native emitter.Damien George
This commit adds first class support for yield and yield-from in the native emitter, including send and throw support, and yields enclosed in exception handlers (which requires pulling down the NLR stack before yielding, then rebuilding it when resuming). This has been fully tested and is working on unix x86 and x86-64, and stm32. Also basic tests have been done with the esp8266 port. Performance of existing native code is unchanged.
2018-10-01py/emitnative: Reorder native state on C stack so nlr_buf_t is first.Damien George
The nlr_buf_t doesn't need to be part of the Python value stack (as it was before this commit), it's simpler to have it separated as auxiliary state that lives on the C stack. This will help adding yield support because in that case the nlr_buf_t and Python value stack live in separate memory areas (C stack and heap respectively).
2018-10-01py/asmxtensa: Use proper calculation for const table offset.Damien George
Instead of hard-coding it to 4 bytes. This allows for there to be other data stored at the very start of the emitted native code.
2018-10-01py/asmx64: Extend asm_x64_mov_reg_pcrel to accept high registers.Damien George
2018-10-01py/asmx86: Comment out unused asm_x86_nop to prevent compiler warnings.Damien George
2018-09-30py/asmthumb: Extend asm entry/exit to handle stack larger than 508 bytesDamien George
2018-09-30py/asmthumb: Clean up asm_thumb_bl_ind to use new optimised ldr helper.Damien George
2018-09-30py/asmthumb: Add wide ldr to handle larger offsets.Damien George
In particular this allows native functions on Thumb2 to index more than 32 constants in the constant table.
2018-09-29py/vm: When VM raises exception put exc obj at beginning of func state.Damien George
Instead of at end of state, n_state - 1. It was originally (way back in v1.0) put at the end of the state because the VM didn't have a pointer to the start. But now that the VM takes a mp_code_state_t pointer it does have a pointer to the start of the state so can put the exception object there. This commit saves about 30 bytes of code on all architectures, and, more importantly, reduces C-stack usage by a couple of words (8 bytes on Thumb2 and 16 bytes on x86-64) for every (non-generator) call of a bytecode function because fun_bc_call no longer needs to remember the n_state variable.
2018-09-28py/objtype: Support full object model for get/set/delitem special meths.Damien George
This makes these special methods have the same calling behaviour as other methods in a class instance (mp_convert_member_lookup() is already called by mp_obj_class_lookup()).
2018-09-28py/objtype: Remove TODO about storing attributes to classes.Damien George
This behaviour is tested in basics/class_store.py and follows CPython.
2018-09-28py/runtime: Remove nlr protection when calling __next__ in mp_resume.Damien George
And remove related comment about needing such protection when calling send. Reasoning for removal is as follows: - mp_resume is only called by the VM in YIELD_FROM opcode - if send_value != MP_OBJ_NULL then throw_value == MP_OBJ_NULL - so if __next__ or send are called then throw_value == MP_OBJ_NULL - if __next__ or send raise an exception without nlr protection then the exception will be handled by the global exception handler of the VM - this handler already has code to handle exceptions raised in YIELD_FROM, including correct handling of StopIteration - this handler doesn't handle the case of injection of GeneratorExit, but this won't be needed because throw_value == MP_OBJ_NULL Note that it's already possible for mp_resume() to raise an exception (including StopIteration) from the unprotected call to type->iternext(), so that's why the VM already has code to handle the case of exceptions coming out of mp_resume(). This commit reduces code size by a bit, and significantly reduces C stack usage when using yield-from, from 88 bytes down to 40 for Thumb2, and 152 down to 72 bytes for x86-64 (better than half). (Note that gcc doesn't seem to tail-call optimise the call from mp_resume() to mp_obj_gen_resume() so this saving in C stack usage helps all uses of yield-from.)