dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] System.Reflection.Emit, My humble oppinion


From: Jonas Printzen
Subject: [Pnet-developers] System.Reflection.Emit, My humble oppinion
Date: Mon, 10 May 2004 14:52:42 +0200

Hi All!

This is about using Emit in a direct Run scenario.
No saving and loading...

I have been analyzing the code and tried to learn
all the stuff on the way. Basically trying to find a way
to satisfy all needs to be able to run the type.

As far as I can see the current implementation of Emit
is so hard-wired towards saving the module, that fixing
this require quite some "shotgun surgery". This mainly
because the Emit-implementation is a mix of ILImage
manipulation and stream-writing.

I tried to find a short-cut but as I found more and more
needs to satisfy the 'fix', it smelled more and more ugly.
It won't be good at all, or manageable in the future.

SUGGESTION:
Doing it right would involve at least three steps.

1)  Unit-testing.
2) Improved Image encapsulation
3) Partial rewrite under the new hood.

The goal should be that the way an image is built from
the pecoff_loader is identical to the way Emit builds the image.
Also, writing an assembly to file should assume a complete
image. All done trough a slightly tighter API ensuring integrity
and known state of the image.

ANALYSIS-DETAILS:

Emit generates an incomplete ILImage. Some tuff is there, some not.

The IL-code is written into a writer buffer. It appears that this is a
linked list of fragments not accessible by the converter. (engine/convert.c)

The ILWriter appears to duplicate stuff from the ILImage. I think removing
the duplicated logic/code would be a great win.

---------------------

Well, as usual, correct me if I'm wrong.
But I would not try to do a quick-fix on this.

/Jonas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]