Re: When to call code after the GC

Jan Kotas <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.rotor
Message-ID <DD12668590C9274E9B2226FDBD02B98807B66B3F@red-msg-08.redmond.corp.microsoft.com>
MethodDesc::Call is used in the EE itself to call the managed code. Here
is an example from comutilnative.cpp:

        MethodDesc *pMD =
g_Mscorlib.GetMethod(METHOD__EXCEPTION__GET_MESSAGE);

        ARG_SLOT GetMessageArgs[] = { ObjToArgSlot(objException) };
        MessageString =
(STRINGREF)ArgSlotToObj(pMD->Call(GetMessageArgs,
METHOD__EXCEPTION__GET_MESSAGE));


In order to call your own method from the EE code, you need to add an
entry in clr\src\vm\mscorlib.h. Entry in mscorlib.h will give you the
METHOD__XXX constant. If your method has unusual signature, you may also
need to add an entry to clr\src\vm\metasig.h in order to complete the
entry in mscorlib.h.

MethodDesc::Call should be used inside
HELPER_METHOD_FRAME_BEGIN/HELPER_METHOD_FRAME_END since it needs a valid
frame to be erected.

If your method is not in mscorlib, I would recommend adding a small
method to mscorlib that will call your non-mscorlib method. Check
LoadISymWrapper method in
clr\src\BCL\System\Reflection\Emit\AssemblyBuilder.cs to see how to do
it.

-Jan

This posting is provided "AS IS" with no warranties, and confers no
rights.

-----Original Message-----
From: Discussion of the Rotor Shared Source CLI implementation
[mailto:[email protected]] On Behalf Of Ricardo Mendes
Sent: Monday, July 07, 2003 8:13 AM
To: [email protected]
Subject: [DOTNET-ROTOR] When to call code after the GC

Hello all,

What is the best place to call managed code after a GC? I tried to call
managed code after the
HELPER_METHOD_FRAME_END(); call in the
FCIMPL1(void, GCInterface::CollectGeneration, INT32 generation) method
(in
the comutilnative.cpp file)
but it just keeps on firing assertions. I want to call managed code
using
something like FFI. It would be great
to call the code I want from managed code but I don't know if it's
possible.
Any ideas regarding a place in which I can call managed code safely
after a
GC?

Thanks in advance for any help...

Ricardo Mendes
Distributed Systems Group
INESC-ID Lisbon, Portugal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.