[Mono-devel-list] JIT, MonoCompile

Kaushik Srenevasan kaushik at vfemail.net
Sun Jan 23 20:18:28 EST 2005


Hi,

 

I've been trying to insert some code into every JITted method by modifying
the mono_codegen function in mini.c.

 

I've added the following function in mini.c

 

Void foo( void )

{

printf( "." );

}

 

And then the following lines 

 

Mono_add_patch_info( cfg, code - cfg->native_code, MONO_PATCH_INFO_ABS,
foo); X86_call_code( code, 0 );

 

This works and my function gets called each time.

 

But earlier I tried inserting only

X86_call_code( code, foo )

 

And I got a segfault.

 

I thought this would work because all that x86_call_code does ( as far as I
understood ) is to emit a call <offset> instruction into the code stream.
And since I am calling a function that neither takes any parameters nor
returns any, I wouldn't be corrupting the stack either. But I fail to
understand why it segfaulted.

 

Why is a call to mono_add_patch_info needed?

 

How does the runtime make use of MonoCompile?

 

Thanks,

Regards,

Krish

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050124/45579aa0/attachment.html 


More information about the Mono-devel-list mailing list