[Mono-devel-list] Writing assembly
05mauben at hawken.edu
Thu Feb 12 13:39:03 EST 2004
Yeah, you should only compile the pre-written code if you are saving to an assembly.
The time to add the code is not really a problem. There is really not that much cost to generating the actual code. I think you will find that parsing the Regex and making a strategy is much more costly than is spitting out some pre generated code. Also, remember the CompileToAssembly case is not really performance critical.
As always, do concentrate on getting it working. Once you guys have that, you can look at performance. I would be happy to lend you a hand if you want it.
Am very excited to see this sort of thing working. Some day, we are probably going to be doing a compiled version of XPath/XQuery/XSLT, so it will be interesting to see another similar piece of code. (MS has this for whidbey)
>>> Eric Durand-Tremblay <eric.durand-tremblay.1 at ulaval.ca> 02/12/04 13:11 PM >>>
Thank you for the quick response.
This is not a problem, we will eventually rewrite dynamically our base
class and merge it with the dynamic assembly. (I asked out of laziness
;) ) The only problem is that it cost a lot of compile time for each
regex. An other possibility is to dynamically compile the base class
only when saving to an assembly. Hence we will keep our compile time
when compiling usual regex.
Actually, MS use base class to achieve this ( RegexRunner ) It is
exactly why we have compatibility issues. Note that we use the IMachine
Interface like mono interpreter.
For now, we concentrate on getting it all to run. We will be happy to
introduce some tweaking later.
Ben Maurer a écrit :
>No, there is not a way to do this easily. Your best option is to use a Perl script that would take the compiled class and turn it into S.R.E code to emit the same IL.
>One other possibility is that the runtime guys could hack something up for you that would copy the code from one assembly into one that is being built. However, this prevents you from using your impl on the MS runtime (eg, you cant copy just your code and compile/run on MS). Although this seems unimportant, it actually opens some unique testing possibilities. For example, you can run a run a regex on a set of random string data under MS and your impl, and see if they come out the same. Or you can do some performance testing of how fast your compiler is. Not a big deal, but if you dont have to loose it you should not.
>Also, for code that will be going into many assemblies, you should optimize it a bit by hand for size. Eg, mcs does not emit short jumps, but you can code those in yourself. There are many other ways you can work on reducing size, and some pretty cool tricks you can do in IL.
>>>>Eric Durand-Tremblay <eric.durand-tremblay.1 at ulaval.ca> 02/12/04 11:34 AM >>>
>Does anyone know a way to emit (with reflection) an already existing
>class (compiled in C#). We looked at System.Reflection.Emit namespace
>but we are only able to save dynamicaly created assembly.
>It could be usefull to do this when it is time to make our assembly
>compatible with MS runtime. (Like saving some base class to assembly)
>Eric Durand Tremblay
>Blogging : http://aeglos.dyndns.org/tip-mono
>Mono-devel-list mailing list
>Mono-devel-list at lists.ximian.com
More information about the Mono-devel-list