|
Ondea
"Because the integer
unit and FPU are separate execution units, it is possible for the processor
to execute floating-point, integer, and system instructions concurrently.
No special programming techniques are required to gain the advantages of
concurrent execution. (Floating-point instructions are placed in the instruction
stream along with the integer and system instructions.) However, concurrent
execution can cause problems for floating-point exception handlers. This
problem is related to the way the FPU signals the existence of unmasked
floating-point exceptions. (Special exception synchronization is not required
for masked floating-point exceptions, because the FPU always returns a
masked result to the destination operand.) When a floating-point exception
is unmasked and the exception condition occurs, the FPU stops further execution
of the floating-point instruction and signals the exception event. On the
next occurrence of a floating-point instruction or a WAIT/FWAIT instruction
in the instruction stream, the processor checks the ES flag in the FPU
status word for pending floating-point exceptions. It floating-point exceptions
are pending, the FPU makes an implicit call (traps) to the floating-point
software exception handler. The exception handler can then execute recovery
procedures for selected or all floating-point exceptions.
Synchronization
problems occur in the time frame between when the exception is signaled
and when it is actually handled. Because of concurrent execution, integer
or system instructions can be executed during this time frame. It is thus
possible for the source or destination operands for a floating-point instruction
that faulted to be overwritten in memory, making it impossible for the
exception handler to analyze or recover from the exception. To solve this
problem, an exception synchronizing instruction (either a floating-point
instruction or a WAIT/FWAIT instruction) can be placed immediately after
any floating-point instruction that might present a situation where state
information pertaining to a floating-point exception might be lost or corrupted.
Floating-point instructions that store data in memory are prime candidates
for synchronization." (quote from Intel Architecture Software Developers'
Manual, Volume 1: Basic Architecture, Chapter 7.9 "Floating-point exception
synchronization").
The Delphi
compiler puts FWait instructions after every statement that uses floating-point
data. This helps trapping errors during debugging, but (almost) needlessly
slows down execution of final releases.
Ondea is tool
that parses EXE files for FWait opcodes ($9B) and replaces them with Nop
opcodes ($90). No debugging info is needed. Click
here for the User Guide.
Please note that
-
removing FWait opcodes
will give a speed-boost that depends on the amount of floating-point computations
performed;
-
exception handlers may
get fooled: if the last FP instruction in a code block raises an FP exception,
it will not be reported until the next FP instruction, that may belong
to a different code block, gets executed!
-
the processed EXE file
may
not work correctly! Please do not send me e-mail such as "I've tried Ondea
on my X exe file, and now it does not work correctly, why?", I'm not going
to browse through tons of assembly codes to find what gone wrong! If it
works, fine; if it does not, just forget about it!
THIS SOFTWARE
IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Click
here to download Ondea (197 KB)!
Credits:
the PE executable
file format info is extracted using parts of the PE Information module
of the GExperts 0.97.1 by Gerald Nunn and others (http://www.gexperts.com).

|
|