Skip to content

Commit

Permalink
Added event keyword support for registerVM
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed Oct 7, 2022
1 parent 07cd386 commit 0d3f3bb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
28 changes: 25 additions & 3 deletions ILRuntime/Runtime/Intepreter/RegisterVM/ILIntepreter.Register.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2854,13 +2854,35 @@ public unsafe partial class ILIntepreter
bool processed = false;
if (m.IsDelegateInvoke)
{
var instance = StackObject.ToObject((esp - (m.ParameterCount + 1)), domain, mStack);
if (instance is IDelegateAdapter)
obj = StackObject.ToObject((esp - (m.ParameterCount + 1)), domain, mStack);
if (obj is IDelegateAdapter)
{
esp = ((IDelegateAdapter)instance).ILInvoke(this, esp, mStack);
esp = ((IDelegateAdapter)obj).ILInvoke(this, esp, mStack);
processed = true;
}
}
else if (ilm.IsEventAdd)
{
objRef = PrepareEventHandler(esp, ilm, mStack, out var instance);

esp = CLRRedirections.DelegateCombine(this, objRef, mStack, null, false);
obj = StackObject.ToObject(esp - 1, domain, mStack);
instance[ilm.EventFieldIndex] = obj;
Free(esp - 1);
esp--;
processed = true;
}
else if (ilm.IsEventRemove)
{
objRef = PrepareEventHandler(esp, ilm, mStack, out var instance);

esp = CLRRedirections.DelegateRemove(this, objRef, mStack, null, false);
obj = StackObject.ToObject(esp - 1, domain, mStack);
instance[ilm.EventFieldIndex] = obj;
Free(esp - 1);
esp--;
processed = true;
}
if (!processed)
{
if (code == OpCodeREnum.Callvirt)
Expand Down
2 changes: 1 addition & 1 deletion ILRuntime/Runtime/Intepreter/RegisterVM/JITCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ int InitializeFunctionParam(ref OpCodes.OpCodeR op, object token, out bool hasRe
bool noJIT = (ilm.JITFlags & ILRuntimeJITFlags.NoJIT) != ILRuntimeJITFlags.None;
bool forceInline = (ilm.JITFlags & ILRuntimeJITFlags.ForceInline) != ILRuntimeJITFlags.None;
bool hasExceptionHandler = ilm.Definition.HasBody && ilm.Definition.Body.HasExceptionHandlers;
if (!ilm.IsDelegateInvoke && !ilm.IsVirtual && !noJIT && !hasExceptionHandler && !ilm.Compiling)
if (!ilm.IsDelegateInvoke && !ilm.IsVirtual && !noJIT && !hasExceptionHandler && !ilm.Compiling && !ilm.IsEventAdd && !ilm.IsEventRemove)
{
var def = ilm.Definition;
if (!def.HasBody || forceInline)
Expand Down

0 comments on commit 0d3f3bb

Please sign in to comment.