Article View: borland.public.cppbuilder.nativeapi
Article #15199Re: __fastcall - Where should I use it?
From: Bob Gonder
Date: Thu, 10 Jul 2003 18:33
Date: Thu, 10 Jul 2003 18:33
40 lines
2643 bytes
2643 bytes
Andrue Cope wrote:
>Malcolm Smith
>> I have a class that improved by 13% in terms of performance
>> when I removed the __fastcall.
Yeah, classes can be tricky. Remember that member functions have a
hidden parameter *this, so fastcalls should only be on 1 or 2
parameter functions.
>Our experience is the reverse. We use __fastcall for any frequently called
>but simple function.
Yep. Functions of 3 or less parameters. I you have 4, then you don't
gain much. I never use fastcall for 4 or more parameters.
Also, functions that mostly only use the 3 parameters, and maybe one
or two locals.
Wrapper functions can benefit.
char* _fastcall Wrapper(char*dest,char*src)
{ return lstrcpyn(dest,src,7);
}
And especially wrapper wrappers:
char* _fastcall Wrapper2(char*dest)
{ return Wrapper(dest,"Default");
}
> It may be that __fastcall makes things worse for
>complex functions due to the contraints it imposes on the optimiser by
>reserving registers.
If a parameter is used late in a (complex) function, or is used
repeatedly to initalize a local, it would probably benefit from being
on the stack, thus not a fastcall candidate.
If you have several locals, it's also probably not a fastcall
candidate.
Some of these constraints might ease if you are compiling for the
Itanium with it's many registers.
Technical Details
Message-ID:
<fqargv8pcja0lsqno2vcf07ufqcd3sceds@4ax.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!newsfeed.news2me.com!newshosting.com!news-xfer2.atl.newshosting.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<oprr23nbz2bq7az6@newsgroups.borland.com> <3f0d4c19$1@newsgroups.borland.com> <VA.00001de7.00d781c2@email.address.sorry>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,cafd0a3f947fe702 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-07-10 11:40:26 PST From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: __fastcall - Where should I use it? Date: Thu, 10 Jul 2003 11:33:47 -0700 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <fqargv8pcja0lsqno2vcf07ufqcd3sceds@4ax.com> References: <oprr23nbz2bq7az6@newsgroups.borland.com> <3f0d4c19$1@newsgroups.borland.com> <VA.00001de7.00d781c2@email.address.sorry> X-Newsreader: Forte Agent 1.91/32.564 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.31.165.57 X-Trace: newsgroups.borland.com 1057861999 67.31.165.57 (10 Jul 2003 11:33:19 -0700) Lines: 42 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!newsfeed.news2me.com!newshosting.com!news-xfer2.atl.newshosting.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail