Re: Is Java useful for writing (C/C++) compiler

Robert A Duff <bobduff@world.std.com>
25 Apr 2000 02:31:57 -0400

          From comp.compilers

Related articles
[5 earlier articles]
Re: Is Java useful for writing (C/C++) compiler iank@bearcave.com (2000-04-20)
Re: Is Java useful for writing (C/C++) compiler jandk@easynet.co.uk (Jonathan Barker) (2000-04-20)
Re: Is Java useful for writing (C/C++) compiler dale@cs.rmit.edu.au (dale) (2000-04-21)
Re: Is Java useful for writing (C/C++) compiler dvdeug@x8b4e53cd.dhcp.okstate.edu (2000-04-21)
Re: Is Java useful for writing (C/C++) compiler nr@labrador.eecs.harvard.edu (2000-04-25)
Re: Is Java useful for writing (C/C++) compiler jandk@easynet.co.uk (Jonathan Barker) (2000-04-25)
Re: Is Java useful for writing (C/C++) compiler bobduff@world.std.com (Robert A Duff) (2000-04-25)
Re: Is Java useful for writing (C/C++) compiler guerby@acm.org (Laurent Guerby) (2000-04-26)
Re: Is Java useful for writing (C/C++) compiler dale@cs.rmit.edu.au (dale) (2000-04-27)
| List of all articles for this month |

From: Robert A Duff <bobduff@world.std.com>
Newsgroups: comp.compilers
Date: 25 Apr 2000 02:31:57 -0400
Organization: The World Public Access UNIX, Brookline, MA
References: 00-04-125 00-04-128 00-04-141 00-04-151
Keywords: performance, errors

dale <dale@cs.rmit.edu.au> writes:


> I don't think it is all that clear at all. If you consider...
>
> while not End_Of_File (File) loop
> read file
> blah blah blah
> end loop;
>
> compared to
>
> begin
> loop
> read file
> blah blah blay
> end loop
> exception
> when End_Error =>
> null;
> end;


And our esteemed moderator says:


> [I would say the relative performance of the two loops depends entirely
> on how the compiler implements exceptions. -John]


Not really. The point is that *both* loops must raise End_Error on
End_Of_File. So in the first loop, End_Of_File is tested twice (once
explicitly, and once inside the implementation of "read file"),
whereas in the second loop, the explicit test is removed.


One can imagine an optimizing compiler that folds the two tests in the
first loop, into one test (especially if "read file" is inlined). But
(for sufficiently large files), the implementation of exception
raising/handling itself is irrelevant.


- Bob
[Indeed, but one can also imagine a simple-minded compiler that emits
explicit EOF testing code at the points where the exception might be
thrown. -John]





Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.