зеркало из https://github.com/mono/ikvm-fork.git
Removed exception mapping methods from Throwable and consolidated into a single method (actually, two methods, but the dynamic one should not be necessary and should be removed later).
This commit is contained in:
Родитель
64563f9af9
Коммит
ce4dfa49da
|
@ -943,31 +943,6 @@
|
|||
<exceptionMapping />
|
||||
</body>
|
||||
</method>
|
||||
<method name="__<map>" sig="(Ljava.lang.Throwable;Z)Ljava.lang.Throwable;" modifiers="public static">
|
||||
<attribute type="IKVM.Attributes.HideFromJavaAttribute" sig="()V" />
|
||||
<attribute type="System.ComponentModel.EditorBrowsableAttribute" sig="(Lcli.System.ComponentModel.EditorBrowsableState;)V">
|
||||
<parameter>Never</parameter>
|
||||
</attribute>
|
||||
<body>
|
||||
<ldarg_0 />
|
||||
<ldarg_1 />
|
||||
<call type="IKVM.Internal.ExceptionHelper" name="MapExceptionFast" sig="(Ljava.lang.Throwable;Z)Ljava.lang.Throwable;" />
|
||||
<ret />
|
||||
</body>
|
||||
</method>
|
||||
<method name="__<map>" sig="(Ljava.lang.Throwable;Lcli.System.Type;Z)Ljava.lang.Throwable;" modifiers="public static">
|
||||
<attribute type="IKVM.Attributes.HideFromJavaAttribute" sig="()V" />
|
||||
<attribute type="System.ComponentModel.EditorBrowsableAttribute" sig="(Lcli.System.ComponentModel.EditorBrowsableState;)V">
|
||||
<parameter>Never</parameter>
|
||||
</attribute>
|
||||
<body>
|
||||
<ldarg_0 />
|
||||
<ldarg_1 />
|
||||
<ldarg_2 />
|
||||
<call type="IKVM.Internal.ExceptionHelper" name="MapException" sig="(Ljava.lang.Throwable;Lcli.System.Type;Z)Ljava.lang.Throwable;" />
|
||||
<ret />
|
||||
</body>
|
||||
</method>
|
||||
<method name="__<unmap>" sig="(Ljava.lang.Throwable;)Ljava.lang.Throwable;" modifiers="public static">
|
||||
<attribute type="IKVM.Attributes.HideFromJavaAttribute" sig="()V" />
|
||||
<attribute type="System.ComponentModel.EditorBrowsableAttribute" sig="(Lcli.System.ComponentModel.EditorBrowsableState;)V">
|
||||
|
|
|
@ -818,6 +818,12 @@ namespace IKVM.Runtime
|
|||
{
|
||||
return (T)ExceptionHelper.MapException(x, typeof(T), (mode & MapFlags.NoRemapping) == 0, (mode & MapFlags.Unused) != 0);
|
||||
}
|
||||
|
||||
[HideFromJava]
|
||||
public static Exception MapExceptionDynamic(Exception x, Type type, MapFlags mode)
|
||||
{
|
||||
return ExceptionHelper.MapException(x, type, (mode & MapFlags.NoRemapping) == 0, (mode & MapFlags.Unused) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
|
|
|
@ -671,16 +671,6 @@ namespace IKVM.Internal
|
|||
#endif
|
||||
}
|
||||
|
||||
[HideFromJava]
|
||||
internal static Exception MapExceptionFast(Exception x, bool remap)
|
||||
{
|
||||
#if FIRST_PASS
|
||||
return null;
|
||||
#else
|
||||
return MapException(x, null, remap);
|
||||
#endif
|
||||
}
|
||||
|
||||
[HideFromJava]
|
||||
private static Exception MapTypeInitializeException(TypeInitializationException t, Type handler)
|
||||
{
|
||||
|
@ -688,7 +678,7 @@ namespace IKVM.Internal
|
|||
return null;
|
||||
#else
|
||||
bool wrapped = false;
|
||||
Exception r = MapExceptionFast(t.InnerException, true);
|
||||
Exception r = MapException(t.InnerException, typeof(Exception), true, false);
|
||||
if (!(r is java.lang.Error))
|
||||
{
|
||||
r = new java.lang.ExceptionInInitializerError(r);
|
||||
|
@ -727,12 +717,6 @@ namespace IKVM.Internal
|
|||
#endif
|
||||
}
|
||||
|
||||
[HideFromJava]
|
||||
internal static Exception MapException(Exception x, Type handler, bool remap)
|
||||
{
|
||||
return MapException(x, handler, remap, false);
|
||||
}
|
||||
|
||||
[HideFromJava]
|
||||
internal static Exception MapException(Exception x, Type handler, bool remap, bool unused)
|
||||
{
|
||||
|
|
|
@ -441,7 +441,7 @@ namespace IKVM.NativeCode.ikvm.runtime
|
|||
[HideFromJava]
|
||||
public static Exception mapException(Exception x)
|
||||
{
|
||||
return ExceptionHelper.MapExceptionFast(x, true);
|
||||
return ExceptionHelper.MapException(x, typeof(Exception), true, false);
|
||||
}
|
||||
|
||||
public static Exception unmapException(Exception x)
|
||||
|
|
|
@ -78,6 +78,7 @@ static class ByteCodeHelperMethods
|
|||
internal static readonly MethodInfo volatileWriteDouble;
|
||||
internal static readonly MethodInfo volatileWriteLong;
|
||||
internal static readonly MethodInfo mapException;
|
||||
internal static readonly MethodInfo mapExceptionDynamic;
|
||||
|
||||
static ByteCodeHelperMethods()
|
||||
{
|
||||
|
@ -122,6 +123,7 @@ static class ByteCodeHelperMethods
|
|||
volatileWriteDouble = typeofByteCodeHelper.GetMethod("VolatileWrite", new Type[] { Types.Double.MakeByRefType(), Types.Double });
|
||||
volatileWriteLong = typeofByteCodeHelper.GetMethod("VolatileWrite", new Type[] { Types.Int64.MakeByRefType(), Types.Int64 });
|
||||
mapException = typeofByteCodeHelper.GetMethod("MapException");
|
||||
mapExceptionDynamic = typeofByteCodeHelper.GetMethod("MapExceptionDynamic");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,8 +153,6 @@ struct MethodKey : IEquatable<MethodKey>
|
|||
|
||||
sealed class Compiler
|
||||
{
|
||||
private static readonly MethodInfo mapExceptionMethod;
|
||||
internal static readonly MethodInfo mapExceptionFastMethod;
|
||||
private static readonly MethodInfo unmapExceptionMethod;
|
||||
private static readonly MethodInfo fixateExceptionMethod;
|
||||
private static readonly MethodInfo suppressFillInStackTraceMethod;
|
||||
|
@ -205,12 +205,7 @@ sealed class Compiler
|
|||
// HACK we need to special case core compilation, because the __<map> methods are HideFromJava
|
||||
if(java_lang_Throwable.TypeAsBaseType is TypeBuilder)
|
||||
{
|
||||
MethodWrapper mw = java_lang_Throwable.GetMethodWrapper("__<map>", "(Ljava.lang.Throwable;Lcli.System.Type;Z)Ljava.lang.Throwable;", false);
|
||||
mw.Link();
|
||||
mapExceptionMethod = (MethodInfo)mw.GetMethod();
|
||||
mw = java_lang_Throwable.GetMethodWrapper("__<map>", "(Ljava.lang.Throwable;Z)Ljava.lang.Throwable;", false);
|
||||
mw.Link();
|
||||
mapExceptionFastMethod = (MethodInfo)mw.GetMethod();
|
||||
MethodWrapper mw;
|
||||
mw = java_lang_Throwable.GetMethodWrapper("__<suppressFillInStackTrace>", "()V", false);
|
||||
mw.Link();
|
||||
suppressFillInStackTraceMethod = (MethodInfo)mw.GetMethod();
|
||||
|
@ -223,8 +218,6 @@ sealed class Compiler
|
|||
}
|
||||
else
|
||||
{
|
||||
mapExceptionMethod = java_lang_Throwable.TypeAsBaseType.GetMethod("__<map>", new Type[] { Types.Exception, Types.Type, Types.Boolean });
|
||||
mapExceptionFastMethod = java_lang_Throwable.TypeAsBaseType.GetMethod("__<map>", new Type[] { Types.Exception, Types.Boolean });
|
||||
suppressFillInStackTraceMethod = java_lang_Throwable.TypeAsBaseType.GetMethod("__<suppressFillInStackTrace>", Type.EmptyTypes);
|
||||
unmapExceptionMethod = java_lang_Throwable.TypeAsBaseType.GetMethod("__<unmap>", new Type[] { Types.Exception });
|
||||
fixateExceptionMethod = java_lang_Throwable.TypeAsBaseType.GetMethod("__<fixate>", new Type[] { Types.Exception });
|
||||
|
@ -1335,7 +1328,8 @@ sealed class Compiler
|
|||
ilGenerator.Emit(OpCodes.Ldstr, exceptionTypeWrapper.Name);
|
||||
ilGenerator.Emit(OpCodes.Call, ByteCodeHelperMethods.DynamicGetTypeAsExceptionType);
|
||||
ilGenerator.Emit(remap ? OpCodes.Ldc_I4_1 : OpCodes.Ldc_I4_0);
|
||||
ilGenerator.Emit(OpCodes.Call, mapExceptionMethod);
|
||||
ilGenerator.LazyEmitLdc_I4(flags | (remap ? 0 : 1));
|
||||
ilGenerator.Emit(OpCodes.Call, ByteCodeHelperMethods.mapExceptionDynamic);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -6243,8 +6243,8 @@ namespace IKVM.NativeCode.sun.reflect
|
|||
ilgen.Emit(OpCodes.Ceq);
|
||||
ilgen.Emit(OpCodes.Brtrue_S, label);
|
||||
}
|
||||
ilgen.Emit(OpCodes.Ldc_I4_1);
|
||||
ilgen.Emit(OpCodes.Call, Compiler.mapExceptionFastMethod);
|
||||
ilgen.Emit(OpCodes.Ldc_I4_0);
|
||||
ilgen.Emit(OpCodes.Call, ByteCodeHelperMethods.mapException.MakeGenericMethod(Types.Exception));
|
||||
ilgen.Emit(OpCodes.Newobj, invocationTargetExceptionCtor);
|
||||
ilgen.MarkLabel(label);
|
||||
ilgen.Emit(OpCodes.Throw);
|
||||
|
@ -6549,8 +6549,8 @@ namespace IKVM.NativeCode.sun.reflect
|
|||
ilgen.Emit(OpCodes.Ceq);
|
||||
CodeEmitterLabel label = ilgen.DefineLabel();
|
||||
ilgen.Emit(OpCodes.Brtrue_S, label);
|
||||
ilgen.Emit(OpCodes.Ldc_I4_1);
|
||||
ilgen.Emit(OpCodes.Call, Compiler.mapExceptionFastMethod);
|
||||
ilgen.Emit(OpCodes.Ldc_I4_0);
|
||||
ilgen.Emit(OpCodes.Call, ByteCodeHelperMethods.mapException.MakeGenericMethod(Types.Exception));
|
||||
ilgen.Emit(OpCodes.Newobj, FastMethodAccessorImpl.invocationTargetExceptionCtor);
|
||||
ilgen.MarkLabel(label);
|
||||
ilgen.Emit(OpCodes.Throw);
|
||||
|
|
Загрузка…
Ссылка в новой задаче