logo       

Re: My second attempt at a data_xfer instruction optimization: msg#00129

emulators.bochs.devel

Subject: Re: My second attempt at a data_xfer instruction optimization


Your comment would be only valid for the functions where write_virtual_whatever is called and has no effect where read_virtual_whatever is called. It also assumes that the compiler is capable of making this type of optimization. In my experience it is never a good idea to rely on the compiler to do your dirty work because often it won't. Desired behaviour of code should be explicitly defined when possible.

Your comment about vunerability to bugs in write_virtual_whatever is valid, unfortunaly writing code that is resilient to bugs is often slow. Slow is not something we want in code that is emulating an instruction that is one of the most frequently called. In my experience writing code to be tollerant of bugs is a double edged sword. It makes a piece of code less suceptable to a bug but does nothing to correct the problem ( The bug itself ). It also may make a bug harder to find and diagnose.

My programing techniques may run afowl of common CS pratices but I base these on my experience in the real world with embedded programming.


Brian Slechta wrote:
Hi,

I am assuming that the reason the compiler could not safely remove these temporary variables is because the "data" parameter in write_virtual() is passed by pointer. Since the compiler could not prove that the value pointed to by "data" would not be manipulated in the write_virtual() functions, it could not make this substitution that you have made by hand.

As an alternative, one could also change the parameter in write_virtual_word() to "const Bit16u* const data", for example. This would allow the compiler to remove the temporaries as well since it knows the const'ness of the parameter being passed. Also, the current changes that you propose are not safe against a bug in write_virtual() that may try to manipulate (*data).

Just a thought.
Brian

Conn Clark wrote:

Hello All,

<SNIP>








--

*****************************************************************
If you live at home long enough, your parents will move out.
(Warning they may try to sell their house out from under you.)
*****************************************************************

Conn Clark
Engineering Stooge clark@xxxxxxxxxx
Electronic Systems Technology Inc. www.esteem.com

Stock Ticker Symbol ELST

"clark@xxxxxxxxxx" Copyright 2000 By Electronic Systems Technology
This email address may be used to communicate to Conn Clark
provided it is not being used for advertisement purposes, unless
prior written consent is given. This email address may not be
sold under any circumstances. All other rights reserved.



-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise