summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Moseley <danmose@microsoft.com>2017-01-30 10:38:28 -0700
committerGitHub <noreply@github.com>2017-01-30 10:38:28 -0700
commitdafad808aba25d940a64568d24d83ee04beebaf2 (patch)
tree3f50579506360024e176aeeb941cf490369dfda4 /src
parent5e61ff96c21b5caca03084cb64379a650832e7d6 (diff)
parenta2a9b015febcc16d4a76f55ee1e76cc03927c315 (diff)
downloadcoreclr-dafad808aba25d940a64568d24d83ee04beebaf2.tar.gz
coreclr-dafad808aba25d940a64568d24d83ee04beebaf2.tar.bz2
coreclr-dafad808aba25d940a64568d24d83ee04beebaf2.zip
Merge pull request #8438 from JonHanna/fix_1764
Support filter and fault blocks in DynamicILGenerator
Diffstat (limited to 'src')
-rw-r--r--src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs43
1 files changed, 18 insertions, 25 deletions
diff --git a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
index 84994ae1e3..7b17f66b16 100644
--- a/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
+++ b/src/mscorlib/src/System/Reflection/Emit/DynamicILGenerator.cs
@@ -379,19 +379,20 @@ namespace System.Reflection.Emit
// Exception related generation
//
//
- public override Label BeginExceptionBlock()
+ public override void BeginExceptFilterBlock()
{
- return base.BeginExceptionBlock();
- }
+ // Begins an exception filter block. Emits a branch instruction to the end of the current exception block.
- public override void EndExceptionBlock()
- {
- base.EndExceptionBlock();
- }
+ if (CurrExcStackCount == 0)
+ throw new NotSupportedException(Environment.GetResourceString("Argument_NotInExceptionBlock"));
- public override void BeginExceptFilterBlock()
- {
- throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod"));
+ __ExceptionInfo current = CurrExcStack[CurrExcStackCount - 1];
+
+ Label endLabel = current.GetEndLabel();
+ Emit(OpCodes.Leave, endLabel);
+ UpdateStackSize(OpCodes.Nop, 1);
+
+ current.MarkFilterAddr(ILOffset);
}
public override void BeginCatchBlock(Type exceptionType)
@@ -412,6 +413,8 @@ namespace System.Reflection.Emit
}
this.Emit(OpCodes.Endfilter);
+
+ current.MarkCatchAddr(ILOffset, null);
}
else
{
@@ -427,24 +430,14 @@ namespace System.Reflection.Emit
// if this is a catch block the exception will be pushed on the stack and we need to update the stack info
UpdateStackSize(OpCodes.Nop, 1);
- }
- current.MarkCatchAddr(ILOffset, exceptionType);
+ current.MarkCatchAddr(ILOffset, exceptionType);
- // this is relying on too much implementation details of the base and so it's highly breaking
- // Need to have a more integreted story for exceptions
- current.m_filterAddr[current.m_currentCatch - 1] = GetTokenFor(rtType);
- }
-
- public override void BeginFaultBlock()
- {
- throw new NotSupportedException(Environment.GetResourceString("InvalidOperation_NotAllowedInDynamicMethod"));
- }
-
- public override void BeginFinallyBlock()
- {
- base.BeginFinallyBlock();
+ // this is relying on too much implementation details of the base and so it's highly breaking
+ // Need to have a more integrated story for exceptions
+ current.m_filterAddr[current.m_currentCatch - 1] = GetTokenFor(rtType);
+ }
}
//