Author: Dan Newman
Date: 15:14:05 08/18/00
Go up one level in this thread
On August 18, 2000 at 17:34:01, Dann Corbit wrote: >On August 18, 2000 at 14:47:30, Oliver Roese wrote: > >>On August 17, 2000 at 18:12:50, Dann Corbit wrote: >> >>>I would be interested to see a set of functions that have been turned into a >>>class and for which the performance lost is more than 3%. >>> >>>If you don't use try/catch or RTTI, then the speed difference should be so small >>>that it is very hard to measure. I don't know why you would need RTTI for a >>>chess game unless you had some very strange chess variant where you make up new >>>piece types on the fly or something. >> >>Just you are there, i would like to know. >>I really couldnt find any explanation on the net. >>Thanks in advance:) > >I don't know how they are implemented, it's up to the compiler vendors. > >I *suspect* that under the covers try/catch is little more than >setjmp()/longjmp() calls. > The way I understand it try/catch are hideously complex under the covers. With setjmp()/longjmp() you just jump directly to the set address (as I understand it--and perhaps setting the stack pointer back, but I don't really recall...). With try/catch the stack is carefully unwound, and all objects that go out of scope as you pass backwards through all the calling routines get their destructors called. So around each throw and function call there has to be some code to handle all this... It's really nice for code that has a lot of potential resource acquisition failures or other failure types scattered throughout it and where the exception handling code would otherwise be tangled throughout the main body of the code. But in a chess program we generally allocate all resources at the start and have nothing of this sort going on during a game--with the exception (perhaps) of breaking out of the search at arbitrary times. >RTTI is expensive for obvious reasons. You have some object and you don't even >know what it is until you interrogate it. Could not possibly be as inexpensive >as a hardwired type. I haven't ever tried RTTI and can't really see where it would be useful in a chess program since we generally know the types of all our objects. OTOH, I guess you could make each piece an object of a different type and when scanning the board use RTTI to identify it. Bleah. (I'm really not sure why it was added to the language since you can easily do it yourself with what language elements were already available...) -Dan.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.