Re: Optimizing in assembly language

"Joachim Durchholz" <joachim_d@gmx.de>
26 Mar 2001 13:49:40 -0500

          From comp.compilers

Related articles
[11 earlier articles]
Re: Optimizing in assembly language rhyde@transdimension.com (Randall Hyde) (2001-03-14)
Re: Optimizing in assembly language bonzini@gnu.org (2001-03-22)
Re: Optimizing in assembly language thp@hill.cs.ucr.edu (Tom Payne) (2001-03-22)
Re: Optimizing in assembly language Eric.Boon@ICT.nl (Eric Boon) (2001-03-22)
Re: Optimizing in assembly language uabbwat@uab.ericsson.se (Barry Watson) (2001-03-26)
Re: Optimizing in assembly language Martin.Ward@durham.ac.uk (2001-03-26)
Re: Optimizing in assembly language joachim_d@gmx.de (Joachim Durchholz) (2001-03-26)
Re: Optimizing in assembly language sunni@speakeasy.net (Shankar Unni) (2001-03-26)
Re: Optimizing in assembly language rhyde@transdimension.com (Randall Hyde) (2001-03-27)
| List of all articles for this month |

From: "Joachim Durchholz" <joachim_d@gmx.de>
Newsgroups: comp.compilers
Date: 26 Mar 2001 13:49:40 -0500
Organization: Compilers Central
References: 01-03-006 01-03-085 01-03-092 01-03-107
Keywords: assembler, optimize
Posted-Date: 26 Mar 2001 13:49:39 EST

Tom Payne <thp@hill.cs.ucr.edu> wrote:
>
> Once the flow graph of an assembly language program has been
> determined, I would assume that the usual optimization tricks can be
> applied. So, what are the special difficulties in determining the
> flow graph of an assembly langauge program?


Assembly is too powerful; there are too many ways to change the
control flow in unorthodox manners. For example:


The result of tail call optimization replaces a subroutine call with a
jump. The disassembler has no way of determining that a jump
instruction is really a subroutine call other than by simulating stack
evolution, and that's damn hard, in particular if the original
assembly was already optimized.


It's easy to change the return address by twiddling with stack contents.


The output of an OO compiler will generate lots of jump tables. An
assembly optimizer will have to establish that these tables are never
overwritten to do any cross-subroutine optimizations. If the OO
software places these tables in the heap (maybe because it's loading
the code dynamically), and the heap is managed by a copying garbage
collector, the disassembler will have a rather hard time determining
that the addresses in the jump table will stay unchanged. (In fact any
optimizer that sees the code of a moving garbage collector will have a
hard time establishing that the GC doesn't change the observable
system state, so this problem isn't limited to determining the flow
graph but to optimization in general. The usual solution is to
withhold the GC mechanism from the optimizer. Of course, this leaves
the combination of GC and optimization prone to bugs - the optimizer
may think that an address is fixed while it really isn't.)




And I didn't even start to think about self-modifying code, or code
that uses some writable data both for display and as a code address or
machine instruction (well, the latter techniques are luckily not very
common anymore, but you get the idea).


Regards,
Joachim


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.