Re: Redundant IL generated by the compiler
- From: Ciaran O''Donnell <CiaranODonnell@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 12 Feb 2007 04:05:01 -0800
I agree in doing things right the first time to if you wanted this done
'correctly' in IL, perhaps you should have coded it that way as you knew that
you didnt need the s variable. If you remove the first assignment to s and
put the readline call as the param to the parse call then the IL is removed.
The compiler is doing what you told it to do.
So if you are that concerned with doing it right first time and not wasting
time compiling those statements and storing them, you need to optimise your
code. The compiler cant as you could still attach debuigging components and
expect to see a value in the field s.
--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"Anthony Paul" wrote:
I agree with you that the emphasis should be on the JIT when it comes.
to optimization; however, I'm a firm believer of doing things right the
first time around. I've read another thread (in which you've been
involved) that was rather interesting regarding this very subject and
am aware that perhaps the MSIL shouldn't be highly optimized (ie. loop
unrolling) because the JIT would do a better job of it seeing that it's
aware of the underlying platform. I can see that now and though I'm not
in the position to agree or disagree I see that there may be undesired
consequences and that's good enough for me. However, in this specific
case I see redundancy in the code that has nothing to do with
optimization... it's just redundant, dead code that does nothing but
contribute to bloat. It's a minor thing really, maybe I'm just being
anal about it but this is probably due to my having learned how to
program in a time when one would drool all over 32K of memory, 1 mhz
processors were the "bomb", and data was stored on tape or floppies.
Ahhh, the good ol' days!! :D
Cheers!
Anthony
p.s. Oh, and shame on you! The C# compiler team should NEVER make any
assumptions! :D
If the C# compiler team knows (for certain) that the JIT will optimise
away those statements when there is no debugger attached, what's the
downside of making it easier to debug even in release mode?
I would imagine that it makes for simpler compiler code - and given
that you'll end up with multiple high level language compilers but only
one JIT, I'd rather the optimisation went into the JIT than the high
level language compilers.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
- Follow-Ups:
- Re: Redundant IL generated by the compiler
- From: Anthony Paul
- Re: Redundant IL generated by the compiler
- Prev by Date: Games
- Next by Date: Re: AppDomains and sharing threadpool
- Previous by thread: Games
- Next by thread: Re: Redundant IL generated by the compiler
- Index(es):
Relevant Pages
|