Skip to content

Commit

Permalink
Introduce insGroup/instrDesc backwards navigation (#80840)
Browse files Browse the repository at this point in the history
* Introduce insGroup/instrDesc backwards navigation

Currently, it is only possible to walk forwards in insGroup/instrDesc
data: insGroup are in a single-linked list, and variable-sized
instrDesc are packed into a memory array where function `emitSizeOfInsDsc()`
can tell you the size of an instrDesc, and `emitAdvanceInstrDesc()`
can advance an `instrDesc*` forward, but there is no facility for
walking to the previous instrDesc.

This change introduces a `igPrev` pointer so the insGroup list is
doubly-linked. Also, each instrDesc is annotated with 4 or 5 bits of
data indicating how large the previous instruction in the buffer is,
so it is possible to find it by subtracting that size from a `instrDesc*`.
Also, each insGroup maintains an `igLastIns` pointer to the last instruction
in the group, to allow seeding the backwards walk.

The instrDesc backwards walk data is taken from the "small constant" area,
so some small constants get pushed to using larger instrDesc sizes.

Walking backwards is done using `emitGetLastIns()` to find the last
instruction in the function, and `emitPrevID()` to walk to the previous one.

This information is currently only used in the JitDump.

Basic measurement of the benchmarks SPMI collection showed about a 2.5% increase
in emitter memory usage.

* Fix one type

* Put code under EMIT_BACKWARDS_NAVIGATION define

* Disable backwards navigation
  • Loading branch information
BruceForstall authored Feb 9, 2023
1 parent c77d687 commit d067431
Show file tree
Hide file tree
Showing 3 changed files with 331 additions and 79 deletions.
Loading

0 comments on commit d067431

Please sign in to comment.