diff options
author | Kaz Kylheku <kkylheku@sierrawireless.com> | 2019-01-31 06:52:09 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-01-31 06:52:09 -0800 |
commit | d3c9f43a229fec71887d9c87836074f8a4313f5a (patch) | |
tree | 30d17ec1fd5fe557332e59aa64baf3661f3450ac /txr.1 | |
parent | 3330b1593c5d591aecbacfdae5a06ade661d9fd6 (diff) | |
download | txr-d3c9f43a229fec71887d9c87836074f8a4313f5a.tar.gz txr-d3c9f43a229fec71887d9c87836074f8a4313f5a.tar.bz2 txr-d3c9f43a229fec71887d9c87836074f8a4313f5a.zip |
compiler: de-dupe strings and bignum literals.
Let's squash duplicate strings and bignum integers in the
virtual machine data tables. We can safely do it for these
objects. For lists and vectors, things are tricky because
these aggregates can contain circularity; so we leave those
alone for now.
Text processing code can generate a lot of duplicate strings.
For instance `@a @b @c` generates three copies of the " " literal.
* share/txr/stdlib/compiler.tl (*dedup*): New special
variable. This is our de-dupe table, but it is globally
nil, so that we don't retain cruft between compile jobs.
(dedup): New function.
(get-dreg): Map the incoming object through dedup.
(dreg-key): New function. This converts a literal object to key for
the dreg hash. Objects that can be de-duped represent themselves.
Objects that cannot be de-duped are keyed by a gensym.
(compiler get-dreg): Use dreg-key to reduce the incoming object to a
key, and work with that, with the effect that strings, characters and
numbers in the data table get de-duped: multiple occurrences of a
character, string or number in the code get the same dreg.
(usr:compile-toplevel, usr:with-compilation-unit): Establish a
dedup hash for the dynamically enclosed compile job. If one is
already established by the surroundign dynamic environment,
then use that one, otherwise create a new hash.
Diffstat (limited to 'txr.1')
0 files changed, 0 insertions, 0 deletions