Correct way of JITing multiple modules?

Hi,

I'm trying to work out the correct way of JITing multiple modules. My original approach was to create a new ExecutionEngine for each Module, however this generates an assert failure. If I create a new ModuleProvider for each new Module and then add this to a single ExecutionEngine then I have a problem with static constructors not being run. With a single module, I can call runStaticConstructorsDestructors(). With the second one, neither ommitting this nor calling it a second time appears to work (I don't think either of these is exactly correct, since I don't want to run the static constructors on pre-existing modules twice, I just want static ctors to run in the new module).

Can anyone advise?

David

Hi,

I'm trying to work out the correct way of JITing multiple modules.
My original approach was to create a new ExecutionEngine for each
Module, however this generates an assert failure. If I create a new

Right. That won't work.

ModuleProvider for each new Module and then add this to a single
ExecutionEngine then I have a problem with static constructors not

Multiple ModuleProvider is the right solution.

being run. With a single module, I can call
runStaticConstructorsDestructors(). With the second one, neither
ommitting this nor calling it a second time appears to work (I don't
think either of these is exactly correct, since I don't want to run
the static constructors on pre-existing modules twice, I just want
static ctors to run in the new module).

You can add a new runStaticConstructorsDestructors which takes a Module as argument and runs only the static initializers for the module. You can model it after the existing runStaticConstructorsDestructors. It should be pretty straight forward.

Evan