diff options
-rw-r--r-- | openjdk/map.xml | 25 | ||||
-rw-r--r-- | runtime/ByteCodeHelper.cs | 6 | ||||
-rw-r--r-- | runtime/ExceptionHelper.cs | 18 | ||||
-rw-r--r-- | runtime/common.cs | 2 | ||||
-rw-r--r-- | runtime/compiler.cs | 16 | ||||
-rw-r--r-- | runtime/openjdk.cs | 8 |
6 files changed, 17 insertions, 58 deletions
diff --git a/openjdk/map.xml b/openjdk/map.xml index f0e78c34..2893f924 100644 --- a/openjdk/map.xml +++ b/openjdk/map.xml @@ -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"> diff --git a/runtime/ByteCodeHelper.cs b/runtime/ByteCodeHelper.cs index b182f39e..a26d2738 100644 --- a/runtime/ByteCodeHelper.cs +++ b/runtime/ByteCodeHelper.cs @@ -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)] diff --git a/runtime/ExceptionHelper.cs b/runtime/ExceptionHelper.cs index daaceff6..064123ce 100644 --- a/runtime/ExceptionHelper.cs +++ b/runtime/ExceptionHelper.cs @@ -672,23 +672,13 @@ namespace IKVM.Internal } [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) { #if FIRST_PASS 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); @@ -728,12 +718,6 @@ namespace IKVM.Internal } [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) { #if FIRST_PASS diff --git a/runtime/common.cs b/runtime/common.cs index dcf29eb8..efea225e 100644 --- a/runtime/common.cs +++ b/runtime/common.cs @@ -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) diff --git a/runtime/compiler.cs b/runtime/compiler.cs index 2a8a3c98..862c2fc2 100644 --- a/runtime/compiler.cs +++ b/runtime/compiler.cs @@ -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 { diff --git a/runtime/openjdk.cs b/runtime/openjdk.cs index f82163fa..7d6183f6 100644 --- a/runtime/openjdk.cs +++ b/runtime/openjdk.cs @@ -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); |