Miguel,

The assert you are triggering occurs because of a stack imbalance. For example if you 
call some function which expects the caller to clean up the stack, but you don't do it 
- you will get this assert. In this case the assert is cause by the fact that you are 
using emit_callhelper_prof2 macro which is redefined on x86 to use __stdcall calling 
convention. If you look in Clr\src\fjit\i386\x86def.h you'll see:

#define emit_callhelper_prof2(fcn, id, arg1, arg2)  \
{                                                   \
    x86_push_imm(arg2);                             \
    x86_push_imm(arg1);                             \
    mov_constant(CALLREG, fcn);                     \
    call_register(CALLREG);                         \
}

The two arguments are pushed onto the stack but are not cleaned up. The CLR 
infrastructure expects the callback to be __stdcall function with two arguments. You 
defined your function to be __stdcall as well but it has no arguments and therefore it 
does no clean up. So if you redefine your function as static void __stdcall Prueba(int 
a, int b) the assert would disappear. The correct solution however would be to define 
you function as void __cdecl Prueba() and add another macro:

#ifndef emit_callhelper_prueba
#define emit_callhelper_prueba(fcn)                  \
{                                                    \
    callInfo.reset();                                \
    emit_callhelper_(fcn);                           \
}
#endif

Thanks,

Vladimir


-----Original Message-----
From: Miguel Tomás [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, February 12, 2003 10:22 AM
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET-ROTOR] Modification on Fjit - help

 --- Vladimir Fedorov <[EMAIL PROTECTED]> escribió:
> ...if part of your project is to create your own
> infrastructure than you can mimic your own code off
> the code for the profiler callback. In particular
> look at the emit_callhelper_prof2(...) macro in
> fjitdef.h. This macro emits the code for the call
> into the jitted function. You can create a new but
> very similar macro to call your function.
>
I tried with the emit_callhelper_prof2 macro inserting
a call to this function before the JitResult =
compileCEE_CALL();

void insertNativeCall(){
  ULONG func = (ULONG) jitInfo->getHelperFtn
(CORINFO_PRUEBA);
  UINT_PTR from = 0;
  UINT_PTR to = 0;
  emit_callhelper_prof2(func, CORINFO_PRUEBA, from,
to);
}

Where CORINFO_PRUEBA is a new helper I added in
CorInfoHelpFunc (corinfo.h) and is registered in
VMHELPDEF hlpFuncTable[] with the
JITHELPER(CORINFO_PRUEBA, prueba) macro.
the method prueba is declared as follows:
static void __stdcall Prueba();
and it only contains a printf.
I think everithing is right, however when I execute
buildall I get an Assert Failure several times with
the following message "ESP not correct on method exit.
Did you forget a leave?" in file fjitdef.h (method
void HELPER_CALL check_stack(int frameSize, BYTE* fp,
BYTE* sp{..}). If I select Retry and finish the build
process and execute clix I get the same Assert Failure
just after the method prueba has executed (just after
the printf message has appeared on the console). I
hope someone can tell me why this happens or what I am
doing wrong.

Thank you

>
>
>
> -----Original Message-----
> From: Miguel Tomás [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 04, 2003 8:12 AM
> To: [EMAIL PROTECTED]
> Subject: [DOTNET-ROTOR] Modification on Fjit - help
>
> Hi! I'm a spanish student and I've just started
> working on sscli. I'm doing some modifications on it
> but I have a problem with Fjit. I want to modify the
> jitCompile method in fjit.cpp, in particular the big
> "switch (opcode)"; when the case CEE_CALL is entered
> I want to insert a call in native code to a method
> written in C++ so every time the jitted method is
> executed it performs a call to my method before
> doing the call that it is supposed to do but I don't
> know how to do it. I hope I have explained it well.
> If anyone can help me I would be very grateful.
> Thank you.
>
> ---------------------------------
> Yahoo! Móviles
> Personaliza tu móvil con tu logo y melodía favorito

___________________________________________________
Yahoo! Móviles
Personaliza tu móvil con tu logo y melodía favorito
en http://moviles.yahoo.es

Reply via email to