summaryrefslogtreecommitdiffstatshomepage
path: root/py/qstr.c
Commit message (Collapse)AuthorAge
* all: Use the name MicroPython consistently in commentsAlexander Steffen2017-07-31
| | | | | There were several different spellings of MicroPython present in comments, when there should be only one.
* py: Fix wrong assumption that m_renew will not move if shrinkingColin Hogben2016-11-02
| | | | | | | | | | | | | | | | In both parse.c and qstr.c, an internal chunking allocator tidies up by calling m_renew to shrink an allocated chunk to the size used, and assumes that the chunk will not move. However, when MICROPY_ENABLE_GC is false, m_renew calls the system realloc, which does not guarantee this behaviour. Environments where realloc may return a different pointer include: (1) mbed-os with MBED_HEAP_STATS_ENABLED (which adds a wrapper around malloc & friends; this is where I was hit by the bug); (2) valgrind on linux (how I diagnosed it). The fix is to call m_renew_maybe with allow_move=false.
* py/qstr: Remove a comment.Damien George2016-09-19
| | | | qstrs are always null terminated so qstr_str will stay as part of the API.
* py: Don't use gc or qstr mutex when the GIL is enabled.Damien George2016-06-28
| | | | | There is no need since the GIL already makes gc and qstr operations atomic.
* py: Make interning of qstrs thread safe.Damien George2016-06-28
|
* py: Rename __QSTR_EXTRACT flag to NO_QSTR.Paul Sokolovsky2016-06-16
| | | | | It has more usages than just qstr extraction, for example, embedding (where people don't care about efficient predefined qstrs).
* py: Rework QSTR extraction to work in simple and obvious way.Paul Sokolovsky2016-04-19
| | | | | | | | | | | | When there're C files to be (re)compiled, they're all passed first to preprocessor. QSTR references are extracted from preprocessed output and split per original C file. Then all available qstr files (including those generated previously) are catenated together. Only if the resulting content has changed, the output file is written (causing almost global rebuild to pick up potentially renumbered qstr's). Otherwise, it's not updated to not cause spurious rebuilds. Related make rules are split to minimize amount of commands executed in the interim case (when some C files were updated, but no qstrs were changed).
* py: Add ability to have frozen persistent bytecode from .mpy files.Damien George2016-04-13
| | | | | | | The config variable MICROPY_MODULE_FROZEN is now made of two separate parts: MICROPY_MODULE_FROZEN_STR and MICROPY_MODULE_FROZEN_MPY. This allows to have none, either or both of frozen strings and frozen mpy files (aka frozen bytecode).
* py/qstr: Use size_t instead of mp_uint_t when counting allocated bytes.Damien George2015-12-17
|
* py: Change qstr_* functions to use size_t as the type for str len arg.Damien George2015-11-29
|
* py/qstr: Fix calc of qstr memory usage, due to new qstr chunk allocation.Damien George2015-10-13
|
* py: Make qstr hash size configurable, defaults to 2 bytes.Damien George2015-07-20
| | | | | | | This patch makes configurable, via MICROPY_QSTR_BYTES_IN_HASH, the number of bytes used for a qstr hash. It was originally fixed at 2 bytes, and now defaults to 2 bytes. Setting it to 1 byte will save ROM and RAM at a small expense of hash collisions.
* py: Improve allocation policy of qstr data.Damien George2015-07-14
| | | | | | | | | | | | | | | | | | | | Previous to this patch all interned strings lived in their own malloc'd chunk. On average this wastes N/2 bytes per interned string, where N is the number-of-bytes for a quanta of the memory allocator (16 bytes on 32 bit archs). With this patch interned strings are concatenated into the same malloc'd chunk when possible. Such chunks are enlarged inplace when possible, and shrunk to fit when a new chunk is needed. RAM savings with this patch are highly varied, but should always show an improvement (unless only 3 or 4 strings are interned). New version typically uses about 70% of previous memory for the qstr data, and can lead to savings of around 10% of total memory footprint of a running script. Costs about 120 bytes code size on Thumb2 archs (depends on how many calls to gc_realloc are made).
* py: Convert occurrences of non-debug printf to mp_printf.Damien George2015-04-16
|
* py: Add option to micropython.qstr_info() to dump actual qstrs.Damien George2015-02-10
|
* py, unix: Allow to compile with -Wsign-compare.Damien George2015-01-16
| | | | See issue #699.
* py: Never intern data of large string/bytes object; add relevant tests.Damien George2015-01-13
| | | | | | | | | | Previously to this patch all constant string/bytes objects were interned by the compiler, and this lead to crashes when the qstr was too long (noticeable now that qstr length storage defaults to 1 byte). With this patch, long string/bytes objects are never interned, and are referenced directly as constant objects within generated code using load_const_obj.
* py: Add MICROPY_QSTR_BYTES_IN_LEN config option, defaulting to 1.Damien George2015-01-11
| | | | | | | | | | | | | | | | | | This new config option sets how many fixed-number-of-bytes to use to store the length of each qstr. Previously this was hard coded to 2, but, as per issue #1056, this is considered overkill since no-one needs identifiers longer than 255 bytes. With this patch the number of bytes for the length is configurable, and defaults to 1 byte. The configuration option filters through to the makeqstrdata.py script. Code size savings going from 2 to 1 byte: - unix x64 down by 592 bytes - stmhal down by 1148 bytes - bare-arm down by 284 bytes Also has RAM savings, and will be slightly more efficient in execution.
* py: Add qstr cfg capability; generate QSTR_NULL and QSTR_ from script.Damien George2015-01-11
|
* py: Fix hard-coded hash for empty qstr (was 0x0000 now 0x1505).Damien George2015-01-11
|
* py: Put all global state together in state structures.Damien George2015-01-07
| | | | | | 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.
* py: Move to guarded includes, everywhere in py/ core.Damien George2015-01-01
| | | | Addresses issue #1022.
* py: Make gc.enable/disable just control auto-GC; alloc is still allowed.Damien George2014-10-31
| | | | | | 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.
* py: Improve memory usage debugging; better GC AT dumping.Damien George2014-10-24
| | | | In unix port, mem_info(1) now prints pretty GC alloc table.
* py: Change [u]int to mp_[u]int_t in qstr.[ch], and some other places.Damien George2014-10-03
| | | | This should pretty much resolve issue #50.
* Rename machine_(u)int_t to mp_(u)int_t.Damien George2014-07-03
| | | | See discussion in issue #50.
* py: Include mpconfig.h before all other includes.Paul Sokolovsky2014-06-21
| | | | | | It defines types used by all other headers. Fixes #691.
* py: Fix static defn in qstr; include mpconfigport.h with "" (not <>).Damien George2014-06-11
|
* Change const byte* to const char* where sensible.Damien George2014-05-25
| | | | | This removes need for some casts (at least, more than it adds need for new casts!).
* Add license header to (almost) all files.Damien George2014-05-03
| | | | | | | 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/.
* build: Simplify build directory layout by putting all headers in genhdr.Damien George2014-04-17
| | | | | Any generated headers go in $(BUILD)/genhdr/, and are #included as 'genhdr/xxx.h'.
* build directory can now be renamedAndrew Scheller2014-04-16
| | | | | | | | | The autogenerated header files have been moved about, and an extra include dir has been added, which means you can give a custom BUILD=newbuilddir option to make, and everything "just works" Also tidied up the way the different Makefiles build their include- directory flags
* qstr, objstr: Make sure that valid hash != 0, treat 0 as "not computed".Paul Sokolovsky2014-04-14
| | | | | This feature was proposed with initial hashing RFC, and is prerequisite for seamless static str object definition.
* py: Replace naive and teribble hash function with djb2.Damien George2014-03-25
|
* py: Remove name of var arg from macros with var args.Damien George2014-02-26
|
* Make DEBUG_printf() a proper function, implementation is port-dependent.Paul Sokolovsky2014-02-16
| | | | | In particular, unix outputs to stderr, to allow to run testsuite against micropython built with debug output (by redirecting stderr to /dev/null).
* Replace global "static" -> "STATIC", to allow "analysis builds". Part 2.Paul Sokolovsky2014-02-12
|
* Add qstr_info() function and bindings for unix port.Damien George2014-01-29
|
* Rework makefiles. Add proper dependency checking.Dave Hylands2014-01-24
|
* py: Implement bool unary op; tidy up unary op dispatch.Damien George2014-01-23
|
* Second stage of qstr revamp: uPy str object can be qstr or not.Damien George2014-01-22
|
* Revamp qstrs: they now include length and hash.Damien George2014-01-21
| | | | | Can now have null bytes in strings. Can define ROM qstrs per port using qstrdefsport.h
* Make qstr_init reinitialize last_pool.Dave Hylands2014-01-05
| | | | This causes the pool to get reinitialized properly on a soft-reset.
* Split qstr into pools, and put initial pool in ROM.Damien George2014-01-04
| | | | | | | | | | | | | | | | Qstr's are now split into a linked-list of qstr pools. This has 2 benefits: the first pool can be in ROM (huge benefit, since we no longer use RAM for the core qstrs), and subsequent pools use m_new for the next pool instead of m_renew (thus avoiding a huge single table for all the qstrs). Still would be better to use a hash table, but this scheme takes us part of the way (eventually convert the pools to hash tables). Also fixed bug with import. Also improved the way the module code is referenced (not magic number 1 anymore).
* Change memory allocation API to require size for free and realloc.Damien2013-12-29
|
* Fix func decls with no arguments: () -> (void).Damien2013-10-23
|
* Initial commit.Damien2013-10-04