Add an alternate string table algorithm with a fixed size hash table and
separate chaining with arrays. This eliminates large continuous memory
allocations for the string table structure. The remaining allocations
(for chains) are small, typically 8 to 64 bytes, and match well with other
small allocations which is convenient for a pool allocator.
The alternate string table is enabled with DUK_OPT_STRTAB_CHAIN and the
top level hash table size is given with DUK_OPT_STRTAB_CHAIN_SIZE. A good
starting point is -DDUK_OPT_STRTAB_CHAIN_SIZE=128.
As a result of this merge there are two string table algorithms (probing
and chaining), and heap pointer compressed variants of each. As a future
work item the two algorithms could be merged so that one algorithm could
serve both low memory and other environments well.
Other cleanup may be necessary as separate work items.
Add DUK_OPT_NO_STRICT_DECL as an experimental feature option to disable
processing "use strict" directives which can be useful when working with
legacy code (for instance, code that has "use strict" declarations but
has only been executed with an engine without strict mode support).
Add support for external strings, where only a fixed size header is allocated
from the Duktape heap, with actual string data stored behind a pointer. This
is analogous to how dynamic buffers work, except that the external string is
immutable like normal strings.
External strings are useful to reduce memory usage in low memory environments.
Duktape built-in strings and common application strings can be moved into the
application binary at compile time so that these strings only require a small
header allocation from RAM. With Duktape built-in strings mapped to external
strings, startup Duktape heap size is about 21.5 kB.
There is no API to push external strings, but the merge provides a string
intern hook (DUK_OPT_EXTSTR_INTERN_CHECK) where an application can inspect a
string about to be merged, and if the string data has been compiled into the
application binary it can return an external pointer to the string data.
Duktape will then use an external string to represent the string in question,
reducing overall RAM usage. The application can also use the hook to write
the string to memory mapped flash on demand, effectively writing string data
to flash on the run.
The merge also adds an optional macro hook DUK_OPT_EXTSTR_FREE which lets
the application know when an external string is no longer referenced by
Duktape. When strings are built into the application this hook is not
necessary, but if there is any dynamic management of flash memory mapped
strings, it may be useful.