This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: Putting C++ code into gcc front end


Personally, I'd love to re-write all of Gcc in C++,
starting with using inheritance for tree nodes, so
we can actually get some static type-checking.
I don't think the issue of the people not having
C++ compilers is as important as developer convenience
and building a solid compiler:  I believe there are very
few people that have a C compiler but don't have or can't
easily get a C++ compiler.

I also think it would be very nice to combine the
two verifiers - it's a complicated algorithm, difficult
to get right, and there are lots of checks that one
or the other misses.

However, there are complications.  One problem is that
the data types are incompatible:  The compile-time
verifier uses treea, the run-time verifier uses run-time
classes and other data structures.  This difference
will presumably have to be hidden using macros or
conditional compilation.  (Compare the way jcf-reader.c
abstracts away what to do with the information read from
a .class file.)  A lot of the logic of the two verifiers
(i.e. big switch on opcodes) is similar; a large part of
the difference is the data structures - plus how we handle
the hard bits relating to subroutines.

I'm not sure the abstraction advantages of C++ helps all
that much.  The compile-time verifier is substanially
less code than the run-time verifier, though comments
some up some of the difference.  Given that both are
incomplete and have bugs (probably more in the compile-time
verifier) it's impossible to make a real comparison.

If I was doing the work, and I understood the issues and
existing code better than I do, I would replace the
subroutine-handling code in the compile-time verifier
with C code based on the algorithms and data structures
in the run-time verifier, and also merge in other missing
tests from the latter.  Then I'd hide the API (such of trees
etc) behind macros, and try plugging it into run-time
verifier.

However, that's a fair bit of work.  I think plugging the
run-time verifier into the compile-time environment *plus*
changing the boostrap framework so gcc/java can contain C++
code is also a fair bit of work.  I'll give my blessing
either way - if we can achieve consensus that using C++
in gcc/java is ok.
--
	--Per Bothner
per at bothner dot com   http://www.bothner.com/per/


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