2006/08/20/14.28 – The Yasm Modular Assembler Project

2006/08/20/14.28

New optimizer merged to trunk

I merged the new optimizer to the yasm trunk in [1598]. A few commits since then have updated a few things that broke (Mkfiles mostly). If you're interested in the actual optimizer code, it starts at line 614 of section.c with a very long comment that tries to describe most of the optimizer algorithm.

How I finally ended up implementing offset-setters was with a linked list in section order. Each span (for normal span-dependent expansion) points to the next offset-setter in the section. When a span is expanded, the linked list is traversed until either all offset-setters in the section have been updated or the offset-setter's offset didn't change. E.g.:

jmp longlabel
align 8
align 16

If the jmp is expanded, the offset following align 8 may or may not move. If it doesn't move, we don't need to bother to look at the align 16, because that's guaranteed not to move.

Note the new optimizer doesn't handle the fact that an align bumping may end up moving a label *closer* to another label (thus reducing a span in length). Or rather it handles it, but the dependent bytecode won't get reduced in size. This is done for two reasons: 1) infinite loops, 2) handling this perfectly is actually NP-complete. If that much fidelity is really required, the user can always force the size of jumps, etc.

Error: Failed to load processor AddComment
No macro or processor named 'AddComment' found