aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-12-29py/parse: Update debugging code to compile on 64-bit arch.Damien George
2017-12-29py/parse: Compress rule pointer table to table of offsets.Damien George
This is the sixth and final patch in a series of patches to the parser that aims to reduce code size by compressing the data corresponding to the rules of the grammar. Prior to this set of patches the rules were stored as rule_t structs with rule_id, act and arg members. And then there was a big table of pointers which allowed to lookup the address of a rule_t struct given the id of that rule. The changes that have been made are: - Breaking up of the rule_t struct into individual components, with each component in a separate array. - Removal of the rule_id part of the struct because it's not needed. - Put all the rule arg data in a big array. - Change the table of pointers to rules to a table of offsets within the array of rule arg data. The last point is what is done in this patch here and brings about the biggest decreases in code size, because an array of pointers is now an array of bytes. Code size changes for the six patches combined is: bare-arm: -644 minimal x86: -1856 unix x64: -5408 unix nanbox: -2080 stm32: -720 esp8266: -812 cc3200: -712 For the change in parser performance: it was measured on pyboard that these six patches combined gave an increase in script parse time of about 0.4%. This is due to the slightly more complicated way of looking up the data for a rule (since the 9th bit of the offset into the rule arg data table is calculated with an if statement). This is an acceptable increase in parse time considering that parsing is only done once per script (if compiled on the target).
2017-12-28py/parse: Remove rule_t struct because it's no longer needed.Damien George
2017-12-28py/parse: Pass rule_id to push_result_token, instead of passing rule_t*.Damien George
2017-12-28py/parse: Pass rule_id to push_result_rule, instead of passing rule_t*.Damien George
Reduces code size by eliminating quite a few pointer dereferences.
2017-12-28py/parse: Break rule data into separate act and arg arrays.Damien George
Instead of each rule being stored in ROM as a struct with rule_id, act and arg, the act and arg parts are now in separate arrays and the rule_id part is removed because it's not needed. This reduces code size, by roughly one byte per grammar rule, around 150 bytes.
2017-12-28py/parse: Split out rule name from rule struct into separate array.Damien George
The rule name is only used for debugging, and this patch makes things a bit cleaner by completely separating out the rule name from the rest of the rule data.
2017-12-28stm32/spi: If MICROPY_HW_SPIn_MISO undefined, do not claim pin on init.Peter D. Gray
This permits output-only SPI use.
2017-12-28py/nlr: Factor out common NLR code to macro and generic funcs in nlr.c.Damien George
Each NLR implementation (Thumb, x86, x64, xtensa, setjmp) duplicates a lot of the NLR code, specifically that dealing with pushing and popping the NLR pointer to maintain the linked-list of NLR buffers. This patch factors all of that code out of the specific implementations into generic functions in nlr.c, along with a helper macro in nlr.h. This eliminates duplicated code.
2017-12-28py/nlr: Clean up selection and config of NLR implementation.Damien George
If MICROPY_NLR_SETJMP is not enabled and the machine is auto-detected then nlr.h now defines some convenience macros for the individual NLR implementations to use (eg MICROPY_NLR_THUMB). This keeps nlr.h and the implementation in sync, and also makes the nlr_buf_t struct easier to read.
2017-12-28py/nlrthumb: Fix use of naked funcs, must only contain basic asm code.Damien George
A function with a naked attribute must only contain basic inline asm statements and no C code. For nlr_push this means removing the "return 0" statement. But for some gcc versions this induces a compiler warning so the __builtin_unreachable() line needs to be added. For nlr_jump, this function contains a combination of C code and inline asm so cannot be naked.
2017-12-26zephyr/main: Remove unused do_str() function.Paul Sokolovsky
The artifact of initial porting effort.
2017-12-26Revert "py/nlr: Factor out common NLR code to generic functions."Paul Sokolovsky
This reverts commit 6a3a742a6c9caaa2be0fd0aac7a5df4ac816081c. The above commit has number of faults starting from the motivation down to the actual implementation. 1. Faulty implementation. The original code contained functions like: NORETURN void nlr_jump(void *val) { nlr_buf_t **top_ptr = &MP_STATE_THREAD(nlr_top); nlr_buf_t *top = *top_ptr; ... __asm volatile ( "mov %0, %%edx \n" // %edx points to nlr_buf "mov 28(%%edx), %%esi \n" // load saved %esi "mov 24(%%edx), %%edi \n" // load saved %edi "mov 20(%%edx), %%ebx \n" // load saved %ebx "mov 16(%%edx), %%esp \n" // load saved %esp "mov 12(%%edx), %%ebp \n" // load saved %ebp "mov 8(%%edx), %%eax \n" // load saved %eip "mov %%eax, (%%esp) \n" // store saved %eip to stack "xor %%eax, %%eax \n" // clear return register "inc %%al \n" // increase to make 1, non-local return "ret \n" // return : // output operands : "r"(top) // input operands : // clobbered registers ); } Which clearly stated that C-level variable should be a parameter of the assembly, whcih then moved it into correct register. Whereas now it's: NORETURN void nlr_jump_tail(nlr_buf_t *top) { (void)top; __asm volatile ( "mov 28(%edx), %esi \n" // load saved %esi "mov 24(%edx), %edi \n" // load saved %edi "mov 20(%edx), %ebx \n" // load saved %ebx "mov 16(%edx), %esp \n" // load saved %esp "mov 12(%edx), %ebp \n" // load saved %ebp "mov 8(%edx), %eax \n" // load saved %eip "mov %eax, (%esp) \n" // store saved %eip to stack "xor %eax, %eax \n" // clear return register "inc %al \n" // increase to make 1, non-local return "ret \n" // return ); for (;;); // needed to silence compiler warning } Which just tries to perform operations on a completely random register (edx in this case). The outcome is the expected: saving the pure random luck of the compiler putting the right value in the random register above, there's a crash. 2. Non-critical assessment. The original commit message says "There is a small overhead introduced (typically 1 machine instruction)". That machine instruction is a call if a compiler doesn't perform tail optimization (happens regularly), and it's 1 instruction only with the broken code shown above, fixing it requires adding more. With inefficiencies already presented in the NLR code, the overhead becomes "considerable" (several times more than 1%), not "small". The commit message also says "This eliminates duplicated code.". An obvious way to eliminate duplication would be to factor out common code to macros, not introduce overhead and breakage like above. 3. Faulty motivation. All this started with a report of warnings/errors happening for a niche compiler. It could have been solved in one the direct ways: a) fixing it just for affected compiler(s); b) rewriting it in proper assembly (like it was before BTW); c) by not doing anything at all, MICROPY_NLR_SETJMP exists exactly to address minor-impact cases like thar (where a) or b) are not applicable). Instead, a backwards "solution" was put forward, leading to all the issues above. The best action thus appears to be revert and rework, not trying to work around what went haywire in the first place.
2017-12-26zephyr/Makefile: clean: Clean libmicropython.a too.Paul Sokolovsky
2017-12-23docs/library/index: Elaborate uPy libraries intro.Paul Sokolovsky
2017-12-23stm32/i2c: Support more I2C baudrates for F746, and more F7 MCUs.Damien George
2017-12-23stm32/i2c: Fix bug with I2C4 initialisation.Damien George
2017-12-23stm32/uart: Support board configs with CTS/RTS on UART6.Damien George
2017-12-22esp8266/Makefile: Remove commented-out unused lines.Damien George
These were copied from the stm32 port (then stmhal) at the very beginning of this port, with the anticipation that the esp8266 port would have board definition files with a list of valid pins and their names. But that has not been implemented and likely won't be, so remove the corresponding lines from the Makefile.
2017-12-22drivers/sdcard: Support old SD cards (<=2GB).Ayke van Laethem
2017-12-22esp32/README: Update toolchain setup.Ayke van Laethem
2017-12-22stm32/uart: Add support for 7-bit modes: 7N1 and 7N2.Peter D. Gray
2017-12-22stm32: Allow to build a board without any hardware I2C ports defined.Damien George
This patch adds in internal config value MICROPY_HW_ENABLE_HW_I2C that is automatically configured, and enabled only if one or more hardware I2C ports are defined in the mpconfigboard.h file. If none are defined then the pyb.I2C class is excluded from the build, along with all supporting code. The machine.I2C class will still be available for software I2C. Disabling all hardware I2C on an F4 board saves around 10,000 bytes of code and 200 bytes of RAM.
2017-12-22stm32: Use corrected capitalization of HAL_SD_CardStateTypedef.Peter D. Gray
It was originally TypeDef. STM32L4 only supports Typedef and F4/F7 have legacy macros in stm32_hal_legacy.h to support both.
2017-12-20tests/basics/memoryerror: Add test for out-of-memory using realloc.Damien George
2017-12-20py/malloc: Remove unneeded code checking m_malloc return value.Damien George
m_malloc already checks for a failed allocation so there's no need to check for it in m_malloc0.
2017-12-20qemu-arm/test_main: Include setjmp.h because it's used by gc_collect.Damien George
And it's no longer unconditionally included by nlr.h, only if NLR_SETJMP is defined.
2017-12-20py/nlr: Factor out common NLR code to generic functions.Damien George
Each NLR implementation (Thumb, x86, x64, xtensa, setjmp) duplicates a lot of the NLR code, specifically that dealing with pushing and popping the NLR pointer to maintain the linked-list of NLR buffers. This patch factors all of that code out of the specific implementations into generic functions in nlr.c. This eliminates duplicated code. The factoring also allows to make the machine-specific NLR code pure assembler code, thus allowing nlrthumb.c to use naked function attributes in the correct way (naked functions can only have basic inline assembler code in them). There is a small overhead introduced (typically 1 machine instruction) because now the generic nlr_jump() must call nlr_jump_tail() rather than them being one combined function.
2017-12-19unix/mpconfigport_coverage.h: Enable MICROPY_PY_IO_RESOURCE_STREAM.Damien George
Where possible it's important to test all code in the code base.
2017-12-19py/modio: Use correct config macro to enable resource_stream function.Damien George
2017-12-19tests/extmod: Add some uctypes tests to improve coverage of that module.Damien George
2017-12-19tests: Add some more tests to improve coverage of py/parse.c.Damien George
2017-12-19py/mpz: Apply a small code-size optimisation.Damien George
2017-12-19tests/basics/builtin_pow3: Add tests for edge cases of pow3.Damien George
2017-12-19py/mpz: Fix pow3 function so it handles the case when 3rd arg is 1.Damien George
In this case the result should always be 0, even if 2nd arg is 0.
2017-12-19tests/basics/generator_pend_throw: Add test for just-started generator.Damien George
2017-12-19tests/unix: Add test for printf with %lx format.Damien George
2017-12-19tests/float/builtin_float_hash: Add test to improve objfloat.c coverage.Damien George
2017-12-19tests/extmod/uhashlib_sha256: Add test for hashing 56 bytes of data.Damien George
2017-12-19py/objset: Remove unneeded check from set_equal.Damien George
set_equal is called only from set_binary_op, and this guarantees that the second arg to set_equal is always a set or frozenset. So there is no need to do a further check.
2017-12-19tests/basics: Add more set tests to improve coverage of py/objset.c.Damien George
2017-12-19py/map: Don't include ordered-dict mutating code when not needed.Damien George
2017-12-19py/runtime: Remove unnecessary break statements from switch.Damien George
2017-12-18esp32/machine_hw_spi: Remove unnecessary white space for consistency.Damien George
2017-12-18esp32/machine_hw_spi: Fix large HW SPI transfers by splitting them up.Eric Poulsen
Breaks up HW SPI transfers into maximum chunks of 32736 bits (4092 bytes), because this is the maximum that the underlying ESP IDF will accept.
2017-12-16.travis.yml: Build and test strict stackless build.Paul Sokolovsky
Previously, testing of stackless build happened (manually) in travis-stackless branch. However, stackless offers important featureset, so it's worth to test it as a part of the main CI. Strict stackless is used because it's the "real" stackless build, which avoids using C stack as much as possible (non-strict just prefers heap over C stack, but may end up using the latter).
2017-12-16unix/mpconfigport.h: Allow to override stackless options from commandline.Paul Sokolovsky
2017-12-16unix/Makefile: coverage: Allow user to pass CFLAGS_EXTRA.Paul Sokolovsky
This build sets CFLAGS_EXTRA itself, but preserve user's value as passed on make command line/etc.
2017-12-16docs/packages: Explicitly recommend usage of setuptools instead of distutils.Paul Sokolovsky
2017-12-16docs/packages: Use "install_dir/" in examples.Paul Sokolovsky