This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C++ patch to build the Java runtime with ENABLE_TREE_CHECKING.
- To: Mark Mitchell <mark at codesourcery dot com>
- Subject: Re: [PATCH] C++ patch to build the Java runtime with ENABLE_TREE_CHECKING.
- From: Jason Merrill <jason at hound dot cygnus dot com>
- Date: 10 Jul 2000 13:05:57 -0700
- Cc: apbianco at redhat dot com, gcc-patches at gcc dot gnu dot org
- References: <14672.22821.427041.156751@deliverance.cygnus.com> <20000621003348X.mitchell@codesourcery.com> <u91z141re8.fsf@casey.soma.redhat.com> <20000710004002Q.mitchell@codesourcery.com>
>>>>> Mark Mitchell <mark@codesourcery.com> writes:
> Sure, there are lots of ways to get undefined behavior. But the
> committee went to a lot of effort to make sure that you couldn't burn
> yourself with control-flow alone. Try all the gotos, exceptions,
> loops, switch-staements, and so-forth; you can't get to a point where
> an object is in scope, but not constructed.
True.
> Computed gotos break that, and that's evil.
It would be possible to restrict them to scopes where that could never
happen; ensure that there are no non-trivial initializers at the site of a
&&label, and no cleanups at the site of a computed goto. This would break
the Java interpreter due to the initializations at the top of the function,
but they could easily be changed to assignments.
Jason> Do you have a better suggestion for doing insn dispatch in
Jason> an interpreter?
> Sure. A switch statement. If the compiler doesn't optimize that as
> well as the computed goto, then the compiler should be improved;
> there's no inherent efficiency in computed goto; all you're doing is
> building the jump-tables manually.
Fair enough. Currently interpret.cc claims a 7% improvement by doing
dispatch at the end of each insn, rather than always dispatching from the
top of the "switch". I suppose that would be an interesting optimization
for switch statements in general; optimize
while (1) switch (*pc++) {
case 'a':
...
break;
case 'b':
...
break;
}
into
switch (*pc++)
{
case 'a':
...
re_switch (*pc++);
case 'b':
...
re_switch (*pc++);
}
Jason