Re: .Net applications, not optimized for CPU at all?
- From: Barry Kelly <barry.j.kelly@xxxxxxxxx>
- Date: Sun, 30 Apr 2006 02:15:28 +0100
Marco van de Voort <marcov@xxxxxxxx> wrote:
IL is based on a stack machine and compilation to native code is not
optimized that much (compared to a native compiler), so yes you may be
right that the code should be larger.
I thought JVM IL was based on stackmachine, but one of the differences of
.NET was that it was not per se, because it doesn't have to be
interpretable?
Both Java VM and MSIL are logically stack machines. The biggest
different between the two, and the one which makes a difference for
creating a somewhat performant interpreter, is that the JVM instructions
are typed (e.g. iadd vs fadd for integer addition versus floating-point
addition), while the MSIL instructions aren't. With MSIL, the
instruction types must be inferred from the state of the stack, which is
itself implied by prior stack load / typecast etc. instructions.
Since the Java VM (the CLI does this too) needs to verify its
instructions before running (to ensure that there is exactly one
possible stack representation per instruction in a method, amongst other
things) anyway, it's a pretty arbitrary distinction. It could have
chosen to tag the operation type at this stage.
Another big difference between the Java VM and MSIL is exception
handling / try-finally blocks, with the Java VM using a kind of computed
jump, whereas MSIL uses a list of ranges.
I've written compilers for both the Java VM and MSIL, so I'm pretty
familiar with the differences.
As said, IL usually is nothing more than a linearised parse tree.
This implies that all the usual compiler tricks can be applied. The
biggest limitation with both JVM and CLI as target architectures with
respect to performance in the context of a code generation for a single
method is the limit to the clever things you can do with register
allocation, pointers and stack allocation. You end up relying on the JIT
compiler to think hard, but part of the definition of a JIT compiler is
something which doesn't have time to think hard.
NGEN may do more in this area in the future, but for now the primary
advantages are the reduction of startup cost and the increase of shared
code pages.
-- Barry
.
- References:
- .Net applications, not optimized for CPU at all?
- From: Arthur Hoornweg
- Re: .Net applications, not optimized for CPU at all?
- From: Euan Garden
- Re: .Net applications, not optimized for CPU at all?
- From: Arthur Hoornweg
- Re: .Net applications, not optimized for CPU at all?
- From: Euan Garden
- Re: .Net applications, not optimized for CPU at all?
- From: Eric Grange
- Re: .Net applications, not optimized for CPU at all?
- From: Andre Kaufmann
- Re: .Net applications, not optimized for CPU at all?
- From: Marco van de Voort
- Re: .Net applications, not optimized for CPU at all?
- From: Andre Kaufmann
- Re: .Net applications, not optimized for CPU at all?
- From: Marco van de Voort
- .Net applications, not optimized for CPU at all?
- Prev by Date: Re: Vista and .NET (Win32 life may be limted)
- Next by Date: Re: The Register interview Nigel Brown
- Previous by thread: Re: .Net applications, not optimized for CPU at all?
- Next by thread: Re: .Net applications, not optimized for CPU at all?
- Index(es):
Relevant Pages
|