[Mono-dev] Question about adding opcodes
Alex Rønne Petersen
alex at alexrp.com
Mon Jun 2 07:44:07 UTC 2014
Hi,
On Mon, Jun 2, 2014 at 12:24 AM, Steven Bluen <sbluen153 at yahoo.com> wrote:
> Thanks for your response. Would you also care to explain something else please? Because I'm not sure why when I place printf calls inside the switch statement, when I run a program with Mono, all of the output is placed at the beginning, before anything else is printed to the console.
Where did you place the printfs? mono_method_to_ir () is one of the
first things that run when a method is JITed.
>
> On another note, is there an easy way to read the preprocessor macros when coding or debugging Mono's functions? Because they slow down my understanding of the code by being skipped in the debugger and because my IDE, Eclipse, can't handle some of them very well under its default settings.
I don't know of any easy way to do this. You could look at the
generated config.h, `gcc -dM -E - < /dev/null`, the
mini-{x86,arm,...}.h arch header for your platform, etc.
>
> Steven Bluen
> --------------------------------------------
> On Sun, 6/1/14, Alex Rønne Petersen <alex at alexrp.com> wrote:
>
> Subject: Re: [Mono-dev] Question about adding opcodes
> To: "Steven Bluen" <sbluen153 at yahoo.com>
> Cc: mono-devel-list at lists.ximian.com
> Date: Sunday, June 1, 2014, 6:16 AM
>
> Hi,
>
> On Sun, Jun 1, 2014 at 2:58 PM, Steven Bluen <sbluen153 at yahoo.com>
> wrote:
> > Hello,
> >
> > I am trying to add an opcode to Mono's JIT compiler and
> its interpreter to allow Mono to compile and run
> applications so that I can make a frequently used operation
> in a C# program run faster. To keep things simple and avoid
> the need for parsing, this opcode is invoked through dynamic
> methods.
>
> Adding it to the interpreter is not worth it. The
> interpreter is
> bitrotted to the point of obscurity.
>
> >
> > I am able to get Mono's JIT compiler to stop at a
> breakpoint in mono/mini/method-to-ir.c at the point where
> the opcode is added to the method's intermediate
> representation. However, it would be much appreciated if
> someone could let me know which component, source code file,
> or function of Mono's interpreter is responsible for
> interpreting the instructions that form the body of a
> dynamic method.
>
> They're parsed like any other method (from an on-disk CIL
> assembly).
> This parsing is based on the tables in mono/cil/ and is done
> in
> mono_method_to_ir () in mono/mini/method-to-ir.c. The CIL
> stream is
> simply interpreted directly. If you're adding a new CIL
> opcode
> (different from an IR opcode), add it in
> mono/cil/cil-opcodes.xml and
> handle it in mono_method_to_ir (). If you plan to also add
> an IR
> opcode (or several), you may want to consider intercepting
> an
> intrinsic method call instead of using a custom CIL opcode.
> This'll be
> portable to MS.NET as MS.NET will then just use the managed
> fallback.
>
> Regards,
> Alex
>
More information about the Mono-devel-list
mailing list