Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #781

Re: basic question about cps

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED!nerds-end
From Stefan Monnier <monnier@iro.umontreal.ca>
Newsgroups comp.compilers
Subject Re: basic question about cps
Date Wed, 14 Nov 2012 11:13:52 -0500
Organization A noiseless patient Spider
Lines 25
Sender johnl@iecc.com
Approved comp.compilers@iecc.com
Message-ID <12-11-010@comp.compilers> (permalink)
References <12-11-004@comp.compilers>
NNTP-Posting-Host news.iecc.com
Mime-Version 1.0
Content-Type text/plain
X-Trace leila.iecc.com 1352955918 99819 64.57.183.58 (15 Nov 2012 05:05:18 GMT)
X-Complaints-To abuse@iecc.com
NNTP-Posting-Date Thu, 15 Nov 2012 05:05:18 +0000 (UTC)
Keywords analysis, code
Posted-Date 15 Nov 2012 00:05:17 EST
X-submission-address compilers@iecc.com
X-moderator-address compilers-request@iecc.com
X-FAQ-and-archives http://compilers.iecc.com
Xref csiph.com comp.compilers:781

Show key headers only | View raw


> It seems to me that if one performs the cps transformation one is left
> with many 'computed' calls (that is call to variables holding
> procedure values, namely, the continuation).

Yes.  Every additional "computed call" (aka indirect call) corresponds
to a "return" in the non-CPS version of the code.

> It seems that compiling such 'computed' calls would be much slower
> than compiling 'direct' calls to known procedures.

That's the wrong comparison: the non-CPS version wouldn't see direct
calls there, but would see `return's instead.

Also, you're talking about "compiling" being "slower": are you really
concerned about the speed of compilation, or the speed of the
generated code?

The performance of "return" versus "indirect call" depends on many
factors, but it's probably important to try and make sure that the
"return-like indirect calls" are compiled to code which the CPU
recognizes as "some sort of return", in order for the
branch-prediction to work better (CPUs keep an internal&hidden stack
to try and predict the destination of return instructions).

        Stefan

Back to comp.compilers | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

basic question about cps n.oje.bar@gmail.com - 2012-11-12 11:05 -0800
  Re: basic question about cps torbenm@diku.dk (Torben Ægidius Mogensen) - 2012-11-14 11:25 +0100
  Re: basic question about cps Stefan Monnier <monnier@iro.umontreal.ca> - 2012-11-14 11:13 -0500
    Re: basic question about cps n.oje.bar@gmail.com - 2012-11-21 09:27 -0800

csiph-web