This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] C++ patch to build the Java runtime with ENABLE_TREE_CHECKING.


>>>>> 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]