[Mono-list] Reference runtime internal variable in managed code

Derek Woo dkw@iseek.net
Tue, 26 Aug 2003 23:10:05 -0400


Sorry for being unclear. I am working in the context of adaptive
optimization. Maybe I would use a small example:

Method mthA {
   =20
     // Call some method B here
}

What I want to do is have the JIT patch the code of mthA as it is =
compiling
it such that it becomes:

Method mthA {
   =20
     if (condition) {
         // Call some method C
     }
     else {
         // Call some method B here
     }
}

Now there are some requirement:
1. "condition" is a reference to internal data of the runtime, e.g. the
execution count of a method, or some info that is collected from the
profiler.
2. The condition check is done as "mthA" is actually executing.

Basically, the runtime passed a reference of some data, to a piece of =
user
code. And the user code checked that data for some condition.

I can certainly do the patching in "mono_method_to_ir()". But the =
problem is
how I can enable such condition check from user code to internal data
structure of the runtime. And do it quickly.

Thanks.

Derek


> Hello,
>=20
> > I am experimenting with some ideas using mono. I hope this is not=20
> > off-topic.
> >=20
> > I want to modify the JIT of mono to insert some code to=20
> > methods when they are being JIT -ted. Specifically, I need to insert =
a=20
> > check to some internal variables declared in the mono runtime (e.g.=20
> > an int, a  single bit, etc). The problem is that these are =
"unmanaged"
stuff=20
> > existing in the runtime's address space. And I must insert  the =
check=20
> > to User's code that are "managed".
> >=20
> > I need a way to insert this check crossing the "managed" /=20
> > "unmanaged" boundary. I know the "Marshal" class would do that for =
me.=20
> > But I am guess it might be too slow. Are there other ways to do it?
Maybe the=20
> > only better way is to patch up the native code after the code gen
process?=20
> > Any insight is appreciated. Thanks.
>=20
> You should describe in more detail what you are after.  There=20
> is a pluggable profiling interface that you might want to=20
> look into (code coverage and profiling are implemented this way).
>=20
> For more technical stuff, you might want to patch directly=20
> the code generation engine.
>=20
> Miguel.
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com=20
> http://lists.ximian.com/mailman/listinfo/mono-list
>=20