Skip to content

Releases: google/emboss

v2024.1017.203246

17 Oct 20:32
73cbd98
Compare
Choose a tag to compare
Convert Location to a namedtuple, and associated cleanup (#205)

This change makes the `Location` dataclass, which does not change
frequently, into a new `SourceLocation` namedtuple, and changes the
`SourceLocation` serialization.  As a result, with this change:

*   `embossc` runs about 25% faster on a large (7kLOC) input; `python3
    -OO emboss` runs about 19% faster on the same input.
*   Serialized IR is about 45% smaller.

Details:

*   Replace the `ir_data.Location` dataclass with a new
    `parser_types.SourceLocation` namedtuple.  The rename helps clarify
    the difference between a location within source code
    (`SourceLocation`) and a location within a structure
    (`FieldLocation`).
*   Similarly, replace `ir_data.Position` with
    `parser_types.SourcePosition`.
*   Update any place that edits a `SourceLocation` with an appropriate
    assignment; e.g., `x.source_location.end = y` becomes
    `x.source_location = x.source_location._replace(end=y)`.  In most
    cases, several fields were updated consecutively; those updates are
    been merged.
*   Update the JSON serialization to use the compact format.
*   Replace `format_location()` and `format_position()` with
    `__str__()` methods on `SourceLocation` and `SourcePosition`,
    respectively.
*   Replace `parse_location()` and `parse_position()` with `from_str()`
    class methods on `SourceLocation` and `SourcePosition`,
    respectively.
*   Move the `make_location()` functionality into
    `SourceLocation.__new__()`.
*   Update `_to_dict` and `_from_dict` in `IrDataSerializer` to
    stringify and destringify `SourceLocation`.  It is tempting to
    try to do this during the JSON serialization step (with a `default=`
    parameter to `json.dumps` and an `object_hook=` parameter to
    `json.loads`), but it is tricky to get the `object_hook` to know
    when to convert.

v2024.1011.225822

11 Oct 22:58
46423da
Compare
Choose a tag to compare
Emit a warning when the cached parser is not used. (#204)

This change checks to see if the cached parser was discarded due to a
mismatch between the cached parser and the grammar specified in
module_ir.py, and, if so, emits a warning that the cached parser was not
used, along with informational messages on the nature of the mismatch.

Adjusted the "warning" color from magenta to yellow.  (This is the first
warning in Emboss, so no magenta messages would have ever been emitted.)

Adjusted the "note" color from "bright black" (dark grey) to "white"
(light grey), becaused at least some terminals display "bright black"
as just black.

v2024.1011.195933

11 Oct 19:59
bd276c4
Compare
Choose a tag to compare
Replace `WhichOneof("x")` with `which_x`.  (#197)

This change refactors `OneOfField` so that all fields in a given `oneof`
construct share the same backing attributes on their container class --
`which_{oneof name}`, which holds the (string) name of the
currently-active member of the oneof named `{oneof name}` (or `None` if
no member is active), and `_value_{oneof name}`, which holds the value
of the currently-active member (or `None`).

This avoids looping through field specs in order to do an update or to
figure out which member of a `oneof` is currently active.

Since the `WhichOneof()` method is now a trivial read of a
similarly-named attribute, it can be inlined for a small decrease in
overall code size and without sacrificing readability.

As a result of these changes, the compiler now runs 4.5% faster on my
large test `.emb`.

v2024.1010.220729

10 Oct 22:07
96675c9
Compare
Choose a tag to compare
Fix test name. (#203)

v2024.1010.183549

10 Oct 18:35
78901f9
Compare
Choose a tag to compare
Cache the generated parser tables as a .py file (#196)

This change adds a checked in, cached copy of the parser tables,
which will normally be used instead of generating a fresh set of
tables.  On my machine, this saves approximately 2.05s on first
run of `embossc`, and 4.96s after `.pyc` files have been generated.

For a small `.emb` file, those savings translate to approximately 36%
and 87% of the current total runtime, respectively.

In order to minimize frustrating cache decoherence problems, there are
two additional features:

*   When loading the cached parser, the set of grammar productions that
    were used to generate the cached parser is compared to the current
    set.  If they do not match, the cached parser is ignored, and a
    fresh parser is generated.  This allows developers to work on
    `module_ir.py` without manually regenerating the parser tables on
    every change.
*   The new `cached_parser_is_up_to_date_test` will fail if the cached
    parser text is not an *exact* match for the text that would be
    generated from a fresh run of `generate_cached_parser`.  This
    ensures that the version of `cached_parser.py` that is in the
    master Emboss repo is always up to date, no matter what might have
    changed in the source tree.

v2024.1010.180834

10 Oct 18:08
42e8514
Compare
Choose a tag to compare
Merge pull request #182 from reventlov/pylint_misc_harmless

Fix miscellaneous harmless lints.

v2024.1010.004723

10 Oct 00:47
3817c78
Compare
Choose a tag to compare
Add a page of useful links for developers. (#199)

v2024.1009.230010

09 Oct 23:00
8b25b90
Compare
Choose a tag to compare
Merge pull request #200 from reventlov/debug_stop_after_step

Add `--debug-stop-before-step` flag.

v2024.1007.192054

07 Oct 19:20
cefa726
Compare
Choose a tag to compare
Move `docs_are_up_to_date_test.py` fix instructions into asserts (#198)

v2024.1002.161650

02 Oct 16:16
886cfbb
Compare
Choose a tag to compare
Restructure ACTION and GOTO tables. (#194)

With this change, the `Parser.action` and `.goto` tables are now 2-layer
hash tables, using states as the keys for the outer tables and symbols
as the keys for the inner tables.  Functionally, this means that
`action[state, symbol]` becomes `action[state][symbol]`, and likewise
for `goto`.

This also allows the `expected` table to be eliminated, as it can be
quickly computed from `action[state]` when needed.