The virtual call macros need ARG_1 and ARG_2 registers that buildCall
fills in. For example, emit_callvirt starts with:

   _ASSERTE( CALLREG != TOS_REG_1 || !inRegTOS );   \
   mov_register_indirect_to(CALLREG,                \
     (ReturnBufferFirst && sizeRetBuff) ? ARG_2 : ARG_1); \

Your helper call is corrupting ARG_1 (ecx) and ARG_2 (edx) since they
are not callee saved registers.

-Jan

-----Original Message-----
From: Discussion of the Rotor Shared Source CLI implementation
[mailto:[EMAIL PROTECTED] On Behalf Of J. Redondo
Sent: Friday, March 04, 2005 12:27 AM
To: DOTNET-ROTOR@DISCUSS.DEVELOP.COM
Subject: [DOTNET-ROTOR] Inserting a helper call into JIT Generated code

Hello,

I'm triying to insert a helper call into the code that the
compileCEE_CALLVIRT method placed the fjit.cpp file generates. I've
tested
the profiler (wich had a helper call similar to the one I'm triying to
do),
but the parameters passed to that helper are not useful for me and I
wasn't
able to mimic the structure to suit my own needs.

What I am trying to do is to make a helper call wich receives the object
and
the MethodDesc as a parameter to make some calculations, and I certainly
did
that, but I wasn't able to make it work everytime. Here is a brief
description of my code:

FJitResult compileCEE_CALLVIRT()
{
...
...//Body of the method
...
argBytes = buildCall (...); (1)
//My code was inserted here
if (...) (2)
{
    void *func = jitInfo->getHelperFtn (...);(3)

    emit_DUP_I4();
    emit_LDFLD_helper(func, targetMethod);(4)
}
}

(1) I inserted my call here because as far as I know, after buildCall
the
stack will be ordered as I need (this pointer on top).

(2) I did not perform this call for some types of methods and classes
(constructors, static methods, value classes, ...).

(3) I declared a helper like this:

HCIMPL2(void, func, Object *obj, MethodDesc *m)

(4) It migth be strange that I use this macro here, but I think it
exactly
does the operations that I need to perform the call.

As I said, the results that I'm obtaining are not completely correct.
After
several correct calls, with the parameters passed as intended (non
corrupted
data), I obtain a call to the same method several times until a "Fatal
Stack
overflow error" is shown. Additionaly, the same code seems to work
flawlessly in the compileCEE_CALL method. I've also modified the
compileCEE_LDFLD method in a similar fashion apparently without
problems. I
think that in this case I'm doing something wrong with the stack, but I
wasn't able to find what. Can anybody tell me what I'm doing wrong?

Thank you in advance,

Jose M. Redondo

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com

View archives and manage your subscription(s) at
http://discuss.develop.com

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to