Merge pull request #4373 from NattyNarwhal/haiku
authorRodrigo Kumpera <kumpera@users.noreply.github.com>
Wed, 1 Mar 2017 17:08:38 +0000 (12:08 -0500)
committerGitHub <noreply@github.com>
Wed, 1 Mar 2017 17:08:38 +0000 (12:08 -0500)
Restore Haiku support

74 files changed:
acceptance-tests/SUBMODULES.json
configure.ac
mcs/class/System.Numerics.Vectors/SR.cs [deleted file]
mcs/class/System.Numerics.Vectors/System.Numerics.Vectors-net_4_x.csproj
mcs/class/System.Numerics.Vectors/System.Numerics.Vectors.dll.sources
mcs/class/System.Numerics.Vectors/corefx/SR.cs [new file with mode: 0644]
mcs/class/System.Numerics/Makefile
mcs/class/System.Numerics/ReferenceSources/SR.cs [deleted file]
mcs/class/System.Numerics/System.Numerics-net_4_x.csproj
mcs/class/System.Numerics/System.Numerics.dll.sources
mcs/class/System.Numerics/corefx/SR.cs [new file with mode: 0644]
mcs/class/System.Numerics/corefx/Vector.cs [new file with mode: 0644]
mcs/class/System/Test/System.Net/FtpWebRequestTest.cs
mcs/class/corlib/Assembly/AssemblyInfo.cs
mono/dis/main.c
mono/metadata/assembly.c
mono/metadata/boehm-gc.c
mono/metadata/domain.c
mono/metadata/metadata.c
mono/metadata/mono-hash.c
mono/metadata/mono-hash.h
mono/metadata/null-gc.c
mono/metadata/object.c
mono/metadata/reflection.c
mono/metadata/sgen-mono.c
mono/metadata/threadpool-io.c
mono/metadata/threads.c
mono/mini/.gitignore
mono/mini/Makefile.am.in
mono/mini/alias-analysis.c
mono/mini/arrays.cs
mono/mini/basic-vectors.cs
mono/mini/debugger-agent.c
mono/mini/driver.c
mono/mini/exceptions.cs
mono/mini/generics.cs
mono/mini/interp/hacks.h [new file with mode: 0644]
mono/mini/interp/interp-internals.h [new file with mode: 0644]
mono/mini/interp/interp.c [new file with mode: 0644]
mono/mini/interp/interp.h [new file with mode: 0644]
mono/mini/interp/mintops.c [new file with mode: 0644]
mono/mini/interp/mintops.def [new file with mode: 0644]
mono/mini/interp/mintops.h [new file with mode: 0644]
mono/mini/interp/transform.c [new file with mode: 0644]
mono/mini/interpreter/hacks.h [deleted file]
mono/mini/interpreter/interp-internals.h [deleted file]
mono/mini/interpreter/interp.c [deleted file]
mono/mini/interpreter/interp.h [deleted file]
mono/mini/interpreter/mintops.c [deleted file]
mono/mini/interpreter/mintops.def [deleted file]
mono/mini/interpreter/mintops.h [deleted file]
mono/mini/interpreter/transform.c [deleted file]
mono/mini/liveness.c
mono/mini/method-to-ir.c
mono/mini/mini-arm64.c
mono/mini/mini-exceptions.c
mono/mini/mini-runtime.c
mono/mini/mini-trampolines.c
mono/mini/objects.cs
mono/mini/seq-points.c
mono/mini/tramp-amd64.c
mono/sgen/gc-internal-agnostic.h
mono/sgen/sgen-cardtable.c
mono/sgen/sgen-cardtable.h
mono/sgen/sgen-debug.c
mono/sgen/sgen-descriptor.c
mono/sgen/sgen-descriptor.h
mono/sgen/sgen-gc.c
mono/sgen/sgen-gc.h
mono/sgen/sgen-marksweep-drain-gray-stack.h
mono/sgen/sgen-marksweep.c
mono/utils/mono-conc-hashtable.c
mono/utils/mono-error.h
msvc/scripts/order.xml

index 9df7b8a5811328aafe3a0a58c0def29cf80ec5bb..1fedbe94fea1f463e15b192a8cd9d6d4592227ef 100644 (file)
@@ -18,7 +18,7 @@
   {
     "name": "ms-test-suite", 
     "url": "git@github.com:xamarin/ms-test-suite.git", 
-    "rev": "55b6637eb1de61c743323ec82db1e0cadfee5b32", 
+    "rev": "73c155f76b55839f26ba707d6d40091060e4f5d8", 
     "remote-branch": "origin/master", 
     "branch": "master", 
     "directory": "ms-test-suite"
index a01830680ca3bcd0e49219b92337bf6466648987..71f242d6fc7445db79c3518dd13e5b0f8f2f4008 100644 (file)
@@ -1432,8 +1432,6 @@ if test x$host_win32 = xno; then
 
        AC_CHECK_FUNCS(getgrgid_r)
        AC_CHECK_FUNCS(getgrnam_r)
-       AC_CHECK_FUNCS(getpwnam_r)
-       AC_CHECK_FUNCS(getpwuid_r)
        AC_CHECK_FUNCS(getresuid)
        AC_CHECK_FUNCS(setresuid)
        AC_CHECK_FUNCS(kqueue)
@@ -1454,6 +1452,11 @@ if test x$host_win32 = xno; then
        AC_CHECK_FUNCS(sched_setaffinity)
        AC_CHECK_FUNCS(sched_getcpu)
 
+       if test x$platform_android != xyes; then
+               AC_CHECK_FUNCS(getpwnam_r)
+               AC_CHECK_FUNCS(getpwuid_r)
+       fi
+
        dnl ****************************************************************
        dnl *** Check for sched_setaffinity from glibc versions before   ***
        dnl *** 2.3.4. The older versions of the function only take 2    ***
@@ -3322,7 +3325,6 @@ if test "x$host" != "x$target"; then
                TARGET=ARM;
                arch_target=arm;
                AC_DEFINE(TARGET_ARM, 1, [...])
-               AC_DEFINE(TARGET_ANDROID, 1, [...])
                ACCESS_UNALIGNED="no"
                CPPFLAGS="$CPPFLAGS -D__ARM_EABI__"
                # Can't use tls, since it depends on the runtime detection of tls offsets
@@ -3335,6 +3337,11 @@ if test "x$host" != "x$target"; then
                        CPPFLAGS="$CPPFLAGS"
                        ;;
                armv5-*-linux-androideabi*)
+                       AC_DEFINE(TARGET_ANDROID, 1, [...])
+                       CPPFLAGS="$CPPFLAGS"
+                       ;;
+               *-linux-androideabi*)
+                       AC_DEFINE(TARGET_ANDROID, 1, [...])
                        CPPFLAGS="$CPPFLAGS"
                        ;;
                esac
@@ -3354,23 +3361,33 @@ if test "x$host" != "x$target"; then
                TARGET=X86;
                arch_target=x86;
                AC_DEFINE(TARGET_X86, 1, [...])
-               AC_DEFINE(TARGET_ANDROID, 1, [...])
                CPPFLAGS="$CPPFLAGS"
                # Can't use tls, since it depends on the runtime detection of tls offsets
                # in mono-compiler.h            
                with_tls=pthread
                target_mach=no
+
+               case "$target" in
+               *-linux-android*)
+                       AC_DEFINE(TARGET_ANDROID, 1, [...])
+                       ;;
+               esac
                ;;
    x86_64*-linux-*)
                TARGET=AMD64;
                arch_target=amd64;
                AC_DEFINE(TARGET_AMD64, 1, [...])
-               AC_DEFINE(TARGET_ANDROID, 1, [...])
                CPPFLAGS="$CPPFLAGS"
                # Can't use tls, since it depends on the runtime detection of tls offsets
                # in mono-compiler.h
                with_tls=pthread
                target_mach=no
+
+               case "$target" in
+               *-linux-android*)
+                       AC_DEFINE(TARGET_ANDROID, 1, [...])
+                       ;;
+               esac
                ;;
    x86_64-ps4-freebsd)
                TARGET=AMD64;
@@ -3389,12 +3406,16 @@ if test "x$host" != "x$target"; then
                TARGET=ARM64;
                arch_target=arm64;
                AC_DEFINE(TARGET_ARM64, 1, [...])
-               AC_DEFINE(TARGET_ANDROID, 1, [...])
                CPPFLAGS="$CPPFLAGS"
                # Can't use tls, since it depends on the runtime detection of tls offsets
                # in mono-compiler.h
                with_tls=pthread
                target_mach=no
+               case "$target" in
+               *-linux-android*)
+                       AC_DEFINE(TARGET_ANDROID, 1, [...])
+                       ;;
+               esac
                ;;
        aarch64-*)
                TARGET=ARM64
diff --git a/mcs/class/System.Numerics.Vectors/SR.cs b/mcs/class/System.Numerics.Vectors/SR.cs
deleted file mode 100644 (file)
index 6c04e22..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-//
-// This file was generated by resx2sr tool
-//
-
-partial class SR
-{
-       public const string Arg_ArgumentOutOfRangeException = "Index was out of bounds:";
-       public const string Arg_ElementsInSourceIsGreaterThanDestination = "Number of elements in source vector is greater than the destination array";
-       public const string Arg_MultiDimArrayNotSupported = "Only one-dimensional arrays are supported";
-       public const string Arg_NullArgumentNullRef = "The method was called with a null array argument.";
-       public const string Arg_RegisterLengthOfRangeException = "length must be less than";
-       public const string Arg_TypeNotSupported = "Specified type is not supported";
-       public const string Reflection_MethodNotSupported = "Vector<T>.Count cannot be called via reflection when intrinsics are enabled.";
-}
index d624f2e4c80f202b4b6fba87d480e4d02e08762c..1466512e844a34268377b6c94c11e2b900d66b3f 100644 (file)
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
   <ItemGroup>\r
     <Compile Include="..\..\..\external\corefx\src\Common\src\System\Numerics\Hashing\HashHelpers.cs" />\r
-    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\\JitIntrinsicAttribute.cs" />\r
-    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\\Register.cs" />\r
-    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\\Vector.cs" />\r
-    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\\Vector_Operations.cs" />\r
     <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\ConstantHelper.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\JitIntrinsicAttribute.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Register.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Vector.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Vector_Operations.cs" />\r
     <Compile Include="..\..\build\common\Consts.cs" />\r
     <Compile Include="..\..\build\common\SR.cs" />\r
     <Compile Include="Assembly\AssemblyInfo.cs" />\r
     <Compile Include="Assembly\TypeForwarders.cs" />\r
-    <Compile Include="SR.cs" />\r  </ItemGroup>\r
+    <Compile Include="corefx\SR.cs" />\r  </ItemGroup>\r
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
        Other similar extension points exist, see Microsoft.Common.targets.\r
   <Target Name="BeforeBuild">\r
index a5f261e85ca657317de65d24332b724e836b28b6..74524d655fd6ff961b88a57caeb632be687a868b 100644 (file)
@@ -2,11 +2,11 @@
 ../../build/common/SR.cs
 Assembly/AssemblyInfo.cs
 Assembly/TypeForwarders.cs
-SR.cs
+corefx/SR.cs
 
 ../../../external/corefx/src/Common/src/System/Numerics/Hashing/HashHelpers.cs
 ../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/ConstantHelper.cs
-../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics//JitIntrinsicAttribute.cs
-../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics//Register.cs
-../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics//Vector_Operations.cs
-../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics//Vector.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/JitIntrinsicAttribute.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Register.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Vector_Operations.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Vector.cs
diff --git a/mcs/class/System.Numerics.Vectors/corefx/SR.cs b/mcs/class/System.Numerics.Vectors/corefx/SR.cs
new file mode 100644 (file)
index 0000000..def5b09
--- /dev/null
@@ -0,0 +1,11 @@
+//
+// This file was generated by resx2sr tool
+//
+
+partial class SR
+{
+       public const string Arg_ArgumentOutOfRangeException = "Index was out of bounds:";
+       public const string Arg_ElementsInSourceIsGreaterThanDestination = "Number of elements in source vector is greater than the destination array";
+       public const string Arg_NullArgumentNullRef = "The method was called with a null array argument.";
+       public const string Arg_TypeNotSupported = "Specified type is not supported";
+}
index bc470e1b6e77c43d72f201970bbb3b488f6c8ab3..19d1e56a543b4ee70e00fe383e04279dc8dd0da3 100644 (file)
@@ -4,10 +4,12 @@ include ../../build/rules.make
 
 LIBRARY = System.Numerics.dll
 LIB_REFS = System
-LIB_MCS_FLAGS = /unsafe -nowarn:414 -nowarn:436
+LIB_MCS_FLAGS = /unsafe
 TEST_MCS_FLAGS = $(LIB_MCS_FLAGS)
 
-TXT_RESOURCE_STRINGS = ../referencesource/System.Numerics/System.Numerics.txt
+RESX_RESOURCE_STRING = \
+       ../../../external/corefx/src/System.Runtime.Numerics/src/Resources/Strings.resx \
+       ../../../external/corefx/src/System.Numerics.Vectors/src/Resources/Strings.resx
 
 EXTRA_DISTFILES =
 
diff --git a/mcs/class/System.Numerics/ReferenceSources/SR.cs b/mcs/class/System.Numerics/ReferenceSources/SR.cs
deleted file mode 100644 (file)
index 3b4d7bd..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-//
-// This file was generated by txt2sr tool
-//
-
-partial class SR
-{
-       public const string Argument_InvalidNumberStyles = "An undefined NumberStyles value is being used.";
-       public const string Argument_InvalidHexStyle = "With the AllowHexSpecifier bit set in the enum bit field, the only other valid bits that can be combined into the enum value must be a subset of those in HexNumber.";
-       public const string Argument_MustBeBigInt = "The parameter must be a BigInteger.";
-       public const string Format_InvalidFormatSpecifier = "Format specifier was invalid.";
-       public const string Format_TooLarge = "The value is too large to be represented by this format specifier.";
-       public const string ArgumentOutOfRange_MustBeNonNeg = "The number must be greater than or equal to zero.";
-       public const string Overflow_BigIntInfinity = "BigInteger cannot represent infinity.";
-       public const string Overflow_NotANumber = "The value is not a number.";
-       public const string Overflow_ParseBigInteger = "The value could not be parsed.";
-       public const string Overflow_Int32 = "Value was either too large or too small for an Int32.";
-       public const string Overflow_Int64 = "Value was either too large or too small for an Int64.";
-       public const string Overflow_UInt32 = "Value was either too large or too small for a UInt32.";
-       public const string Overflow_UInt64 = "Value was either too large or too small for a UInt64.";
-       public const string Overflow_Decimal = "Value was either too large or too small for a Decimal.";
-}
index 598f385ec36d0144c13c6bc53d55a87bd152c67a..60a63a261c5646709fe3bb4542612d0e91808271 100644 (file)
@@ -8,7 +8,7 @@
     <SchemaVersion>2.0</SchemaVersion>\r
     <ProjectGuid>{BD2FFDDC-BD89-4041-82F5-A696C941C7BE}</ProjectGuid>\r
     <OutputType>Library</OutputType>\r
-    <NoWarn>1699,414,436</NoWarn>\r
+    <NoWarn>1699</NoWarn>\r
     <OutputPath>./../../class/lib/net_4_x</OutputPath>\r
     <IntermediateOutputPath>obj-net_4_x</IntermediateOutputPath>\r
     <GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>\r
@@ -27,7 +27,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
     <DebugSymbols>true</DebugSymbols>\r
     <DebugType>full</DebugType>\r
-    <NoWarn>1699,414,436</NoWarn>\r
+    <NoWarn>1699</NoWarn>\r
     <Optimize>false</Optimize>\r
     <DefineConstants>TRACE;NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>\r
     <ErrorReport>prompt</ErrorReport>\r
@@ -35,7 +35,7 @@
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
     <DebugType>pdbonly</DebugType>\r
-    <NoWarn>1699,414,436</NoWarn>\r
+    <NoWarn>1699</NoWarn>\r
     <Optimize>true</Optimize>\r
     <DefineConstants>NET_4_0;NET_4_5;NET_4_6;MONO;WIN_PLATFORM</DefineConstants>\r
     <ErrorReport>prompt</ErrorReport>\r
   </PropertyGroup>\r
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
   <ItemGroup>\r
+    <Compile Include="..\..\..\external\corefx\src\Common\src\System\Globalization\FormatProvider.Number.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\Common\src\System\Numerics\Hashing\HashHelpers.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\JitIntrinsicAttribute.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Matrix3x2.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Matrix4x4.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Plane.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Quaternion.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Vector2.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Vector2_Intrinsics.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Vector3.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Vector3_Intrinsics.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Vector4.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Numerics.Vectors\src\System\Numerics\Vector4_Intrinsics.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Globalization\FormatProvider.BigInteger.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Globalization\FormatProvider.NumberBuffer.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Numerics\BigInteger.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Numerics\BigIntegerCalculator.AddSub.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Numerics\BigIntegerCalculator.BitsBuffer.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Numerics\BigIntegerCalculator.DivRem.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Numerics\BigIntegerCalculator.FastReducer.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Numerics\BigIntegerCalculator.GcdInv.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Numerics\BigIntegerCalculator.PowMod.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Numerics\BigIntegerCalculator.SquMul.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Numerics\BigNumber.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Numerics\Complex.cs" />\r
+    <Compile Include="..\..\..\external\corefx\src\System.Runtime.Numerics\src\System\Numerics\NumericsHelpers.cs" />\r
+    <Compile Include="..\..\build\common\Consts.cs" />\r
     <Compile Include="..\..\build\common\SR.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\BigInteger.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\BigIntegerBuilder.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\BigNumber.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\Complex.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\HashCodeHelper.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\JITIntrinsicAttribute.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\Matrix3x2.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\Matrix4x4.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\NumericsHelpers.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\Plane.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\Quaternion.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\Vector_Operations.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\Vector2.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\Vector2_Intrinsics.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\Vector3.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\Vector3_Intrinsics.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\Vector4.cs" />\r
-    <Compile Include="..\referencesource\System.Numerics\System\Numerics\Vector4_Intrinsics.cs" />\r
     <Compile Include="Assembly\AssemblyInfo.cs" />\r
-    <Compile Include="ReferenceSources\SR.cs" />\r  </ItemGroup>\r
+    <Compile Include="corefx\SR.cs" />\r
+    <Compile Include="corefx\Vector.cs" />\r  </ItemGroup>\r
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
        Other similar extension points exist, see Microsoft.Common.targets.\r
   <Target Name="BeforeBuild">\r
index 9d03ee139172caa2c596fbed4e193c308134f950..1e56c801e93eb413f4a195e33b821d990f065615 100644 (file)
@@ -1,21 +1,34 @@
+../../build/common/Consts.cs
 ../../build/common/SR.cs
 Assembly/AssemblyInfo.cs
-ReferenceSources/SR.cs
-../referencesource/System.Numerics/System/Numerics/BigInteger.cs
-../referencesource/System.Numerics/System/Numerics/BigIntegerBuilder.cs
-../referencesource/System.Numerics/System/Numerics/BigNumber.cs
-../referencesource/System.Numerics/System/Numerics/Complex.cs
-../referencesource/System.Numerics/System/Numerics/NumericsHelpers.cs
-../referencesource/System.Numerics/System/Numerics/HashCodeHelper.cs
-../referencesource/System.Numerics/System/Numerics/JITIntrinsicAttribute.cs
-../referencesource/System.Numerics/System/Numerics/Matrix3x2.cs
-../referencesource/System.Numerics/System/Numerics/Matrix4x4.cs
-../referencesource/System.Numerics/System/Numerics/Plane.cs
-../referencesource/System.Numerics/System/Numerics/Quaternion.cs
-../referencesource/System.Numerics/System/Numerics/Vector2.cs
-../referencesource/System.Numerics/System/Numerics/Vector2_Intrinsics.cs
-../referencesource/System.Numerics/System/Numerics/Vector3.cs
-../referencesource/System.Numerics/System/Numerics/Vector3_Intrinsics.cs
-../referencesource/System.Numerics/System/Numerics/Vector4.cs
-../referencesource/System.Numerics/System/Numerics/Vector4_Intrinsics.cs
-../referencesource/System.Numerics/System/Numerics/Vector_Operations.cs
+corefx/SR.cs
+corefx/Vector.cs
+
+../../../external/corefx/src/Common/src/System/Globalization/FormatProvider.Number.cs
+../../../external/corefx/src/Common/src/System/Numerics/Hashing/HashHelpers.cs
+
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Globalization/FormatProvider.BigInteger.cs
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Globalization/FormatProvider.NumberBuffer.cs
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Numerics/BigInteger.cs
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.AddSub.cs
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.BitsBuffer.cs
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.DivRem.cs
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.FastReducer.cs
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.GcdInv.cs
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.PowMod.cs
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.SquMul.cs
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Numerics/BigNumber.cs
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Numerics/Complex.cs
+../../../external/corefx/src/System.Runtime.Numerics/src/System/Numerics/NumericsHelpers.cs
+
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/JitIntrinsicAttribute.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Matrix3x2.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Matrix4x4.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Plane.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Quaternion.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Vector2.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Vector2_Intrinsics.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Vector3.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Vector3_Intrinsics.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Vector4.cs
+../../../external/corefx/src/System.Numerics.Vectors/src/System/Numerics/Vector4_Intrinsics.cs
diff --git a/mcs/class/System.Numerics/corefx/SR.cs b/mcs/class/System.Numerics/corefx/SR.cs
new file mode 100644 (file)
index 0000000..e4590b7
--- /dev/null
@@ -0,0 +1,25 @@
+//
+// This file was generated by resx2sr tool
+//
+
+partial class SR
+{
+       public const string Argument_BadFormatSpecifier = "Format specifier was invalid.";
+       public const string Argument_InvalidNumberStyles = "An undefined NumberStyles value is being used.";
+       public const string Argument_InvalidHexStyle = "With the AllowHexSpecifier bit set in the enum bit field, the only other valid bits that can be combined into the enum value must be a subset of those in HexNumber.";
+       public const string Argument_MustBeBigInt = "The parameter must be a BigInteger.";
+       public const string Format_TooLarge = "The value is too large to be represented by this format specifier.";
+       public const string ArgumentOutOfRange_MustBeNonNeg = "The number must be greater than or equal to zero.";
+       public const string Overflow_BigIntInfinity = "BigInteger cannot represent infinity.";
+       public const string Overflow_NotANumber = "The value is not a number.";
+       public const string Overflow_ParseBigInteger = "The value could not be parsed.";
+       public const string Overflow_Int32 = "Value was either too large or too small for an Int32.";
+       public const string Overflow_Int64 = "Value was either too large or too small for an Int64.";
+       public const string Overflow_UInt32 = "Value was either too large or too small for a UInt32.";
+       public const string Overflow_UInt64 = "Value was either too large or too small for a UInt64.";
+       public const string Overflow_Decimal = "Value was either too large or too small for a Decimal.";
+       public const string Arg_ArgumentOutOfRangeException = "Index was out of bounds:";
+       public const string Arg_ElementsInSourceIsGreaterThanDestination = "Number of elements in source vector is greater than the destination array";
+       public const string Arg_NullArgumentNullRef = "The method was called with a null array argument.";
+       public const string Arg_TypeNotSupported = "Specified type is not supported";
+}
diff --git a/mcs/class/System.Numerics/corefx/Vector.cs b/mcs/class/System.Numerics/corefx/Vector.cs
new file mode 100644 (file)
index 0000000..de085ba
--- /dev/null
@@ -0,0 +1,12 @@
+namespace System.Numerics
+{
+       static class Vector
+       {
+               [JitIntrinsic]
+               public static bool IsHardwareAccelerated {
+                       get {
+                               return false;
+                       }
+               }
+       }
+}
\ No newline at end of file
index 771d5d1fb6ae4cf35c3e05db8b41a44cb6175435..05654f49edd95980b5085014ece3423d5509c8a6 100644 (file)
@@ -336,10 +336,20 @@ namespace MonoTests.System.Net
                        DownloadFile (new ServerDownload (true));
                }
 
-               void DownloadFile (ServerDownload sp)
+               [Test]
+#if FEATURE_NO_BSD_SOCKETS
+               [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
+               public void DownloadFileNonLatinChars ()
+               {
+                       string filename = "\u0411\u0430\u0448\u043DRowan-\u041F\u0435\u0441\u043D\u043F\u0440\u043E\u043C\u043E\u043D\u0430\u0445\u0430\u0422\u0435\u043E\u0434\u043E\u0440\u0443\u0441\u0430\u0438\u0437\u0413\u0430\u043C\u043C\u0435\u043B\u044C\u043D\u0430.mp3";
+                       DownloadFile (new ServerDownload (null, null, filename, false), "ftp://{0}:{1}/" + filename);
+               }
+
+               void DownloadFile (ServerDownload sp, string uriTemplate = "ftp://{0}:{1}/file.txt")
                {
                        sp.Start ();
-                       string uri = String.Format ("ftp://{0}:{1}/file.txt", EncloseIPv6 (sp.IPAddress), sp.Port);
+                       string uri = String.Format (uriTemplate, EncloseIPv6 (sp.IPAddress), sp.Port);
                        try {
                                FtpWebRequest ftp = (FtpWebRequest) WebRequest.Create (uri);
                                ftp.KeepAlive = false;
@@ -370,7 +380,7 @@ namespace MonoTests.System.Net
                {
                        // Some embedded FTP servers in Industrial Automation Hardware report
                        // the PWD using backslashes, but allow forward slashes for CWD.
-                       DownloadFile (new ServerDownload (@"\Users\someuser", "/Users/someuser/", false));
+                       DownloadFile (new ServerDownload (@"\Users\someuser", "/Users/someuser/", null, false));
                }
 
                [Test]
@@ -381,7 +391,7 @@ namespace MonoTests.System.Net
                {
                        // Some embedded FTP servers in Industrial Automation Hardware report
                        // the PWD using backslashes, but allow forward slashes for CWD.
-                       DownloadFile (new ServerDownload (@"\Users\someuser", "/Users/someuser/", true));
+                       DownloadFile (new ServerDownload (@"\Users\someuser", "/Users/someuser/", null, true));
                }
 
                [Test]
@@ -580,18 +590,19 @@ namespace MonoTests.System.Net
 
                class ServerDownload : FtpServer {
 
-                       string Pwd, Cwd;
+                       string Pwd, Cwd, Filename;
 
                        public ServerDownload (bool ipv6)
-                               : this (null, null, ipv6)
+                               : this (null, null, null, ipv6)
                        {
                        }
 
-                       public ServerDownload (string pwd, string cwd, bool ipv6)
+                       public ServerDownload (string pwd, string cwd, string filename, bool ipv6)
                                : base (ipv6)
                        {
                                Pwd = pwd ?? "/home/someuser";
                                Cwd = cwd ?? "/home/someuser/";
+                               Filename = filename ?? "file.txt";
                        }
 
                        protected override void Run ()
@@ -620,8 +631,8 @@ namespace MonoTests.System.Net
                                writer.Flush ();
 
                                str = reader.ReadLine ();
-                               if (str != "RETR file.txt") {
-                                       Where = "RETR - " + str;
+                               if (str != $"RETR {Filename}") {
+                                       Where = $"RETR - got: {str}, expected: RETR {Filename}";
                                        client.Close ();
                                        return;
                                }
index 59ef32f147fd6f9c8ecade952d86e5a3403592ff..6e1e9ef1264ab13c08957d9d6938eeed71c9497a 100644 (file)
@@ -76,8 +76,6 @@ using System.Runtime.InteropServices;
 [assembly: InternalsVisibleTo ("System, PublicKey=" + AssemblyRef.FrameworkPublicKeyFull2)]
 [assembly: InternalsVisibleTo ("System.Core, PublicKey=" + AssemblyRef.FrameworkPublicKeyFull2)]
 
-[assembly: InternalsVisibleTo ("System.Numerics, PublicKey=00000000000000000400000000000000")]
-
 [assembly: InternalsVisibleTo ("System.Runtime.WindowsRuntime, PublicKey=00000000000000000400000000000000")]
 [assembly: InternalsVisibleTo ("System.Runtime.WindowsRuntime.UI.Xaml, PublicKey=00000000000000000400000000000000")]
 
index d187f28780a3a5bf81e3271768e0f615cb56a0e2..599651b1368b78f6c6770ff5742d1c6d83495c81 100644 (file)
@@ -2027,6 +2027,7 @@ main (int argc, char *argv [])
 
        CHECKED_MONO_INIT ();
        mono_counters_init ();
+       mono_tls_init_runtime_keys ();
        memset (&ticallbacks, 0, sizeof (ticallbacks));
        ticallbacks.thread_state_init = thread_state_init;
 #ifndef HOST_WIN32
index 18ce6c4510a75f21a4762411ff7f387c823c2b03..1766d1d51763c8f8392d790d7c0fe40674fe0c00 100644 (file)
@@ -76,8 +76,13 @@ static char **assemblies_path = NULL;
 static char **extra_gac_paths = NULL;
 
 #ifndef DISABLE_ASSEMBLY_REMAPPING
+
+static GHashTable* assembly_remapping_table;
 /* The list of system assemblies what will be remapped to the running
- * runtime version. WARNING: this list must be sorted.
+ * runtime version.
+ * This list is stored in @assembly_remapping_table during initialization.
+ * Keep it sorted just to make maintenance easier.
+ *
  * The integer number is an index in the MonoRuntimeInfo structure, whose
  * values can be found in domain.c - supported_runtimes. Look there
  * to understand what remapping will be made.
@@ -133,9 +138,9 @@ static const AssemblyVersionMap framework_assemblies [] = {
        {"System.Drawing", 0},
        {"System.Drawing.Design", 0},
        {"System.EnterpriseServices", 0},
+       {"System.IO.Compression", 2},
        {"System.IdentityModel", 3},
        {"System.IdentityModel.Selectors", 3},
-       {"System.IO.Compression", 2},
        {"System.Management", 0},
        {"System.Messaging", 0},
        {"System.Net", 2},
@@ -796,6 +801,15 @@ mono_assemblies_init (void)
 
        mono_os_mutex_init_recursive (&assemblies_mutex);
        mono_os_mutex_init (&assembly_binding_mutex);
+
+#ifndef DISABLE_ASSEMBLY_REMAPPING
+       assembly_remapping_table = g_hash_table_new (g_str_hash, g_str_equal);
+
+       int i;
+       for (i = 0; i < G_N_ELEMENTS (framework_assemblies) - 1; ++i)
+               g_hash_table_insert (assembly_remapping_table, (void*)framework_assemblies [i].assembly_name, (void*)&framework_assemblies [i]);
+
+#endif
 }
 
 static void
@@ -1037,7 +1051,6 @@ static MonoAssemblyName *
 mono_assembly_remap_version (MonoAssemblyName *aname, MonoAssemblyName *dest_aname)
 {
        const MonoRuntimeInfo *current_runtime;
-       int pos, first, last;
 
        if (aname->name == NULL) return aname;
 
@@ -1074,52 +1087,52 @@ mono_assembly_remap_version (MonoAssemblyName *aname, MonoAssemblyName *dest_ana
        }
        
 #ifndef DISABLE_ASSEMBLY_REMAPPING
-       first = 0;
-       last = G_N_ELEMENTS (framework_assemblies) - 1;
-       
-       while (first <= last) {
-               int res;
-               pos = first + (last - first) / 2;
-               res = strcmp (aname->name, framework_assemblies[pos].assembly_name);
-               if (res == 0) {
-                       const AssemblyVersionSet* vset;
-                       int index = framework_assemblies[pos].version_set_index;
-                       g_assert (index < G_N_ELEMENTS (current_runtime->version_sets));
-                       vset = &current_runtime->version_sets [index];
-
-                       if (aname->major == vset->major && aname->minor == vset->minor &&
-                               aname->build == vset->build && aname->revision == vset->revision)
-                               return aname;
-               
-                       if (framework_assemblies[pos].only_lower_versions && compare_versions ((AssemblyVersionSet*)vset, aname) < 0)
-                               return aname;
-
-                       if ((aname->major | aname->minor | aname->build | aname->revision) != 0)
-                               mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_ASSEMBLY,
-                                       "The request to load the assembly %s v%d.%d.%d.%d was remapped to v%d.%d.%d.%d",
-                                                       aname->name,
-                                                       aname->major, aname->minor, aname->build, aname->revision,
-                                                       vset->major, vset->minor, vset->build, vset->revision
-                                                       );
-                       
-                       memcpy (dest_aname, aname, sizeof(MonoAssemblyName));
-                       dest_aname->major = vset->major;
-                       dest_aname->minor = vset->minor;
-                       dest_aname->build = vset->build;
-                       dest_aname->revision = vset->revision;
-                       if (framework_assemblies[pos].new_assembly_name != NULL) {
-                               dest_aname->name = framework_assemblies[pos].new_assembly_name;
-                               mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_ASSEMBLY,
-                                                       "The assembly name %s was remapped to %s",
-                                                       aname->name,
-                                                       dest_aname->name);
-                       }
-                       return dest_aname;
-               } else if (res < 0) {
-                       last = pos - 1;
-               } else {
-                       first = pos + 1;
+       const AssemblyVersionMap *vmap = (AssemblyVersionMap *)g_hash_table_lookup (assembly_remapping_table, aname->name);
+       if (vmap) {
+               const AssemblyVersionSet* vset;
+               int index = vmap->version_set_index;
+               g_assert (index < G_N_ELEMENTS (current_runtime->version_sets));
+               vset = &current_runtime->version_sets [index];
+
+               if (aname->major == vset->major && aname->minor == vset->minor &&
+                       aname->build == vset->build && aname->revision == vset->revision) {
+                       mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY, "Found assembly remapping for %s and was for the same version %d.%d.%d.%d",
+                               aname->name,
+                               aname->major, aname->minor, aname->build, aname->revision);
+                       return aname;
+               }
+
+               if (vmap->only_lower_versions && compare_versions ((AssemblyVersionSet*)vset, aname) < 0) {
+                       mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_ASSEMBLY,
+                               "Found lower-versions-only assembly remaping to load %s %d.%d.%d.%d but mapping has %d.%d.%d.%d",
+                                               aname->name,
+                                               aname->major, aname->minor, aname->build, aname->revision,
+                                               vset->major, vset->minor, vset->build, vset->revision
+                                               );
+                       return aname;
+               }
+
+               if ((aname->major | aname->minor | aname->build | aname->revision) != 0)
+                       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_ASSEMBLY,
+                               "The request to load the assembly %s v%d.%d.%d.%d was remapped to v%d.%d.%d.%d",
+                                               aname->name,
+                                               aname->major, aname->minor, aname->build, aname->revision,
+                                               vset->major, vset->minor, vset->build, vset->revision
+                                               );
+
+               memcpy (dest_aname, aname, sizeof(MonoAssemblyName));
+               dest_aname->major = vset->major;
+               dest_aname->minor = vset->minor;
+               dest_aname->build = vset->build;
+               dest_aname->revision = vset->revision;
+               if (vmap->new_assembly_name != NULL) {
+                       dest_aname->name = vmap->new_assembly_name;
+                       mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_ASSEMBLY,
+                                               "The assembly name %s was remapped to %s",
+                                               aname->name,
+                                               dest_aname->name);
                }
+               return dest_aname;
        }
 #endif
 
index dcfd310f6490ebdd894c863b32e8c65d6ff52f6d..f0fa3579f72bcfd9b456132a305819cc8cc5e075 100644 (file)
@@ -617,6 +617,12 @@ mono_gc_make_descr_from_bitmap (gsize *bitmap, int numbits)
                return (gpointer)GC_make_descriptor ((GC_bitmap)bitmap, numbits);
 }
 
+void*
+mono_gc_make_vector_descr (void)
+{
+       return NULL;
+}
+
 void*
 mono_gc_make_root_descr_all_refs (int numbits)
 {
index 810d41197919ce7d0700169d2d080fced5c6db26..0785369e0c65662c1e35da8696d3ab2ecf47789c 100644 (file)
@@ -494,6 +494,8 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
        mono_counters_register ("Max code space allocated in a domain", MONO_COUNTER_INT|MONO_COUNTER_JIT, &max_domain_code_alloc);
        mono_counters_register ("Total code space allocated", MONO_COUNTER_INT|MONO_COUNTER_JIT, &total_domain_code_alloc);
 
+       mono_counters_register ("Max HashTable Chain Length", MONO_COUNTER_INT|MONO_COUNTER_METADATA, &mono_g_hash_table_max_chain_length);
+
        mono_gc_base_init ();
        mono_thread_info_attach (&dummy);
 
index 7ef3b74c5eb07bcab5f27c55df5877d91108ea6f..545b917177bf45472e6df6c8d7eacc5d344cedd1 100644 (file)
@@ -6714,7 +6714,8 @@ mono_signature_explicit_this (MonoMethodSignature *sig)
 guint
 mono_aligned_addr_hash (gconstpointer ptr)
 {
-       return GPOINTER_TO_UINT (ptr) >> 3;
+       /* Same hashing we use for objects */
+       return (GPOINTER_TO_UINT (ptr) >> 3) * 2654435761u;
 }
 
 /*
index 00f7afab0ccea8eb71d5cb11bdc7adef687aa1a4..9c6cdb44101c6479dfbc36381aefc2252a7fb074 100644 (file)
@@ -34,6 +34,8 @@
 #include <mono/utils/checked-build.h>
 #include <mono/utils/mono-threads-coop.h>
 
+int mono_g_hash_table_max_chain_length;
+
 #ifdef HAVE_BOEHM_GC
 #define mg_new0(type,n)  ((type *) GC_MALLOC(sizeof(type) * (n)))
 #define mg_new(type,n)   ((type *) GC_MALLOC(sizeof(type) * (n)))
 #define mg_free(x)       g_free(x)
 #endif
 
-typedef struct _Slot Slot;
-
-struct _Slot {
-       MonoObject *key;
-       MonoObject *value;
-       Slot    *next;
-};
-
-static gpointer KEYMARKER_REMOVED = &KEYMARKER_REMOVED;
-
 struct _MonoGHashTable {
        GHashFunc      hash_func;
        GEqualFunc     key_equal_func;
 
-       Slot **table;
+       MonoObject **keys;
+       MonoObject **values;
        int   table_size;
        int   in_use;
-       int   threshold;
-       int   last_rehash;
        GDestroyNotify value_destroy_func, key_destroy_func;
        MonoGHashGCType gc_type;
        MonoGCRootSource source;
        const char *msg;
 };
 
-#ifdef HAVE_SGEN_GC
-static MonoGCDescriptor table_hash_descr = MONO_GC_DESCRIPTOR_NULL;
-
-static void mono_g_hash_mark (void *addr, MonoGCMarkFunc mark_func, void *gc_data);
-#endif
-
-static Slot*
-new_slot (MonoGHashTable *hash)
-{
-       return mg_new (Slot, 1);
-}
-
-static void
-free_slot (MonoGHashTable *hash, Slot *slot)
-{
-       mg_free (slot);
-}
-
 #if UNUSED
 static gboolean
 test_prime (int x)
@@ -107,7 +80,7 @@ static int
 calc_prime (int x)
 {
        int i;
-       
+
        for (i = (x & (~1))-1; i< G_MAXINT32; i += 2) {
                if (test_prime (i))
                        return i;
@@ -116,15 +89,67 @@ calc_prime (int x)
 }
 #endif
 
+#define HASH_TABLE_MAX_LOAD_FACTOR 0.7f
+/* We didn't really do compaction before, keep it lenient for now */
+#define HASH_TABLE_MIN_LOAD_FACTOR 0.05f
+/* We triple the table size at rehash time, similar with previous implementation */
+#define HASH_TABLE_RESIZE_RATIO 3
+
+static inline void mono_g_hash_table_key_store (MonoGHashTable *hash, int slot, MonoObject* key)
+{
+       MonoObject **key_addr = &hash->keys [slot];
+       if (hash->gc_type & MONO_HASH_KEY_GC)
+               mono_gc_wbarrier_generic_store (key_addr, key);
+       else
+               *key_addr = key;
+}
+
+static inline void mono_g_hash_table_value_store (MonoGHashTable *hash, int slot, MonoObject* value)
+{
+       MonoObject **value_addr = &hash->values [slot];
+       if (hash->gc_type & MONO_HASH_VALUE_GC)
+               mono_gc_wbarrier_generic_store (value_addr, value);
+       else
+               *value_addr = value;
+}
+
+/* Returns position of key or of an empty slot for it */
+static inline int mono_g_hash_table_find_slot (MonoGHashTable *hash, const MonoObject *key)
+{
+       guint start = ((*hash->hash_func) (key)) % hash->table_size;
+       guint i = start;
+
+       if (hash->key_equal_func) {
+               GEqualFunc equal = hash->key_equal_func;
+
+               while (hash->keys [i] && !(*equal) (hash->keys [i], key)) {
+                       i++;
+                       if (i == hash->table_size)
+                               i = 0;
+               }
+       } else {
+               while (hash->keys [i] && hash->keys [i] != key) {
+                       i++;
+                       if (i == hash->table_size)
+                               i = 0;
+               }
+       }
+
+       if (i > start && (i - start) > mono_g_hash_table_max_chain_length)
+               mono_g_hash_table_max_chain_length = i - start;
+       else if (i < start && (hash->table_size - (start - i)) > mono_g_hash_table_max_chain_length)
+               mono_g_hash_table_max_chain_length = hash->table_size - (start - i);
+       return i;
+}
+
+
 MonoGHashTable *
 mono_g_hash_table_new_type (GHashFunc hash_func, GEqualFunc key_equal_func, MonoGHashGCType type, MonoGCRootSource source, const char *msg)
 {
        MonoGHashTable *hash;
 
-       if (hash_func == NULL)
+       if (!hash_func)
                hash_func = g_direct_hash;
-       if (key_equal_func == NULL)
-               key_equal_func = g_direct_equal;
 
 #ifdef HAVE_SGEN_GC
        hash = mg_new0 (MonoGHashTable, 1);
@@ -136,8 +161,8 @@ mono_g_hash_table_new_type (GHashFunc hash_func, GEqualFunc key_equal_func, Mono
        hash->key_equal_func = key_equal_func;
 
        hash->table_size = g_spaced_primes_closest (1);
-       hash->table = mg_new0 (Slot *, hash->table_size);
-       hash->last_rehash = hash->table_size;
+       hash->keys = mg_new0 (MonoObject*, hash->table_size);
+       hash->values = mg_new0 (MonoObject*, hash->table_size);
 
        hash->gc_type = type;
        hash->source = source;
@@ -147,13 +172,10 @@ mono_g_hash_table_new_type (GHashFunc hash_func, GEqualFunc key_equal_func, Mono
                g_error ("wrong type for gc hashtable");
 
 #ifdef HAVE_SGEN_GC
-       /*
-        * We use a user defined marking function to avoid having to register a GC root for
-        * each hash node.
-        */
-       if (!table_hash_descr)
-               table_hash_descr = mono_gc_make_root_descr_user (mono_g_hash_mark);
-       mono_gc_register_root_wbarrier ((char*)hash, sizeof (MonoGHashTable), table_hash_descr, source, msg);
+       if (hash->gc_type & MONO_HASH_KEY_GC)
+               mono_gc_register_root_wbarrier ((char*)hash->keys, sizeof (MonoObject*) * hash->table_size, mono_gc_make_vector_descr (), hash->source, hash->msg);
+       if (hash->gc_type & MONO_HASH_VALUE_GC)
+               mono_gc_register_root_wbarrier ((char*)hash->values, sizeof (MonoObject*) * hash->table_size, mono_gc_make_vector_descr (), hash->source, hash->msg);
 #endif
 
        return hash;
@@ -162,7 +184,8 @@ mono_g_hash_table_new_type (GHashFunc hash_func, GEqualFunc key_equal_func, Mono
 typedef struct {
        MonoGHashTable *hash;
        int new_size;
-       Slot **table;
+       MonoObject **keys;
+       MonoObject **values;
 } RehashData;
 
 static void*
@@ -171,28 +194,24 @@ do_rehash (void *_data)
        RehashData *data = (RehashData *)_data;
        MonoGHashTable *hash = data->hash;
        int current_size, i;
-       Slot **table;
+       MonoObject **old_keys;
+       MonoObject **old_values;
 
-       /* printf ("Resizing diff=%d slots=%d\n", hash->in_use - hash->last_rehash, hash->table_size); */
-       hash->last_rehash = hash->table_size;
        current_size = hash->table_size;
        hash->table_size = data->new_size;
-       /* printf ("New size: %d\n", hash->table_size); */
-       table = hash->table;
-       hash->table = data->table;
-
-       for (i = 0; i < current_size; i++){
-               Slot *s, *next;
-
-               for (s = table [i]; s != NULL; s = next){
-                       guint hashcode = ((*hash->hash_func) (s->key)) % hash->table_size;
-                       next = s->next;
-
-                       s->next = hash->table [hashcode];
-                       hash->table [hashcode] = s;
+       old_keys = hash->keys;
+       old_values = hash->values;
+       hash->keys = data->keys;
+       hash->values = data->values;
+
+       for (i = 0; i < current_size; i++) {
+               if (old_keys [i]) {
+                       int slot = mono_g_hash_table_find_slot (hash, old_keys [i]);
+                       mono_g_hash_table_key_store (hash, slot, old_keys [i]);
+                       mono_g_hash_table_value_store (hash, slot, old_values [i]);
                }
        }
-       return table;
+       return NULL;
 }
 
 static void
@@ -200,35 +219,48 @@ rehash (MonoGHashTable *hash)
 {
        MONO_REQ_GC_UNSAFE_MODE; //we must run in unsafe mode to make rehash safe
 
-       int diff = ABS (hash->last_rehash - hash->in_use);
        RehashData data;
-       void *old_table G_GNUC_UNUSED; /* unused on Boehm */
-
-       /* These are the factors to play with to change the rehashing strategy */
-       /* I played with them with a large range, and could not really get */
-       /* something that was too good, maybe the tests are not that great */
-       if (!(diff * 0.75 > hash->table_size * 2))
-               return;
+       void *old_keys G_GNUC_UNUSED = hash->keys; /* unused on Boehm */
+       void *old_values G_GNUC_UNUSED = hash->values; /* unused on Boehm */
 
        data.hash = hash;
-       data.new_size = g_spaced_primes_closest (hash->in_use);
-       data.table = mg_new0 (Slot *, data.new_size);
+       /*
+        * Rehash to a size that can fit the current elements. Rehash relative to in_use
+        * to allow also for compaction.
+        */
+       data.new_size = g_spaced_primes_closest (hash->in_use / HASH_TABLE_MAX_LOAD_FACTOR * HASH_TABLE_RESIZE_RATIO);
+       data.keys = mg_new0 (MonoObject*, data.new_size);
+       data.values = mg_new0 (MonoObject*, data.new_size);
+
+#ifdef HAVE_SGEN_GC
+       if (hash->gc_type & MONO_HASH_KEY_GC)
+               mono_gc_register_root_wbarrier ((char*)data.keys, sizeof (MonoObject*) * data.new_size, mono_gc_make_vector_descr (), hash->source, hash->msg);
+       if (hash->gc_type & MONO_HASH_VALUE_GC)
+               mono_gc_register_root_wbarrier ((char*)data.values, sizeof (MonoObject*) * data.new_size, mono_gc_make_vector_descr (), hash->source, hash->msg);
+#endif
 
        if (!mono_threads_is_coop_enabled ()) {
-               old_table = mono_gc_invoke_with_gc_lock (do_rehash, &data);
+               mono_gc_invoke_with_gc_lock (do_rehash, &data);
        } else {
                /* We cannot be preempted */
-               old_table = do_rehash (&data);
+               do_rehash (&data);
        }
 
-       mg_free (old_table);
+#ifdef HAVE_SGEN_GC
+       if (hash->gc_type & MONO_HASH_KEY_GC)
+               mono_gc_deregister_root ((char*)old_keys);
+       if (hash->gc_type & MONO_HASH_VALUE_GC)
+               mono_gc_deregister_root ((char*)old_values);
+#endif
+       mg_free (old_keys);
+       mg_free (old_values);
 }
 
 guint
 mono_g_hash_table_size (MonoGHashTable *hash)
 {
        g_return_val_if_fail (hash != NULL, 0);
-       
+
        return hash->in_use;
 }
 
@@ -236,7 +268,7 @@ gpointer
 mono_g_hash_table_lookup (MonoGHashTable *hash, gconstpointer key)
 {
        gpointer orig_key, value;
-       
+
        if (mono_g_hash_table_lookup_extended (hash, key, &orig_key, &value))
                return value;
        else
@@ -246,22 +278,18 @@ mono_g_hash_table_lookup (MonoGHashTable *hash, gconstpointer key)
 gboolean
 mono_g_hash_table_lookup_extended (MonoGHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value)
 {
-       GEqualFunc equal;
-       Slot *s;
-       guint hashcode;
-       
+       int slot;
+
        g_return_val_if_fail (hash != NULL, FALSE);
-       equal = hash->key_equal_func;
-
-       hashcode = ((*hash->hash_func) (key)) % hash->table_size;
-       
-       for (s = hash->table [hashcode]; s != NULL; s = s->next){
-               if ((*equal)(s->key, key)){
-                       *orig_key = s->key;
-                       *value = s->value;
-                       return TRUE;
-               }
+
+       slot = mono_g_hash_table_find_slot (hash, key);
+
+       if (hash->keys [slot]) {
+               *orig_key = hash->keys [slot];
+               *value = hash->values [slot];
+               return TRUE;
        }
+
        return FALSE;
 }
 
@@ -269,15 +297,13 @@ void
 mono_g_hash_table_foreach (MonoGHashTable *hash, GHFunc func, gpointer user_data)
 {
        int i;
-       
+
        g_return_if_fail (hash != NULL);
        g_return_if_fail (func != NULL);
 
-       for (i = 0; i < hash->table_size; i++){
-               Slot *s;
-
-               for (s = hash->table [i]; s != NULL; s = s->next)
-                       (*func)(s->key, s->value, user_data);
+       for (i = 0; i < hash->table_size; i++) {
+               if (hash->keys [i])
+                       (*func)(hash->keys [i], hash->values [i], user_data);
        }
 }
 
@@ -285,16 +311,13 @@ gpointer
 mono_g_hash_table_find (MonoGHashTable *hash, GHRFunc predicate, gpointer user_data)
 {
        int i;
-       
+
        g_return_val_if_fail (hash != NULL, NULL);
        g_return_val_if_fail (predicate != NULL, NULL);
 
-       for (i = 0; i < hash->table_size; i++){
-               Slot *s;
-
-               for (s = hash->table [i]; s != NULL; s = s->next)
-                       if ((*predicate)(s->key, s->value, user_data))
-                               return s->value;
+       for (i = 0; i < hash->table_size; i++) {
+               if (hash->keys [i] && (*predicate)(hash->keys [i], hash->values [i], user_data))
+                       return hash->values [i];
        }
        return NULL;
 }
@@ -302,32 +325,53 @@ mono_g_hash_table_find (MonoGHashTable *hash, GHRFunc predicate, gpointer user_d
 gboolean
 mono_g_hash_table_remove (MonoGHashTable *hash, gconstpointer key)
 {
-       GEqualFunc equal;
-       Slot *s, *last;
-       guint hashcode;
-       
+       int slot, last_clear_slot;
+
        g_return_val_if_fail (hash != NULL, FALSE);
-       equal = hash->key_equal_func;
-
-       hashcode = ((*hash->hash_func)(key)) % hash->table_size;
-       last = NULL;
-       for (s = hash->table [hashcode]; s != NULL; s = s->next){
-               if ((*equal)(s->key, key)){
-                       if (hash->key_destroy_func != NULL)
-                               (*hash->key_destroy_func)(s->key);
-                       if (hash->value_destroy_func != NULL)
-                               (*hash->value_destroy_func)(s->value);
-                       if (last == NULL)
-                               hash->table [hashcode] = s->next;
-                       else
-                               last->next = s->next;
-                       free_slot (hash, s);
-                       hash->in_use--;
-                       return TRUE;
+       slot = mono_g_hash_table_find_slot (hash, key);
+
+       if (!hash->keys [slot])
+               return FALSE;
+
+       if (hash->key_destroy_func)
+               (*hash->key_destroy_func)(hash->keys [slot]);
+       hash->keys [slot] = NULL;
+       if (hash->value_destroy_func)
+               (*hash->value_destroy_func)(hash->values [slot]);
+       hash->values [slot] = NULL;
+       hash->in_use--;
+
+       /*
+        * When we insert in the hashtable, if the required position is occupied we
+        * consecutively try out following positions. In order to be able to find
+        * if a key exists or not in the array (without traversing the entire hash)
+        * we maintain the constraint that there can be no free slots between two
+        * entries that are hashed to the same position. This means that, at search
+        * time, when we encounter a free slot we can stop looking for collissions.
+        * Similarly, at remove time, we need to shift all following slots to their
+        * normal slot, until we reach an empty slot.
+        */
+       last_clear_slot = slot;
+       slot = (slot + 1) % hash->table_size;
+       while (hash->keys [slot]) {
+               guint hashcode = ((*hash->hash_func)(hash->keys [slot])) % hash->table_size;
+               /*
+                * We try to move the current element to last_clear_slot, but only if
+                * it brings it closer to its normal position (hashcode)
+                */
+               if ((last_clear_slot < slot && (hashcode > slot || hashcode <= last_clear_slot)) ||
+                               (last_clear_slot > slot && (hashcode > slot && hashcode <= last_clear_slot))) {
+                       mono_g_hash_table_key_store (hash, last_clear_slot, hash->keys [slot]);
+                       mono_g_hash_table_value_store (hash, last_clear_slot, hash->values [slot]);
+                       hash->keys [slot] = NULL;
+                       hash->values [slot] = NULL;
+                       last_clear_slot = slot;
                }
-               last = s;
+               slot++;
+               if (slot == hash->table_size)
+                       slot = 0;
        }
-       return FALSE;
+       return TRUE;
 }
 
 guint
@@ -335,40 +379,19 @@ mono_g_hash_table_foreach_remove (MonoGHashTable *hash, GHRFunc func, gpointer u
 {
        int i;
        int count = 0;
-       
+
        g_return_val_if_fail (hash != NULL, 0);
        g_return_val_if_fail (func != NULL, 0);
 
-       for (i = 0; i < hash->table_size; i++){
-               Slot *s, *last;
-
-               last = NULL;
-               for (s = hash->table [i]; s != NULL; ){
-                       if ((*func)(s->key, s->value, user_data)){
-                               Slot *n;
-
-                               if (hash->key_destroy_func != NULL)
-                                       (*hash->key_destroy_func)(s->key);
-                               if (hash->value_destroy_func != NULL)
-                                       (*hash->value_destroy_func)(s->value);
-                               if (last == NULL){
-                                       hash->table [i] = s->next;
-                                       n = s->next;
-                               } else  {
-                                       last->next = s->next;
-                                       n = last->next;
-                               }
-                               free_slot (hash, s);
-                               hash->in_use--;
-                               count++;
-                               s = n;
-                       } else {
-                               last = s;
-                               s = s->next;
-                       }
+       for (i = 0; i < hash->table_size; i++) {
+               if (hash->keys [i] && (*func)(hash->keys [i], hash->values [i], user_data)) {
+                       mono_g_hash_table_remove (hash, hash->keys [i]);
+                       count++;
+                       /* Retry current slot in case the removal shifted elements */
+                       i--;
                }
        }
-       if (count > 0)
+       if (hash->in_use < hash->table_size * HASH_TABLE_MIN_LOAD_FACTOR)
                rehash (hash);
        return count;
 }
@@ -377,27 +400,26 @@ void
 mono_g_hash_table_destroy (MonoGHashTable *hash)
 {
        int i;
-       
+
        g_return_if_fail (hash != NULL);
 
 #ifdef HAVE_SGEN_GC
-       mono_gc_deregister_root ((char*)hash);
+       if (hash->gc_type & MONO_HASH_KEY_GC)
+               mono_gc_deregister_root ((char*)hash->keys);
+       if (hash->gc_type & MONO_HASH_VALUE_GC)
+               mono_gc_deregister_root ((char*)hash->values);
 #endif
 
-       for (i = 0; i < hash->table_size; i++){
-               Slot *s, *next;
-
-               for (s = hash->table [i]; s != NULL; s = next){
-                       next = s->next;
-                       
-                       if (hash->key_destroy_func != NULL)
-                               (*hash->key_destroy_func)(s->key);
-                       if (hash->value_destroy_func != NULL)
-                               (*hash->value_destroy_func)(s->value);
-                       free_slot (hash, s);
+       for (i = 0; i < hash->table_size; i++) {
+               if (hash->keys [i]) {
+                       if (hash->key_destroy_func)
+                               (*hash->key_destroy_func)(hash->keys [i]);
+                       if (hash->value_destroy_func)
+                               (*hash->value_destroy_func)(hash->values [i]);
                }
        }
-       mg_free (hash->table);
+       mg_free (hash->keys);
+       mg_free (hash->values);
 #ifdef HAVE_SGEN_GC
        mg_free (hash);
 #else
@@ -408,36 +430,28 @@ mono_g_hash_table_destroy (MonoGHashTable *hash)
 static void
 mono_g_hash_table_insert_replace (MonoGHashTable *hash, gpointer key, gpointer value, gboolean replace)
 {
-       guint hashcode;
-       Slot *s;
-       GEqualFunc equal;
-       
+       int slot;
        g_return_if_fail (hash != NULL);
 
-       equal = hash->key_equal_func;
-       if (hash->in_use >= hash->threshold)
+       if (hash->in_use > (hash->table_size * HASH_TABLE_MAX_LOAD_FACTOR))
                rehash (hash);
 
-       hashcode = ((*hash->hash_func) (key)) % hash->table_size;
-       for (s = hash->table [hashcode]; s != NULL; s = s->next){
-               if ((*equal) (s->key, key)){
-                       if (replace){
-                               if (hash->key_destroy_func != NULL)
-                                       (*hash->key_destroy_func)(s->key);
-                               s->key = (MonoObject *)key;
-                       }
-                       if (hash->value_destroy_func != NULL)
-                               (*hash->value_destroy_func) (s->value);
-                       s->value = (MonoObject *)value;
-                       return;
+       slot = mono_g_hash_table_find_slot (hash, key);
+
+       if (hash->keys [slot]) {
+               if (replace) {
+                       if (hash->key_destroy_func)
+                               (*hash->key_destroy_func)(hash->keys [slot]);
+                       mono_g_hash_table_key_store (hash, slot, (MonoObject*)key);
                }
+               if (hash->value_destroy_func)
+                       (*hash->value_destroy_func) (hash->values [slot]);
+               mono_g_hash_table_value_store (hash, slot, (MonoObject*)value);
+       } else {
+               mono_g_hash_table_key_store (hash, slot, (MonoObject*)key);
+               mono_g_hash_table_value_store (hash, slot, (MonoObject*)value);
+               hash->in_use++;
        }
-       s = new_slot (hash);
-       s->key = (MonoObject *)key;
-       s->value = (MonoObject *)value;
-       s->next = hash->table [hashcode];
-       hash->table [hashcode] = s;
-       hash->in_use++;
 }
 
 void
@@ -453,56 +467,28 @@ mono_g_hash_table_replace(MonoGHashTable *h, gpointer k, gpointer v)
 }
 
 void
-mono_g_hash_table_print_stats (MonoGHashTable *table)
+mono_g_hash_table_print_stats (MonoGHashTable *hash)
 {
-       int i, chain_size, max_chain_size;
-       Slot *node;
-
-       max_chain_size = 0;
-       for (i = 0; i < table->table_size; i++) {
-               chain_size = 0;
-               for (node = table->table [i]; node; node = node->next)
-                       chain_size ++;
-               max_chain_size = MAX(max_chain_size, chain_size);
-       }
-
-       printf ("Size: %d Table Size: %d Max Chain Length: %d\n", table->in_use, table->table_size, max_chain_size);
-}
-
-#ifdef HAVE_SGEN_GC
-
-/* GC marker function */
-static void
-mono_g_hash_mark (void *addr, MonoGCMarkFunc mark_func, void *gc_data)
-{
-       MonoGHashTable *table = (MonoGHashTable*)addr;
-       Slot *node;
-       int i;
-
-       if (table->gc_type == MONO_HASH_KEY_GC) {
-               for (i = 0; i < table->table_size; i++) {
-                       for (node = table->table [i]; node; node = node->next) {
-                               if (node->key)
-                                       mark_func (&node->key, gc_data);
-                       }
-               }
-       } else if (table->gc_type == MONO_HASH_VALUE_GC) {
-               for (i = 0; i < table->table_size; i++) {
-                       for (node = table->table [i]; node; node = node->next) {
-                               if (node->value)
-                                       mark_func (&node->value, gc_data);
-                       }
+       int i = 0, chain_size = 0, max_chain_size = 0;
+       gboolean wrapped_around = FALSE;
+
+       while (TRUE) {
+               if (hash->keys [i]) {
+                       chain_size++;
+               } else {
+                       max_chain_size = MAX(max_chain_size, chain_size);
+                       chain_size = 0;
+                       if (wrapped_around)
+                               break;
                }
-       } else if (table->gc_type == MONO_HASH_KEY_VALUE_GC) {
-               for (i = 0; i < table->table_size; i++) {
-                       for (node = table->table [i]; node; node = node->next) {
-                               if (node->key)
-                                       mark_func (&node->key, gc_data);
-                               if (node->value)
-                                       mark_func (&node->value, gc_data);
-                       }
+
+               if (i == (hash->table_size - 1)) {
+                       wrapped_around = TRUE;
+                       i = 0;
+               } else {
+                       i++;
                }
        }
+       /* Rehash to a size that can fit the current elements */
+       printf ("Size: %d Table Size: %d Max Chain Length: %d\n", hash->in_use, hash->table_size, max_chain_size);
 }
-       
-#endif
index 60c3328a238782269a18de0e1c9bf04ddef6aa52..dca17694f8eab15a9ae3022b6d49ba112046aa49 100644 (file)
@@ -21,6 +21,8 @@ typedef enum {
        MONO_HASH_KEY_VALUE_GC = MONO_HASH_KEY_GC | MONO_HASH_VALUE_GC,
 } MonoGHashGCType;
 
+extern int mono_g_hash_table_max_chain_length;
+
 typedef struct _MonoGHashTable MonoGHashTable;
 
 MONO_API MonoGHashTable *mono_g_hash_table_new_type (GHashFunc hash_func, GEqualFunc key_equal_func, MonoGHashGCType type, MonoGCRootSource source, const char *msg);
index 9ea87bd844c51a3efaf775a8b159251b1271fc2f..4ee7dd7c9c4f9ea7f327c0ffe7d81a5dcb3e1107 100644 (file)
@@ -164,6 +164,12 @@ mono_gc_make_descr_from_bitmap (gsize *bitmap, int numbits)
        return NULL;
 }
 
+void*
+mono_gc_make_vector_descr (void)
+{
+       return NULL;
+}
+
 void*
 mono_gc_make_root_descr_all_refs (int numbits)
 {
index 96d52815caf7b41997bb284023fbebf9248a9120..b3ce33d12642a64502897a015d4184896039593e 100644 (file)
@@ -7923,6 +7923,9 @@ mono_delegate_ctor_with_method (MonoObject *this_obj, MonoObject *target, gpoint
        if (target && mono_object_is_transparent_proxy (target)) {
                g_assert (method);
                method = mono_marshal_get_remoting_invoke (method);
+#ifdef ENABLE_INTERPRETER
+               g_error ("need RuntimeMethod in method_ptr when using interpreter");
+#endif
                delegate->method_ptr = mono_compile_method_checked (method, error);
                return_val_if_nok (error, FALSE);
                MONO_OBJECT_SETREF (delegate, target, target);
index fbcce02c18cb15aab9c083847680fe611bdc3d6f..43843be4a5a676a9f8f34808588688bbbf81f150 100644 (file)
@@ -165,7 +165,10 @@ reflected_equal (gconstpointer a, gconstpointer b)
 guint
 reflected_hash (gconstpointer a) {
        const ReflectedEntry *ea = (const ReflectedEntry *)a;
-       return mono_aligned_addr_hash (ea->item);
+       /* Combine hashes for item and refclass. Identical to boost's hash_combine */
+       guint seed = mono_aligned_addr_hash (ea->item) + 0x9e3779b9;
+       seed ^= mono_aligned_addr_hash (ea->refclass) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
+       return seed;
 }
 
 
index e8dd50b13d7be09050d60feaf0c89b399961beec..1964c55b064373fa05d69c01e5e3221f3cd6e8c3 100644 (file)
@@ -1573,67 +1573,6 @@ sgen_has_managed_allocator (void)
        return FALSE;
 }
 
-/*
- * Cardtable scanning
- */
-
-#define MWORD_MASK (sizeof (mword) - 1)
-
-static inline int
-find_card_offset (mword card)
-{
-/*XXX Use assembly as this generates some pretty bad code */
-#if defined(__i386__) && defined(__GNUC__)
-       return  (__builtin_ffs (card) - 1) / 8;
-#elif defined(__x86_64__) && defined(__GNUC__)
-       return (__builtin_ffsll (card) - 1) / 8;
-#elif defined(__s390x__)
-       return (__builtin_ffsll (GUINT64_TO_LE(card)) - 1) / 8;
-#else
-       int i;
-       guint8 *ptr = (guint8 *) &card;
-       for (i = 0; i < sizeof (mword); ++i) {
-               if (ptr[i])
-                       return i;
-       }
-       return 0;
-#endif
-}
-
-static guint8*
-find_next_card (guint8 *card_data, guint8 *end)
-{
-       mword *cards, *cards_end;
-       mword card;
-
-       while ((((mword)card_data) & MWORD_MASK) && card_data < end) {
-               if (*card_data)
-                       return card_data;
-               ++card_data;
-       }
-
-       if (card_data == end)
-               return end;
-
-       cards = (mword*)card_data;
-       cards_end = (mword*)((mword)end & ~MWORD_MASK);
-       while (cards < cards_end) {
-               card = *cards;
-               if (card)
-                       return (guint8*)cards + find_card_offset (card);
-               ++cards;
-       }
-
-       card_data = (guint8*)cards_end;
-       while (card_data < end) {
-               if (*card_data)
-                       return card_data;
-               ++card_data;
-       }
-
-       return end;
-}
-
 #define ARRAY_OBJ_INDEX(ptr,array,elem_size) (((char*)(ptr) - ((char*)(array) + G_STRUCT_OFFSET (MonoArray, vector))) / (elem_size))
 
 gboolean
@@ -1690,8 +1629,8 @@ sgen_client_cardtable_scan_object (GCObject *obj, guint8 *cards, ScanCopyContext
 LOOP_HEAD:
 #endif
 
-               card_data = find_next_card (card_data, card_data_end);
-               for (; card_data < card_data_end; card_data = find_next_card (card_data + 1, card_data_end)) {
+               card_data = sgen_find_next_card (card_data, card_data_end);
+               for (; card_data < card_data_end; card_data = sgen_find_next_card (card_data + 1, card_data_end)) {
                        size_t index;
                        size_t idx = (card_data - card_base) + extra_idx;
                        char *start = (char*)(obj_start + idx * CARD_SIZE_IN_BYTES);
@@ -2007,6 +1946,15 @@ precisely_report_roots_from (GCRootReport *report, void** start_root, void** end
                }
                break;
        }
+       case ROOT_DESC_VECTOR: {
+               void **p;
+
+               for (p = start_root; p < end_root; p++) {
+                       if (*p)
+                               add_profile_gc_root (report, *p, MONO_PROFILE_GC_ROOT_OTHER, 0);
+               }
+               break;
+       }
        case ROOT_DESC_USER: {
                MonoGCRootMarkFunc marker = (MonoGCRootMarkFunc)sgen_get_user_descriptor_func (desc);
                root_report = report;
index 618d995dceb7db96eccc7cccbdc98e1852f4cd56..4f4fa7b1559c202ec6d0ef11435e43504759831c 100644 (file)
@@ -325,7 +325,7 @@ selector_thread (gpointer data)
                return 0;
        }
 
-       states = mono_g_hash_table_new_type (g_direct_hash, g_direct_equal, MONO_HASH_VALUE_GC, MONO_ROOT_SOURCE_THREAD_POOL, "i/o thread pool states table");
+       states = mono_g_hash_table_new_type (g_direct_hash, NULL, MONO_HASH_VALUE_GC, MONO_ROOT_SOURCE_THREAD_POOL, "i/o thread pool states table");
 
        while (!mono_runtime_is_shutting_down ()) {
                gint i, j;
index c756a06c94082952563abe49d4326798d669fb8a..3461f81e325c6dde6063bb487799a5d24b4baf02 100644 (file)
@@ -4844,13 +4844,6 @@ async_abort_critical (MonoThreadInfo *info, gpointer ud)
        if (mono_get_eh_callbacks ()->mono_install_handler_block_guard (mono_thread_info_get_suspend_state (info)))
                return MonoResumeThread;
 
-       /*
-       The target thread is running at least one protected block, which must not be interrupted, so we give up.
-       The protected block code will give them a chance when appropriate.
-       */
-       if (mono_thread_get_abort_prot_block_count (thread) > 0)
-               return MonoResumeThread;
-
        /*someone is already interrupting it*/
        if (!mono_thread_set_interruption_requested (thread))
                return MonoResumeThread;
index f53010594c79435c74b13c06bd545ee30d87ddff..af434f4218a008e40471928ff17ea2d51dbd11c7 100644 (file)
@@ -8,7 +8,7 @@
 /*.dll
 /*.mdb
 /*.lo
-/interpreter/*.lo
+/interp/*.lo
 /*.loT
 /*.la
 /.libs
index 59888bbc64dc722b2d29ab611d8a06f6ee1a6d7b..1aa2808c3dc612d00f813db908e49e097959fda1 100755 (executable)
@@ -43,7 +43,7 @@ RUNTIME_EXECUTABLE = $(if $(BOEHM),$(top_builddir)/mono/mini/mono-boehm,$(top_bu
 
 MINI_RUNTIME = MONO_PATH=$(CLASS) $(RUNTIME_EXECUTABLE)
 TOOLS_RUNTIME = MONO_PATH=$(mcs_topdir)/class/lib/build $(top_builddir)/runtime/mono-wrapper
-INTERPRETER_RUNTIME = $(MINI_RUNTIME) --interpreter
+INTERP_RUNTIME = $(MINI_RUNTIME) --interpreter
 RUNTIME_AOTCHECK = MONO_PATH="$(CLASS)$(PLATFORM_PATH_SEPARATOR)." $(RUNTIME_EXECUTABLE)
 
 MCS = CSC_SDK_PATH_DISABLED= $(TOOLS_RUNTIME) $(CSC) -unsafe -nowarn:0162 -nologo -noconfig -r:$(CLASS)/mscorlib.dll -r:$(CLASS)/System.dll -r:$(CLASS)/System.Core.dll
@@ -388,15 +388,15 @@ endif
 endif
 
 if ENABLE_INTERPRETER
-interpreter_sources =  \
-       interpreter/hacks.h             \
-       interpreter/interp.h    \
-       interpreter/interp-internals.h  \
-       interpreter/interp.c    \
-       interpreter/mintops.h   \
-       interpreter/mintops.def \
-       interpreter/mintops.c   \
-       interpreter/transform.c
+interp_sources =       \
+       interp/hacks.h          \
+       interp/interp.h \
+       interp/interp-internals.h       \
+       interp/interp.c \
+       interp/mintops.h        \
+       interp/mintops.def      \
+       interp/mintops.c        \
+       interp/transform.c
 endif
 
 if ENABLE_LLVM
@@ -534,8 +534,14 @@ iregtests = \
        basic-float.exe \
        basic-long.exe \
        basic-calls.exe \
+       objects.exe \
+       arrays.exe \
+       basic-math.exe \
+       exceptions.exe \
+       devirtualization.exe \
        generics.exe \
-       objects.exe
+       basic-simd.exe \
+       basic-vectors.exe
 
 if X86
 arch_sources = $(x86_sources)
@@ -622,7 +628,7 @@ os_sources = $(darwin_sources) $(posix_sources)
 monobin_platform_ldflags=-framework CoreFoundation -framework Foundation
 endif
 
-libmini_la_SOURCES = $(common_sources) $(llvm_sources) $(llvm_runtime_sources) $(interpreter_sources) $(arch_sources) $(os_sources)
+libmini_la_SOURCES = $(common_sources) $(llvm_sources) $(llvm_runtime_sources) $(interp_sources) $(arch_sources) $(os_sources)
 libmini_la_CFLAGS = $(mono_CFLAGS)
 
 libmonoboehm_2_0_la_SOURCES =
@@ -747,7 +753,7 @@ rcheck: mono $(regtests)
        $(MINI_RUNTIME) --regression $(regtests)
 
 richeck: mono $(iregtests)
-       $(INTERPRETER_RUNTIME) --regression $(iregtests)
+       $(INTERP_RUNTIME) --regression $(iregtests)
 
 if ARM
 check-seq-points:
index c419dfa2b42abf4139037e97340225628b8670b3..7ff437f9f9d5e9e1585cc4ac2d9a890959ed0b41 100644 (file)
@@ -159,10 +159,17 @@ lower_memory_access (MonoCompile *cfg)
                for (ins = bb->code; ins; ins = ins->next) {
 handle_instruction:
                        switch (ins->opcode) {
-                       case OP_LDADDR:
-                               g_hash_table_insert (addr_loads, GINT_TO_POINTER (ins->dreg), ins);
-                               if (cfg->verbose_level > 2) { printf ("New address: "); mono_print_ins (ins); }
+                       case OP_LDADDR: {
+                               MonoInst *var = (MonoInst*)ins->inst_p0;
+                               if (var->flags & MONO_INST_VOLATILE) {
+                                       if (cfg->verbose_level > 2) { printf ("Found address to volatile var, can't take it: "); mono_print_ins (ins); }
+                               } else {
+                                       g_hash_table_insert (addr_loads, GINT_TO_POINTER (ins->dreg), ins);
+                                       if (cfg->verbose_level > 2) { printf ("New address: "); mono_print_ins (ins); }
+                               }
                                break;
+                       }
+
                        case OP_MOVE:
                                tmp = (MonoInst*)g_hash_table_lookup (addr_loads, GINT_TO_POINTER (ins->sreg1));
                                /*
index 00a3c6b901f86a6b0c92e4b9a2993dbb447f3e78..b3002716e46085da306e63dfef31888d1354d220 100644 (file)
@@ -318,6 +318,7 @@ class Tests
                return 0;
        }
 
+       [Category ("!INTERPRETER")]
        public static int test_0_multi_dimension_arrays () {
                int sum;
 
@@ -548,6 +549,7 @@ class Tests
                return 0;
        }
 
+       [Category ("!INTERPRETER")]
        public static int test_0_multidym_array_with_negative_lower_bound () {
                int[,] x = (int[,]) Array.CreateInstance(typeof (int), new int[] { 2, 2 }, new int[] { -2, -3 });
 
@@ -778,6 +780,7 @@ class Tests
        }
 
        // #13544
+       [Category ("!INTERPRETER")]
        public static int test_0_newarr_ovf () {
                if (!alloc_long (5000000000))
                        return 1;
index a2cf101450e792a1faf5177fdeb7e6b84ad06cbf..1174292433a87684b10a822ccaa3cdd8d27e9bf0 100644 (file)
@@ -113,6 +113,7 @@ public class VectorTests {
                return Vector2.Abs (v1);
        }
 
+       [Category ("!INTERPRETER")]
        public static int test_0_vector2_abs () {
                var v1 = new Vector2 (-1.0f, -2.0f);
                var v2 = new Vector2 (1.0f, 2.0f);
@@ -350,6 +351,7 @@ public class VectorTests {
                return Vector4.Abs (v1);
        }
 
+       [Category ("!INTERPRETER")]
        public static int test_0_vector4_abs () {
                var v1 = new Vector4 (-1.0f, -2.0f, -3.0f, -4.0f);
                var v2 = new Vector4 (1.0f, 2.0f, 3.0f, 4.0f);
@@ -588,6 +590,7 @@ public class VectorTests {
                return Vector3.Abs (v1);
        }
 
+       [Category ("!INTERPRETER")]
        public static int test_0_vector3_abs () {
                var v1 = new Vector3 (-1.0f, -2.0f, -3.0f);
                var v2 = new Vector3 (1.0f, 2.0f, 3.0f);
index 8f120de8683fd6b93dba923a01a2ff6686dabca4..ed1b7a14a7f3f502ef5708be026901355408022f 100644 (file)
@@ -998,7 +998,7 @@ mono_debugger_agent_init (void)
        /* Needed by the hash_table_new_type () call below */
        mono_gc_base_init ();
 
-       thread_to_tls = mono_g_hash_table_new_type (NULL, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_DEBUGGER, "thread-to-tls table");
+       thread_to_tls = mono_g_hash_table_new_type ((GHashFunc)mono_object_hash, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_DEBUGGER, "thread-to-tls table");
 
        tid_to_thread = mono_g_hash_table_new_type (NULL, NULL, MONO_HASH_VALUE_GC, MONO_ROOT_SOURCE_DEBUGGER, "tid-to-thread table");
 
@@ -1939,7 +1939,7 @@ objrefs_init (void)
 {
        objrefs = g_hash_table_new_full (NULL, NULL, NULL, free_objref);
        obj_to_objref = g_hash_table_new (NULL, NULL);
-       suspended_objs = mono_g_hash_table_new_type (NULL, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_DEBUGGER, "suspended objects table");
+       suspended_objs = mono_g_hash_table_new_type ((GHashFunc)mono_object_hash, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_DEBUGGER, "suspended objects table");
 }
 
 static void
index 860e1ca626fd48ee19f6ff11b4f3dd65e8b461d2..9674a350f904aa1434741540ab3db5f58c94ab10 100644 (file)
@@ -56,7 +56,7 @@
 #include "mini.h"
 #include "jit.h"
 #include "aot-compiler.h"
-#include "interpreter/interp.h"
+#include "interp/interp.h"
 
 #include <string.h>
 #include <ctype.h>
index 98c6046e61a5cdea5dab273ee1b289d63c26a7b5..4e11a7d4157c07e17bcc9151b92114dae72c3c1d 100644 (file)
@@ -981,6 +981,7 @@ class Tests
                return 0;
        }
        
+       [Category ("!INTERPRETER")]
        public static int test_0_int_cast () {
                int a;
                long l;
@@ -1462,6 +1463,7 @@ class Tests
                return 0;
        }
        
+       [Category ("!INTERPRETER")]
        [Category ("NaClDisable")]
        public static int test_0_div_zero () {
                int d = 1;
@@ -1633,6 +1635,7 @@ class Tests
                return 0;
        }
 
+       [Category ("!INTERPRETER")]
        [Category ("NaClDisable")]
        public static int test_0_long_div_zero () {
                long d = 1;
@@ -1800,6 +1803,7 @@ class Tests
                return 0;
        }
 
+       [Category ("!INTERPRETER")]
        public static int test_3_checked_cast_un () {
                 ulong i = 0x8000000034000000;
                 long j;
@@ -1815,6 +1819,7 @@ class Tests
                return 3;
        }
        
+       [Category ("!INTERPRETER")]
        public static int test_4_checked_cast () {
                 long i;
                 ulong j;
@@ -1842,6 +1847,7 @@ class Tests
                7, 0, 7, 1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7, 7, 7, 8,
        };
 
+       [Category ("!INTERPRETER")]
        public static int test_0_multi_dim_array_access () {
                int [,] a = System.Array.CreateInstance (typeof (int),
                        new int [] {3,6}, new int [] {2,2 }) as int[,];
@@ -1878,6 +1884,7 @@ class Tests
                o = "buddy";
        }
 
+       [Category ("!INTERPRETER")]
        public static int test_2_array_mismatch () {
                string[] a = { "hello", "world" };
                object[] b = a;
@@ -2230,6 +2237,7 @@ class Tests
                }
        }
 
+       [Category ("!INTERPRETER")]
        public static int test_0_exception_in_cctor () {
                try {
                        Broken.DoSomething ();
@@ -2318,6 +2326,7 @@ class Tests
                Console.WriteLine ();
        }
 
+       [Category ("!INTERPRETER")]
        [Category ("!BITCODE")]
        public static int test_0_rethrow_stacktrace () {
                // Check that rethrowing an exception preserves the original stack trace
@@ -2380,6 +2389,7 @@ class Tests
                }
        }
 
+       [Category ("!INTERPRETER")]
        public static int test_0_array_size () {
                bool failed;
 
@@ -2706,6 +2716,7 @@ class Tests
                public static Foo* pFoo;
        }
 
+       [Category ("!INTERPRETER")]
        /* MS.NET doesn't seem to throw in this case */
        public unsafe static int test_0_ldflda_null_pointer () {
                int* pi = &Foo.pFoo->i;
index 9defe79f3cc9ff701d1c4bd16da6c91db5f49653..8354e0ba3c104bdc84fc4a5071f49586b82ee7c0 100644 (file)
@@ -233,7 +233,42 @@ class Tests
                return 0;
        }
 
-       [Category ("!INTERPRETER")]
+       interface NonGenericInterface {
+               int return_field ();
+       }
+
+       interface GenericInterface<T> : NonGenericInterface {
+               T not_used ();
+       }
+
+       struct ImplementGenericInterface<T> : GenericInterface<T> {
+               public Object padding1;
+               public Object padding2;
+               public Object padding3;
+               public T[] arr_t;
+
+               public ImplementGenericInterface (T[] arr_t) {
+                       this.padding1 = null;
+                       this.padding2 = null;
+                       this.padding3 = null;
+                       this.arr_t = arr_t;
+               }
+
+               public T not_used () {
+                       return arr_t [0];
+               }
+
+               public int return_field () {
+                       return arr_t.Length;
+               }
+       }
+
+       public static int test_8_struct_implements_generic_interface () {
+               int[] arr = {1, 2, 3, 4};
+               NonGenericInterface s = new ImplementGenericInterface<int> (arr);
+               return s.return_field () + s.return_field ();
+       }
+
        public static int test_0_generic_get_value_optimization_vtype () {
                TestStruct[] arr = new TestStruct[] { new TestStruct (100, 200), new TestStruct (300, 400) };
                IEnumerator<TestStruct> enumerator = GenericClass<TestStruct>.Y (arr);
@@ -427,7 +462,6 @@ class Tests
        }
 #endif
 
-       [Category ("!INTERPRETER")]
        public static int test_0_ldvirtftn_generic_method () {
                new GenericsTests ().ldvirtftn<string> ();
 
@@ -454,7 +488,6 @@ class Tests
        // This cannot be made to work with full-aot, since there it is impossible to
        // statically determine that Foo<string>.Bar <int> is needed, the code only
        // references IFoo.Bar<int>
-       [Category ("!INTERPRETER")]
        [Category ("!FULLAOT")]
        public static int test_0_generic_virtual_on_interfaces () {
                Foo<string>.count1 = 0;
@@ -480,7 +513,6 @@ class Tests
                return 0;
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_0_generic_virtual_on_interfaces_ref () {
                Foo<string>.count1 = 0;
                Foo<string>.count2 = 0;
@@ -520,7 +552,6 @@ class Tests
                Value_2 = 2
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_0_regress_550964_constrained_enum_long () {
         MyEnumUlong a = MyEnumUlong.Value_2;
         MyEnumUlong b = MyEnumUlong.Value_2;
@@ -562,7 +593,6 @@ class Tests
                int c = ((ICollection<T>)arr).Count;
        }
 
-       [Category ("!INTERPRETER")]
        /* Test that treating arrays as generic collections works with full-aot */
        public static int test_0_fullaot_array_wrappers () {
                GenericsTests[] arr = new GenericsTests [10];
@@ -622,7 +652,6 @@ class Tests
                return typeof (T);
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_0_gshared_delegate_rgctx () {
                Func<Type> t = new Func<Type> (get_type<string>);
 
@@ -632,7 +661,6 @@ class Tests
                        return 1;
        }
 
-       [Category ("!INTERPRETER")]
        // Creating a delegate from a generic method from gshared code
        public static int test_0_gshared_delegate_from_gshared () {
                if (gshared_delegate_from_gshared <object> () != 0)
@@ -664,7 +692,6 @@ class Tests
                public delegate TRet Transform<TRet> (TKey key, TValue value);
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_0_bug_620864 () {
                var d = new Pair<string, Type>.Transform<KeyValuePair<string, Type>> (Pair<string, Type>.make_pair);
 
@@ -721,7 +748,6 @@ class Tests
                return 0;
        }
 
-       [Category ("!INTERPRETER")]
        [Category ("GSHAREDVT")]
        public static int test_6_partial_sharing_linq () {
                var messages = new List<Message> ();
@@ -732,7 +758,6 @@ class Tests
                return messages.Max(i => i.MessageID);
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_0_partial_shared_method_in_nonshared_class () {
                var c = new Class1<double> ();
                return (c.Foo<string> (5).GetType () == typeof (Class1<string>)) ? 0 : 1;
@@ -909,7 +934,6 @@ class Tests
                }
        }
 
-       [Category ("!INTERPRETER")]
        [Category ("!FULLAOT")]
        [Category ("!BITCODE")]
        public static int test_0_regress_668095_synchronized_gshared () {
@@ -1256,7 +1280,6 @@ class Tests
 
        static object delegate_8_args_res;
 
-       [Category ("!INTERPRETER")]
        public static int test_0_delegate_8_args () {
                delegate_8_args_res = null;
                Action<string, string, string, string, string, string, string,
diff --git a/mono/mini/interp/hacks.h b/mono/mini/interp/hacks.h
new file mode 100644 (file)
index 0000000..9697ccb
--- /dev/null
@@ -0,0 +1,153 @@
+/* we need some special math function */
+#ifndef _ISOC99_SOURCE
+#define _ISOC99_SOURCE
+#endif
+#include <math.h>
+
+/* which are not defined on FreeBSD */
+#ifdef __GNUC__
+
+#ifndef isunordered
+#   define isunordered(u, v)                              \
+    (__extension__                                        \
+     ({ __typeof__(u) __u = (u); __typeof__(v) __v = (v); \
+        isnan(__u) || isnan(__v); }))
+#endif
+
+#ifndef islessgreater
+#   define islessgreater(x, u)                                    \
+    (__extension__                                                \
+     ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);         \
+        !isunordered (__x, __y) && (__x < __y) || (__y < __x); }))
+#endif
+
+#ifndef islessequal
+#   define islessequal(x, y)                              \
+    (__extension__                                        \
+     ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
+        !isunordered(__x, __y) && __x <= __y; })) 
+#endif
+
+#ifndef isless
+#   define isless(x, y)                                   \
+    (__extension__                                        \
+     ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
+        !isunordered(__x, __y) && __x < __y; })) 
+#endif
+
+#ifndef isgreater
+#   define isgreater(x, y)                                \
+    (__extension__                                        \
+     ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
+        !isunordered(__x, __y) && __x > __y; }))
+#endif
+
+#else
+
+/*  isunordered seems to crash on HPUX when built 64 bits
+    so use generic implementation.
+*/
+#if defined(__hpux) && SIZEOF_VOID_P == 8
+#undef isunordered
+#undef islessgreater
+#undef islessequal
+#undef isless
+#undef isgreater
+#endif
+
+#ifndef isunordered
+#   define isunordered(u, v) (isnan(u) || isnan(v))
+#endif
+
+#ifndef islessgreater
+#   define islessgreater(x, u) (!isunordered (x, y) && (x < y) || (y < x))
+#endif
+
+#ifndef islessequal
+#   define islessequal(x, y) (!isunordered(x, y) && x <= y)
+#endif
+
+#ifndef isless
+#   define isless(x, y) (!isunordered(x, y) && x < y) 
+#endif
+
+#ifndef isgreater
+#   define isgreater(x, y) (!isunordered(x, y) && x > y)
+#endif
+
+#endif
+
+/*
+ * Attempt at using the goto label construct of GNU GCC:
+ * it turns out this does give some benefit: 5-15% speedup.
+ * Don't look at these macros, it hurts...
+ */
+#define GOTO_LABEL
+#undef GOTO_LABEL
+#ifdef GOTO_LABEL
+
+#define SWITCH(a) goto *goto_map [(a)];
+#define BREAK SWITCH(*ip)
+#define CASE(l)        l ## _LABEL:
+#define DEFAULT        \
+       CEE_ILLEGAL_LABEL:      \
+       CEE_ENDMAC_LABEL:
+#define SUB_SWITCH \
+       CEE_PREFIX1_LABEL: \
+       CEE_ARGLIST_LABEL: \
+       CEE_CEQ_LABEL: \
+       CEE_CGT_LABEL: \
+       CEE_CGT_UN_LABEL: \
+       CEE_CLT_LABEL: \
+       CEE_CLT_UN_LABEL: \
+       CEE_LDFTN_LABEL: \
+       CEE_LDVIRTFTN_LABEL: \
+       CEE_UNUSED56_LABEL: \
+       CEE_LDARG_LABEL: \
+       CEE_LDARGA_LABEL: \
+       CEE_STARG_LABEL: \
+       CEE_LDLOC_LABEL: \
+       CEE_LDLOCA_LABEL: \
+       CEE_STLOC_LABEL: \
+       CEE_LOCALLOC_LABEL: \
+       CEE_UNUSED57_LABEL: \
+       CEE_ENDFILTER_LABEL: \
+       CEE_UNALIGNED__LABEL: \
+       CEE_VOLATILE__LABEL: \
+       CEE_TAIL__LABEL: \
+       CEE_INITOBJ_LABEL: \
+       CEE_UNUSED68_LABEL: \
+       CEE_CPBLK_LABEL: \
+       CEE_INITBLK_LABEL: \
+       CEE_UNUSED69_LABEL: \
+       CEE_RETHROW_LABEL: \
+       CEE_UNUSED_LABEL: \
+       CEE_SIZEOF_LABEL: \
+       CEE_REFANYTYPE_LABEL: \
+       CEE_UNUSED52_LABEL: \
+       CEE_UNUSED53_LABEL: \
+       CEE_UNUSED54_LABEL: \
+       CEE_UNUSED55_LABEL: \
+       CEE_UNUSED70_LABEL:
+#define GOTO_LABEL_VARS \
+       const static void * const goto_map [] = {\
+#define OPDEF(a,b,c,d,e,f,g,h,i,j) \   \
+       && a ## _LABEL, \
+#include "mono/cil/opcode.def" \
+#undef OPDEF   \
+       &&DUMMY_LABEL   \
+       };      \
+       DUMMY_LABEL:
+
+#else
+       
+#define SWITCH(a) switch(a)
+#define BREAK  break
+#define CASE(l)        case l:
+#define DEFAULT        \
+               default:        \
+                       g_error ("Unimplemented opcode: %x at 0x%x\n", *ip, ip-header->code);
+#define SUB_SWITCH case 0xFE:
+#define GOTO_LABEL_VARS
+
+#endif
diff --git a/mono/mini/interp/interp-internals.h b/mono/mini/interp/interp-internals.h
new file mode 100644 (file)
index 0000000..f26e4ff
--- /dev/null
@@ -0,0 +1,124 @@
+#ifndef __MONO_MINI_INTERPRETER_INTERNALS_H__
+#define __MONO_MINI_INTERPRETER_INTERNALS_H__
+
+#include <setjmp.h>
+#include <glib.h>
+#include <mono/metadata/loader.h>
+#include <mono/metadata/object.h>
+#include <mono/metadata/domain-internals.h>
+#include <mono/metadata/class-internals.h>
+#include "config.h"
+
+enum {
+       VAL_I32     = 0,
+       VAL_DOUBLE  = 1,
+       VAL_I64     = 2,
+       VAL_VALUET  = 3,
+       VAL_POINTER = 4,
+       VAL_NATI    = 0 + VAL_POINTER,
+       VAL_MP      = 1 + VAL_POINTER,
+       VAL_TP      = 2 + VAL_POINTER,
+       VAL_OBJ     = 3 + VAL_POINTER
+};
+
+#if SIZEOF_VOID_P == 4
+typedef guint32 mono_u;
+typedef gint32  mono_i;
+#elif SIZEOF_VOID_P == 8
+typedef guint64 mono_u;
+typedef gint64  mono_i;
+#endif
+
+/*
+ * Value types are represented on the eval stack as pointers to the
+ * actual storage. The size field tells how much storage is allocated.
+ * A value type can't be larger than 16 MB.
+ */
+typedef struct {
+       union {
+               gint32 i;
+               gint64 l;
+               double f;
+               /* native size integer and pointer types */
+               gpointer p;
+               mono_u nati;
+               gpointer vt;
+       } data;
+#if defined(__ppc__) || defined(__powerpc__)
+       int pad;
+#endif
+} stackval;
+
+typedef struct _MonoInvocation MonoInvocation;
+
+typedef void (*MonoFuncV) (void);
+typedef void (*MonoPIFunc) (MonoFuncV callme, void *margs);
+
+/* 
+ * Structure representing a method transformed for the interpreter 
+ * This is domain specific
+ */
+typedef struct _RuntimeMethod
+{
+       /* NOTE: These first two elements (method and
+          next_jit_code_hash) must be in the same order and at the
+          same offset as in MonoJitInfo, because of the jit_code_hash
+          internal hash table in MonoDomain. */
+       MonoMethod *method;
+       struct _RuntimeMethod *next_jit_code_hash;
+       guint32 locals_size;
+       guint32 args_size;
+       guint32 stack_size;
+       guint32 vt_stack_size;
+       guint32 alloca_size;
+       unsigned short *code;
+       unsigned short *new_body_start; /* after all STINARG instrs */
+       MonoPIFunc func;
+       int num_clauses;
+       MonoExceptionClause *clauses;
+       void **data_items;
+       int transformed;
+       guint32 *arg_offsets;
+       guint32 *local_offsets;
+       unsigned int param_count;
+       unsigned int hasthis;
+} RuntimeMethod;
+
+struct _MonoInvocation {
+       MonoInvocation *parent; /* parent */
+       RuntimeMethod  *runtime_method; /* parent */
+       MonoMethod     *method; /* parent */
+       stackval       *retval; /* parent */
+       char           *args;
+       stackval       *stack_args; /* parent */
+       stackval       *stack;
+       stackval       *sp; /* For GC stack marking */
+       /* exception info */
+       unsigned char  invoke_trap;
+       const unsigned short  *ip;
+       MonoException     *ex;
+       MonoExceptionClause *ex_handler;
+};
+
+typedef struct {
+       MonoDomain *domain;
+       MonoInvocation *base_frame;
+       MonoInvocation *current_frame;
+       MonoInvocation *env_frame;
+       jmp_buf *current_env;
+       unsigned char search_for_handler;
+       unsigned char managed_code;
+} ThreadContext;
+
+extern int mono_interp_traceopt;
+
+MonoException *
+mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *context);
+
+void
+mono_interp_transform_init (void);
+
+RuntimeMethod *
+mono_interp_get_runtime_method (MonoDomain *domain, MonoMethod *method, MonoError *error);
+
+#endif /* __MONO_MINI_INTERPRETER_INTERNALS_H__ */
diff --git a/mono/mini/interp/interp.c b/mono/mini/interp/interp.c
new file mode 100644 (file)
index 0000000..9c21f95
--- /dev/null
@@ -0,0 +1,4550 @@
+/*
+ * PLEASE NOTE: This is a research prototype.
+ *
+ *
+ * interp.c: Interpreter for CIL byte codes
+ *
+ * Authors:
+ *   Paolo Molaro (lupus@ximian.com)
+ *   Miguel de Icaza (miguel@ximian.com)
+ *   Dietmar Maurer (dietmar@ximian.com)
+ *
+ * (C) 2001, 2002 Ximian, Inc.
+ */
+#ifndef __USE_ISOC99
+#define __USE_ISOC99
+#endif
+#include "config.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <glib.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <math.h>
+#include <locale.h>
+
+#include <mono/utils/gc_wrapper.h>
+
+#ifdef HAVE_ALLOCA_H
+#   include <alloca.h>
+#else
+#   ifdef __CYGWIN__
+#      define alloca __builtin_alloca
+#   endif
+#endif
+
+/* trim excessive headers */
+#include <mono/metadata/image.h>
+#include <mono/metadata/assembly.h>
+#include <mono/metadata/cil-coff.h>
+#include <mono/metadata/mono-endian.h>
+#include <mono/metadata/tabledefs.h>
+#include <mono/metadata/tokentype.h>
+#include <mono/metadata/loader.h>
+#include <mono/metadata/threads.h>
+#include <mono/metadata/threadpool.h>
+#include <mono/metadata/profiler-private.h>
+#include <mono/metadata/appdomain.h>
+#include <mono/metadata/reflection.h>
+#include <mono/metadata/reflection-internals.h>
+#include <mono/metadata/exception.h>
+#include <mono/metadata/verify.h>
+#include <mono/metadata/opcodes.h>
+#include <mono/metadata/debug-helpers.h>
+#include <mono/metadata/mono-config.h>
+#include <mono/metadata/marshal.h>
+#include <mono/metadata/environment.h>
+#include <mono/metadata/mono-debug.h>
+
+#include "interp.h"
+#include "interp-internals.h"
+#include "mintops.h"
+#include "hacks.h"
+
+#include <mono/mini/mini.h>
+#include <mono/mini/jit-icalls.h>
+
+
+/* Mingw 2.1 doesnt need this any more, but leave it in for now for older versions */
+#ifdef _WIN32
+#define isnan _isnan
+#define finite _finite
+#endif
+#ifndef HAVE_FINITE
+#ifdef HAVE_ISFINITE
+#define finite isfinite
+#endif
+#endif
+
+#define INIT_FRAME(frame,parent_frame,method_args,method_retval,domain,mono_method,error)      \
+       do {    \
+               (frame)->parent = (parent_frame);       \
+               (frame)->stack_args = (method_args);    \
+               (frame)->retval = (method_retval);      \
+               (frame)->runtime_method = mono_interp_get_runtime_method ((domain), (mono_method), (error));    \
+               (frame)->ex = NULL;     \
+               (frame)->ip = NULL;     \
+               (frame)->invoke_trap = 0;       \
+       } while (0)
+
+void ves_exec_method (MonoInvocation *frame);
+
+static char* dump_stack (stackval *stack, stackval *sp);
+static char* dump_frame (MonoInvocation *inv);
+static MonoArray *get_trace_ips (MonoDomain *domain, MonoInvocation *top);
+static void ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context);
+
+typedef void (*ICallMethod) (MonoInvocation *frame);
+
+static guint32 die_on_exception = 0;
+static MonoNativeTlsKey thread_context_id;
+
+static char* dump_args (MonoInvocation *inv);
+
+#define DEBUG_INTERP 0
+#define COUNT_OPS 0
+#if DEBUG_INTERP
+int mono_interp_traceopt = 2;
+/* If true, then we output the opcodes as we interpret them */
+static int global_tracing = 2;
+
+static int debug_indent_level = 0;
+
+static int break_on_method = 0;
+static int nested_trace = 0;
+static GList *db_methods = NULL;
+
+static void
+output_indent (void)
+{
+       int h;
+
+       for (h = 0; h < debug_indent_level; h++)
+               g_print ("  ");
+}
+
+static void
+db_match_method (gpointer data, gpointer user_data)
+{
+       MonoMethod *m = (MonoMethod*)user_data;
+       MonoMethodDesc *desc = data;
+
+       if (mono_method_desc_full_match (desc, m))
+               break_on_method = 1;
+}
+
+static void debug_enter (MonoInvocation *frame, int *tracing)
+{
+       if (db_methods) {
+               g_list_foreach (db_methods, db_match_method, (gpointer)frame->runtime_method->method);
+               if (break_on_method)
+                       *tracing = nested_trace ? (global_tracing = 2, 3) : 2;
+               break_on_method = 0;
+       }
+       if (*tracing) {
+               MonoMethod *method = frame->runtime_method->method;
+               char *mn, *args = dump_args (frame);
+               debug_indent_level++;
+               output_indent ();
+               mn = mono_method_full_name (method, FALSE);
+               g_print ("(%p) Entering %s (", mono_thread_internal_current (), mn);
+               g_free (mn);
+               g_print  ("%s)\n", args);
+               g_free (args);
+       }
+       if (mono_profiler_events & MONO_PROFILE_ENTER_LEAVE)
+               mono_profiler_method_enter (frame->runtime_method->method);
+}
+
+
+#define DEBUG_LEAVE()  \
+       if (tracing) {  \
+               char *mn, *args;        \
+               args = dump_retval (frame);     \
+               output_indent ();       \
+               mn = mono_method_full_name (frame->runtime_method->method, FALSE); \
+               g_print  ("(%p) Leaving %s", mono_thread_internal_current (),  mn);     \
+               g_free (mn); \
+               g_print  (" => %s\n", args);    \
+               g_free (args);  \
+               debug_indent_level--;   \
+               if (tracing == 3) global_tracing = 0; \
+       }       \
+       if (mono_profiler_events & MONO_PROFILE_ENTER_LEAVE)    \
+               mono_profiler_method_leave (frame->runtime_method->method);
+
+#else
+
+int mono_interp_traceopt = 0;
+static void debug_enter (MonoInvocation *frame, int *tracing)
+{
+}
+#define DEBUG_LEAVE()
+
+#endif
+
+static void
+interp_ex_handler (MonoException *ex) {
+       MonoError error;
+       ThreadContext *context = mono_native_tls_get_value (thread_context_id);
+       char *stack_trace;
+       if (context == NULL)
+               return;
+       stack_trace = dump_frame (context->current_frame);
+       ex->stack_trace = mono_string_new (mono_domain_get(), stack_trace);
+       g_free (stack_trace);
+       if (context->current_env == NULL || strcmp(ex->object.vtable->klass->name, "ExecutionEngineException") == 0) {
+               char *strace = mono_string_to_utf8_checked (ex->stack_trace, &error);
+               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+               fprintf(stderr, "Nothing can catch this exception: ");
+               fprintf(stderr, "%s", ex->object.vtable->klass->name);
+               if (ex->message != NULL) {
+                       char *m = mono_string_to_utf8_checked (ex->message, &error);
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       fprintf(stderr, ": %s", m);
+                       g_free(m);
+               }
+               fprintf(stderr, "\n%s\n", strace);
+               g_free (strace);
+               if (ex->inner_ex != NULL) {
+                       ex = (MonoException *)ex->inner_ex;
+                       fprintf(stderr, "Inner exception: %s", ex->object.vtable->klass->name);
+                       if (ex->message != NULL) {
+                               char *m = mono_string_to_utf8_checked (ex->message, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                               fprintf(stderr, ": %s", m);
+                               g_free(m);
+                       }
+                       strace = mono_string_to_utf8_checked (ex->stack_trace, &error);
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       fprintf(stderr, "\n");
+                       fprintf(stderr, "%s\n", strace);
+                       g_free (strace);
+               }
+               /* wait for other threads to also collapse */
+               // Sleep(1000); // TODO: proper sleep
+               exit(1);
+       }
+       context->env_frame->ex = ex;
+       context->search_for_handler = 1;
+       longjmp (*context->current_env, 1);
+}
+
+static void
+ves_real_abort (int line, MonoMethod *mh,
+               const unsigned short *ip, stackval *stack, stackval *sp)
+{
+       MonoError error;
+       fprintf (stderr, "Execution aborted in method: %s::%s\n", mh->klass->name, mh->name);
+       fprintf (stderr, "Line=%d IP=0x%04lx, Aborted execution\n", line,
+                ip-(const unsigned short *)mono_method_get_header_checked (mh, &error)->code);
+               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+       g_print ("0x%04x %02x\n",
+                ip-(const unsigned short *)mono_method_get_header_checked (mh, &error)->code, *ip);
+       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+       if (sp > stack)
+               printf ("\t[%ld] 0x%08x %0.5f\n", sp-stack, sp[-1].data.i, sp[-1].data.f);
+}
+
+#define ves_abort() \
+       do {\
+               ves_real_abort(__LINE__, frame->runtime_method->method, ip, frame->stack, sp); \
+               THROW_EX (mono_get_exception_execution_engine (NULL), ip); \
+       } while (0);
+
+static mono_mutex_t runtime_method_lookup_section;
+
+RuntimeMethod*
+mono_interp_get_runtime_method (MonoDomain *domain, MonoMethod *method, MonoError *error)
+{
+       RuntimeMethod *rtm;
+       error_init (error);
+
+       mono_os_mutex_lock (&runtime_method_lookup_section);
+       if ((rtm = mono_internal_hash_table_lookup (&domain->jit_code_hash, method))) {
+               mono_os_mutex_unlock (&runtime_method_lookup_section);
+               return rtm;
+       }
+       rtm = mono_mempool_alloc (domain->mp, sizeof (RuntimeMethod));
+       memset (rtm, 0, sizeof (*rtm));
+       rtm->method = method;
+       rtm->param_count = mono_method_signature (method)->param_count;
+       rtm->hasthis = mono_method_signature (method)->hasthis;
+       mono_internal_hash_table_insert (&domain->jit_code_hash, method, rtm);
+       mono_os_mutex_unlock (&runtime_method_lookup_section);
+
+       return rtm;
+}
+
+static gpointer
+interp_create_trampoline (MonoDomain *domain, MonoMethod *method, MonoError *error)
+{
+       if (method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
+               method = mono_marshal_get_synchronized_wrapper (method);
+       return mono_interp_get_runtime_method (domain, method, error);
+}
+
+static inline RuntimeMethod*
+get_virtual_method (MonoDomain *domain, RuntimeMethod *runtime_method, MonoObject *obj)
+{
+       MonoMethod *m = runtime_method->method;
+       MonoError error;
+
+       if ((m->flags & METHOD_ATTRIBUTE_FINAL) || !(m->flags & METHOD_ATTRIBUTE_VIRTUAL)) {
+               RuntimeMethod *ret = NULL;
+               if (mono_object_is_transparent_proxy (obj)) {
+                       ret = mono_interp_get_runtime_method (domain, mono_marshal_get_remoting_invoke (m), &error);
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+               } else if (m->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) {
+                       ret = mono_interp_get_runtime_method (domain, mono_marshal_get_synchronized_wrapper (m), &error);
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+               } else {
+                       ret = runtime_method;
+               }
+               return ret;
+       }
+
+       mono_class_setup_vtable (obj->vtable->klass);
+
+       int slot = mono_method_get_vtable_slot (m);
+       if (mono_class_is_interface (m->klass)) {
+               g_assert (obj->vtable->klass != m->klass);
+               /* TODO: interface offset lookup is slow, go through IMT instead */
+               slot += mono_class_interface_offset (obj->vtable->klass, m->klass);
+       }
+
+       MonoMethod *virtual_method = obj->vtable->klass->vtable [slot];
+       if (m->is_inflated && mono_method_get_context (m)->method_inst) {
+               MonoGenericContext context = { NULL, NULL };
+
+               if (mono_class_is_ginst (virtual_method->klass))
+                       context.class_inst = mono_class_get_generic_class (virtual_method->klass)->context.class_inst;
+               else if (mono_class_is_gtd (virtual_method->klass))
+                       context.class_inst = mono_class_get_generic_container (virtual_method->klass)->context.class_inst;
+               context.method_inst = mono_method_get_context (m)->method_inst;
+
+               virtual_method = mono_class_inflate_generic_method_checked (virtual_method, &context, &error);
+               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+       }
+       RuntimeMethod *virtual_runtime_method = mono_interp_get_runtime_method (domain, virtual_method, &error);
+       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+       return virtual_runtime_method;
+}
+
+static void inline
+stackval_from_data (MonoType *type, stackval *result, char *data, gboolean pinvoke)
+{
+       if (type->byref) {
+               switch (type->type) {
+               case MONO_TYPE_OBJECT:
+               case MONO_TYPE_CLASS:
+               case MONO_TYPE_STRING:
+               case MONO_TYPE_ARRAY:
+               case MONO_TYPE_SZARRAY:
+                       break;
+               default:
+                       break;
+               }
+               result->data.p = *(gpointer*)data;
+               return;
+       }
+       switch (type->type) {
+       case MONO_TYPE_VOID:
+               return;
+       case MONO_TYPE_I1:
+               result->data.i = *(gint8*)data;
+               return;
+       case MONO_TYPE_U1:
+       case MONO_TYPE_BOOLEAN:
+               result->data.i = *(guint8*)data;
+               return;
+       case MONO_TYPE_I2:
+               result->data.i = *(gint16*)data;
+               return;
+       case MONO_TYPE_U2:
+       case MONO_TYPE_CHAR:
+               result->data.i = *(guint16*)data;
+               return;
+       case MONO_TYPE_I4:
+               result->data.i = *(gint32*)data;
+               return;
+       case MONO_TYPE_U:
+       case MONO_TYPE_I:
+               result->data.nati = *(mono_i*)data;
+               return;
+       case MONO_TYPE_PTR:
+               result->data.p = *(gpointer*)data;
+               return;
+       case MONO_TYPE_U4:
+               result->data.i = *(guint32*)data;
+               return;
+       case MONO_TYPE_R4:
+               result->data.f = *(float*)data;
+               return;
+       case MONO_TYPE_I8:
+       case MONO_TYPE_U8:
+               result->data.l = *(gint64*)data;
+               return;
+       case MONO_TYPE_R8:
+               result->data.f = *(double*)data;
+               return;
+       case MONO_TYPE_STRING:
+       case MONO_TYPE_SZARRAY:
+       case MONO_TYPE_CLASS:
+       case MONO_TYPE_OBJECT:
+       case MONO_TYPE_ARRAY:
+               result->data.p = *(gpointer*)data;
+               return;
+       case MONO_TYPE_VALUETYPE:
+               if (type->data.klass->enumtype) {
+                       stackval_from_data (mono_class_enum_basetype (type->data.klass), result, data, pinvoke);
+                       return;
+               } else
+                       mono_value_copy (result->data.vt, data, type->data.klass);
+               return;
+       case MONO_TYPE_GENERICINST:
+               stackval_from_data (&type->data.generic_class->container_class->byval_arg, result, data, pinvoke);
+               return;
+       default:
+               g_warning ("got type 0x%02x", type->type);
+               g_assert_not_reached ();
+       }
+}
+
+static void inline
+stackval_to_data (MonoType *type, stackval *val, char *data, gboolean pinvoke)
+{
+       if (type->byref) {
+               gpointer *p = (gpointer*)data;
+               *p = val->data.p;
+               return;
+       }
+       /* printf ("TODAT0 %p\n", data); */
+       switch (type->type) {
+       case MONO_TYPE_I1:
+       case MONO_TYPE_U1: {
+               guint8 *p = (guint8*)data;
+               *p = val->data.i;
+               return;
+       }
+       case MONO_TYPE_BOOLEAN: {
+               guint8 *p = (guint8*)data;
+               *p = (val->data.i != 0);
+               return;
+       }
+       case MONO_TYPE_I2:
+       case MONO_TYPE_U2:
+       case MONO_TYPE_CHAR: {
+               guint16 *p = (guint16*)data;
+               *p = val->data.i;
+               return;
+       }
+       case MONO_TYPE_I: {
+               mono_i *p = (mono_i*)data;
+               /* In theory the value used by stloc should match the local var type
+                  but in practice it sometimes doesn't (a int32 gets dup'd and stloc'd into
+                  a native int - both by csc and mcs). Not sure what to do about sign extension
+                  as it is outside the spec... doing the obvious */
+               *p = (mono_i)val->data.nati;
+               return;
+       }
+       case MONO_TYPE_U: {
+               mono_u *p = (mono_u*)data;
+               /* see above. */
+               *p = (mono_u)val->data.nati;
+               return;
+       }
+       case MONO_TYPE_I4:
+       case MONO_TYPE_U4: {
+               gint32 *p = (gint32*)data;
+               *p = val->data.i;
+               return;
+       }
+       case MONO_TYPE_I8:
+       case MONO_TYPE_U8: {
+               gint64 *p = (gint64*)data;
+               *p = val->data.l;
+               return;
+       }
+       case MONO_TYPE_R4: {
+               float *p = (float*)data;
+               *p = val->data.f;
+               return;
+       }
+       case MONO_TYPE_R8: {
+               double *p = (double*)data;
+               *p = val->data.f;
+               return;
+       }
+       case MONO_TYPE_STRING:
+       case MONO_TYPE_SZARRAY:
+       case MONO_TYPE_CLASS:
+       case MONO_TYPE_OBJECT:
+       case MONO_TYPE_ARRAY:
+       case MONO_TYPE_PTR: {
+               gpointer *p = (gpointer*)data;
+               *p = val->data.p;
+               return;
+       }
+       case MONO_TYPE_VALUETYPE:
+               if (type->data.klass->enumtype) {
+                       stackval_to_data (mono_class_enum_basetype (type->data.klass), val, data, pinvoke);
+                       return;
+               } else
+                       mono_value_copy (data, val->data.vt, type->data.klass);
+               return;
+       case MONO_TYPE_GENERICINST:
+               stackval_to_data (&type->data.generic_class->container_class->byval_arg, val, data, pinvoke);
+               return;
+       default:
+               g_warning ("got type %x", type->type);
+               g_assert_not_reached ();
+       }
+}
+
+static void
+fill_in_trace (MonoException *exception, MonoInvocation *frame)
+{
+       char *stack_trace = dump_frame (frame);
+       MonoDomain *domain = mono_domain_get();
+       (exception)->stack_trace = mono_string_new (domain, stack_trace);
+       (exception)->trace_ips = get_trace_ips (domain, frame);
+       g_free (stack_trace);
+}
+
+#define FILL_IN_TRACE(exception, frame) fill_in_trace(exception, frame)
+
+#define THROW_EX(exception,ex_ip)      \
+       do {\
+               frame->ip = (ex_ip);            \
+               frame->ex = (MonoException*)(exception);        \
+               FILL_IN_TRACE(frame->ex, frame); \
+               goto handle_exception;  \
+       } while (0)
+
+static MonoObject*
+ves_array_create (MonoDomain *domain, MonoClass *klass, MonoMethodSignature *sig, stackval *values)
+{
+       uintptr_t *lengths;
+       intptr_t *lower_bounds;
+       MonoObject *obj;
+       MonoError error;
+       int i;
+
+       lengths = alloca (sizeof (uintptr_t) * klass->rank * 2);
+       for (i = 0; i < sig->param_count; ++i) {
+               lengths [i] = values->data.i;
+               values ++;
+       }
+       if (klass->rank == sig->param_count) {
+               /* Only lengths provided. */
+               lower_bounds = NULL;
+       } else {
+               /* lower bounds are first. */
+               lower_bounds = (intptr_t *) lengths;
+               lengths += klass->rank;
+       }
+       obj = (MonoObject*) mono_array_new_full_checked (domain, klass, lengths, lower_bounds, &error);
+       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+       return obj;
+}
+
+static void 
+ves_array_set (MonoInvocation *frame)
+{
+       stackval *sp = frame->stack_args + 1;
+       MonoObject *o;
+       MonoArray *ao;
+       MonoClass *ac;
+       gint32 i, t, pos, esize;
+       gpointer ea;
+       MonoType *mt;
+
+       o = frame->stack_args->data.p;
+       ao = (MonoArray *)o;
+       ac = o->vtable->klass;
+
+       g_assert (ac->rank >= 1);
+
+       pos = sp [0].data.i;
+       if (ao->bounds != NULL) {
+               pos -= ao->bounds [0].lower_bound;
+               for (i = 1; i < ac->rank; i++) {
+                       if ((t = sp [i].data.i - ao->bounds [i].lower_bound) >= 
+                           ao->bounds [i].length) {
+                               frame->ex = mono_get_exception_index_out_of_range ();
+                               FILL_IN_TRACE(frame->ex, frame);
+                               return;
+                       }
+                       pos = pos*ao->bounds [i].length + sp [i].data.i - 
+                               ao->bounds [i].lower_bound;
+               }
+       } else if (pos >= ao->max_length) {
+               frame->ex = mono_get_exception_index_out_of_range ();
+               FILL_IN_TRACE(frame->ex, frame);
+               return;
+       }
+
+       if (sp [ac->rank].data.p && !mono_object_class (o)->element_class->valuetype) {
+               MonoError error;
+               MonoObject *isinst = mono_object_isinst_checked (sp [ac->rank].data.p, mono_object_class (o)->element_class, &error);
+               mono_error_cleanup (&error);
+               if (!isinst) {
+                       frame->ex = mono_get_exception_array_type_mismatch ();
+                       FILL_IN_TRACE (frame->ex, frame);
+                       return;
+               }
+       }
+
+       esize = mono_array_element_size (ac);
+       ea = mono_array_addr_with_size (ao, esize, pos);
+
+       mt = mono_method_signature (frame->runtime_method->method)->params [ac->rank];
+       stackval_to_data (mt, &sp [ac->rank], ea, FALSE);
+}
+
+static void 
+ves_array_get (MonoInvocation *frame)
+{
+       stackval *sp = frame->stack_args + 1;
+       MonoObject *o;
+       MonoArray *ao;
+       MonoClass *ac;
+       gint32 i, t, pos, esize;
+       gpointer ea;
+       MonoType *mt;
+
+       o = frame->stack_args->data.p;
+       ao = (MonoArray *)o;
+       ac = o->vtable->klass;
+
+       g_assert (ac->rank >= 1);
+
+       pos = sp [0].data.i;
+       if (ao->bounds != NULL) {
+               pos -= ao->bounds [0].lower_bound;
+               for (i = 1; i < ac->rank; i++) {
+                       if ((t = sp [i].data.i - ao->bounds [i].lower_bound) >= 
+                           ao->bounds [i].length) {
+                               frame->ex = mono_get_exception_index_out_of_range ();
+                               FILL_IN_TRACE(frame->ex, frame);
+                               return;
+                       }
+
+                       pos = pos*ao->bounds [i].length + sp [i].data.i - 
+                               ao->bounds [i].lower_bound;
+               }
+       } else if (pos >= ao->max_length) {
+               frame->ex = mono_get_exception_index_out_of_range ();
+               FILL_IN_TRACE(frame->ex, frame);
+               return;
+       }
+
+       esize = mono_array_element_size (ac);
+       ea = mono_array_addr_with_size (ao, esize, pos);
+
+       mt = mono_method_signature (frame->runtime_method->method)->ret;
+       stackval_from_data (mt, frame->retval, ea, FALSE);
+}
+
+static void
+ves_array_element_address (MonoInvocation *frame)
+{
+       stackval *sp = frame->stack_args + 1;
+       MonoObject *o;
+       MonoArray *ao;
+       MonoClass *ac;
+       gint32 i, t, pos, esize;
+       gpointer ea;
+
+       o = frame->stack_args->data.p;
+       ao = (MonoArray *)o;
+       ac = o->vtable->klass;
+
+       g_assert (ac->rank >= 1);
+
+       pos = sp [0].data.i;
+       if (ao->bounds != NULL) {
+               pos -= ao->bounds [0].lower_bound;
+               for (i = 1; i < ac->rank; i++) {
+                       if ((t = sp [i].data.i - ao->bounds [i].lower_bound) >= 
+                           ao->bounds [i].length) {
+                               frame->ex = mono_get_exception_index_out_of_range ();
+                               FILL_IN_TRACE(frame->ex, frame);
+                               return;
+                       }
+                       pos = pos*ao->bounds [i].length + sp [i].data.i - 
+                               ao->bounds [i].lower_bound;
+               }
+       } else if (pos >= ao->max_length) {
+               frame->ex = mono_get_exception_index_out_of_range ();
+               FILL_IN_TRACE(frame->ex, frame);
+               return;
+       }
+
+       esize = mono_array_element_size (ac);
+       ea = mono_array_addr_with_size (ao, esize, pos);
+
+       frame->retval->data.p = ea;
+}
+
+void
+interp_walk_stack_with_ctx (MonoInternalStackWalk func, MonoContext *ctx, MonoUnwindOptions options, void *user_data)
+{
+       MonoError error;
+       ThreadContext *context = mono_native_tls_get_value (thread_context_id);
+
+       MonoInvocation *frame = context->current_frame;
+
+       while (frame) {
+               MonoStackFrameInfo fi;
+               memset (&fi, 0, sizeof (MonoStackFrameInfo));
+
+               /* TODO: hack to make some asserts happy. */
+               fi.ji = (MonoJitInfo *) frame->runtime_method;
+
+               if (frame->runtime_method)
+                       fi.method = fi.actual_method = frame->runtime_method->method;
+
+               if (!fi.method || (fi.method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) || (fi.method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME))) {
+                       fi.il_offset = -1;
+                       fi.type = FRAME_TYPE_MANAGED_TO_NATIVE;
+               } else {
+                       MonoMethodHeader *hd = mono_method_get_header_checked (fi.method, &error);
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       fi.type = FRAME_TYPE_MANAGED;
+                       fi.il_offset = frame->ip - (const unsigned short *) hd->code;
+                       if (!fi.method->wrapper_type)
+                               fi.managed = TRUE;
+               }
+
+               if (func (&fi, ctx, user_data))
+                       return;
+               frame = frame->parent;
+       }
+
+       g_assert (0);
+}
+
+static MonoPIFunc mono_interp_enter_icall_trampoline = NULL;
+
+struct _MethodArguments {
+       size_t ilen;
+       gpointer *iargs;
+       size_t flen;
+       double *fargs;
+       gpointer *retval;
+       size_t is_float_ret;
+};
+
+typedef struct _MethodArguments MethodArguments;
+
+// TODO: this function is also arch dependent (register width).
+static MethodArguments* build_args_from_sig (MonoMethodSignature *sig, MonoInvocation *frame)
+{
+       // TODO: don't malloc this data structure.
+       MethodArguments *margs = g_malloc0 (sizeof (MethodArguments));
+
+       if (sig->hasthis)
+               margs->ilen++;
+
+       for (int i = 0; i < sig->param_count; i++) {
+               guint32 ptype = sig->params [i]->byref ? MONO_TYPE_PTR : sig->params [i]->type;
+               switch (ptype) {
+               case MONO_TYPE_BOOLEAN:
+               case MONO_TYPE_CHAR:
+               case MONO_TYPE_I1:
+               case MONO_TYPE_U1:
+               case MONO_TYPE_I2:
+               case MONO_TYPE_U2:
+               case MONO_TYPE_I4:
+               case MONO_TYPE_U4:
+               case MONO_TYPE_I:
+               case MONO_TYPE_U:
+               case MONO_TYPE_PTR:
+               case MONO_TYPE_SZARRAY:
+               case MONO_TYPE_CLASS:
+               case MONO_TYPE_OBJECT:
+               case MONO_TYPE_STRING:
+               case MONO_TYPE_I8:
+               case MONO_TYPE_VALUETYPE:
+               case MONO_TYPE_GENERICINST:
+                       margs->ilen++;
+                       break;
+               case MONO_TYPE_R4:
+               case MONO_TYPE_R8:
+                       margs->flen++;
+                       break;
+               default:
+                       g_error ("build_args_from_sig: not implemented yet (1): 0x%x\n", ptype);
+               }
+       }
+
+       if (margs->ilen > 0)
+               margs->iargs = g_malloc0 (sizeof (gpointer) * margs->ilen);
+
+       if (margs->flen > 0)
+               margs->fargs = g_malloc0 (sizeof (double) * margs->flen);
+
+       if (margs->ilen > 8)
+               g_error ("build_args_from_sig: TODO, allocate gregs: %d\n", margs->ilen);
+
+       if (margs->flen > 3)
+               g_error ("build_args_from_sig: TODO, allocate fregs: %d\n", margs->flen);
+
+
+       size_t int_i = 0;
+       size_t int_f = 0;
+
+       if (sig->hasthis) {
+               margs->iargs [0] = frame->stack_args->data.p;
+               int_i++;
+       }
+
+       for (int i = 0; i < sig->param_count; i++) {
+               guint32 ptype = sig->params [i]->byref ? MONO_TYPE_PTR : sig->params [i]->type;
+               switch (ptype) {
+               case MONO_TYPE_BOOLEAN:
+               case MONO_TYPE_CHAR:
+               case MONO_TYPE_I1:
+               case MONO_TYPE_U1:
+               case MONO_TYPE_I2:
+               case MONO_TYPE_U2:
+               case MONO_TYPE_I4:
+               case MONO_TYPE_U4:
+               case MONO_TYPE_I:
+               case MONO_TYPE_U:
+               case MONO_TYPE_PTR:
+               case MONO_TYPE_SZARRAY:
+               case MONO_TYPE_CLASS:
+               case MONO_TYPE_OBJECT:
+               case MONO_TYPE_STRING:
+               case MONO_TYPE_I8:
+               case MONO_TYPE_VALUETYPE:
+               case MONO_TYPE_GENERICINST:
+                       margs->iargs [int_i] = frame->stack_args [i].data.p;
+#if DEBUG_INTERP
+                       g_print ("build_args_from_sig: margs->iargs[%d]: %p (frame @ %d)\n", int_i, margs->iargs[int_i], i);
+#endif
+                       int_i++;
+                       break;
+               case MONO_TYPE_R4:
+               case MONO_TYPE_R8:
+                       margs->fargs [int_f] = frame->stack_args [i].data.f;
+                       int_f++;
+                       break;
+               default:
+                       g_error ("build_args_from_sig: not implemented yet (2): 0x%x\n", ptype);
+               }
+       }
+
+       switch (sig->ret->type) {
+               case MONO_TYPE_BOOLEAN:
+               case MONO_TYPE_CHAR:
+               case MONO_TYPE_I1:
+               case MONO_TYPE_U1:
+               case MONO_TYPE_I2:
+               case MONO_TYPE_U2:
+               case MONO_TYPE_I4:
+               case MONO_TYPE_U4:
+               case MONO_TYPE_I:
+               case MONO_TYPE_U:
+               case MONO_TYPE_PTR:
+               case MONO_TYPE_SZARRAY:
+               case MONO_TYPE_CLASS:
+               case MONO_TYPE_OBJECT:
+               case MONO_TYPE_STRING:
+               case MONO_TYPE_I8:
+               case MONO_TYPE_VALUETYPE:
+               case MONO_TYPE_GENERICINST:
+                       margs->retval = &(frame->retval->data.p);
+                       break;
+               case MONO_TYPE_R4:
+               case MONO_TYPE_R8:
+                       margs->retval = &(frame->retval->data.p);
+                       margs->is_float_ret = 1;
+                       break;
+               case MONO_TYPE_VOID:
+                       margs->retval = NULL;
+                       break;
+               default:
+                       g_error ("build_args_from_sig: ret type not implemented yet: 0x%x\n", sig->ret->type);
+       }
+
+       return margs;
+}
+
+static void 
+ves_pinvoke_method (MonoInvocation *frame, MonoMethodSignature *sig, MonoFuncV addr, gboolean string_ctor, ThreadContext *context)
+{
+       jmp_buf env;
+       MonoInvocation *old_frame = context->current_frame;
+       MonoInvocation *old_env_frame = context->env_frame;
+       jmp_buf *old_env = context->current_env;
+
+       if (setjmp (env)) {
+               context->current_frame = old_frame;
+               context->env_frame = old_env_frame;
+               context->current_env = old_env;
+               context->managed_code = 1;
+               return;
+       }
+
+       frame->ex = NULL;
+       context->env_frame = frame;
+       context->current_env = &env;
+
+       g_assert (!frame->runtime_method);
+       if (!mono_interp_enter_icall_trampoline) {
+               MonoTrampInfo *info;
+               mono_interp_enter_icall_trampoline = mono_arch_get_enter_icall_trampoline (&info);
+               // TODO:
+               // mono_tramp_info_register (info, NULL);
+       }
+
+       MethodArguments *margs = build_args_from_sig (sig, frame);
+#if DEBUG_INTERP
+       g_print ("ICALL: mono_interp_enter_icall_trampoline = %p, addr = %p\n", mono_interp_enter_icall_trampoline, addr);
+       g_print ("margs(out): ilen=%d, flen=%d\n", margs->ilen, margs->flen);
+#endif
+
+       context->current_frame = frame;
+       context->managed_code = 0;
+
+       mono_interp_enter_icall_trampoline (addr, margs);
+
+       context->managed_code = 1;
+       /* domain can only be changed by native code */
+       context->domain = mono_domain_get ();
+
+       if (*mono_thread_interruption_request_flag ())
+               mono_thread_interruption_checkpoint ();
+       
+       if (!MONO_TYPE_ISSTRUCT (sig->ret))
+               stackval_from_data (sig->ret, frame->retval, (char*)&frame->retval->data.p, sig->pinvoke);
+
+       context->current_frame = old_frame;
+       context->env_frame = old_env_frame;
+       context->current_env = old_env;
+
+       g_free (margs->iargs);
+       g_free (margs->fargs);
+       g_free (margs);
+}
+
+void
+mono_interp_init_delegate (MonoDelegate *del)
+{
+       g_assert (!del->method);
+       del->method = ((RuntimeMethod *) del->method_ptr)->method;
+       g_assert (del->method);
+}
+
+/*
+ * From the spec:
+ * runtime specifies that the implementation of the method is automatically
+ * provided by the runtime and is primarily used for the methods of delegates.
+ */
+static void
+ves_runtime_method (MonoInvocation *frame, ThreadContext *context)
+{
+       MonoMethod *method = frame->runtime_method->method;
+       const char *name = method->name;
+       MonoObject *obj = (MonoObject*) frame->stack_args->data.p;
+       MonoObject *isinst_obj;
+       MonoError error;
+
+       mono_class_init (method->klass);
+
+       isinst_obj = mono_object_isinst_checked (obj, mono_defaults.array_class, &error);
+       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+       if (obj && isinst_obj) {
+               if (*name == 'S' && (strcmp (name, "Set") == 0)) {
+                       ves_array_set (frame);
+                       return;
+               }
+               if (*name == 'G' && (strcmp (name, "Get") == 0)) {
+                       ves_array_get (frame);
+                       return;
+               }
+               if (*name == 'A' && (strcmp (name, "Address") == 0)) {
+                       ves_array_element_address (frame);
+                       return;
+               }
+       }
+       
+       g_error ("Don't know how to exec runtime method %s.%s::%s", 
+                       method->klass->name_space, method->klass->name,
+                       method->name);
+}
+
+static char*
+dump_stack (stackval *stack, stackval *sp)
+{
+       stackval *s = stack;
+       GString *str = g_string_new ("");
+       
+       if (sp == stack)
+               return g_string_free (str, FALSE);
+       
+       while (s < sp) {
+               g_string_append_printf (str, "[%p (%lld)] ", s->data.l, s->data.l);
+               ++s;
+       }
+       return g_string_free (str, FALSE);
+}
+
+static void
+dump_stackval (GString *str, stackval *s, MonoType *type)
+{
+       switch (type->type) {
+       case MONO_TYPE_I1:
+       case MONO_TYPE_U1:
+       case MONO_TYPE_I2:
+       case MONO_TYPE_U2:
+       case MONO_TYPE_I4:
+       case MONO_TYPE_U4:
+       case MONO_TYPE_CHAR:
+       case MONO_TYPE_BOOLEAN:
+               g_string_append_printf (str, "[%d] ", s->data.i);
+               break;
+       case MONO_TYPE_STRING:
+       case MONO_TYPE_SZARRAY:
+       case MONO_TYPE_CLASS:
+       case MONO_TYPE_OBJECT:
+       case MONO_TYPE_ARRAY:
+       case MONO_TYPE_PTR:
+       case MONO_TYPE_I:
+       case MONO_TYPE_U:
+               g_string_append_printf (str, "[%p] ", s->data.p);
+               break;
+       case MONO_TYPE_VALUETYPE:
+               if (type->data.klass->enumtype)
+                       g_string_append_printf (str, "[%d] ", s->data.i);
+               else
+                       g_string_append_printf (str, "[vt:%p] ", s->data.p);
+               break;
+       case MONO_TYPE_R4:
+       case MONO_TYPE_R8:
+               g_string_append_printf (str, "[%g] ", s->data.f);
+               break;
+       case MONO_TYPE_I8:
+       case MONO_TYPE_U8:
+       default: {
+               GString *res = g_string_new ("");
+               mono_type_get_desc (res, type, TRUE);
+               g_string_append_printf (str, "[{%s} %lld/0x%0llx] ", res->str, s->data.l, s->data.l);
+               g_string_free (res, TRUE);
+               break;
+       }
+       }
+}
+
+static char*
+dump_args (MonoInvocation *inv)
+{
+       GString *str = g_string_new ("");
+       int i;
+       MonoMethodSignature *signature = mono_method_signature (inv->runtime_method->method);
+       
+       if (signature->param_count == 0 && !signature->hasthis)
+               return g_string_free (str, FALSE);
+
+       if (signature->hasthis) {
+               MonoMethod *method = inv->runtime_method->method;
+               dump_stackval (str, inv->stack_args, &method->klass->byval_arg);
+       }
+
+       for (i = 0; i < signature->param_count; ++i)
+               dump_stackval (str, inv->stack_args + (!!signature->hasthis) + i, signature->params [i]);
+
+       return g_string_free (str, FALSE);
+}
+
+static char*
+dump_retval (MonoInvocation *inv)
+{
+       GString *str = g_string_new ("");
+       MonoType *ret = mono_method_signature (inv->runtime_method->method)->ret;
+
+       if (ret->type != MONO_TYPE_VOID)
+               dump_stackval (str, inv->retval, ret);
+
+       return g_string_free (str, FALSE);
+}
+static char*
+dump_frame (MonoInvocation *inv)
+{
+       GString *str = g_string_new ("");
+       int i;
+       char *args;
+       MonoError error;
+
+       for (i = 0; inv; inv = inv->parent) {
+               if (inv->runtime_method != NULL) {
+                       MonoMethod *method = inv->runtime_method->method;
+                       MonoClass *k;
+
+                       int codep = 0;
+                       const char * opname = "";
+                       char *name;
+                       gchar *source = NULL;
+
+                       k = method->klass;
+
+                       if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) == 0 &&
+                               (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) == 0) {
+                               MonoMethodHeader *hd = mono_method_get_header_checked (method, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+
+                               if (hd != NULL) {
+                                       if (inv->ip) {
+                                               opname = mono_interp_opname [*inv->ip];
+                                               codep = inv->ip - inv->runtime_method->code;
+                                               source = g_strdup_printf ("%s:%d // (TODO: proper stacktrace)", method->name, codep);
+                                       } else 
+                                               opname = "";
+
+#if 0
+                                       MonoDebugSourceLocation *minfo = mono_debug_lookup_method (method);
+                                       source = mono_debug_method_lookup_location (minfo, codep);
+#endif
+                               }
+                       }
+                       args = dump_args (inv);
+                       name = mono_method_full_name (method, TRUE);
+                       if (source)
+                               g_string_append_printf (str, "#%d: 0x%05x %-10s in %s (%s) at %s\n", i, codep, opname, name, args, source);
+                       else
+                               g_string_append_printf (str, "#%d: 0x%05x %-10s in %s (%s)\n", i, codep, opname, name, args);
+                       g_free (name);
+                       g_free (args);
+                       g_free (source);
+                       ++i;
+               }
+       }
+       return g_string_free (str, FALSE);
+}
+
+static MonoArray *
+get_trace_ips (MonoDomain *domain, MonoInvocation *top)
+{
+       int i;
+       MonoArray *res;
+       MonoInvocation *inv;
+       MonoError error;
+
+       for (i = 0, inv = top; inv; inv = inv->parent)
+               if (inv->runtime_method != NULL)
+                       ++i;
+
+       res = mono_array_new_checked (domain, mono_defaults.int_class, 2 * i, &error);
+       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+
+       for (i = 0, inv = top; inv; inv = inv->parent)
+               if (inv->runtime_method != NULL) {
+                       mono_array_set (res, gpointer, i, inv->runtime_method);
+                       ++i;
+                       mono_array_set (res, gpointer, i, (gpointer)inv->ip);
+                       ++i;
+               }
+
+       return res;
+}
+
+
+#define MYGUINT64_MAX 18446744073709551615ULL
+#define MYGINT64_MAX 9223372036854775807LL
+#define MYGINT64_MIN (-MYGINT64_MAX -1LL)
+
+#define MYGUINT32_MAX 4294967295U
+#define MYGINT32_MAX 2147483647
+#define MYGINT32_MIN (-MYGINT32_MAX -1)
+       
+#define CHECK_ADD_OVERFLOW(a,b) \
+       (gint32)(b) >= 0 ? (gint32)(MYGINT32_MAX) - (gint32)(b) < (gint32)(a) ? -1 : 0  \
+       : (gint32)(MYGINT32_MIN) - (gint32)(b) > (gint32)(a) ? +1 : 0
+
+#define CHECK_SUB_OVERFLOW(a,b) \
+       (gint32)(b) < 0 ? (gint32)(MYGINT32_MAX) + (gint32)(b) < (gint32)(a) ? -1 : 0   \
+       : (gint32)(MYGINT32_MIN) + (gint32)(b) > (gint32)(a) ? +1 : 0
+
+#define CHECK_ADD_OVERFLOW_UN(a,b) \
+       (guint32)(MYGUINT32_MAX) - (guint32)(b) < (guint32)(a) ? -1 : 0
+
+#define CHECK_SUB_OVERFLOW_UN(a,b) \
+       (guint32)(a) < (guint32)(b) ? -1 : 0
+
+#define CHECK_ADD_OVERFLOW64(a,b) \
+       (gint64)(b) >= 0 ? (gint64)(MYGINT64_MAX) - (gint64)(b) < (gint64)(a) ? -1 : 0  \
+       : (gint64)(MYGINT64_MIN) - (gint64)(b) > (gint64)(a) ? +1 : 0
+
+#define CHECK_SUB_OVERFLOW64(a,b) \
+       (gint64)(b) < 0 ? (gint64)(MYGINT64_MAX) + (gint64)(b) < (gint64)(a) ? -1 : 0   \
+       : (gint64)(MYGINT64_MIN) + (gint64)(b) > (gint64)(a) ? +1 : 0
+
+#define CHECK_ADD_OVERFLOW64_UN(a,b) \
+       (guint64)(MYGUINT64_MAX) - (guint64)(b) < (guint64)(a) ? -1 : 0
+
+#define CHECK_SUB_OVERFLOW64_UN(a,b) \
+       (guint64)(a) < (guint64)(b) ? -1 : 0
+
+#if SIZEOF_VOID_P == 4
+#define CHECK_ADD_OVERFLOW_NAT(a,b) CHECK_ADD_OVERFLOW(a,b)
+#define CHECK_ADD_OVERFLOW_NAT_UN(a,b) CHECK_ADD_OVERFLOW_UN(a,b)
+#else
+#define CHECK_ADD_OVERFLOW_NAT(a,b) CHECK_ADD_OVERFLOW64(a,b)
+#define CHECK_ADD_OVERFLOW_NAT_UN(a,b) CHECK_ADD_OVERFLOW64_UN(a,b)
+#endif
+
+/* Resolves to TRUE if the operands would overflow */
+#define CHECK_MUL_OVERFLOW(a,b) \
+       ((gint32)(a) == 0) || ((gint32)(b) == 0) ? 0 : \
+       (((gint32)(a) > 0) && ((gint32)(b) == -1)) ? FALSE : \
+       (((gint32)(a) < 0) && ((gint32)(b) == -1)) ? (a == - MYGINT32_MAX) : \
+       (((gint32)(a) > 0) && ((gint32)(b) > 0)) ? (gint32)(a) > ((MYGINT32_MAX) / (gint32)(b)) : \
+       (((gint32)(a) > 0) && ((gint32)(b) < 0)) ? (gint32)(a) > ((MYGINT32_MIN) / (gint32)(b)) : \
+       (((gint32)(a) < 0) && ((gint32)(b) > 0)) ? (gint32)(a) < ((MYGINT32_MIN) / (gint32)(b)) : \
+       (gint32)(a) < ((MYGINT32_MAX) / (gint32)(b))
+
+#define CHECK_MUL_OVERFLOW_UN(a,b) \
+       ((guint32)(a) == 0) || ((guint32)(b) == 0) ? 0 : \
+       (guint32)(b) > ((MYGUINT32_MAX) / (guint32)(a))
+
+#define CHECK_MUL_OVERFLOW64(a,b) \
+       ((gint64)(a) == 0) || ((gint64)(b) == 0) ? 0 : \
+       (((gint64)(a) > 0) && ((gint64)(b) == -1)) ? FALSE : \
+       (((gint64)(a) < 0) && ((gint64)(b) == -1)) ? (a == - MYGINT64_MAX) : \
+       (((gint64)(a) > 0) && ((gint64)(b) > 0)) ? (gint64)(a) > ((MYGINT64_MAX) / (gint64)(b)) : \
+       (((gint64)(a) > 0) && ((gint64)(b) < 0)) ? (gint64)(a) > ((MYGINT64_MIN) / (gint64)(b)) : \
+       (((gint64)(a) < 0) && ((gint64)(b) > 0)) ? (gint64)(a) < ((MYGINT64_MIN) / (gint64)(b)) : \
+       (gint64)(a) < ((MYGINT64_MAX) / (gint64)(b))
+
+#define CHECK_MUL_OVERFLOW64_UN(a,b) \
+       ((guint64)(a) == 0) || ((guint64)(b) == 0) ? 0 : \
+       (guint64)(b) > ((MYGUINT64_MAX) / (guint64)(a))
+
+#if SIZEOF_VOID_P == 4
+#define CHECK_MUL_OVERFLOW_NAT(a,b) CHECK_MUL_OVERFLOW(a,b)
+#define CHECK_MUL_OVERFLOW_NAT_UN(a,b) CHECK_MUL_OVERFLOW_UN(a,b)
+#else
+#define CHECK_MUL_OVERFLOW_NAT(a,b) CHECK_MUL_OVERFLOW64(a,b)
+#define CHECK_MUL_OVERFLOW_NAT_UN(a,b) CHECK_MUL_OVERFLOW64_UN(a,b)
+#endif
+
+MonoObject*
+mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error)
+{
+       MonoInvocation frame;
+       ThreadContext * volatile context = mono_native_tls_get_value (thread_context_id);
+       MonoObject *retval = NULL;
+       MonoMethodSignature *sig = mono_method_signature (method);
+       MonoClass *klass = mono_class_from_mono_type (sig->ret);
+       int i, type, isobject = 0;
+       void *ret = NULL;
+       stackval result;
+       stackval *args = alloca (sizeof (stackval) * (sig->param_count + !!sig->hasthis));
+       ThreadContext context_struct;
+       MonoInvocation *old_frame = NULL;
+       jmp_buf env;
+
+       error_init (error);
+
+       frame.ex = NULL;
+
+       if (setjmp(env)) {
+               if (context != &context_struct) {
+                       context->domain = mono_domain_get ();
+                       context->current_frame = old_frame;
+                       context->managed_code = 0;
+               } else 
+                       mono_native_tls_set_value (thread_context_id, NULL);
+               if (exc != NULL)
+                       *exc = (MonoObject *)frame.ex;
+               return retval;
+       }
+
+       if (context == NULL) {
+               context = &context_struct;
+               context_struct.base_frame = &frame;
+               context_struct.current_frame = NULL;
+               context_struct.env_frame = &frame;
+               context_struct.current_env = &env;
+               context_struct.search_for_handler = 0;
+               context_struct.managed_code = 0;
+               mono_native_tls_set_value (thread_context_id, context);
+       }
+       else
+               old_frame = context->current_frame;
+
+       context->domain = mono_domain_get ();
+
+       switch (sig->ret->type) {
+       case MONO_TYPE_VOID:
+               break;
+       case MONO_TYPE_STRING:
+       case MONO_TYPE_OBJECT:
+       case MONO_TYPE_CLASS:
+       case MONO_TYPE_ARRAY:
+       case MONO_TYPE_SZARRAY:
+               isobject = 1;
+               break;
+       case MONO_TYPE_VALUETYPE:
+               retval = mono_object_new_checked (context->domain, klass, error);
+               ret = ((char*)retval) + sizeof (MonoObject);
+               if (!sig->ret->data.klass->enumtype)
+                       result.data.vt = ret;
+               break;
+       default:
+               retval = mono_object_new_checked (context->domain, klass, error);
+               ret = ((char*)retval) + sizeof (MonoObject);
+               break;
+       }
+
+       if (sig->hasthis)
+               args [0].data.p = obj;
+
+       for (i = 0; i < sig->param_count; ++i) {
+               int a_index = i + !!sig->hasthis;
+               if (sig->params [i]->byref) {
+                       args [a_index].data.p = params [i];
+                       continue;
+               }
+               type = sig->params [i]->type;
+handle_enum:
+               switch (type) {
+               case MONO_TYPE_U1:
+               case MONO_TYPE_I1:
+               case MONO_TYPE_BOOLEAN:
+                       args [a_index].data.i = *(MonoBoolean*)params [i];
+                       break;
+               case MONO_TYPE_U2:
+               case MONO_TYPE_I2:
+               case MONO_TYPE_CHAR:
+                       args [a_index].data.i = *(gint16*)params [i];
+                       break;
+#if SIZEOF_VOID_P == 4
+               case MONO_TYPE_U: /* use VAL_POINTER? */
+               case MONO_TYPE_I:
+#endif
+               case MONO_TYPE_U4:
+               case MONO_TYPE_I4:
+                       args [a_index].data.i = *(gint32*)params [i];
+                       break;
+#if SIZEOF_VOID_P == 8
+               case MONO_TYPE_U:
+               case MONO_TYPE_I:
+#endif
+               case MONO_TYPE_U8:
+               case MONO_TYPE_I8:
+                       args [a_index].data.l = *(gint64*)params [i];
+                       break;
+               case MONO_TYPE_VALUETYPE:
+                       if (sig->params [i]->data.klass->enumtype) {
+                               type = mono_class_enum_basetype (sig->params [i]->data.klass)->type;
+                               goto handle_enum;
+                       } else {
+                               args [a_index].data.p = params [i];
+                       }
+                       break;
+               case MONO_TYPE_STRING:
+               case MONO_TYPE_CLASS:
+               case MONO_TYPE_ARRAY:
+               case MONO_TYPE_SZARRAY:
+               case MONO_TYPE_OBJECT:
+                       args [a_index].data.p = params [i];
+                       break;
+               default:
+                       g_error ("type 0x%x not handled in  runtime invoke", sig->params [i]->type);
+               }
+       }
+
+       if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
+               method = mono_marshal_get_native_wrapper (method, FALSE, FALSE);
+       INIT_FRAME (&frame,context->current_frame,args,&result,mono_get_root_domain (),method,error);
+       if (exc)
+               frame.invoke_trap = 1;
+       context->managed_code = 1;
+       ves_exec_method_with_context (&frame, context);
+       context->managed_code = 0;
+       if (context == &context_struct)
+               mono_native_tls_set_value (thread_context_id, NULL);
+       else
+               context->current_frame = old_frame;
+       if (frame.ex != NULL) {
+               if (exc != NULL) {
+                       *exc = (MonoObject*) frame.ex;
+                       return NULL;
+               }
+               if (context->current_env != NULL) {
+                       context->env_frame->ex = frame.ex;
+                       longjmp(*context->current_env, 1);
+               }
+               else
+                       printf("dropped exception...\n");
+       }
+       if (sig->ret->type == MONO_TYPE_VOID && !method->string_ctor)
+               return NULL;
+       if (isobject || method->string_ctor)
+               return result.data.p;
+       stackval_to_data (sig->ret, &result, ret, sig->pinvoke);
+       return retval;
+}
+
+static stackval * 
+do_icall (ThreadContext *context, int op, stackval *sp, gpointer ptr)
+{
+       MonoInvocation *old_frame = context->current_frame;
+       MonoInvocation *old_env_frame = context->env_frame;
+       jmp_buf *old_env = context->current_env;
+       jmp_buf env;
+
+       if (setjmp (env)) {
+               context->current_frame = old_frame;
+               context->env_frame = old_env_frame;
+               context->current_env = old_env;
+               context->managed_code = 1;
+               return sp;
+       }
+
+       context->env_frame = context->current_frame;
+       context->current_env = &env;
+       context->managed_code = 0;
+
+       switch (op) {
+       case MINT_ICALL_V_V: {
+               void (*func)() = ptr;
+               func ();
+               break;
+       }
+       case MINT_ICALL_V_P: {
+               gpointer (*func)() = ptr;
+               sp++;
+               sp [-1].data.p = func ();
+               break;
+       }
+       case MINT_ICALL_P_V: {
+               void (*func)(gpointer) = ptr;
+               func (sp [-1].data.p);
+               sp --;
+               break;
+       }
+       case MINT_ICALL_P_P: {
+               gpointer (*func)(gpointer) = ptr;
+               sp [-1].data.p = func (sp [-1].data.p);
+               break;
+       }
+       case MINT_ICALL_PP_V: {
+               void (*func)(gpointer,gpointer) = ptr;
+               sp -= 2;
+               func (sp [0].data.p, sp [1].data.p);
+               break;
+       }
+       case MINT_ICALL_PI_V: {
+               void (*func)(gpointer,int) = ptr;
+               sp -= 2;
+               func (sp [0].data.p, sp [1].data.i);
+               break;
+       }
+       case MINT_ICALL_PP_P: {
+               gpointer (*func)(gpointer,gpointer) = ptr;
+               --sp;
+               sp [-1].data.p = func (sp [-1].data.p, sp [0].data.p);
+               break;
+       }
+       case MINT_ICALL_PI_P: {
+               gpointer (*func)(gpointer,int) = ptr;
+               --sp;
+               sp [-1].data.p = func (sp [-1].data.p, sp [0].data.i);
+               break;
+       }
+       case MINT_ICALL_PPP_V: {
+               void (*func)(gpointer,gpointer,gpointer) = ptr;
+               sp -= 3;
+               func (sp [0].data.p, sp [1].data.p, sp [2].data.p);
+               break;
+       }
+       case MINT_ICALL_PPI_V: {
+               void (*func)(gpointer,gpointer,int) = ptr;
+               sp -= 3;
+               func (sp [0].data.p, sp [1].data.p, sp [2].data.i);
+               break;
+       }
+       default:
+               g_assert_not_reached ();
+       }
+
+       context->env_frame = old_env_frame;
+       context->current_env = old_env;
+
+       return sp;
+}
+
+static mono_mutex_t create_method_pointer_mutex;
+
+static GHashTable *method_pointer_hash = NULL;
+
+static MonoMethod *method_pointers [2] = {0};
+
+static MonoObject *
+mp_tramp_0 (MonoObject *this_obj, void **params, MonoObject **exc, void *compiled_method) {
+       MonoError error;
+       void *params_real[] = {this_obj, &params, &exc, &compiled_method};
+       MonoObject *ret = mono_interp_runtime_invoke (method_pointers [0], NULL, params_real, NULL, &error);
+       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+       return ret;
+}
+
+static MonoObject *
+mp_tramp_1 (MonoObject *this_obj, void **params, MonoObject **exc, void *compiled_method) {
+       MonoError error;
+       void *params_real[] = {this_obj, &params, &exc, &compiled_method};
+       MonoObject *ret = mono_interp_runtime_invoke (method_pointers [1], NULL, params_real, NULL, &error);
+       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+       return ret;
+}
+
+gpointer *mp_tramps[] = {(gpointer) mp_tramp_0, (gpointer) mp_tramp_1};
+
+static int tramps_used = 0;
+
+gpointer
+mono_interp_create_method_pointer (MonoMethod *method, MonoError *error)
+{
+       gpointer addr;
+       MonoJitInfo *ji;
+
+       mono_os_mutex_lock (&create_method_pointer_mutex);
+       if (!method_pointer_hash) {
+               // FIXME: is registering method table as GC root really necessary?
+               // MONO_GC_REGISTER_ROOT_FIXED (method_pointer_hash);
+               method_pointer_hash = g_hash_table_new (NULL, NULL);
+       }
+       addr = g_hash_table_lookup (method_pointer_hash, method);
+       if (addr) {
+               mono_os_mutex_unlock (&create_method_pointer_mutex);
+               return addr;
+       }
+
+       /*
+        * If it is a static P/Invoke method, we can just return the pointer
+        * to the method implementation.
+        */
+       if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL && ((MonoMethodPInvoke*) method)->addr) {
+               ji = g_new0 (MonoJitInfo, 1);
+               ji->d.method = method;
+               ji->code_size = 1;
+               ji->code_start = addr = ((MonoMethodPInvoke*) method)->addr;
+
+               mono_jit_info_table_add (mono_get_root_domain (), ji);
+       }               
+       else {
+               g_assert (method->wrapper_type == MONO_WRAPPER_RUNTIME_INVOKE);
+               g_assert (tramps_used < 2);
+
+               /* FIXME: needs locking */
+               method_pointers [tramps_used] = method;
+               addr = mp_tramps [tramps_used];
+               tramps_used++;
+       }
+
+       g_hash_table_insert (method_pointer_hash, method, addr);
+       mono_os_mutex_unlock (&create_method_pointer_mutex);
+
+       return addr;
+}
+
+#if COUNT_OPS
+static int opcode_counts[512];
+
+#define COUNT_OP(op) opcode_counts[op]++
+#else
+#define COUNT_OP(op) 
+#endif
+
+#if DEBUG_INTERP
+#define DUMP_INSTR() \
+       if (tracing > 1) { \
+               char *ins; \
+               if (sp > frame->stack) { \
+                       ins = dump_stack (frame->stack, sp); \
+               } else { \
+                       ins = g_strdup (""); \
+               } \
+               sp->data.l = 0; \
+               output_indent (); \
+               char *mn = mono_method_full_name (frame->runtime_method->method, FALSE); \
+               g_print ("(%p) %s -> ", mono_thread_internal_current (), mn); \
+               g_free (mn); \
+               mono_interp_dis_mintop(rtm->code, ip); \
+               g_print ("\t%d:%s\n", vt_sp - vtalloc, ins); \
+               g_free (ins); \
+       }
+#else
+#define DUMP_INSTR()
+#endif
+
+#ifdef __GNUC__
+#define USE_COMPUTED_GOTO 1
+#endif
+#if USE_COMPUTED_GOTO
+#define MINT_IN_SWITCH(op) COUNT_OP(op); goto *in_labels[op];
+#define MINT_IN_CASE(x) LAB_ ## x:
+#if DEBUG_INTERP
+#define MINT_IN_BREAK if (tracing > 1) goto main_loop; else { COUNT_OP(*ip); goto *in_labels[*ip]; }
+#else
+#define MINT_IN_BREAK { COUNT_OP(*ip); goto *in_labels[*ip]; }
+#endif
+#define MINT_IN_DEFAULT mint_default: if (0) goto mint_default; /* make gcc shut up */
+#else
+#define MINT_IN_SWITCH(op) switch (op)
+#define MINT_IN_CASE(x) case x:
+#define MINT_IN_BREAK break
+#define MINT_IN_DEFAULT default:
+#endif
+
+/* 
+ * Defining this causes register allocation errors in some versions of gcc:
+ * error: unable to find a register to spill in class `SIREG'
+ */
+/* #define MINT_USE_DEDICATED_IP_REG */
+
+static void 
+ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context)
+{
+       MonoInvocation child_frame;
+       GSList *finally_ips = NULL;
+       const unsigned short *endfinally_ip = NULL;
+#if defined(__GNUC__) && defined (i386) && defined (MINT_USE_DEDICATED_IP_REG)
+       register const unsigned short *ip asm ("%esi");
+#else
+       register const unsigned short *ip;
+#endif
+       register stackval *sp;
+       RuntimeMethod *rtm;
+#if DEBUG_INTERP
+       gint tracing = global_tracing;
+       unsigned char *vtalloc;
+#endif
+       int i32;
+       unsigned char *vt_sp;
+       unsigned char *locals;
+       MonoError error;
+       MonoObject *o = NULL;
+       MonoClass *c;
+#if USE_COMPUTED_GOTO
+       static void *in_labels[] = {
+#define OPDEF(a,b,c,d) \
+       &&LAB_ ## a,
+#include "mintops.def"
+       0 };
+#endif
+
+       frame->ex = NULL;
+       frame->ex_handler = NULL;
+       frame->ip = NULL;
+       context->current_frame = frame;
+
+#if DEBUG_INTERP
+       debug_enter (frame, &tracing);
+#endif
+
+       if (!frame->runtime_method->transformed) {
+               context->managed_code = 0;
+#if DEBUG_INTERP
+               char *mn = mono_method_full_name (frame->runtime_method->method, FALSE);
+               g_print ("(%p) Transforming %s\n", mono_thread_internal_current (), mn);
+               g_free (mn);
+#endif
+               frame->ex = mono_interp_transform_method (frame->runtime_method, context);
+               context->managed_code = 1;
+               if (frame->ex) {
+                       rtm = NULL;
+                       ip = NULL;
+                       goto exit_frame;
+               }
+       }
+
+       rtm = frame->runtime_method;
+       frame->args = alloca (rtm->alloca_size);
+       sp = frame->stack = (stackval *)((char *)frame->args + rtm->args_size);
+#if DEBUG_INTERP
+       if (tracing > 1)
+               memset(sp, 0, rtm->stack_size);
+#endif
+       vt_sp = (unsigned char *) sp + rtm->stack_size;
+#if DEBUG_INTERP
+       vtalloc = vt_sp;
+#endif
+       locals = (unsigned char *) vt_sp + rtm->vt_stack_size;
+
+       child_frame.parent = frame;
+
+       /* ready to go */
+       ip = rtm->code;
+
+       /*
+        * using while (ip < end) may result in a 15% performance drop, 
+        * but it may be useful for debug
+        */
+       while (1) {
+       main_loop:
+               /* g_assert (sp >= frame->stack); */
+               /* g_assert(vt_sp - vtalloc <= rtm->vt_stack_size); */
+               DUMP_INSTR();
+               MINT_IN_SWITCH (*ip) {
+               MINT_IN_CASE(MINT_INITLOCALS)
+                       memset (locals, 0, rtm->locals_size);
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_NOP)
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BREAK)
+                       ++ip;
+                       G_BREAKPOINT (); /* this is not portable... */
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDNULL) 
+                       sp->data.p = NULL;
+                       ++ip;
+                       ++sp;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_VTRESULT) {
+                       int ret_size = * (guint16 *)(ip + 1);
+                       unsigned char *ret_vt_sp = vt_sp;
+                       vt_sp -= READ32(ip + 2);
+                       if (ret_size > 0) {
+                               memmove (vt_sp, ret_vt_sp, ret_size);
+                               sp [-1].data.p = vt_sp;
+                               vt_sp += (ret_size + 7) & ~7;
+                       }
+                       ip += 4;
+                       MINT_IN_BREAK;
+               }
+#define LDC(n) do { sp->data.i = (n); ++ip; ++sp; } while (0)
+               MINT_IN_CASE(MINT_LDC_I4_M1)
+                       LDC(-1);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_I4_0)
+                       LDC(0);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_I4_1)
+                       LDC(1);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_I4_2)
+                       LDC(2);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_I4_3)
+                       LDC(3);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_I4_4)
+                       LDC(4);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_I4_5)
+                       LDC(5);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_I4_6)
+                       LDC(6);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_I4_7)
+                       LDC(7);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_I4_8)
+                       LDC(8);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_I4_S) 
+                       sp->data.i = *(const short *)(ip + 1);
+                       ip += 2;
+                       ++sp;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_I4)
+                       ++ip;
+                       sp->data.i = READ32 (ip);
+                       ip += 2;
+                       ++sp;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_I8)
+                       ++ip;
+                       sp->data.l = READ64 (ip);
+                       ip += 4;
+                       ++sp;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDC_R4) {
+                       guint32 val;
+                       ++ip;
+                       val = READ32(ip);
+                       sp->data.f = * (float *)&val;
+                       ip += 2;
+                       ++sp;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_LDC_R8) 
+                       sp->data.l = READ64 (ip + 1); /* note union usage */
+                       ip += 5;
+                       ++sp;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_DUP) 
+                       sp [0] = sp[-1];
+                       ++sp;
+                       ++ip; 
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_DUP_VT)
+                       i32 = READ32 (ip + 1);
+                       sp->data.p = vt_sp;
+                       memcpy(sp->data.p, sp [-1].data.p, i32);
+                       vt_sp += (i32 + 7) & ~7;
+                       ++sp;
+                       ip += 3;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_POP) {
+                       guint16 u16 = (* (guint16 *)(ip + 1)) + 1;
+                       if (u16 > 1)
+                               memmove (sp - u16, sp - 1, (u16 - 1) * sizeof (stackval));
+                       sp--;
+                       ip += 2;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_JMP) {
+                       RuntimeMethod *new_method = rtm->data_items [* (guint16 *)(ip + 1)];
+                       if (!new_method->transformed) {
+                               frame->ip = ip;
+                               frame->ex = mono_interp_transform_method (new_method, context);
+                               if (frame->ex)
+                                       goto exit_frame;
+                       }
+                       ip += 2;
+                       if (new_method->alloca_size > rtm->alloca_size)
+                               g_error ("MINT_JMP to method which needs more stack space (%d > %d)", new_method->alloca_size, rtm->alloca_size); 
+                       rtm = frame->runtime_method = new_method;
+                       vt_sp = (unsigned char *) sp + rtm->stack_size;
+#if DEBUG_INTERP
+                       vtalloc = vt_sp;
+#endif
+                       locals = vt_sp + rtm->vt_stack_size;
+                       ip = rtm->new_body_start; /* bypass storing input args from callers frame */
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_CALLI) {
+                       MonoMethodSignature *csignature;
+                       stackval *endsp = sp;
+
+                       frame->ip = ip;
+                       
+                       csignature = rtm->data_items [* (guint16 *)(ip + 1)];
+                       ip += 2;
+                       --sp;
+                       --endsp;
+                       child_frame.runtime_method = sp->data.p;
+
+                       sp->data.p = vt_sp;
+                       child_frame.retval = sp;
+                       /* decrement by the actual number of args */
+                       sp -= csignature->param_count;
+                       if (csignature->hasthis)
+                               --sp;
+                       child_frame.stack_args = sp;
+
+                       /* `this' can be NULL for string:.ctor */
+                       if (csignature->hasthis && sp->data.p && mono_object_is_transparent_proxy (sp->data.p)) {
+                               child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       } else if (child_frame.runtime_method->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
+                               child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_native_wrapper (child_frame.runtime_method->method, FALSE, FALSE), &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       }
+
+                       if (csignature->hasthis) {
+                               MonoObject *this_arg = sp->data.p;
+
+                               if (this_arg->vtable->klass->valuetype) {
+                                       gpointer *unboxed = mono_object_unbox (this_arg);
+                                       sp [0].data.p = unboxed;
+                               }
+                       }
+
+                       ves_exec_method_with_context (&child_frame, context);
+
+                       context->current_frame = frame;
+
+                       if (child_frame.ex) {
+                               /*
+                                * An exception occurred, need to run finally, fault and catch handlers..
+                                */
+                               frame->ex = child_frame.ex;
+                               goto handle_finally;
+                       }
+
+                       /* need to handle typedbyref ... */
+                       if (csignature->ret->type != MONO_TYPE_VOID) {
+                               *sp = *endsp;
+                               sp++;
+                       }
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_CALLI_NAT) {
+                       MonoMethodSignature *csignature;
+                       stackval *endsp = sp;
+                       unsigned char *code = NULL;
+
+                       frame->ip = ip;
+                       
+                       csignature = rtm->data_items [* (guint16 *)(ip + 1)];
+                       ip += 2;
+                       --sp;
+                       --endsp;
+                       code = sp->data.p;
+                       child_frame.runtime_method = NULL;
+
+                       sp->data.p = vt_sp;
+                       child_frame.retval = sp;
+                       /* decrement by the actual number of args */
+                       sp -= csignature->param_count;
+                       if (csignature->hasthis)
+                               --sp;
+                       child_frame.stack_args = sp;
+                       ves_pinvoke_method (&child_frame, csignature, (MonoFuncV) code, FALSE, context);
+
+                       context->current_frame = frame;
+
+                       if (child_frame.ex) {
+                               /*
+                                * An exception occurred, need to run finally, fault and catch handlers..
+                                */
+                               frame->ex = child_frame.ex;
+                               if (context->search_for_handler) {
+                                       context->search_for_handler = 0;
+                                       goto handle_exception;
+                               }
+                               goto handle_finally;
+                       }
+
+                       /* need to handle typedbyref ... */
+                       if (csignature->ret->type != MONO_TYPE_VOID) {
+                               *sp = *endsp;
+                               sp++;
+                       }
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_CALL) {
+                       stackval *endsp = sp;
+
+                       frame->ip = ip;
+                       
+                       child_frame.runtime_method = rtm->data_items [* (guint16 *)(ip + 1)];
+                       ip += 2;
+                       sp->data.p = vt_sp;
+                       child_frame.retval = sp;
+                       /* decrement by the actual number of args */
+                       sp -= child_frame.runtime_method->param_count;
+                       if (child_frame.runtime_method->hasthis)
+                               --sp;
+                       child_frame.stack_args = sp;
+
+                       /* `this' can be NULL for string:.ctor */
+                       if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->method->klass->valuetype && sp->data.p && mono_object_is_transparent_proxy (sp->data.p)) {
+                               child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       }
+                       ves_exec_method_with_context (&child_frame, context);
+
+                       context->current_frame = frame;
+
+                       if (child_frame.ex) {
+                               /*
+                                * An exception occurred, need to run finally, fault and catch handlers..
+                                */
+                               frame->ex = child_frame.ex;
+                               goto handle_finally;
+                       }
+
+                       /* need to handle typedbyref ... */
+                       *sp = *endsp;
+                       sp++;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_VCALL) {
+                       frame->ip = ip;
+                       
+                       child_frame.runtime_method = rtm->data_items [* (guint16 *)(ip + 1)];
+                       ip += 2;
+
+                       sp->data.p = vt_sp;
+                       child_frame.retval = sp;
+                       /* decrement by the actual number of args */
+                       sp -= child_frame.runtime_method->param_count;
+                       if (child_frame.runtime_method->hasthis)
+                               --sp;
+                       child_frame.stack_args = sp;
+
+                       if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->method->klass->valuetype && mono_object_is_transparent_proxy (sp->data.p)) {
+                               child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       }
+
+                       ves_exec_method_with_context (&child_frame, context);
+
+                       context->current_frame = frame;
+
+                       if (child_frame.ex) {
+                               /*
+                                * An exception occurred, need to run finally, fault and catch handlers..
+                                */
+                               frame->ex = child_frame.ex;
+                               goto handle_finally;
+                       }
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_CALLVIRT) {
+                       stackval *endsp = sp;
+                       MonoObject *this_arg;
+                       guint32 token;
+
+                       frame->ip = ip;
+                       
+                       token = * (unsigned short *)(ip + 1);
+                       ip += 2;
+                       child_frame.runtime_method = rtm->data_items [token];
+                       sp->data.p = vt_sp;
+                       child_frame.retval = sp;
+
+                       /* decrement by the actual number of args */
+                       sp -= child_frame.runtime_method->param_count + 1;
+                       child_frame.stack_args = sp;
+                       this_arg = sp->data.p;
+                       if (!this_arg)
+                               THROW_EX (mono_get_exception_null_reference(), ip - 2);
+                       child_frame.runtime_method = get_virtual_method (context->domain, child_frame.runtime_method, this_arg);
+
+                       MonoClass *this_class = this_arg->vtable->klass;
+                       if (this_class->valuetype && child_frame.runtime_method->method->klass->valuetype) {
+                               /* unbox */
+                               gpointer *unboxed = mono_object_unbox (this_arg);
+                               sp [0].data.p = unboxed;
+                       }
+
+                       ves_exec_method_with_context (&child_frame, context);
+
+                       context->current_frame = frame;
+
+                       if (child_frame.ex) {
+                               /*
+                                * An exception occurred, need to run finally, fault and catch handlers..
+                                */
+                               frame->ex = child_frame.ex;
+                               if (context->search_for_handler) {
+                                       context->search_for_handler = 0;
+                                       goto handle_exception;
+                               }
+                               goto handle_finally;
+                       }
+
+                       /* need to handle typedbyref ... */
+                       *sp = *endsp;
+                       sp++;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_VCALLVIRT) {
+                       MonoObject *this_arg;
+                       guint32 token;
+
+                       frame->ip = ip;
+                       
+                       token = * (unsigned short *)(ip + 1);
+                       ip += 2;
+                       child_frame.runtime_method = rtm->data_items [token];
+                       sp->data.p = vt_sp;
+                       child_frame.retval = sp;
+
+                       /* decrement by the actual number of args */
+                       sp -= child_frame.runtime_method->param_count + 1;
+                       child_frame.stack_args = sp;
+                       this_arg = sp->data.p;
+                       if (!this_arg)
+                               THROW_EX (mono_get_exception_null_reference(), ip - 2);
+                       child_frame.runtime_method = get_virtual_method (context->domain, child_frame.runtime_method, this_arg);
+
+                       MonoClass *this_class = this_arg->vtable->klass;
+                       if (this_class->valuetype && child_frame.runtime_method->method->klass->valuetype) {
+                               gpointer *unboxed = mono_object_unbox (this_arg);
+                               sp [0].data.p = unboxed;
+                       }
+
+                       ves_exec_method_with_context (&child_frame, context);
+
+                       context->current_frame = frame;
+
+                       if (child_frame.ex) {
+                               /*
+                                * An exception occurred, need to run finally, fault and catch handlers..
+                                */
+                               frame->ex = child_frame.ex;
+                               if (context->search_for_handler) {
+                                       context->search_for_handler = 0;
+                                       goto handle_exception;
+                               }
+                               goto handle_finally;
+                       }
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_CALLRUN)
+                       ves_runtime_method (frame, context);
+                       if (frame->ex) {
+                               rtm = NULL;
+                               goto handle_exception;
+                       }
+                       goto exit_frame;
+               MINT_IN_CASE(MINT_RET)
+                       --sp;
+                       *frame->retval = *sp;
+                       if (sp > frame->stack)
+                               g_warning ("ret: more values on stack: %d", sp-frame->stack);
+                       goto exit_frame;
+               MINT_IN_CASE(MINT_RET_VOID)
+                       if (sp > frame->stack)
+                               g_warning ("ret.void: more values on stack: %d", sp-frame->stack);
+                       goto exit_frame;
+               MINT_IN_CASE(MINT_RET_VT)
+                       i32 = READ32(ip + 1);
+                       --sp;
+                       memcpy(frame->retval->data.p, sp->data.p, i32);
+                       if (sp > frame->stack)
+                               g_warning ("ret.vt: more values on stack: %d", sp-frame->stack);
+                       goto exit_frame;
+               MINT_IN_CASE(MINT_BR_S)
+                       ip += (short) *(ip + 1);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BR)
+                       ip += (gint32) READ32(ip + 1);
+                       MINT_IN_BREAK;
+#define ZEROP_S(datamem, op) \
+       --sp; \
+       if (sp->data.datamem op 0) \
+               ip += * (gint16 *)(ip + 1); \
+       else \
+               ip += 2;
+
+#define ZEROP(datamem, op) \
+       --sp; \
+       if (sp->data.datamem op 0) \
+               ip += READ32(ip + 1); \
+       else \
+               ip += 3;
+
+               MINT_IN_CASE(MINT_BRFALSE_I4_S)
+                       ZEROP_S(i, ==);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BRFALSE_I8_S)
+                       ZEROP_S(l, ==);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BRFALSE_R8_S)
+                       ZEROP_S(f, ==);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BRFALSE_I4)
+                       ZEROP(i, ==);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BRFALSE_I8)
+                       ZEROP(l, ==);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BRFALSE_R8)
+                       ZEROP_S(f, ==);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BRTRUE_I4_S)
+                       ZEROP_S(i, !=);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BRTRUE_I8_S)
+                       ZEROP_S(l, !=);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BRTRUE_R8_S)
+                       ZEROP_S(f, !=);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BRTRUE_I4)
+                       ZEROP(i, !=);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BRTRUE_I8)
+                       ZEROP(l, !=);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BRTRUE_R8)
+                       ZEROP(f, !=);
+                       MINT_IN_BREAK;
+#define CONDBR_S(cond) \
+       sp -= 2; \
+       if (cond) \
+               ip += * (gint16 *)(ip + 1); \
+       else \
+               ip += 2;
+#define BRELOP_S(datamem, op) \
+       CONDBR_S(sp[0].data.datamem op sp[1].data.datamem)
+
+#define CONDBR(cond) \
+       sp -= 2; \
+       if (cond) \
+               ip += READ32(ip + 1); \
+       else \
+               ip += 3;
+
+#define BRELOP(datamem, op) \
+       CONDBR(sp[0].data.datamem op sp[1].data.datamem)
+
+               MINT_IN_CASE(MINT_BEQ_I4_S)
+                       BRELOP_S(i, ==)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BEQ_I8_S)
+                       BRELOP_S(l, ==)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BEQ_R8_S)
+                       CONDBR_S(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f == sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BEQ_I4)
+                       BRELOP(i, ==)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BEQ_I8)
+                       BRELOP(l, ==)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BEQ_R8)
+                       CONDBR(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f == sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGE_I4_S)
+                       BRELOP_S(i, >=)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGE_I8_S)
+                       BRELOP_S(l, >=)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGE_R8_S)
+                       CONDBR_S(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f >= sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGE_I4)
+                       BRELOP(i, >=)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGE_I8)
+                       BRELOP(l, >=)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGE_R8)
+                       CONDBR(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f >= sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGT_I4_S)
+                       BRELOP_S(i, >)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGT_I8_S)
+                       BRELOP_S(l, >)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGT_R8_S)
+                       CONDBR_S(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f > sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGT_I4)
+                       BRELOP(i, >)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGT_I8)
+                       BRELOP(l, >)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGT_R8)
+                       CONDBR(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f > sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLT_I4_S)
+                       BRELOP_S(i, <)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLT_I8_S)
+                       BRELOP_S(l, <)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLT_R8_S)
+                       CONDBR_S(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f < sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLT_I4)
+                       BRELOP(i, <)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLT_I8)
+                       BRELOP(l, <)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLT_R8)
+                       CONDBR(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f < sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLE_I4_S)
+                       BRELOP_S(i, <=)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLE_I8_S)
+                       BRELOP_S(l, <=)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLE_R8_S)
+                       CONDBR_S(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f <= sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLE_I4)
+                       BRELOP(i, <=)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLE_I8)
+                       BRELOP(l, <=)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLE_R8)
+                       CONDBR(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f <= sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BNE_UN_I4_S)
+                       BRELOP_S(i, !=)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BNE_UN_I8_S)
+                       BRELOP_S(l, !=)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BNE_UN_R8_S)
+                       CONDBR_S(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f != sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BNE_UN_I4)
+                       BRELOP(i, !=)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BNE_UN_I8)
+                       BRELOP(l, !=)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BNE_UN_R8)
+                       CONDBR(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f != sp[1].data.f)
+                       MINT_IN_BREAK;
+
+#define BRELOP_S_CAST(datamem, op, type) \
+       sp -= 2; \
+       if ((type) sp[0].data.datamem op (type) sp[1].data.datamem) \
+               ip += * (gint16 *)(ip + 1); \
+       else \
+               ip += 2;
+
+#define BRELOP_CAST(datamem, op, type) \
+       sp -= 2; \
+       if ((type) sp[0].data.datamem op (type) sp[1].data.datamem) \
+               ip += READ32(ip + 1); \
+       else \
+               ip += 3;
+
+               MINT_IN_CASE(MINT_BGE_UN_I4_S)
+                       BRELOP_S_CAST(i, >=, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGE_UN_I8_S)
+                       BRELOP_S_CAST(l, >=, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGE_UN_R8_S)
+                       CONDBR_S(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f >= sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGE_UN_I4)
+                       BRELOP_CAST(i, >=, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGE_UN_I8)
+                       BRELOP_CAST(l, >=, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGE_UN_R8)
+                       CONDBR(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f >= sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGT_UN_I4_S)
+                       BRELOP_S_CAST(i, >, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGT_UN_I8_S)
+                       BRELOP_S_CAST(l, >, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGT_UN_R8_S)
+                       CONDBR_S(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f > sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGT_UN_I4)
+                       BRELOP_CAST(i, >, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGT_UN_I8)
+                       BRELOP_CAST(l, >, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BGT_UN_R8)
+                       CONDBR(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f > sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLE_UN_I4_S)
+                       BRELOP_S_CAST(i, <=, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLE_UN_I8_S)
+                       BRELOP_S_CAST(l, <=, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLE_UN_R8_S)
+                       CONDBR_S(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f <= sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLE_UN_I4)
+                       BRELOP_CAST(i, <=, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLE_UN_I8)
+                       BRELOP_CAST(l, <=, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLE_UN_R8)
+                       CONDBR(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f <= sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLT_UN_I4_S)
+                       BRELOP_S_CAST(i, <, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLT_UN_I8_S)
+                       BRELOP_S_CAST(l, <, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLT_UN_R8_S)
+                       CONDBR_S(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f < sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLT_UN_I4)
+                       BRELOP_CAST(i, <, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLT_UN_I8)
+                       BRELOP_CAST(l, <, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BLT_UN_R8)
+                       CONDBR(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f < sp[1].data.f)
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SWITCH) {
+                       guint32 n;
+                       const unsigned short *st;
+                       ++ip;
+                       n = READ32 (ip);
+                       ip += 2;
+                       st = ip + 2 * n;
+                       --sp;
+                       if ((guint32)sp->data.i < n) {
+                               gint offset;
+                               ip += 2 * (guint32)sp->data.i;
+                               offset = READ32 (ip);
+                               ip = st + offset;
+                       } else {
+                               ip = st;
+                       }
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_LDIND_I1)
+                       ++ip;
+                       sp[-1].data.i = *(gint8*)sp[-1].data.p;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDIND_U1)
+                       ++ip;
+                       sp[-1].data.i = *(guint8*)sp[-1].data.p;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDIND_I2)
+                       ++ip;
+                       sp[-1].data.i = *(gint16*)sp[-1].data.p;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDIND_U2)
+                       ++ip;
+                       sp[-1].data.i = *(guint16*)sp[-1].data.p;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDIND_I4) /* Fall through */
+               MINT_IN_CASE(MINT_LDIND_U4)
+                       ++ip;
+                       sp[-1].data.i = *(gint32*)sp[-1].data.p;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDIND_I8)
+                       ++ip;
+                       sp[-1].data.l = *(gint64*)sp[-1].data.p;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDIND_I) {
+                       guint16 offset = * (guint16 *)(ip + 1);
+                       sp[-1 - offset].data.p = *(gpointer*)sp[-1 - offset].data.p;
+                       ip += 2;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_LDIND_R4)
+                       ++ip;
+                       sp[-1].data.f = *(gfloat*)sp[-1].data.p;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDIND_R8)
+                       ++ip;
+                       sp[-1].data.f = *(gdouble*)sp[-1].data.p;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDIND_REF)
+                       ++ip;
+                       sp[-1].data.p = *(gpointer*)sp[-1].data.p;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STIND_REF) 
+                       ++ip;
+                       sp -= 2;
+                       * (gpointer *) sp->data.p = sp[1].data.p;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STIND_I1)
+                       ++ip;
+                       sp -= 2;
+                       * (gint8 *) sp->data.p = (gint8)sp[1].data.i;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STIND_I2)
+                       ++ip;
+                       sp -= 2;
+                       * (gint16 *) sp->data.p = (gint16)sp[1].data.i;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STIND_I4)
+                       ++ip;
+                       sp -= 2;
+                       * (gint32 *) sp->data.p = sp[1].data.i;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STIND_I)
+                       ++ip;
+                       sp -= 2;
+                       * (mono_i *) sp->data.p = (mono_i)sp[1].data.p;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STIND_I8)
+                       ++ip;
+                       sp -= 2;
+                       * (gint64 *) sp->data.p = sp[1].data.l;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STIND_R4)
+                       ++ip;
+                       sp -= 2;
+                       * (float *) sp->data.p = (gfloat)sp[1].data.f;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STIND_R8)
+                       ++ip;
+                       sp -= 2;
+                       * (double *) sp->data.p = sp[1].data.f;
+                       MINT_IN_BREAK;
+#define BINOP(datamem, op) \
+       --sp; \
+       sp [-1].data.datamem = sp [-1].data.datamem op sp [0].data.datamem; \
+       ++ip;
+               MINT_IN_CASE(MINT_ADD_I4)
+                       BINOP(i, +);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_ADD_I8)
+                       BINOP(l, +);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_ADD_R8)
+                       BINOP(f, +);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_ADD1_I4)
+                       ++sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SUB_I4)
+                       BINOP(i, -);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SUB_I8)
+                       BINOP(l, -);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SUB_R8)
+                       BINOP(f, -);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SUB1_I4)
+                       --sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_MUL_I4)
+                       BINOP(i, *);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_MUL_I8)
+                       BINOP(l, *);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_MUL_R8)
+                       BINOP(f, *);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_DIV_I4)
+                       if (sp [-1].data.i == 0)
+                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
+                       if (sp [-1].data.i == (-1))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP(i, /);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_DIV_I8)
+                       if (sp [-1].data.l == 0)
+                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
+                       if (sp [-1].data.l == (-1))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP(l, /);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_DIV_R8)
+                       BINOP(f, /);
+                       MINT_IN_BREAK;
+
+#define BINOP_CAST(datamem, op, type) \
+       --sp; \
+       sp [-1].data.datamem = (type)sp [-1].data.datamem op (type)sp [0].data.datamem; \
+       ++ip;
+               MINT_IN_CASE(MINT_DIV_UN_I4)
+                       if (sp [-1].data.i == 0)
+                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
+                       BINOP_CAST(i, /, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_DIV_UN_I8)
+                       if (sp [-1].data.l == 0)
+                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
+                       BINOP_CAST(l, /, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_REM_I4)
+                       if (sp [-1].data.i == 0)
+                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
+                       BINOP(i, %);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_REM_I8)
+                       if (sp [-1].data.l == 0)
+                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
+                       BINOP(l, %);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_REM_R8)
+                       /* FIXME: what do we actually do here? */
+                       --sp;
+                       sp [-1].data.f = fmod (sp [-1].data.f, sp [0].data.f);
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_REM_UN_I4)
+                       if (sp [-1].data.i == 0)
+                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
+                       BINOP_CAST(i, %, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_REM_UN_I8)
+                       if (sp [-1].data.l == 0)
+                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
+                       BINOP_CAST(l, %, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_AND_I4)
+                       BINOP(i, &);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_AND_I8)
+                       BINOP(l, &);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_OR_I4)
+                       BINOP(i, |);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_OR_I8)
+                       BINOP(l, |);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_XOR_I4)
+                       BINOP(i, ^);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_XOR_I8)
+                       BINOP(l, ^);
+                       MINT_IN_BREAK;
+
+#define SHIFTOP(datamem, op) \
+       --sp; \
+       sp [-1].data.datamem = sp [-1].data.datamem op sp [0].data.i; \
+       ++ip;
+
+               MINT_IN_CASE(MINT_SHL_I4)
+                       SHIFTOP(i, <<);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SHL_I8)
+                       SHIFTOP(l, <<);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SHR_I4)
+                       SHIFTOP(i, >>);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SHR_I8)
+                       SHIFTOP(l, >>);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SHR_UN_I4)
+                       --sp;
+                       sp [-1].data.i = (guint32)sp [-1].data.i >> sp [0].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SHR_UN_I8)
+                       --sp;
+                       sp [-1].data.l = (guint64)sp [-1].data.l >> sp [0].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_NEG_I4)
+                       sp [-1].data.i = - sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_NEG_I8)
+                       sp [-1].data.l = - sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_NEG_R8)
+                       sp [-1].data.f = - sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_NOT_I4)
+                       sp [-1].data.i = ~ sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_NOT_I8)
+                       sp [-1].data.l = ~ sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_I1_I4)
+                       sp [-1].data.i = (gint8)sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_I1_I8)
+                       sp [-1].data.i = (gint8)sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_I1_R8)
+                       sp [-1].data.i = (gint8)sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_U1_I4)
+                       sp [-1].data.i = (guint8)sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_U1_I8)
+                       sp [-1].data.i = (guint8)sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_U1_R8)
+                       sp [-1].data.i = (guint8)sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_I2_I4)
+                       sp [-1].data.i = (gint16)sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_I2_I8)
+                       sp [-1].data.i = (gint16)sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_I2_R8)
+                       sp [-1].data.i = (gint16)sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_U2_I4)
+                       sp [-1].data.i = (guint16)sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_U2_I8)
+                       sp [-1].data.i = (guint16)sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_U2_R8)
+                       sp [-1].data.i = (guint16)sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_I4_R8)
+                       sp [-1].data.i = (gint32)sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_U4_I8)
+               MINT_IN_CASE(MINT_CONV_I4_I8)
+                       sp [-1].data.i = (gint32)sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_I4_I8_SP)
+                       sp [-2].data.i = (gint32)sp [-2].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_U4_R8)
+                       sp [-1].data.i = (guint32)sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_I8_I4)
+                       sp [-1].data.l = sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_I8_I4_SP)
+                       sp [-2].data.l = sp [-2].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_I8_U4)
+                       sp [-1].data.l = (guint32)sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_I8_R8)
+                       sp [-1].data.l = (gint64)sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_R4_I4)
+                       sp [-1].data.f = (float)sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_R4_I8)
+                       sp [-1].data.f = (float)sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_R4_R8)
+                       sp [-1].data.f = (float)sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_R8_I4)
+                       sp [-1].data.f = (double)sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_R8_I8)
+                       sp [-1].data.f = (double)sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_U8_I4)
+                       sp [-1].data.l = sp [-1].data.i & 0xffffffff;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_U8_R8)
+                       sp [-1].data.l = (guint64)sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+#if 0
+               MINT_IN_CASE(MINT_CPOBJ) {
+                       MonoClass *vtklass;
+                       ++ip;
+                       vtklass = rtm->data_items[READ32 (ip)];
+                       ip += 2;
+                       sp -= 2;
+                       memcpy (sp [0].data.p, sp [1].data.p, mono_class_value_size (vtklass, NULL));
+                       MINT_IN_BREAK;
+               }
+#endif
+               MINT_IN_CASE(MINT_LDOBJ) {
+                       int size;
+                       void *p;
+                       c = rtm->data_items[* (guint16 *)(ip + 1)];
+                       ip += 2;
+                       if (c->byval_arg.type != MONO_TYPE_VALUETYPE || c->byval_arg.data.klass->enumtype) {
+                               p = sp [-1].data.p;
+                               stackval_from_data (&c->byval_arg, &sp [-1], p, FALSE);
+                       } else {
+                               size = mono_class_value_size (c, NULL);
+                               p = sp [-1].data.p;
+                               sp [-1].data.p = vt_sp;
+                               memcpy(vt_sp, p, size);
+                               vt_sp += (size + 7) & ~7;
+                       }
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_LDSTR)
+                       sp->data.p = rtm->data_items [* (guint16 *)(ip + 1)];
+                       ++sp;
+                       ip += 2;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_NEWOBJ) {
+                       MonoClass *newobj_class;
+                       MonoMethodSignature *csig;
+                       stackval valuetype_this;
+                       guint32 token;
+                       stackval retval;
+
+                       frame->ip = ip;
+
+                       token = * (guint16 *)(ip + 1);
+                       ip += 2;
+
+                       child_frame.runtime_method = rtm->data_items [token];
+                       csig = mono_method_signature (child_frame.runtime_method->method);
+                       newobj_class = child_frame.runtime_method->method->klass;
+                       /*if (profiling_classes) {
+                               guint count = GPOINTER_TO_UINT (g_hash_table_lookup (profiling_classes, newobj_class));
+                               count++;
+                               g_hash_table_insert (profiling_classes, newobj_class, GUINT_TO_POINTER (count));
+                       }*/
+                               
+                       if (newobj_class->parent == mono_defaults.array_class) {
+                               sp -= csig->param_count;
+                               o = ves_array_create (context->domain, newobj_class, csig, sp);
+                               goto array_constructed;
+                       }
+
+                       g_assert (csig->hasthis);
+                       if (csig->param_count) {
+                               sp -= csig->param_count;
+                               memmove (sp + 1, sp, csig->param_count * sizeof (stackval));
+                       }
+                       child_frame.stack_args = sp;
+
+                       /*
+                        * First arg is the object.
+                        */
+                       if (newobj_class->valuetype) {
+                               MonoType *t = &newobj_class->byval_arg;
+                               if (!newobj_class->enumtype && (t->type == MONO_TYPE_VALUETYPE || (t->type == MONO_TYPE_GENERICINST && mono_type_generic_inst_is_valuetype (t)))) {
+                                       sp->data.p = vt_sp;
+                                       valuetype_this.data.p = vt_sp;
+                               } else {
+                                       memset (&valuetype_this, 0, sizeof (stackval));
+                                       sp->data.p = &valuetype_this;
+                               }
+                       } else {
+                               if (newobj_class != mono_defaults.string_class) {
+                                       context->managed_code = 0;
+                                       o = mono_object_new_checked (context->domain, newobj_class, &error);
+                                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                                       context->managed_code = 1;
+                                       if (*mono_thread_interruption_request_flag ())
+                                               mono_thread_interruption_checkpoint ();
+                                       sp->data.p = o;
+                               } else {
+                                       sp->data.p = NULL;
+                                       child_frame.retval = &retval;
+                               }
+                       }
+
+                       g_assert (csig->call_convention == MONO_CALL_DEFAULT);
+
+                       child_frame.ip = NULL;
+                       child_frame.ex = NULL;
+
+                       ves_exec_method_with_context (&child_frame, context);
+
+                       context->current_frame = frame;
+
+                       if (child_frame.ex) {
+                               /*
+                                * An exception occurred, need to run finally, fault and catch handlers..
+                                */
+                               frame->ex = child_frame.ex;
+                               goto handle_finally;
+                       }
+                       /*
+                        * a constructor returns void, but we need to return the object we created
+                        */
+array_constructed:
+                       if (newobj_class->valuetype && !newobj_class->enumtype) {
+                               *sp = valuetype_this;
+                       } else if (newobj_class == mono_defaults.string_class) {
+                               *sp = retval;
+                       } else {
+                               sp->data.p = o;
+                       }
+                       ++sp;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_CASTCLASS)
+                       c = rtm->data_items [*(guint16 *)(ip + 1)];
+                       if ((o = sp [-1].data.p)) {
+                               MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                               if (!isinst_obj)
+                                       THROW_EX (mono_get_exception_invalid_cast (), ip);
+                       }
+                       ip += 2;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_ISINST)
+                       c = rtm->data_items [*(guint16 *)(ip + 1)];
+                       if ((o = sp [-1].data.p)) {
+                               MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                               if (!isinst_obj)
+                                       sp [-1].data.p = NULL;
+                       }
+                       ip += 2;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_R_UN_I4)
+                       sp [-1].data.f = (double)(guint32)sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_R_UN_I8)
+                       sp [-1].data.f = (double)(guint64)sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_UNBOX)
+                       c = rtm->data_items[*(guint16 *)(ip + 1)];
+                       
+                       o = sp [-1].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+
+                       MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       if (!(isinst_obj || ((o->vtable->klass->rank == 0) && (o->vtable->klass->element_class == c->element_class))))
+                               THROW_EX (mono_get_exception_invalid_cast (), ip);
+
+                       if (c->byval_arg.type == MONO_TYPE_VALUETYPE && !c->enumtype) {
+                               int size = mono_class_native_size (c, NULL);
+                               sp [-1].data.p = vt_sp;
+                               vt_sp += (size + 7) & ~7;
+                       }
+                       stackval_from_data (&c->byval_arg, &sp [-1], mono_object_unbox (o), FALSE);
+                       ip += 2;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_THROW)
+                       --sp;
+                       frame->ex_handler = NULL;
+                       if (!sp->data.p)
+                               sp->data.p = mono_get_exception_null_reference ();
+                       THROW_EX ((MonoException *)sp->data.p, ip);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDFLDA)
+                       o = sp [-1].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+                       sp[-1].data.p = (char *)o + * (guint16 *)(ip + 1);
+                       ip += 2;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CKNULL)
+                       o = sp [-1].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+                       ++ip;
+                       MINT_IN_BREAK;
+
+#define LDFLD(datamem, fieldtype) \
+       o = sp [-1].data.p; \
+       if (!o) \
+               THROW_EX (mono_get_exception_null_reference (), ip); \
+       sp[-1].data.datamem = * (fieldtype *)((char *)o + * (guint16 *)(ip + 1)) ; \
+       ip += 2;
+
+               MINT_IN_CASE(MINT_LDFLD_I1) LDFLD(i, gint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDFLD_U1) LDFLD(i, guint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDFLD_I2) LDFLD(i, gint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDFLD_U2) LDFLD(i, guint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDFLD_I4) LDFLD(i, gint32); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDFLD_I8) LDFLD(l, gint64); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDFLD_R4) LDFLD(f, float); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDFLD_R8) LDFLD(f, double); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDFLD_O) LDFLD(p, gpointer); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDFLD_P) LDFLD(p, gpointer); MINT_IN_BREAK;
+
+               MINT_IN_CASE(MINT_LDFLD_VT)
+                       o = sp [-1].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+                       i32 = READ32(ip + 2);
+                       sp [-1].data.p = vt_sp;
+                       memcpy(sp [-1].data.p, (char *)o + * (guint16 *)(ip + 1), i32);
+                       vt_sp += (i32 + 7) & ~7;
+                       ip += 4;
+                       MINT_IN_BREAK;
+
+               MINT_IN_CASE(MINT_LDRMFLD) {
+                       gpointer tmp;
+                       MonoClassField *field;
+                       char *addr;
+
+                       o = sp [-1].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+                       field = rtm->data_items[* (guint16 *)(ip + 1)];
+                       ip += 2;
+                       if (mono_object_is_transparent_proxy (o)) {
+                               MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
+
+                               addr = mono_load_remote_field_checked (o, klass, field, &tmp, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       } else {
+                               addr = (char*)o + field->offset;
+                       }                               
+
+                       stackval_from_data (field->type, &sp [-1], addr, FALSE);
+                       MINT_IN_BREAK;
+               }
+
+               MINT_IN_CASE(MINT_LDRMFLD_VT) {
+                       MonoClassField *field;
+                       char *addr;
+                       gpointer tmp;
+
+                       o = sp [-1].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+                       field = rtm->data_items[* (guint16 *)(ip + 1)];
+                       i32 = READ32(ip + 2);
+                       ip += 4;
+                       if (mono_object_is_transparent_proxy (o)) {
+                               MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
+                               addr = mono_load_remote_field_checked (o, klass, field, &tmp, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       } else {
+                               addr = (char*)o + field->offset;
+                       }                               
+
+                       sp [-1].data.p = vt_sp;
+                       memcpy(sp [-1].data.p, (char *)o + * (guint16 *)(ip + 1), i32);
+                       vt_sp += (i32 + 7) & ~7;
+                       memcpy(sp [-1].data.p, addr, i32);
+                       MINT_IN_BREAK;
+               }
+
+#define STFLD(datamem, fieldtype) \
+       o = sp [-2].data.p; \
+       if (!o) \
+               THROW_EX (mono_get_exception_null_reference (), ip); \
+       sp -= 2; \
+       * (fieldtype *)((char *)o + * (guint16 *)(ip + 1)) = sp[1].data.datamem; \
+       ip += 2;
+
+               MINT_IN_CASE(MINT_STFLD_I1) STFLD(i, gint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STFLD_U1) STFLD(i, guint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STFLD_I2) STFLD(i, gint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STFLD_U2) STFLD(i, guint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STFLD_I4) STFLD(i, gint32); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STFLD_I8) STFLD(l, gint64); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STFLD_R4) STFLD(f, float); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STFLD_R8) STFLD(f, double); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STFLD_O) STFLD(p, gpointer); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STFLD_P) STFLD(p, gpointer); MINT_IN_BREAK;
+
+               MINT_IN_CASE(MINT_STFLD_VT)
+                       o = sp [-2].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+                       i32 = READ32(ip + 2);
+                       sp -= 2;
+                       memcpy((char *)o + * (guint16 *)(ip + 1), sp [1].data.p, i32);
+                       vt_sp -= (i32 + 7) & ~7;
+                       ip += 4;
+                       MINT_IN_BREAK;
+
+               MINT_IN_CASE(MINT_STRMFLD) {
+                       MonoClassField *field;
+
+                       o = sp [-2].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+                       
+                       field = rtm->data_items[* (guint16 *)(ip + 1)];
+                       ip += 2;
+
+                       if (mono_object_is_transparent_proxy (o)) {
+                               MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
+                               mono_store_remote_field_checked (o, klass, field, &sp [-1].data, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       } else
+                               stackval_to_data (field->type, &sp [-1], (char*)o + field->offset, FALSE);
+
+                       sp -= 2;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_STRMFLD_VT) {
+                       MonoClassField *field;
+
+                       o = sp [-2].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+                       field = rtm->data_items[* (guint16 *)(ip + 1)];
+                       i32 = READ32(ip + 2);
+                       ip += 4;
+
+                       if (mono_object_is_transparent_proxy (o)) {
+                               MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
+                               mono_store_remote_field_checked (o, klass, field, &sp [-1].data, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       } else
+                               memcpy((char*)o + field->offset, sp [-1].data.p, i32);
+
+                       sp -= 2;
+                       vt_sp -= (i32 + 7) & ~7;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_LDSFLDA) {
+                       MonoClassField *field = rtm->data_items[*(guint16 *)(ip + 1)];
+                       sp->data.p = mono_class_static_field_address (context->domain, field);
+                       ip += 2;
+                       ++sp;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_LDSFLD) {
+                       MonoClassField *field = rtm->data_items [* (guint16 *)(ip + 1)];
+                       gpointer addr = mono_class_static_field_address (context->domain, field);
+                       stackval_from_data (field->type, sp, addr, FALSE);
+                       ip += 2;
+                       ++sp;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_LDSFLD_VT) {
+                       MonoClassField *field = rtm->data_items [* (guint16 *)(ip + 1)];
+                       gpointer addr = mono_class_static_field_address (context->domain, field);
+                       int size = READ32 (ip + 2);
+                       ip += 4;
+
+                       sp->data.p = vt_sp;
+                       vt_sp += (size + 7) & ~7;
+                       stackval_from_data (field->type, sp, addr, FALSE);
+                       ++sp;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_STSFLD) {
+                       MonoClassField *field = rtm->data_items [* (guint16 *)(ip + 1)];
+                       gpointer addr = mono_class_static_field_address (context->domain, field);
+                       ip += 2;
+                       --sp;
+                       stackval_to_data (field->type, sp, addr, FALSE);
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_STSFLD_VT) {
+                       MonoClassField *field = rtm->data_items [* (guint16 *)(ip + 1)];
+                       gpointer addr = mono_class_static_field_address (context->domain, field);
+                       int size = READ32 (ip + 2);
+                       ip += 4;
+
+                       --sp;
+                       stackval_to_data (field->type, sp, addr, FALSE);
+                       vt_sp -= (size + 7) & ~7;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_STOBJ_VT) {
+                       int size;
+                       c = rtm->data_items[* (guint16 *)(ip + 1)];
+                       ip += 2;
+                       size = mono_class_value_size (c, NULL);
+                       memcpy(sp [-2].data.p, sp [-1].data.p, size);
+                       vt_sp -= (size + 7) & ~7;
+                       sp -= 2;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_STOBJ) {
+                       int size;
+                       c = rtm->data_items[* (guint16 *)(ip + 1)];
+                       ip += 2;
+                       size = mono_class_value_size (c, NULL);
+                       memcpy(sp [-2].data.p, &sp [-1].data, size);
+                       sp -= 2;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_CONV_OVF_I4_UN_R8)
+                       if (sp [-1].data.f < 0 || sp [-1].data.f > MYGUINT32_MAX)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (guint32)sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_U8_I4)
+                       if (sp [-1].data.i < 0)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.l = sp [-1].data.i;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_U8_R8)
+               MINT_IN_CASE(MINT_CONV_OVF_I8_UN_R8)
+                       if (sp [-1].data.f < 0 || sp [-1].data.f > 9223372036854775807LL)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.l = (guint64)sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_I8_R8)
+                       if (sp [-1].data.f < MYGINT64_MIN || sp [-1].data.f > MYGINT64_MAX)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.l = (gint64)sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_I4_UN_I8)
+                       if ((mono_u)sp [-1].data.l > MYGUINT32_MAX)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (mono_u)sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_BOX) {
+                       c = rtm->data_items [* (guint16 *)(ip + 1)];
+                       guint16 offset = * (guint16 *)(ip + 2);
+
+                       if (c->byval_arg.type == MONO_TYPE_VALUETYPE && !c->enumtype) {
+                               int size = mono_class_value_size (c, NULL);
+                               sp [-1 - offset].data.p = mono_value_box_checked (context->domain, c, sp [-1 - offset].data.p, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                               size = (size + 7) & ~7;
+                               vt_sp -= size;
+                       } else {
+                               stackval_to_data (&c->byval_arg, &sp [-1 - offset], (char *) &sp [-1 - offset], FALSE);
+                               sp [-1 - offset].data.p = mono_value_box_checked (context->domain, c, &sp [-1 - offset], &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       }
+                       ip += 3;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_NEWARR)
+                       sp [-1].data.p = (MonoObject*) mono_array_new_checked (context->domain, rtm->data_items[*(guint16 *)(ip + 1)], sp [-1].data.i, &error);
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       ip += 2;
+                       /*if (profiling_classes) {
+                               guint count = GPOINTER_TO_UINT (g_hash_table_lookup (profiling_classes, o->vtable->klass));
+                               count++;
+                               g_hash_table_insert (profiling_classes, o->vtable->klass, GUINT_TO_POINTER (count));
+                       }*/
+
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDLEN)
+                       o = sp [-1].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+                       sp [-1].data.nati = mono_array_length ((MonoArray *)o);
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_GETCHR) {
+                       MonoString *s;
+                       s = sp [-2].data.p;
+                       if (!s)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+                       i32 = sp [-1].data.i;
+                       if (i32 < 0 || i32 >= mono_string_length (s))
+                               THROW_EX (mono_get_exception_index_out_of_range (), ip);
+                       --sp;
+                       sp [-1].data.i = mono_string_chars(s)[i32];
+                       ++ip;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_STRLEN)
+                       ++ip;
+                       sp [-1].data.i = mono_string_length ((MonoString*)sp [-1].data.p);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_ARRAY_RANK)
+                       o = sp [-1].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+                       sp [-1].data.i = mono_object_class (sp [-1].data.p)->rank;
+                       ip++;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDELEMA) {
+                       guint32 esize;
+                       mono_u aindex;
+                       
+                       /*token = READ32 (ip)*/;
+                       ip += 2;
+                       sp -= 2;
+
+                       o = sp [0].data.p;
+
+                       aindex = sp [1].data.i;
+                       if (aindex >= mono_array_length ((MonoArray *) o))
+                               THROW_EX (mono_get_exception_index_out_of_range (), ip - 2);
+
+                       /* check the array element corresponds to token */
+                       esize = mono_array_element_size (((MonoArray *) o)->obj.vtable->klass);
+                       
+                       sp->data.p = mono_array_addr_with_size ((MonoArray *) o, esize, aindex);
+                       ++sp;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_LDELEM_I1) /* fall through */
+               MINT_IN_CASE(MINT_LDELEM_U1) /* fall through */
+               MINT_IN_CASE(MINT_LDELEM_I2) /* fall through */
+               MINT_IN_CASE(MINT_LDELEM_U2) /* fall through */
+               MINT_IN_CASE(MINT_LDELEM_I4) /* fall through */
+               MINT_IN_CASE(MINT_LDELEM_U4) /* fall through */
+               MINT_IN_CASE(MINT_LDELEM_I8)  /* fall through */
+               MINT_IN_CASE(MINT_LDELEM_I)  /* fall through */
+               MINT_IN_CASE(MINT_LDELEM_R4) /* fall through */
+               MINT_IN_CASE(MINT_LDELEM_R8) /* fall through */
+               MINT_IN_CASE(MINT_LDELEM_REF) /* fall through */
+               MINT_IN_CASE(MINT_LDELEM_VT) {
+                       MonoArray *o;
+                       mono_u aindex;
+
+                       sp -= 2;
+
+                       o = sp [0].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+
+                       aindex = sp [1].data.i;
+                       if (aindex >= mono_array_length (o))
+                               THROW_EX (mono_get_exception_index_out_of_range (), ip);
+
+                       /*
+                        * FIXME: throw mono_get_exception_array_type_mismatch () if needed 
+                        */
+                       switch (*ip) {
+                       case MINT_LDELEM_I1:
+                               sp [0].data.i = mono_array_get (o, gint8, aindex);
+                               break;
+                       case MINT_LDELEM_U1:
+                               sp [0].data.i = mono_array_get (o, guint8, aindex);
+                               break;
+                       case MINT_LDELEM_I2:
+                               sp [0].data.i = mono_array_get (o, gint16, aindex);
+                               break;
+                       case MINT_LDELEM_U2:
+                               sp [0].data.i = mono_array_get (o, guint16, aindex);
+                               break;
+                       case MINT_LDELEM_I:
+                               sp [0].data.nati = mono_array_get (o, mono_i, aindex);
+                               break;
+                       case MINT_LDELEM_I4:
+                               sp [0].data.i = mono_array_get (o, gint32, aindex);
+                               break;
+                       case MINT_LDELEM_U4:
+                               sp [0].data.i = mono_array_get (o, guint32, aindex);
+                               break;
+                       case MINT_LDELEM_I8:
+                               sp [0].data.l = mono_array_get (o, guint64, aindex);
+                               break;
+                       case MINT_LDELEM_R4:
+                               sp [0].data.f = mono_array_get (o, float, aindex);
+                               break;
+                       case MINT_LDELEM_R8:
+                               sp [0].data.f = mono_array_get (o, double, aindex);
+                               break;
+                       case MINT_LDELEM_REF:
+                               sp [0].data.p = mono_array_get (o, gpointer, aindex);
+                               break;
+                       case MINT_LDELEM_VT: {
+                               MonoClass *klass_vt = rtm->data_items [*(guint16 *) (ip + 1)];
+                               i32 = READ32 (ip + 2);
+                               char *src_addr = mono_array_addr_with_size ((MonoArray *) o, i32, aindex);
+                               sp [0].data.vt = vt_sp;
+                               stackval_from_data (&klass_vt->byval_arg, sp, src_addr, FALSE);
+                               vt_sp += (i32 + 7) & ~7;
+                               ip += 3;
+                               break;
+                       }
+                       default:
+                               ves_abort();
+                       }
+
+                       ++ip;
+                       ++sp;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_STELEM_I)  /* fall through */
+               MINT_IN_CASE(MINT_STELEM_I1) /* fall through */ 
+               MINT_IN_CASE(MINT_STELEM_I2) /* fall through */
+               MINT_IN_CASE(MINT_STELEM_I4) /* fall through */
+               MINT_IN_CASE(MINT_STELEM_I8) /* fall through */
+               MINT_IN_CASE(MINT_STELEM_R4) /* fall through */
+               MINT_IN_CASE(MINT_STELEM_R8) /* fall through */
+               MINT_IN_CASE(MINT_STELEM_REF) /* fall through */
+               MINT_IN_CASE(MINT_STELEM_VT) {
+                       mono_u aindex;
+
+                       sp -= 3;
+
+                       o = sp [0].data.p;
+                       if (!o)
+                               THROW_EX (mono_get_exception_null_reference (), ip);
+
+                       aindex = sp [1].data.i;
+                       if (aindex >= mono_array_length ((MonoArray *)o))
+                               THROW_EX (mono_get_exception_index_out_of_range (), ip);
+
+                       switch (*ip) {
+                       case MINT_STELEM_I:
+                               mono_array_set ((MonoArray *)o, mono_i, aindex, sp [2].data.nati);
+                               break;
+                       case MINT_STELEM_I1:
+                               mono_array_set ((MonoArray *)o, gint8, aindex, sp [2].data.i);
+                               break;
+                       case MINT_STELEM_I2:
+                               mono_array_set ((MonoArray *)o, gint16, aindex, sp [2].data.i);
+                               break;
+                       case MINT_STELEM_I4:
+                               mono_array_set ((MonoArray *)o, gint32, aindex, sp [2].data.i);
+                               break;
+                       case MINT_STELEM_I8:
+                               mono_array_set ((MonoArray *)o, gint64, aindex, sp [2].data.l);
+                               break;
+                       case MINT_STELEM_R4:
+                               mono_array_set ((MonoArray *)o, float, aindex, sp [2].data.f);
+                               break;
+                       case MINT_STELEM_R8:
+                               mono_array_set ((MonoArray *)o, double, aindex, sp [2].data.f);
+                               break;
+                       case MINT_STELEM_REF: {
+                               MonoObject *isinst_obj = mono_object_isinst_checked (sp [2].data.p, mono_object_class (o)->element_class, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                               if (sp [2].data.p && !isinst_obj)
+                                       THROW_EX (mono_get_exception_array_type_mismatch (), ip);
+                               mono_array_set ((MonoArray *)o, gpointer, aindex, sp [2].data.p);
+                               break;
+                       }
+                       case MINT_STELEM_VT: {
+                               MonoClass *klass_vt = rtm->data_items [*(guint16 *) (ip + 1)];
+                               i32 = READ32 (ip + 2);
+                               char *dst_addr = mono_array_addr_with_size ((MonoArray *) o, i32, aindex);
+
+                               stackval_to_data (&klass_vt->byval_arg, &sp [2], dst_addr, FALSE);
+                               vt_sp -= (i32 + 7) & ~7;
+                               ip += 3;
+                               break;
+                       }
+                       default:
+                               ves_abort();
+                       }
+
+                       ++ip;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_CONV_OVF_I4_U4)
+                       if (sp [-1].data.i < 0)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_I4_I8)
+                       if (sp [-1].data.l < MYGINT32_MIN || sp [-1].data.l > MYGINT32_MAX)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (gint32) sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_I4_R8)
+                       if (sp [-1].data.f < MYGINT32_MIN || sp [-1].data.f > MYGINT32_MAX)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (gint32) sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_U4_I4)
+                       if (sp [-1].data.i < 0)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_U4_I8)
+                       if (sp [-1].data.l < 0 || sp [-1].data.l > MYGUINT32_MAX)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (guint32) sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_U4_R8)
+                       if (sp [-1].data.f < 0 || sp [-1].data.f > MYGUINT32_MAX)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (guint32) sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_I2_I4)
+                       if (sp [-1].data.i < -32768 || sp [-1].data.i > 32767)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_I2_I8)
+                       if (sp [-1].data.l < -32768 || sp [-1].data.l > 32767)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (gint16) sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_I2_R8)
+                       if (sp [-1].data.f < -32768 || sp [-1].data.f > 32767)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (gint16) sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_U2_I4)
+                       if (sp [-1].data.i < 0 || sp [-1].data.i > 65535)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_U2_I8)
+                       if (sp [-1].data.l < 0 || sp [-1].data.l > 65535)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (guint16) sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_U2_R8)
+                       if (sp [-1].data.f < 0 || sp [-1].data.f > 65535)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (guint16) sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_I1_I4)
+                       if (sp [-1].data.i < -128 || sp [-1].data.i > 127)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_I1_I8)
+                       if (sp [-1].data.l < -128 || sp [-1].data.l > 127)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (gint8) sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_I1_R8)
+                       if (sp [-1].data.f < -128 || sp [-1].data.f > 127)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (gint8) sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_U1_I4)
+                       if (sp [-1].data.i < 0 || sp [-1].data.i > 255)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_U1_I8)
+                       if (sp [-1].data.l < 0 || sp [-1].data.l > 255)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (guint8) sp [-1].data.l;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CONV_OVF_U1_R8)
+                       if (sp [-1].data.f < 0 || sp [-1].data.f > 255)
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       sp [-1].data.i = (guint8) sp [-1].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+#if 0
+               MINT_IN_CASE(MINT_LDELEM) 
+               MINT_IN_CASE(MINT_STELEM) 
+               MINT_IN_CASE(MINT_UNBOX_ANY) 
+
+               MINT_IN_CASE(MINT_REFANYVAL) ves_abort(); MINT_IN_BREAK;
+#endif
+               MINT_IN_CASE(MINT_CKFINITE)
+                       if (!isfinite(sp [-1].data.f))
+                               THROW_EX (mono_get_exception_arithmetic (), ip);
+                       ++ip;
+                       MINT_IN_BREAK;
+#if 0
+               MINT_IN_CASE(MINT_MKREFANY) ves_abort(); MINT_IN_BREAK;
+#endif
+               MINT_IN_CASE(MINT_LDTOKEN)
+                       sp->data.p = vt_sp;
+                       vt_sp += 8;
+                       * (gpointer *)sp->data.p = rtm->data_items[*(guint16 *)(ip + 1)];
+                       ip += 2;
+                       ++sp;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_ADD_OVF_I4)
+                       if (CHECK_ADD_OVERFLOW (sp [-2].data.i, sp [-1].data.i))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP(i, +);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_ADD_OVF_I8)
+                       if (CHECK_ADD_OVERFLOW64 (sp [-2].data.l, sp [-1].data.l))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP(l, +);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_ADD_OVF_UN_I4)
+                       if (CHECK_ADD_OVERFLOW_UN (sp [-2].data.i, sp [-1].data.i))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP_CAST(i, +, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_ADD_OVF_UN_I8)
+                       if (CHECK_ADD_OVERFLOW64_UN (sp [-2].data.l, sp [-1].data.l))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP_CAST(l, +, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_MUL_OVF_I4)
+                       if (CHECK_MUL_OVERFLOW (sp [-2].data.i, sp [-1].data.i))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP(i, *);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_MUL_OVF_I8)
+                       if (CHECK_MUL_OVERFLOW64 (sp [-2].data.l, sp [-1].data.l))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP(l, *);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_MUL_OVF_UN_I4)
+                       if (CHECK_MUL_OVERFLOW_UN (sp [-2].data.i, sp [-1].data.i))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP_CAST(i, *, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_MUL_OVF_UN_I8)
+                       if (CHECK_MUL_OVERFLOW64_UN (sp [-2].data.l, sp [-1].data.l))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP_CAST(l, *, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SUB_OVF_I4)
+                       if (CHECK_SUB_OVERFLOW (sp [-2].data.i, sp [-1].data.i))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP(i, -);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SUB_OVF_I8)
+                       if (CHECK_SUB_OVERFLOW64 (sp [-2].data.l, sp [-1].data.l))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP(l, -);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SUB_OVF_UN_I4)
+                       if (CHECK_SUB_OVERFLOW_UN (sp [-2].data.i, sp [-1].data.i))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP_CAST(i, -, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_SUB_OVF_UN_I8)
+                       if (CHECK_SUB_OVERFLOW64_UN (sp [-2].data.l, sp [-1].data.l))
+                               THROW_EX (mono_get_exception_overflow (), ip);
+                       BINOP_CAST(l, -, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_ENDFINALLY)
+                       if (finally_ips) {
+                               ip = finally_ips->data;
+                               finally_ips = g_slist_remove (finally_ips, ip);
+                               goto main_loop;
+                       }
+                       if (frame->ex)
+                               goto handle_fault;
+                       ves_abort();
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LEAVE) /* Fall through */
+               MINT_IN_CASE(MINT_LEAVE_S)
+                       while (sp > frame->stack) {
+                               --sp;
+                       }
+                       frame->ip = ip;
+                       if (*ip == MINT_LEAVE_S) {
+                               ip += (short) *(ip + 1);
+                       } else {
+                               ip += (gint32) READ32 (ip + 1);
+                       }
+                       endfinally_ip = ip;
+                       if (frame->ex_handler != NULL && MONO_OFFSET_IN_HANDLER(frame->ex_handler, frame->ip - rtm->code)) {
+                               frame->ex_handler = NULL;
+                               frame->ex = NULL;
+                       }
+                       goto handle_finally;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_ICALL_V_V) 
+               MINT_IN_CASE(MINT_ICALL_V_P)
+               MINT_IN_CASE(MINT_ICALL_P_V) 
+               MINT_IN_CASE(MINT_ICALL_P_P)
+               MINT_IN_CASE(MINT_ICALL_PP_V)
+               MINT_IN_CASE(MINT_ICALL_PI_V)
+               MINT_IN_CASE(MINT_ICALL_PP_P)
+               MINT_IN_CASE(MINT_ICALL_PI_P)
+               MINT_IN_CASE(MINT_ICALL_PPP_V)
+               MINT_IN_CASE(MINT_ICALL_PPI_V)
+                       sp = do_icall (context, *ip, sp, rtm->data_items [*(guint16 *)(ip + 1)]);
+                       if (frame->ex != NULL)
+                               goto handle_exception;
+                       ip += 2;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_MONO_LDPTR) 
+                       sp->data.p = rtm->data_items [*(guint16 *)(ip + 1)];
+                       ip += 2;
+                       ++sp;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_MONO_NEWOBJ)
+                       sp->data.p = mono_object_new_checked (context->domain, rtm->data_items [*(guint16 *)(ip + 1)], &error);
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       ip += 2;
+                       sp++;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_MONO_FREE)
+                       ++ip;
+                       --sp;
+                       g_error ("that doesn't seem right");
+                       g_free (sp->data.p);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_MONO_RETOBJ)
+                       ++ip;
+                       sp--;
+                       stackval_from_data (mono_method_signature (frame->runtime_method->method)->ret, frame->retval, sp->data.p,
+                            mono_method_signature (frame->runtime_method->method)->pinvoke);
+                       if (sp > frame->stack)
+                               g_warning ("retobj: more values on stack: %d", sp-frame->stack);
+                       goto exit_frame;
+
+#define RELOP(datamem, op) \
+       --sp; \
+       sp [-1].data.i = sp [-1].data.datamem op sp [0].data.datamem; \
+       ++ip;
+               MINT_IN_CASE(MINT_CEQ_I4)
+                       RELOP(i, ==);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CEQ0_I4)
+                       sp [-1].data.i = (sp [-1].data.i == 0);
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CEQ_I8)
+                       RELOP(l, ==);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CEQ_R8)
+                       --sp; 
+                       if (isunordered (sp [-1].data.f, sp [0].data.f))
+                               sp [-1].data.i = 0;
+                       else
+                               sp [-1].data.i = sp [-1].data.f == sp [0].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CGT_I4)
+                       RELOP(i, >);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CGT_I8)
+                       RELOP(l, >);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CGT_R8)
+                       --sp; 
+                       if (isunordered (sp [-1].data.f, sp [0].data.f))
+                               sp [-1].data.i = 0;
+                       else
+                               sp [-1].data.i = sp [-1].data.f > sp [0].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+
+#define RELOP_CAST(datamem, op, type) \
+       --sp; \
+       sp [-1].data.i = (type)sp [-1].data.datamem op (type)sp [0].data.datamem; \
+       ++ip;
+
+               MINT_IN_CASE(MINT_CGT_UN_I4)
+                       RELOP_CAST(i, >, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CGT_UN_I8)
+                       RELOP_CAST(l, >, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CGT_UN_R8)
+                       --sp; 
+                       if (isunordered (sp [-1].data.f, sp [0].data.f))
+                               sp [-1].data.i = 1;
+                       else
+                               sp [-1].data.i = sp [-1].data.f > sp [0].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CLT_I4)
+                       RELOP(i, <);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CLT_I8)
+                       RELOP(l, <);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CLT_R8)
+                       --sp; 
+                       if (isunordered (sp [-1].data.f, sp [0].data.f))
+                               sp [-1].data.i = 0;
+                       else
+                               sp [-1].data.i = sp [-1].data.f < sp [0].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CLT_UN_I4)
+                       RELOP_CAST(i, <, guint32);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CLT_UN_I8)
+                       RELOP_CAST(l, <, guint64);
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CLT_UN_R8)
+                       --sp; 
+                       if (isunordered (sp [-1].data.f, sp [0].data.f))
+                               sp [-1].data.i = 1;
+                       else
+                               sp [-1].data.i = sp [-1].data.f < sp [0].data.f;
+                       ++ip;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDFTN) {
+                       sp->data.p = rtm->data_items [* (guint16 *)(ip + 1)];
+                       ++sp;
+                       ip += 2;
+                       MINT_IN_BREAK;
+               }
+               MINT_IN_CASE(MINT_LDVIRTFTN) {
+                       RuntimeMethod *m = rtm->data_items [* (guint16 *)(ip + 1)];
+                       ip += 2;
+                       --sp;
+                       if (!sp->data.p)
+                               THROW_EX (mono_get_exception_null_reference (), ip - 2);
+                               
+                       sp->data.p = get_virtual_method (context->domain, m, sp->data.p);
+                       ++sp;
+                       MINT_IN_BREAK;
+               }
+
+               MINT_IN_CASE(MINT_LDTHISA)
+                       g_error ("should not happen");
+                       // sp->data.p = &frame->obj;
+                       ++ip;
+                       ++sp; 
+                       MINT_IN_BREAK;
+
+#define LDARG(datamem, argtype) \
+       sp->data.datamem = * (argtype *)(frame->args + * (guint16 *)(ip + 1)); \
+       ip += 2; \
+       ++sp; 
+       
+               MINT_IN_CASE(MINT_LDARG_I1) LDARG(i, gint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDARG_U1) LDARG(i, guint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDARG_I2) LDARG(i, gint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDARG_U2) LDARG(i, guint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDARG_I4) LDARG(i, gint32); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDARG_I8) LDARG(l, gint64); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDARG_R4) LDARG(f, float); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDARG_R8) LDARG(f, double); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDARG_O) LDARG(p, gpointer); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDARG_P) LDARG(p, gpointer); MINT_IN_BREAK;
+
+               MINT_IN_CASE(MINT_LDARG_VT)
+                       sp->data.p = vt_sp;
+                       i32 = READ32(ip + 2);
+                       memcpy(sp->data.p, frame->args + * (guint16 *)(ip + 1), i32);
+                       vt_sp += (i32 + 7) & ~7;
+                       ip += 4;
+                       ++sp;
+                       MINT_IN_BREAK;
+
+#define STARG(datamem, argtype) \
+       --sp; \
+       * (argtype *)(frame->args + * (guint16 *)(ip + 1)) = sp->data.datamem; \
+       ip += 2; \
+       
+               MINT_IN_CASE(MINT_STARG_I1) STARG(i, gint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STARG_U1) STARG(i, guint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STARG_I2) STARG(i, gint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STARG_U2) STARG(i, guint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STARG_I4) STARG(i, gint32); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STARG_I8) STARG(l, gint64); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STARG_R4) STARG(f, float); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STARG_R8) STARG(f, double); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STARG_O) STARG(p, gpointer); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STARG_P) STARG(p, gpointer); MINT_IN_BREAK;
+
+               MINT_IN_CASE(MINT_STARG_VT) 
+                       i32 = READ32(ip + 2);
+                       --sp;
+                       memcpy(frame->args + * (guint16 *)(ip + 1), sp->data.p, i32);
+                       vt_sp -= (i32 + 7) & ~7;
+                       ip += 4;
+                       MINT_IN_BREAK;
+
+#define STINARG(datamem, argtype) \
+       do { \
+               int n = * (guint16 *)(ip + 1); \
+               * (argtype *)(frame->args + rtm->arg_offsets [n]) = frame->stack_args [n].data.datamem; \
+               ip += 2; \
+       } while (0)
+       
+               MINT_IN_CASE(MINT_STINARG_I1) STINARG(i, gint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STINARG_U1) STINARG(i, guint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STINARG_I2) STINARG(i, gint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STINARG_U2) STINARG(i, guint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STINARG_I4) STINARG(i, gint32); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STINARG_I8) STINARG(l, gint64); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STINARG_R4) STINARG(f, float); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STINARG_R8) STINARG(f, double); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STINARG_O) STINARG(p, gpointer); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STINARG_P) STINARG(p, gpointer); MINT_IN_BREAK;
+
+               MINT_IN_CASE(MINT_STINARG_VT) {
+                       int n = * (guint16 *)(ip + 1);
+                       i32 = READ32(ip + 2);
+                       memcpy (frame->args + rtm->arg_offsets [n], frame->stack_args [n].data.p, i32);
+                       ip += 4;
+                       MINT_IN_BREAK;
+               }
+
+               MINT_IN_CASE(MINT_LDARGA)
+                       sp->data.p = frame->args + * (guint16 *)(ip + 1);
+                       ip += 2;
+                       ++sp;
+                       MINT_IN_BREAK;
+
+#define LDLOC(datamem, argtype) \
+       sp->data.datamem = * (argtype *)(locals + * (guint16 *)(ip + 1)); \
+       ip += 2; \
+       ++sp; 
+       
+               MINT_IN_CASE(MINT_LDLOC_I1) LDLOC(i, gint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDLOC_U1) LDLOC(i, guint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDLOC_I2) LDLOC(i, gint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDLOC_U2) LDLOC(i, guint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDLOC_I4) LDLOC(i, gint32); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDLOC_I8) LDLOC(l, gint64); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDLOC_R4) LDLOC(f, float); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDLOC_R8) LDLOC(f, double); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDLOC_O) LDLOC(p, gpointer); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_LDLOC_P) LDLOC(p, gpointer); MINT_IN_BREAK;
+
+               MINT_IN_CASE(MINT_LDLOC_VT)
+                       sp->data.p = vt_sp;
+                       i32 = READ32(ip + 2);
+                       memcpy(sp->data.p, locals + * (guint16 *)(ip + 1), i32);
+                       vt_sp += (i32 + 7) & ~7;
+                       ip += 4;
+                       ++sp;
+                       MINT_IN_BREAK;
+
+               MINT_IN_CASE(MINT_LDLOCA_S)
+                       sp->data.p = locals + * (guint16 *)(ip + 1);
+                       ip += 2;
+                       ++sp;
+                       MINT_IN_BREAK;
+
+#define STLOC(datamem, argtype) \
+       --sp; \
+       * (argtype *)(locals + * (guint16 *)(ip + 1)) = sp->data.datamem; \
+       ip += 2;
+       
+               MINT_IN_CASE(MINT_STLOC_I1) STLOC(i, gint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STLOC_U1) STLOC(i, guint8); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STLOC_I2) STLOC(i, gint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STLOC_U2) STLOC(i, guint16); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STLOC_I4) STLOC(i, gint32); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STLOC_I8) STLOC(l, gint64); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STLOC_R4) STLOC(f, float); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STLOC_R8) STLOC(f, double); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STLOC_O) STLOC(p, gpointer); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STLOC_P) STLOC(p, gpointer); MINT_IN_BREAK;
+
+#define STLOC_NP(datamem, argtype) \
+       * (argtype *)(locals + * (guint16 *)(ip + 1)) = sp [-1].data.datamem; \
+       ip += 2;
+
+               MINT_IN_CASE(MINT_STLOC_NP_I4) STLOC_NP(i, gint32); MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_STLOC_NP_O) STLOC_NP(p, gpointer); MINT_IN_BREAK;
+
+               MINT_IN_CASE(MINT_STLOC_VT)
+                       i32 = READ32(ip + 2);
+                       --sp;
+                       memcpy(locals + * (guint16 *)(ip + 1), sp->data.p, i32);
+                       vt_sp -= (i32 + 7) & ~7;
+                       ip += 4;
+                       MINT_IN_BREAK;
+
+               MINT_IN_CASE(MINT_LOCALLOC)
+                       if (sp != frame->stack + 1) /*FIX?*/
+                               THROW_EX (mono_get_exception_execution_engine (NULL), ip);
+                       sp [-1].data.p = alloca (sp [-1].data.i);
+                       ++ip;
+                       MINT_IN_BREAK;
+#if 0
+               MINT_IN_CASE(MINT_ENDFILTER) ves_abort(); MINT_IN_BREAK;
+#endif
+               MINT_IN_CASE(MINT_INITOBJ)
+                       --sp;
+                       memset (sp->data.vt, 0, READ32(ip + 1));
+                       ip += 3;
+                       MINT_IN_BREAK;
+               MINT_IN_CASE(MINT_CPBLK)
+                       sp -= 3;
+                       if (!sp [0].data.p || !sp [1].data.p)
+                               THROW_EX (mono_get_exception_null_reference(), ip - 1);
+                       ++ip;
+                       /* FIXME: value and size may be int64... */
+                       memcpy (sp [0].data.p, sp [1].data.p, sp [2].data.i);
+                       MINT_IN_BREAK;
+#if 0
+               MINT_IN_CASE(MINT_CONSTRAINED_) {
+                       guint32 token;
+                       /* FIXME: implement */
+                       ++ip;
+                       token = READ32 (ip);
+                       ip += 2;
+                       MINT_IN_BREAK;
+               }
+#endif
+               MINT_IN_CASE(MINT_INITBLK)
+                       sp -= 3;
+                       if (!sp [0].data.p)
+                               THROW_EX (mono_get_exception_null_reference(), ip - 1);
+                       ++ip;
+                       /* FIXME: value and size may be int64... */
+                       memset (sp [0].data.p, sp [1].data.i, sp [2].data.i);
+                       MINT_IN_BREAK;
+#if 0
+               MINT_IN_CASE(MINT_NO_)
+                       /* FIXME: implement */
+                       ip += 2;
+                       MINT_IN_BREAK;
+#endif
+               MINT_IN_CASE(MINT_RETHROW)
+                       /* 
+                        * need to clarify what this should actually do:
+                        * start the search from the last found handler in
+                        * this method or continue in the caller or what.
+                        * Also, do we need to run finally/fault handlers after a retrow?
+                        * Well, this implementation will follow the usual search
+                        * for an handler, considering the current ip as throw spot.
+                        * We need to NULL frame->ex_handler for the later code to
+                        * actually run the new found handler.
+                        */
+                       frame->ex_handler = NULL;
+                       THROW_EX (frame->ex, ip - 1);
+                       MINT_IN_BREAK;
+               MINT_IN_DEFAULT
+                       g_print ("Unimplemented opcode: %04x %s at 0x%x\n", *ip, mono_interp_opname[*ip], ip-rtm->code);
+                       THROW_EX (mono_get_exception_execution_engine ("Unimplemented opcode"), ip);
+               }
+       }
+
+       g_assert_not_reached ();
+       /*
+        * Exception handling code.
+        * The exception object is stored in frame->ex.
+        */
+
+       handle_exception:
+       {
+               int i;
+               guint32 ip_offset;
+               MonoInvocation *inv;
+               MonoExceptionClause *clause;
+               /*char *message;*/
+               MonoObject *ex_obj;
+
+#if DEBUG_INTERP
+               if (tracing)
+                       g_print ("* Handling exception '%s' at IL_%04x\n", 
+                               frame->ex == NULL ? "** Unknown **" : mono_object_class (frame->ex)->name, 
+                               rtm == NULL ? 0 : frame->ip - rtm->code);
+#endif
+               if (die_on_exception)
+                       goto die_on_ex;
+
+               for (inv = frame; inv; inv = inv->parent) {
+                       MonoMethod *method;
+                       if (inv->runtime_method == NULL)
+                               continue;
+                       method = inv->runtime_method->method;
+                       if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
+                               continue;
+                       if (method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME))
+                               continue;
+                       if (inv->ip == NULL)
+                               continue;
+                       ip_offset = inv->ip - inv->runtime_method->code;
+                       inv->ex_handler = NULL; /* clear this in case we are trhowing an exception while handling one  - this one wins */
+                       for (i = 0; i < inv->runtime_method->num_clauses; ++i) {
+                               clause = &inv->runtime_method->clauses [i];
+                               if (clause->flags <= 1 && MONO_OFFSET_IN_CLAUSE (clause, ip_offset)) {
+                                       if (!clause->flags) {
+                                               MonoObject *isinst_obj = mono_object_isinst_checked ((MonoObject*)frame->ex, clause->data.catch_class, &error);
+                                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                                               if (isinst_obj) {
+                                                       /* 
+                                                        * OK, we found an handler, now we need to execute the finally
+                                                        * and fault blocks before branching to the handler code.
+                                                        */
+                                                       inv->ex_handler = clause;
+#if DEBUG_INTERP
+                                                       if (tracing)
+                                                               g_print ("* Found handler at '%s'\n", method->name);
+#endif
+                                                       goto handle_finally;
+                                               }
+                                       } else {
+                                               /* FIXME: handle filter clauses */
+                                               g_assert (0);
+                                       }
+                               }
+                       }
+               }
+               /*
+                * If we get here, no handler was found: print a stack trace.
+                */
+               for (inv = frame; inv; inv = inv->parent) {
+                       if (inv->invoke_trap)
+                               goto handle_finally;
+               }
+die_on_ex:
+               ex_obj = (MonoObject*)frame->ex;
+               mono_unhandled_exception (ex_obj);
+               exit (1);
+       }
+       handle_finally:
+       {
+               int i;
+               guint32 ip_offset;
+               MonoExceptionClause *clause;
+               GSList *old_list = finally_ips;
+               MonoMethod *method = frame->runtime_method->method;
+               MonoMethodHeader *header = mono_method_get_header_checked (method, &error);
+               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+               
+#if DEBUG_INTERP
+               if (tracing)
+                       g_print ("* Handle finally IL_%04x\n", endfinally_ip == NULL ? 0 : endfinally_ip - rtm->code);
+#endif
+               if (rtm == NULL || (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) 
+                               || (method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME))) {
+                       goto exit_frame;
+               }
+               ip_offset = frame->ip - rtm->code;
+
+               if (endfinally_ip != NULL)
+                       finally_ips = g_slist_prepend(finally_ips, (void *)endfinally_ip);
+               for (i = 0; i < header->num_clauses; ++i)
+                       if (frame->ex_handler == &rtm->clauses [i])
+                               break;
+               while (i > 0) {
+                       --i;
+                       clause = &rtm->clauses [i];
+                       if (MONO_OFFSET_IN_CLAUSE (clause, ip_offset) && (endfinally_ip == NULL || !(MONO_OFFSET_IN_CLAUSE (clause, endfinally_ip - rtm->code)))) {
+                               if (clause->flags == MONO_EXCEPTION_CLAUSE_FINALLY) {
+                                       ip = rtm->code + clause->handler_offset;
+                                       finally_ips = g_slist_prepend (finally_ips, (gpointer) ip);
+#if DEBUG_INTERP
+                                       if (tracing)
+                                               g_print ("* Found finally at IL_%04x with exception: %s\n", clause->handler_offset, frame->ex? "yes": "no");
+#endif
+                               }
+                       }
+               }
+
+               endfinally_ip = NULL;
+
+               if (old_list != finally_ips && finally_ips) {
+                       ip = finally_ips->data;
+                       finally_ips = g_slist_remove (finally_ips, ip);
+                       sp = frame->stack; /* spec says stack should be empty at endfinally so it should be at the start too */
+                       goto main_loop;
+               }
+
+               /*
+                * If an exception is set, we need to execute the fault handler, too,
+                * otherwise, we continue normally.
+                */
+               if (frame->ex)
+                       goto handle_fault;
+               ves_abort();
+       }
+       handle_fault:
+       {
+               int i;
+               guint32 ip_offset;
+               MonoExceptionClause *clause;
+               MonoMethod *method = frame->runtime_method->method;
+               MonoMethodHeader *header = mono_method_get_header_checked (method, &error);
+               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+               
+#if DEBUG_INTERP
+               if (tracing)
+                       g_print ("* Handle fault\n");
+#endif
+               ip_offset = frame->ip - rtm->code;
+               for (i = 0; i < header->num_clauses; ++i) {
+                       clause = &rtm->clauses [i];
+                       if (clause->flags == MONO_EXCEPTION_CLAUSE_FAULT && MONO_OFFSET_IN_CLAUSE (clause, ip_offset)) {
+                               ip = rtm->code + clause->handler_offset;
+#if DEBUG_INTERP
+                               if (tracing)
+                                       g_print ("* Executing handler at IL_%04x\n", clause->handler_offset);
+#endif
+                               goto main_loop;
+                       }
+               }
+               /*
+                * If the handler for the exception was found in this method, we jump
+                * to it right away, otherwise we return and let the caller run
+                * the finally, fault and catch blocks.
+                * This same code should be present in the endfault opcode, but it
+                * is corrently not assigned in the ECMA specs: LAMESPEC.
+                */
+               if (frame->ex_handler) {
+#if DEBUG_INTERP
+                       if (tracing)
+                               g_print ("* Executing handler at IL_%04x\n", frame->ex_handler->handler_offset);
+#endif
+                       ip = rtm->code + frame->ex_handler->handler_offset;
+                       sp = frame->stack;
+                       vt_sp = (unsigned char *) sp + rtm->stack_size;
+                       sp->data.p = frame->ex;
+                       ++sp;
+                       goto main_loop;
+               }
+               goto exit_frame;
+       }
+exit_frame:
+       DEBUG_LEAVE ();
+}
+
+void
+ves_exec_method (MonoInvocation *frame)
+{
+       ThreadContext *context = mono_native_tls_get_value (thread_context_id);
+       ThreadContext context_struct;
+       MonoError error;
+       jmp_buf env;
+
+       frame->ex = NULL;
+
+       if (setjmp(env)) {
+               mono_unhandled_exception ((MonoObject*)frame->ex);
+               return;
+       }
+       if (context == NULL) {
+               context = &context_struct;
+               context_struct.domain = mono_domain_get ();
+               context_struct.base_frame = frame;
+               context_struct.current_frame = NULL;
+               context_struct.env_frame = frame;
+               context_struct.current_env = &env;
+               context_struct.search_for_handler = 0;
+               context_struct.managed_code = 0;
+               mono_native_tls_set_value (thread_context_id, context);
+       }
+       frame->ip = NULL;
+       frame->parent = context->current_frame;
+       frame->runtime_method = mono_interp_get_runtime_method (context->domain, frame->method, &error);
+       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+       context->managed_code = 1;
+       ves_exec_method_with_context (frame, context);
+       context->managed_code = 0;
+       if (frame->ex) {
+               if (context != &context_struct && context->current_env) {
+                       context->env_frame->ex = frame->ex;
+                       longjmp (*context->current_env, 1);
+               }
+               else
+                       mono_unhandled_exception ((MonoObject*)frame->ex);
+       }
+       if (context->base_frame == frame)
+               mono_native_tls_set_value (thread_context_id, NULL);
+       else
+               context->current_frame = frame->parent;
+}
+
+static int 
+ves_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[])
+{
+       MonoImage *image = mono_assembly_get_image (assembly);
+       MonoMethod *method;
+       MonoError error;
+       int rval;
+
+       method = mono_get_method_checked (image, mono_image_get_entry_point (image), NULL, NULL, &error);
+       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+
+       if (!method)
+               g_error ("No entry point method found in %s", mono_image_get_filename (image));
+
+       rval = mono_runtime_run_main_checked (method, argc, argv, &error);
+       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+       return rval;
+}
+
+static void
+usage (void)
+{
+       fprintf (stderr,
+                "mint %s, the Mono ECMA CLI interpreter, (C) 2001, 2002 Ximian, Inc.\n\n"
+                "Usage is: mint [options] executable args...\n\n", VERSION);
+       fprintf (stderr,
+                "Runtime Debugging:\n"
+#ifdef DEBUG_INTERP
+                "   --debug\n"
+#endif
+                "   --dieonex\n"
+                "   --noptr\t\t\tdon't print pointer addresses in trace output\n"
+                "   --opcode-count\n"
+                "   --print-vtable\n"
+                "   --traceclassinit\n"
+                "\n"
+                "Development:\n"
+                "   --debug method_name\n"
+                "   --profile\n"
+                "   --trace\n"
+                "   --traceops\n"
+                "   --regression\n"
+                "\n"
+                "Runtime:\n"
+                "   --config filename  load the specified config file instead of the default\n"
+                "   --workers n        maximum number of worker threads\n"
+               );
+       exit (1);
+}
+
+static MonoBoolean
+interp_ves_icall_get_frame_info (gint32 skip, MonoBoolean need_file_info, 
+                         MonoReflectionMethod **method, 
+                         gint32 *iloffset, gint32 *native_offset,
+                         MonoString **file, gint32 *line, gint32 *column)
+{
+       ThreadContext *context = mono_native_tls_get_value (thread_context_id);
+       MonoInvocation *inv = context->current_frame;
+       MonoError error;
+       int i;
+
+       for (i = 0; inv && i < skip; inv = inv->parent)
+               if (inv->runtime_method != NULL)
+                       ++i;
+
+       if (iloffset)
+               *iloffset = 0;
+       if (native_offset)
+               *native_offset = 0;
+       if (method) {
+               if (inv == NULL) {
+                       *method = NULL;
+               } else {
+                       *method = mono_method_get_object_checked (context->domain, inv->runtime_method->method, NULL, &error);
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+               }
+       }
+       if (line)
+               *line = 0;
+       if (need_file_info) {
+               if (column)
+                       *column = 0;
+               if (file)
+                       *file = mono_string_new (mono_domain_get (), "unknown");
+       }
+
+       return TRUE;
+}
+
+static MonoArray *
+interp_ves_icall_get_trace (MonoException *exc, gint32 skip, MonoBoolean need_file_info)
+{
+       MonoDomain *domain = mono_domain_get ();
+       MonoArray *res;
+       MonoArray *ta = exc->trace_ips;
+       MonoError error;
+       int i, len;
+
+       if (ta == NULL) {
+               /* Exception is not thrown yet */
+               MonoArray *array = mono_array_new_checked (domain, mono_defaults.stack_frame_class, 0, &error);
+               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+               return array;
+       }
+       
+       len = mono_array_length (ta);
+
+       res = mono_array_new_checked (domain, mono_defaults.stack_frame_class, len > skip ? len - skip : 0, &error);
+       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+
+       for (i = skip; i < len / 2; i++) {
+               MonoStackFrame *sf = (MonoStackFrame *)mono_object_new_checked (domain, mono_defaults.stack_frame_class, &error);
+               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+               gushort *ip = mono_array_get (ta, gpointer, 2 * i + 1);
+               RuntimeMethod *rtm = mono_array_get (ta, gpointer, 2 * i);
+
+               if (rtm != NULL) {
+                       sf->method = mono_method_get_object_checked (domain, rtm->method, NULL, &error);
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       sf->native_offset = ip - rtm->code;
+               }
+
+#if 0
+               sf->il_offset = mono_debug_il_offset_from_address (ji->method, sf->native_offset, domain);
+
+               if (need_file_info) {
+                       gchar *filename;
+                       
+                       filename = mono_debug_source_location_from_address (ji->method, sf->native_offset, &sf->line, domain);
+
+                       sf->filename = filename? mono_string_new (domain, filename): NULL;
+                       sf->column = 0;
+
+                       g_free (filename);
+               }
+#endif
+
+               mono_array_set (res, gpointer, i, sf);
+       }
+
+       return res;
+}
+
+void
+mono_interp_init ()
+{
+       mono_native_tls_alloc (&thread_context_id, NULL);
+    mono_native_tls_set_value (thread_context_id, NULL);
+       mono_os_mutex_init_recursive (&runtime_method_lookup_section);
+       mono_os_mutex_init_recursive (&create_method_pointer_mutex);
+
+       mono_interp_transform_init ();
+}
+
+typedef int (*TestMethod) (void);
+
+static void
+interp_regression_step (MonoImage *image, int verbose, int *total_run, int *total, GTimer *timer, MonoDomain *domain)
+{
+       int result, expected, failed, cfailed, run;
+       double elapsed, transform_time;
+       int i;
+       MonoObject *result_obj;
+       static gboolean filter_method_init = FALSE;
+       static const char *filter_method = NULL;
+
+       g_print ("Test run: image=%s\n", mono_image_get_filename (image));
+       cfailed = failed = run = 0;
+       transform_time = elapsed = 0.0;
+
+#if 0
+       /* fixme: ugly hack - delete all previously compiled methods */
+       if (domain_jit_info (domain)) {
+               g_hash_table_destroy (domain_jit_info (domain)->jit_trampoline_hash);
+               domain_jit_info (domain)->jit_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
+               mono_internal_hash_table_destroy (&(domain->jit_code_hash));
+               mono_jit_code_hash_init (&(domain->jit_code_hash));
+       }
+#endif
+
+       g_timer_start (timer);
+       for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
+               MonoObject *exc = NULL;
+               MonoError error;
+               MonoMethod *method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, &error);
+               if (!method) {
+                       mono_error_cleanup (&error); /* FIXME don't swallow the error */
+                       continue;
+               }
+
+               if (!filter_method_init) {
+                       filter_method = g_getenv ("INTERP_FILTER_METHOD");
+                       filter_method_init = TRUE;
+               }
+               gboolean filter = FALSE;
+               if (filter_method) {
+                       const char *name = filter_method;
+
+                       if ((strchr (name, '.') > name) || strchr (name, ':')) {
+                               MonoMethodDesc *desc = mono_method_desc_new (name, TRUE);
+                               filter = mono_method_desc_full_match (desc, method);
+                               mono_method_desc_free (desc);
+                       } else {
+                               filter = strcmp (method->name, name) == 0;
+                       }
+               } else { /* no filter, check for `Category' attribute on method */
+                       filter = TRUE;
+                       MonoCustomAttrInfo* ainfo = mono_custom_attrs_from_method_checked (method, &error);
+                       mono_error_cleanup (&error);
+
+                       if (ainfo) {
+                               int j;
+                               for (j = 0; j < ainfo->num_attrs && filter; ++j) {
+                                       MonoCustomAttrEntry *centry = &ainfo->attrs [j];
+                                       if (centry->ctor == NULL)
+                                               continue;
+
+                                       MonoClass *klass = centry->ctor->klass;
+                                       if (strcmp (klass->name, "CategoryAttribute"))
+                                               continue;
+
+                                       MonoObject *obj = mono_custom_attrs_get_attr_checked (ainfo, klass, &error);
+                                       /* FIXME: there is an ordering problem if there're multiple attributes, do this instead:
+                                        * MonoObject *obj = create_custom_attr (ainfo->image, centry->ctor, centry->data, centry->data_size, &error); */
+                                       mono_error_cleanup (&error);
+                                       MonoMethod *getter = mono_class_get_method_from_name (klass, "get_Category", -1);
+                                       MonoObject *str = mono_interp_runtime_invoke (getter, obj, NULL, &exc, &error);
+                                       mono_error_cleanup (&error);
+                                       char *utf8_str = mono_string_to_utf8_checked ((MonoString *) str, &error);
+                                       mono_error_cleanup (&error);
+                                       if (!strcmp (utf8_str, "!INTERPRETER")) {
+                                               g_print ("skip %s...\n", method->name);
+                                               filter = FALSE;
+                                       }
+                               }
+                       }
+               }
+               if (strncmp (method->name, "test_", 5) == 0 && filter) {
+                       MonoError interp_error;
+                       MonoObject *exc = NULL;
+
+                       result_obj = mono_interp_runtime_invoke (method, NULL, NULL, &exc, &interp_error);
+                       if (!mono_error_ok (&interp_error)) {
+                               cfailed++;
+                               g_print ("Test '%s' execution failed.\n", method->name);
+                       } else if (exc != NULL) {
+                               g_print ("Exception in Test '%s' occured:\n", method->name);
+                               mono_object_describe (exc);
+                               run++;
+                               failed++;
+                       } else {
+                               result = *(gint32 *) mono_object_unbox (result_obj);
+                               expected = atoi (method->name + 5);  // FIXME: oh no.
+                               run++;
+
+                               if (result != expected) {
+                                       failed++;
+                                       g_print ("Test '%s' failed result (got %d, expected %d).\n", method->name, result, expected);
+                               }
+                       }
+               }
+       }
+       g_timer_stop (timer);
+       elapsed = g_timer_elapsed (timer, NULL);
+       if (failed > 0 || cfailed > 0){
+               g_print ("Results: total tests: %d, failed: %d, cfailed: %d (pass: %.2f%%)\n",
+                               run, failed, cfailed, 100.0*(run-failed-cfailed)/run);
+       } else {
+               g_print ("Results: total tests: %d, all pass \n",  run);
+       }
+
+       g_print ("Elapsed time: %f secs (%f, %f)\n\n", elapsed,
+                       elapsed - transform_time, transform_time);
+       *total += failed + cfailed;
+       *total_run += run;
+}
+static int
+interp_regression (MonoImage *image, int verbose, int *total_run)
+{
+       MonoMethod *method;
+       GTimer *timer = g_timer_new ();
+       MonoDomain *domain = mono_domain_get ();
+       guint32 i;
+       int total;
+
+       /* load the metadata */
+       for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
+               MonoError error;
+               method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, &error);
+               if (!method) {
+                       mono_error_cleanup (&error);
+                       continue;
+               }
+               mono_class_init (method->klass);
+       }
+
+       total = 0;
+       *total_run = 0;
+       interp_regression_step (image, verbose, total_run, &total, timer, domain);
+
+       g_timer_destroy (timer);
+       return total;
+}
+
+int
+mono_interp_regression_list (int verbose, int count, char *images [])
+{
+       int i, total, total_run, run;
+       
+       total_run = total = 0;
+       for (i = 0; i < count; ++i) {
+               MonoAssembly *ass = mono_assembly_open (images [i], NULL);
+               if (!ass) {
+                       g_warning ("failed to load assembly: %s", images [i]);
+                       continue;
+               }
+               total += interp_regression (mono_assembly_get_image (ass), verbose, &run);
+               total_run += run;
+       }
+       if (total > 0) {
+               g_print ("Overall results: tests: %d, failed: %d (pass: %.2f%%)\n", total_run, total, 100.0*(total_run-total)/total_run);
+       } else {
+               g_print ("Overall results: tests: %d, 100%% pass\n", total_run);
+       }
+       
+       return total;
+}
+
diff --git a/mono/mini/interp/interp.h b/mono/mini/interp/interp.h
new file mode 100644 (file)
index 0000000..59428a8
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef __MONO_MINI_INTERPRETER_H__
+#define __MONO_MINI_INTERPRETER_H__
+#include <mono/mini/mini.h>
+
+int
+mono_interp_regression_list (int verbose, int count, char *images []);
+
+void
+mono_interp_init (void);
+
+gpointer
+mono_interp_create_method_pointer (MonoMethod *method, MonoError *error);
+
+MonoObject*
+mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error);
+
+void
+mono_interp_init_delegate (MonoDelegate *del);
+
+void
+interp_walk_stack_with_ctx (MonoInternalStackWalk func, MonoContext *ctx, MonoUnwindOptions options, void *user_data);
+#endif /* __MONO_MINI_INTERPRETER_H__ */
diff --git a/mono/mini/interp/mintops.c b/mono/mini/interp/mintops.c
new file mode 100644 (file)
index 0000000..5b4d692
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Utilities for handling interpreter VM instructions
+ *
+ * Authors:
+ *   Bernie Solomon (bernard@ugsolutions.com)
+ *
+ */
+#include <glib.h>
+#include <stdio.h>
+#include "mintops.h"
+
+#define OPDEF(a,b,c,d) \
+       b,
+const char *mono_interp_opname[] = {
+#include "mintops.def"
+       ""
+};
+#undef OPDEF
+
+#define OPDEF(a,b,c,d) \
+       c,
+unsigned char mono_interp_oplen[] = {
+#include "mintops.def"
+       0
+};
+#undef OPDEF
+
+
+#define OPDEF(a,b,c,d) \
+       d,
+MintOpArgType mono_interp_opargtype[] = {
+#include "mintops.def"
+       0
+};
+#undef OPDEF
+
+const guint16 *
+mono_interp_dis_mintop(const guint16 *base, const guint16 *ip)
+{
+       int len = mono_interp_oplen [*ip];
+       guint32 token;
+       int target;
+       if (len < 0 || len > 10) {
+               g_print ("op %d len %d\n", *ip, len);
+               g_assert_not_reached ();
+       } else if (len == 0) { /* SWITCH */
+               int n = READ32 (ip + 1);
+               len = 3 + n * 2;
+       }
+
+       g_print ("IL_%04x: %-10s", ip - base, mono_interp_opname [*ip]);
+       switch (mono_interp_opargtype [*ip]) {
+       case MintOpNoArgs:
+               break;
+       case MintOpUShortInt:
+               g_print (" %u", * (guint16 *)(ip + 1));
+               break;
+       case MintOpTwoShorts:
+               g_print (" %u,%u", * (guint16 *)(ip + 1), * (guint16 *)(ip + 2));
+               break;
+       case MintOpShortAndInt:
+               g_print (" %u,%u", * (guint16 *)(ip + 1), (guint32)READ32(ip + 2));
+               break;
+       case MintOpShortInt:
+               g_print (" %d", * (short *)(ip + 1));
+               break;
+       case MintOpClassToken:
+       case MintOpMethodToken:
+       case MintOpFieldToken:
+               token = * (guint16 *)(ip + 1);
+               g_print (" %u", token);
+               break;
+       case MintOpInt:
+               g_print (" %d", (gint32)READ32 (ip + 1));
+               break;
+       case MintOpLongInt:
+               g_print (" %lld", (gint64)READ64 (ip + 1));
+               break;
+       case MintOpFloat: {
+               gint32 tmp = READ32 (ip + 1);
+               g_print (" %g", * (float *)&tmp);
+               break;
+       }
+       case MintOpDouble: {
+               gint64 tmp = READ64 (ip + 1);
+               g_print (" %g", * (double *)&tmp);
+               break;
+       }
+       case MintOpShortBranch:
+               target = ip + * (short *)(ip + 1) - base;
+               g_print (" IL_%04x", target);
+               break;
+       case MintOpBranch:
+               target = ip + (gint32)READ32 (ip + 1) - base;
+               g_print (" IL_%04x", target);
+               break;
+       case MintOpSwitch: {
+               const guint16 *p = ip + 1;
+               int sval = (gint32)READ32 (p);
+               int i;
+               p += 2;
+               g_print ("(");
+               for (i = 0; i < sval; ++i) {
+                       int offset;
+                       if (i > 0)
+                               g_print (", ");
+                       offset = (gint32)READ32 (p);
+                       g_print ("IL_%04x", ip - base + 3 + 2 * sval + offset);
+                       p += 2;
+               }
+               g_print (")");
+               break;
+       }
+       default:
+               g_print("unknown arg type\n");
+       }
+
+       return ip + len;
+}
+
diff --git a/mono/mini/interp/mintops.def b/mono/mini/interp/mintops.def
new file mode 100644 (file)
index 0000000..54c5422
--- /dev/null
@@ -0,0 +1,506 @@
+/*
+ * Definitions of VM instructions executed by interp.c
+ *
+ * Authors:
+ *   Bernie Solomon (bernard@ugsolutions.com)
+ *
+ */
+
+/* OPDEF (opsymbol, opstring, oplength, optype) */
+
+OPDEF(MINT_NOP, "nop", 1, MintOpNoArgs)
+OPDEF(MINT_BREAK, "break", 1, MintOpNoArgs)
+OPDEF(MINT_LDNULL, "ldnull", 1, MintOpNoArgs)
+OPDEF(MINT_DUP, "dup", 1, MintOpNoArgs)
+OPDEF(MINT_DUP_VT, "dup.vt", 3, MintOpInt)
+OPDEF(MINT_POP, "pop", 2, MintOpShortInt)
+
+OPDEF(MINT_RET, "ret", 1, MintOpNoArgs)
+OPDEF(MINT_RET_VOID, "ret.void", 1, MintOpNoArgs)
+OPDEF(MINT_RET_VT, "ret.vt", 3, MintOpInt)
+
+OPDEF(MINT_VTRESULT, "vtresult", 4, MintOpShortAndInt) /*FIX should be unsigned*/
+
+OPDEF(MINT_LDC_I4_M1, "ldc.i4.m1", 1, MintOpNoArgs)
+OPDEF(MINT_LDC_I4_0, "ldc.i4.0", 1, MintOpNoArgs)
+OPDEF(MINT_LDC_I4_1, "ldc.i4.1", 1, MintOpNoArgs)
+OPDEF(MINT_LDC_I4_2, "ldc.i4.2", 1, MintOpNoArgs)
+OPDEF(MINT_LDC_I4_3, "ldc.i4.3", 1, MintOpNoArgs)
+OPDEF(MINT_LDC_I4_4, "ldc.i4.4", 1, MintOpNoArgs)
+OPDEF(MINT_LDC_I4_5, "ldc.i4.5", 1, MintOpNoArgs)
+OPDEF(MINT_LDC_I4_6, "ldc.i4.6", 1, MintOpNoArgs)
+OPDEF(MINT_LDC_I4_7, "ldc.i4.7", 1, MintOpNoArgs)
+OPDEF(MINT_LDC_I4_8, "ldc.i4.8", 1, MintOpNoArgs)
+
+OPDEF(MINT_LDC_I4_S, "ldc.i4.s", 2, MintOpShortInt)
+OPDEF(MINT_LDC_I4, "ldc.i4", 3, MintOpInt)
+OPDEF(MINT_LDC_I8, "ldc.i8", 5, MintOpLongInt)
+
+OPDEF(MINT_LDC_R4, "ldc.r4", 3, MintOpFloat)
+OPDEF(MINT_LDC_R8, "ldc.r8", 5, MintOpDouble)
+
+OPDEF(MINT_LDARG_I1, "ldarg.i1", 2, MintOpUShortInt)
+OPDEF(MINT_LDARG_U1, "ldarg.u1", 2, MintOpUShortInt)
+OPDEF(MINT_LDARG_I2, "ldarg.i2", 2, MintOpUShortInt)
+OPDEF(MINT_LDARG_U2, "ldarg.u2", 2, MintOpUShortInt)
+OPDEF(MINT_LDARG_I4, "ldarg.i4", 2, MintOpUShortInt)
+OPDEF(MINT_LDARG_I8, "ldarg.i8", 2, MintOpUShortInt)
+OPDEF(MINT_LDARG_R4, "ldarg.r4", 2, MintOpUShortInt)
+OPDEF(MINT_LDARG_R8, "ldarg.r8", 2, MintOpUShortInt)
+OPDEF(MINT_LDARG_O, "ldarg.o", 2, MintOpUShortInt)
+OPDEF(MINT_LDARG_P, "ldarg.p", 2, MintOpUShortInt)
+OPDEF(MINT_LDARG_VT, "ldarg.vt", 4, MintOpShortAndInt)
+
+OPDEF(MINT_STARG_I1, "starg.i1", 2, MintOpUShortInt)
+OPDEF(MINT_STARG_U1, "starg.u1", 2, MintOpUShortInt)
+OPDEF(MINT_STARG_I2, "starg.i2", 2, MintOpUShortInt)
+OPDEF(MINT_STARG_U2, "starg.u2", 2, MintOpUShortInt)
+OPDEF(MINT_STARG_I4, "starg.i4", 2, MintOpUShortInt)
+OPDEF(MINT_STARG_I8, "starg.i8", 2, MintOpUShortInt)
+OPDEF(MINT_STARG_R4, "starg.r4", 2, MintOpUShortInt)
+OPDEF(MINT_STARG_R8, "starg.r8", 2, MintOpUShortInt)
+OPDEF(MINT_STARG_O, "starg.o", 2, MintOpUShortInt)
+OPDEF(MINT_STARG_P, "starg.p", 2, MintOpUShortInt)
+OPDEF(MINT_STARG_VT, "starg.vt", 4, MintOpShortAndInt)
+
+OPDEF(MINT_STINARG_I1, "stinarg.i1", 2, MintOpUShortInt)
+OPDEF(MINT_STINARG_U1, "stinarg.u1", 2, MintOpUShortInt)
+OPDEF(MINT_STINARG_I2, "stinarg.i2", 2, MintOpUShortInt)
+OPDEF(MINT_STINARG_U2, "stinarg.u2", 2, MintOpUShortInt)
+OPDEF(MINT_STINARG_I4, "stinarg.i4", 2, MintOpUShortInt)
+OPDEF(MINT_STINARG_I8, "stinarg.i8", 2, MintOpUShortInt)
+OPDEF(MINT_STINARG_R4, "stinarg.r4", 2, MintOpUShortInt)
+OPDEF(MINT_STINARG_R8, "stinarg.r8", 2, MintOpUShortInt)
+OPDEF(MINT_STINARG_O, "stinarg.o", 2, MintOpUShortInt)
+OPDEF(MINT_STINARG_P, "stinarg.p", 2, MintOpUShortInt)
+OPDEF(MINT_STINARG_VT, "stinarg.vt", 4, MintOpShortAndInt)
+
+OPDEF(MINT_LDARGA, "ldarga", 2, MintOpUShortInt)
+OPDEF(MINT_LDTHISA, "ldthisa", 1, MintOpNoArgs)
+
+OPDEF(MINT_LDFLD_I1, "ldfld.i1", 2, MintOpUShortInt)
+OPDEF(MINT_LDFLD_U1, "ldfld.u1", 2, MintOpUShortInt)
+OPDEF(MINT_LDFLD_I2, "ldfld.i2", 2, MintOpUShortInt)
+OPDEF(MINT_LDFLD_U2, "ldfld.u2", 2, MintOpUShortInt)
+OPDEF(MINT_LDFLD_I4, "ldfld.i4", 2, MintOpUShortInt)
+OPDEF(MINT_LDFLD_I8, "ldfld.i8", 2, MintOpUShortInt)
+OPDEF(MINT_LDFLD_R4, "ldfld.r4", 2, MintOpUShortInt)
+OPDEF(MINT_LDFLD_R8, "ldfld.r8", 2, MintOpUShortInt)
+OPDEF(MINT_LDFLD_O, "ldfld.o", 2, MintOpUShortInt)
+OPDEF(MINT_LDFLD_P, "ldfld.p", 2, MintOpUShortInt)
+OPDEF(MINT_LDFLD_VT, "ldfld.vt", 4, MintOpShortAndInt)
+
+OPDEF(MINT_LDRMFLD, "ldrmfld", 2, MintOpFieldToken)
+OPDEF(MINT_LDRMFLD_VT, "ldrmfld.vt", 4, MintOpShortAndInt)
+
+OPDEF(MINT_LDFLDA, "ldflda", 2, MintOpUShortInt)
+
+OPDEF(MINT_STFLD_I1, "stfld.i1", 2, MintOpUShortInt)
+OPDEF(MINT_STFLD_U1, "stfld.u1", 2, MintOpUShortInt)
+OPDEF(MINT_STFLD_I2, "stfld.i2", 2, MintOpUShortInt)
+OPDEF(MINT_STFLD_U2, "stfld.u2", 2, MintOpUShortInt)
+OPDEF(MINT_STFLD_I4, "stfld.i4", 2, MintOpUShortInt)
+OPDEF(MINT_STFLD_I8, "stfld.i8", 2, MintOpUShortInt)
+OPDEF(MINT_STFLD_R4, "stfld.r4", 2, MintOpUShortInt)
+OPDEF(MINT_STFLD_R8, "stfld.r8", 2, MintOpUShortInt)
+OPDEF(MINT_STFLD_O, "stfld.o", 2, MintOpUShortInt)
+OPDEF(MINT_STFLD_P, "stfld.p", 2, MintOpUShortInt)
+OPDEF(MINT_STFLD_VT, "stfld.vt", 4, MintOpShortAndInt)
+
+OPDEF(MINT_STRMFLD, "strmfld", 2, MintOpFieldToken)
+OPDEF(MINT_STRMFLD_VT, "strmfld.vt", 4, MintOpShortAndInt)
+
+OPDEF(MINT_LDSFLD, "ldsfld", 2, MintOpFieldToken)
+OPDEF(MINT_LDSFLD_VT, "ldsfld.vt", 4, MintOpShortAndInt)
+OPDEF(MINT_STSFLD, "stsfld", 2, MintOpUShortInt)
+OPDEF(MINT_STSFLD_VT, "stsfld.vt", 4, MintOpShortAndInt)
+OPDEF(MINT_LDSFLDA, "ldsflda", 2, MintOpUShortInt)
+
+OPDEF(MINT_LDLOC_I1, "ldloc.i1", 2, MintOpUShortInt)
+OPDEF(MINT_LDLOC_U1, "ldloc.u1", 2, MintOpUShortInt)
+OPDEF(MINT_LDLOC_I2, "ldloc.i2", 2, MintOpUShortInt)
+OPDEF(MINT_LDLOC_U2, "ldloc.u2", 2, MintOpUShortInt)
+OPDEF(MINT_LDLOC_I4, "ldloc.i4", 2, MintOpUShortInt)
+OPDEF(MINT_LDLOC_I8, "ldloc.i8", 2, MintOpUShortInt)
+OPDEF(MINT_LDLOC_R4, "ldloc.r4", 2, MintOpUShortInt)
+OPDEF(MINT_LDLOC_R8, "ldloc.r8", 2, MintOpUShortInt)
+OPDEF(MINT_LDLOC_O, "ldloc.o", 2, MintOpUShortInt)
+OPDEF(MINT_LDLOC_P, "ldloc.p", 2, MintOpUShortInt)
+OPDEF(MINT_LDLOC_VT, "ldloc.vt", 4, MintOpShortAndInt)
+
+OPDEF(MINT_STLOC_I1, "stloc.i1", 2, MintOpUShortInt)
+OPDEF(MINT_STLOC_U1, "stloc.u1", 2, MintOpUShortInt)
+OPDEF(MINT_STLOC_I2, "stloc.i2", 2, MintOpUShortInt)
+OPDEF(MINT_STLOC_U2, "stloc.u2", 2, MintOpUShortInt)
+OPDEF(MINT_STLOC_I4, "stloc.i4", 2, MintOpUShortInt)
+OPDEF(MINT_STLOC_I8, "stloc.i8", 2, MintOpUShortInt)
+OPDEF(MINT_STLOC_R4, "stloc.r4", 2, MintOpUShortInt)
+OPDEF(MINT_STLOC_R8, "stloc.r8", 2, MintOpUShortInt)
+OPDEF(MINT_STLOC_O, "stloc.o", 2, MintOpUShortInt)
+OPDEF(MINT_STLOC_P, "stloc.p", 2, MintOpUShortInt)
+OPDEF(MINT_STLOC_VT, "stloc.vt", 4, MintOpShortAndInt)
+
+OPDEF(MINT_STLOC_NP_I4, "stloc.np.i4", 2, MintOpUShortInt)
+OPDEF(MINT_STLOC_NP_O, "stloc.np.o", 2, MintOpUShortInt)
+
+OPDEF(MINT_LDLOCA_S, "ldloca.s", 2, MintOpUShortInt)
+
+OPDEF(MINT_LDIND_I1, "ldind.i1", 1, MintOpNoArgs)
+OPDEF(MINT_LDIND_U1, "ldind.u1", 1, MintOpNoArgs)
+OPDEF(MINT_LDIND_I2, "ldind.i2", 1, MintOpNoArgs)
+OPDEF(MINT_LDIND_U2, "ldind.u2", 1, MintOpNoArgs)
+OPDEF(MINT_LDIND_I4, "ldind.i4", 1, MintOpNoArgs)
+OPDEF(MINT_LDIND_U4, "ldind.u4", 1, MintOpNoArgs)
+OPDEF(MINT_LDIND_I8, "ldind.i8", 1, MintOpNoArgs)
+OPDEF(MINT_LDIND_I, "ldind.i", 2, MintOpUShortInt)
+OPDEF(MINT_LDIND_R4, "ldind.r4", 1, MintOpNoArgs)
+OPDEF(MINT_LDIND_R8, "ldind.r8", 1, MintOpNoArgs)
+OPDEF(MINT_LDIND_REF, "ldind.ref", 1, MintOpNoArgs)
+OPDEF(MINT_STIND_I1, "stind.i1", 1, MintOpNoArgs)
+OPDEF(MINT_STIND_I2, "stind.i2", 1, MintOpNoArgs)
+OPDEF(MINT_STIND_I4, "stind.i4", 1, MintOpNoArgs)
+OPDEF(MINT_STIND_I8, "stind.i8", 1, MintOpNoArgs)
+OPDEF(MINT_STIND_I, "stind.i", 1, MintOpNoArgs)
+OPDEF(MINT_STIND_R4, "stind.r4", 1, MintOpNoArgs)
+OPDEF(MINT_STIND_R8, "stind.r8", 1, MintOpNoArgs)
+OPDEF(MINT_STIND_REF, "stind.ref", 1, MintOpNoArgs)
+
+OPDEF(MINT_BR, "br", 3, MintOpBranch)
+OPDEF(MINT_LEAVE, "leave", 3, MintOpBranch)
+OPDEF(MINT_BR_S, "br.s", 2, MintOpShortBranch)
+OPDEF(MINT_LEAVE_S, "leave.s", 2, MintOpShortBranch)
+
+OPDEF(MINT_THROW, "throw", 1, MintOpNoArgs)
+OPDEF(MINT_RETHROW, "rethrow", 1, MintOpNoArgs)
+OPDEF(MINT_ENDFINALLY, "endfinally", 1, MintOpNoArgs)
+
+OPDEF(MINT_BRFALSE_I4, "brfalse.i4", 3, MintOpBranch)
+OPDEF(MINT_BRFALSE_I8, "brfalse.i8", 3, MintOpBranch)
+OPDEF(MINT_BRFALSE_R8, "brfalse.r8", 3, MintOpBranch)
+OPDEF(MINT_BRTRUE_I4, "brtrue.i4", 3, MintOpBranch)
+OPDEF(MINT_BRTRUE_I8, "brtrue.i8", 3, MintOpBranch)
+OPDEF(MINT_BRTRUE_R8, "brtrue.r8", 3, MintOpBranch)
+
+OPDEF(MINT_BRFALSE_I4_S, "brfalse.i4.s", 2, MintOpShortBranch)
+OPDEF(MINT_BRFALSE_I8_S, "brfalse.i8.s", 2, MintOpShortBranch)
+OPDEF(MINT_BRFALSE_R8_S, "brfalse.r8.s", 2, MintOpShortBranch)
+OPDEF(MINT_BRTRUE_I4_S, "brtrue.i4.s", 2, MintOpShortBranch)
+OPDEF(MINT_BRTRUE_I8_S, "brtrue.i8.s", 2, MintOpShortBranch)
+OPDEF(MINT_BRTRUE_R8_S, "brtrue.r8.s", 2, MintOpShortBranch)
+
+OPDEF(MINT_BEQ_I4, "beq.i4", 3, MintOpBranch)
+OPDEF(MINT_BEQ_I8, "beq.i8", 3, MintOpBranch)
+OPDEF(MINT_BEQ_R8, "beq.r8", 3, MintOpBranch)
+OPDEF(MINT_BGE_I4, "bge.i4", 3, MintOpBranch) 
+OPDEF(MINT_BGE_I8, "bge.i8", 3, MintOpBranch) 
+OPDEF(MINT_BGE_R8, "bge.r8", 3, MintOpBranch) 
+OPDEF(MINT_BGT_I4, "bgt.i4", 3, MintOpBranch) 
+OPDEF(MINT_BGT_I8, "bgt.i8", 3, MintOpBranch) 
+OPDEF(MINT_BGT_R8, "bgt.r8", 3, MintOpBranch) 
+OPDEF(MINT_BLT_I4, "blt.i4", 3, MintOpBranch) 
+OPDEF(MINT_BLT_I8, "blt.i8", 3, MintOpBranch) 
+OPDEF(MINT_BLT_R8, "blt.r8", 3, MintOpBranch) 
+OPDEF(MINT_BLE_I4, "ble.i4", 3, MintOpBranch) 
+OPDEF(MINT_BLE_I8, "ble.i8", 3, MintOpBranch) 
+OPDEF(MINT_BLE_R8, "ble.r8", 3, MintOpBranch) 
+
+OPDEF(MINT_BNE_UN_I4, "bne.un.i4", 3, MintOpBranch)
+OPDEF(MINT_BNE_UN_I8, "bne.un.i8", 3, MintOpBranch)
+OPDEF(MINT_BNE_UN_R8, "bne.un.r8", 3, MintOpBranch)
+OPDEF(MINT_BGE_UN_I4, "bge.un.i4", 3, MintOpBranch) 
+OPDEF(MINT_BGE_UN_I8, "bge.un.i8", 3, MintOpBranch) 
+OPDEF(MINT_BGE_UN_R8, "bge.un.r8", 3, MintOpBranch) 
+OPDEF(MINT_BGT_UN_I4, "bgt.un.i4", 3, MintOpBranch) 
+OPDEF(MINT_BGT_UN_I8, "bgt.un.i8", 3, MintOpBranch) 
+OPDEF(MINT_BGT_UN_R8, "bgt.un.r8", 3, MintOpBranch) 
+OPDEF(MINT_BLE_UN_I4, "ble.un.i4", 3, MintOpBranch) 
+OPDEF(MINT_BLE_UN_I8, "ble.un.i8", 3, MintOpBranch) 
+OPDEF(MINT_BLE_UN_R8, "ble.un.r8", 3, MintOpBranch) 
+OPDEF(MINT_BLT_UN_I4, "blt.un.i4", 3, MintOpBranch) 
+OPDEF(MINT_BLT_UN_I8, "blt.un.i8", 3, MintOpBranch) 
+OPDEF(MINT_BLT_UN_R8, "blt.un.r8", 3, MintOpBranch) 
+
+OPDEF(MINT_BEQ_I4_S, "beq.i4.s", 2, MintOpShortBranch)
+OPDEF(MINT_BEQ_I8_S, "beq.i8.s", 2, MintOpShortBranch)
+OPDEF(MINT_BEQ_R8_S, "beq.r8.s", 2, MintOpShortBranch)
+OPDEF(MINT_BGE_I4_S, "bge.i4.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BGE_I8_S, "bge.i8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BGE_R8_S, "bge.r8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BGT_I4_S, "bgt.i4.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BGT_I8_S, "bgt.i8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BGT_R8_S, "bgt.r8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BLT_I4_S, "blt.i4.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BLT_I8_S, "blt.i8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BLT_R8_S, "blt.r8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BLE_I4_S, "ble.i4.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BLE_I8_S, "ble.i8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BLE_R8_S, "ble.r8.s", 2, MintOpShortBranch) 
+
+OPDEF(MINT_BNE_UN_I4_S, "bne.un.i4.s", 2, MintOpShortBranch)
+OPDEF(MINT_BNE_UN_I8_S, "bne.un.i8.s", 2, MintOpShortBranch)
+OPDEF(MINT_BNE_UN_R8_S, "bne.un.r8.s", 2, MintOpShortBranch)
+OPDEF(MINT_BGE_UN_I4_S, "bge.un.i4.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BGE_UN_I8_S, "bge.un.i8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BGE_UN_R8_S, "bge.un.r8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BGT_UN_I4_S, "bgt.un.i4.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BGT_UN_I8_S, "bgt.un.i8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BGT_UN_R8_S, "bgt.un.r8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BLE_UN_I4_S, "ble.un.i4.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BLE_UN_I8_S, "ble.un.i8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BLE_UN_R8_S, "ble.un.r8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BLT_UN_I4_S, "blt.un.i4.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BLT_UN_I8_S, "blt.un.i8.s", 2, MintOpShortBranch) 
+OPDEF(MINT_BLT_UN_R8_S, "blt.un.r8.s", 2, MintOpShortBranch) 
+
+OPDEF(MINT_SWITCH, "switch", 0, MintOpSwitch)
+
+OPDEF(MINT_LDSTR, "ldstr", 2, MintOpMethodToken) /* not really */
+
+OPDEF(MINT_CALL, "call", 2, MintOpMethodToken) 
+OPDEF(MINT_VCALL, "vcall", 2, MintOpMethodToken) 
+OPDEF(MINT_CALLVIRT, "callvirt", 2, MintOpMethodToken) 
+OPDEF(MINT_VCALLVIRT, "vcallvirt", 2, MintOpMethodToken) 
+OPDEF(MINT_CALLI, "calli", 2, MintOpMethodToken) 
+OPDEF(MINT_CALLI_NAT, "calli.nat", 2, MintOpMethodToken) 
+OPDEF(MINT_JMP, "jmp", 2, MintOpMethodToken) 
+
+OPDEF(MINT_CALLRUN, "callrun", 1, MintOpNoArgs)
+
+OPDEF(MINT_NEWOBJ, "newobj", 2, MintOpMethodToken) 
+OPDEF(MINT_INITOBJ, "initobj", 3, MintOpInt) 
+OPDEF(MINT_CASTCLASS, "castclass", 2, MintOpClassToken) 
+OPDEF(MINT_ISINST, "isinst", 2, MintOpClassToken) 
+OPDEF(MINT_NEWARR, "newarr", 2, MintOpClassToken) 
+OPDEF(MINT_BOX, "box", 3, MintOpTwoShorts)
+OPDEF(MINT_UNBOX, "unbox", 2, MintOpClassToken) 
+OPDEF(MINT_LDTOKEN, "ldtoken", 2, MintOpClassToken) /* not really */
+OPDEF(MINT_LDFTN, "ldftn", 2, MintOpMethodToken) 
+OPDEF(MINT_LDVIRTFTN, "ldvirtftn", 2, MintOpMethodToken) 
+OPDEF(MINT_LDOBJ, "ldobj", 2, MintOpClassToken) 
+OPDEF(MINT_STOBJ, "stobj", 2, MintOpClassToken) 
+OPDEF(MINT_STOBJ_VT, "stobj.vt", 2, MintOpClassToken) 
+OPDEF(MINT_CPBLK, "cpblk", 1, MintOpNoArgs) 
+OPDEF(MINT_INITBLK, "initblk", 1, MintOpNoArgs) 
+OPDEF(MINT_LOCALLOC, "localloc", 1, MintOpNoArgs) 
+OPDEF(MINT_INITLOCALS, "initlocals", 1, MintOpNoArgs) 
+
+OPDEF(MINT_LDELEM_I, "ldelem.i", 1, MintOpNoArgs)
+OPDEF(MINT_LDELEM_I1, "ldelem.i1", 1, MintOpNoArgs)
+OPDEF(MINT_LDELEM_U1, "ldelem.u1", 1, MintOpNoArgs)
+OPDEF(MINT_LDELEM_I2, "ldelem.i2", 1, MintOpNoArgs)
+OPDEF(MINT_LDELEM_U2, "ldelem.u2", 1, MintOpNoArgs)
+OPDEF(MINT_LDELEM_I4, "ldelem.i4", 1, MintOpNoArgs)
+OPDEF(MINT_LDELEM_U4, "ldelem.u4", 1, MintOpNoArgs)
+OPDEF(MINT_LDELEM_I8, "ldelem.i8", 1, MintOpNoArgs)
+OPDEF(MINT_LDELEM_R4, "ldelem.r4", 1, MintOpNoArgs)
+OPDEF(MINT_LDELEM_R8, "ldelem.r8", 1, MintOpNoArgs)
+OPDEF(MINT_LDELEM_REF, "ldelem.ref", 1, MintOpNoArgs)
+OPDEF(MINT_LDELEM_VT, "ldelem.vt", 4, MintOpShortAndInt)
+
+OPDEF(MINT_LDELEMA, "ldelema", 2, MintOpClassToken)
+
+OPDEF(MINT_STELEM_I, "stelem.i", 1, MintOpNoArgs)
+OPDEF(MINT_STELEM_I1, "stelem.i1", 1, MintOpNoArgs)
+OPDEF(MINT_STELEM_I2, "stelem.i2", 1, MintOpNoArgs)
+OPDEF(MINT_STELEM_I4, "stelem.i4", 1, MintOpNoArgs)
+OPDEF(MINT_STELEM_I8, "stelem.i8", 1, MintOpNoArgs)
+OPDEF(MINT_STELEM_R4, "stelem.r4", 1, MintOpNoArgs)
+OPDEF(MINT_STELEM_R8, "stelem.r8", 1, MintOpNoArgs)
+OPDEF(MINT_STELEM_REF, "stelem.ref", 1, MintOpNoArgs)
+OPDEF(MINT_STELEM_VT, "stelem.vt", 4, MintOpShortAndInt)
+
+OPDEF(MINT_LDLEN, "ldlen", 1, MintOpNoArgs)
+
+OPDEF(MINT_ADD_I4, "add.i4", 1, MintOpNoArgs)
+OPDEF(MINT_ADD_I8, "add.i8", 1, MintOpNoArgs)
+OPDEF(MINT_ADD_R8, "add.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_ADD1_I4, "add1.i4", 1, MintOpNoArgs)
+
+OPDEF(MINT_SUB_I4, "sub.i4", 1, MintOpNoArgs)
+OPDEF(MINT_SUB_I8, "sub.i8", 1, MintOpNoArgs)
+OPDEF(MINT_SUB_R8, "sub.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_SUB1_I4, "sub1.i4", 1, MintOpNoArgs)
+
+OPDEF(MINT_MUL_I4, "mul.i4", 1, MintOpNoArgs)
+OPDEF(MINT_MUL_I8, "mul.i8", 1, MintOpNoArgs)
+OPDEF(MINT_MUL_R8, "mul.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_DIV_I4, "div.i4", 1, MintOpNoArgs)
+OPDEF(MINT_DIV_I8, "div.i8", 1, MintOpNoArgs)
+OPDEF(MINT_DIV_R8, "div.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_DIV_UN_I4, "div.un.i4", 1, MintOpNoArgs)
+OPDEF(MINT_DIV_UN_I8, "div.un.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_ADD_OVF_I4, "add.ovf.i4", 1, MintOpNoArgs)
+OPDEF(MINT_ADD_OVF_I8, "add.ovf.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_ADD_OVF_UN_I4, "add.ovf.un.i4", 1, MintOpNoArgs)
+OPDEF(MINT_ADD_OVF_UN_I8, "add.ovf.un.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_MUL_OVF_I4, "mul.ovf.i4", 1, MintOpNoArgs)
+OPDEF(MINT_MUL_OVF_I8, "mul.ovf.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_MUL_OVF_UN_I4, "mul.ovf.un.i4", 1, MintOpNoArgs)
+OPDEF(MINT_MUL_OVF_UN_I8, "mul.ovf.un.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_SUB_OVF_I4, "sub.ovf.i4", 1, MintOpNoArgs)
+OPDEF(MINT_SUB_OVF_I8, "sub.ovf.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_SUB_OVF_UN_I4, "sub.ovf.un.i4", 1, MintOpNoArgs)
+OPDEF(MINT_SUB_OVF_UN_I8, "sub.ovf.un.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_NEG_I4, "neg.i4", 1, MintOpNoArgs)
+OPDEF(MINT_NEG_I8, "neg.i8", 1, MintOpNoArgs)
+OPDEF(MINT_NEG_R8, "neg.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_NOT_I4, "not.i4", 1, MintOpNoArgs)
+OPDEF(MINT_NOT_I8, "not.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_AND_I4, "and.i4", 1, MintOpNoArgs)
+OPDEF(MINT_AND_I8, "and.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_OR_I4, "or.i4", 1, MintOpNoArgs)
+OPDEF(MINT_OR_I8, "or.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_XOR_I4, "xor.i4", 1, MintOpNoArgs)
+OPDEF(MINT_XOR_I8, "xor.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_REM_I4, "rem.i4", 1, MintOpNoArgs)
+OPDEF(MINT_REM_I8, "rem.i8", 1, MintOpNoArgs)
+OPDEF(MINT_REM_R8, "rem.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_REM_UN_I4, "rem.un.i4", 1, MintOpNoArgs)
+OPDEF(MINT_REM_UN_I8, "rem.un.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_SHR_UN_I4, "shr.un.i4", 1, MintOpNoArgs)
+OPDEF(MINT_SHR_UN_I8, "shr.un.i8", 1, MintOpNoArgs)
+OPDEF(MINT_SHL_I4, "shl.i4", 1, MintOpNoArgs)
+OPDEF(MINT_SHL_I8, "shl.i8", 1, MintOpNoArgs)
+OPDEF(MINT_SHR_I4, "shr.i4", 1, MintOpNoArgs)
+OPDEF(MINT_SHR_I8, "shr.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_R_UN_I4, "conv.r.un.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_R_UN_I8, "conv.r.un.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_I1_I4, "conv.i1.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_I1_I8, "conv.i1.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_I1_R8, "conv.i1.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_U1_I4, "conv.u1.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_U1_I8, "conv.u1.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_U1_R8, "conv.u1.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_I2_I4, "conv.i2.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_I2_I8, "conv.i2.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_I2_R8, "conv.i2.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_U2_I4, "conv.u2.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_U2_I8, "conv.u2.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_U2_R8, "conv.u2.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_I4_I8, "conv.i4.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_I4_R8, "conv.i4.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_U4_I8, "conv.u4.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_U4_R8, "conv.u4.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_I8_I4, "conv.i8.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_I8_U4, "conv.i8.u4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_I8_R8, "conv.i8.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_R4_I4, "conv.r4.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_R4_I8, "conv.r4.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_R4_R8, "conv.r4.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_R8_I4, "conv.r8.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_R8_I8, "conv.r8.i8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_I4_I8_SP, "conv.i4.i8.sp", 1, MintOpNoArgs) /* special for narrowing sp[-2] on 64 bits */
+OPDEF(MINT_CONV_I8_I4_SP, "conv.i8.i4.sp", 1, MintOpNoArgs) /* special for widening sp[-2] on 64 bits */
+
+OPDEF(MINT_CONV_U8_I4, "conv.u8.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_U8_R8, "conv.u8.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_OVF_I1_I4, "conv.ovf.i1.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_I1_I8, "conv.ovf.i1.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_I1_R8, "conv.ovf.i1.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_OVF_U1_I4, "conv.ovf.u1.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_U1_I8, "conv.ovf.u1.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_U1_R8, "conv.ovf.u1.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_OVF_I2_I4, "conv.ovf.i2.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_I2_I8, "conv.ovf.i2.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_I2_R8, "conv.ovf.i2.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_OVF_U2_I4, "conv.ovf.u2.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_U2_I8, "conv.ovf.u2.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_U2_R8, "conv.ovf.u2.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_OVF_I4_U4, "conv.ovf.i4.u4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_I4_I8, "conv.ovf.i4.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_I4_R8, "conv.ovf.i4.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_OVF_I4_UN_I8, "conv.ovf.i4.un.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_I4_UN_R8, "conv.ovf.i4.un.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_OVF_U4_I4, "conv.ovf.u4.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_U4_I8, "conv.ovf.u4.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_U4_R8, "conv.ovf.u4.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_OVF_I8_R8, "conv.ovf.i8.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_OVF_I8_UN_R8, "conv.ovf.i8.un.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CONV_OVF_U8_I4, "conv.ovf.u8.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CONV_OVF_U8_R8, "conv.ovf.u8.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CEQ_I4, "ceq.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CEQ_I8, "ceq.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CEQ_R8, "ceq.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CEQ0_I4, "ceq0.i4", 1, MintOpNoArgs)
+
+OPDEF(MINT_CGT_I4, "cgt.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CGT_I8, "cgt.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CGT_R8, "cgt.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CGT_UN_I4, "cgt.un.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CGT_UN_I8, "cgt.un.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CGT_UN_R8, "cgt.un.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CLT_I4, "clt.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CLT_I8, "clt.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CLT_R8, "clt.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CLT_UN_I4, "clt.un.i4", 1, MintOpNoArgs)
+OPDEF(MINT_CLT_UN_I8, "clt.un.i8", 1, MintOpNoArgs)
+OPDEF(MINT_CLT_UN_R8, "clt.un.r8", 1, MintOpNoArgs)
+
+OPDEF(MINT_CKFINITE, "ckfinite", 1, MintOpNoArgs)
+
+OPDEF(MINT_CKNULL, "cknull", 1, MintOpNoArgs)
+
+OPDEF(MINT_GETCHR, "getchr", 1, MintOpNoArgs)
+OPDEF(MINT_STRLEN, "strlen", 1, MintOpNoArgs)
+OPDEF(MINT_ARRAY_RANK, "array_rank", 1, MintOpNoArgs)
+
+OPDEF(MINT_ICALL_V_V, "mono_icall_v_v", 2, MintOpClassToken) /* not really */
+OPDEF(MINT_ICALL_V_P, "mono_icall_v_p", 2, MintOpClassToken)
+OPDEF(MINT_ICALL_P_V, "mono_icall_p_v", 2, MintOpClassToken)
+OPDEF(MINT_ICALL_P_P, "mono_icall_p_p", 2, MintOpClassToken)
+OPDEF(MINT_ICALL_PP_V, "mono_icall_pp_v", 2, MintOpClassToken)
+OPDEF(MINT_ICALL_PI_V, "mono_icall_pi_v", 2, MintOpClassToken)
+OPDEF(MINT_ICALL_PP_P, "mono_icall_pp_p", 2, MintOpClassToken)
+OPDEF(MINT_ICALL_PI_P, "mono_icall_pi_p", 2, MintOpClassToken)
+OPDEF(MINT_ICALL_PPP_V, "mono_icall_ppp_v", 2, MintOpClassToken)
+OPDEF(MINT_ICALL_PPI_V, "mono_icall_ppi_v", 2, MintOpClassToken)
+OPDEF(MINT_MONO_LDPTR, "mono_ldptr", 2, MintOpClassToken) 
+OPDEF(MINT_MONO_NEWOBJ, "mono_newobj", 2, MintOpClassToken)
+OPDEF(MINT_MONO_RETOBJ, "mono_retobj", 1, MintOpNoArgs)
+OPDEF(MINT_MONO_FREE, "mono_free", 1, MintOpNoArgs)
+
+
diff --git a/mono/mini/interp/mintops.h b/mono/mini/interp/mintops.h
new file mode 100644 (file)
index 0000000..e787526
--- /dev/null
@@ -0,0 +1,58 @@
+#ifndef __INTERPRETER_MINTOPS_H
+#define __INTERPRETER_MINTOPS_H
+
+#include <glib.h>
+
+typedef enum
+{
+       MintOpNoArgs,
+       MintOpShortInt,
+       MintOpUShortInt,
+       MintOpInt,
+       MintOpLongInt,
+       MintOpFloat,
+       MintOpDouble,
+       MintOpBranch,
+       MintOpShortBranch,
+       MintOpSwitch,
+       MintOpMethodToken,
+       MintOpFieldToken,
+       MintOpClassToken,
+       MintOpTwoShorts,
+       MintOpShortAndInt
+} MintOpArgType;
+
+#define OPDEF(a,b,c,d) \
+       a,
+enum {
+#include "mintops.def"
+       MINT_LASTOP
+};
+#undef OPDEF
+
+#if NO_UNALIGNED_ACCESS
+#  if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define READ32(x) (((guint16 *)(x)) [0] | ((guint16 *)(x)) [1] << 16)
+#define READ64(x) ((guint64)((guint16 *)(x)) [0] | \
+                   (guint64)((guint16 *)(x)) [1] << 16 | \
+                   (guint64)((guint16 *)(x)) [2] << 32 | \
+                   (guint64)((guint16 *)(x)) [3] << 48)
+#  else
+#define READ32(x) (((guint16 *)(x)) [0] << 16 | ((guint16 *)(x)) [1])
+#define READ64(x) ((guint64)((guint16 *)(x)) [0] << 48 | \
+                   (guint64)((guint16 *)(x)) [1] << 32 | \
+                   (guint64)((guint16 *)(x)) [2] << 16 | \
+                   (guint64)((guint16 *)(x)) [3])
+#  endif
+#else /* unaligned access OK */
+#define READ32(x) (*(guint32 *)(x))
+#define READ64(x) (*(guint64 *)(x))
+#endif
+
+extern const char *mono_interp_opname[];
+extern unsigned char mono_interp_oplen[];
+extern MintOpArgType mono_interp_opargtype[];
+extern const guint16 *mono_interp_dis_mintop(const unsigned short *base, const guint16 *ip);
+
+#endif
+
diff --git a/mono/mini/interp/transform.c b/mono/mini/interp/transform.c
new file mode 100644 (file)
index 0000000..e5e2ec9
--- /dev/null
@@ -0,0 +1,3382 @@
+/*
+ * transform CIL into different opcodes for more
+ * efficient interpretation
+ *
+ * Written by Bernie Solomon (bernard@ugsolutions.com)
+ * Copyright (c) 2004.
+ */
+
+#include <string.h>
+#include <mono/metadata/appdomain.h>
+#include <mono/metadata/debug-helpers.h>
+#include <mono/metadata/exception.h>
+#include <mono/metadata/mono-endian.h>
+#include <mono/metadata/marshal.h>
+#include <mono/metadata/profiler-private.h>
+#include <mono/metadata/tabledefs.h>
+
+#include <mono/mini/mini.h>
+
+#include "mintops.h"
+#include "interp-internals.h"
+#include "interp.h"
+
+// TODO: export from marshal.c
+MonoDelegate* mono_ftnptr_to_delegate (MonoClass *klass, gpointer ftn);
+
+#define DEBUG 0
+
+typedef struct
+{
+       MonoClass *klass;
+       unsigned char type;
+       unsigned char flags;
+} StackInfo;
+
+typedef struct
+{
+       MonoMethod *method;
+       MonoMethodHeader *header;
+       RuntimeMethod *rtm;
+       const unsigned char *il_code;
+       const unsigned char *ip;
+       const unsigned char *last_ip;
+       const unsigned char *in_start;
+       int code_size;
+       int *in_offsets;
+       int *forward_refs;
+       StackInfo **stack_state;
+       int *stack_height;
+       int *vt_stack_size;
+       unsigned char *is_bb_start;
+       unsigned short *new_code;
+       unsigned short *new_code_end;
+       unsigned short *new_ip;
+       unsigned short *last_new_ip;
+       unsigned int max_code_size;
+       StackInfo *stack;
+       StackInfo *sp;
+       unsigned int max_stack_height;
+       unsigned int vt_sp;
+       unsigned int max_vt_sp;
+       int n_data_items;
+       int max_data_items;
+       void **data_items;
+       GHashTable *data_hash;
+} TransformData;
+
+#define MINT_TYPE_I1 0
+#define MINT_TYPE_U1 1
+#define MINT_TYPE_I2 2
+#define MINT_TYPE_U2 3
+#define MINT_TYPE_I4 4
+#define MINT_TYPE_I8 5
+#define MINT_TYPE_R4 6
+#define MINT_TYPE_R8 7
+#define MINT_TYPE_O  8
+#define MINT_TYPE_P  9
+#define MINT_TYPE_VT 10
+
+#define STACK_TYPE_I4 0
+#define STACK_TYPE_I8 1
+#define STACK_TYPE_R8 2
+#define STACK_TYPE_O  3
+#define STACK_TYPE_VT 4
+#define STACK_TYPE_MP 5
+#define STACK_TYPE_F  6
+
+static const char *stack_type_string [] = { "I4", "I8", "R8", "O ", "VT", "MP", "F " };
+
+#if SIZEOF_VOID_P == 8
+#define STACK_TYPE_I STACK_TYPE_I8
+#else
+#define STACK_TYPE_I STACK_TYPE_I4
+#endif
+
+static int stack_type [] = {
+       STACK_TYPE_I4, /*I1*/
+       STACK_TYPE_I4, /*U1*/
+       STACK_TYPE_I4, /*I2*/
+       STACK_TYPE_I4, /*U2*/
+       STACK_TYPE_I4, /*I4*/
+       STACK_TYPE_I8, /*I8*/
+       STACK_TYPE_R8, /*R4*/
+       STACK_TYPE_R8, /*R8*/
+       STACK_TYPE_O,  /*O*/
+       STACK_TYPE_MP, /*P*/
+       STACK_TYPE_VT
+};
+
+static void
+grow_code (TransformData *td)
+{
+       unsigned int old_ip_offset = td->new_ip - td->new_code;
+       unsigned int old_last_ip_offset = td->last_new_ip - td->new_code;
+       g_assert (old_ip_offset <= td->max_code_size);
+       td->new_code = g_realloc (td->new_code, (td->max_code_size *= 2) * sizeof (td->new_code [0]));
+       td->new_code_end = td->new_code + td->max_code_size;
+       td->new_ip = td->new_code + old_ip_offset;
+       td->last_new_ip = td->new_code + old_last_ip_offset;
+}
+
+#define ENSURE_CODE(td, n) \
+       do { \
+               if ((td)->new_ip + (n) > (td)->new_code_end) \
+                       grow_code (td); \
+       } while (0)
+
+#define ADD_CODE(td, n) \
+       do { \
+               if ((td)->new_ip == (td)->new_code_end) \
+                       grow_code (td); \
+               *(td)->new_ip++ = (n); \
+       } while (0)
+
+#define CHECK_STACK(td, n) \
+       do { \
+               int stack_size = (td)->sp - (td)->stack; \
+               if (stack_size < (n)) \
+                       g_warning ("%s.%s: not enough values (%d < %d) on stack at %04x", \
+                               (td)->method->klass->name, (td)->method->name, \
+                               stack_size, n, (td)->ip - (td)->il_code); \
+       } while (0)
+
+#define ENSURE_I4(td, sp_off) \
+       do { \
+               if ((td)->sp [-sp_off].type == STACK_TYPE_I8) \
+                       ADD_CODE(td, sp_off == 1 ? MINT_CONV_I4_I8 : MINT_CONV_I4_I8_SP); \
+       } while (0)
+
+static void 
+handle_branch(TransformData *td, int short_op, int long_op, int offset) 
+{
+       int shorten_branch = 0;
+       int target = td->ip + offset - td->il_code;
+       if (target < 0 || target >= td->code_size)
+               g_assert_not_reached ();
+       if (offset > 0 && td->stack_height [target] < 0) {
+               td->stack_height [target] = td->sp - td->stack;
+               if (td->stack_height [target] > 0)
+                       td->stack_state [target] = g_memdup (td->stack, td->stack_height [target] * sizeof (td->stack [0]));
+               td->vt_stack_size [target] = td->vt_sp;
+       }
+       if (offset < 0) {
+               offset = td->in_offsets [target] - (td->new_ip - td->new_code);
+               if (offset >= -32768) {
+                       shorten_branch = 1;
+               }
+       } else {
+               int prev = td->forward_refs [target];
+               td->forward_refs [td->ip - td->il_code] = prev;
+               td->forward_refs [target] = td->ip - td->il_code;
+               offset = 0;
+               if (td->header->code_size <= 25000) /* FIX to be precise somehow? */
+                       shorten_branch = 1;
+       }
+       if (shorten_branch) {
+               ADD_CODE(td, short_op);
+               ADD_CODE(td, offset);
+       } else {
+               ADD_CODE(td, long_op);
+               ADD_CODE(td, * (unsigned short *)(&offset));
+               ADD_CODE(td, * ((unsigned short *)&offset + 1));
+       }
+}
+
+static void 
+one_arg_branch(TransformData *td, int mint_op, int offset) 
+{
+       int type = td->sp [-1].type == STACK_TYPE_O || td->sp [-1].type == STACK_TYPE_MP ? STACK_TYPE_I : td->sp [-1].type;
+       int long_op = mint_op + type - STACK_TYPE_I4;
+       int short_op = long_op + MINT_BRFALSE_I4_S - MINT_BRFALSE_I4;
+       CHECK_STACK(td, 1);
+       --td->sp;
+       handle_branch (td, short_op, long_op, offset);
+}
+
+static void 
+two_arg_branch(TransformData *td, int mint_op, int offset) 
+{
+       int type1 = td->sp [-1].type == STACK_TYPE_O || td->sp [-1].type == STACK_TYPE_MP ? STACK_TYPE_I : td->sp [-1].type;
+       int type2 = td->sp [-2].type == STACK_TYPE_O || td->sp [-2].type == STACK_TYPE_MP ? STACK_TYPE_I : td->sp [-2].type;
+       int long_op = mint_op + type1 - STACK_TYPE_I4;
+       int short_op = long_op + MINT_BEQ_I4_S - MINT_BEQ_I4;
+       CHECK_STACK(td, 2);
+       if (type1 == STACK_TYPE_I4 && type2 == STACK_TYPE_I8) {
+               ADD_CODE(td, MINT_CONV_I8_I4);
+               td->in_offsets [td->ip - td->il_code]++;
+       } else if (type1 == STACK_TYPE_I8 && type2 == STACK_TYPE_I4) {
+               ADD_CODE(td, MINT_CONV_I8_I4_SP);
+               td->in_offsets [td->ip - td->il_code]++;
+       } else if (type1 != type2) {
+               g_warning("%s.%s: branch type mismatch %d %d", 
+                       td->method->klass->name, td->method->name, 
+                       td->sp [-1].type, td->sp [-2].type);
+       }
+       td->sp -= 2;
+       handle_branch (td, short_op, long_op, offset);
+}
+
+static void
+unary_arith_op(TransformData *td, int mint_op)
+{
+       int op = mint_op + td->sp [-1].type - STACK_TYPE_I4;
+       CHECK_STACK(td, 1);
+       ADD_CODE(td, op);
+}
+
+static void
+binary_arith_op(TransformData *td, int mint_op)
+{
+       int type1 = td->sp [-2].type;
+       int type2 = td->sp [-1].type;
+       int op;
+#if SIZEOF_VOID_P == 8
+       if ((type1 == STACK_TYPE_MP || type1 == STACK_TYPE_I8) && type2 == STACK_TYPE_I4) {
+               ADD_CODE(td, MINT_CONV_I8_I4);
+               type2 = STACK_TYPE_I8;
+       }
+       if (type1 == STACK_TYPE_I4 && (type2 == STACK_TYPE_MP || type2 == STACK_TYPE_I8)) {
+               ADD_CODE(td, MINT_CONV_I8_I4_SP);
+               type1 = STACK_TYPE_I8;
+               td->sp [-2].type = STACK_TYPE_I8;
+       }
+#endif
+       if (type1 == STACK_TYPE_MP)
+               type1 = STACK_TYPE_I;
+       if (type2 == STACK_TYPE_MP)
+               type2 = STACK_TYPE_I;
+       if (type1 != type2) {
+               g_warning("%s.%s: %04x arith type mismatch %s %d %d", 
+                       td->method->klass->name, td->method->name, 
+                       td->ip - td->il_code, mono_interp_opname[mint_op], type1, type2);
+       }
+       op = mint_op + type1 - STACK_TYPE_I4;
+       CHECK_STACK(td, 2);
+       ADD_CODE(td, op);
+       --td->sp;
+}
+
+static void
+binary_int_op(TransformData *td, int mint_op)
+{
+       int op = mint_op + td->sp [-1].type - STACK_TYPE_I4;
+       CHECK_STACK(td, 2);
+       if (td->sp [-1].type != td->sp [-2].type)
+               g_warning("%s.%s: int type mismatch", td->method->klass->name, td->method->name);
+       ADD_CODE(td, op);
+       --td->sp;
+}
+
+static void
+shift_op(TransformData *td, int mint_op)
+{
+       int op = mint_op + td->sp [-2].type - STACK_TYPE_I4;
+       CHECK_STACK(td, 2);
+       if (td->sp [-1].type != STACK_TYPE_I4) {
+               g_warning("%s.%s: shift type mismatch %d", 
+                       td->method->klass->name, td->method->name,
+                       td->sp [-2].type);
+       }
+       ADD_CODE(td, op);
+       --td->sp;
+}
+
+static int 
+mint_type(MonoType *type)
+{
+       if (type->byref)
+               return MINT_TYPE_P;
+enum_type:
+       switch (type->type) {
+       case MONO_TYPE_I1:
+               return MINT_TYPE_I1;
+       case MONO_TYPE_U1:
+       case MONO_TYPE_BOOLEAN:
+               return MINT_TYPE_U1;
+       case MONO_TYPE_I2:
+               return MINT_TYPE_I2;
+       case MONO_TYPE_U2:
+       case MONO_TYPE_CHAR:
+               return MINT_TYPE_U2;
+       case MONO_TYPE_I4:
+       case MONO_TYPE_U4:
+               return MINT_TYPE_I4;
+       case MONO_TYPE_I:
+       case MONO_TYPE_U:
+#if SIZEOF_VOID_P == 4
+               return MINT_TYPE_I4;
+#else
+               return MINT_TYPE_I8;
+#endif
+       case MONO_TYPE_PTR:
+               return MINT_TYPE_P;
+       case MONO_TYPE_R4:
+               return MINT_TYPE_R4;
+       case MONO_TYPE_I8:
+       case MONO_TYPE_U8:
+               return MINT_TYPE_I8;
+       case MONO_TYPE_R8:
+               return MINT_TYPE_R8;
+       case MONO_TYPE_STRING:
+       case MONO_TYPE_SZARRAY:
+       case MONO_TYPE_CLASS:
+       case MONO_TYPE_OBJECT:
+       case MONO_TYPE_ARRAY:
+               return MINT_TYPE_O;
+       case MONO_TYPE_VALUETYPE:
+               if (type->data.klass->enumtype) {
+                       type = mono_class_enum_basetype (type->data.klass);
+                       goto enum_type;
+               } else
+                       return MINT_TYPE_VT;
+       case MONO_TYPE_GENERICINST:
+               type = &type->data.generic_class->container_class->byval_arg;
+               goto enum_type;
+       default:
+               g_warning ("got type 0x%02x", type->type);
+               g_assert_not_reached ();
+       }
+       return -1;
+}
+
+static int 
+can_store (int stack_type, int var_type)
+{
+       if (stack_type == STACK_TYPE_O || stack_type == STACK_TYPE_MP)
+               stack_type = STACK_TYPE_I;
+       if (var_type == STACK_TYPE_O || var_type == STACK_TYPE_MP)
+               var_type = STACK_TYPE_I;
+       return stack_type == var_type;
+}
+
+#define SET_SIMPLE_TYPE(s, ty) \
+       do { \
+               (s)->type = (ty); \
+               (s)->flags = 0; \
+               (s)->klass = NULL; \
+       } while (0)
+
+#define SET_TYPE(s, ty, k) \
+       do { \
+               (s)->type = (ty); \
+               (s)->flags = 0; \
+               (s)->klass = k; \
+       } while (0)
+
+#define PUSH_SIMPLE_TYPE(td, ty) \
+       do { \
+               int sp_height; \
+               (td)->sp++; \
+               sp_height = (td)->sp - (td)->stack; \
+               if (sp_height > (td)->max_stack_height) \
+                       (td)->max_stack_height = sp_height; \
+               SET_SIMPLE_TYPE((td)->sp - 1, ty); \
+       } while (0)
+
+#define PUSH_TYPE(td, ty, k) \
+       do { \
+               int sp_height; \
+               (td)->sp++; \
+               sp_height = (td)->sp - (td)->stack; \
+               if (sp_height > (td)->max_stack_height) \
+                       (td)->max_stack_height = sp_height; \
+               SET_TYPE((td)->sp - 1, ty, k); \
+       } while (0)
+
+#define PUSH_VT(td, size) \
+       do { \
+               (td)->vt_sp += ((size) + 7) & ~7; \
+               if ((td)->vt_sp > (td)->max_vt_sp) \
+                       (td)->max_vt_sp = (td)->vt_sp; \
+       } while (0)
+
+#define POP_VT(td, size) \
+       do { \
+               (td)->vt_sp -= ((size) + 7) & ~7; \
+       } while (0)
+
+#if NO_UNALIGNED_ACCESS
+#define WRITE32(td, v) \
+       do { \
+               ENSURE_CODE(td, 2); \
+               * (guint16 *)((td)->new_ip) = * (guint16 *)(v); \
+               * ((guint16 *)((td)->new_ip) + 1) = * ((guint16 *)(v) + 1); \
+               (td)->new_ip += 2; \
+       } while (0)
+
+#define WRITE64(td, v) \
+       do { \
+               ENSURE_CODE(td, 4); \
+               * (guint16 *)((td)->new_ip) = * (guint16 *)(v); \
+               * ((guint16 *)((td)->new_ip) + 1) = * ((guint16 *)(v) + 1); \
+               * ((guint16 *)((td)->new_ip) + 2) = * ((guint16 *)(v) + 2); \
+               * ((guint16 *)((td)->new_ip) + 3) = * ((guint16 *)(v) + 3); \
+               (td)->new_ip += 4; \
+       } while (0)
+#else
+#define WRITE32(td, v) \
+       do { \
+               ENSURE_CODE(td, 2); \
+               * (guint32 *)((td)->new_ip) = * (guint32 *)(v); \
+               (td)->new_ip += 2; \
+       } while (0)
+
+#define WRITE64(td, v) \
+       do { \
+               ENSURE_CODE(td, 4); \
+               * (guint64 *)((td)->new_ip) = * (guint64 *)(v); \
+               (td)->new_ip += 4; \
+       } while (0)
+
+#endif
+
+static void 
+load_arg(TransformData *td, int n)
+{
+       int mt;
+       MonoClass *klass = NULL;
+       MonoType *type;
+
+       gboolean hasthis = mono_method_signature (td->method)->hasthis;
+       if (hasthis && n == 0)
+               type = &td->method->klass->byval_arg;
+       else
+               type = mono_method_signature (td->method)->params [hasthis ? n - 1 : n];
+
+       mt = mint_type (type);
+       if (mt == MINT_TYPE_VT) {
+               gint32 size;
+               klass = mono_class_from_mono_type (type);
+               if (mono_method_signature (td->method)->pinvoke)
+                       size = mono_class_native_size (klass, NULL);
+               else
+                       size = mono_class_value_size (klass, NULL);
+
+               if (hasthis && n == 0) {
+                       mt = MINT_TYPE_P;
+                       ADD_CODE (td, MINT_LDARG_P);
+                       ADD_CODE (td, td->rtm->arg_offsets [n]); /* FIX for large offset */
+                       klass = NULL;
+               } else {
+                       PUSH_VT (td, size);
+                       ADD_CODE (td, MINT_LDARG_VT);
+                       ADD_CODE (td, td->rtm->arg_offsets [n]); /* FIX for large offset */
+                       WRITE32 (td, &size);
+               }
+       } else {
+               if (hasthis && n == 0) {
+                       mt = MINT_TYPE_P;
+                       ADD_CODE (td, MINT_LDARG_P);
+                       ADD_CODE (td, td->rtm->arg_offsets [n]); /* FIX for large offset */
+                       klass = NULL;
+               } else {
+                       ADD_CODE(td, MINT_LDARG_I1 + (mt - MINT_TYPE_I1));
+                       ADD_CODE(td, td->rtm->arg_offsets [n]); /* FIX for large offset */
+                       if (mt == MINT_TYPE_O)
+                               klass = mono_class_from_mono_type (type);
+               }
+       }
+       PUSH_TYPE(td, stack_type[mt], klass);
+}
+
+static void 
+store_arg(TransformData *td, int n)
+{
+       int mt;
+       CHECK_STACK (td, 1);
+       MonoType *type;
+
+       gboolean hasthis = mono_method_signature (td->method)->hasthis;
+       if (hasthis && n == 0)
+               type = &td->method->klass->byval_arg;
+       else
+               type = mono_method_signature (td->method)->params [n - !!hasthis];
+
+       mt = mint_type (type);
+       if (mt == MINT_TYPE_VT) {
+               gint32 size;
+               g_error ("data.klass");
+               if (mono_method_signature (td->method)->pinvoke)
+                       size = mono_class_native_size (type->data.klass, NULL);
+               else
+                       size = mono_class_value_size (type->data.klass, NULL);
+               ADD_CODE(td, MINT_STARG_VT);
+               ADD_CODE(td, n);
+               WRITE32(td, &size);
+               if (td->sp [-1].type == STACK_TYPE_VT)
+                       POP_VT(td, size);
+       } else {
+               ADD_CODE(td, MINT_STARG_I1 + (mt - MINT_TYPE_I1));
+               ADD_CODE(td, td->rtm->arg_offsets [n]);
+       }
+       --td->sp;
+}
+
+static void 
+store_inarg(TransformData *td, int n)
+{
+       MonoType *type;
+       gboolean hasthis = mono_method_signature (td->method)->hasthis;
+       if (hasthis && n == 0)
+               type = &td->method->klass->byval_arg;
+       else
+               type = mono_method_signature (td->method)->params [n - !!hasthis];
+
+       int mt = mint_type (type);
+       if (hasthis && n == 0) {
+               ADD_CODE (td, MINT_STINARG_P);
+               ADD_CODE (td, n);
+               return;
+       }
+       if (mt == MINT_TYPE_VT) {
+               MonoClass *klass = mono_class_from_mono_type (type);
+               gint32 size;
+               if (mono_method_signature (td->method)->pinvoke)
+                       size = mono_class_native_size (klass, NULL);
+               else
+                       size = mono_class_value_size (klass, NULL);
+               ADD_CODE(td, MINT_STINARG_VT);
+               ADD_CODE(td, n);
+               WRITE32(td, &size);
+       } else {
+               ADD_CODE(td, MINT_STINARG_I1 + (mt - MINT_TYPE_I1));
+               ADD_CODE(td, n);
+       }
+}
+
+static void 
+load_local(TransformData *td, int n)
+{
+       MonoType *type = td->header->locals [n];
+       int mt = mint_type (type);
+       int offset = td->rtm->local_offsets [n];
+       MonoClass *klass = NULL;
+       if (mt == MINT_TYPE_VT) {
+               klass = mono_class_from_mono_type (type);
+               gint32 size = mono_class_value_size (klass, NULL);
+               PUSH_VT(td, size);
+               ADD_CODE(td, MINT_LDLOC_VT);
+               ADD_CODE(td, offset); /*FIX for large offset */
+               WRITE32(td, &size);
+       } else {
+               g_assert (mt < MINT_TYPE_VT);
+               if (mt == MINT_TYPE_I4 && !td->is_bb_start [td->in_start - td->il_code] && td->last_new_ip != NULL &&
+                       td->last_new_ip [0] == MINT_STLOC_I4 && td->last_new_ip [1] == offset) {
+                       td->last_new_ip [0] = MINT_STLOC_NP_I4;
+               } else if (mt == MINT_TYPE_O && !td->is_bb_start [td->in_start - td->il_code] && td->last_new_ip != NULL &&
+                       td->last_new_ip [0] == MINT_STLOC_O && td->last_new_ip [1] == offset) {
+                       td->last_new_ip [0] = MINT_STLOC_NP_O;
+               } else {
+                       ADD_CODE(td, MINT_LDLOC_I1 + (mt - MINT_TYPE_I1));
+                       ADD_CODE(td, offset); /*FIX for large offset */
+               }
+               if (mt == MINT_TYPE_O)
+                       klass = mono_class_from_mono_type (type);
+       }
+       PUSH_TYPE(td, stack_type[mt], klass);
+}
+
+static void 
+store_local(TransformData *td, int n)
+{
+       MonoType *type = td->header->locals [n];
+       int mt = mint_type (type);
+       int offset = td->rtm->local_offsets [n];
+       CHECK_STACK (td, 1);
+#if SIZEOF_VOID_P == 8
+       if (td->sp [-1].type == STACK_TYPE_I4 && stack_type [mt] == STACK_TYPE_I8) {
+               ADD_CODE(td, MINT_CONV_I8_I4);
+               td->sp [-1].type = STACK_TYPE_I8;
+       }
+#endif
+       if (!can_store(td->sp [-1].type, stack_type [mt])) {
+               g_warning("%s.%s: Store local stack type mismatch %d %d", 
+                       td->method->klass->name, td->method->name,
+                       stack_type [mt], td->sp [-1].type);
+       }
+       if (mt == MINT_TYPE_VT) {
+               MonoClass *klass = mono_class_from_mono_type (type);
+               gint32 size = mono_class_value_size (klass, NULL);
+               ADD_CODE(td, MINT_STLOC_VT);
+               ADD_CODE(td, offset); /*FIX for large offset */
+               WRITE32(td, &size);
+               if (td->sp [-1].type == STACK_TYPE_VT)
+                       POP_VT(td, size);
+       } else {
+               g_assert (mt < MINT_TYPE_VT);
+               ADD_CODE(td, MINT_STLOC_I1 + (mt - MINT_TYPE_I1));
+               ADD_CODE(td, offset); /*FIX for large offset */
+       }
+       --td->sp;
+}
+
+#define SIMPLE_OP(td, op) \
+       do { \
+               ADD_CODE(&td, op); \
+               ++td.ip; \
+       } while (0)
+
+static guint16
+get_data_item_index (TransformData *td, void *ptr)
+{
+       gpointer p = g_hash_table_lookup (td->data_hash, ptr);
+       guint index;
+       if (p != NULL)
+               return GPOINTER_TO_UINT (p) - 1;
+       if (td->max_data_items == td->n_data_items) {
+               td->max_data_items = td->n_data_items == 0 ? 16 : 2 * td->max_data_items;
+               td->data_items = g_realloc (td->data_items, td->max_data_items * sizeof(td->data_items [0]));
+       }
+       index = td->n_data_items;
+       td->data_items [index] = ptr;
+       ++td->n_data_items;
+       g_hash_table_insert (td->data_hash, ptr, GUINT_TO_POINTER (index + 1));
+       return index;
+}
+
+static void
+interp_transform_call (TransformData *td, MonoMethod *method, MonoMethod *target_method, MonoDomain *domain, MonoGenericContext *generic_context, unsigned char *is_bb_start, int body_start_offset, MonoClass *constrained_class)
+{
+       MonoImage *image = method->klass->image;
+       MonoMethodSignature *csignature;
+       MonoError error;
+       int virtual = *td->ip == CEE_CALLVIRT;
+       int calli = *td->ip == CEE_CALLI || *td->ip == CEE_MONO_CALLI_EXTRA_ARG;
+       int i;
+       guint32 vt_stack_used = 0;
+       guint32 vt_res_size = 0;
+       int op = -1;
+       int native = 0;
+       int is_void = 0;
+
+       guint32 token = read32 (td->ip + 1);
+
+       if (target_method == NULL) {
+               if (calli) {
+                       CHECK_STACK(td, 1);
+                       native = (method->wrapper_type != MONO_WRAPPER_DELEGATE_INVOKE && td->sp [-1].type == STACK_TYPE_I);
+                       --td->sp;
+                       if (method->wrapper_type != MONO_WRAPPER_NONE)
+                               csignature = (MonoMethodSignature *)mono_method_get_wrapper_data (method, token);
+                       else
+                               csignature = mono_metadata_parse_signature (image, token);
+
+                       if (generic_context) {
+                               csignature = mono_inflate_generic_signature (csignature, generic_context, &error);
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       }
+
+                       target_method = NULL;
+               } else {
+                       if (method->wrapper_type == MONO_WRAPPER_NONE)
+                               target_method = mono_get_method_full (image, token, NULL, generic_context);
+                       else
+                               target_method = (MonoMethod *)mono_method_get_wrapper_data (method, token);
+                       csignature = mono_method_signature (target_method);
+                       if (target_method->klass == mono_defaults.string_class) {
+                               if (target_method->name [0] == 'g') {
+                                       if (strcmp (target_method->name, "get_Chars") == 0)
+                                               op = MINT_GETCHR;
+                                       else if (strcmp (target_method->name, "get_Length") == 0)
+                                               op = MINT_STRLEN;
+                               }
+                       } else if (target_method->klass == mono_defaults.array_class) {
+                               if (strcmp (target_method->name, "get_Rank") == 0)
+                                       op = MINT_ARRAY_RANK;
+                               else if (strcmp (target_method->name, "get_Length") == 0)
+                                       op = MINT_LDLEN;
+                       }
+               }
+       } else {
+               csignature = mono_method_signature (target_method);
+       }
+
+       /* TODO: that's oddly specific? */
+       if (generic_context && target_method && !strcmp ("Invoke", target_method->name) && target_method->klass->parent == mono_defaults.multicastdelegate_class) {
+               csignature = mono_inflate_generic_signature (csignature, generic_context, &error);
+               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+       }
+
+       if (constrained_class) {
+               if (constrained_class->enumtype && !strcmp (target_method->name, "GetHashCode")) {
+                       /* Use the corresponding method from the base type to avoid boxing */
+                       MonoType *base_type = mono_class_enum_basetype (constrained_class);
+                       g_assert (base_type);
+                       constrained_class = mono_class_from_mono_type (base_type);
+                       target_method = mono_class_get_method_from_name (constrained_class, target_method->name, 0);
+                       g_assert (target_method);
+               }
+       }
+
+       if (constrained_class) {
+               mono_class_setup_vtable (constrained_class);
+#if DEBUG_INTERP
+               g_print ("CONSTRAINED.CALLVIRT: %s::%s.  %s (%p) ->\n", target_method->klass->name, target_method->name, mono_signature_full_name (target_method->signature), target_method);
+#endif
+               target_method = mono_get_method_constrained_with_method (image, target_method, constrained_class, generic_context, &error);
+#if DEBUG_INTERP
+               g_print ("                    : %s::%s.  %s (%p)\n", target_method->klass->name, target_method->name, mono_signature_full_name (target_method->signature), target_method);
+#endif
+               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+               mono_class_setup_vtable (target_method->klass);
+
+               if (constrained_class->valuetype && (target_method->klass == mono_defaults.object_class || target_method->klass == mono_defaults.enum_class->parent || target_method->klass == mono_defaults.enum_class)) {
+                       if (target_method->klass == mono_defaults.enum_class && (td->sp - csignature->param_count - 1)->type == STACK_TYPE_MP) {
+                               /* managed pointer on the stack, we need to deref that puppy */
+                               ADD_CODE (td, MINT_LDIND_I);
+                               ADD_CODE (td, csignature->param_count);
+                       }
+                       ADD_CODE (td, MINT_BOX);
+                       ADD_CODE (td, get_data_item_index (td, constrained_class));
+                       ADD_CODE (td, csignature->param_count);
+               } else if (!constrained_class->valuetype) {
+                       /* managed pointer on the stack, we need to deref that puppy */
+                       ADD_CODE (td, MINT_LDIND_I);
+                       ADD_CODE (td, csignature->param_count);
+               } else {
+                       g_assert (target_method->klass->valuetype);
+                       virtual = FALSE;
+               }
+       }
+
+       if (target_method)
+               mono_class_init (target_method->klass);
+
+       CHECK_STACK (td, csignature->param_count + csignature->hasthis);
+       if (!calli && (!virtual || (target_method->flags & METHOD_ATTRIBUTE_VIRTUAL) == 0) &&
+               (target_method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) == 0 && 
+               (target_method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) == 0) {
+               int called_inited = mono_class_vtable (domain, target_method->klass)->initialized;
+               MonoMethodHeader *mheader = mono_method_get_header (target_method);
+
+               if (/*mono_metadata_signature_equal (method->signature, target_method->signature) */ method == target_method && *(td->ip + 5) == CEE_RET) {
+                       int offset;
+                       if (mono_interp_traceopt)
+                               g_print ("Optimize tail call of %s.%s\n", target_method->klass->name, target_method->name);
+                       for (i = csignature->param_count - 1; i >= 0; --i)
+                               store_arg (td, i + csignature->hasthis);
+
+                       if (csignature->hasthis) {
+                               g_error ("STTHIS removal");
+                               // ADD_CODE(td, MINT_STTHIS);
+                               --td->sp;
+                       }
+                       ADD_CODE(td, MINT_BR_S);
+                       offset = body_start_offset - ((td->new_ip - 1) - td->new_code);
+                       ADD_CODE(td, offset);
+                       if (!is_bb_start [td->ip + 5 - td->il_code])
+                               ++td->ip; /* gobble the CEE_RET if it isn't branched to */                              
+                       td->ip += 5;
+                       return;
+               } else {
+                       /* mheader might not exist if this is a delegate invoc, etc */
+                       if (mheader && *mheader->code == CEE_RET && called_inited) {
+                               if (mono_interp_traceopt)
+                                       g_print ("Inline (empty) call of %s.%s\n", target_method->klass->name, target_method->name);
+                               for (i = 0; i < csignature->param_count; i++)
+                                       ADD_CODE (td, MINT_POP); /*FIX: vt */
+                                       ADD_CODE (td, 0);
+                               if (csignature->hasthis) {
+                                       if (virtual)
+                                               ADD_CODE(td, MINT_CKNULL);
+                                       ADD_CODE (td, MINT_POP);
+                                       ADD_CODE (td, 0);
+                               }
+                               td->sp -= csignature->param_count + csignature->hasthis;
+                               td->ip += 5;
+                               return;
+                       }
+               }
+       }
+       if (method->wrapper_type == MONO_WRAPPER_NONE && target_method != NULL) {
+               if (target_method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
+                       target_method = mono_marshal_get_native_wrapper (target_method, FALSE, FALSE);
+               if (!virtual && target_method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
+                       target_method = mono_marshal_get_synchronized_wrapper (target_method);
+       }
+       g_assert (csignature->call_convention == MONO_CALL_DEFAULT || csignature->call_convention == MONO_CALL_C);
+       td->sp -= csignature->param_count + !!csignature->hasthis;
+       for (i = 0; i < csignature->param_count; ++i) {
+               if (td->sp [i + !!csignature->hasthis].type == STACK_TYPE_VT) {
+                       gint32 size;
+                       MonoClass *klass = mono_class_from_mono_type (csignature->params [i]);
+                       if (csignature->pinvoke && method->wrapper_type != MONO_WRAPPER_NONE)
+                               size = mono_class_native_size (klass, NULL);
+                       else
+                               size = mono_class_value_size (klass, NULL);
+                       size = (size + 7) & ~7;
+                       vt_stack_used += size;
+               }
+       }
+
+       /* need to handle typedbyref ... */
+       if (csignature->ret->type != MONO_TYPE_VOID) {
+               int mt = mint_type(csignature->ret);
+               MonoClass *klass = mono_class_from_mono_type (csignature->ret);
+               if (mt == MINT_TYPE_VT) {
+                       if (csignature->pinvoke && method->wrapper_type != MONO_WRAPPER_NONE)
+                               vt_res_size = mono_class_native_size (klass, NULL);
+                       else
+                               vt_res_size = mono_class_value_size (klass, NULL);
+                       PUSH_VT(td, vt_res_size);
+               }
+               PUSH_TYPE(td, stack_type[mt], klass);
+       } else
+               is_void = TRUE;
+
+       if (op >= 0) {
+               ADD_CODE(td, op);
+#if SIZEOF_VOID_P == 8
+               if (op == MINT_LDLEN)
+                       ADD_CODE(td, MINT_CONV_I4_I8);
+#endif
+       } else {
+               if (calli)
+                       ADD_CODE(td, native ? MINT_CALLI_NAT : MINT_CALLI);
+               else if (virtual)
+                       ADD_CODE(td, is_void ? MINT_VCALLVIRT : MINT_CALLVIRT);
+               else
+                       ADD_CODE(td, is_void ? MINT_VCALL : MINT_CALL);
+               
+               if (calli) {
+                       ADD_CODE(td, get_data_item_index (td, (void *)csignature));
+               } else {
+                       ADD_CODE(td, get_data_item_index (td, (void *)mono_interp_get_runtime_method (domain, target_method, &error)));
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+               }
+       }
+       td->ip += 5;
+       if (vt_stack_used != 0 || vt_res_size != 0) {
+               ADD_CODE(td, MINT_VTRESULT);
+               ADD_CODE(td, vt_res_size);
+               WRITE32(td, &vt_stack_used);
+               td->vt_sp -= vt_stack_used;
+       }
+}
+
+static void
+generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start, MonoGenericContext *generic_context)
+{
+       MonoMethodHeader *header = mono_method_get_header (method);
+       MonoMethodSignature *signature = mono_method_signature (method);
+       MonoImage *image = method->klass->image;
+       MonoDomain *domain = mono_domain_get ();
+       MonoClass *constrained_class = NULL;
+       MonoError error;
+       int offset, mt;
+       int i;
+       int i32;
+       MonoClass *klass;
+       MonoClassField *field;
+       const unsigned char *end;
+       int new_in_start_offset;
+       int body_start_offset;
+       int target;
+       guint32 token;
+       TransformData td;
+       int generating_code = 1;
+
+       memset(&td, 0, sizeof(td));
+       td.method = method;
+       td.rtm = rtm;
+       td.is_bb_start = is_bb_start;
+       td.il_code = header->code;
+       td.code_size = header->code_size;
+       td.header = header;
+       td.max_code_size = td.code_size;
+       td.new_code = (unsigned short *)g_malloc(td.max_code_size * sizeof(gushort));
+       td.new_code_end = td.new_code + td.max_code_size;
+       td.in_offsets = g_malloc0(header->code_size * sizeof(int));
+       td.forward_refs = g_malloc(header->code_size * sizeof(int));
+       td.stack_state = g_malloc0(header->code_size * sizeof(StackInfo *));
+       td.stack_height = g_malloc(header->code_size * sizeof(int));
+       td.vt_stack_size = g_malloc(header->code_size * sizeof(int));
+       td.n_data_items = 0;
+       td.max_data_items = 0;
+       td.data_items = NULL;
+       td.data_hash = g_hash_table_new (NULL, NULL);
+       rtm->data_items = td.data_items;
+       for (i = 0; i < header->code_size; i++) {
+               td.forward_refs [i] = -1;
+               td.stack_height [i] = -1;
+       }
+       td.new_ip = td.new_code;
+       td.last_new_ip = NULL;
+
+       td.stack = g_malloc0(header->max_stack * sizeof(td.stack[0]));
+       td.sp = td.stack;
+       td.max_stack_height = 0;
+
+       for (i = 0; i < header->num_clauses; i++) {
+               MonoExceptionClause *c = header->clauses + i;
+               td.stack_height [c->handler_offset] = 0;
+               td.vt_stack_size [c->handler_offset] = 0;
+               td.is_bb_start [c->handler_offset] = 1;
+               if (c->flags == MONO_EXCEPTION_CLAUSE_NONE) {
+                       td.stack_height [c->handler_offset] = 1;
+                       td.stack_state [c->handler_offset] = g_malloc0(sizeof(StackInfo));
+                       td.stack_state [c->handler_offset][0].type = STACK_TYPE_O;
+                       td.stack_state [c->handler_offset][0].klass = NULL; /*FIX*/
+               }
+       }
+
+       td.ip = header->code;
+       end = td.ip + header->code_size;
+
+       if (mono_interp_traceopt) {
+               char *tmp = mono_disasm_code (NULL, method, td.ip, end);
+               char *name = mono_method_full_name (method, TRUE);
+               g_print ("Method %s, original code:\n", name);
+               g_print ("%s\n", tmp);
+               g_free (tmp);
+               g_free (name);
+       }
+
+       if (signature->hasthis)
+               store_inarg (&td, 0);
+       for (i = 0; i < signature->param_count; i++)
+               store_inarg (&td, i + !!signature->hasthis);
+
+       body_start_offset = td.new_ip - td.new_code;
+
+       for (i = 0; i < header->num_locals; i++) {
+               int mt = mint_type(header->locals [i]);
+               if (mt == MINT_TYPE_VT || mt == MINT_TYPE_O) {
+                       ADD_CODE(&td, MINT_INITLOCALS);
+                       break;
+               }
+       }
+
+       while (td.ip < end) {
+               int in_offset;
+
+               g_assert (td.sp >= td.stack);
+               g_assert (td.vt_sp < 0x10000000);
+               in_offset = td.ip - header->code;
+               td.in_offsets [in_offset] = td.new_ip - td.new_code;
+               new_in_start_offset = td.new_ip - td.new_code;
+               td.in_start = td.ip;
+               while (td.forward_refs [in_offset] >= 0) {
+                       int j = td.forward_refs [in_offset];
+                       int slot;
+                       td.forward_refs [in_offset] = td.forward_refs [j];
+                       if (td.in_offsets [j] < 0) {                        
+                               int old_switch_offset = -td.in_offsets [j];
+                               int new_switch_offset = td.in_offsets [old_switch_offset];
+                               int switch_case = (j - old_switch_offset - 5) / 4;
+                               int n_cases = read32 (header->code + old_switch_offset + 1);
+                               offset = (td.new_ip - td.new_code) - (new_switch_offset + 2 * n_cases + 3);
+                               slot = new_switch_offset + 3 + 2 * switch_case;
+                               td.new_code [slot] = * (unsigned short *)(&offset);
+                               td.new_code [slot + 1] = * ((unsigned short *)&offset + 1);
+                       } else {
+                               int op = td.new_code [td.in_offsets [j]];
+                               if (mono_interp_opargtype [op] == MintOpShortBranch) {
+                                       offset = (td.new_ip - td.new_code) - td.in_offsets [j];
+                                       g_assert (offset <= 32767);
+                                       slot = td.in_offsets [j] + 1;
+                                       td.new_code [slot] = offset;
+                               } else {
+                                       offset = (td.new_ip - td.new_code) - td.in_offsets [j];
+                                       slot = td.in_offsets [j] + 1;
+                                       td.new_code [slot] = * (unsigned short *)(&offset);
+                                       td.new_code [slot + 1] = * ((unsigned short *)&offset + 1);
+                               }
+                       }
+               }
+               if (td.stack_height [in_offset] >= 0) {
+                       g_assert (is_bb_start [in_offset]);
+                       if (td.stack_height [in_offset] > 0)
+                               memcpy (td.stack, td.stack_state [in_offset], td.stack_height [in_offset] * sizeof(td.stack [0]));
+                       td.sp = td.stack + td.stack_height [in_offset];
+                       td.vt_sp = td.vt_stack_size [in_offset];
+               }
+               if (is_bb_start [in_offset]) {
+                       generating_code = 1;
+               }
+               if (!generating_code) {
+                       while (td.ip < end && !is_bb_start [td.ip - td.il_code])
+                               ++td.ip;
+                       continue;
+               }
+               if (mono_interp_traceopt > 1) {
+                       printf("IL_%04lx %s %-10s -> IL_%04lx, sp %ld, %s %-12s vt_sp %u (max %u)\n", 
+                               td.ip - td.il_code,
+                               td.is_bb_start [td.ip - td.il_code] == 3 ? "<>" :
+                               td.is_bb_start [td.ip - td.il_code] == 2 ? "< " :
+                               td.is_bb_start [td.ip - td.il_code] == 1 ? " >" : "  ",
+                               mono_opcode_name (*td.ip), td.new_ip - td.new_code, td.sp - td.stack, 
+                               td.sp > td.stack ? stack_type_string [td.sp [-1].type] : "  ",
+                               (td.sp > td.stack && (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_VT)) ? (td.sp [-1].klass == NULL ? "?" : td.sp [-1].klass->name) : "",
+                               td.vt_sp, td.max_vt_sp);
+               }
+               switch (*td.ip) {
+               case CEE_NOP: 
+                       /* lose it */
+                       ++td.ip;
+                       break;
+               case CEE_BREAK:
+                       SIMPLE_OP(td, MINT_BREAK);
+                       break;
+               case CEE_LDARG_0:
+               case CEE_LDARG_1:
+               case CEE_LDARG_2:
+               case CEE_LDARG_3:
+                       load_arg (&td, *td.ip - CEE_LDARG_0);
+                       ++td.ip;
+                       break;
+               case CEE_LDLOC_0:
+               case CEE_LDLOC_1:
+               case CEE_LDLOC_2:
+               case CEE_LDLOC_3:
+                       load_local (&td, *td.ip - CEE_LDLOC_0);
+                       ++td.ip;
+                       break;
+               case CEE_STLOC_0:
+               case CEE_STLOC_1:
+               case CEE_STLOC_2:
+               case CEE_STLOC_3:
+                       store_local (&td, *td.ip - CEE_STLOC_0);
+                       ++td.ip;
+                       break;
+               case CEE_LDARG_S:
+                       load_arg (&td, ((guint8 *)td.ip)[1]);
+                       td.ip += 2;
+                       break;
+               case CEE_LDARGA_S: {
+                       /* NOTE: n includes this */
+                       int n = ((guint8 *)td.ip)[1];
+                       if (n == 0 && signature->hasthis) {
+                               g_error ("LDTHISA: NOPE");
+                               ADD_CODE(&td, MINT_LDTHISA);
+                       }
+                       else {
+                               ADD_CODE(&td, MINT_LDARGA);
+                               ADD_CODE(&td, td.rtm->arg_offsets [n]);
+                       }
+                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_MP);
+                       td.ip += 2;
+                       break;
+               }
+               case CEE_STARG_S:
+                       store_arg (&td, ((guint8 *)td.ip)[1]);
+                       td.ip += 2;
+                       break;
+               case CEE_LDLOC_S:
+                       load_local (&td, ((guint8 *)td.ip)[1]);
+                       td.ip += 2;
+                       break;
+               case CEE_LDLOCA_S:
+                       ADD_CODE(&td, MINT_LDLOCA_S);
+                       ADD_CODE(&td, td.rtm->local_offsets [((guint8 *)td.ip)[1]]);
+                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_MP);
+                       td.ip += 2;
+                       break;
+               case CEE_STLOC_S:
+                       store_local (&td, ((guint8 *)td.ip)[1]);
+                       td.ip += 2;
+                       break;
+               case CEE_LDNULL: 
+                       SIMPLE_OP(td, MINT_LDNULL);
+                       PUSH_TYPE(&td, STACK_TYPE_O, NULL);
+                       break;
+               case CEE_LDC_I4_M1:
+                       SIMPLE_OP(td, MINT_LDC_I4_M1);
+                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
+                       break;
+               case CEE_LDC_I4_0:
+                       if (!td.is_bb_start[td.ip + 1 - td.il_code] && td.ip [1] == 0xfe && td.ip [2] == CEE_CEQ && 
+                               td.sp > td.stack && td.sp [-1].type == STACK_TYPE_I4) {
+                               SIMPLE_OP(td, MINT_CEQ0_I4);
+                               td.ip += 2;
+                       } else {
+                               SIMPLE_OP(td, MINT_LDC_I4_0);
+                               PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
+                       }
+                       break;
+               case CEE_LDC_I4_1:
+                       if (!td.is_bb_start[td.ip + 1 - td.il_code] && 
+                               (td.ip [1] == CEE_ADD || td.ip [1] == CEE_SUB) && td.sp [-1].type == STACK_TYPE_I4) {
+                               ADD_CODE(&td, td.ip [1] == CEE_ADD ? MINT_ADD1_I4 : MINT_SUB1_I4);
+                               td.ip += 2;
+                       } else {
+                               SIMPLE_OP(td, MINT_LDC_I4_1);
+                               PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
+                       }
+                       break;
+               case CEE_LDC_I4_2:
+               case CEE_LDC_I4_3:
+               case CEE_LDC_I4_4:
+               case CEE_LDC_I4_5:
+               case CEE_LDC_I4_6:
+               case CEE_LDC_I4_7:
+               case CEE_LDC_I4_8:
+                       SIMPLE_OP(td, (*td.ip - CEE_LDC_I4_0) + MINT_LDC_I4_0);
+                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
+                       break;
+               case CEE_LDC_I4_S: 
+                       ADD_CODE(&td, MINT_LDC_I4_S);
+                       ADD_CODE(&td, ((gint8 *) td.ip) [1]);
+                       td.ip += 2;
+                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
+                       break;
+               case CEE_LDC_I4:
+                       i32 = read32 (td.ip + 1);
+                       ADD_CODE(&td, MINT_LDC_I4);
+                       WRITE32(&td, &i32);
+                       td.ip += 5;
+                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
+                       break;
+               case CEE_LDC_I8: {
+                       gint64 val = read64 (td.ip + 1);
+                       ADD_CODE(&td, MINT_LDC_I8);
+                       WRITE64(&td, &val);
+                       td.ip += 9;
+                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I8);
+                       break;
+               }
+               case CEE_LDC_R4: {
+                       float val;
+                       readr4 (td.ip + 1, &val);
+                       ADD_CODE(&td, MINT_LDC_R4);
+                       WRITE32(&td, &val);
+                       td.ip += 5;
+                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_R8);
+                       break;
+               }
+               case CEE_LDC_R8: {
+                       double val;
+                       readr8 (td.ip + 1, &val);
+                       ADD_CODE(&td, MINT_LDC_R8);
+                       WRITE64(&td, &val);
+                       td.ip += 9;
+                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_R8);
+                       break;
+               }
+               case CEE_DUP: {
+                       int type = td.sp [-1].type;
+                       MonoClass *klass = td.sp [-1].klass;
+                       if (td.sp [-1].type == STACK_TYPE_VT) {
+                               gint32 size = mono_class_value_size (klass, NULL);
+                               PUSH_VT(&td, size);
+                               ADD_CODE(&td, MINT_DUP_VT);
+                               WRITE32(&td, &size);
+                               td.ip ++;
+                       } else 
+                               SIMPLE_OP(td, MINT_DUP);
+                       PUSH_TYPE(&td, type, klass);
+                       break;
+               }
+               case CEE_POP:
+                       CHECK_STACK(&td, 1);
+                       SIMPLE_OP(td, MINT_POP);
+                       ADD_CODE (&td, 0);
+                       if (td.sp [-1].type == STACK_TYPE_VT) {
+                               int size = mono_class_value_size (td.sp [-1].klass, NULL);
+                               size = (size + 7) & ~7;
+                               ADD_CODE(&td, MINT_VTRESULT);
+                               ADD_CODE(&td, 0);
+                               WRITE32(&td, &size);
+                               td.vt_sp -= size;
+                       }
+                       --td.sp;
+                       break;
+               case CEE_JMP: {
+                       MonoMethod *m;
+                       if (td.sp > td.stack)
+                               g_warning ("CEE_JMP: stack must be empty");
+                       token = read32 (td.ip + 1);
+                       m = mono_get_method_full (image, token, NULL, generic_context);
+                       ADD_CODE (&td, MINT_JMP);
+                       ADD_CODE (&td, get_data_item_index (&td, mono_interp_get_runtime_method (domain, m, &error)));
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                       td.ip += 5;
+                       break;
+               }
+               case CEE_CALLVIRT: /* Fall through */
+               case CEE_CALLI:    /* Fall through */
+               case CEE_CALL: {
+                       interp_transform_call (&td, method, NULL, domain, generic_context, is_bb_start, body_start_offset, constrained_class);
+                       constrained_class = NULL;
+                       break;
+               }
+               case CEE_RET: {
+                       int vt_size = 0;
+                       if (signature->ret->type != MONO_TYPE_VOID) {
+                               --td.sp;
+                               MonoClass *klass = mono_class_from_mono_type (signature->ret);
+                               if (mint_type (&klass->byval_arg) == MINT_TYPE_VT) {
+                                       vt_size = mono_class_value_size (klass, NULL);
+                                       vt_size = (vt_size + 7) & ~7;
+                               }
+                       }
+                       if (td.sp > td.stack)
+                               g_warning ("%s.%s: CEE_RET: more values on stack: %d", td.method->klass->name, td.method->name, td.sp - td.stack);
+                       if (td.vt_sp != vt_size)
+                               g_error ("%s.%s: CEE_RET: value type stack: %d vs. %d", td.method->klass->name, td.method->name, td.vt_sp, vt_size);
+                       if (vt_size == 0)
+                               SIMPLE_OP(td, signature->ret->type == MONO_TYPE_VOID ? MINT_RET_VOID : MINT_RET);
+                       else {
+                               ADD_CODE(&td, MINT_RET_VT);
+                               WRITE32(&td, &vt_size);
+                               ++td.ip;
+                       }
+                       generating_code = 0;
+                       break;
+               }
+               case CEE_BR:
+                       handle_branch (&td, MINT_BR_S, MINT_BR, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       generating_code = 0;
+                       break;
+               case CEE_BR_S:
+                       handle_branch (&td, MINT_BR_S, MINT_BR, 2 + (gint8)td.ip [1]);
+                       td.ip += 2;
+                       generating_code = 0;
+                       break;
+               case CEE_BRFALSE:
+                       one_arg_branch (&td, MINT_BRFALSE_I4, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       break;
+               case CEE_BRFALSE_S:
+                       one_arg_branch (&td, MINT_BRFALSE_I4, 2 + (gint8)td.ip [1]);
+                       td.ip += 2;
+                       break;
+               case CEE_BRTRUE:
+                       one_arg_branch (&td, MINT_BRTRUE_I4, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       break;
+               case CEE_BRTRUE_S:
+                       one_arg_branch (&td, MINT_BRTRUE_I4, 2 + (gint8)td.ip [1]);
+                       td.ip += 2;
+                       break;
+               case CEE_BEQ:
+                       two_arg_branch (&td, MINT_BEQ_I4, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       break;
+               case CEE_BEQ_S:
+                       two_arg_branch (&td, MINT_BEQ_I4, 2 + (gint8) td.ip [1]);
+                       td.ip += 2;
+                       break;
+               case CEE_BGE:
+                       two_arg_branch (&td, MINT_BGE_I4, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       break;
+               case CEE_BGE_S:
+                       two_arg_branch (&td, MINT_BGE_I4, 2 + (gint8) td.ip [1]);
+                       td.ip += 2;
+                       break;
+               case CEE_BGT:
+                       two_arg_branch (&td, MINT_BGT_I4, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       break;
+               case CEE_BGT_S:
+                       two_arg_branch (&td, MINT_BGT_I4, 2 + (gint8) td.ip [1]);
+                       td.ip += 2;
+                       break;
+               case CEE_BLT:
+                       two_arg_branch (&td, MINT_BLT_I4, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       break;
+               case CEE_BLT_S:
+                       two_arg_branch (&td, MINT_BLT_I4, 2 + (gint8) td.ip [1]);
+                       td.ip += 2;
+                       break;
+               case CEE_BLE:
+                       two_arg_branch (&td, MINT_BLE_I4, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       break;
+               case CEE_BLE_S:
+                       two_arg_branch (&td, MINT_BLE_I4, 2 + (gint8) td.ip [1]);
+                       td.ip += 2;
+                       break;
+               case CEE_BNE_UN:
+                       two_arg_branch (&td, MINT_BNE_UN_I4, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       break;
+               case CEE_BNE_UN_S:
+                       two_arg_branch (&td, MINT_BNE_UN_I4, 2 + (gint8) td.ip [1]);
+                       td.ip += 2;
+                       break;
+               case CEE_BGE_UN:
+                       two_arg_branch (&td, MINT_BGE_UN_I4, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       break;
+               case CEE_BGE_UN_S:
+                       two_arg_branch (&td, MINT_BGE_UN_I4, 2 + (gint8) td.ip [1]);
+                       td.ip += 2;
+                       break;
+               case CEE_BGT_UN:
+                       two_arg_branch (&td, MINT_BGT_UN_I4, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       break;
+               case CEE_BGT_UN_S:
+                       two_arg_branch (&td, MINT_BGT_UN_I4, 2 + (gint8) td.ip [1]);
+                       td.ip += 2;
+                       break;
+               case CEE_BLE_UN:
+                       two_arg_branch (&td, MINT_BLE_UN_I4, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       break;
+               case CEE_BLE_UN_S:
+                       two_arg_branch (&td, MINT_BLE_UN_I4, 2 + (gint8) td.ip [1]);
+                       td.ip += 2;
+                       break;
+               case CEE_BLT_UN:
+                       two_arg_branch (&td, MINT_BLT_UN_I4, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       break;
+               case CEE_BLT_UN_S:
+                       two_arg_branch (&td, MINT_BLT_UN_I4, 2 + (gint8) td.ip [1]);
+                       td.ip += 2;
+                       break;
+               case CEE_SWITCH: {
+                       guint32 n;
+                       const unsigned char *next_ip;
+                       const unsigned char *base_ip = td.ip;
+                       unsigned short *next_new_ip;
+                       ++td.ip;
+                       n = read32 (td.ip);
+                       ADD_CODE(&td, MINT_SWITCH);
+                       ADD_CODE(&td, * (unsigned short *)(&n));
+                       ADD_CODE(&td, * ((unsigned short *)&n + 1));
+                       td.ip += 4;
+                       next_ip = td.ip + n * 4;
+                       next_new_ip = td.new_ip + n * 2;
+                       for (i = 0; i < n; i++) {
+                               offset = read32 (td.ip);
+                               target = next_ip - td.il_code + offset;
+                               if (offset < 0)
+                                       target = td.in_offsets [target] - (next_new_ip - td.new_code);
+                               else {
+                                       int prev = td.forward_refs [target];
+                                       td.forward_refs [td.ip - td.il_code] = prev;
+                                       td.forward_refs [target] = td.ip - td.il_code;
+                                       td.in_offsets [td.ip - td.il_code] = - (base_ip - td.il_code);
+                               }
+                               ADD_CODE(&td, * (unsigned short *)(&target));
+                               ADD_CODE(&td, * ((unsigned short *)&target + 1));
+                               td.ip += 4;
+                       }
+                       --td.sp;
+                       break;
+               }
+               case CEE_LDIND_I1:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_LDIND_I1);
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_LDIND_U1:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_LDIND_U1);
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_LDIND_I2:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_LDIND_I2);
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_LDIND_U2:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_LDIND_U2);
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_LDIND_I4:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_LDIND_I4);
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_LDIND_U4:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_LDIND_U4);
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_LDIND_I8:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_LDIND_I8);
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
+                       break;
+               case CEE_LDIND_I:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_LDIND_I);
+                       ADD_CODE (&td, 0);
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I);
+                       break;
+               case CEE_LDIND_R4:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_LDIND_R4);
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
+                       break;
+               case CEE_LDIND_R8:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_LDIND_R8);
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
+                       break;
+               case CEE_LDIND_REF:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_LDIND_REF);
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_O);
+                       break;
+               case CEE_STIND_REF:
+                       CHECK_STACK (&td, 2);
+                       SIMPLE_OP (td, MINT_STIND_REF);
+                       td.sp -= 2;
+                       break;
+               case CEE_STIND_I1:
+                       CHECK_STACK (&td, 2);
+                       SIMPLE_OP (td, MINT_STIND_I1);
+                       td.sp -= 2;
+                       break;
+               case CEE_STIND_I2:
+                       CHECK_STACK (&td, 2);
+                       SIMPLE_OP (td, MINT_STIND_I2);
+                       td.sp -= 2;
+                       break;
+               case CEE_STIND_I4:
+                       CHECK_STACK (&td, 2);
+                       SIMPLE_OP (td, MINT_STIND_I4);
+                       td.sp -= 2;
+                       break;
+               case CEE_STIND_I:
+                       CHECK_STACK (&td, 2);
+                       SIMPLE_OP (td, MINT_STIND_I);
+                       td.sp -= 2;
+                       break;
+               case CEE_STIND_I8:
+                       CHECK_STACK (&td, 2);
+                       SIMPLE_OP (td, MINT_STIND_I8);
+                       td.sp -= 2;
+                       break;
+               case CEE_STIND_R4:
+                       CHECK_STACK (&td, 2);
+                       SIMPLE_OP (td, MINT_STIND_R4);
+                       td.sp -= 2;
+                       break;
+               case CEE_STIND_R8:
+                       CHECK_STACK (&td, 2);
+                       SIMPLE_OP (td, MINT_STIND_R8);
+                       td.sp -= 2;
+                       break;
+               case CEE_ADD:
+                       binary_arith_op(&td, MINT_ADD_I4);
+                       ++td.ip;
+                       break;
+               case CEE_SUB:
+                       binary_arith_op(&td, MINT_SUB_I4);
+                       ++td.ip;
+                       break;
+               case CEE_MUL:
+                       binary_arith_op(&td, MINT_MUL_I4);
+                       ++td.ip;
+                       break;
+               case CEE_DIV:
+                       binary_arith_op(&td, MINT_DIV_I4);
+                       ++td.ip;
+                       break;
+               case CEE_DIV_UN:
+                       binary_arith_op(&td, MINT_DIV_UN_I4);
+                       ++td.ip;
+                       break;
+               case CEE_REM:
+                       binary_int_op (&td, MINT_REM_I4);
+                       ++td.ip;
+                       break;
+               case CEE_REM_UN:
+                       binary_int_op (&td, MINT_REM_UN_I4);
+                       ++td.ip;
+                       break;
+               case CEE_AND:
+                       binary_int_op (&td, MINT_AND_I4);
+                       ++td.ip;
+                       break;
+               case CEE_OR:
+                       binary_int_op (&td, MINT_OR_I4);
+                       ++td.ip;
+                       break;
+               case CEE_XOR:
+                       binary_int_op (&td, MINT_XOR_I4);
+                       ++td.ip;
+                       break;
+               case CEE_SHL:
+                       shift_op (&td, MINT_SHL_I4);
+                       ++td.ip;
+                       break;
+               case CEE_SHR:
+                       shift_op (&td, MINT_SHR_I4);
+                       ++td.ip;
+                       break;
+               case CEE_SHR_UN:
+                       shift_op (&td, MINT_SHR_UN_I4);
+                       ++td.ip;
+                       break;
+               case CEE_NEG:
+                       unary_arith_op (&td, MINT_NEG_I4);
+                       ++td.ip;
+                       break;
+               case CEE_NOT:
+                       unary_arith_op (&td, MINT_NOT_I4);
+                       ++td.ip;
+                       break;
+               case CEE_CONV_U1:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_U1_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_U1_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_U1_I8);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_CONV_I1:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_I1_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_I1_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_I1_I8);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_CONV_U2:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_U2_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_U2_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_U2_I8);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_CONV_I2:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_I2_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_I2_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_I2_I8);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_CONV_U:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+#if SIZEOF_VOID_P == 4
+                               ADD_CODE(&td, MINT_CONV_U4_R8);
+#else
+                               ADD_CODE(&td, MINT_CONV_U8_R8);
+#endif
+                               break;
+                       case STACK_TYPE_I4:
+#if SIZEOF_VOID_P == 8
+                               ADD_CODE(&td, MINT_CONV_U8_I4);
+#endif
+                               break;
+                       case STACK_TYPE_I8:
+#if SIZEOF_VOID_P == 4
+                               ADD_CODE(&td, MINT_CONV_U4_I8);
+#endif
+                               break;
+                       case STACK_TYPE_MP:
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I);
+                       break;
+               case CEE_CONV_I: 
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+#if SIZEOF_VOID_P == 8
+                               ADD_CODE(&td, MINT_CONV_I8_R8);
+#else
+                               ADD_CODE(&td, MINT_CONV_I4_R8);
+#endif
+                               break;
+                       case STACK_TYPE_I4:
+#if SIZEOF_VOID_P == 8
+                               ADD_CODE(&td, MINT_CONV_I8_I4);
+#endif
+                               break;
+                       case STACK_TYPE_O:
+                               break;
+                       case STACK_TYPE_MP:
+                               break;
+                       case STACK_TYPE_I8:
+#if SIZEOF_VOID_P == 4
+                               ADD_CODE(&td, MINT_CONV_I4_I8);
+#endif
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I);
+                       break;
+               case CEE_CONV_U4:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_U4_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_U4_I8);
+                               break;
+                       case STACK_TYPE_MP:
+#if SIZEOF_VOID_P == 8
+                               ADD_CODE(&td, MINT_CONV_U4_I8);
+#endif
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_CONV_I4:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_I4_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_I4_I8);
+                               break;
+                       case STACK_TYPE_MP:
+#if SIZEOF_VOID_P == 8
+                               ADD_CODE(&td, MINT_CONV_I4_I8);
+#endif
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_CONV_I8:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_I8_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_I8_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               break;
+                       case STACK_TYPE_MP:
+#if SIZEOF_VOID_P == 4
+                               ADD_CODE(&td, MINT_CONV_I8_I4);
+#endif
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
+                       break;
+               case CEE_CONV_R4:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_R4_R8);
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_R4_I8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_R4_I4);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
+                       break;
+               case CEE_CONV_R8:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_R8_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_R8_I8);
+                               break;
+                       case STACK_TYPE_R8:
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
+                       break;
+               case CEE_CONV_U8:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_U8_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               break;
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_U8_R8);
+                               break;
+                       case STACK_TYPE_MP:
+#if SIZEOF_VOID_P == 4
+                               ADD_CODE(&td, MINT_CONV_U8_I4);
+#endif
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
+                       break;
+#if 0
+               case CEE_CPOBJ: {
+                       MonoClass *vtklass;
+                       ++ip;
+                       vtklass = mono_class_get_full (image, read32 (ip), generic_context);
+                       ip += 4;
+                       sp -= 2;
+                       memcpy (sp [0].data.p, sp [1].data.p, mono_class_value_size (vtklass, NULL));
+                       break;
+               }
+#endif
+               case CEE_LDOBJ: {
+                       int size;
+                       CHECK_STACK (&td, 1);
+
+                       token = read32 (td.ip + 1);
+
+                       if (method->wrapper_type != MONO_WRAPPER_NONE)
+                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
+                       else
+                               klass = mono_class_get_full (image, token, generic_context);
+
+                       ADD_CODE(&td, MINT_LDOBJ);
+                       ADD_CODE(&td, get_data_item_index(&td, klass));
+                       if (mint_type (&klass->byval_arg) == MINT_TYPE_VT) {
+                               size = mono_class_value_size (klass, NULL);
+                               PUSH_VT(&td, size);
+                       }
+                       td.ip += 5;
+                       SET_TYPE(td.sp - 1, stack_type[mint_type(&klass->byval_arg)], klass);
+                       break;
+               }
+               case CEE_LDSTR: {
+                       MonoString *s;
+                       token = mono_metadata_token_index (read32 (td.ip + 1));
+                       td.ip += 5;
+                       if (method->wrapper_type != MONO_WRAPPER_NONE) {
+                               s = mono_string_new_wrapper(
+                                       mono_method_get_wrapper_data (method, token));
+                       }
+                       else
+                               s = mono_ldstr (domain, image, token);
+                       ADD_CODE(&td, MINT_LDSTR);
+                       ADD_CODE(&td, get_data_item_index (&td, s));
+                       PUSH_TYPE(&td, STACK_TYPE_O, mono_defaults.string_class);
+                       break;
+               }
+               case CEE_NEWOBJ: {
+                       MonoMethod *m;
+                       MonoMethodSignature *csignature;
+                       guint32 vt_stack_used = 0;
+                       guint32 vt_res_size = 0;
+
+                       td.ip++;
+                       token = read32 (td.ip);
+                       td.ip += 4;
+
+                       if (method->wrapper_type != MONO_WRAPPER_NONE)
+                               m = (MonoMethod *)mono_method_get_wrapper_data (method, token);
+                       else 
+                               m = mono_get_method_full (image, token, NULL, generic_context);
+
+                       csignature = mono_method_signature (m);
+                       klass = m->klass;
+                       td.sp -= csignature->param_count;
+                       ADD_CODE(&td, MINT_NEWOBJ);
+                       ADD_CODE(&td, get_data_item_index (&td, mono_interp_get_runtime_method (domain, m, &error)));
+                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+
+                       if (mint_type (&klass->byval_arg) == MINT_TYPE_VT) {
+                               vt_res_size = mono_class_value_size (klass, NULL);
+                               PUSH_VT (&td, vt_res_size);
+                       }
+                       for (i = 0; i < csignature->param_count; ++i) {
+                               int mt = mint_type(csignature->params [i]);
+                               if (mt == MINT_TYPE_VT) {
+                                       MonoClass *k = mono_class_from_mono_type (csignature->params [i]);
+                                       gint32 size = mono_class_value_size (k, NULL);
+                                       size = (size + 7) & ~7;
+                                       vt_stack_used += size;
+                               }
+                       }
+                       if (vt_stack_used != 0 || vt_res_size != 0) {
+                               ADD_CODE(&td, MINT_VTRESULT);
+                               ADD_CODE(&td, vt_res_size);
+                               WRITE32(&td, &vt_stack_used);
+                               td.vt_sp -= vt_stack_used;
+                       }
+                       PUSH_TYPE (&td, stack_type [mint_type (&klass->byval_arg)], klass);
+                       break;
+               }
+               case CEE_CASTCLASS:
+                       CHECK_STACK (&td, 1);
+                       token = read32 (td.ip + 1);
+                       klass = mono_class_get_full (image, token, generic_context);
+                       ADD_CODE(&td, MINT_CASTCLASS);
+                       ADD_CODE(&td, get_data_item_index (&td, klass));
+                       td.sp [-1].klass = klass;
+                       td.ip += 5;
+                       break;
+               case CEE_ISINST:
+                       CHECK_STACK (&td, 1);
+                       token = read32 (td.ip + 1);
+                       klass = mono_class_get_full (image, token, generic_context);
+                       ADD_CODE(&td, MINT_ISINST);
+                       ADD_CODE(&td, get_data_item_index (&td, klass));
+                       td.ip += 5;
+                       break;
+               case CEE_CONV_R_UN:
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_R_UN_I8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_R_UN_I4);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
+                       ++td.ip;
+                       break;
+               case CEE_UNBOX:
+                       CHECK_STACK (&td, 1);
+                       token = read32 (td.ip + 1);
+                       
+                       if (method->wrapper_type != MONO_WRAPPER_NONE)
+                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
+                       else 
+                               klass = mono_class_get_full (image, token, generic_context);
+
+                       if (mono_class_is_nullable (klass)) {
+                               g_error ("cee_unbox: implement Nullable");
+                       }
+                       
+                       ADD_CODE(&td, MINT_UNBOX);
+                       ADD_CODE(&td, get_data_item_index (&td, klass));
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
+                       td.ip += 5;
+                       break;
+               case CEE_UNBOX_ANY:
+                       CHECK_STACK (&td, 1);
+                       token = read32 (td.ip + 1);
+
+                       g_assert (method->wrapper_type == MONO_WRAPPER_NONE);
+                       klass = mono_class_get_full (image, token, generic_context);
+
+                       if (mini_type_is_reference (&klass->byval_arg)) {
+                               g_error ("unbox_any: generic class is reference type");
+                       } else if (mono_class_is_nullable (klass)) {
+                               MonoMethod *target_method = mono_class_get_method_from_name (klass, "Unbox", 1);
+                               /* td.ip is incremented by interp_transform_call */
+                               interp_transform_call (&td, method, target_method, domain, generic_context, is_bb_start, body_start_offset, NULL);
+                       } else {
+                               int mt = mint_type (&klass->byval_arg);
+                               ADD_CODE (&td, MINT_UNBOX);
+                               ADD_CODE (&td, get_data_item_index (&td, klass));
+                               SET_TYPE (td.sp - 1, stack_type [mt], klass);
+                               if (mt == MINT_TYPE_VT) {
+                                       int size = mono_class_value_size (klass, NULL);
+                                       PUSH_VT (&td, size);
+                               }
+                               td.ip += 5;
+                       }
+
+                       break;
+               case CEE_THROW:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_THROW);
+                       --td.sp;
+                       generating_code = 0;
+                       break;
+               case CEE_LDFLDA:
+                       CHECK_STACK (&td, 1);
+                       token = read32 (td.ip + 1);
+                       field = mono_field_from_token (image, token, &klass, generic_context);
+                       mono_class_init (klass);
+                       mt = mint_type(field->type);
+                       ADD_CODE(&td, MINT_LDFLDA);
+                       ADD_CODE(&td, klass->valuetype ? field->offset - sizeof(MonoObject) : field->offset);
+                       td.ip += 5;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
+                       break;
+               case CEE_LDFLD: {
+                       CHECK_STACK (&td, 1);
+                       token = read32 (td.ip + 1);
+                       field = mono_field_from_token (image, token, &klass, generic_context);
+                       mono_class_init (klass);
+
+                       MonoClass *field_klass = mono_class_from_mono_type (field->type);
+                       mt = mint_type (&field_klass->byval_arg);
+                       if (klass->marshalbyref) {
+                               ADD_CODE(&td, mt == MINT_TYPE_VT ? MINT_LDRMFLD_VT :  MINT_LDRMFLD);
+                               ADD_CODE(&td, get_data_item_index (&td, field));
+                       } else  {
+                               ADD_CODE(&td, MINT_LDFLD_I1 + mt - MINT_TYPE_I1);
+                               ADD_CODE(&td, klass->valuetype ? field->offset - sizeof(MonoObject) : field->offset);
+                       }
+                       if (mt == MINT_TYPE_VT) {
+                               int size = mono_class_value_size (field_klass, NULL);
+                               PUSH_VT(&td, size);
+                               WRITE32(&td, &size);
+                       }
+                       if (td.sp [-1].type == STACK_TYPE_VT) {
+                               int size = mono_class_value_size (klass, NULL);
+                               size = (size + 7) & ~7;
+                               td.vt_sp -= size;
+                               ADD_CODE (&td, MINT_VTRESULT);
+                               ADD_CODE (&td, 0);
+                               WRITE32 (&td, &size);
+                       }
+                       td.ip += 5;
+                       SET_TYPE(td.sp - 1, stack_type [mt], field_klass);
+                       break;
+               }
+               case CEE_STFLD:
+                       CHECK_STACK (&td, 2);
+                       token = read32 (td.ip + 1);
+                       field = mono_field_from_token (image, token, &klass, generic_context);
+                       mono_class_init (klass);
+                       mt = mint_type(field->type);
+                       if (klass->marshalbyref) {
+                               ADD_CODE(&td, mt == MINT_TYPE_VT ? MINT_STRMFLD_VT : MINT_STRMFLD);
+                               ADD_CODE(&td, get_data_item_index (&td, field));
+                       } else  {
+                               ADD_CODE(&td, MINT_STFLD_I1 + mt - MINT_TYPE_I1);
+                               ADD_CODE(&td, klass->valuetype ? field->offset - sizeof(MonoObject) : field->offset);
+                       }
+                       if (mt == MINT_TYPE_VT) {
+                               MonoClass *klass = mono_class_from_mono_type (field->type);
+                               int size = mono_class_value_size (klass, NULL);
+                               POP_VT(&td, size);
+                               WRITE32(&td, &size);
+                       }
+                       td.ip += 5;
+                       td.sp -= 2;
+                       break;
+               case CEE_LDSFLDA:
+                       token = read32 (td.ip + 1);
+                       field = mono_field_from_token (image, token, &klass, generic_context);
+                       ADD_CODE(&td, MINT_LDSFLDA);
+                       ADD_CODE(&td, get_data_item_index (&td, field));
+                       td.ip += 5;
+                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_MP);
+                       break;
+               case CEE_LDSFLD:
+                       token = read32 (td.ip + 1);
+                       field = mono_field_from_token (image, token, &klass, generic_context);
+                       mt = mint_type(field->type);
+                       ADD_CODE(&td, mt == MINT_TYPE_VT ? MINT_LDSFLD_VT : MINT_LDSFLD);
+                       ADD_CODE(&td, get_data_item_index (&td, field));
+                       klass = NULL;
+                       if (mt == MINT_TYPE_VT) {
+                               MonoClass *klass = mono_class_from_mono_type (field->type);
+                               int size = mono_class_value_size (klass, NULL);
+                               PUSH_VT(&td, size);
+                               WRITE32(&td, &size);
+                               klass = field->type->data.klass;
+                       } else {
+                               if (mt == MINT_TYPE_O) 
+                                       klass = mono_class_from_mono_type (field->type);
+                       }
+                       td.ip += 5;
+                       PUSH_TYPE(&td, stack_type [mt], klass);
+                       break;
+               case CEE_STSFLD:
+                       CHECK_STACK (&td, 1);
+                       token = read32 (td.ip + 1);
+                       field = mono_field_from_token (image, token, &klass, generic_context);
+                       mt = mint_type(field->type);
+                       ADD_CODE(&td, mt == MINT_TYPE_VT ? MINT_STSFLD_VT : MINT_STSFLD);
+                       ADD_CODE(&td, get_data_item_index (&td, field));
+                       if (mt == MINT_TYPE_VT) {
+                               MonoClass *klass = mono_class_from_mono_type (field->type);
+                               int size = mono_class_value_size (klass, NULL);
+                               POP_VT (&td, size);
+                               WRITE32 (&td, &size);
+                       }
+                       td.ip += 5;
+                       --td.sp;
+                       break;
+               case CEE_STOBJ: {
+                       int size;
+                       token = read32 (td.ip + 1);
+
+                       if (method->wrapper_type != MONO_WRAPPER_NONE)
+                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
+                       else
+                               klass = mono_class_get_full (image, token, generic_context);
+
+                       ADD_CODE(&td, td.sp [-1].type == STACK_TYPE_VT ? MINT_STOBJ_VT : MINT_STOBJ);
+                       ADD_CODE(&td, get_data_item_index (&td, klass));
+                       if (td.sp [-1].type == STACK_TYPE_VT) {
+                               size = mono_class_value_size (klass, NULL);
+                               size = (size + 7) & ~7;
+                               td.vt_sp -= size;
+                       }
+                       td.ip += 5;
+                       td.sp -= 2;
+                       break;
+               }
+               case CEE_CONV_OVF_I_UN:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+#if SIZEOF_VOID_P == 8
+                               ADD_CODE(&td, MINT_CONV_OVF_I8_UN_R8);
+#else
+                               ADD_CODE(&td, MINT_CONV_OVF_I4_UN_R8);
+#endif
+                               break;
+                       case STACK_TYPE_I8:
+                               /*FIX*/
+                               break;
+                       case STACK_TYPE_I4:
+#if SIZEOF_VOID_P == 8
+                               ADD_CODE(&td, MINT_CONV_I8_U4);
+#endif
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                               break;
+                       }
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
+                       ++td.ip;
+                       break;
+               case CEE_CONV_OVF_I8_UN:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_OVF_I8_UN_R8);
+                               break;
+                       case STACK_TYPE_I8:
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_I8_U4);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                               break;
+                       }
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
+                       ++td.ip;
+                       break;
+               case CEE_BOX: {
+                       int size;
+                       CHECK_STACK (&td, 1);
+                       token = read32 (td.ip + 1);
+                       if (method->wrapper_type != MONO_WRAPPER_NONE)
+                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
+                       else
+                               klass = mono_class_get_full (image, token, generic_context);
+
+                       if (mono_class_is_nullable (klass)) {
+                               MonoMethod *target_method = mono_class_get_method_from_name (klass, "Box", 1);
+                               /* td.ip is incremented by interp_transform_call */
+                               interp_transform_call (&td, method, target_method, domain, generic_context, is_bb_start, body_start_offset, NULL);
+                       } else if (!klass->valuetype) {
+                               /* already boxed, do nothing. */
+                               td.ip += 5;
+                       } else {
+                               if (mint_type (&klass->byval_arg) == MINT_TYPE_VT && !klass->enumtype) {
+                                       size = mono_class_value_size (klass, NULL);
+                                       size = (size + 7) & ~7;
+                                       td.vt_sp -= size;
+                               }
+                               ADD_CODE(&td, MINT_BOX);
+                               ADD_CODE(&td, get_data_item_index (&td, klass));
+                               ADD_CODE (&td, 0);
+                               SET_TYPE(td.sp - 1, STACK_TYPE_O, klass);
+                               td.ip += 5;
+                       }
+
+                       break;
+               }
+               case CEE_NEWARR:
+                       CHECK_STACK (&td, 1);
+                       token = read32 (td.ip + 1);
+
+                       if (method->wrapper_type != MONO_WRAPPER_NONE)
+                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
+                       else
+                               klass = mono_class_get_full (image, token, generic_context);
+
+                       ADD_CODE(&td, MINT_NEWARR);
+                       ADD_CODE(&td, get_data_item_index (&td, klass));
+                       SET_TYPE(td.sp - 1, STACK_TYPE_O, klass);
+                       td.ip += 5;
+                       break;
+               case CEE_LDLEN:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_LDLEN);
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I);
+                       break;
+               case CEE_LDELEMA:
+                       CHECK_STACK (&td, 2);
+                       ENSURE_I4 (&td, 1);
+                       token = read32 (td.ip + 1);
+
+                       if (method->wrapper_type != MONO_WRAPPER_NONE)
+                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
+                       else
+                               klass = mono_class_get_full (image, token, generic_context);
+
+                       ADD_CODE(&td, MINT_LDELEMA);
+                       ADD_CODE(&td, get_data_item_index (&td, klass));
+                       td.ip += 5;
+                       --td.sp;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
+                       break;
+               case CEE_LDELEM_I1:
+                       CHECK_STACK (&td, 2);
+                       ENSURE_I4 (&td, 1);
+                       SIMPLE_OP (td, MINT_LDELEM_I1);
+                       --td.sp;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_LDELEM_U1:
+                       CHECK_STACK (&td, 2);
+                       ENSURE_I4 (&td, 1);
+                       SIMPLE_OP (td, MINT_LDELEM_U1);
+                       --td.sp;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_LDELEM_I2:
+                       CHECK_STACK (&td, 2);
+                       ENSURE_I4 (&td, 1);
+                       SIMPLE_OP (td, MINT_LDELEM_I2);
+                       --td.sp;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_LDELEM_U2:
+                       CHECK_STACK (&td, 2);
+                       ENSURE_I4 (&td, 1);
+                       SIMPLE_OP (td, MINT_LDELEM_U2);
+                       --td.sp;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_LDELEM_I4:
+                       CHECK_STACK (&td, 2);
+                       ENSURE_I4 (&td, 1);
+                       SIMPLE_OP (td, MINT_LDELEM_I4);
+                       --td.sp;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_LDELEM_U4:
+                       CHECK_STACK (&td, 2);
+                       ENSURE_I4 (&td, 1);
+                       SIMPLE_OP (td, MINT_LDELEM_U4);
+                       --td.sp;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_LDELEM_I8:
+                       CHECK_STACK (&td, 2);
+                       ENSURE_I4 (&td, 1);
+                       SIMPLE_OP (td, MINT_LDELEM_I8);
+                       --td.sp;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
+                       break;
+               case CEE_LDELEM_I:
+                       CHECK_STACK (&td, 2);
+                       ENSURE_I4 (&td, 1);
+                       SIMPLE_OP (td, MINT_LDELEM_I);
+                       --td.sp;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I);
+                       break;
+               case CEE_LDELEM_R4:
+                       CHECK_STACK (&td, 2);
+                       ENSURE_I4 (&td, 1);
+                       SIMPLE_OP (td, MINT_LDELEM_R4);
+                       --td.sp;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
+                       break;
+               case CEE_LDELEM_R8:
+                       CHECK_STACK (&td, 2);
+                       ENSURE_I4 (&td, 1);
+                       SIMPLE_OP (td, MINT_LDELEM_R8);
+                       --td.sp;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
+                       break;
+               case CEE_LDELEM_REF:
+                       CHECK_STACK (&td, 2);
+                       ENSURE_I4 (&td, 1);
+                       SIMPLE_OP (td, MINT_LDELEM_REF);
+                       --td.sp;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_O);
+                       break;
+               case CEE_LDELEM:
+                       CHECK_STACK (&td, 2);
+                       token = read32 (td.ip + 1);
+                       klass = mono_class_get_full (image, token, generic_context);
+                       switch (mint_type (&klass->byval_arg)) {
+                               case MINT_TYPE_I1:
+                                       ENSURE_I4 (&td, 1);
+                                       SIMPLE_OP (td, MINT_LDELEM_I1);
+                                       --td.sp;
+                                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                                       break;
+                               case MINT_TYPE_U1:
+                                       ENSURE_I4 (&td, 1);
+                                       SIMPLE_OP (td, MINT_LDELEM_U1);
+                                       --td.sp;
+                                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                                       break;
+                               case MINT_TYPE_U2:
+                                       ENSURE_I4 (&td, 1);
+                                       SIMPLE_OP (td, MINT_LDELEM_U2);
+                                       --td.sp;
+                                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                                       break;
+                               case MINT_TYPE_I2:
+                                       ENSURE_I4 (&td, 1);
+                                       SIMPLE_OP (td, MINT_LDELEM_I2);
+                                       --td.sp;
+                                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                                       break;
+                               case MINT_TYPE_I4:
+                                       ENSURE_I4 (&td, 1);
+                                       SIMPLE_OP (td, MINT_LDELEM_I4);
+                                       --td.sp;
+                                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                                       break;
+                               case MINT_TYPE_I8:
+                                       ENSURE_I4 (&td, 1);
+                                       SIMPLE_OP (td, MINT_LDELEM_I8);
+                                       --td.sp;
+                                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
+                                       break;
+                               case MINT_TYPE_R4:
+                                       ENSURE_I4 (&td, 1);
+                                       SIMPLE_OP (td, MINT_LDELEM_R4);
+                                       --td.sp;
+                                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
+                                       break;
+                               case MINT_TYPE_R8:
+                                       ENSURE_I4 (&td, 1);
+                                       SIMPLE_OP (td, MINT_LDELEM_R8);
+                                       --td.sp;
+                                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
+                                       break;
+                               case MINT_TYPE_O:
+                                       ENSURE_I4 (&td, 1);
+                                       SIMPLE_OP (td, MINT_LDELEM_REF);
+                                       --td.sp;
+                                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_O);
+                                       break;
+                               case MINT_TYPE_VT: {
+                                       int size = mono_class_value_size (klass, NULL);
+                                       ENSURE_I4 (&td, 1);
+                                       SIMPLE_OP (td, MINT_LDELEM_VT);
+                                       ADD_CODE (&td, get_data_item_index (&td, klass));
+                                       WRITE32 (&td, &size);
+                                       --td.sp;
+                                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_VT);
+                                       PUSH_VT (&td, size);
+                                       break;
+                               }
+                               default: {
+                                       GString *res = g_string_new ("");
+                                       mono_type_get_desc (res, &klass->byval_arg, TRUE);
+                                       g_print ("LDELEM: %s -> %d (%s)\n", klass->name, mint_type (&klass->byval_arg), res->str);
+                                       g_string_free (res, TRUE);
+                                       g_assert (0);
+                                       break;
+                               }
+                       }
+                       td.ip += 4;
+                       break;
+               case CEE_STELEM_I:
+                       CHECK_STACK (&td, 3);
+                       ENSURE_I4 (&td, 2);
+                       SIMPLE_OP (td, MINT_STELEM_I);
+                       td.sp -= 3;
+                       break;
+               case CEE_STELEM_I1:
+                       CHECK_STACK (&td, 3);
+                       ENSURE_I4 (&td, 2);
+                       SIMPLE_OP (td, MINT_STELEM_I1);
+                       td.sp -= 3;
+                       break;
+               case CEE_STELEM_I2:
+                       CHECK_STACK (&td, 3);
+                       ENSURE_I4 (&td, 2);
+                       SIMPLE_OP (td, MINT_STELEM_I2);
+                       td.sp -= 3;
+                       break;
+               case CEE_STELEM_I4:
+                       CHECK_STACK (&td, 3);
+                       ENSURE_I4 (&td, 2);
+                       SIMPLE_OP (td, MINT_STELEM_I4);
+                       td.sp -= 3;
+                       break;
+               case CEE_STELEM_I8:
+                       CHECK_STACK (&td, 3);
+                       ENSURE_I4 (&td, 2);
+                       SIMPLE_OP (td, MINT_STELEM_I8);
+                       td.sp -= 3;
+                       break;
+               case CEE_STELEM_R4:
+                       CHECK_STACK (&td, 3);
+                       ENSURE_I4 (&td, 2);
+                       SIMPLE_OP (td, MINT_STELEM_R4);
+                       td.sp -= 3;
+                       break;
+               case CEE_STELEM_R8:
+                       CHECK_STACK (&td, 3);
+                       ENSURE_I4 (&td, 2);
+                       SIMPLE_OP (td, MINT_STELEM_R8);
+                       td.sp -= 3;
+                       break;
+               case CEE_STELEM_REF:
+                       CHECK_STACK (&td, 3);
+                       ENSURE_I4 (&td, 2);
+                       SIMPLE_OP (td, MINT_STELEM_REF);
+                       td.sp -= 3;
+                       break;
+               case CEE_STELEM:
+                       CHECK_STACK (&td, 3);
+                       ENSURE_I4 (&td, 2);
+                       token = read32 (td.ip + 1);
+                       klass = mono_class_get_full (image, token, generic_context);
+                       switch (mint_type (&klass->byval_arg)) {
+                               case MINT_TYPE_I4:
+                                       SIMPLE_OP (td, MINT_STELEM_I4);
+                                       break;
+                               case MINT_TYPE_O:
+                                       SIMPLE_OP (td, MINT_STELEM_REF);
+                                       break;
+                               case MINT_TYPE_VT: {
+                                       int size = mono_class_value_size (klass, NULL);
+                                       SIMPLE_OP (td, MINT_STELEM_VT);
+                                       ADD_CODE (&td, get_data_item_index (&td, klass));
+                                       WRITE32 (&td, &size);
+                                       POP_VT (&td, size);
+                                       break;
+                               }
+                               default: {
+                                       GString *res = g_string_new ("");
+                                       mono_type_get_desc (res, &klass->byval_arg, TRUE);
+                                       g_print ("STELEM: %s -> %d (%s)\n", klass->name, mint_type (&klass->byval_arg), res->str);
+                                       g_string_free (res, TRUE);
+                                       g_assert (0);
+                                       break;
+                               }
+                       }
+                       td.ip += 4;
+                       td.sp -= 3;
+                       break;
+#if 0
+               case CEE_CONV_OVF_U1:
+
+               case CEE_CONV_OVF_I8:
+
+#if SIZEOF_VOID_P == 8
+               case CEE_CONV_OVF_U:
+#endif
+               case CEE_REFANYVAL: ves_abort(); break;
+#endif
+               case CEE_CKFINITE:
+                       CHECK_STACK (&td, 1);
+                       SIMPLE_OP (td, MINT_CKFINITE);
+                       break;
+               case CEE_CONV_OVF_I1:
+               case CEE_CONV_OVF_I1_UN:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_OVF_I1_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_OVF_I1_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_OVF_I1_I8);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_CONV_OVF_U1:
+               case CEE_CONV_OVF_U1_UN:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_OVF_U1_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_OVF_U1_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_OVF_U1_I8);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_CONV_OVF_I2:
+               case CEE_CONV_OVF_I2_UN:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_OVF_I2_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_OVF_I2_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_OVF_I2_I8);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+               case CEE_CONV_OVF_U2_UN:
+               case CEE_CONV_OVF_U2:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_OVF_U2_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_OVF_U2_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_OVF_U2_I8);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+#if SIZEOF_VOID_P == 4
+               case CEE_CONV_OVF_I:
+#endif
+               case CEE_CONV_OVF_I4:
+               case CEE_CONV_OVF_I4_UN:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_OVF_I4_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               if (*td.ip == CEE_CONV_OVF_I4_UN)
+                                       ADD_CODE(&td, MINT_CONV_OVF_I4_U4);
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_OVF_I4_I8);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+#if SIZEOF_VOID_P == 4
+               case CEE_CONV_OVF_U:
+#endif
+               case CEE_CONV_OVF_U4:
+               case CEE_CONV_OVF_U4_UN:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_OVF_U4_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               if (*td.ip != CEE_CONV_OVF_U4_UN)
+                                       ADD_CODE(&td, MINT_CONV_OVF_U4_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               ADD_CODE(&td, MINT_CONV_OVF_U4_I8);
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                       break;
+#if SIZEOF_VOID_P == 8
+               case CEE_CONV_OVF_I:
+#endif
+               case CEE_CONV_OVF_I8:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_OVF_I8_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_I8_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
+                       break;
+#if SIZEOF_VOID_P == 8
+               case CEE_CONV_OVF_U:
+#endif
+               case CEE_CONV_OVF_U8:
+                       CHECK_STACK (&td, 1);
+                       switch (td.sp [-1].type) {
+                       case STACK_TYPE_R8:
+                               ADD_CODE(&td, MINT_CONV_OVF_U8_R8);
+                               break;
+                       case STACK_TYPE_I4:
+                               ADD_CODE(&td, MINT_CONV_OVF_U8_I4);
+                               break;
+                       case STACK_TYPE_I8:
+                               break;
+                       default:
+                               g_assert_not_reached ();
+                       }
+                       ++td.ip;
+                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
+                       break;
+               case CEE_LDTOKEN: {
+                       int size;
+                       gpointer handle;
+                       token = read32 (td.ip + 1);
+                       if (method->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD || method->wrapper_type == MONO_WRAPPER_SYNCHRONIZED) {
+                               handle = mono_method_get_wrapper_data (method, token);
+                               klass = (MonoClass *) mono_method_get_wrapper_data (method, token + 1);
+                               if (klass == mono_defaults.typehandle_class)
+                                       handle = &((MonoClass *) handle)->byval_arg;
+                       } else {
+                               handle = mono_ldtoken (image, token, &klass, generic_context);
+                       }
+                       mt = mint_type(&klass->byval_arg);
+                       g_assert (mt == MINT_TYPE_VT);
+                       size = mono_class_value_size (klass, NULL);
+                       g_assert (size == sizeof(gpointer));
+                       PUSH_VT(&td, sizeof(gpointer));
+                       ADD_CODE(&td, MINT_LDTOKEN);
+                       ADD_CODE(&td, get_data_item_index (&td, handle));
+                       PUSH_SIMPLE_TYPE(&td, stack_type [mt]);
+                       td.ip += 5;
+                       break;
+               }
+               case CEE_ADD_OVF:
+                       binary_arith_op(&td, MINT_ADD_OVF_I4);
+                       ++td.ip;
+                       break;
+               case CEE_ADD_OVF_UN:
+                       binary_arith_op(&td, MINT_ADD_OVF_UN_I4);
+                       ++td.ip;
+                       break;
+               case CEE_MUL_OVF:
+                       binary_arith_op(&td, MINT_MUL_OVF_I4);
+                       ++td.ip;
+                       break;
+               case CEE_MUL_OVF_UN:
+                       binary_arith_op(&td, MINT_MUL_OVF_UN_I4);
+                       ++td.ip;
+                       break;
+               case CEE_SUB_OVF:
+                       binary_arith_op(&td, MINT_SUB_OVF_I4);
+                       ++td.ip;
+                       break;
+               case CEE_SUB_OVF_UN:
+                       binary_arith_op(&td, MINT_SUB_OVF_UN_I4);
+                       ++td.ip;
+                       break;
+               case CEE_ENDFINALLY:
+                       SIMPLE_OP (td, MINT_ENDFINALLY);
+                       generating_code = 0;
+                       break;
+               case CEE_LEAVE:
+                       td.sp = td.stack;
+                       handle_branch (&td, MINT_LEAVE_S, MINT_LEAVE, 5 + read32 (td.ip + 1));
+                       td.ip += 5;
+                       generating_code = 0;
+                       break;
+               case CEE_LEAVE_S:
+                       td.sp = td.stack;
+                       handle_branch (&td, MINT_LEAVE_S, MINT_LEAVE, 2 + (gint8)td.ip [1]);
+                       td.ip += 2;
+                       generating_code = 0;
+                       break;
+               case CEE_UNUSED41:
+                       ++td.ip;
+                       switch (*td.ip) {
+                               case CEE_MONO_CALLI_EXTRA_ARG:
+                                       /* Same as CEE_CALLI, except that we drop the extra arg required for llvm specific behaviour */
+                                       ADD_CODE (&td, MINT_POP);
+                                       ADD_CODE (&td, 1);
+                                       --td.sp;
+                                       interp_transform_call (&td, method, NULL, domain, generic_context, is_bb_start, body_start_offset, NULL);
+                                       break;
+                               case CEE_MONO_JIT_ICALL_ADDR: {
+                                       guint32 token;
+                                       gpointer func;
+                                       MonoJitICallInfo *info;
+
+                                       token = read32 (td.ip + 1);
+                                       td.ip += 5;
+                                       func = mono_method_get_wrapper_data (method, token);
+                                       info = mono_find_jit_icall_by_addr (func);
+
+                                       ADD_CODE (&td, MINT_LDFTN);
+                                       ADD_CODE (&td, get_data_item_index (&td, func));
+                                       PUSH_SIMPLE_TYPE (&td, STACK_TYPE_I);
+                                       break;
+                               }
+                               case CEE_MONO_ICALL: {
+                                       guint32 token;
+                                       gpointer func;
+                                       MonoJitICallInfo *info;
+
+                                       token = read32 (td.ip + 1);
+                                       td.ip += 5;
+                                       func = mono_method_get_wrapper_data (method, token);
+                                       info = mono_find_jit_icall_by_addr (func);
+                                       g_assert (info);
+
+                                       CHECK_STACK (&td, info->sig->param_count);
+                                       switch (info->sig->param_count) {
+                                       case 0:
+                                               if (MONO_TYPE_IS_VOID (info->sig->ret))
+                                                       ADD_CODE (&td,MINT_ICALL_V_V);
+                                               else
+                                                       ADD_CODE (&td, MINT_ICALL_V_P);
+                                               break;
+                                       case 1:
+                                               if (MONO_TYPE_IS_VOID (info->sig->ret))
+                                                       ADD_CODE (&td,MINT_ICALL_P_V);
+                                               else
+                                                       ADD_CODE (&td,MINT_ICALL_P_P);
+                                               break;
+                                       case 2:
+                                               if (MONO_TYPE_IS_VOID (info->sig->ret)) {
+                                                       if (info->sig->params [1]->type == MONO_TYPE_I4)
+                                                               ADD_CODE (&td,MINT_ICALL_PI_V);
+                                                       else
+                                                               ADD_CODE (&td,MINT_ICALL_PP_V);
+                                               } else {
+                                                       if (info->sig->params [1]->type == MONO_TYPE_I4)
+                                                               ADD_CODE (&td,MINT_ICALL_PI_P);
+                                                       else
+                                                               ADD_CODE (&td,MINT_ICALL_PP_P);
+                                               }
+                                               break;
+                                       case 3:
+                                               g_assert (MONO_TYPE_IS_VOID (info->sig->ret));
+                                               if (info->sig->params [2]->type == MONO_TYPE_I4)
+                                                       ADD_CODE (&td,MINT_ICALL_PPI_V);
+                                               else
+                                                       ADD_CODE (&td,MINT_ICALL_PPP_V);
+                                               break;
+                                       default:
+                                               g_assert_not_reached ();
+                                       }
+
+                                       if (func == mono_ftnptr_to_delegate) {
+                                               g_error ("TODO: ?");
+                                       }
+                                       ADD_CODE(&td, get_data_item_index (&td, func));
+                                       td.sp -= info->sig->param_count;
+
+                                       if (!MONO_TYPE_IS_VOID (info->sig->ret)) {
+                                               td.sp ++;
+                                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I);
+                                       }
+                                       break;
+                               }
+                       case CEE_MONO_VTADDR: {
+                               int size;
+                               CHECK_STACK (&td, 1);
+                               if (method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE)
+                                       size = mono_class_native_size(td.sp [-1].klass, NULL);
+                               else
+                                       size = mono_class_value_size(td.sp [-1].klass, NULL);
+                               size = (size + 7) & ~7;
+                               ADD_CODE(&td, MINT_VTRESULT);
+                               ADD_CODE(&td, 0);
+                               WRITE32(&td, &size);
+                               td.vt_sp -= size;
+                               ++td.ip;
+                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
+                               break;
+                       }
+                       case CEE_MONO_LDPTR:
+                       case CEE_MONO_CLASSCONST:
+                               token = read32 (td.ip + 1);
+                               td.ip += 5;
+                               ADD_CODE(&td, MINT_MONO_LDPTR);
+                               ADD_CODE(&td, get_data_item_index (&td, mono_method_get_wrapper_data (method, token)));
+                               td.sp [0].type = STACK_TYPE_I;
+                               ++td.sp;
+                               break;
+                       case CEE_MONO_OBJADDR:
+                               CHECK_STACK (&td, 1);
+                               ++td.ip;
+                               td.sp[-1].type = STACK_TYPE_MP;
+                               /* do nothing? */
+                               break;
+                       case CEE_MONO_NEWOBJ:
+                               token = read32 (td.ip + 1);
+                               td.ip += 5;
+                               ADD_CODE(&td, MINT_MONO_NEWOBJ);
+                               ADD_CODE(&td, get_data_item_index (&td, mono_method_get_wrapper_data (method, token)));
+                               td.sp [0].type = STACK_TYPE_O;
+                               ++td.sp;
+                               break;
+                       case CEE_MONO_RETOBJ:
+                               CHECK_STACK (&td, 1);
+                               token = read32 (td.ip + 1);
+                               td.ip += 5;
+                               ADD_CODE(&td, MINT_MONO_RETOBJ);
+                               td.sp--;
+
+                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
+                               
+                               /*stackval_from_data (signature->ret, frame->retval, sp->data.vt, signature->pinvoke);*/
+
+                               if (td.sp > td.stack)
+                                       g_warning ("CEE_MONO_RETOBJ: more values on stack: %d", td.sp-td.stack);
+                               break;
+                       case CEE_MONO_LDNATIVEOBJ:
+                               token = read32 (td.ip + 1);
+                               td.ip += 5;
+                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
+                               g_assert(klass->valuetype);
+                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
+                               break;
+                       case CEE_MONO_SAVE_LMF:
+                       case CEE_MONO_RESTORE_LMF:
+                       case CEE_MONO_NOT_TAKEN:
+                               ++td.ip;
+                               break;
+                       case CEE_MONO_LDPTR_INT_REQ_FLAG:
+                               ADD_CODE (&td, MINT_MONO_LDPTR);
+                               ADD_CODE (&td, get_data_item_index (&td, mono_thread_interruption_request_flag ()));
+                               PUSH_TYPE (&td, STACK_TYPE_MP, NULL);
+                               ++td.ip;
+                               break;
+                       default:
+                               g_error ("transform.c: Unimplemented opcode: 0xF0 %02x at 0x%x\n", *td.ip, td.ip-header->code);
+                       }
+                       break;
+#if 0
+               case CEE_PREFIX7:
+               case CEE_PREFIX6:
+               case CEE_PREFIX5:
+               case CEE_PREFIX4:
+               case CEE_PREFIX3:
+               case CEE_PREFIX2:
+               case CEE_PREFIXREF: ves_abort(); break;
+#endif
+               /*
+                * Note: Exceptions thrown when executing a prefixed opcode need
+                * to take into account the number of prefix bytes (usually the
+                * throw point is just (ip - n_prefix_bytes).
+                */
+               case CEE_PREFIX1: 
+                       ++td.ip;
+                       switch (*td.ip) {
+#if 0
+                       case CEE_ARGLIST: ves_abort(); break;
+#endif
+                       case CEE_CEQ:
+                               CHECK_STACK(&td, 2);
+                               if (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_MP)
+                                       ADD_CODE(&td, MINT_CEQ_I4 + STACK_TYPE_I - STACK_TYPE_I4);
+                               else
+                                       ADD_CODE(&td, MINT_CEQ_I4 + td.sp [-1].type - STACK_TYPE_I4);
+                               --td.sp;
+                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                               ++td.ip;
+                               break;
+                       case CEE_CGT:
+                               CHECK_STACK(&td, 2);
+                               if (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_MP)
+                                       ADD_CODE(&td, MINT_CGT_I4 + STACK_TYPE_I - STACK_TYPE_I4);
+                               else
+                                       ADD_CODE(&td, MINT_CGT_I4 + td.sp [-1].type - STACK_TYPE_I4);
+                               --td.sp;
+                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                               ++td.ip;
+                               break;
+                       case CEE_CGT_UN:
+                               CHECK_STACK(&td, 2);
+                               if (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_MP)
+                                       ADD_CODE(&td, MINT_CGT_UN_I4 + STACK_TYPE_I - STACK_TYPE_I4);
+                               else
+                                       ADD_CODE(&td, MINT_CGT_UN_I4 + td.sp [-1].type - STACK_TYPE_I4);
+                               --td.sp;
+                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                               ++td.ip;
+                               break;
+                       case CEE_CLT:
+                               CHECK_STACK(&td, 2);
+                               if (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_MP)
+                                       ADD_CODE(&td, MINT_CLT_I4 + STACK_TYPE_I - STACK_TYPE_I4);
+                               else
+                                       ADD_CODE(&td, MINT_CLT_I4 + td.sp [-1].type - STACK_TYPE_I4);
+                               --td.sp;
+                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                               ++td.ip;
+                               break;
+                       case CEE_CLT_UN:
+                               CHECK_STACK(&td, 2);
+                               if (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_MP)
+                                       ADD_CODE(&td, MINT_CLT_UN_I4 + STACK_TYPE_I - STACK_TYPE_I4);
+                               else
+                                       ADD_CODE(&td, MINT_CLT_UN_I4 + td.sp [-1].type - STACK_TYPE_I4);
+                               --td.sp;
+                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
+                               ++td.ip;
+                               break;
+                       case CEE_LDVIRTFTN: /* fallthrough */
+                       case CEE_LDFTN: {
+                               MonoMethod *m;
+                               if (*td.ip == CEE_LDVIRTFTN) {
+                                       CHECK_STACK (&td, 1);
+                                       --td.sp;
+                               }
+                               token = read32 (td.ip + 1);
+                               if (method->wrapper_type != MONO_WRAPPER_NONE)
+                                       m = (MonoMethod *)mono_method_get_wrapper_data (method, token);
+                               else 
+                                       m = mono_get_method_full (image, token, NULL, generic_context);
+
+                               if (method->wrapper_type == MONO_WRAPPER_NONE && m->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
+                                       m = mono_marshal_get_synchronized_wrapper (m);
+
+                               ADD_CODE(&td, *td.ip == CEE_LDFTN ? MINT_LDFTN : MINT_LDVIRTFTN);
+                               ADD_CODE(&td, get_data_item_index (&td, mono_interp_get_runtime_method (domain, m, &error)));
+                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
+                               td.ip += 5;
+                               PUSH_SIMPLE_TYPE (&td, STACK_TYPE_F);
+                               break;
+                       }
+                       case CEE_LDARG:
+                               load_arg (&td, read16 (td.ip + 1));
+                               td.ip += 3;
+                               break;
+                       case CEE_LDARGA: {
+                               int n = read16 (td.ip + 1);
+                               if (n == 0 && signature->hasthis) {
+                                       g_error ("LDTHISA: NOPE");
+                                       ADD_CODE(&td, MINT_LDTHISA);
+                               }
+                               else {
+                                       ADD_CODE(&td, MINT_LDARGA);
+                                       ADD_CODE(&td, td.rtm->arg_offsets [n]); /* FIX for large offsets */
+                               }
+                               PUSH_SIMPLE_TYPE(&td, STACK_TYPE_MP);
+                               td.ip += 3;
+                               break;
+                       }
+                       case CEE_STARG:
+                               store_arg (&td, read16 (td.ip + 1));
+                               td.ip += 3;
+                               break;
+                       case CEE_LDLOC:
+                               load_local (&td, read16 (td.ip + 1));
+                               td.ip += 3;
+                               break;
+                       case CEE_LDLOCA:
+                               ADD_CODE(&td, MINT_LDLOCA_S);
+                               ADD_CODE(&td, td.rtm->local_offsets [read16 (td.ip + 1)]);
+                               PUSH_SIMPLE_TYPE(&td, STACK_TYPE_MP);
+                               td.ip += 3;
+                               break;
+                       case CEE_STLOC:
+                               store_local (&td, read16 (td.ip + 1));
+                               td.ip += 3;
+                               break;
+                       case CEE_LOCALLOC:
+                               CHECK_STACK (&td, 1);
+#if SIZEOF_VOID_P == 8
+                               if (td.sp [-1].type == STACK_TYPE_I8)
+                                       ADD_CODE(&td, MINT_CONV_I4_I8);
+#endif                         
+                               ADD_CODE(&td, MINT_LOCALLOC);
+                               if (td.sp != td.stack + 1)
+                                       g_warning("CEE_LOCALLOC: stack not empty");
+                               ++td.ip;
+                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
+                               break;
+#if 0
+                       case CEE_UNUSED57: ves_abort(); break;
+                       case CEE_ENDFILTER: ves_abort(); break;
+#endif
+                       case CEE_UNALIGNED_:
+                               ++td.ip;
+                               /* FIX: should do something? */;
+                               break;
+                       case CEE_VOLATILE_:
+                               ++td.ip;
+                               /* FIX: should do something? */;
+                               break;
+                       case CEE_TAIL_:
+                               ++td.ip;
+                               /* FIX: should do something? */;
+                               break;
+                       case CEE_INITOBJ:
+                               CHECK_STACK(&td, 1);
+                               token = read32 (td.ip + 1);
+                               klass = mono_class_get_full (image, token, generic_context);
+                               ADD_CODE(&td, MINT_INITOBJ);
+                               i32 = mono_class_value_size (klass, NULL);
+                               WRITE32(&td, &i32);
+                               td.ip += 5;
+                               --td.sp;
+                               break;
+                       case CEE_CPBLK:
+                               CHECK_STACK(&td, 3);
+                               /* FIX? convert length to I8? */
+                               ADD_CODE(&td, MINT_CPBLK);
+                               td.sp -= 3;
+                               ++td.ip;
+                               break;
+                       case CEE_CONSTRAINED_:
+                               token = read32 (td.ip + 1);
+                               constrained_class = mono_class_get_full (image, token, generic_context);
+                               mono_class_init (constrained_class);
+                               td.ip += 5;
+                               break;
+                       case CEE_INITBLK:
+                               CHECK_STACK(&td, 3);
+                               ADD_CODE(&td, MINT_INITBLK);
+                               td.sp -= 3;
+                               break;
+#if 0
+                       case CEE_NO_:
+                               /* FIXME: implement */
+                               ip += 2;
+                               break;
+#endif
+                       case CEE_RETHROW:
+                               SIMPLE_OP (td, MINT_RETHROW);
+                               generating_code = 0;
+                               break;
+                       case CEE_SIZEOF: {
+                               gint32 size;
+                               token = read32 (td.ip + 1);
+                               td.ip += 5;
+                               if (mono_metadata_token_table (token) == MONO_TABLE_TYPESPEC) {
+                                       int align;
+                                       MonoType *type = mono_type_create_from_typespec (image, token);
+                                       size = mono_type_size (type, &align);
+                               } else {
+                                       guint32 align;
+                                       MonoClass *szclass = mono_class_get_full (image, token, generic_context);
+                                       mono_class_init (szclass);
+#if 0
+                                       if (!szclass->valuetype)
+                                               THROW_EX (mono_exception_from_name (mono_defaults.corlib, "System", "InvalidProgramException"), ip - 5);
+#endif
+                                       size = mono_class_value_size (szclass, &align);
+                               } 
+                               ADD_CODE(&td, MINT_LDC_I4);
+                               WRITE32(&td, &size);
+                               PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
+                               break;
+                       }
+#if 0
+                       case CEE_REFANYTYPE: ves_abort(); break;
+#endif
+                       default:
+                               g_error ("transform.c: Unimplemented opcode: 0xFE %02x (%s) at 0x%x\n", *td.ip, mono_opcode_name (256 + *td.ip), td.ip-header->code);
+                       }
+                       break;
+               default:
+                       g_error ("transform.c: Unimplemented opcode: %02x at 0x%x\n", *td.ip, td.ip-header->code);
+               }
+
+               if (td.new_ip - td.new_code != new_in_start_offset) 
+                       td.last_new_ip = td.new_code + new_in_start_offset;
+               else if (td.is_bb_start [td.in_start - td.il_code])
+                       td.is_bb_start [td.ip - td.il_code] = 1;
+                       
+               td.last_ip = td.in_start;
+       }
+
+       if (mono_interp_traceopt) {
+               const guint16 *p = td.new_code;
+               printf("Runtime method: %p, VT stack size: %d\n", rtm, td.max_vt_sp);
+               printf("Calculated stack size: %d, stated size: %d\n", td.max_stack_height, header->max_stack);
+               while (p < td.new_ip) {
+                       p = mono_interp_dis_mintop(td.new_code, p);
+                       printf("\n");
+               }
+       }
+
+       rtm->clauses = mono_mempool_alloc (domain->mp, header->num_clauses * sizeof(MonoExceptionClause));
+       memcpy (rtm->clauses, header->clauses, header->num_clauses * sizeof(MonoExceptionClause));
+       rtm->code = mono_mempool_alloc (domain->mp, (td.new_ip - td.new_code) * sizeof(gushort));
+       memcpy (rtm->code, td.new_code, (td.new_ip - td.new_code) * sizeof(gushort));
+       g_free (td.new_code);
+       rtm->new_body_start = rtm->code + body_start_offset;
+       rtm->num_clauses = header->num_clauses;
+       for (i = 0; i < header->num_clauses; i++) {
+               MonoExceptionClause *c = rtm->clauses + i;
+               int end_off = c->try_offset + c->try_len;
+               c->try_offset = td.in_offsets [c->try_offset];
+               c->try_len = td.in_offsets [end_off] - c->try_offset;
+               end_off = c->handler_offset + c->handler_len;
+               c->handler_offset = td.in_offsets [c->handler_offset];
+               c->handler_len = td.in_offsets [end_off] - c->handler_offset;
+       }
+       rtm->vt_stack_size = td.max_vt_sp;
+       rtm->alloca_size = rtm->locals_size + rtm->args_size + rtm->vt_stack_size + rtm->stack_size;
+       rtm->data_items = mono_mempool_alloc (domain->mp, td.n_data_items * sizeof (td.data_items [0]));
+       memcpy (rtm->data_items, td.data_items, td.n_data_items * sizeof (td.data_items [0]));
+       g_free (td.in_offsets);
+       g_free (td.forward_refs);
+       for (i = 0; i < header->code_size; ++i)
+               g_free (td.stack_state [i]);
+       g_free (td.stack_state);
+       g_free (td.stack_height);
+       g_free (td.vt_stack_size);
+       g_free (td.data_items);
+       g_hash_table_destroy (td.data_hash);
+}
+
+static mono_mutex_t calc_section;
+
+void 
+mono_interp_transform_init (void)
+{
+       mono_os_mutex_init_recursive(&calc_section);
+}
+
+MonoException *
+mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *context)
+{
+       int i, align, size, offset;
+       MonoMethod *method = runtime_method->method;
+       MonoImage *image = method->klass->image;
+       MonoMethodHeader *header = mono_method_get_header (method);
+       MonoMethodSignature *signature = mono_method_signature (method);
+       register const unsigned char *ip, *end;
+       const MonoOpcode *opcode;
+       MonoMethod *m;
+       MonoClass *class;
+       MonoDomain *domain = mono_domain_get ();
+       unsigned char *is_bb_start;
+       int in;
+       MonoVTable *method_class_vt;
+       int backwards;
+       MonoGenericContext *generic_context = NULL;
+
+       // g_printerr ("TRANSFORM(0x%016lx): begin %s::%s\n", mono_thread_current (), method->klass->name, method->name);
+       method_class_vt = mono_class_vtable (domain, runtime_method->method->klass);
+       if (!method_class_vt->initialized) {
+               jmp_buf env;
+               MonoInvocation *last_env_frame = context->env_frame;
+               jmp_buf *old_env = context->current_env;
+
+               if (setjmp(env)) {
+                       MonoException *failed = context->env_frame->ex;
+                       context->env_frame->ex = NULL;
+                       context->env_frame = last_env_frame;
+                       context->current_env = old_env;
+                       return failed;
+               }
+               context->env_frame = context->current_frame;
+               context->current_env = &env;
+               mono_runtime_class_init (method_class_vt);
+               context->env_frame = last_env_frame;
+               context->current_env = old_env;
+       }
+
+       mono_profiler_method_jit (method); /* sort of... */
+
+       if (mono_method_signature (method)->is_inflated)
+               generic_context = mono_method_get_context (method);
+       else {
+               MonoGenericContainer *generic_container = mono_method_get_generic_container (method);
+               if (generic_container)
+                       generic_context = &generic_container->context;
+       }
+
+       if (method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME)) {
+               MonoMethod *nm = NULL;
+               mono_os_mutex_lock(&calc_section);
+               if (runtime_method->transformed) {
+                       mono_os_mutex_unlock(&calc_section);
+                       g_error ("FIXME: no jit info?");
+                       mono_profiler_method_end_jit (method, NULL, MONO_PROFILE_OK);
+                       return NULL;
+               }
+
+               /* assumes all internal calls with an array this are built in... */
+               if (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL && (! mono_method_signature (method)->hasthis || method->klass->rank == 0)) {
+                       nm = mono_marshal_get_native_wrapper (method, TRUE, FALSE);
+                       signature = mono_method_signature (nm);
+               } else {
+                       const char *name = method->name;
+                       if (method->klass->parent == mono_defaults.multicastdelegate_class) {
+                               if (*name == '.' && (strcmp (name, ".ctor") == 0)) {
+                                       MonoJitICallInfo *mi = mono_find_jit_icall_by_name ("ves_icall_mono_delegate_ctor");
+                                       g_assert (mi);
+                                       char *wrapper_name = g_strdup_printf ("__icall_wrapper_%s", mi->name);
+                                       nm = mono_marshal_get_icall_wrapper (mi->sig, wrapper_name, mi->func, TRUE);
+                               } else if (*name == 'I' && (strcmp (name, "Invoke") == 0)) {
+                                       nm = mono_marshal_get_delegate_invoke (method, NULL);
+                               } else if (*name == 'B' && (strcmp (name, "BeginInvoke") == 0)) {
+                                       nm = mono_marshal_get_delegate_begin_invoke (method);
+                               } else if (*name == 'E' && (strcmp (name, "EndInvoke") == 0)) {
+                                       nm = mono_marshal_get_delegate_end_invoke (method);
+                               }
+                       } 
+                       if (nm == NULL) {
+                               runtime_method->code = g_malloc(sizeof(short));
+                               runtime_method->code[0] = MINT_CALLRUN;
+                       }
+               }
+               if (nm == NULL) {
+                       runtime_method->stack_size = sizeof (stackval); /* for tracing */
+                       runtime_method->alloca_size = runtime_method->stack_size;
+                       runtime_method->transformed = TRUE;
+                       mono_os_mutex_unlock(&calc_section);
+                       mono_profiler_method_end_jit (method, NULL, MONO_PROFILE_OK);
+                       return NULL;
+               }
+               method = nm;
+               header = mono_method_get_header (nm);
+               mono_os_mutex_unlock(&calc_section);
+       }
+       g_assert ((signature->param_count + signature->hasthis) < 1000);
+       g_assert (header->max_stack < 10000);
+       /* intern the strings in the method. */
+       ip = header->code;
+       end = ip + header->code_size;
+
+       is_bb_start = g_malloc0(header->code_size);
+       is_bb_start [0] = 1;
+       while (ip < end) {
+               in = *ip;
+               if (in == 0xfe) {
+                       ip++;
+                       in = *ip + 256;
+               }
+               else if (in == 0xf0) {
+                       ip++;
+                       in = *ip + MONO_CEE_MONO_ICALL;
+               }
+               opcode = &mono_opcodes [in];
+               switch (opcode->argument) {
+               case MonoInlineNone:
+                       ++ip;
+                       break;
+               case MonoInlineString:
+                       if (method->wrapper_type == MONO_WRAPPER_NONE)
+                               mono_ldstr (domain, image, mono_metadata_token_index (read32 (ip + 1)));
+                       ip += 5;
+                       break;
+               case MonoInlineType:
+                       if (method->wrapper_type == MONO_WRAPPER_NONE) {
+                               class = mono_class_get_full (image, read32 (ip + 1), generic_context);
+                               mono_class_init (class);
+                               /* quick fix to not do this for the fake ptr classes - probably should not be getting the vtable at all here */
+#if 0
+                               g_error ("FIXME: interface method lookup: %s (in method %s)", class->name, method->name);
+                               if (!(class->flags & TYPE_ATTRIBUTE_INTERFACE) && class->interface_offsets != NULL)
+                                       mono_class_vtable (domain, class);
+#endif
+                       }
+                       ip += 5;
+                       break;
+               case MonoInlineMethod:
+                       if (method->wrapper_type == MONO_WRAPPER_NONE && *ip != CEE_CALLI) {
+                               m = mono_get_method_full (image, read32 (ip + 1), NULL, generic_context);
+                               if (m == NULL) {
+                                       g_free (is_bb_start);
+                                       g_error ("FIXME: where to get method and class string?"); 
+                                       return NULL;
+                                       // return mono_get_exception_missing_method ();
+                               }
+                               mono_class_init (m->klass);
+                               if (!mono_class_is_interface (m->klass))
+                                       mono_class_vtable (domain, m->klass);
+                       }
+                       ip += 5;
+                       break;
+               case MonoInlineField:
+               case MonoInlineSig:
+               case MonoInlineI:
+               case MonoInlineTok:
+               case MonoShortInlineR:
+                       ip += 5;
+                       break;
+               case MonoInlineBrTarget:
+                       offset = read32 (ip + 1);
+                       ip += 5;
+                       backwards = offset < 0;
+                       offset += ip - header->code;
+                       g_assert (offset >= 0 && offset < header->code_size);
+                       is_bb_start [offset] |= backwards ? 2 : 1;
+                       break;
+               case MonoShortInlineBrTarget:
+                       offset = ((gint8 *)ip) [1];
+                       ip += 2;
+                       backwards = offset < 0;
+                       offset += ip - header->code;
+                       g_assert (offset >= 0 && offset < header->code_size);
+                       is_bb_start [offset] |= backwards ? 2 : 1;
+                       break;
+               case MonoInlineVar:
+                       ip += 3;
+                       break;
+               case MonoShortInlineVar:
+               case MonoShortInlineI:
+                       ip += 2;
+                       break;
+               case MonoInlineSwitch: {
+                       guint32 n;
+                       const unsigned char *next_ip;
+                       ++ip;
+                       n = read32 (ip);
+                       ip += 4;
+                       next_ip = ip + 4 * n;
+                       for (i = 0; i < n; i++) {
+                               offset = read32 (ip);
+                               backwards = offset < 0;
+                               offset += next_ip - header->code;
+                               g_assert (offset >= 0 && offset < header->code_size);
+                               is_bb_start [offset] |= backwards ? 2 : 1;
+                               ip += 4;
+                       }
+                       break;
+               }
+               case MonoInlineR:
+               case MonoInlineI8:
+                       ip += 9;
+                       break;
+               default:
+                       g_assert_not_reached ();
+               }
+       }
+       // g_printerr ("TRANSFORM(0x%016lx): end %s::%s\n", mono_thread_current (), method->klass->name, method->name);
+
+       /* the rest needs to be locked so it is only done once */
+       mono_os_mutex_lock(&calc_section);
+       if (runtime_method->transformed) {
+               mono_os_mutex_unlock(&calc_section);
+               g_free (is_bb_start);
+               mono_profiler_method_end_jit (method, NULL, MONO_PROFILE_OK);
+               return NULL;
+       }
+
+       runtime_method->local_offsets = g_malloc (header->num_locals * sizeof(guint32));
+       runtime_method->stack_size = (sizeof (stackval) + 2) * header->max_stack; /* + 1 for returns of called functions  + 1 for 0-ing in trace*/
+       runtime_method->stack_size = (runtime_method->stack_size + 7) & ~7;
+       offset = 0;
+       for (i = 0; i < header->num_locals; ++i) {
+               size = mono_type_size (header->locals [i], &align);
+               offset += align - 1;
+               offset &= ~(align - 1);
+               runtime_method->local_offsets [i] = offset;
+               offset += size;
+       }
+       offset = (offset + 7) & ~7;
+       runtime_method->locals_size = offset;
+       g_assert (runtime_method->locals_size < 65536);
+       offset = 0;
+       runtime_method->arg_offsets = g_malloc ((!!signature->hasthis + signature->param_count) * sizeof(guint32));
+
+       if (signature->hasthis) {
+               g_assert (!signature->pinvoke);
+               size = mono_type_stack_size (&method->klass->byval_arg, &align);
+               offset += align - 1;
+               offset &= ~(align - 1);
+               runtime_method->arg_offsets [0] = offset;
+               offset += size;
+       }
+
+       for (i = 0; i < signature->param_count; ++i) {
+               if (signature->pinvoke) {
+                       guint32 dummy;
+                       size = mono_type_native_stack_size (signature->params [i], &dummy);
+                       align = 8;
+               }
+               else
+                       size = mono_type_stack_size (signature->params [i], &align);
+               offset += align - 1;
+               offset &= ~(align - 1);
+               runtime_method->arg_offsets [i + !!signature->hasthis] = offset;
+               offset += size;
+       }
+       offset = (offset + 7) & ~7;
+       runtime_method->args_size = offset;
+       g_assert (runtime_method->args_size < 10000);
+
+       generate (method, runtime_method, is_bb_start, generic_context);
+
+       g_free (is_bb_start);
+
+       mono_profiler_method_end_jit (method, NULL, MONO_PROFILE_OK);
+       runtime_method->transformed = TRUE;
+       mono_os_mutex_unlock(&calc_section);
+
+       return NULL;
+}
+
diff --git a/mono/mini/interpreter/hacks.h b/mono/mini/interpreter/hacks.h
deleted file mode 100644 (file)
index 9697ccb..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/* we need some special math function */
-#ifndef _ISOC99_SOURCE
-#define _ISOC99_SOURCE
-#endif
-#include <math.h>
-
-/* which are not defined on FreeBSD */
-#ifdef __GNUC__
-
-#ifndef isunordered
-#   define isunordered(u, v)                              \
-    (__extension__                                        \
-     ({ __typeof__(u) __u = (u); __typeof__(v) __v = (v); \
-        isnan(__u) || isnan(__v); }))
-#endif
-
-#ifndef islessgreater
-#   define islessgreater(x, u)                                    \
-    (__extension__                                                \
-     ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y);         \
-        !isunordered (__x, __y) && (__x < __y) || (__y < __x); }))
-#endif
-
-#ifndef islessequal
-#   define islessequal(x, y)                              \
-    (__extension__                                        \
-     ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
-        !isunordered(__x, __y) && __x <= __y; })) 
-#endif
-
-#ifndef isless
-#   define isless(x, y)                                   \
-    (__extension__                                        \
-     ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
-        !isunordered(__x, __y) && __x < __y; })) 
-#endif
-
-#ifndef isgreater
-#   define isgreater(x, y)                                \
-    (__extension__                                        \
-     ({ __typeof__(x) __x = (x); __typeof__(y) __y = (y); \
-        !isunordered(__x, __y) && __x > __y; }))
-#endif
-
-#else
-
-/*  isunordered seems to crash on HPUX when built 64 bits
-    so use generic implementation.
-*/
-#if defined(__hpux) && SIZEOF_VOID_P == 8
-#undef isunordered
-#undef islessgreater
-#undef islessequal
-#undef isless
-#undef isgreater
-#endif
-
-#ifndef isunordered
-#   define isunordered(u, v) (isnan(u) || isnan(v))
-#endif
-
-#ifndef islessgreater
-#   define islessgreater(x, u) (!isunordered (x, y) && (x < y) || (y < x))
-#endif
-
-#ifndef islessequal
-#   define islessequal(x, y) (!isunordered(x, y) && x <= y)
-#endif
-
-#ifndef isless
-#   define isless(x, y) (!isunordered(x, y) && x < y) 
-#endif
-
-#ifndef isgreater
-#   define isgreater(x, y) (!isunordered(x, y) && x > y)
-#endif
-
-#endif
-
-/*
- * Attempt at using the goto label construct of GNU GCC:
- * it turns out this does give some benefit: 5-15% speedup.
- * Don't look at these macros, it hurts...
- */
-#define GOTO_LABEL
-#undef GOTO_LABEL
-#ifdef GOTO_LABEL
-
-#define SWITCH(a) goto *goto_map [(a)];
-#define BREAK SWITCH(*ip)
-#define CASE(l)        l ## _LABEL:
-#define DEFAULT        \
-       CEE_ILLEGAL_LABEL:      \
-       CEE_ENDMAC_LABEL:
-#define SUB_SWITCH \
-       CEE_PREFIX1_LABEL: \
-       CEE_ARGLIST_LABEL: \
-       CEE_CEQ_LABEL: \
-       CEE_CGT_LABEL: \
-       CEE_CGT_UN_LABEL: \
-       CEE_CLT_LABEL: \
-       CEE_CLT_UN_LABEL: \
-       CEE_LDFTN_LABEL: \
-       CEE_LDVIRTFTN_LABEL: \
-       CEE_UNUSED56_LABEL: \
-       CEE_LDARG_LABEL: \
-       CEE_LDARGA_LABEL: \
-       CEE_STARG_LABEL: \
-       CEE_LDLOC_LABEL: \
-       CEE_LDLOCA_LABEL: \
-       CEE_STLOC_LABEL: \
-       CEE_LOCALLOC_LABEL: \
-       CEE_UNUSED57_LABEL: \
-       CEE_ENDFILTER_LABEL: \
-       CEE_UNALIGNED__LABEL: \
-       CEE_VOLATILE__LABEL: \
-       CEE_TAIL__LABEL: \
-       CEE_INITOBJ_LABEL: \
-       CEE_UNUSED68_LABEL: \
-       CEE_CPBLK_LABEL: \
-       CEE_INITBLK_LABEL: \
-       CEE_UNUSED69_LABEL: \
-       CEE_RETHROW_LABEL: \
-       CEE_UNUSED_LABEL: \
-       CEE_SIZEOF_LABEL: \
-       CEE_REFANYTYPE_LABEL: \
-       CEE_UNUSED52_LABEL: \
-       CEE_UNUSED53_LABEL: \
-       CEE_UNUSED54_LABEL: \
-       CEE_UNUSED55_LABEL: \
-       CEE_UNUSED70_LABEL:
-#define GOTO_LABEL_VARS \
-       const static void * const goto_map [] = {\
-#define OPDEF(a,b,c,d,e,f,g,h,i,j) \   \
-       && a ## _LABEL, \
-#include "mono/cil/opcode.def" \
-#undef OPDEF   \
-       &&DUMMY_LABEL   \
-       };      \
-       DUMMY_LABEL:
-
-#else
-       
-#define SWITCH(a) switch(a)
-#define BREAK  break
-#define CASE(l)        case l:
-#define DEFAULT        \
-               default:        \
-                       g_error ("Unimplemented opcode: %x at 0x%x\n", *ip, ip-header->code);
-#define SUB_SWITCH case 0xFE:
-#define GOTO_LABEL_VARS
-
-#endif
diff --git a/mono/mini/interpreter/interp-internals.h b/mono/mini/interpreter/interp-internals.h
deleted file mode 100644 (file)
index 603e20a..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-#ifndef __MONO_MINI_INTERPRETER_INTERNALS_H__
-#define __MONO_MINI_INTERPRETER_INTERNALS_H__
-
-#include <setjmp.h>
-#include <glib.h>
-#include <mono/metadata/loader.h>
-#include <mono/metadata/object.h>
-#include <mono/metadata/domain-internals.h>
-#include <mono/metadata/class-internals.h>
-#include "config.h"
-
-enum {
-       VAL_I32     = 0,
-       VAL_DOUBLE  = 1,
-       VAL_I64     = 2,
-       VAL_VALUET  = 3,
-       VAL_POINTER = 4,
-       VAL_NATI    = 0 + VAL_POINTER,
-       VAL_MP      = 1 + VAL_POINTER,
-       VAL_TP      = 2 + VAL_POINTER,
-       VAL_OBJ     = 3 + VAL_POINTER
-};
-
-#if SIZEOF_VOID_P == 4
-typedef guint32 mono_u;
-typedef gint32  mono_i;
-#elif SIZEOF_VOID_P == 8
-typedef guint64 mono_u;
-typedef gint64  mono_i;
-#endif
-
-/*
- * Value types are represented on the eval stack as pointers to the
- * actual storage. The size field tells how much storage is allocated.
- * A value type can't be larger than 16 MB.
- */
-typedef struct {
-       union {
-               gint32 i;
-               gint64 l;
-               double f;
-               /* native size integer and pointer types */
-               gpointer p;
-               mono_u nati;
-               gpointer vt;
-       } data;
-#if defined(__ppc__) || defined(__powerpc__)
-       int pad;
-#endif
-} stackval;
-
-typedef struct _MonoInvocation MonoInvocation;
-
-typedef void (*MonoFuncV) (void);
-typedef void (*MonoPIFunc) (MonoFuncV callme, void *margs);
-
-/* 
- * Structure representing a method transformed for the interpreter 
- * This is domain specific
- */
-typedef struct _RuntimeMethod
-{
-       /* NOTE: These first two elements (method and
-          next_jit_code_hash) must be in the same order and at the
-          same offset as in MonoJitInfo, because of the jit_code_hash
-          internal hash table in MonoDomain. */
-       MonoMethod *method;
-       struct _RuntimeMethod *next_jit_code_hash;
-       guint32 locals_size;
-       guint32 args_size;
-       guint32 stack_size;
-       guint32 vt_stack_size;
-       guint32 alloca_size;
-       unsigned short *code;
-       unsigned short *new_body_start; /* after all STINARG instrs */
-       MonoPIFunc func;
-       int num_clauses;
-       MonoExceptionClause *clauses;
-       void **data_items;
-       int transformed;
-       guint32 *arg_offsets;
-       guint32 *local_offsets;
-       unsigned int param_count;
-       unsigned int hasthis;
-       unsigned int valuetype;
-} RuntimeMethod;
-
-struct _MonoInvocation {
-       MonoInvocation *parent; /* parent */
-       RuntimeMethod  *runtime_method; /* parent */
-       MonoMethod     *method; /* parent */
-       stackval       *retval; /* parent */
-       char           *args;
-       stackval       *stack_args; /* parent */
-       stackval       *stack;
-       stackval       *sp; /* For GC stack marking */
-       /* exception info */
-       unsigned char  invoke_trap;
-       const unsigned short  *ip;
-       MonoException     *ex;
-       MonoExceptionClause *ex_handler;
-};
-
-typedef struct {
-       MonoDomain *domain;
-       MonoInvocation *base_frame;
-       MonoInvocation *current_frame;
-       MonoInvocation *env_frame;
-       jmp_buf *current_env;
-       unsigned char search_for_handler;
-       unsigned char managed_code;
-} ThreadContext;
-
-extern int mono_interp_traceopt;
-
-MonoException *
-mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *context);
-
-MonoDelegate*
-mono_interp_ftnptr_to_delegate (MonoClass *klass, gpointer ftn);
-
-void
-mono_interp_transform_init (void);
-
-RuntimeMethod *
-mono_interp_get_runtime_method (MonoDomain *domain, MonoMethod *method, MonoError *error);
-
-#endif /* __MONO_MINI_INTERPRETER_INTERNALS_H__ */
diff --git a/mono/mini/interpreter/interp.c b/mono/mini/interpreter/interp.c
deleted file mode 100644 (file)
index 2ec0105..0000000
+++ /dev/null
@@ -1,4533 +0,0 @@
-/*
- * PLEASE NOTE: This is a research prototype.
- *
- *
- * interp.c: Interpreter for CIL byte codes
- *
- * Authors:
- *   Paolo Molaro (lupus@ximian.com)
- *   Miguel de Icaza (miguel@ximian.com)
- *   Dietmar Maurer (dietmar@ximian.com)
- *
- * (C) 2001, 2002 Ximian, Inc.
- */
-#ifndef __USE_ISOC99
-#define __USE_ISOC99
-#endif
-#include "config.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <glib.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <math.h>
-#include <locale.h>
-
-#include <mono/utils/gc_wrapper.h>
-
-#ifdef HAVE_ALLOCA_H
-#   include <alloca.h>
-#else
-#   ifdef __CYGWIN__
-#      define alloca __builtin_alloca
-#   endif
-#endif
-
-/* trim excessive headers */
-#include <mono/metadata/image.h>
-#include <mono/metadata/assembly.h>
-#include <mono/metadata/cil-coff.h>
-#include <mono/metadata/mono-endian.h>
-#include <mono/metadata/tabledefs.h>
-#include <mono/metadata/tokentype.h>
-#include <mono/metadata/loader.h>
-#include <mono/metadata/threads.h>
-#include <mono/metadata/threadpool.h>
-#include <mono/metadata/profiler-private.h>
-#include <mono/metadata/appdomain.h>
-#include <mono/metadata/reflection.h>
-#include <mono/metadata/reflection-internals.h>
-#include <mono/metadata/exception.h>
-#include <mono/metadata/verify.h>
-#include <mono/metadata/opcodes.h>
-#include <mono/metadata/debug-helpers.h>
-#include <mono/metadata/mono-config.h>
-#include <mono/metadata/marshal.h>
-#include <mono/metadata/environment.h>
-#include <mono/metadata/mono-debug.h>
-
-#include "interp.h"
-#include "interp-internals.h"
-#include "mintops.h"
-#include "hacks.h"
-
-#include <mono/mini/mini.h>
-#include <mono/mini/jit-icalls.h>
-
-
-/* Mingw 2.1 doesnt need this any more, but leave it in for now for older versions */
-#ifdef _WIN32
-#define isnan _isnan
-#define finite _finite
-#endif
-#ifndef HAVE_FINITE
-#ifdef HAVE_ISFINITE
-#define finite isfinite
-#endif
-#endif
-
-#define INIT_FRAME(frame,parent_frame,method_args,method_retval,domain,mono_method,error)      \
-       do {    \
-               (frame)->parent = (parent_frame);       \
-               (frame)->stack_args = (method_args);    \
-               (frame)->retval = (method_retval);      \
-               (frame)->runtime_method = mono_interp_get_runtime_method ((domain), (mono_method), (error));    \
-               (frame)->ex = NULL;     \
-               (frame)->ip = NULL;     \
-               (frame)->invoke_trap = 0;       \
-       } while (0)
-
-void ves_exec_method (MonoInvocation *frame);
-
-static char* dump_stack (stackval *stack, stackval *sp);
-static char* dump_frame (MonoInvocation *inv);
-static MonoArray *get_trace_ips (MonoDomain *domain, MonoInvocation *top);
-static void ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context);
-
-typedef void (*ICallMethod) (MonoInvocation *frame);
-
-static guint32 die_on_exception = 0;
-static MonoNativeTlsKey thread_context_id;
-
-static char* dump_args (MonoInvocation *inv);
-
-#define DEBUG_INTERP 0
-#define COUNT_OPS 0
-#if DEBUG_INTERP
-int mono_interp_traceopt = 2;
-/* If true, then we output the opcodes as we interpret them */
-static int global_tracing = 2;
-
-static int debug_indent_level = 0;
-
-static int break_on_method = 0;
-static int nested_trace = 0;
-static GList *db_methods = NULL;
-
-static void
-output_indent (void)
-{
-       int h;
-
-       for (h = 0; h < debug_indent_level; h++)
-               g_print ("  ");
-}
-
-static void
-db_match_method (gpointer data, gpointer user_data)
-{
-       MonoMethod *m = (MonoMethod*)user_data;
-       MonoMethodDesc *desc = data;
-
-       if (mono_method_desc_full_match (desc, m))
-               break_on_method = 1;
-}
-
-static void debug_enter (MonoInvocation *frame, int *tracing)
-{
-       if (db_methods) {
-               g_list_foreach (db_methods, db_match_method, (gpointer)frame->runtime_method->method);
-               if (break_on_method)
-                       *tracing = nested_trace ? (global_tracing = 2, 3) : 2;
-               break_on_method = 0;
-       }
-       if (*tracing) {
-               MonoMethod *method = frame->runtime_method->method;
-               char *mn, *args = dump_args (frame);
-               debug_indent_level++;
-               output_indent ();
-               mn = mono_method_full_name (method, FALSE);
-               g_print ("(%p) Entering %s (", mono_thread_internal_current (), mn);
-               g_free (mn);
-               g_print  ("%s)\n", args);
-               g_free (args);
-       }
-       if (mono_profiler_events & MONO_PROFILE_ENTER_LEAVE)
-               mono_profiler_method_enter (frame->runtime_method->method);
-}
-
-
-#define DEBUG_LEAVE()  \
-       if (tracing) {  \
-               char *mn, *args;        \
-               args = dump_retval (frame);     \
-               output_indent ();       \
-               mn = mono_method_full_name (frame->runtime_method->method, FALSE); \
-               g_print  ("(%p) Leaving %s", mono_thread_internal_current (),  mn);     \
-               g_free (mn); \
-               g_print  (" => %s\n", args);    \
-               g_free (args);  \
-               debug_indent_level--;   \
-               if (tracing == 3) global_tracing = 0; \
-       }       \
-       if (mono_profiler_events & MONO_PROFILE_ENTER_LEAVE)    \
-               mono_profiler_method_leave (frame->runtime_method->method);
-
-#else
-
-int mono_interp_traceopt = 0;
-static void debug_enter (MonoInvocation *frame, int *tracing)
-{
-}
-#define DEBUG_LEAVE()
-
-#endif
-
-static void
-interp_ex_handler (MonoException *ex) {
-       MonoError error;
-       ThreadContext *context = mono_native_tls_get_value (thread_context_id);
-       char *stack_trace;
-       if (context == NULL)
-               return;
-       stack_trace = dump_frame (context->current_frame);
-       ex->stack_trace = mono_string_new (mono_domain_get(), stack_trace);
-       g_free (stack_trace);
-       if (context->current_env == NULL || strcmp(ex->object.vtable->klass->name, "ExecutionEngineException") == 0) {
-               char *strace = mono_string_to_utf8_checked (ex->stack_trace, &error);
-               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-               fprintf(stderr, "Nothing can catch this exception: ");
-               fprintf(stderr, "%s", ex->object.vtable->klass->name);
-               if (ex->message != NULL) {
-                       char *m = mono_string_to_utf8_checked (ex->message, &error);
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       fprintf(stderr, ": %s", m);
-                       g_free(m);
-               }
-               fprintf(stderr, "\n%s\n", strace);
-               g_free (strace);
-               if (ex->inner_ex != NULL) {
-                       ex = (MonoException *)ex->inner_ex;
-                       fprintf(stderr, "Inner exception: %s", ex->object.vtable->klass->name);
-                       if (ex->message != NULL) {
-                               char *m = mono_string_to_utf8_checked (ex->message, &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                               fprintf(stderr, ": %s", m);
-                               g_free(m);
-                       }
-                       strace = mono_string_to_utf8_checked (ex->stack_trace, &error);
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "%s\n", strace);
-                       g_free (strace);
-               }
-               /* wait for other threads to also collapse */
-               // Sleep(1000); // TODO: proper sleep
-               exit(1);
-       }
-       context->env_frame->ex = ex;
-       context->search_for_handler = 1;
-       longjmp (*context->current_env, 1);
-}
-
-static void
-ves_real_abort (int line, MonoMethod *mh,
-               const unsigned short *ip, stackval *stack, stackval *sp)
-{
-       MonoError error;
-       fprintf (stderr, "Execution aborted in method: %s::%s\n", mh->klass->name, mh->name);
-       fprintf (stderr, "Line=%d IP=0x%04lx, Aborted execution\n", line,
-                ip-(const unsigned short *)mono_method_get_header_checked (mh, &error)->code);
-               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-       g_print ("0x%04x %02x\n",
-                ip-(const unsigned short *)mono_method_get_header_checked (mh, &error)->code, *ip);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-       if (sp > stack)
-               printf ("\t[%ld] 0x%08x %0.5f\n", sp-stack, sp[-1].data.i, sp[-1].data.f);
-}
-
-#define ves_abort() \
-       do {\
-               ves_real_abort(__LINE__, frame->runtime_method->method, ip, frame->stack, sp); \
-               THROW_EX (mono_get_exception_execution_engine (NULL), ip); \
-       } while (0);
-
-static mono_mutex_t runtime_method_lookup_section;
-
-RuntimeMethod*
-mono_interp_get_runtime_method (MonoDomain *domain, MonoMethod *method, MonoError *error)
-{
-       RuntimeMethod *rtm;
-       error_init (error);
-
-       mono_os_mutex_lock (&runtime_method_lookup_section);
-       if ((rtm = mono_internal_hash_table_lookup (&domain->jit_code_hash, method))) {
-               mono_os_mutex_unlock (&runtime_method_lookup_section);
-               return rtm;
-       }
-       rtm = mono_mempool_alloc (domain->mp, sizeof (RuntimeMethod));
-       memset (rtm, 0, sizeof (*rtm));
-       rtm->method = method;
-       rtm->param_count = mono_method_signature (method)->param_count;
-       rtm->hasthis = mono_method_signature (method)->hasthis;
-       rtm->valuetype = method->klass->valuetype;
-       mono_internal_hash_table_insert (&domain->jit_code_hash, method, rtm);
-       mono_os_mutex_unlock (&runtime_method_lookup_section);
-
-       return rtm;
-}
-
-static gpointer
-interp_create_trampoline (MonoDomain *domain, MonoMethod *method, MonoError *error)
-{
-       if (method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
-               method = mono_marshal_get_synchronized_wrapper (method);
-       return mono_interp_get_runtime_method (domain, method, error);
-}
-
-static inline RuntimeMethod*
-get_virtual_method (MonoDomain *domain, RuntimeMethod *runtime_method, MonoObject *obj)
-{
-       MonoMethod *m = runtime_method->method;
-       MonoError error;
-
-       if ((m->flags & METHOD_ATTRIBUTE_FINAL) || !(m->flags & METHOD_ATTRIBUTE_VIRTUAL)) {
-               RuntimeMethod *ret = NULL;
-               if (mono_object_is_transparent_proxy (obj)) {
-                       ret = mono_interp_get_runtime_method (domain, mono_marshal_get_remoting_invoke (m), &error);
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-               } else if (m->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) {
-                       ret = mono_interp_get_runtime_method (domain, mono_marshal_get_synchronized_wrapper (m), &error);
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-               } else {
-                       ret = runtime_method;
-               }
-               return ret;
-       }
-
-       mono_class_setup_vtable (obj->vtable->klass);
-
-       int slot = mono_method_get_vtable_slot (m);
-       if (mono_class_is_interface (m->klass)) {
-               g_assert (obj->vtable->klass != m->klass);
-               /* TODO: interface offset lookup is slow, go through IMT instead */
-               slot += mono_class_interface_offset (obj->vtable->klass, m->klass);
-       }
-       MonoMethod *virtual_method = obj->vtable->klass->vtable [slot];
-       RuntimeMethod *virtual_runtime_method = mono_interp_get_runtime_method (domain, virtual_method, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-       return virtual_runtime_method;
-}
-
-static void inline
-stackval_from_data (MonoType *type, stackval *result, char *data, gboolean pinvoke)
-{
-       if (type->byref) {
-               switch (type->type) {
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_CLASS:
-               case MONO_TYPE_STRING:
-               case MONO_TYPE_ARRAY:
-               case MONO_TYPE_SZARRAY:
-                       break;
-               default:
-                       break;
-               }
-               result->data.p = *(gpointer*)data;
-               return;
-       }
-       switch (type->type) {
-       case MONO_TYPE_VOID:
-               return;
-       case MONO_TYPE_I1:
-               result->data.i = *(gint8*)data;
-               return;
-       case MONO_TYPE_U1:
-       case MONO_TYPE_BOOLEAN:
-               result->data.i = *(guint8*)data;
-               return;
-       case MONO_TYPE_I2:
-               result->data.i = *(gint16*)data;
-               return;
-       case MONO_TYPE_U2:
-       case MONO_TYPE_CHAR:
-               result->data.i = *(guint16*)data;
-               return;
-       case MONO_TYPE_I4:
-               result->data.i = *(gint32*)data;
-               return;
-       case MONO_TYPE_U:
-       case MONO_TYPE_I:
-               result->data.nati = *(mono_i*)data;
-               return;
-       case MONO_TYPE_PTR:
-               result->data.p = *(gpointer*)data;
-               return;
-       case MONO_TYPE_U4:
-               result->data.i = *(guint32*)data;
-               return;
-       case MONO_TYPE_R4:
-               result->data.f = *(float*)data;
-               return;
-       case MONO_TYPE_I8:
-       case MONO_TYPE_U8:
-               result->data.l = *(gint64*)data;
-               return;
-       case MONO_TYPE_R8:
-               result->data.f = *(double*)data;
-               return;
-       case MONO_TYPE_STRING:
-       case MONO_TYPE_SZARRAY:
-       case MONO_TYPE_CLASS:
-       case MONO_TYPE_OBJECT:
-       case MONO_TYPE_ARRAY:
-               result->data.p = *(gpointer*)data;
-               return;
-       case MONO_TYPE_VALUETYPE:
-               if (type->data.klass->enumtype) {
-                       stackval_from_data (mono_class_enum_basetype (type->data.klass), result, data, pinvoke);
-                       return;
-               } else
-                       mono_value_copy (result->data.vt, data, type->data.klass);
-               return;
-       case MONO_TYPE_GENERICINST:
-               stackval_from_data (&type->data.generic_class->container_class->byval_arg, result, data, pinvoke);
-               return;
-       default:
-               g_warning ("got type 0x%02x", type->type);
-               g_assert_not_reached ();
-       }
-}
-
-static void inline
-stackval_to_data (MonoType *type, stackval *val, char *data, gboolean pinvoke)
-{
-       if (type->byref) {
-               gpointer *p = (gpointer*)data;
-               *p = val->data.p;
-               return;
-       }
-       /* printf ("TODAT0 %p\n", data); */
-       switch (type->type) {
-       case MONO_TYPE_I1:
-       case MONO_TYPE_U1: {
-               guint8 *p = (guint8*)data;
-               *p = val->data.i;
-               return;
-       }
-       case MONO_TYPE_BOOLEAN: {
-               guint8 *p = (guint8*)data;
-               *p = (val->data.i != 0);
-               return;
-       }
-       case MONO_TYPE_I2:
-       case MONO_TYPE_U2:
-       case MONO_TYPE_CHAR: {
-               guint16 *p = (guint16*)data;
-               *p = val->data.i;
-               return;
-       }
-       case MONO_TYPE_I: {
-               mono_i *p = (mono_i*)data;
-               /* In theory the value used by stloc should match the local var type
-                  but in practice it sometimes doesn't (a int32 gets dup'd and stloc'd into
-                  a native int - both by csc and mcs). Not sure what to do about sign extension
-                  as it is outside the spec... doing the obvious */
-               *p = (mono_i)val->data.nati;
-               return;
-       }
-       case MONO_TYPE_U: {
-               mono_u *p = (mono_u*)data;
-               /* see above. */
-               *p = (mono_u)val->data.nati;
-               return;
-       }
-       case MONO_TYPE_I4:
-       case MONO_TYPE_U4: {
-               gint32 *p = (gint32*)data;
-               *p = val->data.i;
-               return;
-       }
-       case MONO_TYPE_I8:
-       case MONO_TYPE_U8: {
-               gint64 *p = (gint64*)data;
-               *p = val->data.l;
-               return;
-       }
-       case MONO_TYPE_R4: {
-               float *p = (float*)data;
-               *p = val->data.f;
-               return;
-       }
-       case MONO_TYPE_R8: {
-               double *p = (double*)data;
-               *p = val->data.f;
-               return;
-       }
-       case MONO_TYPE_STRING:
-       case MONO_TYPE_SZARRAY:
-       case MONO_TYPE_CLASS:
-       case MONO_TYPE_OBJECT:
-       case MONO_TYPE_ARRAY:
-       case MONO_TYPE_PTR: {
-               gpointer *p = (gpointer*)data;
-               *p = val->data.p;
-               return;
-       }
-       case MONO_TYPE_VALUETYPE:
-               if (type->data.klass->enumtype) {
-                       stackval_to_data (mono_class_enum_basetype (type->data.klass), val, data, pinvoke);
-                       return;
-               } else
-                       mono_value_copy (data, val->data.vt, type->data.klass);
-               return;
-       case MONO_TYPE_GENERICINST:
-               stackval_to_data (&type->data.generic_class->container_class->byval_arg, val, data, pinvoke);
-               return;
-       default:
-               g_warning ("got type %x", type->type);
-               g_assert_not_reached ();
-       }
-}
-
-static void
-fill_in_trace (MonoException *exception, MonoInvocation *frame)
-{
-       char *stack_trace = dump_frame (frame);
-       MonoDomain *domain = mono_domain_get();
-       (exception)->stack_trace = mono_string_new (domain, stack_trace);
-       (exception)->trace_ips = get_trace_ips (domain, frame);
-       g_free (stack_trace);
-}
-
-#define FILL_IN_TRACE(exception, frame) fill_in_trace(exception, frame)
-
-#define THROW_EX(exception,ex_ip)      \
-       do {\
-               frame->ip = (ex_ip);            \
-               frame->ex = (MonoException*)(exception);        \
-               FILL_IN_TRACE(frame->ex, frame); \
-               goto handle_exception;  \
-       } while (0)
-
-static MonoObject*
-ves_array_create (MonoDomain *domain, MonoClass *klass, MonoMethodSignature *sig, stackval *values)
-{
-       uintptr_t *lengths;
-       intptr_t *lower_bounds;
-       MonoObject *obj;
-       MonoError error;
-       int i;
-
-       lengths = alloca (sizeof (uintptr_t) * klass->rank * 2);
-       for (i = 0; i < sig->param_count; ++i) {
-               lengths [i] = values->data.i;
-               values ++;
-       }
-       if (klass->rank == sig->param_count) {
-               /* Only lengths provided. */
-               lower_bounds = NULL;
-       } else {
-               /* lower bounds are first. */
-               lower_bounds = (intptr_t *) lengths;
-               lengths += klass->rank;
-       }
-       obj = (MonoObject*) mono_array_new_full_checked (domain, klass, lengths, lower_bounds, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-       return obj;
-}
-
-static void 
-ves_array_set (MonoInvocation *frame)
-{
-       stackval *sp = frame->stack_args;
-       MonoObject *o;
-       MonoArray *ao;
-       MonoClass *ac;
-       gint32 i, t, pos, esize;
-       gpointer ea;
-       MonoType *mt;
-
-       o = frame->stack_args->data.p;
-       ao = (MonoArray *)o;
-       ac = o->vtable->klass;
-
-       g_assert (ac->rank >= 1);
-
-       pos = sp [0].data.i;
-       if (ao->bounds != NULL) {
-               pos -= ao->bounds [0].lower_bound;
-               for (i = 1; i < ac->rank; i++) {
-                       if ((t = sp [i].data.i - ao->bounds [i].lower_bound) >= 
-                           ao->bounds [i].length) {
-                               frame->ex = mono_get_exception_index_out_of_range ();
-                               FILL_IN_TRACE(frame->ex, frame);
-                               return;
-                       }
-                       pos = pos*ao->bounds [i].length + sp [i].data.i - 
-                               ao->bounds [i].lower_bound;
-               }
-       } else if (pos >= ao->max_length) {
-               frame->ex = mono_get_exception_index_out_of_range ();
-               FILL_IN_TRACE(frame->ex, frame);
-               return;
-       }
-
-       if (sp [ac->rank].data.p && !mono_object_class (o)->element_class->valuetype) {
-               MonoError error;
-               MonoObject *isinst = mono_object_isinst_checked (sp [ac->rank].data.p, mono_object_class (o)->element_class, &error);
-               mono_error_cleanup (&error);
-               if (!isinst) {
-                       frame->ex = mono_get_exception_array_type_mismatch ();
-                       FILL_IN_TRACE (frame->ex, frame);
-                       return;
-               }
-       }
-
-       esize = mono_array_element_size (ac);
-       ea = mono_array_addr_with_size (ao, esize, pos);
-
-       mt = mono_method_signature (frame->runtime_method->method)->params [ac->rank];
-       stackval_to_data (mt, &sp [ac->rank], ea, FALSE);
-}
-
-static void 
-ves_array_get (MonoInvocation *frame)
-{
-       stackval *sp = frame->stack_args;
-       MonoObject *o;
-       MonoArray *ao;
-       MonoClass *ac;
-       gint32 i, t, pos, esize;
-       gpointer ea;
-       MonoType *mt;
-
-       o = frame->stack_args->data.p;
-       ao = (MonoArray *)o;
-       ac = o->vtable->klass;
-
-       g_assert (ac->rank >= 1);
-
-       pos = sp [0].data.i;
-       if (ao->bounds != NULL) {
-               pos -= ao->bounds [0].lower_bound;
-               for (i = 1; i < ac->rank; i++) {
-                       if ((t = sp [i].data.i - ao->bounds [i].lower_bound) >= 
-                           ao->bounds [i].length) {
-                               frame->ex = mono_get_exception_index_out_of_range ();
-                               FILL_IN_TRACE(frame->ex, frame);
-                               return;
-                       }
-
-                       pos = pos*ao->bounds [i].length + sp [i].data.i - 
-                               ao->bounds [i].lower_bound;
-               }
-       } else if (pos >= ao->max_length) {
-               frame->ex = mono_get_exception_index_out_of_range ();
-               FILL_IN_TRACE(frame->ex, frame);
-               return;
-       }
-
-       esize = mono_array_element_size (ac);
-       ea = mono_array_addr_with_size (ao, esize, pos);
-
-       mt = mono_method_signature (frame->runtime_method->method)->ret;
-       stackval_from_data (mt, frame->retval, ea, FALSE);
-}
-
-static void
-ves_array_element_address (MonoInvocation *frame)
-{
-       stackval *sp = frame->stack_args;
-       MonoObject *o;
-       MonoArray *ao;
-       MonoClass *ac;
-       gint32 i, t, pos, esize;
-       gpointer ea;
-
-       o = frame->stack_args->data.p;
-       ao = (MonoArray *)o;
-       ac = o->vtable->klass;
-
-       g_assert (ac->rank >= 1);
-
-       pos = sp [0].data.i;
-       if (ao->bounds != NULL) {
-               pos -= ao->bounds [0].lower_bound;
-               for (i = 1; i < ac->rank; i++) {
-                       if ((t = sp [i].data.i - ao->bounds [i].lower_bound) >= 
-                           ao->bounds [i].length) {
-                               frame->ex = mono_get_exception_index_out_of_range ();
-                               FILL_IN_TRACE(frame->ex, frame);
-                               return;
-                       }
-                       pos = pos*ao->bounds [i].length + sp [i].data.i - 
-                               ao->bounds [i].lower_bound;
-               }
-       } else if (pos >= ao->max_length) {
-               frame->ex = mono_get_exception_index_out_of_range ();
-               FILL_IN_TRACE(frame->ex, frame);
-               return;
-       }
-
-       esize = mono_array_element_size (ac);
-       ea = mono_array_addr_with_size (ao, esize, pos);
-
-       frame->retval->data.p = ea;
-}
-
-static void
-interp_walk_stack (MonoStackWalk func, gboolean do_il_offset, gpointer user_data)
-{
-       ThreadContext *context = mono_native_tls_get_value (thread_context_id);
-       MonoInvocation *frame;
-       int il_offset;
-       MonoMethodHeader *hd;
-       MonoError error;
-
-       if (!context) return;
-               
-       frame = context->current_frame;
-
-       while (frame) {
-               gboolean managed = FALSE;
-               MonoMethod *method = frame->runtime_method->method;
-               if (!method || (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) || (method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME)))
-                       il_offset = -1;
-               else {
-                       hd = mono_method_get_header_checked (method, &error);
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       il_offset = frame->ip - (const unsigned short *)hd->code;
-                       if (!method->wrapper_type)
-                               managed = TRUE;
-               }
-               if (func (method, -1, il_offset, managed, user_data))
-                       return;
-               frame = frame->parent;
-       }
-}
-
-static MonoPIFunc mono_interp_enter_icall_trampoline = NULL;
-
-struct _MethodArguments {
-       size_t ilen;
-       gpointer *iargs;
-       size_t flen;
-       gpointer *fargs;
-       gpointer *retval;
-};
-
-typedef struct _MethodArguments MethodArguments;
-
-// TODO: this function is also arch dependent (register width).
-static MethodArguments* build_args_from_sig (MonoMethodSignature *sig, MonoInvocation *frame)
-{
-       // TODO: don't malloc this data structure.
-       MethodArguments *margs = g_malloc0 (sizeof (MethodArguments));
-
-       if (sig->hasthis)
-               margs->ilen++;
-
-       for (int i = 0; i < sig->param_count; i++) {
-               guint32 ptype = sig->params [i]->byref ? MONO_TYPE_PTR : sig->params [i]->type;
-               switch (ptype) {
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_CHAR:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_PTR:
-               case MONO_TYPE_SZARRAY:
-               case MONO_TYPE_CLASS:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_STRING:
-               case MONO_TYPE_I8:
-               case MONO_TYPE_VALUETYPE:
-                       margs->ilen++;
-                       break;
-               default:
-                       g_error ("build_args_from_sig: not implemented yet (1): 0x%x\n", ptype);
-               }
-       }
-
-       if (margs->ilen > 0)
-               margs->iargs = g_malloc0 (sizeof (gpointer) * margs->ilen);
-
-       if (margs->ilen > 6)
-               g_error ("build_args_from_sig: TODO, more than 6 iregs: %d\n", margs->ilen);
-
-       if (margs->flen > 0)
-               g_error ("build_args_from_sig: TODO, allocate floats: %d\n", margs->flen);
-
-
-       size_t int_i = 0;
-
-       if (sig->hasthis) {
-               margs->iargs [0] = frame->stack_args->data.p;
-               int_i++;
-       }
-
-       for (int i = 0; i < sig->param_count; i++) {
-               guint32 ptype = sig->params [i]->byref ? MONO_TYPE_PTR : sig->params [i]->type;
-               switch (ptype) {
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_CHAR:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_PTR:
-               case MONO_TYPE_SZARRAY:
-               case MONO_TYPE_CLASS:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_STRING:
-               case MONO_TYPE_I8:
-               case MONO_TYPE_VALUETYPE:
-                       margs->iargs [int_i] = frame->stack_args [i].data.p;
-#if DEBUG_INTERP
-                       g_print ("build_args_from_sig: margs->iargs[%d]: %p (frame @ %d)\n", int_i, margs->iargs[int_i], i);
-#endif
-                       int_i++;
-                       break;
-               default:
-                       g_error ("build_args_from_sig: not implemented yet (2): 0x%x\n", ptype);
-               }
-       }
-
-       if (sig->ret->type != MONO_TYPE_VOID) {
-               margs->retval = &(frame->retval->data.p);
-       } else {
-               margs->retval = NULL;
-       }
-
-       return margs;
-}
-
-static void 
-ves_pinvoke_method (MonoInvocation *frame, MonoMethodSignature *sig, MonoFuncV addr, gboolean string_ctor, ThreadContext *context)
-{
-       jmp_buf env;
-       MonoInvocation *old_frame = context->current_frame;
-       MonoInvocation *old_env_frame = context->env_frame;
-       jmp_buf *old_env = context->current_env;
-
-       if (setjmp (env)) {
-               context->current_frame = old_frame;
-               context->env_frame = old_env_frame;
-               context->current_env = old_env;
-               context->managed_code = 1;
-               return;
-       }
-
-       frame->ex = NULL;
-       context->env_frame = frame;
-       context->current_env = &env;
-
-       g_assert (!frame->runtime_method);
-       if (!mono_interp_enter_icall_trampoline) {
-               MonoTrampInfo *info;
-               mono_interp_enter_icall_trampoline = mono_arch_get_enter_icall_trampoline (&info);
-               // TODO:
-               // mono_tramp_info_register (info, NULL);
-       }
-
-       MethodArguments *margs = build_args_from_sig (sig, frame);
-#if DEBUG_INTERP
-       g_print ("ICALL: mono_interp_enter_icall_trampoline = %p, addr = %p\n", mono_interp_enter_icall_trampoline, addr);
-       g_print ("margs(out): ilen=%d, flen=%d\n", margs->ilen, margs->flen);
-#endif
-
-       context->current_frame = frame;
-       context->managed_code = 0;
-
-       mono_interp_enter_icall_trampoline (addr, margs);
-
-       context->managed_code = 1;
-       /* domain can only be changed by native code */
-       context->domain = mono_domain_get ();
-
-       if (*mono_thread_interruption_request_flag ())
-               mono_thread_interruption_checkpoint ();
-       
-       if (!MONO_TYPE_ISSTRUCT (sig->ret))
-               stackval_from_data (sig->ret, frame->retval, (char*)&frame->retval->data.p, sig->pinvoke);
-
-       context->current_frame = old_frame;
-       context->env_frame = old_env_frame;
-       context->current_env = old_env;
-
-       g_free (margs->iargs);
-       g_free (margs->fargs);
-       g_free (margs);
-}
-
-static void
-interp_delegate_ctor (MonoDomain *domain, MonoObject *this, MonoObject *target, RuntimeMethod *runtime_method)
-{
-       MonoDelegate *delegate = (MonoDelegate *)this;
-       MonoError error;
-
-       delegate->method_info = mono_method_get_object_checked (domain, runtime_method->method, NULL, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-       delegate->target = target;
-
-       if (target && mono_object_is_transparent_proxy (target)) {
-               MonoMethod *method = mono_marshal_get_remoting_invoke (runtime_method->method);
-               delegate->method_ptr = mono_interp_get_runtime_method (domain, method, &error);
-               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-       } else {
-               delegate->method_ptr = runtime_method;
-       }
-}
-
-MonoDelegate*
-mono_interp_ftnptr_to_delegate (MonoClass *klass, gpointer ftn)
-{
-       MonoDelegate *d;
-       MonoJitInfo *ji;
-       MonoDomain *domain = mono_domain_get ();
-       MonoError error;
-
-       d = (MonoDelegate*)mono_object_new_checked (domain, klass, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-
-       ji = mono_jit_info_table_find (domain, ftn);
-       if (ji == NULL)
-               mono_raise_exception (mono_get_exception_argument ("", "Function pointer was not created by a Delegate."));
-
-       /* FIXME: discard the wrapper and call the original method */
-       interp_delegate_ctor (domain, (MonoObject*)d, NULL, mono_interp_get_runtime_method (domain, ji->d.method, &error));
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-
-       return d;
-}
-
-/*
- * From the spec:
- * runtime specifies that the implementation of the method is automatically
- * provided by the runtime and is primarily used for the methods of delegates.
- */
-static void
-ves_runtime_method (MonoInvocation *frame, ThreadContext *context)
-{
-       MonoMethod *method = frame->runtime_method->method;
-       const char *name = method->name;
-       MonoObject *obj = (MonoObject*) frame->stack_args->data.p;
-       MonoObject *isinst_obj;
-       MonoError error;
-
-       mono_class_init (method->klass);
-
-       isinst_obj = mono_object_isinst_checked (obj, mono_defaults.multicastdelegate_class, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-       if (obj && isinst_obj) {
-               if (*name == '.' && (strcmp (name, ".ctor") == 0)) {
-                       interp_delegate_ctor (context->domain, obj, frame->stack_args [1].data.p, frame->stack_args[2].data.p);
-                       return;
-               }
-       }
-
-       isinst_obj = mono_object_isinst_checked (obj, mono_defaults.array_class, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-       if (obj && isinst_obj) {
-               if (*name == 'S' && (strcmp (name, "Set") == 0)) {
-                       ves_array_set (frame);
-                       return;
-               }
-               if (*name == 'G' && (strcmp (name, "Get") == 0)) {
-                       ves_array_get (frame);
-                       return;
-               }
-               if (*name == 'A' && (strcmp (name, "Address") == 0)) {
-                       ves_array_element_address (frame);
-                       return;
-               }
-       }
-       
-       g_error ("Don't know how to exec runtime method %s.%s::%s", 
-                       method->klass->name_space, method->klass->name,
-                       method->name);
-}
-
-static char*
-dump_stack (stackval *stack, stackval *sp)
-{
-       stackval *s = stack;
-       GString *str = g_string_new ("");
-       
-       if (sp == stack)
-               return g_string_free (str, FALSE);
-       
-       while (s < sp) {
-               g_string_append_printf (str, "[%p (%lld)] ", s->data.l, s->data.l);
-               ++s;
-       }
-       return g_string_free (str, FALSE);
-}
-
-static void
-dump_stackval (GString *str, stackval *s, MonoType *type)
-{
-       switch (type->type) {
-       case MONO_TYPE_I1:
-       case MONO_TYPE_U1:
-       case MONO_TYPE_I2:
-       case MONO_TYPE_U2:
-       case MONO_TYPE_I4:
-       case MONO_TYPE_U4:
-       case MONO_TYPE_CHAR:
-       case MONO_TYPE_BOOLEAN:
-               g_string_append_printf (str, "[%d] ", s->data.i);
-               break;
-       case MONO_TYPE_STRING:
-       case MONO_TYPE_SZARRAY:
-       case MONO_TYPE_CLASS:
-       case MONO_TYPE_OBJECT:
-       case MONO_TYPE_ARRAY:
-       case MONO_TYPE_PTR:
-       case MONO_TYPE_I:
-       case MONO_TYPE_U:
-               g_string_append_printf (str, "[%p] ", s->data.p);
-               break;
-       case MONO_TYPE_VALUETYPE:
-               if (type->data.klass->enumtype)
-                       g_string_append_printf (str, "[%d] ", s->data.i);
-               else
-                       g_string_append_printf (str, "[vt:%p] ", s->data.p);
-               break;
-       case MONO_TYPE_R4:
-       case MONO_TYPE_R8:
-               g_string_append_printf (str, "[%g] ", s->data.f);
-               break;
-       case MONO_TYPE_I8:
-       case MONO_TYPE_U8:
-       default: {
-               GString *res = g_string_new ("");
-               mono_type_get_desc (res, type, TRUE);
-               g_string_append_printf (str, "[{%s} %lld/0x%0llx] ", res->str, s->data.l, s->data.l);
-               g_string_free (res, TRUE);
-               break;
-       }
-       }
-}
-
-static char*
-dump_args (MonoInvocation *inv)
-{
-       GString *str = g_string_new ("");
-       int i;
-       MonoMethodSignature *signature = mono_method_signature (inv->runtime_method->method);
-       
-       if (signature->param_count == 0 && !signature->hasthis)
-               return g_string_free (str, FALSE);
-
-       if (signature->hasthis) {
-               MonoMethod *method = inv->runtime_method->method;
-               dump_stackval (str, inv->stack_args, &method->klass->byval_arg);
-       }
-
-       for (i = 0; i < signature->param_count; ++i)
-               dump_stackval (str, inv->stack_args + (!!signature->hasthis) + i, signature->params [i]);
-
-       return g_string_free (str, FALSE);
-}
-
-static char*
-dump_retval (MonoInvocation *inv)
-{
-       GString *str = g_string_new ("");
-       MonoType *ret = mono_method_signature (inv->runtime_method->method)->ret;
-
-       if (ret->type != MONO_TYPE_VOID)
-               dump_stackval (str, inv->retval, ret);
-
-       return g_string_free (str, FALSE);
-}
-static char*
-dump_frame (MonoInvocation *inv)
-{
-       GString *str = g_string_new ("");
-       int i;
-       char *args;
-       MonoError error;
-
-       for (i = 0; inv; inv = inv->parent) {
-               if (inv->runtime_method != NULL) {
-                       MonoMethod *method = inv->runtime_method->method;
-                       MonoClass *k;
-
-                       int codep = 0;
-                       const char * opname = "";
-                       char *name;
-                       gchar *source = NULL;
-
-                       k = method->klass;
-
-                       if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) == 0 &&
-                               (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) == 0) {
-                               MonoMethodHeader *hd = mono_method_get_header_checked (method, &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-
-                               if (hd != NULL) {
-                                       if (inv->ip) {
-                                               opname = mono_interp_opname [*inv->ip];
-                                               codep = inv->ip - inv->runtime_method->code;
-                                               source = g_strdup_printf ("%s:%d // (TODO: proper stacktrace)", method->name, codep);
-                                       } else 
-                                               opname = "";
-
-#if 0
-                                       MonoDebugSourceLocation *minfo = mono_debug_lookup_method (method);
-                                       source = mono_debug_method_lookup_location (minfo, codep);
-#endif
-                               }
-                       }
-                       args = dump_args (inv);
-                       name = mono_method_full_name (method, TRUE);
-                       if (source)
-                               g_string_append_printf (str, "#%d: 0x%05x %-10s in %s (%s) at %s\n", i, codep, opname, name, args, source);
-                       else
-                               g_string_append_printf (str, "#%d: 0x%05x %-10s in %s (%s)\n", i, codep, opname, name, args);
-                       g_free (name);
-                       g_free (args);
-                       g_free (source);
-                       ++i;
-               }
-       }
-       return g_string_free (str, FALSE);
-}
-
-static MonoArray *
-get_trace_ips (MonoDomain *domain, MonoInvocation *top)
-{
-       int i;
-       MonoArray *res;
-       MonoInvocation *inv;
-       MonoError error;
-
-       for (i = 0, inv = top; inv; inv = inv->parent)
-               if (inv->runtime_method != NULL)
-                       ++i;
-
-       res = mono_array_new_checked (domain, mono_defaults.int_class, 2 * i, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-
-       for (i = 0, inv = top; inv; inv = inv->parent)
-               if (inv->runtime_method != NULL) {
-                       mono_array_set (res, gpointer, i, inv->runtime_method);
-                       ++i;
-                       mono_array_set (res, gpointer, i, (gpointer)inv->ip);
-                       ++i;
-               }
-
-       return res;
-}
-
-
-#define MYGUINT64_MAX 18446744073709551615ULL
-#define MYGINT64_MAX 9223372036854775807LL
-#define MYGINT64_MIN (-MYGINT64_MAX -1LL)
-
-#define MYGUINT32_MAX 4294967295U
-#define MYGINT32_MAX 2147483647
-#define MYGINT32_MIN (-MYGINT32_MAX -1)
-       
-#define CHECK_ADD_OVERFLOW(a,b) \
-       (gint32)(b) >= 0 ? (gint32)(MYGINT32_MAX) - (gint32)(b) < (gint32)(a) ? -1 : 0  \
-       : (gint32)(MYGINT32_MIN) - (gint32)(b) > (gint32)(a) ? +1 : 0
-
-#define CHECK_SUB_OVERFLOW(a,b) \
-       (gint32)(b) < 0 ? (gint32)(MYGINT32_MAX) + (gint32)(b) < (gint32)(a) ? -1 : 0   \
-       : (gint32)(MYGINT32_MIN) + (gint32)(b) > (gint32)(a) ? +1 : 0
-
-#define CHECK_ADD_OVERFLOW_UN(a,b) \
-       (guint32)(MYGUINT32_MAX) - (guint32)(b) < (guint32)(a) ? -1 : 0
-
-#define CHECK_SUB_OVERFLOW_UN(a,b) \
-       (guint32)(a) < (guint32)(b) ? -1 : 0
-
-#define CHECK_ADD_OVERFLOW64(a,b) \
-       (gint64)(b) >= 0 ? (gint64)(MYGINT64_MAX) - (gint64)(b) < (gint64)(a) ? -1 : 0  \
-       : (gint64)(MYGINT64_MIN) - (gint64)(b) > (gint64)(a) ? +1 : 0
-
-#define CHECK_SUB_OVERFLOW64(a,b) \
-       (gint64)(b) < 0 ? (gint64)(MYGINT64_MAX) + (gint64)(b) < (gint64)(a) ? -1 : 0   \
-       : (gint64)(MYGINT64_MIN) + (gint64)(b) > (gint64)(a) ? +1 : 0
-
-#define CHECK_ADD_OVERFLOW64_UN(a,b) \
-       (guint64)(MYGUINT64_MAX) - (guint64)(b) < (guint64)(a) ? -1 : 0
-
-#define CHECK_SUB_OVERFLOW64_UN(a,b) \
-       (guint64)(a) < (guint64)(b) ? -1 : 0
-
-#if SIZEOF_VOID_P == 4
-#define CHECK_ADD_OVERFLOW_NAT(a,b) CHECK_ADD_OVERFLOW(a,b)
-#define CHECK_ADD_OVERFLOW_NAT_UN(a,b) CHECK_ADD_OVERFLOW_UN(a,b)
-#else
-#define CHECK_ADD_OVERFLOW_NAT(a,b) CHECK_ADD_OVERFLOW64(a,b)
-#define CHECK_ADD_OVERFLOW_NAT_UN(a,b) CHECK_ADD_OVERFLOW64_UN(a,b)
-#endif
-
-/* Resolves to TRUE if the operands would overflow */
-#define CHECK_MUL_OVERFLOW(a,b) \
-       ((gint32)(a) == 0) || ((gint32)(b) == 0) ? 0 : \
-       (((gint32)(a) > 0) && ((gint32)(b) == -1)) ? FALSE : \
-       (((gint32)(a) < 0) && ((gint32)(b) == -1)) ? (a == - MYGINT32_MAX) : \
-       (((gint32)(a) > 0) && ((gint32)(b) > 0)) ? (gint32)(a) > ((MYGINT32_MAX) / (gint32)(b)) : \
-       (((gint32)(a) > 0) && ((gint32)(b) < 0)) ? (gint32)(a) > ((MYGINT32_MIN) / (gint32)(b)) : \
-       (((gint32)(a) < 0) && ((gint32)(b) > 0)) ? (gint32)(a) < ((MYGINT32_MIN) / (gint32)(b)) : \
-       (gint32)(a) < ((MYGINT32_MAX) / (gint32)(b))
-
-#define CHECK_MUL_OVERFLOW_UN(a,b) \
-       ((guint32)(a) == 0) || ((guint32)(b) == 0) ? 0 : \
-       (guint32)(b) > ((MYGUINT32_MAX) / (guint32)(a))
-
-#define CHECK_MUL_OVERFLOW64(a,b) \
-       ((gint64)(a) == 0) || ((gint64)(b) == 0) ? 0 : \
-       (((gint64)(a) > 0) && ((gint64)(b) == -1)) ? FALSE : \
-       (((gint64)(a) < 0) && ((gint64)(b) == -1)) ? (a == - MYGINT64_MAX) : \
-       (((gint64)(a) > 0) && ((gint64)(b) > 0)) ? (gint64)(a) > ((MYGINT64_MAX) / (gint64)(b)) : \
-       (((gint64)(a) > 0) && ((gint64)(b) < 0)) ? (gint64)(a) > ((MYGINT64_MIN) / (gint64)(b)) : \
-       (((gint64)(a) < 0) && ((gint64)(b) > 0)) ? (gint64)(a) < ((MYGINT64_MIN) / (gint64)(b)) : \
-       (gint64)(a) < ((MYGINT64_MAX) / (gint64)(b))
-
-#define CHECK_MUL_OVERFLOW64_UN(a,b) \
-       ((guint64)(a) == 0) || ((guint64)(b) == 0) ? 0 : \
-       (guint64)(b) > ((MYGUINT64_MAX) / (guint64)(a))
-
-#if SIZEOF_VOID_P == 4
-#define CHECK_MUL_OVERFLOW_NAT(a,b) CHECK_MUL_OVERFLOW(a,b)
-#define CHECK_MUL_OVERFLOW_NAT_UN(a,b) CHECK_MUL_OVERFLOW_UN(a,b)
-#else
-#define CHECK_MUL_OVERFLOW_NAT(a,b) CHECK_MUL_OVERFLOW64(a,b)
-#define CHECK_MUL_OVERFLOW_NAT_UN(a,b) CHECK_MUL_OVERFLOW64_UN(a,b)
-#endif
-
-MonoObject*
-mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error)
-{
-       MonoInvocation frame;
-       ThreadContext * volatile context = mono_native_tls_get_value (thread_context_id);
-       MonoObject *retval = NULL;
-       MonoMethodSignature *sig = mono_method_signature (method);
-       MonoClass *klass = mono_class_from_mono_type (sig->ret);
-       int i, type, isobject = 0;
-       void *ret = NULL;
-       stackval result;
-       stackval *args = alloca (sizeof (stackval) * (sig->param_count + !!sig->hasthis));
-       ThreadContext context_struct;
-       MonoInvocation *old_frame = NULL;
-       jmp_buf env;
-
-       error_init (error);
-
-       frame.ex = NULL;
-
-       if (setjmp(env)) {
-               if (context != &context_struct) {
-                       context->domain = mono_domain_get ();
-                       context->current_frame = old_frame;
-                       context->managed_code = 0;
-               } else 
-                       mono_native_tls_set_value (thread_context_id, NULL);
-               if (exc != NULL)
-                       *exc = (MonoObject *)frame.ex;
-               return retval;
-       }
-
-       if (context == NULL) {
-               context = &context_struct;
-               context_struct.base_frame = &frame;
-               context_struct.current_frame = NULL;
-               context_struct.env_frame = &frame;
-               context_struct.current_env = &env;
-               context_struct.search_for_handler = 0;
-               context_struct.managed_code = 0;
-               mono_native_tls_set_value (thread_context_id, context);
-       }
-       else
-               old_frame = context->current_frame;
-
-       context->domain = mono_domain_get ();
-
-       switch (sig->ret->type) {
-       case MONO_TYPE_VOID:
-               break;
-       case MONO_TYPE_STRING:
-       case MONO_TYPE_OBJECT:
-       case MONO_TYPE_CLASS:
-       case MONO_TYPE_ARRAY:
-       case MONO_TYPE_SZARRAY:
-               isobject = 1;
-               break;
-       case MONO_TYPE_VALUETYPE:
-               retval = mono_object_new_checked (context->domain, klass, error);
-               ret = ((char*)retval) + sizeof (MonoObject);
-               if (!sig->ret->data.klass->enumtype)
-                       result.data.vt = ret;
-               break;
-       default:
-               retval = mono_object_new_checked (context->domain, klass, error);
-               ret = ((char*)retval) + sizeof (MonoObject);
-               break;
-       }
-
-       if (sig->hasthis)
-               args [0].data.p = obj;
-
-       for (i = 0; i < sig->param_count; ++i) {
-               int a_index = i + !!sig->hasthis;
-               if (sig->params [i]->byref) {
-                       args [a_index].data.p = params [i];
-                       continue;
-               }
-               type = sig->params [i]->type;
-handle_enum:
-               switch (type) {
-               case MONO_TYPE_U1:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_BOOLEAN:
-                       args [a_index].data.i = *(MonoBoolean*)params [i];
-                       break;
-               case MONO_TYPE_U2:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_CHAR:
-                       args [a_index].data.i = *(gint16*)params [i];
-                       break;
-#if SIZEOF_VOID_P == 4
-               case MONO_TYPE_U: /* use VAL_POINTER? */
-               case MONO_TYPE_I:
-#endif
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I4:
-                       args [a_index].data.i = *(gint32*)params [i];
-                       break;
-#if SIZEOF_VOID_P == 8
-               case MONO_TYPE_U:
-               case MONO_TYPE_I:
-#endif
-               case MONO_TYPE_U8:
-               case MONO_TYPE_I8:
-                       args [a_index].data.l = *(gint64*)params [i];
-                       break;
-               case MONO_TYPE_VALUETYPE:
-                       if (sig->params [i]->data.klass->enumtype) {
-                               type = mono_class_enum_basetype (sig->params [i]->data.klass)->type;
-                               goto handle_enum;
-                       } else {
-                               args [a_index].data.p = params [i];
-                       }
-                       break;
-               case MONO_TYPE_STRING:
-               case MONO_TYPE_CLASS:
-               case MONO_TYPE_ARRAY:
-               case MONO_TYPE_SZARRAY:
-               case MONO_TYPE_OBJECT:
-                       args [a_index].data.p = params [i];
-                       break;
-               default:
-                       g_error ("type 0x%x not handled in  runtime invoke", sig->params [i]->type);
-               }
-       }
-
-       if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
-               method = mono_marshal_get_native_wrapper (method, FALSE, FALSE);
-       INIT_FRAME (&frame,context->current_frame,args,&result,mono_get_root_domain (),method,error);
-       if (exc)
-               frame.invoke_trap = 1;
-       context->managed_code = 1;
-       ves_exec_method_with_context (&frame, context);
-       context->managed_code = 0;
-       if (context == &context_struct)
-               mono_native_tls_set_value (thread_context_id, NULL);
-       else
-               context->current_frame = old_frame;
-       if (frame.ex != NULL) {
-               if (exc != NULL) {
-                       *exc = (MonoObject*) frame.ex;
-                       return NULL;
-               }
-               if (context->current_env != NULL) {
-                       context->env_frame->ex = frame.ex;
-                       longjmp(*context->current_env, 1);
-               }
-               else
-                       printf("dropped exception...\n");
-       }
-       if (sig->ret->type == MONO_TYPE_VOID && !method->string_ctor)
-               return NULL;
-       if (isobject || method->string_ctor)
-               return result.data.p;
-       stackval_to_data (sig->ret, &result, ret, sig->pinvoke);
-       return retval;
-}
-
-static stackval * 
-do_icall (ThreadContext *context, int op, stackval *sp, gpointer ptr)
-{
-       MonoInvocation *old_frame = context->current_frame;
-       MonoInvocation *old_env_frame = context->env_frame;
-       jmp_buf *old_env = context->current_env;
-       jmp_buf env;
-
-       if (setjmp (env)) {
-               context->current_frame = old_frame;
-               context->env_frame = old_env_frame;
-               context->current_env = old_env;
-               context->managed_code = 1;
-               return sp;
-       }
-
-       context->env_frame = context->current_frame;
-       context->current_env = &env;
-       context->managed_code = 0;
-
-       switch (op) {
-       case MINT_ICALL_V_V: {
-               void (*func)() = ptr;
-               func ();
-               break;
-       }
-       case MINT_ICALL_V_P: {
-               gpointer (*func)() = ptr;
-               sp++;
-               sp [-1].data.p = func ();
-               break;
-       }
-       case MINT_ICALL_P_V: {
-               void (*func)(gpointer) = ptr;
-               func (sp [-1].data.p);
-               sp --;
-               break;
-       }
-       case MINT_ICALL_P_P: {
-               gpointer (*func)(gpointer) = ptr;
-               sp [-1].data.p = func (sp [-1].data.p);
-               break;
-       }
-       case MINT_ICALL_PP_V: {
-               void (*func)(gpointer,gpointer) = ptr;
-               sp -= 2;
-               func (sp [0].data.p, sp [1].data.p);
-               break;
-       }
-       case MINT_ICALL_PI_V: {
-               void (*func)(gpointer,int) = ptr;
-               sp -= 2;
-               func (sp [0].data.p, sp [1].data.i);
-               break;
-       }
-       case MINT_ICALL_PP_P: {
-               gpointer (*func)(gpointer,gpointer) = ptr;
-               --sp;
-               sp [-1].data.p = func (sp [-1].data.p, sp [0].data.p);
-               break;
-       }
-       case MINT_ICALL_PI_P: {
-               gpointer (*func)(gpointer,int) = ptr;
-               --sp;
-               sp [-1].data.p = func (sp [-1].data.p, sp [0].data.i);
-               break;
-       }
-       case MINT_ICALL_PPP_V: {
-               void (*func)(gpointer,gpointer,gpointer) = ptr;
-               sp -= 3;
-               func (sp [0].data.p, sp [1].data.p, sp [2].data.p);
-               break;
-       }
-       case MINT_ICALL_PPI_V: {
-               void (*func)(gpointer,gpointer,int) = ptr;
-               sp -= 3;
-               func (sp [0].data.p, sp [1].data.p, sp [2].data.i);
-               break;
-       }
-       default:
-               g_assert_not_reached ();
-       }
-
-       context->env_frame = old_env_frame;
-       context->current_env = old_env;
-
-       return sp;
-}
-
-static mono_mutex_t create_method_pointer_mutex;
-
-static GHashTable *method_pointer_hash = NULL;
-
-static MonoMethod *method_pointers [2] = {0};
-
-static MonoObject *
-mp_tramp_0 (MonoObject *this_obj, void **params, MonoObject **exc, void *compiled_method) {
-       MonoError error;
-       void *params_real[] = {this_obj, &params, &exc, &compiled_method};
-       MonoObject *ret = mono_interp_runtime_invoke (method_pointers [0], NULL, params_real, NULL, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-       return ret;
-}
-
-static MonoObject *
-mp_tramp_1 (MonoObject *this_obj, void **params, MonoObject **exc, void *compiled_method) {
-       MonoError error;
-       void *params_real[] = {this_obj, &params, &exc, &compiled_method};
-       MonoObject *ret = mono_interp_runtime_invoke (method_pointers [1], NULL, params_real, NULL, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-       return ret;
-}
-
-gpointer *mp_tramps[] = {(gpointer) mp_tramp_0, (gpointer) mp_tramp_1};
-
-static int tramps_used = 0;
-
-gpointer
-mono_interp_create_method_pointer (MonoMethod *method, MonoError *error)
-{
-       gpointer addr;
-       MonoJitInfo *ji;
-
-       mono_os_mutex_lock (&create_method_pointer_mutex);
-       if (!method_pointer_hash) {
-               // FIXME: is registering method table as GC root really necessary?
-               // MONO_GC_REGISTER_ROOT_FIXED (method_pointer_hash);
-               method_pointer_hash = g_hash_table_new (NULL, NULL);
-       }
-       addr = g_hash_table_lookup (method_pointer_hash, method);
-       if (addr) {
-               mono_os_mutex_unlock (&create_method_pointer_mutex);
-               return addr;
-       }
-
-       /*
-        * If it is a static P/Invoke method, we can just return the pointer
-        * to the method implementation.
-        */
-       if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL && ((MonoMethodPInvoke*) method)->addr) {
-               ji = g_new0 (MonoJitInfo, 1);
-               ji->d.method = method;
-               ji->code_size = 1;
-               ji->code_start = addr = ((MonoMethodPInvoke*) method)->addr;
-
-               mono_jit_info_table_add (mono_get_root_domain (), ji);
-       }               
-       else {
-               g_assert (method->wrapper_type == MONO_WRAPPER_RUNTIME_INVOKE);
-               g_assert (tramps_used < 2);
-
-               /* FIXME: needs locking */
-               method_pointers [tramps_used] = method;
-               addr = mp_tramps [tramps_used];
-               tramps_used++;
-       }
-
-       g_hash_table_insert (method_pointer_hash, method, addr);
-       mono_os_mutex_unlock (&create_method_pointer_mutex);
-
-       return addr;
-}
-
-#if COUNT_OPS
-static int opcode_counts[512];
-
-#define COUNT_OP(op) opcode_counts[op]++
-#else
-#define COUNT_OP(op) 
-#endif
-
-#if DEBUG_INTERP
-#define DUMP_INSTR() \
-       if (tracing > 1) { \
-               char *ins; \
-               if (sp > frame->stack) { \
-                       ins = dump_stack (frame->stack, sp); \
-               } else { \
-                       ins = g_strdup (""); \
-               } \
-               sp->data.l = 0; \
-               output_indent (); \
-               char *mn = mono_method_full_name (frame->runtime_method->method, FALSE); \
-               g_print ("(%p) %s -> ", mono_thread_internal_current (), mn); \
-               g_free (mn); \
-               mono_interp_dis_mintop(rtm->code, ip); \
-               g_print ("\t%d:%s\n", vt_sp - vtalloc, ins); \
-               g_free (ins); \
-       }
-#else
-#define DUMP_INSTR()
-#endif
-
-#ifdef __GNUC__
-#define USE_COMPUTED_GOTO 1
-#endif
-#if USE_COMPUTED_GOTO
-#define MINT_IN_SWITCH(op) COUNT_OP(op); goto *in_labels[op];
-#define MINT_IN_CASE(x) LAB_ ## x:
-#if DEBUG_INTERP
-#define MINT_IN_BREAK if (tracing > 1) goto main_loop; else { COUNT_OP(*ip); goto *in_labels[*ip]; }
-#else
-#define MINT_IN_BREAK { COUNT_OP(*ip); goto *in_labels[*ip]; }
-#endif
-#define MINT_IN_DEFAULT mint_default: if (0) goto mint_default; /* make gcc shut up */
-#else
-#define MINT_IN_SWITCH(op) switch (op)
-#define MINT_IN_CASE(x) case x:
-#define MINT_IN_BREAK break
-#define MINT_IN_DEFAULT default:
-#endif
-
-/* 
- * Defining this causes register allocation errors in some versions of gcc:
- * error: unable to find a register to spill in class `SIREG'
- */
-/* #define MINT_USE_DEDICATED_IP_REG */
-
-static void 
-ves_exec_method_with_context (MonoInvocation *frame, ThreadContext *context)
-{
-       MonoInvocation child_frame;
-       GSList *finally_ips = NULL;
-       const unsigned short *endfinally_ip = NULL;
-#if defined(__GNUC__) && defined (i386) && defined (MINT_USE_DEDICATED_IP_REG)
-       register const unsigned short *ip asm ("%esi");
-#else
-       register const unsigned short *ip;
-#endif
-       register stackval *sp;
-       RuntimeMethod *rtm;
-#if DEBUG_INTERP
-       gint tracing = global_tracing;
-       unsigned char *vtalloc;
-#endif
-       int i32;
-       unsigned char *vt_sp;
-       unsigned char *locals;
-       MonoError error;
-       MonoObject *o = NULL;
-       MonoClass *c;
-#if USE_COMPUTED_GOTO
-       static void *in_labels[] = {
-#define OPDEF(a,b,c,d) \
-       &&LAB_ ## a,
-#include "mintops.def"
-       0 };
-#endif
-
-       frame->ex = NULL;
-       frame->ex_handler = NULL;
-       frame->ip = NULL;
-       context->current_frame = frame;
-
-#if DEBUG_INTERP
-       debug_enter (frame, &tracing);
-#endif
-
-       if (!frame->runtime_method->transformed) {
-               context->managed_code = 0;
-#if DEBUG_INTERP
-               char *mn = mono_method_full_name (frame->runtime_method->method, FALSE);
-               g_print ("(%p) Transforming %s\n", mono_thread_internal_current (), mn);
-               g_free (mn);
-#endif
-               frame->ex = mono_interp_transform_method (frame->runtime_method, context);
-               context->managed_code = 1;
-               if (frame->ex) {
-                       rtm = NULL;
-                       ip = NULL;
-                       goto exit_frame;
-               }
-       }
-
-       rtm = frame->runtime_method;
-       frame->args = alloca (rtm->alloca_size);
-       sp = frame->stack = (stackval *)((char *)frame->args + rtm->args_size);
-#if DEBUG_INTERP
-       if (tracing > 1)
-               memset(sp, 0, rtm->stack_size);
-#endif
-       vt_sp = (unsigned char *) sp + rtm->stack_size;
-#if DEBUG_INTERP
-       vtalloc = vt_sp;
-#endif
-       locals = (unsigned char *) vt_sp + rtm->vt_stack_size;
-
-       child_frame.parent = frame;
-
-       /* ready to go */
-       ip = rtm->code;
-
-       /*
-        * using while (ip < end) may result in a 15% performance drop, 
-        * but it may be useful for debug
-        */
-       while (1) {
-       main_loop:
-               /* g_assert (sp >= frame->stack); */
-               /* g_assert(vt_sp - vtalloc <= rtm->vt_stack_size); */
-               DUMP_INSTR();
-               MINT_IN_SWITCH (*ip) {
-               MINT_IN_CASE(MINT_INITLOCALS)
-                       memset (locals, 0, rtm->locals_size);
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_NOP)
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BREAK)
-                       ++ip;
-                       G_BREAKPOINT (); /* this is not portable... */
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDNULL) 
-                       sp->data.p = NULL;
-                       ++ip;
-                       ++sp;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_VTRESULT) {
-                       int ret_size = * (guint16 *)(ip + 1);
-                       unsigned char *ret_vt_sp = vt_sp;
-                       vt_sp -= READ32(ip + 2);
-                       if (ret_size > 0) {
-                               memmove (vt_sp, ret_vt_sp, ret_size);
-                               sp [-1].data.p = vt_sp;
-                               vt_sp += (ret_size + 7) & ~7;
-                       }
-                       ip += 4;
-                       MINT_IN_BREAK;
-               }
-#define LDC(n) do { sp->data.i = (n); ++ip; ++sp; } while (0)
-               MINT_IN_CASE(MINT_LDC_I4_M1)
-                       LDC(-1);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_I4_0)
-                       LDC(0);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_I4_1)
-                       LDC(1);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_I4_2)
-                       LDC(2);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_I4_3)
-                       LDC(3);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_I4_4)
-                       LDC(4);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_I4_5)
-                       LDC(5);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_I4_6)
-                       LDC(6);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_I4_7)
-                       LDC(7);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_I4_8)
-                       LDC(8);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_I4_S) 
-                       sp->data.i = *(const short *)(ip + 1);
-                       ip += 2;
-                       ++sp;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_I4)
-                       ++ip;
-                       sp->data.i = READ32 (ip);
-                       ip += 2;
-                       ++sp;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_I8)
-                       ++ip;
-                       sp->data.l = READ64 (ip);
-                       ip += 4;
-                       ++sp;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDC_R4) {
-                       guint32 val;
-                       ++ip;
-                       val = READ32(ip);
-                       sp->data.f = * (float *)&val;
-                       ip += 2;
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDC_R8) 
-                       sp->data.l = READ64 (ip + 1); /* note union usage */
-                       ip += 5;
-                       ++sp;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_DUP) 
-                       sp [0] = sp[-1];
-                       ++sp;
-                       ++ip; 
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_DUP_VT)
-                       i32 = READ32 (ip + 1);
-                       sp->data.p = vt_sp;
-                       memcpy(sp->data.p, sp [-1].data.p, i32);
-                       vt_sp += (i32 + 7) & ~7;
-                       ++sp;
-                       ip += 3;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_POP)
-                       ++ip;
-                       --sp;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_JMP) {
-                       RuntimeMethod *new_method = rtm->data_items [* (guint16 *)(ip + 1)];
-                       if (!new_method->transformed) {
-                               frame->ip = ip;
-                               frame->ex = mono_interp_transform_method (new_method, context);
-                               if (frame->ex)
-                                       goto exit_frame;
-                       }
-                       ip += 2;
-                       if (new_method->alloca_size > rtm->alloca_size)
-                               g_error ("MINT_JMP to method which needs more stack space (%d > %d)", new_method->alloca_size, rtm->alloca_size); 
-                       rtm = frame->runtime_method = new_method;
-                       vt_sp = (unsigned char *) sp + rtm->stack_size;
-#if DEBUG_INTERP
-                       vtalloc = vt_sp;
-#endif
-                       locals = vt_sp + rtm->vt_stack_size;
-                       ip = rtm->new_body_start; /* bypass storing input args from callers frame */
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_CALLI) {
-                       MonoMethodSignature *csignature;
-                       stackval *endsp = sp;
-
-                       frame->ip = ip;
-                       
-                       csignature = rtm->data_items [* (guint16 *)(ip + 1)];
-                       ip += 2;
-                       --sp;
-                       --endsp;
-                       child_frame.runtime_method = sp->data.p;
-
-                       sp->data.p = vt_sp;
-                       child_frame.retval = sp;
-                       /* decrement by the actual number of args */
-                       sp -= csignature->param_count;
-                       if (csignature->hasthis)
-                               --sp;
-                       child_frame.stack_args = sp;
-
-                       /* `this' can be NULL for string:.ctor */
-                       if (csignature->hasthis && sp->data.p && mono_object_is_transparent_proxy (sp->data.p)) {
-                               child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       } else if (child_frame.runtime_method->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
-                               child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_native_wrapper (child_frame.runtime_method->method, FALSE, FALSE), &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       }
-
-                       ves_exec_method_with_context (&child_frame, context);
-
-                       context->current_frame = frame;
-
-                       if (child_frame.ex) {
-                               /*
-                                * An exception occurred, need to run finally, fault and catch handlers..
-                                */
-                               frame->ex = child_frame.ex;
-                               goto handle_finally;
-                       }
-
-                       /* need to handle typedbyref ... */
-                       if (csignature->ret->type != MONO_TYPE_VOID) {
-                               *sp = *endsp;
-                               sp++;
-                       }
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_CALLI_NAT) {
-                       MonoMethodSignature *csignature;
-                       stackval *endsp = sp;
-                       unsigned char *code = NULL;
-
-                       frame->ip = ip;
-                       
-                       csignature = rtm->data_items [* (guint16 *)(ip + 1)];
-                       ip += 2;
-                       --sp;
-                       --endsp;
-                       code = sp->data.p;
-                       child_frame.runtime_method = NULL;
-
-                       sp->data.p = vt_sp;
-                       child_frame.retval = sp;
-                       /* decrement by the actual number of args */
-                       sp -= csignature->param_count;
-                       if (csignature->hasthis)
-                               --sp;
-                       child_frame.stack_args = sp;
-                       ves_pinvoke_method (&child_frame, csignature, (MonoFuncV) code, FALSE, context);
-
-                       context->current_frame = frame;
-
-                       if (child_frame.ex) {
-                               /*
-                                * An exception occurred, need to run finally, fault and catch handlers..
-                                */
-                               frame->ex = child_frame.ex;
-                               if (context->search_for_handler) {
-                                       context->search_for_handler = 0;
-                                       goto handle_exception;
-                               }
-                               goto handle_finally;
-                       }
-
-                       /* need to handle typedbyref ... */
-                       if (csignature->ret->type != MONO_TYPE_VOID) {
-                               *sp = *endsp;
-                               sp++;
-                       }
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_CALL) {
-                       stackval *endsp = sp;
-
-                       frame->ip = ip;
-                       
-                       child_frame.runtime_method = rtm->data_items [* (guint16 *)(ip + 1)];
-                       ip += 2;
-                       sp->data.p = vt_sp;
-                       child_frame.retval = sp;
-                       /* decrement by the actual number of args */
-                       sp -= child_frame.runtime_method->param_count;
-                       if (child_frame.runtime_method->hasthis)
-                               --sp;
-                       child_frame.stack_args = sp;
-
-                       /* `this' can be NULL for string:.ctor */
-                       if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->valuetype && sp->data.p && mono_object_is_transparent_proxy (sp->data.p)) {
-                               child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       }
-                       ves_exec_method_with_context (&child_frame, context);
-
-                       context->current_frame = frame;
-
-                       if (child_frame.ex) {
-                               /*
-                                * An exception occurred, need to run finally, fault and catch handlers..
-                                */
-                               frame->ex = child_frame.ex;
-                               goto handle_finally;
-                       }
-
-                       /* need to handle typedbyref ... */
-                       *sp = *endsp;
-                       sp++;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_VCALL) {
-                       frame->ip = ip;
-                       
-                       child_frame.runtime_method = rtm->data_items [* (guint16 *)(ip + 1)];
-                       ip += 2;
-
-                       sp->data.p = vt_sp;
-                       child_frame.retval = sp;
-                       /* decrement by the actual number of args */
-                       sp -= child_frame.runtime_method->param_count;
-                       if (child_frame.runtime_method->hasthis)
-                               --sp;
-                       child_frame.stack_args = sp;
-
-                       if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->valuetype && mono_object_is_transparent_proxy (sp->data.p)) {
-                               child_frame.runtime_method = mono_interp_get_runtime_method (context->domain, mono_marshal_get_remoting_invoke (child_frame.runtime_method->method), &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       }
-
-                       ves_exec_method_with_context (&child_frame, context);
-
-                       context->current_frame = frame;
-
-                       if (child_frame.ex) {
-                               /*
-                                * An exception occurred, need to run finally, fault and catch handlers..
-                                */
-                               frame->ex = child_frame.ex;
-                               goto handle_finally;
-                       }
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_CALLVIRT) {
-                       stackval *endsp = sp;
-                       MonoObject *this_arg;
-                       guint32 token;
-
-                       frame->ip = ip;
-                       
-                       token = * (unsigned short *)(ip + 1);
-                       ip += 2;
-                       child_frame.runtime_method = rtm->data_items [token];
-                       sp->data.p = vt_sp;
-                       child_frame.retval = sp;
-
-                       /* decrement by the actual number of args */
-                       sp -= child_frame.runtime_method->param_count + 1;
-                       child_frame.stack_args = sp;
-                       this_arg = sp->data.p;
-                       if (!this_arg)
-                               THROW_EX (mono_get_exception_null_reference(), ip - 2);
-                       child_frame.runtime_method = get_virtual_method (context->domain, child_frame.runtime_method, this_arg);
-
-                       if (this_arg->vtable->klass->valuetype && child_frame.runtime_method->valuetype) {
-                               /* unbox */
-                               gpointer *unboxed = mono_object_unbox (this_arg);
-                               stackval_from_data (&this_arg->vtable->klass->byval_arg, sp, (char *) unboxed, FALSE);
-                       }
-
-                       ves_exec_method_with_context (&child_frame, context);
-
-                       context->current_frame = frame;
-
-                       if (child_frame.ex) {
-                               /*
-                                * An exception occurred, need to run finally, fault and catch handlers..
-                                */
-                               frame->ex = child_frame.ex;
-                               if (context->search_for_handler) {
-                                       context->search_for_handler = 0;
-                                       goto handle_exception;
-                               }
-                               goto handle_finally;
-                       }
-
-                       /* need to handle typedbyref ... */
-                       *sp = *endsp;
-                       sp++;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_VCALLVIRT) {
-                       MonoObject *this_arg;
-                       guint32 token;
-
-                       frame->ip = ip;
-                       
-                       token = * (unsigned short *)(ip + 1);
-                       ip += 2;
-                       child_frame.runtime_method = rtm->data_items [token];
-                       sp->data.p = vt_sp;
-                       child_frame.retval = sp;
-
-                       /* decrement by the actual number of args */
-                       sp -= child_frame.runtime_method->param_count + 1;
-                       child_frame.stack_args = sp;
-                       this_arg = sp->data.p;
-                       if (!this_arg)
-                               THROW_EX (mono_get_exception_null_reference(), ip - 2);
-                       child_frame.runtime_method = get_virtual_method (context->domain, child_frame.runtime_method, this_arg);
-
-                       if (this_arg->vtable->klass->valuetype && child_frame.runtime_method->valuetype) {
-                               gpointer *unboxed = mono_object_unbox (this_arg);
-                               stackval_from_data (&this_arg->vtable->klass->byval_arg, sp, (char *) unboxed, FALSE);
-                       }
-
-                       ves_exec_method_with_context (&child_frame, context);
-
-                       context->current_frame = frame;
-
-                       if (child_frame.ex) {
-                               /*
-                                * An exception occurred, need to run finally, fault and catch handlers..
-                                */
-                               frame->ex = child_frame.ex;
-                               if (context->search_for_handler) {
-                                       context->search_for_handler = 0;
-                                       goto handle_exception;
-                               }
-                               goto handle_finally;
-                       }
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_CALLRUN)
-                       ves_runtime_method (frame, context);
-                       if (frame->ex) {
-                               rtm = NULL;
-                               goto handle_exception;
-                       }
-                       goto exit_frame;
-               MINT_IN_CASE(MINT_RET)
-                       --sp;
-                       *frame->retval = *sp;
-                       if (sp > frame->stack)
-                               g_warning ("ret: more values on stack: %d", sp-frame->stack);
-                       goto exit_frame;
-               MINT_IN_CASE(MINT_RET_VOID)
-                       if (sp > frame->stack)
-                               g_warning ("ret.void: more values on stack: %d", sp-frame->stack);
-                       goto exit_frame;
-               MINT_IN_CASE(MINT_RET_VT)
-                       i32 = READ32(ip + 1);
-                       --sp;
-                       memcpy(frame->retval->data.p, sp->data.p, i32);
-                       if (sp > frame->stack)
-                               g_warning ("ret.vt: more values on stack: %d", sp-frame->stack);
-                       goto exit_frame;
-               MINT_IN_CASE(MINT_BR_S)
-                       ip += (short) *(ip + 1);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BR)
-                       ip += (gint32) READ32(ip + 1);
-                       MINT_IN_BREAK;
-#define ZEROP_S(datamem, op) \
-       --sp; \
-       if (sp->data.datamem op 0) \
-               ip += * (gint16 *)(ip + 1); \
-       else \
-               ip += 2;
-
-#define ZEROP(datamem, op) \
-       --sp; \
-       if (sp->data.datamem op 0) \
-               ip += READ32(ip + 1); \
-       else \
-               ip += 3;
-
-               MINT_IN_CASE(MINT_BRFALSE_I4_S)
-                       ZEROP_S(i, ==);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BRFALSE_I8_S)
-                       ZEROP_S(l, ==);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BRFALSE_R8_S)
-                       ZEROP_S(f, ==);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BRFALSE_I4)
-                       ZEROP(i, ==);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BRFALSE_I8)
-                       ZEROP(l, ==);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BRFALSE_R8)
-                       ZEROP_S(f, ==);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BRTRUE_I4_S)
-                       ZEROP_S(i, !=);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BRTRUE_I8_S)
-                       ZEROP_S(l, !=);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BRTRUE_R8_S)
-                       ZEROP_S(f, !=);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BRTRUE_I4)
-                       ZEROP(i, !=);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BRTRUE_I8)
-                       ZEROP(l, !=);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BRTRUE_R8)
-                       ZEROP(f, !=);
-                       MINT_IN_BREAK;
-#define CONDBR_S(cond) \
-       sp -= 2; \
-       if (cond) \
-               ip += * (gint16 *)(ip + 1); \
-       else \
-               ip += 2;
-#define BRELOP_S(datamem, op) \
-       CONDBR_S(sp[0].data.datamem op sp[1].data.datamem)
-
-#define CONDBR(cond) \
-       sp -= 2; \
-       if (cond) \
-               ip += READ32(ip + 1); \
-       else \
-               ip += 3;
-
-#define BRELOP(datamem, op) \
-       CONDBR(sp[0].data.datamem op sp[1].data.datamem)
-
-               MINT_IN_CASE(MINT_BEQ_I4_S)
-                       BRELOP_S(i, ==)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BEQ_I8_S)
-                       BRELOP_S(l, ==)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BEQ_R8_S)
-                       CONDBR_S(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f == sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BEQ_I4)
-                       BRELOP(i, ==)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BEQ_I8)
-                       BRELOP(l, ==)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BEQ_R8)
-                       CONDBR(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f == sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGE_I4_S)
-                       BRELOP_S(i, >=)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGE_I8_S)
-                       BRELOP_S(l, >=)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGE_R8_S)
-                       CONDBR_S(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f >= sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGE_I4)
-                       BRELOP(i, >=)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGE_I8)
-                       BRELOP(l, >=)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGE_R8)
-                       CONDBR(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f >= sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGT_I4_S)
-                       BRELOP_S(i, >)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGT_I8_S)
-                       BRELOP_S(l, >)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGT_R8_S)
-                       CONDBR_S(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f > sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGT_I4)
-                       BRELOP(i, >)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGT_I8)
-                       BRELOP(l, >)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGT_R8)
-                       CONDBR(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f > sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLT_I4_S)
-                       BRELOP_S(i, <)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLT_I8_S)
-                       BRELOP_S(l, <)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLT_R8_S)
-                       CONDBR_S(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f < sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLT_I4)
-                       BRELOP(i, <)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLT_I8)
-                       BRELOP(l, <)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLT_R8)
-                       CONDBR(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f < sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLE_I4_S)
-                       BRELOP_S(i, <=)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLE_I8_S)
-                       BRELOP_S(l, <=)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLE_R8_S)
-                       CONDBR_S(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f <= sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLE_I4)
-                       BRELOP(i, <=)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLE_I8)
-                       BRELOP(l, <=)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLE_R8)
-                       CONDBR(!isunordered (sp [0].data.f, sp [1].data.f) && sp[0].data.f <= sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BNE_UN_I4_S)
-                       BRELOP_S(i, !=)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BNE_UN_I8_S)
-                       BRELOP_S(l, !=)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BNE_UN_R8_S)
-                       CONDBR_S(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f != sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BNE_UN_I4)
-                       BRELOP(i, !=)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BNE_UN_I8)
-                       BRELOP(l, !=)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BNE_UN_R8)
-                       CONDBR(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f != sp[1].data.f)
-                       MINT_IN_BREAK;
-
-#define BRELOP_S_CAST(datamem, op, type) \
-       sp -= 2; \
-       if ((type) sp[0].data.datamem op (type) sp[1].data.datamem) \
-               ip += * (gint16 *)(ip + 1); \
-       else \
-               ip += 2;
-
-#define BRELOP_CAST(datamem, op, type) \
-       sp -= 2; \
-       if ((type) sp[0].data.datamem op (type) sp[1].data.datamem) \
-               ip += READ32(ip + 1); \
-       else \
-               ip += 3;
-
-               MINT_IN_CASE(MINT_BGE_UN_I4_S)
-                       BRELOP_S_CAST(i, >=, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGE_UN_I8_S)
-                       BRELOP_S_CAST(l, >=, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGE_UN_R8_S)
-                       CONDBR_S(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f >= sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGE_UN_I4)
-                       BRELOP_CAST(i, >=, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGE_UN_I8)
-                       BRELOP_CAST(l, >=, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGE_UN_R8)
-                       CONDBR(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f >= sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGT_UN_I4_S)
-                       BRELOP_S_CAST(i, >, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGT_UN_I8_S)
-                       BRELOP_S_CAST(l, >, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGT_UN_R8_S)
-                       CONDBR_S(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f > sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGT_UN_I4)
-                       BRELOP_CAST(i, >, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGT_UN_I8)
-                       BRELOP_CAST(l, >, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BGT_UN_R8)
-                       CONDBR(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f > sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLE_UN_I4_S)
-                       BRELOP_S_CAST(i, <=, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLE_UN_I8_S)
-                       BRELOP_S_CAST(l, <=, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLE_UN_R8_S)
-                       CONDBR_S(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f <= sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLE_UN_I4)
-                       BRELOP_CAST(i, <=, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLE_UN_I8)
-                       BRELOP_CAST(l, <=, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLE_UN_R8)
-                       CONDBR(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f <= sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLT_UN_I4_S)
-                       BRELOP_S_CAST(i, <, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLT_UN_I8_S)
-                       BRELOP_S_CAST(l, <, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLT_UN_R8_S)
-                       CONDBR_S(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f < sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLT_UN_I4)
-                       BRELOP_CAST(i, <, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLT_UN_I8)
-                       BRELOP_CAST(l, <, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BLT_UN_R8)
-                       CONDBR(isunordered (sp [0].data.f, sp [1].data.f) || sp[0].data.f < sp[1].data.f)
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SWITCH) {
-                       guint32 n;
-                       const unsigned short *st;
-                       ++ip;
-                       n = READ32 (ip);
-                       ip += 2;
-                       st = ip + 2 * n;
-                       --sp;
-                       if ((guint32)sp->data.i < n) {
-                               gint offset;
-                               ip += 2 * (guint32)sp->data.i;
-                               offset = READ32 (ip);
-                               ip = st + offset;
-                       } else {
-                               ip = st;
-                       }
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDIND_I1)
-                       ++ip;
-                       sp[-1].data.i = *(gint8*)sp[-1].data.p;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDIND_U1)
-                       ++ip;
-                       sp[-1].data.i = *(guint8*)sp[-1].data.p;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDIND_I2)
-                       ++ip;
-                       sp[-1].data.i = *(gint16*)sp[-1].data.p;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDIND_U2)
-                       ++ip;
-                       sp[-1].data.i = *(guint16*)sp[-1].data.p;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDIND_I4) /* Fall through */
-               MINT_IN_CASE(MINT_LDIND_U4)
-                       ++ip;
-                       sp[-1].data.i = *(gint32*)sp[-1].data.p;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDIND_I8)
-                       ++ip;
-                       sp[-1].data.l = *(gint64*)sp[-1].data.p;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDIND_I) {
-                       guint16 offset = * (guint16 *)(ip + 1);
-                       sp[-1 - offset].data.p = *(gpointer*)sp[-1 - offset].data.p;
-                       ip += 2;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDIND_R4)
-                       ++ip;
-                       sp[-1].data.f = *(gfloat*)sp[-1].data.p;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDIND_R8)
-                       ++ip;
-                       sp[-1].data.f = *(gdouble*)sp[-1].data.p;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDIND_REF)
-                       ++ip;
-                       sp[-1].data.p = *(gpointer*)sp[-1].data.p;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STIND_REF) 
-                       ++ip;
-                       sp -= 2;
-                       * (gpointer *) sp->data.p = sp[1].data.p;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STIND_I1)
-                       ++ip;
-                       sp -= 2;
-                       * (gint8 *) sp->data.p = (gint8)sp[1].data.i;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STIND_I2)
-                       ++ip;
-                       sp -= 2;
-                       * (gint16 *) sp->data.p = (gint16)sp[1].data.i;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STIND_I4)
-                       ++ip;
-                       sp -= 2;
-                       * (gint32 *) sp->data.p = sp[1].data.i;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STIND_I)
-                       ++ip;
-                       sp -= 2;
-                       * (mono_i *) sp->data.p = (mono_i)sp[1].data.p;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STIND_I8)
-                       ++ip;
-                       sp -= 2;
-                       * (gint64 *) sp->data.p = sp[1].data.l;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STIND_R4)
-                       ++ip;
-                       sp -= 2;
-                       * (float *) sp->data.p = (gfloat)sp[1].data.f;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STIND_R8)
-                       ++ip;
-                       sp -= 2;
-                       * (double *) sp->data.p = sp[1].data.f;
-                       MINT_IN_BREAK;
-#define BINOP(datamem, op) \
-       --sp; \
-       sp [-1].data.datamem = sp [-1].data.datamem op sp [0].data.datamem; \
-       ++ip;
-               MINT_IN_CASE(MINT_ADD_I4)
-                       BINOP(i, +);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_ADD_I8)
-                       BINOP(l, +);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_ADD_R8)
-                       BINOP(f, +);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_ADD1_I4)
-                       ++sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SUB_I4)
-                       BINOP(i, -);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SUB_I8)
-                       BINOP(l, -);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SUB_R8)
-                       BINOP(f, -);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SUB1_I4)
-                       --sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_MUL_I4)
-                       BINOP(i, *);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_MUL_I8)
-                       BINOP(l, *);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_MUL_R8)
-                       BINOP(f, *);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_DIV_I4)
-                       if (sp [-1].data.i == 0)
-                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
-                       if (sp [-1].data.i == (-1))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP(i, /);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_DIV_I8)
-                       if (sp [-1].data.l == 0)
-                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
-                       if (sp [-1].data.l == (-1))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP(l, /);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_DIV_R8)
-                       BINOP(f, /);
-                       MINT_IN_BREAK;
-
-#define BINOP_CAST(datamem, op, type) \
-       --sp; \
-       sp [-1].data.datamem = (type)sp [-1].data.datamem op (type)sp [0].data.datamem; \
-       ++ip;
-               MINT_IN_CASE(MINT_DIV_UN_I4)
-                       if (sp [-1].data.i == 0)
-                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
-                       BINOP_CAST(i, /, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_DIV_UN_I8)
-                       if (sp [-1].data.l == 0)
-                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
-                       BINOP_CAST(l, /, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_REM_I4)
-                       if (sp [-1].data.i == 0)
-                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
-                       BINOP(i, %);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_REM_I8)
-                       if (sp [-1].data.l == 0)
-                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
-                       BINOP(l, %);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_REM_R8)
-                       /* FIXME: what do we actually do here? */
-                       --sp;
-                       sp [-1].data.f = fmod (sp [-1].data.f, sp [0].data.f);
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_REM_UN_I4)
-                       if (sp [-1].data.i == 0)
-                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
-                       BINOP_CAST(i, %, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_REM_UN_I8)
-                       if (sp [-1].data.l == 0)
-                               THROW_EX (mono_get_exception_divide_by_zero (), ip);
-                       BINOP_CAST(l, %, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_AND_I4)
-                       BINOP(i, &);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_AND_I8)
-                       BINOP(l, &);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_OR_I4)
-                       BINOP(i, |);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_OR_I8)
-                       BINOP(l, |);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_XOR_I4)
-                       BINOP(i, ^);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_XOR_I8)
-                       BINOP(l, ^);
-                       MINT_IN_BREAK;
-
-#define SHIFTOP(datamem, op) \
-       --sp; \
-       sp [-1].data.datamem = sp [-1].data.datamem op sp [0].data.i; \
-       ++ip;
-
-               MINT_IN_CASE(MINT_SHL_I4)
-                       SHIFTOP(i, <<);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SHL_I8)
-                       SHIFTOP(l, <<);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SHR_I4)
-                       SHIFTOP(i, >>);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SHR_I8)
-                       SHIFTOP(l, >>);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SHR_UN_I4)
-                       --sp;
-                       sp [-1].data.i = (guint32)sp [-1].data.i >> sp [0].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SHR_UN_I8)
-                       --sp;
-                       sp [-1].data.l = (guint64)sp [-1].data.l >> sp [0].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_NEG_I4)
-                       sp [-1].data.i = - sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_NEG_I8)
-                       sp [-1].data.l = - sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_NEG_R8)
-                       sp [-1].data.f = - sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_NOT_I4)
-                       sp [-1].data.i = ~ sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_NOT_I8)
-                       sp [-1].data.l = ~ sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_I1_I4)
-                       sp [-1].data.i = (gint8)sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_I1_I8)
-                       sp [-1].data.i = (gint8)sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_I1_R8)
-                       sp [-1].data.i = (gint8)sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_U1_I4)
-                       sp [-1].data.i = (guint8)sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_U1_I8)
-                       sp [-1].data.i = (guint8)sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_U1_R8)
-                       sp [-1].data.i = (guint8)sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_I2_I4)
-                       sp [-1].data.i = (gint16)sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_I2_I8)
-                       sp [-1].data.i = (gint16)sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_I2_R8)
-                       sp [-1].data.i = (gint16)sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_U2_I4)
-                       sp [-1].data.i = (guint16)sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_U2_I8)
-                       sp [-1].data.i = (guint16)sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_U2_R8)
-                       sp [-1].data.i = (guint16)sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_I4_R8)
-                       sp [-1].data.i = (gint32)sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_U4_I8)
-               MINT_IN_CASE(MINT_CONV_I4_I8)
-                       sp [-1].data.i = (gint32)sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_I4_I8_SP)
-                       sp [-2].data.i = (gint32)sp [-2].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_U4_R8)
-                       sp [-1].data.i = (guint32)sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_I8_I4)
-                       sp [-1].data.l = sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_I8_I4_SP)
-                       sp [-2].data.l = sp [-2].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_I8_U4)
-                       sp [-1].data.l = (guint32)sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_I8_R8)
-                       sp [-1].data.l = (gint64)sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_R4_I4)
-                       sp [-1].data.f = (float)sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_R4_I8)
-                       sp [-1].data.f = (float)sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_R4_R8)
-                       sp [-1].data.f = (float)sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_R8_I4)
-                       sp [-1].data.f = (double)sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_R8_I8)
-                       sp [-1].data.f = (double)sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_U8_I4)
-                       sp [-1].data.l = sp [-1].data.i & 0xffffffff;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_U8_R8)
-                       sp [-1].data.l = (guint64)sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-#if 0
-               MINT_IN_CASE(MINT_CPOBJ) {
-                       MonoClass *vtklass;
-                       ++ip;
-                       vtklass = rtm->data_items[READ32 (ip)];
-                       ip += 2;
-                       sp -= 2;
-                       memcpy (sp [0].data.p, sp [1].data.p, mono_class_value_size (vtklass, NULL));
-                       MINT_IN_BREAK;
-               }
-#endif
-               MINT_IN_CASE(MINT_LDOBJ) {
-                       int size;
-                       void *p;
-                       c = rtm->data_items[* (guint16 *)(ip + 1)];
-                       ip += 2;
-                       if (c->byval_arg.type != MONO_TYPE_VALUETYPE || c->byval_arg.data.klass->enumtype) {
-                               p = sp [-1].data.p;
-                               stackval_from_data (&c->byval_arg, &sp [-1], p, FALSE);
-                       } else {
-                               size = mono_class_value_size (c, NULL);
-                               p = sp [-1].data.p;
-                               sp [-1].data.p = vt_sp;
-                               memcpy(vt_sp, p, size);
-                               vt_sp += (size + 7) & ~7;
-                       }
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDSTR)
-                       sp->data.p = rtm->data_items [* (guint16 *)(ip + 1)];
-                       ++sp;
-                       ip += 2;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_NEWOBJ) {
-                       MonoClass *newobj_class;
-                       MonoMethodSignature *csig;
-                       stackval valuetype_this;
-                       guint32 token;
-                       stackval retval;
-
-                       frame->ip = ip;
-
-                       token = * (guint16 *)(ip + 1);
-                       ip += 2;
-
-                       child_frame.runtime_method = rtm->data_items [token];
-                       csig = mono_method_signature (child_frame.runtime_method->method);
-                       newobj_class = child_frame.runtime_method->method->klass;
-                       /*if (profiling_classes) {
-                               guint count = GPOINTER_TO_UINT (g_hash_table_lookup (profiling_classes, newobj_class));
-                               count++;
-                               g_hash_table_insert (profiling_classes, newobj_class, GUINT_TO_POINTER (count));
-                       }*/
-                               
-                       if (newobj_class->parent == mono_defaults.array_class) {
-                               sp -= csig->param_count;
-                               o = ves_array_create (context->domain, newobj_class, csig, sp);
-                               goto array_constructed;
-                       }
-
-                       g_assert (csig->hasthis);
-                       if (csig->param_count) {
-                               sp -= csig->param_count;
-                               memmove (sp + 1, sp, csig->param_count * sizeof (stackval));
-                       }
-                       child_frame.stack_args = sp;
-
-                       /*
-                        * First arg is the object.
-                        */
-                       if (newobj_class->valuetype) {
-                               MonoType *t = &newobj_class->byval_arg;
-                               if (!newobj_class->enumtype && (t->type == MONO_TYPE_VALUETYPE || (t->type == MONO_TYPE_GENERICINST && mono_type_generic_inst_is_valuetype (t)))) {
-                                       sp->data.p = vt_sp;
-                                       valuetype_this.data.p = vt_sp;
-                               } else {
-                                       memset (&valuetype_this, 0, sizeof (stackval));
-                                       sp->data.p = &valuetype_this;
-                               }
-                       } else {
-                               if (newobj_class != mono_defaults.string_class) {
-                                       context->managed_code = 0;
-                                       o = mono_object_new_checked (context->domain, newobj_class, &error);
-                                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                                       context->managed_code = 1;
-                                       if (*mono_thread_interruption_request_flag ())
-                                               mono_thread_interruption_checkpoint ();
-                                       sp->data.p = o;
-                               } else {
-                                       sp->data.p = NULL;
-                                       child_frame.retval = &retval;
-                               }
-                       }
-
-                       g_assert (csig->call_convention == MONO_CALL_DEFAULT);
-
-                       child_frame.ip = NULL;
-                       child_frame.ex = NULL;
-
-                       ves_exec_method_with_context (&child_frame, context);
-
-                       context->current_frame = frame;
-
-                       if (child_frame.ex) {
-                               /*
-                                * An exception occurred, need to run finally, fault and catch handlers..
-                                */
-                               frame->ex = child_frame.ex;
-                               goto handle_finally;
-                       }
-                       /*
-                        * a constructor returns void, but we need to return the object we created
-                        */
-array_constructed:
-                       if (newobj_class->valuetype && !newobj_class->enumtype) {
-                               *sp = valuetype_this;
-                       } else if (newobj_class == mono_defaults.string_class) {
-                               *sp = retval;
-                       } else {
-                               sp->data.p = o;
-                       }
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_CASTCLASS)
-                       c = rtm->data_items [*(guint16 *)(ip + 1)];
-                       if ((o = sp [-1].data.p)) {
-                               MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                               if (!isinst_obj)
-                                       THROW_EX (mono_get_exception_invalid_cast (), ip);
-                       }
-                       ip += 2;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_ISINST)
-                       c = rtm->data_items [*(guint16 *)(ip + 1)];
-                       if ((o = sp [-1].data.p)) {
-                               MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                               if (!isinst_obj)
-                                       sp [-1].data.p = NULL;
-                       }
-                       ip += 2;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_R_UN_I4)
-                       sp [-1].data.f = (double)(guint32)sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_R_UN_I8)
-                       sp [-1].data.f = (double)(guint64)sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_UNBOX)
-                       c = rtm->data_items[*(guint16 *)(ip + 1)];
-                       
-                       o = sp [-1].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-
-                       MonoObject *isinst_obj = mono_object_isinst_checked (o, c, &error);
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       if (!(isinst_obj || ((o->vtable->klass->rank == 0) && (o->vtable->klass->element_class == c->element_class))))
-                               THROW_EX (mono_get_exception_invalid_cast (), ip);
-
-                       if (c->byval_arg.type == MONO_TYPE_VALUETYPE && !c->enumtype) {
-                               int size = mono_class_native_size (c, NULL);
-                               sp [-1].data.p = vt_sp;
-                               vt_sp += (size + 7) & ~7;
-                       }
-                       stackval_from_data (&c->byval_arg, &sp [-1], mono_object_unbox (o), FALSE);
-                       ip += 2;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_THROW)
-                       --sp;
-                       frame->ex_handler = NULL;
-                       if (!sp->data.p)
-                               sp->data.p = mono_get_exception_null_reference ();
-                       THROW_EX ((MonoException *)sp->data.p, ip);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDFLDA)
-                       o = sp [-1].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-                       sp[-1].data.p = (char *)o + * (guint16 *)(ip + 1);
-                       ip += 2;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CKNULL)
-                       o = sp [-1].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-                       ++ip;
-                       MINT_IN_BREAK;
-
-#define LDFLD(datamem, fieldtype) \
-       o = sp [-1].data.p; \
-       if (!o) \
-               THROW_EX (mono_get_exception_null_reference (), ip); \
-       sp[-1].data.datamem = * (fieldtype *)((char *)o + * (guint16 *)(ip + 1)) ; \
-       ip += 2;
-
-               MINT_IN_CASE(MINT_LDFLD_I1) LDFLD(i, gint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDFLD_U1) LDFLD(i, guint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDFLD_I2) LDFLD(i, gint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDFLD_U2) LDFLD(i, guint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDFLD_I4) LDFLD(i, gint32); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDFLD_I8) LDFLD(l, gint64); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDFLD_R4) LDFLD(f, float); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDFLD_R8) LDFLD(f, double); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDFLD_O) LDFLD(p, gpointer); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDFLD_P) LDFLD(p, gpointer); MINT_IN_BREAK;
-
-               MINT_IN_CASE(MINT_LDFLD_VT)
-                       o = sp [-1].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-                       i32 = READ32(ip + 2);
-                       sp [-1].data.p = vt_sp;
-                       memcpy(sp [-1].data.p, (char *)o + * (guint16 *)(ip + 1), i32);
-                       vt_sp += (i32 + 7) & ~7;
-                       ip += 4;
-                       MINT_IN_BREAK;
-
-               MINT_IN_CASE(MINT_LDRMFLD) {
-                       gpointer tmp;
-                       MonoClassField *field;
-                       char *addr;
-
-                       o = sp [-1].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-                       field = rtm->data_items[* (guint16 *)(ip + 1)];
-                       ip += 2;
-                       if (mono_object_is_transparent_proxy (o)) {
-                               MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
-
-                               addr = mono_load_remote_field_checked (o, klass, field, &tmp, &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       } else {
-                               addr = (char*)o + field->offset;
-                       }                               
-
-                       stackval_from_data (field->type, &sp [-1], addr, FALSE);
-                       MINT_IN_BREAK;
-               }
-
-               MINT_IN_CASE(MINT_LDRMFLD_VT) {
-                       MonoClassField *field;
-                       char *addr;
-                       gpointer tmp;
-
-                       o = sp [-1].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-                       field = rtm->data_items[* (guint16 *)(ip + 1)];
-                       i32 = READ32(ip + 2);
-                       ip += 4;
-                       if (mono_object_is_transparent_proxy (o)) {
-                               MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
-                               addr = mono_load_remote_field_checked (o, klass, field, &tmp, &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       } else {
-                               addr = (char*)o + field->offset;
-                       }                               
-
-                       sp [-1].data.p = vt_sp;
-                       memcpy(sp [-1].data.p, (char *)o + * (guint16 *)(ip + 1), i32);
-                       vt_sp += (i32 + 7) & ~7;
-                       memcpy(sp [-1].data.p, addr, i32);
-                       MINT_IN_BREAK;
-               }
-
-#define STFLD(datamem, fieldtype) \
-       o = sp [-2].data.p; \
-       if (!o) \
-               THROW_EX (mono_get_exception_null_reference (), ip); \
-       sp -= 2; \
-       * (fieldtype *)((char *)o + * (guint16 *)(ip + 1)) = sp[1].data.datamem; \
-       ip += 2;
-
-               MINT_IN_CASE(MINT_STFLD_I1) STFLD(i, gint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STFLD_U1) STFLD(i, guint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STFLD_I2) STFLD(i, gint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STFLD_U2) STFLD(i, guint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STFLD_I4) STFLD(i, gint32); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STFLD_I8) STFLD(l, gint64); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STFLD_R4) STFLD(f, float); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STFLD_R8) STFLD(f, double); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STFLD_O) STFLD(p, gpointer); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STFLD_P) STFLD(p, gpointer); MINT_IN_BREAK;
-
-               MINT_IN_CASE(MINT_STFLD_VT)
-                       o = sp [-2].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-                       i32 = READ32(ip + 2);
-                       sp -= 2;
-                       memcpy((char *)o + * (guint16 *)(ip + 1), sp [1].data.p, i32);
-                       vt_sp -= (i32 + 7) & ~7;
-                       ip += 4;
-                       MINT_IN_BREAK;
-
-               MINT_IN_CASE(MINT_STRMFLD) {
-                       MonoClassField *field;
-
-                       o = sp [-2].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-                       
-                       field = rtm->data_items[* (guint16 *)(ip + 1)];
-                       ip += 2;
-
-                       if (mono_object_is_transparent_proxy (o)) {
-                               MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
-                               mono_store_remote_field_checked (o, klass, field, &sp [-1].data, &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       } else
-                               stackval_to_data (field->type, &sp [-1], (char*)o + field->offset, FALSE);
-
-                       sp -= 2;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_STRMFLD_VT) {
-                       MonoClassField *field;
-
-                       o = sp [-2].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-                       field = rtm->data_items[* (guint16 *)(ip + 1)];
-                       i32 = READ32(ip + 2);
-                       ip += 4;
-
-                       if (mono_object_is_transparent_proxy (o)) {
-                               MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
-                               mono_store_remote_field_checked (o, klass, field, &sp [-1].data, &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       } else
-                               memcpy((char*)o + field->offset, sp [-1].data.p, i32);
-
-                       sp -= 2;
-                       vt_sp -= (i32 + 7) & ~7;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDSFLDA) {
-                       MonoClassField *field = rtm->data_items[*(guint16 *)(ip + 1)];
-                       sp->data.p = mono_class_static_field_address (context->domain, field);
-                       ip += 2;
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDSFLD) {
-                       MonoClassField *field = rtm->data_items [* (guint16 *)(ip + 1)];
-                       gpointer addr = mono_class_static_field_address (context->domain, field);
-                       stackval_from_data (field->type, sp, addr, FALSE);
-                       ip += 2;
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDSFLD_VT) {
-                       MonoClassField *field = rtm->data_items [* (guint16 *)(ip + 1)];
-                       gpointer addr = mono_class_static_field_address (context->domain, field);
-                       int size = READ32 (ip + 2);
-                       ip += 4;
-
-                       sp->data.p = vt_sp;
-                       vt_sp += (size + 7) & ~7;
-                       stackval_from_data (field->type, sp, addr, FALSE);
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_STSFLD) {
-                       MonoClassField *field = rtm->data_items [* (guint16 *)(ip + 1)];
-                       gpointer addr = mono_class_static_field_address (context->domain, field);
-                       ip += 2;
-                       --sp;
-                       stackval_to_data (field->type, sp, addr, FALSE);
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_STSFLD_VT) {
-                       MonoClassField *field = rtm->data_items [* (guint16 *)(ip + 1)];
-                       gpointer addr = mono_class_static_field_address (context->domain, field);
-                       int size = READ32 (ip + 2);
-                       ip += 4;
-
-                       --sp;
-                       stackval_to_data (field->type, sp, addr, FALSE);
-                       vt_sp -= (size + 7) & ~7;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_STOBJ_VT) {
-                       int size;
-                       c = rtm->data_items[* (guint16 *)(ip + 1)];
-                       ip += 2;
-                       size = mono_class_value_size (c, NULL);
-                       memcpy(sp [-2].data.p, sp [-1].data.p, size);
-                       vt_sp -= (size + 7) & ~7;
-                       sp -= 2;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_STOBJ) {
-                       int size;
-                       c = rtm->data_items[* (guint16 *)(ip + 1)];
-                       ip += 2;
-                       size = mono_class_value_size (c, NULL);
-                       memcpy(sp [-2].data.p, &sp [-1].data, size);
-                       sp -= 2;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_CONV_OVF_I4_UN_R8)
-                       if (sp [-1].data.f < 0 || sp [-1].data.f > MYGUINT32_MAX)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (guint32)sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_U8_I4)
-                       if (sp [-1].data.i < 0)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.l = sp [-1].data.i;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_U8_R8)
-               MINT_IN_CASE(MINT_CONV_OVF_I8_UN_R8)
-                       if (sp [-1].data.f < 0 || sp [-1].data.f > 9223372036854775807LL)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.l = (guint64)sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_I8_R8)
-                       if (sp [-1].data.f < MYGINT64_MIN || sp [-1].data.f > MYGINT64_MAX)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.l = (gint64)sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_I4_UN_I8)
-                       if ((mono_u)sp [-1].data.l > MYGUINT32_MAX)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (mono_u)sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_BOX) {
-                       c = rtm->data_items [* (guint16 *)(ip + 1)];
-                       guint16 offset = * (guint16 *)(ip + 2);
-
-                       if (c->byval_arg.type == MONO_TYPE_VALUETYPE && !c->enumtype) {
-                               int size = mono_class_value_size (c, NULL);
-                               sp [-1 - offset].data.p = mono_value_box_checked (context->domain, c, sp [-1 - offset].data.p, &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                               size = (size + 7) & ~7;
-                               vt_sp -= size;
-                       } else {
-                               stackval_to_data (&c->byval_arg, &sp [-1 - offset], (char *) &sp [-1 - offset], FALSE);
-                               sp [-1 - offset].data.p = mono_value_box_checked (context->domain, c, &sp [-1 - offset], &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       }
-                       ip += 3;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_NEWARR)
-                       sp [-1].data.p = (MonoObject*) mono_array_new_checked (context->domain, rtm->data_items[*(guint16 *)(ip + 1)], sp [-1].data.i, &error);
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       ip += 2;
-                       /*if (profiling_classes) {
-                               guint count = GPOINTER_TO_UINT (g_hash_table_lookup (profiling_classes, o->vtable->klass));
-                               count++;
-                               g_hash_table_insert (profiling_classes, o->vtable->klass, GUINT_TO_POINTER (count));
-                       }*/
-
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDLEN)
-                       o = sp [-1].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-                       sp [-1].data.nati = mono_array_length ((MonoArray *)o);
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_GETCHR) {
-                       MonoString *s;
-                       s = sp [-2].data.p;
-                       if (!s)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-                       i32 = sp [-1].data.i;
-                       if (i32 < 0 || i32 >= mono_string_length (s))
-                               THROW_EX (mono_get_exception_index_out_of_range (), ip);
-                       --sp;
-                       sp [-1].data.i = mono_string_chars(s)[i32];
-                       ++ip;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_STRLEN)
-                       ++ip;
-                       sp [-1].data.i = mono_string_length ((MonoString*)sp [-1].data.p);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_ARRAY_RANK)
-                       o = sp [-1].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-                       sp [-1].data.i = mono_object_class (sp [-1].data.p)->rank;
-                       ip++;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDELEMA) {
-                       guint32 esize;
-                       mono_u aindex;
-                       
-                       /*token = READ32 (ip)*/;
-                       ip += 2;
-                       sp -= 2;
-
-                       o = sp [0].data.p;
-
-                       aindex = sp [1].data.i;
-                       if (aindex >= mono_array_length ((MonoArray *) o))
-                               THROW_EX (mono_get_exception_index_out_of_range (), ip - 2);
-
-                       /* check the array element corresponds to token */
-                       esize = mono_array_element_size (((MonoArray *) o)->obj.vtable->klass);
-                       
-                       sp->data.p = mono_array_addr_with_size ((MonoArray *) o, esize, aindex);
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDELEM_I1) /* fall through */
-               MINT_IN_CASE(MINT_LDELEM_U1) /* fall through */
-               MINT_IN_CASE(MINT_LDELEM_I2) /* fall through */
-               MINT_IN_CASE(MINT_LDELEM_U2) /* fall through */
-               MINT_IN_CASE(MINT_LDELEM_I4) /* fall through */
-               MINT_IN_CASE(MINT_LDELEM_U4) /* fall through */
-               MINT_IN_CASE(MINT_LDELEM_I8)  /* fall through */
-               MINT_IN_CASE(MINT_LDELEM_I)  /* fall through */
-               MINT_IN_CASE(MINT_LDELEM_R4) /* fall through */
-               MINT_IN_CASE(MINT_LDELEM_R8) /* fall through */
-               MINT_IN_CASE(MINT_LDELEM_REF) /* fall through */
-               MINT_IN_CASE(MINT_LDELEM_VT) {
-                       MonoArray *o;
-                       mono_u aindex;
-
-                       sp -= 2;
-
-                       o = sp [0].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-
-                       aindex = sp [1].data.i;
-                       if (aindex >= mono_array_length (o))
-                               THROW_EX (mono_get_exception_index_out_of_range (), ip);
-
-                       /*
-                        * FIXME: throw mono_get_exception_array_type_mismatch () if needed 
-                        */
-                       switch (*ip) {
-                       case MINT_LDELEM_I1:
-                               sp [0].data.i = mono_array_get (o, gint8, aindex);
-                               break;
-                       case MINT_LDELEM_U1:
-                               sp [0].data.i = mono_array_get (o, guint8, aindex);
-                               break;
-                       case MINT_LDELEM_I2:
-                               sp [0].data.i = mono_array_get (o, gint16, aindex);
-                               break;
-                       case MINT_LDELEM_U2:
-                               sp [0].data.i = mono_array_get (o, guint16, aindex);
-                               break;
-                       case MINT_LDELEM_I:
-                               sp [0].data.nati = mono_array_get (o, mono_i, aindex);
-                               break;
-                       case MINT_LDELEM_I4:
-                               sp [0].data.i = mono_array_get (o, gint32, aindex);
-                               break;
-                       case MINT_LDELEM_U4:
-                               sp [0].data.i = mono_array_get (o, guint32, aindex);
-                               break;
-                       case MINT_LDELEM_I8:
-                               sp [0].data.l = mono_array_get (o, guint64, aindex);
-                               break;
-                       case MINT_LDELEM_R4:
-                               sp [0].data.f = mono_array_get (o, float, aindex);
-                               break;
-                       case MINT_LDELEM_R8:
-                               sp [0].data.f = mono_array_get (o, double, aindex);
-                               break;
-                       case MINT_LDELEM_REF:
-                               sp [0].data.p = mono_array_get (o, gpointer, aindex);
-                               break;
-                       case MINT_LDELEM_VT: {
-                               MonoClass *klass_vt = rtm->data_items [*(guint16 *) (ip + 1)];
-                               i32 = READ32 (ip + 2);
-                               char *src_addr = mono_array_addr_with_size ((MonoArray *) o, i32, aindex);
-                               sp [0].data.vt = vt_sp;
-                               stackval_from_data (&klass_vt->byval_arg, sp, src_addr, FALSE);
-                               vt_sp += (i32 + 7) & ~7;
-                               ip += 3;
-                               break;
-                       }
-                       default:
-                               ves_abort();
-                       }
-
-                       ++ip;
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_STELEM_I)  /* fall through */
-               MINT_IN_CASE(MINT_STELEM_I1) /* fall through */ 
-               MINT_IN_CASE(MINT_STELEM_I2) /* fall through */
-               MINT_IN_CASE(MINT_STELEM_I4) /* fall through */
-               MINT_IN_CASE(MINT_STELEM_I8) /* fall through */
-               MINT_IN_CASE(MINT_STELEM_R4) /* fall through */
-               MINT_IN_CASE(MINT_STELEM_R8) /* fall through */
-               MINT_IN_CASE(MINT_STELEM_REF) /* fall through */
-               MINT_IN_CASE(MINT_STELEM_VT) {
-                       mono_u aindex;
-
-                       sp -= 3;
-
-                       o = sp [0].data.p;
-                       if (!o)
-                               THROW_EX (mono_get_exception_null_reference (), ip);
-
-                       aindex = sp [1].data.i;
-                       if (aindex >= mono_array_length ((MonoArray *)o))
-                               THROW_EX (mono_get_exception_index_out_of_range (), ip);
-
-                       switch (*ip) {
-                       case MINT_STELEM_I:
-                               mono_array_set ((MonoArray *)o, mono_i, aindex, sp [2].data.nati);
-                               break;
-                       case MINT_STELEM_I1:
-                               mono_array_set ((MonoArray *)o, gint8, aindex, sp [2].data.i);
-                               break;
-                       case MINT_STELEM_I2:
-                               mono_array_set ((MonoArray *)o, gint16, aindex, sp [2].data.i);
-                               break;
-                       case MINT_STELEM_I4:
-                               mono_array_set ((MonoArray *)o, gint32, aindex, sp [2].data.i);
-                               break;
-                       case MINT_STELEM_I8:
-                               mono_array_set ((MonoArray *)o, gint64, aindex, sp [2].data.l);
-                               break;
-                       case MINT_STELEM_R4:
-                               mono_array_set ((MonoArray *)o, float, aindex, sp [2].data.f);
-                               break;
-                       case MINT_STELEM_R8:
-                               mono_array_set ((MonoArray *)o, double, aindex, sp [2].data.f);
-                               break;
-                       case MINT_STELEM_REF: {
-                               MonoObject *isinst_obj = mono_object_isinst_checked (sp [2].data.p, mono_object_class (o)->element_class, &error);
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                               if (sp [2].data.p && !isinst_obj)
-                                       THROW_EX (mono_get_exception_array_type_mismatch (), ip);
-                               mono_array_set ((MonoArray *)o, gpointer, aindex, sp [2].data.p);
-                               break;
-                       }
-                       case MINT_STELEM_VT: {
-                               MonoClass *klass_vt = rtm->data_items [*(guint16 *) (ip + 1)];
-                               i32 = READ32 (ip + 2);
-                               char *dst_addr = mono_array_addr_with_size ((MonoArray *) o, i32, aindex);
-
-                               stackval_to_data (&klass_vt->byval_arg, &sp [2], dst_addr, FALSE);
-                               vt_sp -= (i32 + 7) & ~7;
-                               ip += 3;
-                               break;
-                       }
-                       default:
-                               ves_abort();
-                       }
-
-                       ++ip;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_CONV_OVF_I4_U4)
-                       if (sp [-1].data.i < 0)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_I4_I8)
-                       if (sp [-1].data.l < MYGINT32_MIN || sp [-1].data.l > MYGINT32_MAX)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (gint32) sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_I4_R8)
-                       if (sp [-1].data.f < MYGINT32_MIN || sp [-1].data.f > MYGINT32_MAX)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (gint32) sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_U4_I4)
-                       if (sp [-1].data.i < 0)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_U4_I8)
-                       if (sp [-1].data.l < 0 || sp [-1].data.l > MYGUINT32_MAX)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (guint32) sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_U4_R8)
-                       if (sp [-1].data.f < 0 || sp [-1].data.f > MYGUINT32_MAX)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (guint32) sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_I2_I4)
-                       if (sp [-1].data.i < -32768 || sp [-1].data.i > 32767)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_I2_I8)
-                       if (sp [-1].data.l < -32768 || sp [-1].data.l > 32767)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (gint16) sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_I2_R8)
-                       if (sp [-1].data.f < -32768 || sp [-1].data.f > 32767)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (gint16) sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_U2_I4)
-                       if (sp [-1].data.i < 0 || sp [-1].data.i > 65535)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_U2_I8)
-                       if (sp [-1].data.l < 0 || sp [-1].data.l > 65535)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (guint16) sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_U2_R8)
-                       if (sp [-1].data.f < 0 || sp [-1].data.f > 65535)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (guint16) sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_I1_I4)
-                       if (sp [-1].data.i < -128 || sp [-1].data.i > 127)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_I1_I8)
-                       if (sp [-1].data.l < -128 || sp [-1].data.l > 127)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (gint8) sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_I1_R8)
-                       if (sp [-1].data.f < -128 || sp [-1].data.f > 127)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (gint8) sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_U1_I4)
-                       if (sp [-1].data.i < 0 || sp [-1].data.i > 255)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_U1_I8)
-                       if (sp [-1].data.l < 0 || sp [-1].data.l > 255)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (guint8) sp [-1].data.l;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CONV_OVF_U1_R8)
-                       if (sp [-1].data.f < 0 || sp [-1].data.f > 255)
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       sp [-1].data.i = (guint8) sp [-1].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-#if 0
-               MINT_IN_CASE(MINT_LDELEM) 
-               MINT_IN_CASE(MINT_STELEM) 
-               MINT_IN_CASE(MINT_UNBOX_ANY) 
-
-               MINT_IN_CASE(MINT_REFANYVAL) ves_abort(); MINT_IN_BREAK;
-#endif
-               MINT_IN_CASE(MINT_CKFINITE)
-                       if (!isfinite(sp [-1].data.f))
-                               THROW_EX (mono_get_exception_arithmetic (), ip);
-                       ++ip;
-                       MINT_IN_BREAK;
-#if 0
-               MINT_IN_CASE(MINT_MKREFANY) ves_abort(); MINT_IN_BREAK;
-#endif
-               MINT_IN_CASE(MINT_LDTOKEN)
-                       sp->data.p = vt_sp;
-                       vt_sp += 8;
-                       * (gpointer *)sp->data.p = rtm->data_items[*(guint16 *)(ip + 1)];
-                       ip += 2;
-                       ++sp;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_ADD_OVF_I4)
-                       if (CHECK_ADD_OVERFLOW (sp [-2].data.i, sp [-1].data.i))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP(i, +);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_ADD_OVF_I8)
-                       if (CHECK_ADD_OVERFLOW64 (sp [-2].data.l, sp [-1].data.l))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP(l, +);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_ADD_OVF_UN_I4)
-                       if (CHECK_ADD_OVERFLOW_UN (sp [-2].data.i, sp [-1].data.i))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP_CAST(i, +, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_ADD_OVF_UN_I8)
-                       if (CHECK_ADD_OVERFLOW64_UN (sp [-2].data.l, sp [-1].data.l))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP_CAST(l, +, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_MUL_OVF_I4)
-                       if (CHECK_MUL_OVERFLOW (sp [-2].data.i, sp [-1].data.i))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP(i, *);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_MUL_OVF_I8)
-                       if (CHECK_MUL_OVERFLOW64 (sp [-2].data.l, sp [-1].data.l))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP(l, *);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_MUL_OVF_UN_I4)
-                       if (CHECK_MUL_OVERFLOW_UN (sp [-2].data.i, sp [-1].data.i))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP_CAST(i, *, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_MUL_OVF_UN_I8)
-                       if (CHECK_MUL_OVERFLOW64_UN (sp [-2].data.l, sp [-1].data.l))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP_CAST(l, *, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SUB_OVF_I4)
-                       if (CHECK_SUB_OVERFLOW (sp [-2].data.i, sp [-1].data.i))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP(i, -);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SUB_OVF_I8)
-                       if (CHECK_SUB_OVERFLOW64 (sp [-2].data.l, sp [-1].data.l))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP(l, -);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SUB_OVF_UN_I4)
-                       if (CHECK_SUB_OVERFLOW_UN (sp [-2].data.i, sp [-1].data.i))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP_CAST(i, -, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_SUB_OVF_UN_I8)
-                       if (CHECK_SUB_OVERFLOW64_UN (sp [-2].data.l, sp [-1].data.l))
-                               THROW_EX (mono_get_exception_overflow (), ip);
-                       BINOP_CAST(l, -, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_ENDFINALLY)
-                       if (finally_ips) {
-                               ip = finally_ips->data;
-                               finally_ips = g_slist_remove (finally_ips, ip);
-                               goto main_loop;
-                       }
-                       if (frame->ex)
-                               goto handle_fault;
-                       ves_abort();
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LEAVE) /* Fall through */
-               MINT_IN_CASE(MINT_LEAVE_S)
-                       while (sp > frame->stack) {
-                               --sp;
-                       }
-                       frame->ip = ip;
-                       if (*ip == MINT_LEAVE_S) {
-                               ip += (short) *(ip + 1);
-                       } else {
-                               ip += (gint32) READ32 (ip + 1);
-                       }
-                       endfinally_ip = ip;
-                       if (frame->ex_handler != NULL && MONO_OFFSET_IN_HANDLER(frame->ex_handler, frame->ip - rtm->code)) {
-                               frame->ex_handler = NULL;
-                               frame->ex = NULL;
-                       }
-                       goto handle_finally;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_ICALL_V_V) 
-               MINT_IN_CASE(MINT_ICALL_V_P)
-               MINT_IN_CASE(MINT_ICALL_P_V) 
-               MINT_IN_CASE(MINT_ICALL_P_P)
-               MINT_IN_CASE(MINT_ICALL_PP_V)
-               MINT_IN_CASE(MINT_ICALL_PI_V)
-               MINT_IN_CASE(MINT_ICALL_PP_P)
-               MINT_IN_CASE(MINT_ICALL_PI_P)
-               MINT_IN_CASE(MINT_ICALL_PPP_V)
-               MINT_IN_CASE(MINT_ICALL_PPI_V)
-                       sp = do_icall (context, *ip, sp, rtm->data_items [*(guint16 *)(ip + 1)]);
-                       if (frame->ex != NULL)
-                               goto handle_exception;
-                       ip += 2;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_MONO_LDPTR) 
-                       sp->data.p = rtm->data_items [*(guint16 *)(ip + 1)];
-                       ip += 2;
-                       ++sp;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_MONO_NEWOBJ)
-                       sp->data.p = mono_object_new_checked (context->domain, rtm->data_items [*(guint16 *)(ip + 1)], &error);
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       ip += 2;
-                       sp++;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_MONO_FREE)
-                       ++ip;
-                       --sp;
-                       g_error ("that doesn't seem right");
-                       g_free (sp->data.p);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_MONO_RETOBJ)
-                       ++ip;
-                       sp--;
-                       stackval_from_data (mono_method_signature (frame->runtime_method->method)->ret, frame->retval, sp->data.p,
-                            mono_method_signature (frame->runtime_method->method)->pinvoke);
-                       if (sp > frame->stack)
-                               g_warning ("retobj: more values on stack: %d", sp-frame->stack);
-                       goto exit_frame;
-
-#define RELOP(datamem, op) \
-       --sp; \
-       sp [-1].data.i = sp [-1].data.datamem op sp [0].data.datamem; \
-       ++ip;
-               MINT_IN_CASE(MINT_CEQ_I4)
-                       RELOP(i, ==);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CEQ0_I4)
-                       sp [-1].data.i = (sp [-1].data.i == 0);
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CEQ_I8)
-                       RELOP(l, ==);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CEQ_R8)
-                       --sp; 
-                       if (isunordered (sp [-1].data.f, sp [0].data.f))
-                               sp [-1].data.i = 0;
-                       else
-                               sp [-1].data.i = sp [-1].data.f == sp [0].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CGT_I4)
-                       RELOP(i, >);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CGT_I8)
-                       RELOP(l, >);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CGT_R8)
-                       --sp; 
-                       if (isunordered (sp [-1].data.f, sp [0].data.f))
-                               sp [-1].data.i = 0;
-                       else
-                               sp [-1].data.i = sp [-1].data.f > sp [0].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-
-#define RELOP_CAST(datamem, op, type) \
-       --sp; \
-       sp [-1].data.i = (type)sp [-1].data.datamem op (type)sp [0].data.datamem; \
-       ++ip;
-
-               MINT_IN_CASE(MINT_CGT_UN_I4)
-                       RELOP_CAST(i, >, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CGT_UN_I8)
-                       RELOP_CAST(l, >, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CGT_UN_R8)
-                       --sp; 
-                       if (isunordered (sp [-1].data.f, sp [0].data.f))
-                               sp [-1].data.i = 1;
-                       else
-                               sp [-1].data.i = sp [-1].data.f > sp [0].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CLT_I4)
-                       RELOP(i, <);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CLT_I8)
-                       RELOP(l, <);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CLT_R8)
-                       --sp; 
-                       if (isunordered (sp [-1].data.f, sp [0].data.f))
-                               sp [-1].data.i = 0;
-                       else
-                               sp [-1].data.i = sp [-1].data.f < sp [0].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CLT_UN_I4)
-                       RELOP_CAST(i, <, guint32);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CLT_UN_I8)
-                       RELOP_CAST(l, <, guint64);
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CLT_UN_R8)
-                       --sp; 
-                       if (isunordered (sp [-1].data.f, sp [0].data.f))
-                               sp [-1].data.i = 1;
-                       else
-                               sp [-1].data.i = sp [-1].data.f < sp [0].data.f;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDFTN) {
-                       sp->data.p = rtm->data_items [* (guint16 *)(ip + 1)];
-                       ++sp;
-                       ip += 2;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDVIRTFTN) {
-                       RuntimeMethod *m = rtm->data_items [* (guint16 *)(ip + 1)];
-                       ip += 2;
-                       --sp;
-                       if (!sp->data.p)
-                               THROW_EX (mono_get_exception_null_reference (), ip - 2);
-                               
-                       sp->data.p = get_virtual_method (context->domain, m, sp->data.p);
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-
-               MINT_IN_CASE(MINT_LDTHISA)
-                       g_error ("should not happen");
-                       // sp->data.p = &frame->obj;
-                       ++ip;
-                       ++sp; 
-                       MINT_IN_BREAK;
-
-#define LDARG(datamem, argtype) \
-       sp->data.datamem = * (argtype *)(frame->args + * (guint16 *)(ip + 1)); \
-       ip += 2; \
-       ++sp; 
-       
-               MINT_IN_CASE(MINT_LDARG_I1) LDARG(i, gint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDARG_U1) LDARG(i, guint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDARG_I2) LDARG(i, gint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDARG_U2) LDARG(i, guint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDARG_I4) LDARG(i, gint32); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDARG_I8) LDARG(l, gint64); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDARG_R4) LDARG(f, float); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDARG_R8) LDARG(f, double); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDARG_O) LDARG(p, gpointer); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDARG_P) LDARG(p, gpointer); MINT_IN_BREAK;
-
-               MINT_IN_CASE(MINT_LDARG_VT)
-                       sp->data.p = vt_sp;
-                       i32 = READ32(ip + 2);
-                       memcpy(sp->data.p, frame->args + * (guint16 *)(ip + 1), i32);
-                       vt_sp += (i32 + 7) & ~7;
-                       ip += 4;
-                       ++sp;
-                       MINT_IN_BREAK;
-
-#define STARG(datamem, argtype) \
-       --sp; \
-       * (argtype *)(frame->args + * (guint16 *)(ip + 1)) = sp->data.datamem; \
-       ip += 2; \
-       
-               MINT_IN_CASE(MINT_STARG_I1) STARG(i, gint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STARG_U1) STARG(i, guint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STARG_I2) STARG(i, gint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STARG_U2) STARG(i, guint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STARG_I4) STARG(i, gint32); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STARG_I8) STARG(l, gint64); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STARG_R4) STARG(f, float); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STARG_R8) STARG(f, double); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STARG_O) STARG(p, gpointer); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STARG_P) STARG(p, gpointer); MINT_IN_BREAK;
-
-               MINT_IN_CASE(MINT_STARG_VT) 
-                       i32 = READ32(ip + 2);
-                       --sp;
-                       memcpy(frame->args + * (guint16 *)(ip + 1), sp->data.p, i32);
-                       vt_sp -= (i32 + 7) & ~7;
-                       ip += 4;
-                       MINT_IN_BREAK;
-
-#define STINARG(datamem, argtype) \
-       do { \
-               int n = * (guint16 *)(ip + 1); \
-               * (argtype *)(frame->args + rtm->arg_offsets [n]) = frame->stack_args [n].data.datamem; \
-               ip += 2; \
-       } while (0)
-       
-               MINT_IN_CASE(MINT_STINARG_I1) STINARG(i, gint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STINARG_U1) STINARG(i, guint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STINARG_I2) STINARG(i, gint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STINARG_U2) STINARG(i, guint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STINARG_I4) STINARG(i, gint32); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STINARG_I8) STINARG(l, gint64); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STINARG_R4) STINARG(f, float); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STINARG_R8) STINARG(f, double); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STINARG_O) STINARG(p, gpointer); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STINARG_P) STINARG(p, gpointer); MINT_IN_BREAK;
-
-               MINT_IN_CASE(MINT_STINARG_VT) {
-                       int n = * (guint16 *)(ip + 1);
-                       i32 = READ32(ip + 2);
-                       memcpy (frame->args + rtm->arg_offsets [n], frame->stack_args [n].data.p, i32);
-                       ip += 4;
-                       MINT_IN_BREAK;
-               }
-
-               MINT_IN_CASE(MINT_LDARGA)
-                       sp->data.p = frame->args + * (guint16 *)(ip + 1);
-                       ip += 2;
-                       ++sp;
-                       MINT_IN_BREAK;
-
-#define LDLOC(datamem, argtype) \
-       sp->data.datamem = * (argtype *)(locals + * (guint16 *)(ip + 1)); \
-       ip += 2; \
-       ++sp; 
-       
-               MINT_IN_CASE(MINT_LDLOC_I1) LDLOC(i, gint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDLOC_U1) LDLOC(i, guint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDLOC_I2) LDLOC(i, gint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDLOC_U2) LDLOC(i, guint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDLOC_I4) LDLOC(i, gint32); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDLOC_I8) LDLOC(l, gint64); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDLOC_R4) LDLOC(f, float); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDLOC_R8) LDLOC(f, double); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDLOC_O) LDLOC(p, gpointer); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDLOC_P) LDLOC(p, gpointer); MINT_IN_BREAK;
-
-               MINT_IN_CASE(MINT_LDLOC_VT)
-                       sp->data.p = vt_sp;
-                       i32 = READ32(ip + 2);
-                       memcpy(sp->data.p, locals + * (guint16 *)(ip + 1), i32);
-                       vt_sp += (i32 + 7) & ~7;
-                       ip += 4;
-                       ++sp;
-                       MINT_IN_BREAK;
-
-               MINT_IN_CASE(MINT_LDLOCA_S)
-                       sp->data.p = locals + * (guint16 *)(ip + 1);
-                       ip += 2;
-                       ++sp;
-                       MINT_IN_BREAK;
-
-#define STLOC(datamem, argtype) \
-       --sp; \
-       * (argtype *)(locals + * (guint16 *)(ip + 1)) = sp->data.datamem; \
-       ip += 2;
-       
-               MINT_IN_CASE(MINT_STLOC_I1) STLOC(i, gint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STLOC_U1) STLOC(i, guint8); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STLOC_I2) STLOC(i, gint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STLOC_U2) STLOC(i, guint16); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STLOC_I4) STLOC(i, gint32); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STLOC_I8) STLOC(l, gint64); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STLOC_R4) STLOC(f, float); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STLOC_R8) STLOC(f, double); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STLOC_O) STLOC(p, gpointer); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STLOC_P) STLOC(p, gpointer); MINT_IN_BREAK;
-
-#define STLOC_NP(datamem, argtype) \
-       * (argtype *)(locals + * (guint16 *)(ip + 1)) = sp [-1].data.datamem; \
-       ip += 2;
-
-               MINT_IN_CASE(MINT_STLOC_NP_I4) STLOC_NP(i, gint32); MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STLOC_NP_O) STLOC_NP(p, gpointer); MINT_IN_BREAK;
-
-               MINT_IN_CASE(MINT_STLOC_VT)
-                       i32 = READ32(ip + 2);
-                       --sp;
-                       memcpy(locals + * (guint16 *)(ip + 1), sp->data.p, i32);
-                       vt_sp -= (i32 + 7) & ~7;
-                       ip += 4;
-                       MINT_IN_BREAK;
-
-               MINT_IN_CASE(MINT_LOCALLOC)
-                       if (sp != frame->stack + 1) /*FIX?*/
-                               THROW_EX (mono_get_exception_execution_engine (NULL), ip);
-                       sp [-1].data.p = alloca (sp [-1].data.i);
-                       ++ip;
-                       MINT_IN_BREAK;
-#if 0
-               MINT_IN_CASE(MINT_ENDFILTER) ves_abort(); MINT_IN_BREAK;
-#endif
-               MINT_IN_CASE(MINT_INITOBJ)
-                       --sp;
-                       memset (sp->data.vt, 0, READ32(ip + 1));
-                       ip += 3;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_CPBLK)
-                       sp -= 3;
-                       if (!sp [0].data.p || !sp [1].data.p)
-                               THROW_EX (mono_get_exception_null_reference(), ip - 1);
-                       ++ip;
-                       /* FIXME: value and size may be int64... */
-                       memcpy (sp [0].data.p, sp [1].data.p, sp [2].data.i);
-                       MINT_IN_BREAK;
-#if 0
-               MINT_IN_CASE(MINT_CONSTRAINED_) {
-                       guint32 token;
-                       /* FIXME: implement */
-                       ++ip;
-                       token = READ32 (ip);
-                       ip += 2;
-                       MINT_IN_BREAK;
-               }
-#endif
-               MINT_IN_CASE(MINT_INITBLK)
-                       sp -= 3;
-                       if (!sp [0].data.p)
-                               THROW_EX (mono_get_exception_null_reference(), ip - 1);
-                       ++ip;
-                       /* FIXME: value and size may be int64... */
-                       memset (sp [0].data.p, sp [1].data.i, sp [2].data.i);
-                       MINT_IN_BREAK;
-#if 0
-               MINT_IN_CASE(MINT_NO_)
-                       /* FIXME: implement */
-                       ip += 2;
-                       MINT_IN_BREAK;
-#endif
-               MINT_IN_CASE(MINT_RETHROW)
-                       /* 
-                        * need to clarify what this should actually do:
-                        * start the search from the last found handler in
-                        * this method or continue in the caller or what.
-                        * Also, do we need to run finally/fault handlers after a retrow?
-                        * Well, this implementation will follow the usual search
-                        * for an handler, considering the current ip as throw spot.
-                        * We need to NULL frame->ex_handler for the later code to
-                        * actually run the new found handler.
-                        */
-                       frame->ex_handler = NULL;
-                       THROW_EX (frame->ex, ip - 1);
-                       MINT_IN_BREAK;
-               MINT_IN_DEFAULT
-                       g_print ("Unimplemented opcode: %04x %s at 0x%x\n", *ip, mono_interp_opname[*ip], ip-rtm->code);
-                       THROW_EX (mono_get_exception_execution_engine ("Unimplemented opcode"), ip);
-               }
-       }
-
-       g_assert_not_reached ();
-       /*
-        * Exception handling code.
-        * The exception object is stored in frame->ex.
-        */
-
-       handle_exception:
-       {
-               int i;
-               guint32 ip_offset;
-               MonoInvocation *inv;
-               MonoExceptionClause *clause;
-               /*char *message;*/
-               MonoObject *ex_obj;
-
-#if DEBUG_INTERP
-               if (tracing)
-                       g_print ("* Handling exception '%s' at IL_%04x\n", 
-                               frame->ex == NULL ? "** Unknown **" : mono_object_class (frame->ex)->name, 
-                               rtm == NULL ? 0 : frame->ip - rtm->code);
-#endif
-               if (die_on_exception)
-                       goto die_on_ex;
-
-               for (inv = frame; inv; inv = inv->parent) {
-                       MonoMethod *method;
-                       if (inv->runtime_method == NULL)
-                               continue;
-                       method = inv->runtime_method->method;
-                       if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
-                               continue;
-                       if (method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME))
-                               continue;
-                       if (inv->ip == NULL)
-                               continue;
-                       ip_offset = inv->ip - inv->runtime_method->code;
-                       inv->ex_handler = NULL; /* clear this in case we are trhowing an exception while handling one  - this one wins */
-                       for (i = 0; i < inv->runtime_method->num_clauses; ++i) {
-                               clause = &inv->runtime_method->clauses [i];
-                               if (clause->flags <= 1 && MONO_OFFSET_IN_CLAUSE (clause, ip_offset)) {
-                                       if (!clause->flags) {
-                                               MonoObject *isinst_obj = mono_object_isinst_checked ((MonoObject*)frame->ex, clause->data.catch_class, &error);
-                                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                                               if (isinst_obj) {
-                                                       /* 
-                                                        * OK, we found an handler, now we need to execute the finally
-                                                        * and fault blocks before branching to the handler code.
-                                                        */
-                                                       inv->ex_handler = clause;
-#if DEBUG_INTERP
-                                                       if (tracing)
-                                                               g_print ("* Found handler at '%s'\n", method->name);
-#endif
-                                                       goto handle_finally;
-                                               }
-                                       } else {
-                                               /* FIXME: handle filter clauses */
-                                               g_assert (0);
-                                       }
-                               }
-                       }
-               }
-               /*
-                * If we get here, no handler was found: print a stack trace.
-                */
-               for (inv = frame; inv; inv = inv->parent) {
-                       if (inv->invoke_trap)
-                               goto handle_finally;
-               }
-die_on_ex:
-               ex_obj = (MonoObject*)frame->ex;
-               mono_unhandled_exception (ex_obj);
-               exit (1);
-       }
-       handle_finally:
-       {
-               int i;
-               guint32 ip_offset;
-               MonoExceptionClause *clause;
-               GSList *old_list = finally_ips;
-               MonoMethod *method = frame->runtime_method->method;
-               MonoMethodHeader *header = mono_method_get_header_checked (method, &error);
-               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-               
-#if DEBUG_INTERP
-               if (tracing)
-                       g_print ("* Handle finally IL_%04x\n", endfinally_ip == NULL ? 0 : endfinally_ip - rtm->code);
-#endif
-               if (rtm == NULL || (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) 
-                               || (method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME))) {
-                       goto exit_frame;
-               }
-               ip_offset = frame->ip - rtm->code;
-
-               if (endfinally_ip != NULL)
-                       finally_ips = g_slist_prepend(finally_ips, (void *)endfinally_ip);
-               for (i = 0; i < header->num_clauses; ++i)
-                       if (frame->ex_handler == &rtm->clauses [i])
-                               break;
-               while (i > 0) {
-                       --i;
-                       clause = &rtm->clauses [i];
-                       if (MONO_OFFSET_IN_CLAUSE (clause, ip_offset) && (endfinally_ip == NULL || !(MONO_OFFSET_IN_CLAUSE (clause, endfinally_ip - rtm->code)))) {
-                               if (clause->flags == MONO_EXCEPTION_CLAUSE_FINALLY) {
-                                       ip = rtm->code + clause->handler_offset;
-                                       finally_ips = g_slist_prepend (finally_ips, (gpointer) ip);
-#if DEBUG_INTERP
-                                       if (tracing)
-                                               g_print ("* Found finally at IL_%04x with exception: %s\n", clause->handler_offset, frame->ex? "yes": "no");
-#endif
-                               }
-                       }
-               }
-
-               endfinally_ip = NULL;
-
-               if (old_list != finally_ips && finally_ips) {
-                       ip = finally_ips->data;
-                       finally_ips = g_slist_remove (finally_ips, ip);
-                       sp = frame->stack; /* spec says stack should be empty at endfinally so it should be at the start too */
-                       goto main_loop;
-               }
-
-               /*
-                * If an exception is set, we need to execute the fault handler, too,
-                * otherwise, we continue normally.
-                */
-               if (frame->ex)
-                       goto handle_fault;
-               ves_abort();
-       }
-       handle_fault:
-       {
-               int i;
-               guint32 ip_offset;
-               MonoExceptionClause *clause;
-               MonoMethod *method = frame->runtime_method->method;
-               MonoMethodHeader *header = mono_method_get_header_checked (method, &error);
-               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-               
-#if DEBUG_INTERP
-               if (tracing)
-                       g_print ("* Handle fault\n");
-#endif
-               ip_offset = frame->ip - rtm->code;
-               for (i = 0; i < header->num_clauses; ++i) {
-                       clause = &rtm->clauses [i];
-                       if (clause->flags == MONO_EXCEPTION_CLAUSE_FAULT && MONO_OFFSET_IN_CLAUSE (clause, ip_offset)) {
-                               ip = rtm->code + clause->handler_offset;
-#if DEBUG_INTERP
-                               if (tracing)
-                                       g_print ("* Executing handler at IL_%04x\n", clause->handler_offset);
-#endif
-                               goto main_loop;
-                       }
-               }
-               /*
-                * If the handler for the exception was found in this method, we jump
-                * to it right away, otherwise we return and let the caller run
-                * the finally, fault and catch blocks.
-                * This same code should be present in the endfault opcode, but it
-                * is corrently not assigned in the ECMA specs: LAMESPEC.
-                */
-               if (frame->ex_handler) {
-#if DEBUG_INTERP
-                       if (tracing)
-                               g_print ("* Executing handler at IL_%04x\n", frame->ex_handler->handler_offset);
-#endif
-                       ip = rtm->code + frame->ex_handler->handler_offset;
-                       sp = frame->stack;
-                       vt_sp = (unsigned char *) sp + rtm->stack_size;
-                       sp->data.p = frame->ex;
-                       ++sp;
-                       goto main_loop;
-               }
-               goto exit_frame;
-       }
-exit_frame:
-       DEBUG_LEAVE ();
-}
-
-void
-ves_exec_method (MonoInvocation *frame)
-{
-       ThreadContext *context = mono_native_tls_get_value (thread_context_id);
-       ThreadContext context_struct;
-       MonoError error;
-       jmp_buf env;
-
-       frame->ex = NULL;
-
-       if (setjmp(env)) {
-               mono_unhandled_exception ((MonoObject*)frame->ex);
-               return;
-       }
-       if (context == NULL) {
-               context = &context_struct;
-               context_struct.domain = mono_domain_get ();
-               context_struct.base_frame = frame;
-               context_struct.current_frame = NULL;
-               context_struct.env_frame = frame;
-               context_struct.current_env = &env;
-               context_struct.search_for_handler = 0;
-               context_struct.managed_code = 0;
-               mono_native_tls_set_value (thread_context_id, context);
-       }
-       frame->ip = NULL;
-       frame->parent = context->current_frame;
-       frame->runtime_method = mono_interp_get_runtime_method (context->domain, frame->method, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-       context->managed_code = 1;
-       ves_exec_method_with_context (frame, context);
-       context->managed_code = 0;
-       if (frame->ex) {
-               if (context != &context_struct && context->current_env) {
-                       context->env_frame->ex = frame->ex;
-                       longjmp (*context->current_env, 1);
-               }
-               else
-                       mono_unhandled_exception ((MonoObject*)frame->ex);
-       }
-       if (context->base_frame == frame)
-               mono_native_tls_set_value (thread_context_id, NULL);
-       else
-               context->current_frame = frame->parent;
-}
-
-static int 
-ves_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[])
-{
-       MonoImage *image = mono_assembly_get_image (assembly);
-       MonoMethod *method;
-       MonoError error;
-       int rval;
-
-       method = mono_get_method_checked (image, mono_image_get_entry_point (image), NULL, NULL, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-
-       if (!method)
-               g_error ("No entry point method found in %s", mono_image_get_filename (image));
-
-       rval = mono_runtime_run_main_checked (method, argc, argv, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-       return rval;
-}
-
-static void
-usage (void)
-{
-       fprintf (stderr,
-                "mint %s, the Mono ECMA CLI interpreter, (C) 2001, 2002 Ximian, Inc.\n\n"
-                "Usage is: mint [options] executable args...\n\n", VERSION);
-       fprintf (stderr,
-                "Runtime Debugging:\n"
-#ifdef DEBUG_INTERP
-                "   --debug\n"
-#endif
-                "   --dieonex\n"
-                "   --noptr\t\t\tdon't print pointer addresses in trace output\n"
-                "   --opcode-count\n"
-                "   --print-vtable\n"
-                "   --traceclassinit\n"
-                "\n"
-                "Development:\n"
-                "   --debug method_name\n"
-                "   --profile\n"
-                "   --trace\n"
-                "   --traceops\n"
-                "   --regression\n"
-                "\n"
-                "Runtime:\n"
-                "   --config filename  load the specified config file instead of the default\n"
-                "   --workers n        maximum number of worker threads\n"
-               );
-       exit (1);
-}
-
-static MonoBoolean
-interp_ves_icall_get_frame_info (gint32 skip, MonoBoolean need_file_info, 
-                         MonoReflectionMethod **method, 
-                         gint32 *iloffset, gint32 *native_offset,
-                         MonoString **file, gint32 *line, gint32 *column)
-{
-       ThreadContext *context = mono_native_tls_get_value (thread_context_id);
-       MonoInvocation *inv = context->current_frame;
-       MonoError error;
-       int i;
-
-       for (i = 0; inv && i < skip; inv = inv->parent)
-               if (inv->runtime_method != NULL)
-                       ++i;
-
-       if (iloffset)
-               *iloffset = 0;
-       if (native_offset)
-               *native_offset = 0;
-       if (method) {
-               if (inv == NULL) {
-                       *method = NULL;
-               } else {
-                       *method = mono_method_get_object_checked (context->domain, inv->runtime_method->method, NULL, &error);
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-               }
-       }
-       if (line)
-               *line = 0;
-       if (need_file_info) {
-               if (column)
-                       *column = 0;
-               if (file)
-                       *file = mono_string_new (mono_domain_get (), "unknown");
-       }
-
-       return TRUE;
-}
-
-static MonoArray *
-interp_ves_icall_get_trace (MonoException *exc, gint32 skip, MonoBoolean need_file_info)
-{
-       MonoDomain *domain = mono_domain_get ();
-       MonoArray *res;
-       MonoArray *ta = exc->trace_ips;
-       MonoError error;
-       int i, len;
-
-       if (ta == NULL) {
-               /* Exception is not thrown yet */
-               MonoArray *array = mono_array_new_checked (domain, mono_defaults.stack_frame_class, 0, &error);
-               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-               return array;
-       }
-       
-       len = mono_array_length (ta);
-
-       res = mono_array_new_checked (domain, mono_defaults.stack_frame_class, len > skip ? len - skip : 0, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-
-       for (i = skip; i < len / 2; i++) {
-               MonoStackFrame *sf = (MonoStackFrame *)mono_object_new_checked (domain, mono_defaults.stack_frame_class, &error);
-               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-               gushort *ip = mono_array_get (ta, gpointer, 2 * i + 1);
-               RuntimeMethod *rtm = mono_array_get (ta, gpointer, 2 * i);
-
-               if (rtm != NULL) {
-                       sf->method = mono_method_get_object_checked (domain, rtm->method, NULL, &error);
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       sf->native_offset = ip - rtm->code;
-               }
-
-#if 0
-               sf->il_offset = mono_debug_il_offset_from_address (ji->method, sf->native_offset, domain);
-
-               if (need_file_info) {
-                       gchar *filename;
-                       
-                       filename = mono_debug_source_location_from_address (ji->method, sf->native_offset, &sf->line, domain);
-
-                       sf->filename = filename? mono_string_new (domain, filename): NULL;
-                       sf->column = 0;
-
-                       g_free (filename);
-               }
-#endif
-
-               mono_array_set (res, gpointer, i, sf);
-       }
-
-       return res;
-}
-
-static MonoObject *
-ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, MonoObject *target, MonoReflectionMethod *info)
-{
-       MonoClass *delegate_class = mono_class_from_mono_type (type->type);
-       MonoObject *delegate;
-       MonoError error;
-
-       g_assert (delegate_class->parent == mono_defaults.multicastdelegate_class);
-
-       delegate = mono_object_new_checked (mono_object_domain (type), delegate_class, &error);
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-
-       interp_delegate_ctor (mono_object_domain (type), delegate, target, mono_interp_get_runtime_method (mono_get_root_domain (), info->method, &error));
-       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-
-       return delegate;
-}
-
-void
-mono_interp_init ()
-{
-       mono_native_tls_alloc (&thread_context_id, NULL);
-    mono_native_tls_set_value (thread_context_id, NULL);
-       mono_os_mutex_init_recursive (&runtime_method_lookup_section);
-       mono_os_mutex_init_recursive (&create_method_pointer_mutex);
-
-       mono_interp_transform_init ();
-}
-
-typedef int (*TestMethod) (void);
-
-static void
-interp_regression_step (MonoImage *image, int verbose, int *total_run, int *total, GTimer *timer, MonoDomain *domain)
-{
-       int result, expected, failed, cfailed, run;
-       double elapsed, transform_time;
-       int i;
-       MonoObject *result_obj;
-       static gboolean filter_method_init = FALSE;
-       static const char *filter_method = NULL;
-
-       g_print ("Test run: image=%s\n", mono_image_get_filename (image));
-       cfailed = failed = run = 0;
-       transform_time = elapsed = 0.0;
-
-#if 0
-       /* fixme: ugly hack - delete all previously compiled methods */
-       if (domain_jit_info (domain)) {
-               g_hash_table_destroy (domain_jit_info (domain)->jit_trampoline_hash);
-               domain_jit_info (domain)->jit_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
-               mono_internal_hash_table_destroy (&(domain->jit_code_hash));
-               mono_jit_code_hash_init (&(domain->jit_code_hash));
-       }
-#endif
-
-       g_timer_start (timer);
-       for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
-               MonoObject *exc = NULL;
-               MonoError error;
-               MonoMethod *method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, &error);
-               if (!method) {
-                       mono_error_cleanup (&error); /* FIXME don't swallow the error */
-                       continue;
-               }
-
-               if (!filter_method_init) {
-                       filter_method = g_getenv ("INTERP_FILTER_METHOD");
-                       filter_method_init = TRUE;
-               }
-               gboolean filter = FALSE;
-               if (filter_method) {
-                       const char *name = filter_method;
-
-                       if ((strchr (name, '.') > name) || strchr (name, ':')) {
-                               MonoMethodDesc *desc = mono_method_desc_new (name, TRUE);
-                               filter = mono_method_desc_full_match (desc, method);
-                               mono_method_desc_free (desc);
-                       } else {
-                               filter = strcmp (method->name, name) == 0;
-                       }
-               } else { /* no filter, check for `Category' attribute on method */
-                       filter = TRUE;
-                       MonoCustomAttrInfo* ainfo = mono_custom_attrs_from_method_checked (method, &error);
-                       mono_error_cleanup (&error);
-
-                       if (ainfo) {
-                               int j;
-                               for (j = 0; j < ainfo->num_attrs && filter; ++j) {
-                                       MonoCustomAttrEntry *centry = &ainfo->attrs [j];
-                                       if (centry->ctor == NULL)
-                                               continue;
-
-                                       MonoClass *klass = centry->ctor->klass;
-                                       if (strcmp (klass->name, "CategoryAttribute"))
-                                               continue;
-
-                                       MonoObject *obj = mono_custom_attrs_get_attr_checked (ainfo, klass, &error);
-                                       /* FIXME: there is an ordering problem if there're multiple attributes, do this instead:
-                                        * MonoObject *obj = create_custom_attr (ainfo->image, centry->ctor, centry->data, centry->data_size, &error); */
-                                       mono_error_cleanup (&error);
-                                       MonoMethod *getter = mono_class_get_method_from_name (klass, "get_Category", -1);
-                                       MonoObject *str = mono_interp_runtime_invoke (getter, obj, NULL, &exc, &error);
-                                       mono_error_cleanup (&error);
-                                       char *utf8_str = mono_string_to_utf8_checked ((MonoString *) str, &error);
-                                       mono_error_cleanup (&error);
-                                       if (!strcmp (utf8_str, "!INTERPRETER")) {
-                                               g_print ("skip %s...\n", method->name);
-                                               filter = FALSE;
-                                       }
-                               }
-                       }
-               }
-               if (strncmp (method->name, "test_", 5) == 0 && filter) {
-                       MonoError interp_error;
-                       MonoObject *exc = NULL;
-
-                       result_obj = mono_interp_runtime_invoke (method, NULL, NULL, &exc, &interp_error);
-                       if (!mono_error_ok (&interp_error)) {
-                               cfailed++;
-                               g_print ("Test '%s' execution failed.\n", method->name);
-                       } else if (exc != NULL) {
-                               g_print ("Exception in Test '%s' occured:\n", method->name);
-                               mono_object_describe (exc);
-                               run++;
-                               failed++;
-                       } else {
-                               result = *(gint32 *) mono_object_unbox (result_obj);
-                               expected = atoi (method->name + 5);  // FIXME: oh no.
-                               run++;
-
-                               if (result != expected) {
-                                       failed++;
-                                       g_print ("Test '%s' failed result (got %d, expected %d).\n", method->name, result, expected);
-                               }
-                       }
-               }
-       }
-       g_timer_stop (timer);
-       elapsed = g_timer_elapsed (timer, NULL);
-       if (failed > 0 || cfailed > 0){
-               g_print ("Results: total tests: %d, failed: %d, cfailed: %d (pass: %.2f%%)\n",
-                               run, failed, cfailed, 100.0*(run-failed-cfailed)/run);
-       } else {
-               g_print ("Results: total tests: %d, all pass \n",  run);
-       }
-
-       g_print ("Elapsed time: %f secs (%f, %f)\n\n", elapsed,
-                       elapsed - transform_time, transform_time);
-       *total += failed + cfailed;
-       *total_run += run;
-}
-static int
-interp_regression (MonoImage *image, int verbose, int *total_run)
-{
-       MonoMethod *method;
-       GTimer *timer = g_timer_new ();
-       MonoDomain *domain = mono_domain_get ();
-       guint32 i;
-       int total;
-
-       /* load the metadata */
-       for (i = 0; i < mono_image_get_table_rows (image, MONO_TABLE_METHOD); ++i) {
-               MonoError error;
-               method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, &error);
-               if (!method) {
-                       mono_error_cleanup (&error);
-                       continue;
-               }
-               mono_class_init (method->klass);
-       }
-
-       total = 0;
-       *total_run = 0;
-       interp_regression_step (image, verbose, total_run, &total, timer, domain);
-
-       g_timer_destroy (timer);
-       return total;
-}
-
-int
-mono_interp_regression_list (int verbose, int count, char *images [])
-{
-       int i, total, total_run, run;
-       
-       total_run = total = 0;
-       for (i = 0; i < count; ++i) {
-               MonoAssembly *ass = mono_assembly_open (images [i], NULL);
-               if (!ass) {
-                       g_warning ("failed to load assembly: %s", images [i]);
-                       continue;
-               }
-               total += interp_regression (mono_assembly_get_image (ass), verbose, &run);
-               total_run += run;
-       }
-       if (total > 0) {
-               g_print ("Overall results: tests: %d, failed: %d (pass: %.2f%%)\n", total_run, total, 100.0*(total_run-total)/total_run);
-       } else {
-               g_print ("Overall results: tests: %d, 100%% pass\n", total_run);
-       }
-       
-       return total;
-}
-
diff --git a/mono/mini/interpreter/interp.h b/mono/mini/interpreter/interp.h
deleted file mode 100644 (file)
index 8c75b94..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __MONO_MINI_INTERPRETER_H__
-#define __MONO_MINI_INTERPRETER_H__
-#include <mono/mini/mini.h>
-
-int
-mono_interp_regression_list (int verbose, int count, char *images []);
-
-void
-mono_interp_init (void);
-
-gpointer
-mono_interp_create_method_pointer (MonoMethod *method, MonoError *error);
-
-MonoObject*
-mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc, MonoError *error);
-
-#endif /* __MONO_MINI_INTERPRETER_H__ */
diff --git a/mono/mini/interpreter/mintops.c b/mono/mini/interpreter/mintops.c
deleted file mode 100644 (file)
index 5b4d692..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Utilities for handling interpreter VM instructions
- *
- * Authors:
- *   Bernie Solomon (bernard@ugsolutions.com)
- *
- */
-#include <glib.h>
-#include <stdio.h>
-#include "mintops.h"
-
-#define OPDEF(a,b,c,d) \
-       b,
-const char *mono_interp_opname[] = {
-#include "mintops.def"
-       ""
-};
-#undef OPDEF
-
-#define OPDEF(a,b,c,d) \
-       c,
-unsigned char mono_interp_oplen[] = {
-#include "mintops.def"
-       0
-};
-#undef OPDEF
-
-
-#define OPDEF(a,b,c,d) \
-       d,
-MintOpArgType mono_interp_opargtype[] = {
-#include "mintops.def"
-       0
-};
-#undef OPDEF
-
-const guint16 *
-mono_interp_dis_mintop(const guint16 *base, const guint16 *ip)
-{
-       int len = mono_interp_oplen [*ip];
-       guint32 token;
-       int target;
-       if (len < 0 || len > 10) {
-               g_print ("op %d len %d\n", *ip, len);
-               g_assert_not_reached ();
-       } else if (len == 0) { /* SWITCH */
-               int n = READ32 (ip + 1);
-               len = 3 + n * 2;
-       }
-
-       g_print ("IL_%04x: %-10s", ip - base, mono_interp_opname [*ip]);
-       switch (mono_interp_opargtype [*ip]) {
-       case MintOpNoArgs:
-               break;
-       case MintOpUShortInt:
-               g_print (" %u", * (guint16 *)(ip + 1));
-               break;
-       case MintOpTwoShorts:
-               g_print (" %u,%u", * (guint16 *)(ip + 1), * (guint16 *)(ip + 2));
-               break;
-       case MintOpShortAndInt:
-               g_print (" %u,%u", * (guint16 *)(ip + 1), (guint32)READ32(ip + 2));
-               break;
-       case MintOpShortInt:
-               g_print (" %d", * (short *)(ip + 1));
-               break;
-       case MintOpClassToken:
-       case MintOpMethodToken:
-       case MintOpFieldToken:
-               token = * (guint16 *)(ip + 1);
-               g_print (" %u", token);
-               break;
-       case MintOpInt:
-               g_print (" %d", (gint32)READ32 (ip + 1));
-               break;
-       case MintOpLongInt:
-               g_print (" %lld", (gint64)READ64 (ip + 1));
-               break;
-       case MintOpFloat: {
-               gint32 tmp = READ32 (ip + 1);
-               g_print (" %g", * (float *)&tmp);
-               break;
-       }
-       case MintOpDouble: {
-               gint64 tmp = READ64 (ip + 1);
-               g_print (" %g", * (double *)&tmp);
-               break;
-       }
-       case MintOpShortBranch:
-               target = ip + * (short *)(ip + 1) - base;
-               g_print (" IL_%04x", target);
-               break;
-       case MintOpBranch:
-               target = ip + (gint32)READ32 (ip + 1) - base;
-               g_print (" IL_%04x", target);
-               break;
-       case MintOpSwitch: {
-               const guint16 *p = ip + 1;
-               int sval = (gint32)READ32 (p);
-               int i;
-               p += 2;
-               g_print ("(");
-               for (i = 0; i < sval; ++i) {
-                       int offset;
-                       if (i > 0)
-                               g_print (", ");
-                       offset = (gint32)READ32 (p);
-                       g_print ("IL_%04x", ip - base + 3 + 2 * sval + offset);
-                       p += 2;
-               }
-               g_print (")");
-               break;
-       }
-       default:
-               g_print("unknown arg type\n");
-       }
-
-       return ip + len;
-}
-
diff --git a/mono/mini/interpreter/mintops.def b/mono/mini/interpreter/mintops.def
deleted file mode 100644 (file)
index a9ed29f..0000000
+++ /dev/null
@@ -1,506 +0,0 @@
-/*
- * Definitions of VM instructions executed by interp.c
- *
- * Authors:
- *   Bernie Solomon (bernard@ugsolutions.com)
- *
- */
-
-/* OPDEF (opsymbol, opstring, oplength, optype) */
-
-OPDEF(MINT_NOP, "nop", 1, MintOpNoArgs)
-OPDEF(MINT_BREAK, "break", 1, MintOpNoArgs)
-OPDEF(MINT_LDNULL, "ldnull", 1, MintOpNoArgs)
-OPDEF(MINT_DUP, "dup", 1, MintOpNoArgs)
-OPDEF(MINT_DUP_VT, "dup.vt", 3, MintOpInt)
-OPDEF(MINT_POP, "pop", 1, MintOpNoArgs)
-
-OPDEF(MINT_RET, "ret", 1, MintOpNoArgs)
-OPDEF(MINT_RET_VOID, "ret.void", 1, MintOpNoArgs)
-OPDEF(MINT_RET_VT, "ret.vt", 3, MintOpInt)
-
-OPDEF(MINT_VTRESULT, "vtresult", 4, MintOpShortAndInt) /*FIX should be unsigned*/
-
-OPDEF(MINT_LDC_I4_M1, "ldc.i4.m1", 1, MintOpNoArgs)
-OPDEF(MINT_LDC_I4_0, "ldc.i4.0", 1, MintOpNoArgs)
-OPDEF(MINT_LDC_I4_1, "ldc.i4.1", 1, MintOpNoArgs)
-OPDEF(MINT_LDC_I4_2, "ldc.i4.2", 1, MintOpNoArgs)
-OPDEF(MINT_LDC_I4_3, "ldc.i4.3", 1, MintOpNoArgs)
-OPDEF(MINT_LDC_I4_4, "ldc.i4.4", 1, MintOpNoArgs)
-OPDEF(MINT_LDC_I4_5, "ldc.i4.5", 1, MintOpNoArgs)
-OPDEF(MINT_LDC_I4_6, "ldc.i4.6", 1, MintOpNoArgs)
-OPDEF(MINT_LDC_I4_7, "ldc.i4.7", 1, MintOpNoArgs)
-OPDEF(MINT_LDC_I4_8, "ldc.i4.8", 1, MintOpNoArgs)
-
-OPDEF(MINT_LDC_I4_S, "ldc.i4.s", 2, MintOpShortInt)
-OPDEF(MINT_LDC_I4, "ldc.i4", 3, MintOpInt)
-OPDEF(MINT_LDC_I8, "ldc.i8", 5, MintOpLongInt)
-
-OPDEF(MINT_LDC_R4, "ldc.r4", 3, MintOpFloat)
-OPDEF(MINT_LDC_R8, "ldc.r8", 5, MintOpDouble)
-
-OPDEF(MINT_LDARG_I1, "ldarg.i1", 2, MintOpUShortInt)
-OPDEF(MINT_LDARG_U1, "ldarg.u1", 2, MintOpUShortInt)
-OPDEF(MINT_LDARG_I2, "ldarg.i2", 2, MintOpUShortInt)
-OPDEF(MINT_LDARG_U2, "ldarg.u2", 2, MintOpUShortInt)
-OPDEF(MINT_LDARG_I4, "ldarg.i4", 2, MintOpUShortInt)
-OPDEF(MINT_LDARG_I8, "ldarg.i8", 2, MintOpUShortInt)
-OPDEF(MINT_LDARG_R4, "ldarg.r4", 2, MintOpUShortInt)
-OPDEF(MINT_LDARG_R8, "ldarg.r8", 2, MintOpUShortInt)
-OPDEF(MINT_LDARG_O, "ldarg.o", 2, MintOpUShortInt)
-OPDEF(MINT_LDARG_P, "ldarg.p", 2, MintOpUShortInt)
-OPDEF(MINT_LDARG_VT, "ldarg.vt", 4, MintOpShortAndInt)
-
-OPDEF(MINT_STARG_I1, "starg.i1", 2, MintOpUShortInt)
-OPDEF(MINT_STARG_U1, "starg.u1", 2, MintOpUShortInt)
-OPDEF(MINT_STARG_I2, "starg.i2", 2, MintOpUShortInt)
-OPDEF(MINT_STARG_U2, "starg.u2", 2, MintOpUShortInt)
-OPDEF(MINT_STARG_I4, "starg.i4", 2, MintOpUShortInt)
-OPDEF(MINT_STARG_I8, "starg.i8", 2, MintOpUShortInt)
-OPDEF(MINT_STARG_R4, "starg.r4", 2, MintOpUShortInt)
-OPDEF(MINT_STARG_R8, "starg.r8", 2, MintOpUShortInt)
-OPDEF(MINT_STARG_O, "starg.o", 2, MintOpUShortInt)
-OPDEF(MINT_STARG_P, "starg.p", 2, MintOpUShortInt)
-OPDEF(MINT_STARG_VT, "starg.vt", 4, MintOpShortAndInt)
-
-OPDEF(MINT_STINARG_I1, "stinarg.i1", 2, MintOpUShortInt)
-OPDEF(MINT_STINARG_U1, "stinarg.u1", 2, MintOpUShortInt)
-OPDEF(MINT_STINARG_I2, "stinarg.i2", 2, MintOpUShortInt)
-OPDEF(MINT_STINARG_U2, "stinarg.u2", 2, MintOpUShortInt)
-OPDEF(MINT_STINARG_I4, "stinarg.i4", 2, MintOpUShortInt)
-OPDEF(MINT_STINARG_I8, "stinarg.i8", 2, MintOpUShortInt)
-OPDEF(MINT_STINARG_R4, "stinarg.r4", 2, MintOpUShortInt)
-OPDEF(MINT_STINARG_R8, "stinarg.r8", 2, MintOpUShortInt)
-OPDEF(MINT_STINARG_O, "stinarg.o", 2, MintOpUShortInt)
-OPDEF(MINT_STINARG_P, "stinarg.p", 2, MintOpUShortInt)
-OPDEF(MINT_STINARG_VT, "stinarg.vt", 4, MintOpShortAndInt)
-
-OPDEF(MINT_LDARGA, "ldarga", 2, MintOpUShortInt)
-OPDEF(MINT_LDTHISA, "ldthisa", 1, MintOpNoArgs)
-
-OPDEF(MINT_LDFLD_I1, "ldfld.i1", 2, MintOpUShortInt)
-OPDEF(MINT_LDFLD_U1, "ldfld.u1", 2, MintOpUShortInt)
-OPDEF(MINT_LDFLD_I2, "ldfld.i2", 2, MintOpUShortInt)
-OPDEF(MINT_LDFLD_U2, "ldfld.u2", 2, MintOpUShortInt)
-OPDEF(MINT_LDFLD_I4, "ldfld.i4", 2, MintOpUShortInt)
-OPDEF(MINT_LDFLD_I8, "ldfld.i8", 2, MintOpUShortInt)
-OPDEF(MINT_LDFLD_R4, "ldfld.r4", 2, MintOpUShortInt)
-OPDEF(MINT_LDFLD_R8, "ldfld.r8", 2, MintOpUShortInt)
-OPDEF(MINT_LDFLD_O, "ldfld.o", 2, MintOpUShortInt)
-OPDEF(MINT_LDFLD_P, "ldfld.p", 2, MintOpUShortInt)
-OPDEF(MINT_LDFLD_VT, "ldfld.vt", 4, MintOpShortAndInt)
-
-OPDEF(MINT_LDRMFLD, "ldrmfld", 2, MintOpFieldToken)
-OPDEF(MINT_LDRMFLD_VT, "ldrmfld.vt", 4, MintOpShortAndInt)
-
-OPDEF(MINT_LDFLDA, "ldflda", 2, MintOpUShortInt)
-
-OPDEF(MINT_STFLD_I1, "stfld.i1", 2, MintOpUShortInt)
-OPDEF(MINT_STFLD_U1, "stfld.u1", 2, MintOpUShortInt)
-OPDEF(MINT_STFLD_I2, "stfld.i2", 2, MintOpUShortInt)
-OPDEF(MINT_STFLD_U2, "stfld.u2", 2, MintOpUShortInt)
-OPDEF(MINT_STFLD_I4, "stfld.i4", 2, MintOpUShortInt)
-OPDEF(MINT_STFLD_I8, "stfld.i8", 2, MintOpUShortInt)
-OPDEF(MINT_STFLD_R4, "stfld.r4", 2, MintOpUShortInt)
-OPDEF(MINT_STFLD_R8, "stfld.r8", 2, MintOpUShortInt)
-OPDEF(MINT_STFLD_O, "stfld.o", 2, MintOpUShortInt)
-OPDEF(MINT_STFLD_P, "stfld.p", 2, MintOpUShortInt)
-OPDEF(MINT_STFLD_VT, "stfld.vt", 4, MintOpShortAndInt)
-
-OPDEF(MINT_STRMFLD, "strmfld", 2, MintOpFieldToken)
-OPDEF(MINT_STRMFLD_VT, "strmfld.vt", 4, MintOpShortAndInt)
-
-OPDEF(MINT_LDSFLD, "ldsfld", 2, MintOpFieldToken)
-OPDEF(MINT_LDSFLD_VT, "ldsfld.vt", 4, MintOpShortAndInt)
-OPDEF(MINT_STSFLD, "stsfld", 2, MintOpUShortInt)
-OPDEF(MINT_STSFLD_VT, "stsfld.vt", 4, MintOpShortAndInt)
-OPDEF(MINT_LDSFLDA, "ldsflda", 2, MintOpUShortInt)
-
-OPDEF(MINT_LDLOC_I1, "ldloc.i1", 2, MintOpUShortInt)
-OPDEF(MINT_LDLOC_U1, "ldloc.u1", 2, MintOpUShortInt)
-OPDEF(MINT_LDLOC_I2, "ldloc.i2", 2, MintOpUShortInt)
-OPDEF(MINT_LDLOC_U2, "ldloc.u2", 2, MintOpUShortInt)
-OPDEF(MINT_LDLOC_I4, "ldloc.i4", 2, MintOpUShortInt)
-OPDEF(MINT_LDLOC_I8, "ldloc.i8", 2, MintOpUShortInt)
-OPDEF(MINT_LDLOC_R4, "ldloc.r4", 2, MintOpUShortInt)
-OPDEF(MINT_LDLOC_R8, "ldloc.r8", 2, MintOpUShortInt)
-OPDEF(MINT_LDLOC_O, "ldloc.o", 2, MintOpUShortInt)
-OPDEF(MINT_LDLOC_P, "ldloc.p", 2, MintOpUShortInt)
-OPDEF(MINT_LDLOC_VT, "ldloc.vt", 4, MintOpShortAndInt)
-
-OPDEF(MINT_STLOC_I1, "stloc.i1", 2, MintOpUShortInt)
-OPDEF(MINT_STLOC_U1, "stloc.u1", 2, MintOpUShortInt)
-OPDEF(MINT_STLOC_I2, "stloc.i2", 2, MintOpUShortInt)
-OPDEF(MINT_STLOC_U2, "stloc.u2", 2, MintOpUShortInt)
-OPDEF(MINT_STLOC_I4, "stloc.i4", 2, MintOpUShortInt)
-OPDEF(MINT_STLOC_I8, "stloc.i8", 2, MintOpUShortInt)
-OPDEF(MINT_STLOC_R4, "stloc.r4", 2, MintOpUShortInt)
-OPDEF(MINT_STLOC_R8, "stloc.r8", 2, MintOpUShortInt)
-OPDEF(MINT_STLOC_O, "stloc.o", 2, MintOpUShortInt)
-OPDEF(MINT_STLOC_P, "stloc.p", 2, MintOpUShortInt)
-OPDEF(MINT_STLOC_VT, "stloc.vt", 4, MintOpShortAndInt)
-
-OPDEF(MINT_STLOC_NP_I4, "stloc.np.i4", 2, MintOpUShortInt)
-OPDEF(MINT_STLOC_NP_O, "stloc.np.o", 2, MintOpUShortInt)
-
-OPDEF(MINT_LDLOCA_S, "ldloca.s", 2, MintOpUShortInt)
-
-OPDEF(MINT_LDIND_I1, "ldind.i1", 1, MintOpNoArgs)
-OPDEF(MINT_LDIND_U1, "ldind.u1", 1, MintOpNoArgs)
-OPDEF(MINT_LDIND_I2, "ldind.i2", 1, MintOpNoArgs)
-OPDEF(MINT_LDIND_U2, "ldind.u2", 1, MintOpNoArgs)
-OPDEF(MINT_LDIND_I4, "ldind.i4", 1, MintOpNoArgs)
-OPDEF(MINT_LDIND_U4, "ldind.u4", 1, MintOpNoArgs)
-OPDEF(MINT_LDIND_I8, "ldind.i8", 1, MintOpNoArgs)
-OPDEF(MINT_LDIND_I, "ldind.i", 2, MintOpUShortInt)
-OPDEF(MINT_LDIND_R4, "ldind.r4", 1, MintOpNoArgs)
-OPDEF(MINT_LDIND_R8, "ldind.r8", 1, MintOpNoArgs)
-OPDEF(MINT_LDIND_REF, "ldind.ref", 1, MintOpNoArgs)
-OPDEF(MINT_STIND_I1, "stind.i1", 1, MintOpNoArgs)
-OPDEF(MINT_STIND_I2, "stind.i2", 1, MintOpNoArgs)
-OPDEF(MINT_STIND_I4, "stind.i4", 1, MintOpNoArgs)
-OPDEF(MINT_STIND_I8, "stind.i8", 1, MintOpNoArgs)
-OPDEF(MINT_STIND_I, "stind.i", 1, MintOpNoArgs)
-OPDEF(MINT_STIND_R4, "stind.r4", 1, MintOpNoArgs)
-OPDEF(MINT_STIND_R8, "stind.r8", 1, MintOpNoArgs)
-OPDEF(MINT_STIND_REF, "stind.ref", 1, MintOpNoArgs)
-
-OPDEF(MINT_BR, "br", 3, MintOpBranch)
-OPDEF(MINT_LEAVE, "leave", 3, MintOpBranch)
-OPDEF(MINT_BR_S, "br.s", 2, MintOpShortBranch)
-OPDEF(MINT_LEAVE_S, "leave.s", 2, MintOpShortBranch)
-
-OPDEF(MINT_THROW, "throw", 1, MintOpNoArgs)
-OPDEF(MINT_RETHROW, "rethrow", 1, MintOpNoArgs)
-OPDEF(MINT_ENDFINALLY, "endfinally", 1, MintOpNoArgs)
-
-OPDEF(MINT_BRFALSE_I4, "brfalse.i4", 3, MintOpBranch)
-OPDEF(MINT_BRFALSE_I8, "brfalse.i8", 3, MintOpBranch)
-OPDEF(MINT_BRFALSE_R8, "brfalse.r8", 3, MintOpBranch)
-OPDEF(MINT_BRTRUE_I4, "brtrue.i4", 3, MintOpBranch)
-OPDEF(MINT_BRTRUE_I8, "brtrue.i8", 3, MintOpBranch)
-OPDEF(MINT_BRTRUE_R8, "brtrue.r8", 3, MintOpBranch)
-
-OPDEF(MINT_BRFALSE_I4_S, "brfalse.i4.s", 2, MintOpShortBranch)
-OPDEF(MINT_BRFALSE_I8_S, "brfalse.i8.s", 2, MintOpShortBranch)
-OPDEF(MINT_BRFALSE_R8_S, "brfalse.r8.s", 2, MintOpShortBranch)
-OPDEF(MINT_BRTRUE_I4_S, "brtrue.i4.s", 2, MintOpShortBranch)
-OPDEF(MINT_BRTRUE_I8_S, "brtrue.i8.s", 2, MintOpShortBranch)
-OPDEF(MINT_BRTRUE_R8_S, "brtrue.r8.s", 2, MintOpShortBranch)
-
-OPDEF(MINT_BEQ_I4, "beq.i4", 3, MintOpBranch)
-OPDEF(MINT_BEQ_I8, "beq.i8", 3, MintOpBranch)
-OPDEF(MINT_BEQ_R8, "beq.r8", 3, MintOpBranch)
-OPDEF(MINT_BGE_I4, "bge.i4", 3, MintOpBranch) 
-OPDEF(MINT_BGE_I8, "bge.i8", 3, MintOpBranch) 
-OPDEF(MINT_BGE_R8, "bge.r8", 3, MintOpBranch) 
-OPDEF(MINT_BGT_I4, "bgt.i4", 3, MintOpBranch) 
-OPDEF(MINT_BGT_I8, "bgt.i8", 3, MintOpBranch) 
-OPDEF(MINT_BGT_R8, "bgt.r8", 3, MintOpBranch) 
-OPDEF(MINT_BLT_I4, "blt.i4", 3, MintOpBranch) 
-OPDEF(MINT_BLT_I8, "blt.i8", 3, MintOpBranch) 
-OPDEF(MINT_BLT_R8, "blt.r8", 3, MintOpBranch) 
-OPDEF(MINT_BLE_I4, "ble.i4", 3, MintOpBranch) 
-OPDEF(MINT_BLE_I8, "ble.i8", 3, MintOpBranch) 
-OPDEF(MINT_BLE_R8, "ble.r8", 3, MintOpBranch) 
-
-OPDEF(MINT_BNE_UN_I4, "bne.un.i4", 3, MintOpBranch)
-OPDEF(MINT_BNE_UN_I8, "bne.un.i8", 3, MintOpBranch)
-OPDEF(MINT_BNE_UN_R8, "bne.un.r8", 3, MintOpBranch)
-OPDEF(MINT_BGE_UN_I4, "bge.un.i4", 3, MintOpBranch) 
-OPDEF(MINT_BGE_UN_I8, "bge.un.i8", 3, MintOpBranch) 
-OPDEF(MINT_BGE_UN_R8, "bge.un.r8", 3, MintOpBranch) 
-OPDEF(MINT_BGT_UN_I4, "bgt.un.i4", 3, MintOpBranch) 
-OPDEF(MINT_BGT_UN_I8, "bgt.un.i8", 3, MintOpBranch) 
-OPDEF(MINT_BGT_UN_R8, "bgt.un.r8", 3, MintOpBranch) 
-OPDEF(MINT_BLE_UN_I4, "ble.un.i4", 3, MintOpBranch) 
-OPDEF(MINT_BLE_UN_I8, "ble.un.i8", 3, MintOpBranch) 
-OPDEF(MINT_BLE_UN_R8, "ble.un.r8", 3, MintOpBranch) 
-OPDEF(MINT_BLT_UN_I4, "blt.un.i4", 3, MintOpBranch) 
-OPDEF(MINT_BLT_UN_I8, "blt.un.i8", 3, MintOpBranch) 
-OPDEF(MINT_BLT_UN_R8, "blt.un.r8", 3, MintOpBranch) 
-
-OPDEF(MINT_BEQ_I4_S, "beq.i4.s", 2, MintOpShortBranch)
-OPDEF(MINT_BEQ_I8_S, "beq.i8.s", 2, MintOpShortBranch)
-OPDEF(MINT_BEQ_R8_S, "beq.r8.s", 2, MintOpShortBranch)
-OPDEF(MINT_BGE_I4_S, "bge.i4.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BGE_I8_S, "bge.i8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BGE_R8_S, "bge.r8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BGT_I4_S, "bgt.i4.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BGT_I8_S, "bgt.i8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BGT_R8_S, "bgt.r8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BLT_I4_S, "blt.i4.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BLT_I8_S, "blt.i8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BLT_R8_S, "blt.r8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BLE_I4_S, "ble.i4.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BLE_I8_S, "ble.i8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BLE_R8_S, "ble.r8.s", 2, MintOpShortBranch) 
-
-OPDEF(MINT_BNE_UN_I4_S, "bne.un.i4.s", 2, MintOpShortBranch)
-OPDEF(MINT_BNE_UN_I8_S, "bne.un.i8.s", 2, MintOpShortBranch)
-OPDEF(MINT_BNE_UN_R8_S, "bne.un.r8.s", 2, MintOpShortBranch)
-OPDEF(MINT_BGE_UN_I4_S, "bge.un.i4.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BGE_UN_I8_S, "bge.un.i8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BGE_UN_R8_S, "bge.un.r8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BGT_UN_I4_S, "bgt.un.i4.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BGT_UN_I8_S, "bgt.un.i8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BGT_UN_R8_S, "bgt.un.r8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BLE_UN_I4_S, "ble.un.i4.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BLE_UN_I8_S, "ble.un.i8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BLE_UN_R8_S, "ble.un.r8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BLT_UN_I4_S, "blt.un.i4.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BLT_UN_I8_S, "blt.un.i8.s", 2, MintOpShortBranch) 
-OPDEF(MINT_BLT_UN_R8_S, "blt.un.r8.s", 2, MintOpShortBranch) 
-
-OPDEF(MINT_SWITCH, "switch", 0, MintOpSwitch)
-
-OPDEF(MINT_LDSTR, "ldstr", 2, MintOpMethodToken) /* not really */
-
-OPDEF(MINT_CALL, "call", 2, MintOpMethodToken) 
-OPDEF(MINT_VCALL, "vcall", 2, MintOpMethodToken) 
-OPDEF(MINT_CALLVIRT, "callvirt", 2, MintOpMethodToken) 
-OPDEF(MINT_VCALLVIRT, "vcallvirt", 2, MintOpMethodToken) 
-OPDEF(MINT_CALLI, "calli", 2, MintOpMethodToken) 
-OPDEF(MINT_CALLI_NAT, "calli.nat", 2, MintOpMethodToken) 
-OPDEF(MINT_JMP, "jmp", 2, MintOpMethodToken) 
-
-OPDEF(MINT_CALLRUN, "callrun", 1, MintOpNoArgs)
-
-OPDEF(MINT_NEWOBJ, "newobj", 2, MintOpMethodToken) 
-OPDEF(MINT_INITOBJ, "initobj", 3, MintOpInt) 
-OPDEF(MINT_CASTCLASS, "castclass", 2, MintOpClassToken) 
-OPDEF(MINT_ISINST, "isinst", 2, MintOpClassToken) 
-OPDEF(MINT_NEWARR, "newarr", 2, MintOpClassToken) 
-OPDEF(MINT_BOX, "box", 3, MintOpTwoShorts)
-OPDEF(MINT_UNBOX, "unbox", 2, MintOpClassToken) 
-OPDEF(MINT_LDTOKEN, "ldtoken", 2, MintOpClassToken) /* not really */
-OPDEF(MINT_LDFTN, "ldftn", 2, MintOpMethodToken) 
-OPDEF(MINT_LDVIRTFTN, "ldvirtftn", 2, MintOpMethodToken) 
-OPDEF(MINT_LDOBJ, "ldobj", 2, MintOpClassToken) 
-OPDEF(MINT_STOBJ, "stobj", 2, MintOpClassToken) 
-OPDEF(MINT_STOBJ_VT, "stobj.vt", 2, MintOpClassToken) 
-OPDEF(MINT_CPBLK, "cpblk", 1, MintOpNoArgs) 
-OPDEF(MINT_INITBLK, "initblk", 1, MintOpNoArgs) 
-OPDEF(MINT_LOCALLOC, "localloc", 1, MintOpNoArgs) 
-OPDEF(MINT_INITLOCALS, "initlocals", 1, MintOpNoArgs) 
-
-OPDEF(MINT_LDELEM_I, "ldelem.i", 1, MintOpNoArgs)
-OPDEF(MINT_LDELEM_I1, "ldelem.i1", 1, MintOpNoArgs)
-OPDEF(MINT_LDELEM_U1, "ldelem.u1", 1, MintOpNoArgs)
-OPDEF(MINT_LDELEM_I2, "ldelem.i2", 1, MintOpNoArgs)
-OPDEF(MINT_LDELEM_U2, "ldelem.u2", 1, MintOpNoArgs)
-OPDEF(MINT_LDELEM_I4, "ldelem.i4", 1, MintOpNoArgs)
-OPDEF(MINT_LDELEM_U4, "ldelem.u4", 1, MintOpNoArgs)
-OPDEF(MINT_LDELEM_I8, "ldelem.i8", 1, MintOpNoArgs)
-OPDEF(MINT_LDELEM_R4, "ldelem.r4", 1, MintOpNoArgs)
-OPDEF(MINT_LDELEM_R8, "ldelem.r8", 1, MintOpNoArgs)
-OPDEF(MINT_LDELEM_REF, "ldelem.ref", 1, MintOpNoArgs)
-OPDEF(MINT_LDELEM_VT, "ldelem.vt", 4, MintOpShortAndInt)
-
-OPDEF(MINT_LDELEMA, "ldelema", 2, MintOpClassToken)
-
-OPDEF(MINT_STELEM_I, "stelem.i", 1, MintOpNoArgs)
-OPDEF(MINT_STELEM_I1, "stelem.i1", 1, MintOpNoArgs)
-OPDEF(MINT_STELEM_I2, "stelem.i2", 1, MintOpNoArgs)
-OPDEF(MINT_STELEM_I4, "stelem.i4", 1, MintOpNoArgs)
-OPDEF(MINT_STELEM_I8, "stelem.i8", 1, MintOpNoArgs)
-OPDEF(MINT_STELEM_R4, "stelem.r4", 1, MintOpNoArgs)
-OPDEF(MINT_STELEM_R8, "stelem.r8", 1, MintOpNoArgs)
-OPDEF(MINT_STELEM_REF, "stelem.ref", 1, MintOpNoArgs)
-OPDEF(MINT_STELEM_VT, "stelem.vt", 4, MintOpShortAndInt)
-
-OPDEF(MINT_LDLEN, "ldlen", 1, MintOpNoArgs)
-
-OPDEF(MINT_ADD_I4, "add.i4", 1, MintOpNoArgs)
-OPDEF(MINT_ADD_I8, "add.i8", 1, MintOpNoArgs)
-OPDEF(MINT_ADD_R8, "add.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_ADD1_I4, "add1.i4", 1, MintOpNoArgs)
-
-OPDEF(MINT_SUB_I4, "sub.i4", 1, MintOpNoArgs)
-OPDEF(MINT_SUB_I8, "sub.i8", 1, MintOpNoArgs)
-OPDEF(MINT_SUB_R8, "sub.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_SUB1_I4, "sub1.i4", 1, MintOpNoArgs)
-
-OPDEF(MINT_MUL_I4, "mul.i4", 1, MintOpNoArgs)
-OPDEF(MINT_MUL_I8, "mul.i8", 1, MintOpNoArgs)
-OPDEF(MINT_MUL_R8, "mul.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_DIV_I4, "div.i4", 1, MintOpNoArgs)
-OPDEF(MINT_DIV_I8, "div.i8", 1, MintOpNoArgs)
-OPDEF(MINT_DIV_R8, "div.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_DIV_UN_I4, "div.un.i4", 1, MintOpNoArgs)
-OPDEF(MINT_DIV_UN_I8, "div.un.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_ADD_OVF_I4, "add.ovf.i4", 1, MintOpNoArgs)
-OPDEF(MINT_ADD_OVF_I8, "add.ovf.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_ADD_OVF_UN_I4, "add.ovf.un.i4", 1, MintOpNoArgs)
-OPDEF(MINT_ADD_OVF_UN_I8, "add.ovf.un.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_MUL_OVF_I4, "mul.ovf.i4", 1, MintOpNoArgs)
-OPDEF(MINT_MUL_OVF_I8, "mul.ovf.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_MUL_OVF_UN_I4, "mul.ovf.un.i4", 1, MintOpNoArgs)
-OPDEF(MINT_MUL_OVF_UN_I8, "mul.ovf.un.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_SUB_OVF_I4, "sub.ovf.i4", 1, MintOpNoArgs)
-OPDEF(MINT_SUB_OVF_I8, "sub.ovf.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_SUB_OVF_UN_I4, "sub.ovf.un.i4", 1, MintOpNoArgs)
-OPDEF(MINT_SUB_OVF_UN_I8, "sub.ovf.un.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_NEG_I4, "neg.i4", 1, MintOpNoArgs)
-OPDEF(MINT_NEG_I8, "neg.i8", 1, MintOpNoArgs)
-OPDEF(MINT_NEG_R8, "neg.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_NOT_I4, "not.i4", 1, MintOpNoArgs)
-OPDEF(MINT_NOT_I8, "not.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_AND_I4, "and.i4", 1, MintOpNoArgs)
-OPDEF(MINT_AND_I8, "and.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_OR_I4, "or.i4", 1, MintOpNoArgs)
-OPDEF(MINT_OR_I8, "or.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_XOR_I4, "xor.i4", 1, MintOpNoArgs)
-OPDEF(MINT_XOR_I8, "xor.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_REM_I4, "rem.i4", 1, MintOpNoArgs)
-OPDEF(MINT_REM_I8, "rem.i8", 1, MintOpNoArgs)
-OPDEF(MINT_REM_R8, "rem.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_REM_UN_I4, "rem.un.i4", 1, MintOpNoArgs)
-OPDEF(MINT_REM_UN_I8, "rem.un.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_SHR_UN_I4, "shr.un.i4", 1, MintOpNoArgs)
-OPDEF(MINT_SHR_UN_I8, "shr.un.i8", 1, MintOpNoArgs)
-OPDEF(MINT_SHL_I4, "shl.i4", 1, MintOpNoArgs)
-OPDEF(MINT_SHL_I8, "shl.i8", 1, MintOpNoArgs)
-OPDEF(MINT_SHR_I4, "shr.i4", 1, MintOpNoArgs)
-OPDEF(MINT_SHR_I8, "shr.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_R_UN_I4, "conv.r.un.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_R_UN_I8, "conv.r.un.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_I1_I4, "conv.i1.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_I1_I8, "conv.i1.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_I1_R8, "conv.i1.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_U1_I4, "conv.u1.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_U1_I8, "conv.u1.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_U1_R8, "conv.u1.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_I2_I4, "conv.i2.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_I2_I8, "conv.i2.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_I2_R8, "conv.i2.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_U2_I4, "conv.u2.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_U2_I8, "conv.u2.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_U2_R8, "conv.u2.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_I4_I8, "conv.i4.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_I4_R8, "conv.i4.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_U4_I8, "conv.u4.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_U4_R8, "conv.u4.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_I8_I4, "conv.i8.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_I8_U4, "conv.i8.u4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_I8_R8, "conv.i8.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_R4_I4, "conv.r4.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_R4_I8, "conv.r4.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_R4_R8, "conv.r4.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_R8_I4, "conv.r8.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_R8_I8, "conv.r8.i8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_I4_I8_SP, "conv.i4.i8.sp", 1, MintOpNoArgs) /* special for narrowing sp[-2] on 64 bits */
-OPDEF(MINT_CONV_I8_I4_SP, "conv.i8.i4.sp", 1, MintOpNoArgs) /* special for widening sp[-2] on 64 bits */
-
-OPDEF(MINT_CONV_U8_I4, "conv.u8.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_U8_R8, "conv.u8.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_OVF_I1_I4, "conv.ovf.i1.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_I1_I8, "conv.ovf.i1.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_I1_R8, "conv.ovf.i1.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_OVF_U1_I4, "conv.ovf.u1.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_U1_I8, "conv.ovf.u1.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_U1_R8, "conv.ovf.u1.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_OVF_I2_I4, "conv.ovf.i2.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_I2_I8, "conv.ovf.i2.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_I2_R8, "conv.ovf.i2.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_OVF_U2_I4, "conv.ovf.u2.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_U2_I8, "conv.ovf.u2.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_U2_R8, "conv.ovf.u2.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_OVF_I4_U4, "conv.ovf.i4.u4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_I4_I8, "conv.ovf.i4.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_I4_R8, "conv.ovf.i4.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_OVF_I4_UN_I8, "conv.ovf.i4.un.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_I4_UN_R8, "conv.ovf.i4.un.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_OVF_U4_I4, "conv.ovf.u4.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_U4_I8, "conv.ovf.u4.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_U4_R8, "conv.ovf.u4.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_OVF_I8_R8, "conv.ovf.i8.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_OVF_I8_UN_R8, "conv.ovf.i8.un.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CONV_OVF_U8_I4, "conv.ovf.u8.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CONV_OVF_U8_R8, "conv.ovf.u8.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CEQ_I4, "ceq.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CEQ_I8, "ceq.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CEQ_R8, "ceq.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CEQ0_I4, "ceq0.i4", 1, MintOpNoArgs)
-
-OPDEF(MINT_CGT_I4, "cgt.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CGT_I8, "cgt.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CGT_R8, "cgt.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CGT_UN_I4, "cgt.un.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CGT_UN_I8, "cgt.un.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CGT_UN_R8, "cgt.un.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CLT_I4, "clt.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CLT_I8, "clt.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CLT_R8, "clt.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CLT_UN_I4, "clt.un.i4", 1, MintOpNoArgs)
-OPDEF(MINT_CLT_UN_I8, "clt.un.i8", 1, MintOpNoArgs)
-OPDEF(MINT_CLT_UN_R8, "clt.un.r8", 1, MintOpNoArgs)
-
-OPDEF(MINT_CKFINITE, "ckfinite", 1, MintOpNoArgs)
-
-OPDEF(MINT_CKNULL, "cknull", 1, MintOpNoArgs)
-
-OPDEF(MINT_GETCHR, "getchr", 1, MintOpNoArgs)
-OPDEF(MINT_STRLEN, "strlen", 1, MintOpNoArgs)
-OPDEF(MINT_ARRAY_RANK, "array_rank", 1, MintOpNoArgs)
-
-OPDEF(MINT_ICALL_V_V, "mono_icall_v_v", 2, MintOpClassToken) /* not really */
-OPDEF(MINT_ICALL_V_P, "mono_icall_v_p", 2, MintOpClassToken)
-OPDEF(MINT_ICALL_P_V, "mono_icall_p_v", 2, MintOpClassToken)
-OPDEF(MINT_ICALL_P_P, "mono_icall_p_p", 2, MintOpClassToken)
-OPDEF(MINT_ICALL_PP_V, "mono_icall_pp_v", 2, MintOpClassToken)
-OPDEF(MINT_ICALL_PI_V, "mono_icall_pi_v", 2, MintOpClassToken)
-OPDEF(MINT_ICALL_PP_P, "mono_icall_pp_p", 2, MintOpClassToken)
-OPDEF(MINT_ICALL_PI_P, "mono_icall_pi_p", 2, MintOpClassToken)
-OPDEF(MINT_ICALL_PPP_V, "mono_icall_ppp_v", 2, MintOpClassToken)
-OPDEF(MINT_ICALL_PPI_V, "mono_icall_ppi_v", 2, MintOpClassToken)
-OPDEF(MINT_MONO_LDPTR, "mono_ldptr", 2, MintOpClassToken) 
-OPDEF(MINT_MONO_NEWOBJ, "mono_newobj", 2, MintOpClassToken)
-OPDEF(MINT_MONO_RETOBJ, "mono_retobj", 1, MintOpNoArgs)
-OPDEF(MINT_MONO_FREE, "mono_free", 1, MintOpNoArgs)
-
-
diff --git a/mono/mini/interpreter/mintops.h b/mono/mini/interpreter/mintops.h
deleted file mode 100644 (file)
index e787526..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef __INTERPRETER_MINTOPS_H
-#define __INTERPRETER_MINTOPS_H
-
-#include <glib.h>
-
-typedef enum
-{
-       MintOpNoArgs,
-       MintOpShortInt,
-       MintOpUShortInt,
-       MintOpInt,
-       MintOpLongInt,
-       MintOpFloat,
-       MintOpDouble,
-       MintOpBranch,
-       MintOpShortBranch,
-       MintOpSwitch,
-       MintOpMethodToken,
-       MintOpFieldToken,
-       MintOpClassToken,
-       MintOpTwoShorts,
-       MintOpShortAndInt
-} MintOpArgType;
-
-#define OPDEF(a,b,c,d) \
-       a,
-enum {
-#include "mintops.def"
-       MINT_LASTOP
-};
-#undef OPDEF
-
-#if NO_UNALIGNED_ACCESS
-#  if G_BYTE_ORDER == G_LITTLE_ENDIAN
-#define READ32(x) (((guint16 *)(x)) [0] | ((guint16 *)(x)) [1] << 16)
-#define READ64(x) ((guint64)((guint16 *)(x)) [0] | \
-                   (guint64)((guint16 *)(x)) [1] << 16 | \
-                   (guint64)((guint16 *)(x)) [2] << 32 | \
-                   (guint64)((guint16 *)(x)) [3] << 48)
-#  else
-#define READ32(x) (((guint16 *)(x)) [0] << 16 | ((guint16 *)(x)) [1])
-#define READ64(x) ((guint64)((guint16 *)(x)) [0] << 48 | \
-                   (guint64)((guint16 *)(x)) [1] << 32 | \
-                   (guint64)((guint16 *)(x)) [2] << 16 | \
-                   (guint64)((guint16 *)(x)) [3])
-#  endif
-#else /* unaligned access OK */
-#define READ32(x) (*(guint32 *)(x))
-#define READ64(x) (*(guint64 *)(x))
-#endif
-
-extern const char *mono_interp_opname[];
-extern unsigned char mono_interp_oplen[];
-extern MintOpArgType mono_interp_opargtype[];
-extern const guint16 *mono_interp_dis_mintop(const unsigned short *base, const guint16 *ip);
-
-#endif
-
diff --git a/mono/mini/interpreter/transform.c b/mono/mini/interpreter/transform.c
deleted file mode 100644 (file)
index 149b452..0000000
+++ /dev/null
@@ -1,3284 +0,0 @@
-/*
- * transform CIL into different opcodes for more
- * efficient interpretation
- *
- * Written by Bernie Solomon (bernard@ugsolutions.com)
- * Copyright (c) 2004.
- */
-
-#include <string.h>
-#include <mono/metadata/appdomain.h>
-#include <mono/metadata/debug-helpers.h>
-#include <mono/metadata/exception.h>
-#include <mono/metadata/mono-endian.h>
-#include <mono/metadata/marshal.h>
-#include <mono/metadata/profiler-private.h>
-#include <mono/metadata/tabledefs.h>
-
-#include <mono/mini/mini.h>
-
-#include "mintops.h"
-#include "interp-internals.h"
-#include "interp.h"
-
-// TODO: export from marshal.c
-MonoDelegate* mono_ftnptr_to_delegate (MonoClass *klass, gpointer ftn);
-
-#define DEBUG 0
-
-typedef struct
-{
-       MonoClass *klass;
-       unsigned char type;
-       unsigned char flags;
-} StackInfo;
-
-typedef struct
-{
-       MonoMethod *method;
-       MonoMethodHeader *header;
-       RuntimeMethod *rtm;
-       const unsigned char *il_code;
-       const unsigned char *ip;
-       const unsigned char *last_ip;
-       const unsigned char *in_start;
-       int code_size;
-       int *in_offsets;
-       int *forward_refs;
-       StackInfo **stack_state;
-       int *stack_height;
-       int *vt_stack_size;
-       unsigned char *is_bb_start;
-       unsigned short *new_code;
-       unsigned short *new_code_end;
-       unsigned short *new_ip;
-       unsigned short *last_new_ip;
-       unsigned int max_code_size;
-       StackInfo *stack;
-       StackInfo *sp;
-       unsigned int max_stack_height;
-       unsigned int vt_sp;
-       unsigned int max_vt_sp;
-       int n_data_items;
-       int max_data_items;
-       void **data_items;
-       GHashTable *data_hash;
-} TransformData;
-
-#define MINT_TYPE_I1 0
-#define MINT_TYPE_U1 1
-#define MINT_TYPE_I2 2
-#define MINT_TYPE_U2 3
-#define MINT_TYPE_I4 4
-#define MINT_TYPE_I8 5
-#define MINT_TYPE_R4 6
-#define MINT_TYPE_R8 7
-#define MINT_TYPE_O  8
-#define MINT_TYPE_P  9
-#define MINT_TYPE_VT 10
-
-#define STACK_TYPE_I4 0
-#define STACK_TYPE_I8 1
-#define STACK_TYPE_R8 2
-#define STACK_TYPE_O  3
-#define STACK_TYPE_VT 4
-#define STACK_TYPE_MP 5
-#define STACK_TYPE_F  6
-
-static const char *stack_type_string [] = { "I4", "I8", "R8", "O ", "VT", "MP", "F " };
-
-#if SIZEOF_VOID_P == 8
-#define STACK_TYPE_I STACK_TYPE_I8
-#else
-#define STACK_TYPE_I STACK_TYPE_I4
-#endif
-
-static int stack_type [] = {
-       STACK_TYPE_I4, /*I1*/
-       STACK_TYPE_I4, /*U1*/
-       STACK_TYPE_I4, /*I2*/
-       STACK_TYPE_I4, /*U2*/
-       STACK_TYPE_I4, /*I4*/
-       STACK_TYPE_I8, /*I8*/
-       STACK_TYPE_R8, /*R4*/
-       STACK_TYPE_R8, /*R8*/
-       STACK_TYPE_O,  /*O*/
-       STACK_TYPE_MP, /*P*/
-       STACK_TYPE_VT
-};
-
-static void
-grow_code (TransformData *td)
-{
-       unsigned int old_ip_offset = td->new_ip - td->new_code;
-       unsigned int old_last_ip_offset = td->last_new_ip - td->new_code;
-       g_assert (old_ip_offset <= td->max_code_size);
-       td->new_code = g_realloc (td->new_code, (td->max_code_size *= 2) * sizeof (td->new_code [0]));
-       td->new_code_end = td->new_code + td->max_code_size;
-       td->new_ip = td->new_code + old_ip_offset;
-       td->last_new_ip = td->new_code + old_last_ip_offset;
-}
-
-#define ENSURE_CODE(td, n) \
-       do { \
-               if ((td)->new_ip + (n) > (td)->new_code_end) \
-                       grow_code (td); \
-       } while (0)
-
-#define ADD_CODE(td, n) \
-       do { \
-               if ((td)->new_ip == (td)->new_code_end) \
-                       grow_code (td); \
-               *(td)->new_ip++ = (n); \
-       } while (0)
-
-#define CHECK_STACK(td, n) \
-       do { \
-               int stack_size = (td)->sp - (td)->stack; \
-               if (stack_size < (n)) \
-                       g_warning ("%s.%s: not enough values (%d < %d) on stack at %04x", \
-                               (td)->method->klass->name, (td)->method->name, \
-                               stack_size, n, (td)->ip - (td)->il_code); \
-       } while (0)
-
-#define ENSURE_I4(td, sp_off) \
-       do { \
-               if ((td)->sp [-sp_off].type == STACK_TYPE_I8) \
-                       ADD_CODE(td, sp_off == 1 ? MINT_CONV_I4_I8 : MINT_CONV_I4_I8_SP); \
-       } while (0)
-
-static void 
-handle_branch(TransformData *td, int short_op, int long_op, int offset) 
-{
-       int shorten_branch = 0;
-       int target = td->ip + offset - td->il_code;
-       if (target < 0 || target >= td->code_size)
-               g_assert_not_reached ();
-       if (offset > 0 && td->stack_height [target] < 0) {
-               td->stack_height [target] = td->sp - td->stack;
-               if (td->stack_height [target] > 0)
-                       td->stack_state [target] = g_memdup (td->stack, td->stack_height [target] * sizeof (td->stack [0]));
-               td->vt_stack_size [target] = td->vt_sp;
-       }
-       if (offset < 0) {
-               offset = td->in_offsets [target] - (td->new_ip - td->new_code);
-               if (offset >= -32768) {
-                       shorten_branch = 1;
-               }
-       } else {
-               int prev = td->forward_refs [target];
-               td->forward_refs [td->ip - td->il_code] = prev;
-               td->forward_refs [target] = td->ip - td->il_code;
-               offset = 0;
-               if (td->header->code_size <= 25000) /* FIX to be precise somehow? */
-                       shorten_branch = 1;
-       }
-       if (shorten_branch) {
-               ADD_CODE(td, short_op);
-               ADD_CODE(td, offset);
-       } else {
-               ADD_CODE(td, long_op);
-               ADD_CODE(td, * (unsigned short *)(&offset));
-               ADD_CODE(td, * ((unsigned short *)&offset + 1));
-       }
-}
-
-static void 
-one_arg_branch(TransformData *td, int mint_op, int offset) 
-{
-       int type = td->sp [-1].type == STACK_TYPE_O || td->sp [-1].type == STACK_TYPE_MP ? STACK_TYPE_I : td->sp [-1].type;
-       int long_op = mint_op + type - STACK_TYPE_I4;
-       int short_op = long_op + MINT_BRFALSE_I4_S - MINT_BRFALSE_I4;
-       CHECK_STACK(td, 1);
-       --td->sp;
-       handle_branch (td, short_op, long_op, offset);
-}
-
-static void 
-two_arg_branch(TransformData *td, int mint_op, int offset) 
-{
-       int type1 = td->sp [-1].type == STACK_TYPE_O || td->sp [-1].type == STACK_TYPE_MP ? STACK_TYPE_I : td->sp [-1].type;
-       int type2 = td->sp [-2].type == STACK_TYPE_O || td->sp [-2].type == STACK_TYPE_MP ? STACK_TYPE_I : td->sp [-2].type;
-       int long_op = mint_op + type1 - STACK_TYPE_I4;
-       int short_op = long_op + MINT_BEQ_I4_S - MINT_BEQ_I4;
-       CHECK_STACK(td, 2);
-       if (type1 == STACK_TYPE_I4 && type2 == STACK_TYPE_I8) {
-               ADD_CODE(td, MINT_CONV_I8_I4);
-               td->in_offsets [td->ip - td->il_code]++;
-       } else if (type1 == STACK_TYPE_I8 && type2 == STACK_TYPE_I4) {
-               ADD_CODE(td, MINT_CONV_I8_I4_SP);
-               td->in_offsets [td->ip - td->il_code]++;
-       } else if (type1 != type2) {
-               g_warning("%s.%s: branch type mismatch %d %d", 
-                       td->method->klass->name, td->method->name, 
-                       td->sp [-1].type, td->sp [-2].type);
-       }
-       td->sp -= 2;
-       handle_branch (td, short_op, long_op, offset);
-}
-
-static void
-unary_arith_op(TransformData *td, int mint_op)
-{
-       int op = mint_op + td->sp [-1].type - STACK_TYPE_I4;
-       CHECK_STACK(td, 1);
-       ADD_CODE(td, op);
-}
-
-static void
-binary_arith_op(TransformData *td, int mint_op)
-{
-       int type1 = td->sp [-2].type;
-       int type2 = td->sp [-1].type;
-       int op;
-#if SIZEOF_VOID_P == 8
-       if ((type1 == STACK_TYPE_MP || type1 == STACK_TYPE_I8) && type2 == STACK_TYPE_I4) {
-               ADD_CODE(td, MINT_CONV_I8_I4);
-               type2 = STACK_TYPE_I8;
-       }
-       if (type1 == STACK_TYPE_I4 && (type2 == STACK_TYPE_MP || type2 == STACK_TYPE_I8)) {
-               ADD_CODE(td, MINT_CONV_I8_I4_SP);
-               type1 = STACK_TYPE_I8;
-               td->sp [-2].type = STACK_TYPE_I8;
-       }
-#endif
-       if (type1 == STACK_TYPE_MP)
-               type1 = STACK_TYPE_I;
-       if (type2 == STACK_TYPE_MP)
-               type2 = STACK_TYPE_I;
-       if (type1 != type2) {
-               g_warning("%s.%s: %04x arith type mismatch %s %d %d", 
-                       td->method->klass->name, td->method->name, 
-                       td->ip - td->il_code, mono_interp_opname[mint_op], type1, type2);
-       }
-       op = mint_op + type1 - STACK_TYPE_I4;
-       CHECK_STACK(td, 2);
-       ADD_CODE(td, op);
-       --td->sp;
-}
-
-static void
-binary_int_op(TransformData *td, int mint_op)
-{
-       int op = mint_op + td->sp [-1].type - STACK_TYPE_I4;
-       CHECK_STACK(td, 2);
-       if (td->sp [-1].type != td->sp [-2].type)
-               g_warning("%s.%s: int type mismatch", td->method->klass->name, td->method->name);
-       ADD_CODE(td, op);
-       --td->sp;
-}
-
-static void
-shift_op(TransformData *td, int mint_op)
-{
-       int op = mint_op + td->sp [-2].type - STACK_TYPE_I4;
-       CHECK_STACK(td, 2);
-       if (td->sp [-1].type != STACK_TYPE_I4) {
-               g_warning("%s.%s: shift type mismatch %d", 
-                       td->method->klass->name, td->method->name,
-                       td->sp [-2].type);
-       }
-       ADD_CODE(td, op);
-       --td->sp;
-}
-
-static int 
-mint_type(MonoType *type)
-{
-       if (type->byref)
-               return MINT_TYPE_P;
-enum_type:
-       switch (type->type) {
-       case MONO_TYPE_I1:
-               return MINT_TYPE_I1;
-       case MONO_TYPE_U1:
-       case MONO_TYPE_BOOLEAN:
-               return MINT_TYPE_U1;
-       case MONO_TYPE_I2:
-               return MINT_TYPE_I2;
-       case MONO_TYPE_U2:
-       case MONO_TYPE_CHAR:
-               return MINT_TYPE_U2;
-       case MONO_TYPE_I4:
-       case MONO_TYPE_U4:
-               return MINT_TYPE_I4;
-       case MONO_TYPE_I:
-       case MONO_TYPE_U:
-#if SIZEOF_VOID_P == 4
-               return MINT_TYPE_I4;
-#else
-               return MINT_TYPE_I8;
-#endif
-       case MONO_TYPE_PTR:
-               return MINT_TYPE_P;
-       case MONO_TYPE_R4:
-               return MINT_TYPE_R4;
-       case MONO_TYPE_I8:
-       case MONO_TYPE_U8:
-               return MINT_TYPE_I8;
-       case MONO_TYPE_R8:
-               return MINT_TYPE_R8;
-       case MONO_TYPE_STRING:
-       case MONO_TYPE_SZARRAY:
-       case MONO_TYPE_CLASS:
-       case MONO_TYPE_OBJECT:
-       case MONO_TYPE_ARRAY:
-               return MINT_TYPE_O;
-       case MONO_TYPE_VALUETYPE:
-               if (type->data.klass->enumtype) {
-                       type = mono_class_enum_basetype (type->data.klass);
-                       goto enum_type;
-               } else
-                       return MINT_TYPE_VT;
-       case MONO_TYPE_GENERICINST:
-               type = &type->data.generic_class->container_class->byval_arg;
-               goto enum_type;
-       default:
-               g_warning ("got type 0x%02x", type->type);
-               g_assert_not_reached ();
-       }
-       return -1;
-}
-
-static int 
-can_store (int stack_type, int var_type)
-{
-       if (stack_type == STACK_TYPE_O || stack_type == STACK_TYPE_MP)
-               stack_type = STACK_TYPE_I;
-       if (var_type == STACK_TYPE_O || var_type == STACK_TYPE_MP)
-               var_type = STACK_TYPE_I;
-       return stack_type == var_type;
-}
-
-#define SET_SIMPLE_TYPE(s, ty) \
-       do { \
-               (s)->type = (ty); \
-               (s)->flags = 0; \
-               (s)->klass = NULL; \
-       } while (0)
-
-#define SET_TYPE(s, ty, k) \
-       do { \
-               (s)->type = (ty); \
-               (s)->flags = 0; \
-               (s)->klass = k; \
-       } while (0)
-
-#define PUSH_SIMPLE_TYPE(td, ty) \
-       do { \
-               int sp_height; \
-               (td)->sp++; \
-               sp_height = (td)->sp - (td)->stack; \
-               if (sp_height > (td)->max_stack_height) \
-                       (td)->max_stack_height = sp_height; \
-               SET_SIMPLE_TYPE((td)->sp - 1, ty); \
-       } while (0)
-
-#define PUSH_TYPE(td, ty, k) \
-       do { \
-               int sp_height; \
-               (td)->sp++; \
-               sp_height = (td)->sp - (td)->stack; \
-               if (sp_height > (td)->max_stack_height) \
-                       (td)->max_stack_height = sp_height; \
-               SET_TYPE((td)->sp - 1, ty, k); \
-       } while (0)
-
-#define PUSH_VT(td, size) \
-       do { \
-               (td)->vt_sp += ((size) + 7) & ~7; \
-               if ((td)->vt_sp > (td)->max_vt_sp) \
-                       (td)->max_vt_sp = (td)->vt_sp; \
-       } while (0)
-
-#define POP_VT(td, size) \
-       do { \
-               (td)->vt_sp -= ((size) + 7) & ~7; \
-       } while (0)
-
-#if NO_UNALIGNED_ACCESS
-#define WRITE32(td, v) \
-       do { \
-               ENSURE_CODE(td, 2); \
-               * (guint16 *)((td)->new_ip) = * (guint16 *)(v); \
-               * ((guint16 *)((td)->new_ip) + 1) = * ((guint16 *)(v) + 1); \
-               (td)->new_ip += 2; \
-       } while (0)
-
-#define WRITE64(td, v) \
-       do { \
-               ENSURE_CODE(td, 4); \
-               * (guint16 *)((td)->new_ip) = * (guint16 *)(v); \
-               * ((guint16 *)((td)->new_ip) + 1) = * ((guint16 *)(v) + 1); \
-               * ((guint16 *)((td)->new_ip) + 2) = * ((guint16 *)(v) + 2); \
-               * ((guint16 *)((td)->new_ip) + 3) = * ((guint16 *)(v) + 3); \
-               (td)->new_ip += 4; \
-       } while (0)
-#else
-#define WRITE32(td, v) \
-       do { \
-               ENSURE_CODE(td, 2); \
-               * (guint32 *)((td)->new_ip) = * (guint32 *)(v); \
-               (td)->new_ip += 2; \
-       } while (0)
-
-#define WRITE64(td, v) \
-       do { \
-               ENSURE_CODE(td, 4); \
-               * (guint64 *)((td)->new_ip) = * (guint64 *)(v); \
-               (td)->new_ip += 4; \
-       } while (0)
-
-#endif
-
-static void 
-load_arg(TransformData *td, int n)
-{
-       int mt;
-       MonoClass *klass = NULL;
-       MonoType *type;
-
-       gboolean hasthis = mono_method_signature (td->method)->hasthis;
-       if (hasthis && n == 0)
-               type = &td->method->klass->byval_arg;
-       else
-               type = mono_method_signature (td->method)->params [hasthis ? n - 1 : n];
-
-       mt = mint_type (type);
-       if (mt == MINT_TYPE_VT) {
-               gint32 size;
-               klass = mono_class_from_mono_type (type);
-               if (mono_method_signature (td->method)->pinvoke)
-                       size = mono_class_native_size (klass, NULL);
-               else
-                       size = mono_class_value_size (klass, NULL);
-
-               if (hasthis && n == 0) {
-                       mt = MINT_TYPE_P;
-                       ADD_CODE (td, MINT_LDARG_P);
-                       ADD_CODE (td, td->rtm->arg_offsets [n]); /* FIX for large offset */
-                       klass = NULL;
-               } else {
-                       PUSH_VT (td, size);
-                       ADD_CODE (td, MINT_LDARG_VT);
-                       ADD_CODE (td, td->rtm->arg_offsets [n]); /* FIX for large offset */
-                       WRITE32 (td, &size);
-               }
-       } else {
-               if (hasthis && n == 0) {
-                       mt = MINT_TYPE_P;
-                       ADD_CODE (td, MINT_LDARG_P);
-                       ADD_CODE (td, td->rtm->arg_offsets [n]); /* FIX for large offset */
-                       klass = NULL;
-               } else {
-                       ADD_CODE(td, MINT_LDARG_I1 + (mt - MINT_TYPE_I1));
-                       ADD_CODE(td, td->rtm->arg_offsets [n]); /* FIX for large offset */
-                       if (mt == MINT_TYPE_O)
-                               klass = mono_class_from_mono_type (type);
-               }
-       }
-       PUSH_TYPE(td, stack_type[mt], klass);
-}
-
-static void 
-store_arg(TransformData *td, int n)
-{
-       int mt;
-       CHECK_STACK (td, 1);
-       MonoType *type;
-
-       gboolean hasthis = mono_method_signature (td->method)->hasthis;
-       if (hasthis && n == 0)
-               type = &td->method->klass->byval_arg;
-       else
-               type = mono_method_signature (td->method)->params [n - !!hasthis];
-
-       mt = mint_type (type);
-       if (mt == MINT_TYPE_VT) {
-               gint32 size;
-               g_error ("data.klass");
-               if (mono_method_signature (td->method)->pinvoke)
-                       size = mono_class_native_size (type->data.klass, NULL);
-               else
-                       size = mono_class_value_size (type->data.klass, NULL);
-               ADD_CODE(td, MINT_STARG_VT);
-               ADD_CODE(td, n);
-               WRITE32(td, &size);
-               if (td->sp [-1].type == STACK_TYPE_VT)
-                       POP_VT(td, size);
-       } else {
-               ADD_CODE(td, MINT_STARG_I1 + (mt - MINT_TYPE_I1));
-               ADD_CODE(td, td->rtm->arg_offsets [n]);
-       }
-       --td->sp;
-}
-
-static void 
-store_inarg(TransformData *td, int n)
-{
-       MonoType *type;
-       gboolean hasthis = mono_method_signature (td->method)->hasthis;
-       if (hasthis && n == 0)
-               type = &td->method->klass->byval_arg;
-       else
-               type = mono_method_signature (td->method)->params [n - !!hasthis];
-
-       int mt = mint_type (type);
-       if (hasthis && n == 0) {
-               ADD_CODE (td, MINT_STINARG_P);
-               ADD_CODE (td, n);
-               return;
-       }
-       if (mt == MINT_TYPE_VT) {
-               MonoClass *klass = mono_class_from_mono_type (type);
-               gint32 size;
-               if (mono_method_signature (td->method)->pinvoke)
-                       size = mono_class_native_size (klass, NULL);
-               else
-                       size = mono_class_value_size (klass, NULL);
-               ADD_CODE(td, MINT_STINARG_VT);
-               ADD_CODE(td, n);
-               WRITE32(td, &size);
-       } else {
-               ADD_CODE(td, MINT_STINARG_I1 + (mt - MINT_TYPE_I1));
-               ADD_CODE(td, n);
-       }
-}
-
-static void 
-load_local(TransformData *td, int n)
-{
-       MonoType *type = td->header->locals [n];
-       int mt = mint_type (type);
-       int offset = td->rtm->local_offsets [n];
-       MonoClass *klass = NULL;
-       if (mt == MINT_TYPE_VT) {
-               klass = mono_class_from_mono_type (type);
-               gint32 size = mono_class_value_size (klass, NULL);
-               PUSH_VT(td, size);
-               ADD_CODE(td, MINT_LDLOC_VT);
-               ADD_CODE(td, offset); /*FIX for large offset */
-               WRITE32(td, &size);
-       } else {
-               g_assert (mt < MINT_TYPE_VT);
-               if (mt == MINT_TYPE_I4 && !td->is_bb_start [td->in_start - td->il_code] && td->last_new_ip != NULL &&
-                       td->last_new_ip [0] == MINT_STLOC_I4 && td->last_new_ip [1] == offset) {
-                       td->last_new_ip [0] = MINT_STLOC_NP_I4;
-               } else if (mt == MINT_TYPE_O && !td->is_bb_start [td->in_start - td->il_code] && td->last_new_ip != NULL &&
-                       td->last_new_ip [0] == MINT_STLOC_O && td->last_new_ip [1] == offset) {
-                       td->last_new_ip [0] = MINT_STLOC_NP_O;
-               } else {
-                       ADD_CODE(td, MINT_LDLOC_I1 + (mt - MINT_TYPE_I1));
-                       ADD_CODE(td, offset); /*FIX for large offset */
-               }
-               if (mt == MINT_TYPE_O)
-                       klass = mono_class_from_mono_type (type);
-       }
-       PUSH_TYPE(td, stack_type[mt], klass);
-}
-
-static void 
-store_local(TransformData *td, int n)
-{
-       MonoType *type = td->header->locals [n];
-       int mt = mint_type (type);
-       int offset = td->rtm->local_offsets [n];
-       CHECK_STACK (td, 1);
-#if SIZEOF_VOID_P == 8
-       if (td->sp [-1].type == STACK_TYPE_I4 && stack_type [mt] == STACK_TYPE_I8) {
-               ADD_CODE(td, MINT_CONV_I8_I4);
-               td->sp [-1].type = STACK_TYPE_I8;
-       }
-#endif
-       if (!can_store(td->sp [-1].type, stack_type [mt])) {
-               g_warning("%s.%s: Store local stack type mismatch %d %d", 
-                       td->method->klass->name, td->method->name,
-                       stack_type [mt], td->sp [-1].type);
-       }
-       if (mt == MINT_TYPE_VT) {
-               MonoClass *klass = mono_class_from_mono_type (type);
-               gint32 size = mono_class_value_size (klass, NULL);
-               ADD_CODE(td, MINT_STLOC_VT);
-               ADD_CODE(td, offset); /*FIX for large offset */
-               WRITE32(td, &size);
-               if (td->sp [-1].type == STACK_TYPE_VT)
-                       POP_VT(td, size);
-       } else {
-               g_assert (mt < MINT_TYPE_VT);
-               ADD_CODE(td, MINT_STLOC_I1 + (mt - MINT_TYPE_I1));
-               ADD_CODE(td, offset); /*FIX for large offset */
-       }
-       --td->sp;
-}
-
-#define SIMPLE_OP(td, op) \
-       do { \
-               ADD_CODE(&td, op); \
-               ++td.ip; \
-       } while (0)
-
-static guint16
-get_data_item_index (TransformData *td, void *ptr)
-{
-       gpointer p = g_hash_table_lookup (td->data_hash, ptr);
-       guint index;
-       if (p != NULL)
-               return GPOINTER_TO_UINT (p) - 1;
-       if (td->max_data_items == td->n_data_items) {
-               td->max_data_items = td->n_data_items == 0 ? 16 : 2 * td->max_data_items;
-               td->data_items = g_realloc (td->data_items, td->max_data_items * sizeof(td->data_items [0]));
-       }
-       index = td->n_data_items;
-       td->data_items [index] = ptr;
-       ++td->n_data_items;
-       g_hash_table_insert (td->data_hash, ptr, GUINT_TO_POINTER (index + 1));
-       return index;
-}
-
-static void
-interp_transform_call (TransformData *td, MonoMethod *method, MonoMethod *target_method, MonoDomain *domain, MonoGenericContext *generic_context, unsigned char *is_bb_start, int body_start_offset, MonoClass *constrained_class)
-{
-       MonoImage *image = method->klass->image;
-       MonoMethodSignature *csignature;
-       MonoError error;
-       int virtual = *td->ip == CEE_CALLVIRT;
-       int calli = *td->ip == CEE_CALLI || *td->ip == CEE_MONO_CALLI_EXTRA_ARG;
-       int i;
-       guint32 vt_stack_used = 0;
-       guint32 vt_res_size = 0;
-       int op = -1;
-       int native = 0;
-       int is_void = 0;
-
-       guint32 token = read32 (td->ip + 1);
-
-       if (target_method == NULL) {
-               if (calli) {
-                       CHECK_STACK(td, 1);
-                       native = (method->wrapper_type != MONO_WRAPPER_DELEGATE_INVOKE && td->sp [-1].type == STACK_TYPE_I);
-                       --td->sp;
-                       if (method->wrapper_type != MONO_WRAPPER_NONE)
-                               csignature = (MonoMethodSignature *)mono_method_get_wrapper_data (method, token);
-                       else
-                               csignature = mono_metadata_parse_signature (image, token);
-                       target_method = NULL;
-               } else {
-                       if (method->wrapper_type == MONO_WRAPPER_NONE)
-                               target_method = mono_get_method_full (image, token, NULL, generic_context);
-                       else
-                               target_method = (MonoMethod *)mono_method_get_wrapper_data (method, token);
-                       csignature = mono_method_signature (target_method);
-                       if (target_method->klass == mono_defaults.string_class) {
-                               if (target_method->name [0] == 'g') {
-                                       if (strcmp (target_method->name, "get_Chars") == 0)
-                                               op = MINT_GETCHR;
-                                       else if (strcmp (target_method->name, "get_Length") == 0)
-                                               op = MINT_STRLEN;
-                               }
-                       } else if (target_method->klass == mono_defaults.array_class) {
-                               if (strcmp (target_method->name, "get_Rank") == 0)
-                                       op = MINT_ARRAY_RANK;
-                               else if (strcmp (target_method->name, "get_Length") == 0)
-                                       op = MINT_LDLEN;
-                       }
-               }
-       } else {
-               csignature = mono_method_signature (target_method);
-       }
-
-       if (constrained_class) {
-               if (constrained_class->enumtype && !strcmp (target_method->name, "GetHashCode")) {
-                       /* Use the corresponding method from the base type to avoid boxing */
-                       MonoType *base_type = mono_class_enum_basetype (constrained_class);
-                       g_assert (base_type);
-                       constrained_class = mono_class_from_mono_type (base_type);
-                       target_method = mono_class_get_method_from_name (constrained_class, target_method->name, 0);
-                       g_assert (target_method);
-               }
-       }
-
-       if (constrained_class) {
-               mono_class_setup_vtable (constrained_class);
-#if DEBUG_INTERP
-               g_print ("CONSTRAINED.CALLVIRT: %s::%s.  %s (%p) ->\n", target_method->klass->name, target_method->name, mono_signature_full_name (target_method->signature), target_method);
-#endif
-               target_method = mono_get_method_constrained_with_method (image, target_method, constrained_class, generic_context, &error);
-#if DEBUG_INTERP
-               g_print ("                    : %s::%s.  %s (%p)\n", target_method->klass->name, target_method->name, mono_signature_full_name (target_method->signature), target_method);
-#endif
-               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-               mono_class_setup_vtable (target_method->klass);
-
-               if (constrained_class->valuetype && (target_method->klass == mono_defaults.object_class || target_method->klass == mono_defaults.enum_class->parent || target_method->klass == mono_defaults.enum_class)) {
-                       ADD_CODE (td, MINT_BOX);
-                       ADD_CODE (td, get_data_item_index (td, constrained_class));
-                       ADD_CODE (td, csignature->param_count);
-               } else if (!constrained_class->valuetype) {
-                       /* managed pointer on the stack, we need to deref that puppy */
-                       ADD_CODE (td, MINT_LDIND_I);
-                       ADD_CODE (td, csignature->param_count);
-               } else {
-                       g_assert (target_method->klass->valuetype);
-                       virtual = FALSE;
-               }
-       }
-
-       if (target_method)
-               mono_class_init (target_method->klass);
-
-       CHECK_STACK (td, csignature->param_count + csignature->hasthis);
-       if (!calli && (!virtual || (target_method->flags & METHOD_ATTRIBUTE_VIRTUAL) == 0) &&
-               (target_method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) == 0 && 
-               (target_method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) == 0) {
-               int called_inited = mono_class_vtable (domain, target_method->klass)->initialized;
-               MonoMethodHeader *mheader = mono_method_get_header (target_method);
-
-               if (/*mono_metadata_signature_equal (method->signature, target_method->signature) */ method == target_method && *(td->ip + 5) == CEE_RET) {
-                       int offset;
-                       if (mono_interp_traceopt)
-                               g_print ("Optimize tail call of %s.%s\n", target_method->klass->name, target_method->name);
-                       for (i = csignature->param_count - 1; i >= 0; --i)
-                               store_arg (td, i + csignature->hasthis);
-
-                       if (csignature->hasthis) {
-                               g_error ("STTHIS removal");
-                               // ADD_CODE(td, MINT_STTHIS);
-                               --td->sp;
-                       }
-                       ADD_CODE(td, MINT_BR_S);
-                       offset = body_start_offset - ((td->new_ip - 1) - td->new_code);
-                       ADD_CODE(td, offset);
-                       if (!is_bb_start [td->ip + 5 - td->il_code])
-                               ++td->ip; /* gobble the CEE_RET if it isn't branched to */                              
-                       td->ip += 5;
-                       return;
-               } else {
-                       /* mheader might not exist if this is a delegate invoc, etc */
-                       if (mheader && *mheader->code == CEE_RET && called_inited) {
-                               if (mono_interp_traceopt)
-                                       g_print ("Inline (empty) call of %s.%s\n", target_method->klass->name, target_method->name);
-                               for (i = 0; i < csignature->param_count; i++)
-                                       ADD_CODE(td, MINT_POP); /*FIX: vt */
-                               if (csignature->hasthis) {
-                                       if (virtual)
-                                               ADD_CODE(td, MINT_CKNULL);
-                                       ADD_CODE(td, MINT_POP);
-                               }
-                               td->sp -= csignature->param_count + csignature->hasthis;
-                               td->ip += 5;
-                               return;
-                       }
-               }
-       }
-       if (method->wrapper_type == MONO_WRAPPER_NONE && target_method != NULL) {
-               if (target_method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
-                       target_method = mono_marshal_get_native_wrapper (target_method, FALSE, FALSE);
-               if (!virtual && target_method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
-                       target_method = mono_marshal_get_synchronized_wrapper (target_method);
-       }
-       g_assert (csignature->call_convention == MONO_CALL_DEFAULT || csignature->call_convention == MONO_CALL_C);
-       td->sp -= csignature->param_count + !!csignature->hasthis;
-       for (i = 0; i < csignature->param_count; ++i) {
-               if (td->sp [i + !!csignature->hasthis].type == STACK_TYPE_VT) {
-                       gint32 size;
-                       MonoClass *klass = mono_class_from_mono_type (csignature->params [i]);
-                       if (csignature->pinvoke && method->wrapper_type != MONO_WRAPPER_NONE)
-                               size = mono_class_native_size (klass, NULL);
-                       else
-                               size = mono_class_value_size (klass, NULL);
-                       size = (size + 7) & ~7;
-                       vt_stack_used += size;
-               }
-       }
-
-       /* need to handle typedbyref ... */
-       if (csignature->ret->type != MONO_TYPE_VOID) {
-               int mt = mint_type(csignature->ret);
-               MonoClass *klass = mono_class_from_mono_type (csignature->ret);
-               if (mt == MINT_TYPE_VT) {
-                       if (csignature->pinvoke && method->wrapper_type != MONO_WRAPPER_NONE)
-                               vt_res_size = mono_class_native_size (klass, NULL);
-                       else
-                               vt_res_size = mono_class_value_size (klass, NULL);
-                       PUSH_VT(td, vt_res_size);
-               }
-               PUSH_TYPE(td, stack_type[mt], klass);
-       } else
-               is_void = TRUE;
-
-       if (op >= 0) {
-               ADD_CODE(td, op);
-#if SIZEOF_VOID_P == 8
-               if (op == MINT_LDLEN)
-                       ADD_CODE(td, MINT_CONV_I4_I8);
-#endif
-       } else {
-               if (calli)
-                       ADD_CODE(td, native ? MINT_CALLI_NAT : MINT_CALLI);
-               else if (virtual)
-                       ADD_CODE(td, is_void ? MINT_VCALLVIRT : MINT_CALLVIRT);
-               else
-                       ADD_CODE(td, is_void ? MINT_VCALL : MINT_CALL);
-               
-               if (calli) {
-                       ADD_CODE(td, get_data_item_index (td, (void *)csignature));
-               } else {
-                       ADD_CODE(td, get_data_item_index (td, (void *)mono_interp_get_runtime_method (domain, target_method, &error)));
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-               }
-       }
-       td->ip += 5;
-       if (vt_stack_used != 0 || vt_res_size != 0) {
-               ADD_CODE(td, MINT_VTRESULT);
-               ADD_CODE(td, vt_res_size);
-               WRITE32(td, &vt_stack_used);
-               td->vt_sp -= vt_stack_used;
-       }
-}
-
-static void
-generate (MonoMethod *method, RuntimeMethod *rtm, unsigned char *is_bb_start)
-{
-       MonoMethodHeader *header = mono_method_get_header (method);
-       MonoMethodSignature *signature = mono_method_signature (method);
-       MonoImage *image = method->klass->image;
-       MonoDomain *domain = mono_domain_get ();
-       MonoGenericContext *generic_context = NULL;
-       MonoClass *constrained_class = NULL;
-       MonoError error;
-       int offset, mt;
-       int i;
-       int i32;
-       MonoClass *klass;
-       MonoClassField *field;
-       const unsigned char *end;
-       int new_in_start_offset;
-       int body_start_offset;
-       int target;
-       guint32 token;
-       TransformData td;
-       int generating_code = 1;
-
-       if (mono_method_signature (method)->is_inflated)
-               generic_context = &((MonoMethodInflated *) method)->context;
-
-       memset(&td, 0, sizeof(td));
-       td.method = method;
-       td.rtm = rtm;
-       td.is_bb_start = is_bb_start;
-       td.il_code = header->code;
-       td.code_size = header->code_size;
-       td.header = header;
-       td.max_code_size = td.code_size;
-       td.new_code = (unsigned short *)g_malloc(td.max_code_size * sizeof(gushort));
-       td.new_code_end = td.new_code + td.max_code_size;
-       td.in_offsets = g_malloc0(header->code_size * sizeof(int));
-       td.forward_refs = g_malloc(header->code_size * sizeof(int));
-       td.stack_state = g_malloc0(header->code_size * sizeof(StackInfo *));
-       td.stack_height = g_malloc(header->code_size * sizeof(int));
-       td.vt_stack_size = g_malloc(header->code_size * sizeof(int));
-       td.n_data_items = 0;
-       td.max_data_items = 0;
-       td.data_items = NULL;
-       td.data_hash = g_hash_table_new (NULL, NULL);
-       rtm->data_items = td.data_items;
-       for (i = 0; i < header->code_size; i++) {
-               td.forward_refs [i] = -1;
-               td.stack_height [i] = -1;
-       }
-       td.new_ip = td.new_code;
-       td.last_new_ip = NULL;
-
-       td.stack = g_malloc0(header->max_stack * sizeof(td.stack[0]));
-       td.sp = td.stack;
-       td.max_stack_height = 0;
-
-       for (i = 0; i < header->num_clauses; i++) {
-               MonoExceptionClause *c = header->clauses + i;
-               td.stack_height [c->handler_offset] = 0;
-               td.vt_stack_size [c->handler_offset] = 0;
-               td.is_bb_start [c->handler_offset] = 1;
-               if (c->flags == MONO_EXCEPTION_CLAUSE_NONE) {
-                       td.stack_height [c->handler_offset] = 1;
-                       td.stack_state [c->handler_offset] = g_malloc0(sizeof(StackInfo));
-                       td.stack_state [c->handler_offset][0].type = STACK_TYPE_O;
-                       td.stack_state [c->handler_offset][0].klass = NULL; /*FIX*/
-               }
-       }
-
-       td.ip = header->code;
-       end = td.ip + header->code_size;
-
-       if (mono_interp_traceopt) {
-               char *tmp = mono_disasm_code (NULL, method, td.ip, end);
-               char *name = mono_method_full_name (method, TRUE);
-               g_print ("Method %s, original code:\n", name);
-               g_print ("%s\n", tmp);
-               g_free (tmp);
-               g_free (name);
-       }
-
-       if (signature->hasthis)
-               store_inarg (&td, 0);
-       for (i = 0; i < signature->param_count; i++)
-               store_inarg (&td, i + !!signature->hasthis);
-
-       body_start_offset = td.new_ip - td.new_code;
-
-       for (i = 0; i < header->num_locals; i++) {
-               int mt = mint_type(header->locals [i]);
-               if (mt == MINT_TYPE_VT || mt == MINT_TYPE_O) {
-                       ADD_CODE(&td, MINT_INITLOCALS);
-                       break;
-               }
-       }
-
-       while (td.ip < end) {
-               int in_offset;
-
-               g_assert (td.sp >= td.stack);
-               g_assert (td.vt_sp < 0x10000000);
-               in_offset = td.ip - header->code;
-               td.in_offsets [in_offset] = td.new_ip - td.new_code;
-               new_in_start_offset = td.new_ip - td.new_code;
-               td.in_start = td.ip;
-               while (td.forward_refs [in_offset] >= 0) {
-                       int j = td.forward_refs [in_offset];
-                       int slot;
-                       td.forward_refs [in_offset] = td.forward_refs [j];
-                       if (td.in_offsets [j] < 0) {                        
-                               int old_switch_offset = -td.in_offsets [j];
-                               int new_switch_offset = td.in_offsets [old_switch_offset];
-                               int switch_case = (j - old_switch_offset - 5) / 4;
-                               int n_cases = read32 (header->code + old_switch_offset + 1);
-                               offset = (td.new_ip - td.new_code) - (new_switch_offset + 2 * n_cases + 3);
-                               slot = new_switch_offset + 3 + 2 * switch_case;
-                               td.new_code [slot] = * (unsigned short *)(&offset);
-                               td.new_code [slot + 1] = * ((unsigned short *)&offset + 1);
-                       } else {
-                               int op = td.new_code [td.in_offsets [j]];
-                               if (mono_interp_opargtype [op] == MintOpShortBranch) {
-                                       offset = (td.new_ip - td.new_code) - td.in_offsets [j];
-                                       g_assert (offset <= 32767);
-                                       slot = td.in_offsets [j] + 1;
-                                       td.new_code [slot] = offset;
-                               } else {
-                                       offset = (td.new_ip - td.new_code) - td.in_offsets [j];
-                                       slot = td.in_offsets [j] + 1;
-                                       td.new_code [slot] = * (unsigned short *)(&offset);
-                                       td.new_code [slot + 1] = * ((unsigned short *)&offset + 1);
-                               }
-                       }
-               }
-               if (td.stack_height [in_offset] >= 0) {
-                       g_assert (is_bb_start [in_offset]);
-                       if (td.stack_height [in_offset] > 0)
-                               memcpy (td.stack, td.stack_state [in_offset], td.stack_height [in_offset] * sizeof(td.stack [0]));
-                       td.sp = td.stack + td.stack_height [in_offset];
-                       td.vt_sp = td.vt_stack_size [in_offset];
-               }
-               if (is_bb_start [in_offset]) {
-                       generating_code = 1;
-               }
-               if (!generating_code) {
-                       while (td.ip < end && !is_bb_start [td.ip - td.il_code])
-                               ++td.ip;
-                       continue;
-               }
-               if (mono_interp_traceopt > 1) {
-                       printf("IL_%04lx %s %-10s -> IL_%04lx, sp %ld, %s %-12s vt_sp %u (max %u)\n", 
-                               td.ip - td.il_code,
-                               td.is_bb_start [td.ip - td.il_code] == 3 ? "<>" :
-                               td.is_bb_start [td.ip - td.il_code] == 2 ? "< " :
-                               td.is_bb_start [td.ip - td.il_code] == 1 ? " >" : "  ",
-                               mono_opcode_name (*td.ip), td.new_ip - td.new_code, td.sp - td.stack, 
-                               td.sp > td.stack ? stack_type_string [td.sp [-1].type] : "  ",
-                               (td.sp > td.stack && (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_VT)) ? (td.sp [-1].klass == NULL ? "?" : td.sp [-1].klass->name) : "",
-                               td.vt_sp, td.max_vt_sp);
-               }
-               switch (*td.ip) {
-               case CEE_NOP: 
-                       /* lose it */
-                       ++td.ip;
-                       break;
-               case CEE_BREAK:
-                       SIMPLE_OP(td, MINT_BREAK);
-                       break;
-               case CEE_LDARG_0:
-               case CEE_LDARG_1:
-               case CEE_LDARG_2:
-               case CEE_LDARG_3:
-                       load_arg (&td, *td.ip - CEE_LDARG_0);
-                       ++td.ip;
-                       break;
-               case CEE_LDLOC_0:
-               case CEE_LDLOC_1:
-               case CEE_LDLOC_2:
-               case CEE_LDLOC_3:
-                       load_local (&td, *td.ip - CEE_LDLOC_0);
-                       ++td.ip;
-                       break;
-               case CEE_STLOC_0:
-               case CEE_STLOC_1:
-               case CEE_STLOC_2:
-               case CEE_STLOC_3:
-                       store_local (&td, *td.ip - CEE_STLOC_0);
-                       ++td.ip;
-                       break;
-               case CEE_LDARG_S:
-                       load_arg (&td, ((guint8 *)td.ip)[1]);
-                       td.ip += 2;
-                       break;
-               case CEE_LDARGA_S: {
-                       /* NOTE: n includes this */
-                       int n = ((guint8 *)td.ip)[1];
-                       if (n == 0 && signature->hasthis) {
-                               g_error ("LDTHISA: NOPE");
-                               ADD_CODE(&td, MINT_LDTHISA);
-                       }
-                       else {
-                               ADD_CODE(&td, MINT_LDARGA);
-                               ADD_CODE(&td, td.rtm->arg_offsets [n]);
-                       }
-                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_MP);
-                       td.ip += 2;
-                       break;
-               }
-               case CEE_STARG_S:
-                       store_arg (&td, ((guint8 *)td.ip)[1]);
-                       td.ip += 2;
-                       break;
-               case CEE_LDLOC_S:
-                       load_local (&td, ((guint8 *)td.ip)[1]);
-                       td.ip += 2;
-                       break;
-               case CEE_LDLOCA_S:
-                       ADD_CODE(&td, MINT_LDLOCA_S);
-                       ADD_CODE(&td, td.rtm->local_offsets [((guint8 *)td.ip)[1]]);
-                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_MP);
-                       td.ip += 2;
-                       break;
-               case CEE_STLOC_S:
-                       store_local (&td, ((guint8 *)td.ip)[1]);
-                       td.ip += 2;
-                       break;
-               case CEE_LDNULL: 
-                       SIMPLE_OP(td, MINT_LDNULL);
-                       PUSH_TYPE(&td, STACK_TYPE_O, NULL);
-                       break;
-               case CEE_LDC_I4_M1:
-                       SIMPLE_OP(td, MINT_LDC_I4_M1);
-                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
-                       break;
-               case CEE_LDC_I4_0:
-                       if (!td.is_bb_start[td.ip + 1 - td.il_code] && td.ip [1] == 0xfe && td.ip [2] == CEE_CEQ && 
-                               td.sp > td.stack && td.sp [-1].type == STACK_TYPE_I4) {
-                               SIMPLE_OP(td, MINT_CEQ0_I4);
-                               td.ip += 2;
-                       } else {
-                               SIMPLE_OP(td, MINT_LDC_I4_0);
-                               PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
-                       }
-                       break;
-               case CEE_LDC_I4_1:
-                       if (!td.is_bb_start[td.ip + 1 - td.il_code] && 
-                               (td.ip [1] == CEE_ADD || td.ip [1] == CEE_SUB) && td.sp [-1].type == STACK_TYPE_I4) {
-                               ADD_CODE(&td, td.ip [1] == CEE_ADD ? MINT_ADD1_I4 : MINT_SUB1_I4);
-                               td.ip += 2;
-                       } else {
-                               SIMPLE_OP(td, MINT_LDC_I4_1);
-                               PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
-                       }
-                       break;
-               case CEE_LDC_I4_2:
-               case CEE_LDC_I4_3:
-               case CEE_LDC_I4_4:
-               case CEE_LDC_I4_5:
-               case CEE_LDC_I4_6:
-               case CEE_LDC_I4_7:
-               case CEE_LDC_I4_8:
-                       SIMPLE_OP(td, (*td.ip - CEE_LDC_I4_0) + MINT_LDC_I4_0);
-                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
-                       break;
-               case CEE_LDC_I4_S: 
-                       ADD_CODE(&td, MINT_LDC_I4_S);
-                       ADD_CODE(&td, ((gint8 *) td.ip) [1]);
-                       td.ip += 2;
-                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
-                       break;
-               case CEE_LDC_I4:
-                       i32 = read32 (td.ip + 1);
-                       ADD_CODE(&td, MINT_LDC_I4);
-                       WRITE32(&td, &i32);
-                       td.ip += 5;
-                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
-                       break;
-               case CEE_LDC_I8: {
-                       gint64 val = read64 (td.ip + 1);
-                       ADD_CODE(&td, MINT_LDC_I8);
-                       WRITE64(&td, &val);
-                       td.ip += 9;
-                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I8);
-                       break;
-               }
-               case CEE_LDC_R4: {
-                       float val;
-                       readr4 (td.ip + 1, &val);
-                       ADD_CODE(&td, MINT_LDC_R4);
-                       WRITE32(&td, &val);
-                       td.ip += 5;
-                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_R8);
-                       break;
-               }
-               case CEE_LDC_R8: {
-                       double val;
-                       readr8 (td.ip + 1, &val);
-                       ADD_CODE(&td, MINT_LDC_R8);
-                       WRITE64(&td, &val);
-                       td.ip += 9;
-                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_R8);
-                       break;
-               }
-               case CEE_DUP: {
-                       int type = td.sp [-1].type;
-                       MonoClass *klass = td.sp [-1].klass;
-                       if (td.sp [-1].type == STACK_TYPE_VT) {
-                               gint32 size = mono_class_value_size (klass, NULL);
-                               PUSH_VT(&td, size);
-                               ADD_CODE(&td, MINT_DUP_VT);
-                               WRITE32(&td, &size);
-                               td.ip ++;
-                       } else 
-                               SIMPLE_OP(td, MINT_DUP);
-                       PUSH_TYPE(&td, type, klass);
-                       break;
-               }
-               case CEE_POP:
-                       CHECK_STACK(&td, 1);
-                       SIMPLE_OP(td, MINT_POP);
-                       if (td.sp [-1].type == STACK_TYPE_VT) {
-                               int size = mono_class_value_size (td.sp [-1].klass, NULL);
-                               size = (size + 7) & ~7;
-                               ADD_CODE(&td, MINT_VTRESULT);
-                               ADD_CODE(&td, 0);
-                               WRITE32(&td, &size);
-                               td.vt_sp -= size;
-                       }
-                       --td.sp;
-                       break;
-               case CEE_JMP: {
-                       MonoMethod *m;
-                       if (td.sp > td.stack)
-                               g_warning ("CEE_JMP: stack must be empty");
-                       token = read32 (td.ip + 1);
-                       m = mono_get_method_full (image, token, NULL, generic_context);
-                       ADD_CODE (&td, MINT_JMP);
-                       ADD_CODE (&td, get_data_item_index (&td, mono_interp_get_runtime_method (domain, m, &error)));
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                       td.ip += 5;
-                       break;
-               }
-               case CEE_CALLVIRT: /* Fall through */
-               case CEE_CALLI:    /* Fall through */
-               case CEE_CALL: {
-                       interp_transform_call (&td, method, NULL, domain, generic_context, is_bb_start, body_start_offset, constrained_class);
-                       constrained_class = NULL;
-                       break;
-               }
-               case CEE_RET: {
-                       int vt_size = 0;
-                       if (signature->ret->type != MONO_TYPE_VOID) {
-                               --td.sp;
-                               MonoClass *klass = mono_class_from_mono_type (signature->ret);
-                               if (mint_type (&klass->byval_arg) == MINT_TYPE_VT) {
-                                       vt_size = mono_class_value_size (klass, NULL);
-                                       vt_size = (vt_size + 7) & ~7;
-                               }
-                       }
-                       if (td.sp > td.stack)
-                               g_warning ("%s.%s: CEE_RET: more values on stack: %d", td.method->klass->name, td.method->name, td.sp - td.stack);
-                       if (td.vt_sp != vt_size)
-                               g_error ("%s.%s: CEE_RET: value type stack: %d vs. %d", td.method->klass->name, td.method->name, td.vt_sp, vt_size);
-                       if (vt_size == 0)
-                               SIMPLE_OP(td, signature->ret->type == MONO_TYPE_VOID ? MINT_RET_VOID : MINT_RET);
-                       else {
-                               ADD_CODE(&td, MINT_RET_VT);
-                               WRITE32(&td, &vt_size);
-                               ++td.ip;
-                       }
-                       generating_code = 0;
-                       break;
-               }
-               case CEE_BR:
-                       handle_branch (&td, MINT_BR_S, MINT_BR, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       generating_code = 0;
-                       break;
-               case CEE_BR_S:
-                       handle_branch (&td, MINT_BR_S, MINT_BR, 2 + (gint8)td.ip [1]);
-                       td.ip += 2;
-                       generating_code = 0;
-                       break;
-               case CEE_BRFALSE:
-                       one_arg_branch (&td, MINT_BRFALSE_I4, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       break;
-               case CEE_BRFALSE_S:
-                       one_arg_branch (&td, MINT_BRFALSE_I4, 2 + (gint8)td.ip [1]);
-                       td.ip += 2;
-                       break;
-               case CEE_BRTRUE:
-                       one_arg_branch (&td, MINT_BRTRUE_I4, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       break;
-               case CEE_BRTRUE_S:
-                       one_arg_branch (&td, MINT_BRTRUE_I4, 2 + (gint8)td.ip [1]);
-                       td.ip += 2;
-                       break;
-               case CEE_BEQ:
-                       two_arg_branch (&td, MINT_BEQ_I4, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       break;
-               case CEE_BEQ_S:
-                       two_arg_branch (&td, MINT_BEQ_I4, 2 + (gint8) td.ip [1]);
-                       td.ip += 2;
-                       break;
-               case CEE_BGE:
-                       two_arg_branch (&td, MINT_BGE_I4, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       break;
-               case CEE_BGE_S:
-                       two_arg_branch (&td, MINT_BGE_I4, 2 + (gint8) td.ip [1]);
-                       td.ip += 2;
-                       break;
-               case CEE_BGT:
-                       two_arg_branch (&td, MINT_BGT_I4, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       break;
-               case CEE_BGT_S:
-                       two_arg_branch (&td, MINT_BGT_I4, 2 + (gint8) td.ip [1]);
-                       td.ip += 2;
-                       break;
-               case CEE_BLT:
-                       two_arg_branch (&td, MINT_BLT_I4, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       break;
-               case CEE_BLT_S:
-                       two_arg_branch (&td, MINT_BLT_I4, 2 + (gint8) td.ip [1]);
-                       td.ip += 2;
-                       break;
-               case CEE_BLE:
-                       two_arg_branch (&td, MINT_BLE_I4, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       break;
-               case CEE_BLE_S:
-                       two_arg_branch (&td, MINT_BLE_I4, 2 + (gint8) td.ip [1]);
-                       td.ip += 2;
-                       break;
-               case CEE_BNE_UN:
-                       two_arg_branch (&td, MINT_BNE_UN_I4, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       break;
-               case CEE_BNE_UN_S:
-                       two_arg_branch (&td, MINT_BNE_UN_I4, 2 + (gint8) td.ip [1]);
-                       td.ip += 2;
-                       break;
-               case CEE_BGE_UN:
-                       two_arg_branch (&td, MINT_BGE_UN_I4, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       break;
-               case CEE_BGE_UN_S:
-                       two_arg_branch (&td, MINT_BGE_UN_I4, 2 + (gint8) td.ip [1]);
-                       td.ip += 2;
-                       break;
-               case CEE_BGT_UN:
-                       two_arg_branch (&td, MINT_BGT_UN_I4, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       break;
-               case CEE_BGT_UN_S:
-                       two_arg_branch (&td, MINT_BGT_UN_I4, 2 + (gint8) td.ip [1]);
-                       td.ip += 2;
-                       break;
-               case CEE_BLE_UN:
-                       two_arg_branch (&td, MINT_BLE_UN_I4, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       break;
-               case CEE_BLE_UN_S:
-                       two_arg_branch (&td, MINT_BLE_UN_I4, 2 + (gint8) td.ip [1]);
-                       td.ip += 2;
-                       break;
-               case CEE_BLT_UN:
-                       two_arg_branch (&td, MINT_BLT_UN_I4, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       break;
-               case CEE_BLT_UN_S:
-                       two_arg_branch (&td, MINT_BLT_UN_I4, 2 + (gint8) td.ip [1]);
-                       td.ip += 2;
-                       break;
-               case CEE_SWITCH: {
-                       guint32 n;
-                       const unsigned char *next_ip;
-                       const unsigned char *base_ip = td.ip;
-                       unsigned short *next_new_ip;
-                       ++td.ip;
-                       n = read32 (td.ip);
-                       ADD_CODE(&td, MINT_SWITCH);
-                       ADD_CODE(&td, * (unsigned short *)(&n));
-                       ADD_CODE(&td, * ((unsigned short *)&n + 1));
-                       td.ip += 4;
-                       next_ip = td.ip + n * 4;
-                       next_new_ip = td.new_ip + n * 2;
-                       for (i = 0; i < n; i++) {
-                               offset = read32 (td.ip);
-                               target = next_ip - td.il_code + offset;
-                               if (offset < 0)
-                                       target = td.in_offsets [target] - (next_new_ip - td.new_code);
-                               else {
-                                       int prev = td.forward_refs [target];
-                                       td.forward_refs [td.ip - td.il_code] = prev;
-                                       td.forward_refs [target] = td.ip - td.il_code;
-                                       td.in_offsets [td.ip - td.il_code] = - (base_ip - td.il_code);
-                               }
-                               ADD_CODE(&td, * (unsigned short *)(&target));
-                               ADD_CODE(&td, * ((unsigned short *)&target + 1));
-                               td.ip += 4;
-                       }
-                       --td.sp;
-                       break;
-               }
-               case CEE_LDIND_I1:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_LDIND_I1);
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_LDIND_U1:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_LDIND_U1);
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_LDIND_I2:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_LDIND_I2);
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_LDIND_U2:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_LDIND_U2);
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_LDIND_I4:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_LDIND_I4);
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_LDIND_U4:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_LDIND_U4);
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_LDIND_I8:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_LDIND_I8);
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
-                       break;
-               case CEE_LDIND_I:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_LDIND_I);
-                       ADD_CODE (&td, 0);
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I);
-                       break;
-               case CEE_LDIND_R4:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_LDIND_R4);
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
-                       break;
-               case CEE_LDIND_R8:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_LDIND_R8);
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
-                       break;
-               case CEE_LDIND_REF:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_LDIND_REF);
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_O);
-                       break;
-               case CEE_STIND_REF:
-                       CHECK_STACK (&td, 2);
-                       SIMPLE_OP (td, MINT_STIND_REF);
-                       td.sp -= 2;
-                       break;
-               case CEE_STIND_I1:
-                       CHECK_STACK (&td, 2);
-                       SIMPLE_OP (td, MINT_STIND_I1);
-                       td.sp -= 2;
-                       break;
-               case CEE_STIND_I2:
-                       CHECK_STACK (&td, 2);
-                       SIMPLE_OP (td, MINT_STIND_I2);
-                       td.sp -= 2;
-                       break;
-               case CEE_STIND_I4:
-                       CHECK_STACK (&td, 2);
-                       SIMPLE_OP (td, MINT_STIND_I4);
-                       td.sp -= 2;
-                       break;
-               case CEE_STIND_I:
-                       CHECK_STACK (&td, 2);
-                       SIMPLE_OP (td, MINT_STIND_I);
-                       td.sp -= 2;
-                       break;
-               case CEE_STIND_I8:
-                       CHECK_STACK (&td, 2);
-                       SIMPLE_OP (td, MINT_STIND_I8);
-                       td.sp -= 2;
-                       break;
-               case CEE_STIND_R4:
-                       CHECK_STACK (&td, 2);
-                       SIMPLE_OP (td, MINT_STIND_R4);
-                       td.sp -= 2;
-                       break;
-               case CEE_STIND_R8:
-                       CHECK_STACK (&td, 2);
-                       SIMPLE_OP (td, MINT_STIND_R8);
-                       td.sp -= 2;
-                       break;
-               case CEE_ADD:
-                       binary_arith_op(&td, MINT_ADD_I4);
-                       ++td.ip;
-                       break;
-               case CEE_SUB:
-                       binary_arith_op(&td, MINT_SUB_I4);
-                       ++td.ip;
-                       break;
-               case CEE_MUL:
-                       binary_arith_op(&td, MINT_MUL_I4);
-                       ++td.ip;
-                       break;
-               case CEE_DIV:
-                       binary_arith_op(&td, MINT_DIV_I4);
-                       ++td.ip;
-                       break;
-               case CEE_DIV_UN:
-                       binary_arith_op(&td, MINT_DIV_UN_I4);
-                       ++td.ip;
-                       break;
-               case CEE_REM:
-                       binary_int_op (&td, MINT_REM_I4);
-                       ++td.ip;
-                       break;
-               case CEE_REM_UN:
-                       binary_int_op (&td, MINT_REM_UN_I4);
-                       ++td.ip;
-                       break;
-               case CEE_AND:
-                       binary_int_op (&td, MINT_AND_I4);
-                       ++td.ip;
-                       break;
-               case CEE_OR:
-                       binary_int_op (&td, MINT_OR_I4);
-                       ++td.ip;
-                       break;
-               case CEE_XOR:
-                       binary_int_op (&td, MINT_XOR_I4);
-                       ++td.ip;
-                       break;
-               case CEE_SHL:
-                       shift_op (&td, MINT_SHL_I4);
-                       ++td.ip;
-                       break;
-               case CEE_SHR:
-                       shift_op (&td, MINT_SHR_I4);
-                       ++td.ip;
-                       break;
-               case CEE_SHR_UN:
-                       shift_op (&td, MINT_SHR_UN_I4);
-                       ++td.ip;
-                       break;
-               case CEE_NEG:
-                       unary_arith_op (&td, MINT_NEG_I4);
-                       ++td.ip;
-                       break;
-               case CEE_NOT:
-                       unary_arith_op (&td, MINT_NOT_I4);
-                       ++td.ip;
-                       break;
-               case CEE_CONV_U1:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_U1_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_U1_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_U1_I8);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_CONV_I1:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_I1_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_I1_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_I1_I8);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_CONV_U2:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_U2_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_U2_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_U2_I8);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_CONV_I2:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_I2_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_I2_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_I2_I8);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_CONV_U:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-#if SIZEOF_VOID_P == 4
-                               ADD_CODE(&td, MINT_CONV_U4_R8);
-#else
-                               ADD_CODE(&td, MINT_CONV_U8_R8);
-#endif
-                               break;
-                       case STACK_TYPE_I4:
-#if SIZEOF_VOID_P == 8
-                               ADD_CODE(&td, MINT_CONV_U8_I4);
-#endif
-                               break;
-                       case STACK_TYPE_I8:
-#if SIZEOF_VOID_P == 4
-                               ADD_CODE(&td, MINT_CONV_U4_I8);
-#endif
-                               break;
-                       case STACK_TYPE_MP:
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I);
-                       break;
-               case CEE_CONV_I: 
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-#if SIZEOF_VOID_P == 8
-                               ADD_CODE(&td, MINT_CONV_I8_R8);
-#else
-                               ADD_CODE(&td, MINT_CONV_I4_R8);
-#endif
-                               break;
-                       case STACK_TYPE_I4:
-#if SIZEOF_VOID_P == 8
-                               ADD_CODE(&td, MINT_CONV_I8_I4);
-#endif
-                               break;
-                       case STACK_TYPE_O:
-                               break;
-                       case STACK_TYPE_MP:
-                               break;
-                       case STACK_TYPE_I8:
-#if SIZEOF_VOID_P == 4
-                               ADD_CODE(&td, MINT_CONV_I4_I8);
-#endif
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I);
-                       break;
-               case CEE_CONV_U4:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_U4_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_U4_I8);
-                               break;
-                       case STACK_TYPE_MP:
-#if SIZEOF_VOID_P == 8
-                               ADD_CODE(&td, MINT_CONV_U4_I8);
-#endif
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_CONV_I4:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_I4_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_I4_I8);
-                               break;
-                       case STACK_TYPE_MP:
-#if SIZEOF_VOID_P == 8
-                               ADD_CODE(&td, MINT_CONV_I4_I8);
-#endif
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_CONV_I8:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_I8_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_I8_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               break;
-                       case STACK_TYPE_MP:
-#if SIZEOF_VOID_P == 4
-                               ADD_CODE(&td, MINT_CONV_I8_I4);
-#endif
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
-                       break;
-               case CEE_CONV_R4:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_R4_R8);
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_R4_I8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_R4_I4);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
-                       break;
-               case CEE_CONV_R8:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_R8_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_R8_I8);
-                               break;
-                       case STACK_TYPE_R8:
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
-                       break;
-               case CEE_CONV_U8:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_U8_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               break;
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_U8_R8);
-                               break;
-                       case STACK_TYPE_MP:
-#if SIZEOF_VOID_P == 4
-                               ADD_CODE(&td, MINT_CONV_U8_I4);
-#endif
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
-                       break;
-#if 0
-               case CEE_CPOBJ: {
-                       MonoClass *vtklass;
-                       ++ip;
-                       vtklass = mono_class_get_full (image, read32 (ip), generic_context);
-                       ip += 4;
-                       sp -= 2;
-                       memcpy (sp [0].data.p, sp [1].data.p, mono_class_value_size (vtklass, NULL));
-                       break;
-               }
-#endif
-               case CEE_LDOBJ: {
-                       int size;
-                       CHECK_STACK (&td, 1);
-
-                       token = read32 (td.ip + 1);
-
-                       if (method->wrapper_type != MONO_WRAPPER_NONE)
-                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
-                       else
-                               klass = mono_class_get_full (image, token, generic_context);
-
-                       ADD_CODE(&td, MINT_LDOBJ);
-                       ADD_CODE(&td, get_data_item_index(&td, klass));
-                       if (mint_type (&klass->byval_arg) == MINT_TYPE_VT) {
-                               size = mono_class_value_size (klass, NULL);
-                               PUSH_VT(&td, size);
-                       }
-                       td.ip += 5;
-                       SET_TYPE(td.sp - 1, stack_type[mint_type(&klass->byval_arg)], klass);
-                       break;
-               }
-               case CEE_LDSTR: {
-                       MonoString *s;
-                       token = mono_metadata_token_index (read32 (td.ip + 1));
-                       td.ip += 5;
-                       if (method->wrapper_type != MONO_WRAPPER_NONE) {
-                               s = mono_string_new_wrapper(
-                                       mono_method_get_wrapper_data (method, token));
-                       }
-                       else
-                               s = mono_ldstr (domain, image, token);
-                       ADD_CODE(&td, MINT_LDSTR);
-                       ADD_CODE(&td, get_data_item_index (&td, s));
-                       PUSH_TYPE(&td, STACK_TYPE_O, mono_defaults.string_class);
-                       break;
-               }
-               case CEE_NEWOBJ: {
-                       MonoMethod *m;
-                       MonoMethodSignature *csignature;
-                       guint32 vt_stack_used = 0;
-                       guint32 vt_res_size = 0;
-
-                       td.ip++;
-                       token = read32 (td.ip);
-                       td.ip += 4;
-
-                       if (method->wrapper_type != MONO_WRAPPER_NONE)
-                               m = (MonoMethod *)mono_method_get_wrapper_data (method, token);
-                       else 
-                               m = mono_get_method_full (image, token, NULL, generic_context);
-
-                       csignature = mono_method_signature (m);
-                       klass = m->klass;
-                       td.sp -= csignature->param_count;
-                       ADD_CODE(&td, MINT_NEWOBJ);
-                       ADD_CODE(&td, get_data_item_index (&td, mono_interp_get_runtime_method (domain, m, &error)));
-                       mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-
-                       if (mint_type (&klass->byval_arg) == MINT_TYPE_VT) {
-                               vt_res_size = mono_class_value_size (klass, NULL);
-                               PUSH_VT (&td, vt_res_size);
-                       }
-                       for (i = 0; i < csignature->param_count; ++i) {
-                               int mt = mint_type(csignature->params [i]);
-                               if (mt == MINT_TYPE_VT) {
-                                       MonoClass *k = mono_class_from_mono_type (csignature->params [i]);
-                                       gint32 size = mono_class_value_size (k, NULL);
-                                       size = (size + 7) & ~7;
-                                       vt_stack_used += size;
-                               }
-                       }
-                       if (vt_stack_used != 0 || vt_res_size != 0) {
-                               ADD_CODE(&td, MINT_VTRESULT);
-                               ADD_CODE(&td, vt_res_size);
-                               WRITE32(&td, &vt_stack_used);
-                               td.vt_sp -= vt_stack_used;
-                       }
-                       PUSH_TYPE (&td, stack_type [mint_type (&klass->byval_arg)], klass);
-                       break;
-               }
-               case CEE_CASTCLASS:
-                       CHECK_STACK (&td, 1);
-                       token = read32 (td.ip + 1);
-                       klass = mono_class_get_full (image, token, generic_context);
-                       ADD_CODE(&td, MINT_CASTCLASS);
-                       ADD_CODE(&td, get_data_item_index (&td, klass));
-                       td.sp [-1].klass = klass;
-                       td.ip += 5;
-                       break;
-               case CEE_ISINST:
-                       CHECK_STACK (&td, 1);
-                       token = read32 (td.ip + 1);
-                       klass = mono_class_get_full (image, token, generic_context);
-                       ADD_CODE(&td, MINT_ISINST);
-                       ADD_CODE(&td, get_data_item_index (&td, klass));
-                       td.ip += 5;
-                       break;
-               case CEE_CONV_R_UN:
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_R_UN_I8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_R_UN_I4);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
-                       ++td.ip;
-                       break;
-               case CEE_UNBOX:
-                       CHECK_STACK (&td, 1);
-                       token = read32 (td.ip + 1);
-                       
-                       if (method->wrapper_type != MONO_WRAPPER_NONE)
-                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
-                       else 
-                               klass = mono_class_get_full (image, token, generic_context);
-
-                       if (mono_class_is_nullable (klass)) {
-                               g_error ("cee_unbox: implement Nullable");
-                       }
-                       
-                       ADD_CODE(&td, MINT_UNBOX);
-                       ADD_CODE(&td, get_data_item_index (&td, klass));
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
-                       td.ip += 5;
-                       break;
-               case CEE_UNBOX_ANY:
-                       CHECK_STACK (&td, 1);
-                       token = read32 (td.ip + 1);
-
-                       g_assert (method->wrapper_type == MONO_WRAPPER_NONE);
-                       klass = mono_class_get_full (image, token, generic_context);
-
-                       if (mini_type_is_reference (&klass->byval_arg)) {
-                               g_error ("unbox_any: generic class is reference type");
-                       } else if (mono_class_is_nullable (klass)) {
-                               MonoMethod *target_method = mono_class_get_method_from_name (klass, "Unbox", 1);
-                               /* td.ip is incremented by interp_transform_call */
-                               interp_transform_call (&td, method, target_method, domain, generic_context, is_bb_start, body_start_offset, NULL);
-                       } else {
-                               int mt = mint_type (&klass->byval_arg);
-                               ADD_CODE (&td, MINT_UNBOX);
-                               ADD_CODE (&td, get_data_item_index (&td, klass));
-                               SET_TYPE (td.sp - 1, stack_type [mt], klass);
-                               if (mt == MINT_TYPE_VT) {
-                                       int size = mono_class_value_size (klass, NULL);
-                                       PUSH_VT (&td, size);
-                               }
-                               td.ip += 5;
-                       }
-
-                       break;
-               case CEE_THROW:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_THROW);
-                       --td.sp;
-                       generating_code = 0;
-                       break;
-               case CEE_LDFLDA:
-                       CHECK_STACK (&td, 1);
-                       token = read32 (td.ip + 1);
-                       field = mono_field_from_token (image, token, &klass, generic_context);
-                       mono_class_init (klass);
-                       mt = mint_type(field->type);
-                       ADD_CODE(&td, MINT_LDFLDA);
-                       ADD_CODE(&td, klass->valuetype ? field->offset - sizeof(MonoObject) : field->offset);
-                       td.ip += 5;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
-                       break;
-               case CEE_LDFLD: {
-                       CHECK_STACK (&td, 1);
-                       token = read32 (td.ip + 1);
-                       field = mono_field_from_token (image, token, &klass, generic_context);
-                       mono_class_init (klass);
-
-                       MonoClass *field_klass = mono_class_from_mono_type (field->type);
-                       mt = mint_type (&field_klass->byval_arg);
-                       if (klass->marshalbyref) {
-                               ADD_CODE(&td, mt == MINT_TYPE_VT ? MINT_LDRMFLD_VT :  MINT_LDRMFLD);
-                               ADD_CODE(&td, get_data_item_index (&td, field));
-                       } else  {
-                               ADD_CODE(&td, MINT_LDFLD_I1 + mt - MINT_TYPE_I1);
-                               ADD_CODE(&td, klass->valuetype ? field->offset - sizeof(MonoObject) : field->offset);
-                       }
-                       if (mt == MINT_TYPE_VT) {
-                               int size = mono_class_value_size (field_klass, NULL);
-                               PUSH_VT(&td, size);
-                               WRITE32(&td, &size);
-                       }
-                       if (td.sp [-1].type == STACK_TYPE_VT) {
-                               int size = mono_class_value_size (klass, NULL);
-                               size = (size + 7) & ~7;
-                               td.vt_sp -= size;
-                               ADD_CODE (&td, MINT_VTRESULT);
-                               ADD_CODE (&td, 0);
-                               WRITE32 (&td, &size);
-                       }
-                       td.ip += 5;
-                       SET_TYPE(td.sp - 1, stack_type [mt], field_klass);
-                       break;
-               }
-               case CEE_STFLD:
-                       CHECK_STACK (&td, 2);
-                       token = read32 (td.ip + 1);
-                       field = mono_field_from_token (image, token, &klass, generic_context);
-                       mono_class_init (klass);
-                       mt = mint_type(field->type);
-                       if (klass->marshalbyref) {
-                               ADD_CODE(&td, mt == MINT_TYPE_VT ? MINT_STRMFLD_VT : MINT_STRMFLD);
-                               ADD_CODE(&td, get_data_item_index (&td, field));
-                       } else  {
-                               ADD_CODE(&td, MINT_STFLD_I1 + mt - MINT_TYPE_I1);
-                               ADD_CODE(&td, klass->valuetype ? field->offset - sizeof(MonoObject) : field->offset);
-                       }
-                       if (mt == MINT_TYPE_VT) {
-                               MonoClass *klass = mono_class_from_mono_type (field->type);
-                               int size = mono_class_value_size (klass, NULL);
-                               POP_VT(&td, size);
-                               WRITE32(&td, &size);
-                       }
-                       td.ip += 5;
-                       td.sp -= 2;
-                       break;
-               case CEE_LDSFLDA:
-                       token = read32 (td.ip + 1);
-                       field = mono_field_from_token (image, token, &klass, generic_context);
-                       ADD_CODE(&td, MINT_LDSFLDA);
-                       ADD_CODE(&td, get_data_item_index (&td, field));
-                       td.ip += 5;
-                       PUSH_SIMPLE_TYPE(&td, STACK_TYPE_MP);
-                       break;
-               case CEE_LDSFLD:
-                       token = read32 (td.ip + 1);
-                       field = mono_field_from_token (image, token, &klass, generic_context);
-                       mt = mint_type(field->type);
-                       ADD_CODE(&td, mt == MINT_TYPE_VT ? MINT_LDSFLD_VT : MINT_LDSFLD);
-                       ADD_CODE(&td, get_data_item_index (&td, field));
-                       klass = NULL;
-                       if (mt == MINT_TYPE_VT) {
-                               MonoClass *klass = mono_class_from_mono_type (field->type);
-                               int size = mono_class_value_size (klass, NULL);
-                               PUSH_VT(&td, size);
-                               WRITE32(&td, &size);
-                               klass = field->type->data.klass;
-                       } else {
-                               if (mt == MINT_TYPE_O) 
-                                       klass = mono_class_from_mono_type (field->type);
-                       }
-                       td.ip += 5;
-                       PUSH_TYPE(&td, stack_type [mt], klass);
-                       break;
-               case CEE_STSFLD:
-                       CHECK_STACK (&td, 1);
-                       token = read32 (td.ip + 1);
-                       field = mono_field_from_token (image, token, &klass, generic_context);
-                       mt = mint_type(field->type);
-                       ADD_CODE(&td, mt == MINT_TYPE_VT ? MINT_STSFLD_VT : MINT_STSFLD);
-                       ADD_CODE(&td, get_data_item_index (&td, field));
-                       if (mt == MINT_TYPE_VT) {
-                               MonoClass *klass = mono_class_from_mono_type (field->type);
-                               int size = mono_class_value_size (klass, NULL);
-                               POP_VT (&td, size);
-                               WRITE32 (&td, &size);
-                       }
-                       td.ip += 5;
-                       --td.sp;
-                       break;
-               case CEE_STOBJ: {
-                       int size;
-                       token = read32 (td.ip + 1);
-
-                       if (method->wrapper_type != MONO_WRAPPER_NONE)
-                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
-                       else
-                               klass = mono_class_get_full (image, token, generic_context);
-
-                       ADD_CODE(&td, td.sp [-1].type == STACK_TYPE_VT ? MINT_STOBJ_VT : MINT_STOBJ);
-                       ADD_CODE(&td, get_data_item_index (&td, klass));
-                       if (td.sp [-1].type == STACK_TYPE_VT) {
-                               size = mono_class_value_size (klass, NULL);
-                               size = (size + 7) & ~7;
-                               td.vt_sp -= size;
-                       }
-                       td.ip += 5;
-                       td.sp -= 2;
-                       break;
-               }
-               case CEE_CONV_OVF_I_UN:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-#if SIZEOF_VOID_P == 8
-                               ADD_CODE(&td, MINT_CONV_OVF_I8_UN_R8);
-#else
-                               ADD_CODE(&td, MINT_CONV_OVF_I4_UN_R8);
-#endif
-                               break;
-                       case STACK_TYPE_I8:
-                               /*FIX*/
-                               break;
-                       case STACK_TYPE_I4:
-#if SIZEOF_VOID_P == 8
-                               ADD_CODE(&td, MINT_CONV_I8_U4);
-#endif
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                               break;
-                       }
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
-                       ++td.ip;
-                       break;
-               case CEE_CONV_OVF_I8_UN:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_OVF_I8_UN_R8);
-                               break;
-                       case STACK_TYPE_I8:
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_I8_U4);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                               break;
-                       }
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
-                       ++td.ip;
-                       break;
-               case CEE_BOX: {
-                       int size;
-                       CHECK_STACK (&td, 1);
-                       token = read32 (td.ip + 1);
-                       if (method->wrapper_type != MONO_WRAPPER_NONE)
-                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
-                       else
-                               klass = mono_class_get_full (image, token, generic_context);
-
-                       if (mono_class_is_nullable (klass)) {
-                               MonoMethod *target_method = mono_class_get_method_from_name (klass, "Box", 1);
-                               /* td.ip is incremented by interp_transform_call */
-                               interp_transform_call (&td, method, target_method, domain, generic_context, is_bb_start, body_start_offset, NULL);
-                       } else if (!klass->valuetype) {
-                               /* already boxed, do nothing. */
-                               td.ip += 5;
-                       } else {
-                               if (mint_type (&klass->byval_arg) == MINT_TYPE_VT && !klass->enumtype) {
-                                       size = mono_class_value_size (klass, NULL);
-                                       size = (size + 7) & ~7;
-                                       td.vt_sp -= size;
-                               }
-                               ADD_CODE(&td, MINT_BOX);
-                               ADD_CODE(&td, get_data_item_index (&td, klass));
-                               ADD_CODE (&td, 0);
-                               SET_TYPE(td.sp - 1, STACK_TYPE_O, klass);
-                               td.ip += 5;
-                       }
-
-                       break;
-               }
-               case CEE_NEWARR:
-                       CHECK_STACK (&td, 1);
-                       token = read32 (td.ip + 1);
-
-                       if (method->wrapper_type != MONO_WRAPPER_NONE)
-                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
-                       else
-                               klass = mono_class_get_full (image, token, generic_context);
-
-                       ADD_CODE(&td, MINT_NEWARR);
-                       ADD_CODE(&td, get_data_item_index (&td, klass));
-                       SET_TYPE(td.sp - 1, STACK_TYPE_O, klass);
-                       td.ip += 5;
-                       break;
-               case CEE_LDLEN:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_LDLEN);
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I);
-                       break;
-               case CEE_LDELEMA:
-                       CHECK_STACK (&td, 2);
-                       ENSURE_I4 (&td, 1);
-                       token = read32 (td.ip + 1);
-
-                       if (method->wrapper_type != MONO_WRAPPER_NONE)
-                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
-                       else
-                               klass = mono_class_get_full (image, token, generic_context);
-
-                       ADD_CODE(&td, MINT_LDELEMA);
-                       ADD_CODE(&td, get_data_item_index (&td, klass));
-                       td.ip += 5;
-                       --td.sp;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
-                       break;
-               case CEE_LDELEM_I1:
-                       CHECK_STACK (&td, 2);
-                       ENSURE_I4 (&td, 1);
-                       SIMPLE_OP (td, MINT_LDELEM_I1);
-                       --td.sp;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_LDELEM_U1:
-                       CHECK_STACK (&td, 2);
-                       ENSURE_I4 (&td, 1);
-                       SIMPLE_OP (td, MINT_LDELEM_U1);
-                       --td.sp;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_LDELEM_I2:
-                       CHECK_STACK (&td, 2);
-                       ENSURE_I4 (&td, 1);
-                       SIMPLE_OP (td, MINT_LDELEM_I2);
-                       --td.sp;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_LDELEM_U2:
-                       CHECK_STACK (&td, 2);
-                       ENSURE_I4 (&td, 1);
-                       SIMPLE_OP (td, MINT_LDELEM_U2);
-                       --td.sp;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_LDELEM_I4:
-                       CHECK_STACK (&td, 2);
-                       ENSURE_I4 (&td, 1);
-                       SIMPLE_OP (td, MINT_LDELEM_I4);
-                       --td.sp;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_LDELEM_U4:
-                       CHECK_STACK (&td, 2);
-                       ENSURE_I4 (&td, 1);
-                       SIMPLE_OP (td, MINT_LDELEM_U4);
-                       --td.sp;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_LDELEM_I8:
-                       CHECK_STACK (&td, 2);
-                       ENSURE_I4 (&td, 1);
-                       SIMPLE_OP (td, MINT_LDELEM_I8);
-                       --td.sp;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
-                       break;
-               case CEE_LDELEM_I:
-                       CHECK_STACK (&td, 2);
-                       ENSURE_I4 (&td, 1);
-                       SIMPLE_OP (td, MINT_LDELEM_I);
-                       --td.sp;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I);
-                       break;
-               case CEE_LDELEM_R4:
-                       CHECK_STACK (&td, 2);
-                       ENSURE_I4 (&td, 1);
-                       SIMPLE_OP (td, MINT_LDELEM_R4);
-                       --td.sp;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
-                       break;
-               case CEE_LDELEM_R8:
-                       CHECK_STACK (&td, 2);
-                       ENSURE_I4 (&td, 1);
-                       SIMPLE_OP (td, MINT_LDELEM_R8);
-                       --td.sp;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_R8);
-                       break;
-               case CEE_LDELEM_REF:
-                       CHECK_STACK (&td, 2);
-                       ENSURE_I4 (&td, 1);
-                       SIMPLE_OP (td, MINT_LDELEM_REF);
-                       --td.sp;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_O);
-                       break;
-               case CEE_LDELEM:
-                       CHECK_STACK (&td, 2);
-                       token = read32 (td.ip + 1);
-                       klass = mono_class_get_full (image, token, generic_context);
-                       switch (mint_type (&klass->byval_arg)) {
-                               case MINT_TYPE_I4:
-                                       ENSURE_I4 (&td, 1);
-                                       SIMPLE_OP (td, MINT_LDELEM_I4);
-                                       --td.sp;
-                                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                                       break;
-                               case MINT_TYPE_VT: {
-                                       int size = mono_class_value_size (klass, NULL);
-                                       ENSURE_I4 (&td, 1);
-                                       SIMPLE_OP (td, MINT_LDELEM_VT);
-                                       ADD_CODE (&td, get_data_item_index (&td, klass));
-                                       WRITE32 (&td, &size);
-                                       --td.sp;
-                                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_VT);
-                                       PUSH_VT (&td, size);
-                                       break;
-                               }
-                               default: {
-                                       GString *res = g_string_new ("");
-                                       mono_type_get_desc (res, &klass->byval_arg, TRUE);
-                                       g_print ("LDELEM: %s -> %d (%s)\n", klass->name, mint_type (&klass->byval_arg), res->str);
-                                       g_string_free (res, TRUE);
-                                       g_assert (0);
-                                       break;
-                               }
-                       }
-                       td.ip += 4;
-                       break;
-               case CEE_STELEM_I:
-                       CHECK_STACK (&td, 3);
-                       ENSURE_I4 (&td, 2);
-                       SIMPLE_OP (td, MINT_STELEM_I);
-                       td.sp -= 3;
-                       break;
-               case CEE_STELEM_I1:
-                       CHECK_STACK (&td, 3);
-                       ENSURE_I4 (&td, 2);
-                       SIMPLE_OP (td, MINT_STELEM_I1);
-                       td.sp -= 3;
-                       break;
-               case CEE_STELEM_I2:
-                       CHECK_STACK (&td, 3);
-                       ENSURE_I4 (&td, 2);
-                       SIMPLE_OP (td, MINT_STELEM_I2);
-                       td.sp -= 3;
-                       break;
-               case CEE_STELEM_I4:
-                       CHECK_STACK (&td, 3);
-                       ENSURE_I4 (&td, 2);
-                       SIMPLE_OP (td, MINT_STELEM_I4);
-                       td.sp -= 3;
-                       break;
-               case CEE_STELEM_I8:
-                       CHECK_STACK (&td, 3);
-                       ENSURE_I4 (&td, 2);
-                       SIMPLE_OP (td, MINT_STELEM_I8);
-                       td.sp -= 3;
-                       break;
-               case CEE_STELEM_R4:
-                       CHECK_STACK (&td, 3);
-                       ENSURE_I4 (&td, 2);
-                       SIMPLE_OP (td, MINT_STELEM_R4);
-                       td.sp -= 3;
-                       break;
-               case CEE_STELEM_R8:
-                       CHECK_STACK (&td, 3);
-                       ENSURE_I4 (&td, 2);
-                       SIMPLE_OP (td, MINT_STELEM_R8);
-                       td.sp -= 3;
-                       break;
-               case CEE_STELEM_REF:
-                       CHECK_STACK (&td, 3);
-                       ENSURE_I4 (&td, 2);
-                       SIMPLE_OP (td, MINT_STELEM_REF);
-                       td.sp -= 3;
-                       break;
-               case CEE_STELEM:
-                       CHECK_STACK (&td, 3);
-                       ENSURE_I4 (&td, 2);
-                       token = read32 (td.ip + 1);
-                       klass = mono_class_get_full (image, token, generic_context);
-                       switch (mint_type (&klass->byval_arg)) {
-                               case MINT_TYPE_I4:
-                                       SIMPLE_OP (td, MINT_STELEM_I4);
-                                       break;
-                               case MINT_TYPE_O:
-                                       SIMPLE_OP (td, MINT_STELEM_REF);
-                                       break;
-                               case MINT_TYPE_VT: {
-                                       int size = mono_class_value_size (klass, NULL);
-                                       SIMPLE_OP (td, MINT_STELEM_VT);
-                                       ADD_CODE (&td, get_data_item_index (&td, klass));
-                                       WRITE32 (&td, &size);
-                                       POP_VT (&td, size);
-                                       break;
-                               }
-                               default: {
-                                       GString *res = g_string_new ("");
-                                       mono_type_get_desc (res, &klass->byval_arg, TRUE);
-                                       g_print ("STELEM: %s -> %d (%s)\n", klass->name, mint_type (&klass->byval_arg), res->str);
-                                       g_string_free (res, TRUE);
-                                       g_assert (0);
-                                       break;
-                               }
-                       }
-                       td.ip += 4;
-                       td.sp -= 3;
-                       break;
-#if 0
-               case CEE_CONV_OVF_U1:
-
-               case CEE_CONV_OVF_I8:
-
-#if SIZEOF_VOID_P == 8
-               case CEE_CONV_OVF_U:
-#endif
-               case CEE_REFANYVAL: ves_abort(); break;
-#endif
-               case CEE_CKFINITE:
-                       CHECK_STACK (&td, 1);
-                       SIMPLE_OP (td, MINT_CKFINITE);
-                       break;
-               case CEE_CONV_OVF_I1:
-               case CEE_CONV_OVF_I1_UN:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_OVF_I1_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_OVF_I1_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_OVF_I1_I8);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_CONV_OVF_U1:
-               case CEE_CONV_OVF_U1_UN:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_OVF_U1_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_OVF_U1_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_OVF_U1_I8);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_CONV_OVF_I2:
-               case CEE_CONV_OVF_I2_UN:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_OVF_I2_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_OVF_I2_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_OVF_I2_I8);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-               case CEE_CONV_OVF_U2_UN:
-               case CEE_CONV_OVF_U2:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_OVF_U2_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_OVF_U2_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_OVF_U2_I8);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-#if SIZEOF_VOID_P == 4
-               case CEE_CONV_OVF_I:
-#endif
-               case CEE_CONV_OVF_I4:
-               case CEE_CONV_OVF_I4_UN:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_OVF_I4_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               if (*td.ip == CEE_CONV_OVF_I4_UN)
-                                       ADD_CODE(&td, MINT_CONV_OVF_I4_U4);
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_OVF_I4_I8);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-#if SIZEOF_VOID_P == 4
-               case CEE_CONV_OVF_U:
-#endif
-               case CEE_CONV_OVF_U4:
-               case CEE_CONV_OVF_U4_UN:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_OVF_U4_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               if (*td.ip != CEE_CONV_OVF_U4_UN)
-                                       ADD_CODE(&td, MINT_CONV_OVF_U4_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               ADD_CODE(&td, MINT_CONV_OVF_U4_I8);
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                       break;
-#if SIZEOF_VOID_P == 8
-               case CEE_CONV_OVF_I:
-#endif
-               case CEE_CONV_OVF_I8:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_OVF_I8_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_I8_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
-                       break;
-#if SIZEOF_VOID_P == 8
-               case CEE_CONV_OVF_U:
-#endif
-               case CEE_CONV_OVF_U8:
-                       CHECK_STACK (&td, 1);
-                       switch (td.sp [-1].type) {
-                       case STACK_TYPE_R8:
-                               ADD_CODE(&td, MINT_CONV_OVF_U8_R8);
-                               break;
-                       case STACK_TYPE_I4:
-                               ADD_CODE(&td, MINT_CONV_OVF_U8_I4);
-                               break;
-                       case STACK_TYPE_I8:
-                               break;
-                       default:
-                               g_assert_not_reached ();
-                       }
-                       ++td.ip;
-                       SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I8);
-                       break;
-               case CEE_LDTOKEN: {
-                       int size;
-                       gpointer handle;
-                       token = read32 (td.ip + 1);
-                       handle = mono_ldtoken (image, token, &klass, generic_context);
-                       mt = mint_type(&klass->byval_arg);
-                       g_assert (mt == MINT_TYPE_VT);
-                       size = mono_class_value_size (klass, NULL);
-                       g_assert (size == sizeof(gpointer));
-                       PUSH_VT(&td, sizeof(gpointer));
-                       ADD_CODE(&td, MINT_LDTOKEN);
-                       ADD_CODE(&td, get_data_item_index (&td, handle));
-                       PUSH_SIMPLE_TYPE(&td, stack_type [mt]);
-                       td.ip += 5;
-                       break;
-               }
-               case CEE_ADD_OVF:
-                       binary_arith_op(&td, MINT_ADD_OVF_I4);
-                       ++td.ip;
-                       break;
-               case CEE_ADD_OVF_UN:
-                       binary_arith_op(&td, MINT_ADD_OVF_UN_I4);
-                       ++td.ip;
-                       break;
-               case CEE_MUL_OVF:
-                       binary_arith_op(&td, MINT_MUL_OVF_I4);
-                       ++td.ip;
-                       break;
-               case CEE_MUL_OVF_UN:
-                       binary_arith_op(&td, MINT_MUL_OVF_UN_I4);
-                       ++td.ip;
-                       break;
-               case CEE_SUB_OVF:
-                       binary_arith_op(&td, MINT_SUB_OVF_I4);
-                       ++td.ip;
-                       break;
-               case CEE_SUB_OVF_UN:
-                       binary_arith_op(&td, MINT_SUB_OVF_UN_I4);
-                       ++td.ip;
-                       break;
-               case CEE_ENDFINALLY:
-                       SIMPLE_OP (td, MINT_ENDFINALLY);
-                       generating_code = 0;
-                       break;
-               case CEE_LEAVE:
-                       td.sp = td.stack;
-                       handle_branch (&td, MINT_LEAVE_S, MINT_LEAVE, 5 + read32 (td.ip + 1));
-                       td.ip += 5;
-                       generating_code = 0;
-                       break;
-               case CEE_LEAVE_S:
-                       td.sp = td.stack;
-                       handle_branch (&td, MINT_LEAVE_S, MINT_LEAVE, 2 + (gint8)td.ip [1]);
-                       td.ip += 2;
-                       generating_code = 0;
-                       break;
-               case CEE_UNUSED41:
-                       ++td.ip;
-                       switch (*td.ip) {
-                               case CEE_MONO_CALLI_EXTRA_ARG:
-                                       /* Same as CEE_CALLI, llvm specific */
-                                       interp_transform_call (&td, method, NULL, domain, generic_context, is_bb_start, body_start_offset, NULL);
-                                       break;
-                               case CEE_MONO_ICALL: {
-                                       guint32 token;
-                                       gpointer func;
-                                       MonoJitICallInfo *info;
-
-                                       token = read32 (td.ip + 1);
-                                       td.ip += 5;
-                                       func = mono_method_get_wrapper_data (method, token);
-                                       info = mono_find_jit_icall_by_addr (func);
-                                       g_assert (info);
-
-                                       CHECK_STACK (&td, info->sig->param_count);
-                                       switch (info->sig->param_count) {
-                                       case 0:
-                                               if (MONO_TYPE_IS_VOID (info->sig->ret))
-                                                       ADD_CODE (&td,MINT_ICALL_V_V);
-                                               else
-                                                       ADD_CODE (&td, MINT_ICALL_V_P);
-                                               break;
-                                       case 1:
-                                               if (MONO_TYPE_IS_VOID (info->sig->ret))
-                                                       ADD_CODE (&td,MINT_ICALL_P_V);
-                                               else
-                                                       ADD_CODE (&td,MINT_ICALL_P_P);
-                                               break;
-                                       case 2:
-                                               if (MONO_TYPE_IS_VOID (info->sig->ret)) {
-                                                       if (info->sig->params [1]->type == MONO_TYPE_I4)
-                                                               ADD_CODE (&td,MINT_ICALL_PI_V);
-                                                       else
-                                                               ADD_CODE (&td,MINT_ICALL_PP_V);
-                                               } else {
-                                                       if (info->sig->params [1]->type == MONO_TYPE_I4)
-                                                               ADD_CODE (&td,MINT_ICALL_PI_P);
-                                                       else
-                                                               ADD_CODE (&td,MINT_ICALL_PP_P);
-                                               }
-                                               break;
-                                       case 3:
-                                               g_assert (MONO_TYPE_IS_VOID (info->sig->ret));
-                                               if (info->sig->params [2]->type == MONO_TYPE_I4)
-                                                       ADD_CODE (&td,MINT_ICALL_PPI_V);
-                                               else
-                                                       ADD_CODE (&td,MINT_ICALL_PPP_V);
-                                               break;
-                                       default:
-                                               g_assert_not_reached ();
-                                       }
-
-                                       if (func == mono_ftnptr_to_delegate) {
-                                               g_error ("TODO: ?");
-                                               func = mono_interp_ftnptr_to_delegate;
-                                       }
-                                       ADD_CODE(&td, get_data_item_index (&td, func));
-                                       td.sp -= info->sig->param_count;
-
-                                       if (!MONO_TYPE_IS_VOID (info->sig->ret)) {
-                                               td.sp ++;
-                                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I);
-                                       }
-                                       break;
-                               }
-                       case CEE_MONO_VTADDR: {
-                               int size;
-                               CHECK_STACK (&td, 1);
-                               if (method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE)
-                                       size = mono_class_native_size(td.sp [-1].klass, NULL);
-                               else
-                                       size = mono_class_value_size(td.sp [-1].klass, NULL);
-                               size = (size + 7) & ~7;
-                               ADD_CODE(&td, MINT_VTRESULT);
-                               ADD_CODE(&td, 0);
-                               WRITE32(&td, &size);
-                               td.vt_sp -= size;
-                               ++td.ip;
-                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
-                               break;
-                       }
-                       case CEE_MONO_LDPTR:
-                       case CEE_MONO_CLASSCONST:
-                               token = read32 (td.ip + 1);
-                               td.ip += 5;
-                               ADD_CODE(&td, MINT_MONO_LDPTR);
-                               ADD_CODE(&td, get_data_item_index (&td, mono_method_get_wrapper_data (method, token)));
-                               td.sp [0].type = STACK_TYPE_I;
-                               ++td.sp;
-                               break;
-                       case CEE_MONO_OBJADDR:
-                               CHECK_STACK (&td, 1);
-                               ++td.ip;
-                               td.sp[-1].type = STACK_TYPE_MP;
-                               /* do nothing? */
-                               break;
-                       case CEE_MONO_NEWOBJ:
-                               token = read32 (td.ip + 1);
-                               td.ip += 5;
-                               ADD_CODE(&td, MINT_MONO_NEWOBJ);
-                               ADD_CODE(&td, get_data_item_index (&td, mono_method_get_wrapper_data (method, token)));
-                               td.sp [0].type = STACK_TYPE_O;
-                               ++td.sp;
-                               break;
-                       case CEE_MONO_RETOBJ:
-                               CHECK_STACK (&td, 1);
-                               token = read32 (td.ip + 1);
-                               td.ip += 5;
-                               ADD_CODE(&td, MINT_MONO_RETOBJ);
-                               td.sp--;
-
-                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
-                               
-                               /*stackval_from_data (signature->ret, frame->retval, sp->data.vt, signature->pinvoke);*/
-
-                               if (td.sp > td.stack)
-                                       g_warning ("CEE_MONO_RETOBJ: more values on stack: %d", td.sp-td.stack);
-                               break;
-                       case CEE_MONO_LDNATIVEOBJ:
-                               token = read32 (td.ip + 1);
-                               td.ip += 5;
-                               klass = (MonoClass *)mono_method_get_wrapper_data (method, token);
-                               g_assert(klass->valuetype);
-                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
-                               break;
-                       case CEE_MONO_SAVE_LMF:
-                       case CEE_MONO_RESTORE_LMF:
-                       case CEE_MONO_NOT_TAKEN:
-                               ++td.ip;
-                               break;
-                       case CEE_MONO_LDPTR_INT_REQ_FLAG:
-                               ADD_CODE (&td, MINT_MONO_LDPTR);
-                               ADD_CODE (&td, get_data_item_index (&td, mono_thread_interruption_request_flag ()));
-                               PUSH_TYPE (&td, STACK_TYPE_MP, NULL);
-                               ++td.ip;
-                               break;
-                       default:
-                               g_error ("transform.c: Unimplemented opcode: 0xF0 %02x at 0x%x\n", *td.ip, td.ip-header->code);
-                       }
-                       break;
-#if 0
-               case CEE_PREFIX7:
-               case CEE_PREFIX6:
-               case CEE_PREFIX5:
-               case CEE_PREFIX4:
-               case CEE_PREFIX3:
-               case CEE_PREFIX2:
-               case CEE_PREFIXREF: ves_abort(); break;
-#endif
-               /*
-                * Note: Exceptions thrown when executing a prefixed opcode need
-                * to take into account the number of prefix bytes (usually the
-                * throw point is just (ip - n_prefix_bytes).
-                */
-               case CEE_PREFIX1: 
-                       ++td.ip;
-                       switch (*td.ip) {
-#if 0
-                       case CEE_ARGLIST: ves_abort(); break;
-#endif
-                       case CEE_CEQ:
-                               CHECK_STACK(&td, 2);
-                               if (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_MP)
-                                       ADD_CODE(&td, MINT_CEQ_I4 + STACK_TYPE_I - STACK_TYPE_I4);
-                               else
-                                       ADD_CODE(&td, MINT_CEQ_I4 + td.sp [-1].type - STACK_TYPE_I4);
-                               --td.sp;
-                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                               ++td.ip;
-                               break;
-                       case CEE_CGT:
-                               CHECK_STACK(&td, 2);
-                               if (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_MP)
-                                       ADD_CODE(&td, MINT_CGT_I4 + STACK_TYPE_I - STACK_TYPE_I4);
-                               else
-                                       ADD_CODE(&td, MINT_CGT_I4 + td.sp [-1].type - STACK_TYPE_I4);
-                               --td.sp;
-                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                               ++td.ip;
-                               break;
-                       case CEE_CGT_UN:
-                               CHECK_STACK(&td, 2);
-                               if (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_MP)
-                                       ADD_CODE(&td, MINT_CGT_UN_I4 + STACK_TYPE_I - STACK_TYPE_I4);
-                               else
-                                       ADD_CODE(&td, MINT_CGT_UN_I4 + td.sp [-1].type - STACK_TYPE_I4);
-                               --td.sp;
-                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                               ++td.ip;
-                               break;
-                       case CEE_CLT:
-                               CHECK_STACK(&td, 2);
-                               if (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_MP)
-                                       ADD_CODE(&td, MINT_CLT_I4 + STACK_TYPE_I - STACK_TYPE_I4);
-                               else
-                                       ADD_CODE(&td, MINT_CLT_I4 + td.sp [-1].type - STACK_TYPE_I4);
-                               --td.sp;
-                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                               ++td.ip;
-                               break;
-                       case CEE_CLT_UN:
-                               CHECK_STACK(&td, 2);
-                               if (td.sp [-1].type == STACK_TYPE_O || td.sp [-1].type == STACK_TYPE_MP)
-                                       ADD_CODE(&td, MINT_CLT_UN_I4 + STACK_TYPE_I - STACK_TYPE_I4);
-                               else
-                                       ADD_CODE(&td, MINT_CLT_UN_I4 + td.sp [-1].type - STACK_TYPE_I4);
-                               --td.sp;
-                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_I4);
-                               ++td.ip;
-                               break;
-                       case CEE_LDVIRTFTN: /* fallthrough */
-                       case CEE_LDFTN: {
-                               MonoMethod *m;
-                               if (*td.ip == CEE_LDVIRTFTN) {
-                                       CHECK_STACK (&td, 1);
-                                       --td.sp;
-                               }
-                               token = read32 (td.ip + 1);
-                               if (method->wrapper_type != MONO_WRAPPER_NONE)
-                                       m = (MonoMethod *)mono_method_get_wrapper_data (method, token);
-                               else 
-                                       m = mono_get_method_full (image, token, NULL, generic_context);
-
-                               if (method->wrapper_type == MONO_WRAPPER_NONE && m->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
-                                       m = mono_marshal_get_synchronized_wrapper (m);
-
-                               ADD_CODE(&td, *td.ip == CEE_LDFTN ? MINT_LDFTN : MINT_LDVIRTFTN);
-                               ADD_CODE(&td, get_data_item_index (&td, mono_interp_get_runtime_method (domain, m, &error)));
-                               mono_error_cleanup (&error); /* FIXME: don't swallow the error */
-                               td.ip += 5;
-                               PUSH_SIMPLE_TYPE (&td, STACK_TYPE_F);
-                               break;
-                       }
-                       case CEE_LDARG:
-                               load_arg (&td, read16 (td.ip + 1));
-                               td.ip += 3;
-                               break;
-                       case CEE_LDARGA: {
-                               int n = read16 (td.ip + 1);
-                               if (n == 0 && signature->hasthis) {
-                                       g_error ("LDTHISA: NOPE");
-                                       ADD_CODE(&td, MINT_LDTHISA);
-                               }
-                               else {
-                                       ADD_CODE(&td, MINT_LDARGA);
-                                       ADD_CODE(&td, td.rtm->arg_offsets [n]); /* FIX for large offsets */
-                               }
-                               PUSH_SIMPLE_TYPE(&td, STACK_TYPE_MP);
-                               td.ip += 3;
-                               break;
-                       }
-                       case CEE_STARG:
-                               store_arg (&td, read16 (td.ip + 1));
-                               td.ip += 3;
-                               break;
-                       case CEE_LDLOC:
-                               load_local (&td, read16 (td.ip + 1));
-                               td.ip += 3;
-                               break;
-                       case CEE_LDLOCA:
-                               ADD_CODE(&td, MINT_LDLOCA_S);
-                               ADD_CODE(&td, td.rtm->local_offsets [read16 (td.ip + 1)]);
-                               PUSH_SIMPLE_TYPE(&td, STACK_TYPE_MP);
-                               td.ip += 3;
-                               break;
-                       case CEE_STLOC:
-                               store_local (&td, read16 (td.ip + 1));
-                               td.ip += 3;
-                               break;
-                       case CEE_LOCALLOC:
-                               CHECK_STACK (&td, 1);
-#if SIZEOF_VOID_P == 8
-                               if (td.sp [-1].type == STACK_TYPE_I8)
-                                       ADD_CODE(&td, MINT_CONV_I4_I8);
-#endif                         
-                               ADD_CODE(&td, MINT_LOCALLOC);
-                               if (td.sp != td.stack + 1)
-                                       g_warning("CEE_LOCALLOC: stack not empty");
-                               ++td.ip;
-                               SET_SIMPLE_TYPE(td.sp - 1, STACK_TYPE_MP);
-                               break;
-#if 0
-                       case CEE_UNUSED57: ves_abort(); break;
-                       case CEE_ENDFILTER: ves_abort(); break;
-#endif
-                       case CEE_UNALIGNED_:
-                               ++td.ip;
-                               /* FIX: should do something? */;
-                               break;
-                       case CEE_VOLATILE_:
-                               ++td.ip;
-                               /* FIX: should do something? */;
-                               break;
-                       case CEE_TAIL_:
-                               ++td.ip;
-                               /* FIX: should do something? */;
-                               break;
-                       case CEE_INITOBJ:
-                               CHECK_STACK(&td, 1);
-                               token = read32 (td.ip + 1);
-                               klass = mono_class_get_full (image, token, generic_context);
-                               ADD_CODE(&td, MINT_INITOBJ);
-                               i32 = mono_class_value_size (klass, NULL);
-                               WRITE32(&td, &i32);
-                               td.ip += 5;
-                               --td.sp;
-                               break;
-                       case CEE_CPBLK:
-                               CHECK_STACK(&td, 3);
-                               /* FIX? convert length to I8? */
-                               ADD_CODE(&td, MINT_CPBLK);
-                               td.sp -= 3;
-                               ++td.ip;
-                               break;
-                       case CEE_CONSTRAINED_:
-                               token = read32 (td.ip + 1);
-                               constrained_class = mono_class_get_full (image, token, generic_context);
-                               mono_class_init (constrained_class);
-                               td.ip += 5;
-                               break;
-                       case CEE_INITBLK:
-                               CHECK_STACK(&td, 3);
-                               ADD_CODE(&td, MINT_INITBLK);
-                               td.sp -= 3;
-                               break;
-#if 0
-                       case CEE_NO_:
-                               /* FIXME: implement */
-                               ip += 2;
-                               break;
-#endif
-                       case CEE_RETHROW:
-                               SIMPLE_OP (td, MINT_RETHROW);
-                               generating_code = 0;
-                               break;
-                       case CEE_SIZEOF: {
-                               gint32 size;
-                               token = read32 (td.ip + 1);
-                               td.ip += 5;
-                               if (mono_metadata_token_table (token) == MONO_TABLE_TYPESPEC) {
-                                       int align;
-                                       MonoType *type = mono_type_create_from_typespec (image, token);
-                                       size = mono_type_size (type, &align);
-                               } else {
-                                       guint32 align;
-                                       MonoClass *szclass = mono_class_get_full (image, token, generic_context);
-                                       mono_class_init (szclass);
-#if 0
-                                       if (!szclass->valuetype)
-                                               THROW_EX (mono_exception_from_name (mono_defaults.corlib, "System", "InvalidProgramException"), ip - 5);
-#endif
-                                       size = mono_class_value_size (szclass, &align);
-                               } 
-                               ADD_CODE(&td, MINT_LDC_I4);
-                               WRITE32(&td, &size);
-                               PUSH_SIMPLE_TYPE(&td, STACK_TYPE_I4);
-                               break;
-                       }
-#if 0
-                       case CEE_REFANYTYPE: ves_abort(); break;
-#endif
-                       default:
-                               g_error ("transform.c: Unimplemented opcode: 0xFE %02x (%s) at 0x%x\n", *td.ip, mono_opcode_name (256 + *td.ip), td.ip-header->code);
-                       }
-                       break;
-               default:
-                       g_error ("transform.c: Unimplemented opcode: %02x at 0x%x\n", *td.ip, td.ip-header->code);
-               }
-
-               if (td.new_ip - td.new_code != new_in_start_offset) 
-                       td.last_new_ip = td.new_code + new_in_start_offset;
-               else if (td.is_bb_start [td.in_start - td.il_code])
-                       td.is_bb_start [td.ip - td.il_code] = 1;
-                       
-               td.last_ip = td.in_start;
-       }
-
-       if (mono_interp_traceopt) {
-               const guint16 *p = td.new_code;
-               printf("Runtime method: %p, VT stack size: %d\n", rtm, td.max_vt_sp);
-               printf("Calculated stack size: %d, stated size: %d\n", td.max_stack_height, header->max_stack);
-               while (p < td.new_ip) {
-                       p = mono_interp_dis_mintop(td.new_code, p);
-                       printf("\n");
-               }
-       }
-
-       rtm->clauses = mono_mempool_alloc (domain->mp, header->num_clauses * sizeof(MonoExceptionClause));
-       memcpy (rtm->clauses, header->clauses, header->num_clauses * sizeof(MonoExceptionClause));
-       rtm->code = mono_mempool_alloc (domain->mp, (td.new_ip - td.new_code) * sizeof(gushort));
-       memcpy (rtm->code, td.new_code, (td.new_ip - td.new_code) * sizeof(gushort));
-       g_free (td.new_code);
-       rtm->new_body_start = rtm->code + body_start_offset;
-       rtm->num_clauses = header->num_clauses;
-       for (i = 0; i < header->num_clauses; i++) {
-               MonoExceptionClause *c = rtm->clauses + i;
-               int end_off = c->try_offset + c->try_len;
-               c->try_offset = td.in_offsets [c->try_offset];
-               c->try_len = td.in_offsets [end_off] - c->try_offset;
-               end_off = c->handler_offset + c->handler_len;
-               c->handler_offset = td.in_offsets [c->handler_offset];
-               c->handler_len = td.in_offsets [end_off] - c->handler_offset;
-       }
-       rtm->vt_stack_size = td.max_vt_sp;
-       rtm->alloca_size = rtm->locals_size + rtm->args_size + rtm->vt_stack_size + rtm->stack_size;
-       rtm->data_items = mono_mempool_alloc (domain->mp, td.n_data_items * sizeof (td.data_items [0]));
-       memcpy (rtm->data_items, td.data_items, td.n_data_items * sizeof (td.data_items [0]));
-       g_free (td.in_offsets);
-       g_free (td.forward_refs);
-       for (i = 0; i < header->code_size; ++i)
-               g_free (td.stack_state [i]);
-       g_free (td.stack_state);
-       g_free (td.stack_height);
-       g_free (td.vt_stack_size);
-       g_free (td.data_items);
-       g_hash_table_destroy (td.data_hash);
-}
-
-static mono_mutex_t calc_section;
-
-void 
-mono_interp_transform_init (void)
-{
-       mono_os_mutex_init_recursive(&calc_section);
-}
-
-MonoException *
-mono_interp_transform_method (RuntimeMethod *runtime_method, ThreadContext *context)
-{
-       int i, align, size, offset;
-       MonoMethod *method = runtime_method->method;
-       MonoImage *image = method->klass->image;
-       MonoMethodHeader *header = mono_method_get_header (method);
-       MonoMethodSignature *signature = mono_method_signature (method);
-       register const unsigned char *ip, *end;
-       const MonoOpcode *opcode;
-       MonoMethod *m;
-       MonoClass *class;
-       MonoDomain *domain = mono_domain_get ();
-       unsigned char *is_bb_start;
-       int in;
-       MonoVTable *method_class_vt;
-       int backwards;
-       MonoGenericContext *generic_context = NULL;
-
-       // g_printerr ("TRANSFORM(0x%016lx): begin %s::%s\n", mono_thread_current (), method->klass->name, method->name);
-       method_class_vt = mono_class_vtable (domain, runtime_method->method->klass);
-       if (!method_class_vt->initialized) {
-               jmp_buf env;
-               MonoInvocation *last_env_frame = context->env_frame;
-               jmp_buf *old_env = context->current_env;
-
-               if (setjmp(env)) {
-                       MonoException *failed = context->env_frame->ex;
-                       context->env_frame->ex = NULL;
-                       context->env_frame = last_env_frame;
-                       context->current_env = old_env;
-                       return failed;
-               }
-               context->env_frame = context->current_frame;
-               context->current_env = &env;
-               mono_runtime_class_init (method_class_vt);
-               context->env_frame = last_env_frame;
-               context->current_env = old_env;
-       }
-
-       mono_profiler_method_jit (method); /* sort of... */
-
-       if (mono_method_signature (method)->is_inflated)
-               generic_context = &((MonoMethodInflated *) method)->context;
-
-       if (method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME)) {
-               MonoMethod *nm = NULL;
-               mono_os_mutex_lock(&calc_section);
-               if (runtime_method->transformed) {
-                       mono_os_mutex_unlock(&calc_section);
-                       g_error ("FIXME: no jit info?");
-                       mono_profiler_method_end_jit (method, NULL, MONO_PROFILE_OK);
-                       return NULL;
-               }
-
-               /* assumes all internal calls with an array this are built in... */
-               if (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL && (! mono_method_signature (method)->hasthis || method->klass->rank == 0)) {
-                       nm = mono_marshal_get_native_wrapper (method, TRUE, FALSE);
-                       signature = mono_method_signature (nm);
-               } else {
-                       const char *name = method->name;
-                       if (method->klass->parent == mono_defaults.multicastdelegate_class) {
-                               if (*name == 'I' && (strcmp (name, "Invoke") == 0)) {
-                                       nm = mono_marshal_get_delegate_invoke (method, NULL);
-                               } else if (*name == 'B' && (strcmp (name, "BeginInvoke") == 0)) {
-                                       nm = mono_marshal_get_delegate_begin_invoke (method);
-                               } else if (*name == 'E' && (strcmp (name, "EndInvoke") == 0)) {
-                                       nm = mono_marshal_get_delegate_end_invoke (method);
-                               }
-                       } 
-                       if (nm == NULL) {
-                               runtime_method->code = g_malloc(sizeof(short));
-                               runtime_method->code[0] = MINT_CALLRUN;
-                       }
-               }
-               if (nm == NULL) {
-                       runtime_method->stack_size = sizeof (stackval); /* for tracing */
-                       runtime_method->alloca_size = runtime_method->stack_size;
-                       runtime_method->transformed = TRUE;
-                       mono_os_mutex_unlock(&calc_section);
-                       mono_profiler_method_end_jit (method, NULL, MONO_PROFILE_OK);
-                       return NULL;
-               }
-               method = nm;
-               header = mono_method_get_header (nm);
-               mono_os_mutex_unlock(&calc_section);
-       }
-       g_assert ((signature->param_count + signature->hasthis) < 1000);
-       g_assert (header->max_stack < 10000);
-       /* intern the strings in the method. */
-       ip = header->code;
-       end = ip + header->code_size;
-
-       is_bb_start = g_malloc0(header->code_size);
-       is_bb_start [0] = 1;
-       while (ip < end) {
-               in = *ip;
-               if (in == 0xfe) {
-                       ip++;
-                       in = *ip + 256;
-               }
-               else if (in == 0xf0) {
-                       ip++;
-                       in = *ip + MONO_CEE_MONO_ICALL;
-               }
-               opcode = &mono_opcodes [in];
-               switch (opcode->argument) {
-               case MonoInlineNone:
-                       ++ip;
-                       break;
-               case MonoInlineString:
-                       if (method->wrapper_type == MONO_WRAPPER_NONE)
-                               mono_ldstr (domain, image, mono_metadata_token_index (read32 (ip + 1)));
-                       ip += 5;
-                       break;
-               case MonoInlineType:
-                       if (method->wrapper_type == MONO_WRAPPER_NONE) {
-                               class = mono_class_get_full (image, read32 (ip + 1), generic_context);
-                               mono_class_init (class);
-                               /* quick fix to not do this for the fake ptr classes - probably should not be getting the vtable at all here */
-#if 0
-                               g_error ("FIXME: interface method lookup: %s (in method %s)", class->name, method->name);
-                               if (!(class->flags & TYPE_ATTRIBUTE_INTERFACE) && class->interface_offsets != NULL)
-                                       mono_class_vtable (domain, class);
-#endif
-                       }
-                       ip += 5;
-                       break;
-               case MonoInlineMethod:
-                       if (method->wrapper_type == MONO_WRAPPER_NONE && *ip != CEE_CALLI) {
-                               m = mono_get_method_full (image, read32 (ip + 1), NULL, generic_context);
-                               if (m == NULL) {
-                                       g_free (is_bb_start);
-                                       g_error ("FIXME: where to get method and class string?"); 
-                                       return NULL;
-                                       // return mono_get_exception_missing_method ();
-                               }
-                               mono_class_init (m->klass);
-                               if (!mono_class_is_interface (m->klass))
-                                       mono_class_vtable (domain, m->klass);
-                       }
-                       ip += 5;
-                       break;
-               case MonoInlineField:
-               case MonoInlineSig:
-               case MonoInlineI:
-               case MonoInlineTok:
-               case MonoShortInlineR:
-                       ip += 5;
-                       break;
-               case MonoInlineBrTarget:
-                       offset = read32 (ip + 1);
-                       ip += 5;
-                       backwards = offset < 0;
-                       offset += ip - header->code;
-                       g_assert (offset >= 0 && offset < header->code_size);
-                       is_bb_start [offset] |= backwards ? 2 : 1;
-                       break;
-               case MonoShortInlineBrTarget:
-                       offset = ((gint8 *)ip) [1];
-                       ip += 2;
-                       backwards = offset < 0;
-                       offset += ip - header->code;
-                       g_assert (offset >= 0 && offset < header->code_size);
-                       is_bb_start [offset] |= backwards ? 2 : 1;
-                       break;
-               case MonoInlineVar:
-                       ip += 3;
-                       break;
-               case MonoShortInlineVar:
-               case MonoShortInlineI:
-                       ip += 2;
-                       break;
-               case MonoInlineSwitch: {
-                       guint32 n;
-                       const unsigned char *next_ip;
-                       ++ip;
-                       n = read32 (ip);
-                       ip += 4;
-                       next_ip = ip + 4 * n;
-                       for (i = 0; i < n; i++) {
-                               offset = read32 (ip);
-                               backwards = offset < 0;
-                               offset += next_ip - header->code;
-                               g_assert (offset >= 0 && offset < header->code_size);
-                               is_bb_start [offset] |= backwards ? 2 : 1;
-                               ip += 4;
-                       }
-                       break;
-               }
-               case MonoInlineR:
-               case MonoInlineI8:
-                       ip += 9;
-                       break;
-               default:
-                       g_assert_not_reached ();
-               }
-       }
-       // g_printerr ("TRANSFORM(0x%016lx): end %s::%s\n", mono_thread_current (), method->klass->name, method->name);
-
-       /* the rest needs to be locked so it is only done once */
-       mono_os_mutex_lock(&calc_section);
-       if (runtime_method->transformed) {
-               mono_os_mutex_unlock(&calc_section);
-               g_free (is_bb_start);
-               mono_profiler_method_end_jit (method, NULL, MONO_PROFILE_OK);
-               return NULL;
-       }
-
-       runtime_method->local_offsets = g_malloc (header->num_locals * sizeof(guint32));
-       runtime_method->stack_size = (sizeof (stackval) + 2) * header->max_stack; /* + 1 for returns of called functions  + 1 for 0-ing in trace*/
-       runtime_method->stack_size = (runtime_method->stack_size + 7) & ~7;
-       offset = 0;
-       for (i = 0; i < header->num_locals; ++i) {
-               size = mono_type_size (header->locals [i], &align);
-               offset += align - 1;
-               offset &= ~(align - 1);
-               runtime_method->local_offsets [i] = offset;
-               offset += size;
-       }
-       offset = (offset + 7) & ~7;
-       runtime_method->locals_size = offset;
-       g_assert (runtime_method->locals_size < 65536);
-       offset = 0;
-       runtime_method->arg_offsets = g_malloc ((!!signature->hasthis + signature->param_count) * sizeof(guint32));
-
-       if (signature->hasthis) {
-               g_assert (!signature->pinvoke);
-               size = mono_type_stack_size (&method->klass->byval_arg, &align);
-               offset += align - 1;
-               offset &= ~(align - 1);
-               runtime_method->arg_offsets [0] = offset;
-               offset += size;
-       }
-
-       for (i = 0; i < signature->param_count; ++i) {
-               if (signature->pinvoke) {
-                       guint32 dummy;
-                       size = mono_type_native_stack_size (signature->params [i], &dummy);
-                       align = 8;
-               }
-               else
-                       size = mono_type_stack_size (signature->params [i], &align);
-               offset += align - 1;
-               offset &= ~(align - 1);
-               runtime_method->arg_offsets [i + !!signature->hasthis] = offset;
-               offset += size;
-       }
-       offset = (offset + 7) & ~7;
-       runtime_method->args_size = offset;
-       g_assert (runtime_method->args_size < 10000);
-
-       generate(method, runtime_method, is_bb_start);
-
-       g_free (is_bb_start);
-
-       mono_profiler_method_end_jit (method, NULL, MONO_PROFILE_OK);
-       runtime_method->transformed = TRUE;
-       mono_os_mutex_unlock(&calc_section);
-
-       return NULL;
-}
-
index cdd1c42ef491a6b772f6155f11bfd424dee7ffcd..cfdc728c0d019e49bf5b19d187be5919eb0d0465 100644 (file)
@@ -231,8 +231,7 @@ analyze_liveness_bb (MonoCompile *cfg, MonoBasicBlock *bb)
 
 #ifdef DEBUG_LIVENESS
                if (cfg->verbose_level > 1) {
-                       printf ("\t");
-                       mono_print_ins (ins);
+                       mono_print_ins_index (1, ins);
                }
 #endif
 
index e522e4e69b307283bbc94a0f1cdc15ee855a5959..5982e0c200851a771b00e243d5a71586c450c074 100644 (file)
@@ -348,14 +348,19 @@ mono_print_bb (MonoBasicBlock *bb, const char *msg)
 {
        int i;
        MonoInst *tree;
+       GString *str = g_string_new ("");
 
-       printf ("\n%s %d: [IN: ", msg, bb->block_num);
+       g_string_append_printf (str, "%s %d: [IN: ", msg, bb->block_num);
        for (i = 0; i < bb->in_count; ++i)
-               printf (" BB%d(%d)", bb->in_bb [i]->block_num, bb->in_bb [i]->dfn);
-       printf (", OUT: ");
+               g_string_append_printf (str, " BB%d(%d)", bb->in_bb [i]->block_num, bb->in_bb [i]->dfn);
+       g_string_append_printf (str, ", OUT: ");
        for (i = 0; i < bb->out_count; ++i)
-               printf (" BB%d(%d)", bb->out_bb [i]->block_num, bb->out_bb [i]->dfn);
-       printf (" ]\n");
+               g_string_append_printf (str, " BB%d(%d)", bb->out_bb [i]->block_num, bb->out_bb [i]->dfn);
+       g_string_append_printf (str, " ]\n");
+
+       g_print ("%s", str->str);
+       g_string_free (str, TRUE);
+
        for (tree = bb->code; tree; tree = tree->next)
                mono_print_ins_index (-1, tree);
 }
index 3ad91e31cd0dda930ff1206ef5690d9c1971b896..1884dc1d49d714d53444064d6e76947b989aedd0 100644 (file)
@@ -1902,7 +1902,7 @@ mono_arch_create_vars (MonoCompile *cfg)
        if (cfg->method->save_lmf) {
                cfg->create_lmf_var = TRUE;
                cfg->lmf_ir = TRUE;
-#ifndef TARGET_MACH
+#ifdef HAVE_GET_TLS_ADDR
                cfg->lmf_ir_mono_lmf = TRUE;
 #endif
        }
index e130eb59411d6d759ca059e13d4fff1c39a03365..272065388e6187182d90d5d35fe36d8d1f6730c9 100644 (file)
@@ -73,6 +73,7 @@
 #include "seq-points.h"
 #include "llvm-runtime.h"
 #include "mini-llvm.h"
+#include "interp/interp.h"
 
 #ifdef ENABLE_LLVM
 #include "mini-llvm-cpp.h"
@@ -220,7 +221,13 @@ mono_exceptions_init (void)
 #ifdef MONO_ARCH_HAVE_EXCEPTIONS_INIT
        mono_arch_exceptions_init ();
 #endif
-       cbs.mono_walk_stack_with_ctx = mono_runtime_walk_stack_with_ctx;
+#ifdef ENABLE_INTERPRETER
+       if (mono_use_interpreter)
+               cbs.mono_walk_stack_with_ctx = interp_walk_stack_with_ctx;
+       else
+#endif
+               cbs.mono_walk_stack_with_ctx = mono_runtime_walk_stack_with_ctx;
+
        cbs.mono_walk_stack_with_state = mono_walk_stack_with_state;
 
        if (mono_llvm_only)
index 2ebf1c7873ab04004be1be89d89ce522209c00fe..9336b94f2d2bcc0f5935fa09163f6f5bfb9e0098 100644 (file)
@@ -91,7 +91,7 @@
 #endif
 
 #ifdef ENABLE_INTERPRETER
-#include "interpreter/interp.h"
+#include "interp/interp.h"
 #endif
 
 static guint32 default_opt = 0;
@@ -3048,6 +3048,10 @@ mini_init_delegate (MonoDelegate *del)
 {
        if (mono_llvm_only)
                del->extra_arg = mini_get_delegate_arg (del->method, del->method_ptr);
+#ifdef ENABLE_INTERPRETER
+       if (mono_use_interpreter)
+               mono_interp_init_delegate (del);
+#endif
 }
 
 char*
index c01f6eaebf4ab2f3bb6f0ebf03c5ca0c4deb8b8b..92abc196e803e233adfa61969d631d8952492a9e 100644 (file)
@@ -1636,7 +1636,7 @@ no_delegate_trampoline (void)
 gpointer
 mono_create_delegate_trampoline (MonoDomain *domain, MonoClass *klass)
 {
-       if (mono_llvm_only)
+       if (mono_llvm_only || mono_use_interpreter)
                return no_delegate_trampoline;
 
        return mono_create_delegate_trampoline_info (domain, klass, NULL)->invoke_impl;
index 3aa8a24aaf45ad48caba52720f067ee06133f6ad..21fd43e7d437f0ed5689d9d63c455e19add2be50 100644 (file)
@@ -473,7 +473,6 @@ class Tests {
                return o.GetHashCode ();
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_0_unbox_trampoline2 () {
                int i = 12;
                object o = i;
@@ -623,7 +622,6 @@ class Tests {
                return 0;
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_0_multi_array_cast () {
                Duper[,] d = new Duper [1, 1];
                object[,] o = d;
@@ -876,6 +874,23 @@ class Tests {
                return 2;
        }
 
+       class InstanceDelegateTest {
+               public int a;
+
+               public int return_field () {
+                       return a;
+               }
+       }
+
+       public static int test_2_instance_delegate_with_field () {
+               InstanceDelegateTest t = new InstanceDelegateTest () { a = 1337 };
+               GetIntDel del = new GetIntDel (t.return_field);
+               int v = del ();
+               if (v != 1337)
+                       return 0;
+               return 2;
+       }
+
        interface IFaceVirtualDel {
                int return_field ();
        }
@@ -890,21 +905,18 @@ class Tests {
                }
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_42_vtype_delegate () {
                var s = new VtypeVirtualDelStruct () { f = 42 };
                Func<int> f = s.return_field_nonvirt;
                return f ();
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_42_vtype_virtual_delegate () {
                IFaceVirtualDel s = new VtypeVirtualDelStruct () { f = 42 };
                Func<int> f = s.return_field;
                return f ();
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_1_store_decimal () {
                decimal[,] a = {{1}};
 
@@ -1423,7 +1435,6 @@ ncells ) {
                return 0;
        }
 
-       [Category ("!INTERPRETER")]
        static int test_0_array_get_set_soft_float () {
                float[,] arr = new float [2, 2];
                arr [0, 0] = 256f;
@@ -1584,7 +1595,6 @@ ncells ) {
                return mInstance;
        }
 
-       [Category ("!INTERPRETER")]
        static int test_0_synchronized () {
                getInstance ();
                return 0;
@@ -1753,7 +1763,6 @@ ncells ) {
                }
        }
 
-       [Category ("!INTERPRETER")]
        public static int test_0_delegate_to_virtual_generic_on_ifaces () {
                IComparer2 c = new AClass ();
 
@@ -1776,7 +1785,6 @@ ncells ) {
 
        enum Mine { One, Two }
 
-       [Category ("!INTERPRETER")]
        public static int test_0_enum_gethashcode_opt () {
                int sum = 0;
         for (int i = 0; i < 1000000; ++i)
index a0294d7dd462a2db2c3efcfee3057d053844ab27..623783262034c2a9d18540b85dedffb41ef139a4 100644 (file)
@@ -223,6 +223,8 @@ mono_save_seq_point_info (MonoCompile *cfg)
                }
        }
 
+       g_free (seq_points);
+
        if (has_debug_data)
                g_free (next);
 
index b143645fb7d83c9d70d04ac4e9f6d2f9d81b9ded..b2b7a7fc5fd556eb43ea7c2332876cba6446856e 100644 (file)
@@ -982,80 +982,144 @@ gpointer
 mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info)
 {
 #ifdef ENABLE_INTERPRETER
-       const int gregs_num = 6;
-       guint8 *start = NULL, *code, *exits [gregs_num], *leave_tramp;
+       const int gregs_num = 8;
+       const int fregs_num = 3;
+       guint8 *start = NULL, *code, *label_gexits [gregs_num], *label_fexits [fregs_num], *label_leave_tramp [3], *label_is_float_ret;
        MonoJumpInfo *ji = NULL;
        GSList *unwind_ops = NULL;
-       static int arg_regs[] = {AMD64_ARG_REG1, AMD64_ARG_REG2, AMD64_ARG_REG3, AMD64_ARG_REG4, AMD64_R8, AMD64_R9};
-       int i, offset = 0;
+       static int farg_regs[] = {AMD64_XMM0, AMD64_XMM1, AMD64_XMM2};
+       int i, framesize = 0, off_rbp, off_methodargs, off_targetaddr;
 
        start = code = (guint8 *) mono_global_codeman_reserve (256);
 
+       off_rbp = -framesize;
+
+       framesize += sizeof (mgreg_t);
+       off_methodargs = -framesize;
+
+       framesize += sizeof (mgreg_t);
+       off_targetaddr = -framesize;
+
+       framesize += (gregs_num - PARAM_REGS) * sizeof (mgreg_t);
+
+       amd64_push_reg (code, AMD64_RBP);
+       amd64_mov_reg_reg (code, AMD64_RBP, AMD64_RSP, sizeof (mgreg_t));
+       amd64_alu_reg_imm (code, X86_SUB, AMD64_RSP, ALIGN_TO (framesize, MONO_ARCH_FRAME_ALIGNMENT));
+
        /* save MethodArguments* onto stack */
-       amd64_push_reg (code, AMD64_ARG_REG2);
+       amd64_mov_membase_reg (code, AMD64_RBP, off_methodargs, AMD64_ARG_REG2, sizeof (mgreg_t));
 
        /* save target address on stack */
-       amd64_push_reg (code, AMD64_ARG_REG1);
-       amd64_push_reg (code, AMD64_RAX);
+       amd64_mov_membase_reg (code, AMD64_RBP, off_targetaddr, AMD64_ARG_REG1, sizeof (mgreg_t));
 
        /* load pointer to MethodArguments* into R11 */
        amd64_mov_reg_reg (code, AMD64_R11, AMD64_ARG_REG2, 8);
        
-       /* TODO: do float stuff first */
+       /* move flen into RAX */ // TODO: struct offset
+       amd64_mov_reg_membase (code, AMD64_RAX, AMD64_R11, 16, sizeof (mgreg_t));
+       /* load pointer to fregs into R11 */ // TODO: struct offset
+       amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 24, sizeof (mgreg_t));
+
+       for (i = 0; i < fregs_num; ++i) {
+               amd64_test_reg_reg (code, AMD64_RAX, AMD64_RAX);
+               label_fexits [i] = code;
+               x86_branch8 (code, X86_CC_Z, 0, FALSE);
 
+               amd64_sse_movsd_reg_membase (code, farg_regs [i], AMD64_R11, i * sizeof (double));
+               amd64_dec_reg_size (code, AMD64_RAX, 1);
+       }
+
+       for (i = 0; i < fregs_num; i++) {
+               x86_patch (label_fexits [i], code);
+       }
+
+       /* load pointer to MethodArguments* into R11 */
+       amd64_mov_reg_reg (code, AMD64_R11, AMD64_ARG_REG2, sizeof (mgreg_t));
        /* move ilen into RAX */ // TODO: struct offset
-       amd64_mov_reg_membase (code, AMD64_RAX, AMD64_R11, 0, 8);
-       /* load pointer to iregs into R11 */ // TODO: struct offset
-       amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 8, 8);
+       amd64_mov_reg_membase (code, AMD64_RAX, AMD64_R11, 0, sizeof (mgreg_t));
 
+       int stack_offset = 0;
        for (i = 0; i < gregs_num; i++) {
                amd64_test_reg_reg (code, AMD64_RAX, AMD64_RAX);
-               exits [i] = code;
-               x86_branch8 (code, X86_CC_Z, 0, FALSE);
+               label_gexits [i] = code;
+               x86_branch32 (code, X86_CC_Z, 0, FALSE);
 
-#ifdef TARGET_WIN32
-               if (i < 4) {
-#else
-               if (i < 6) {
-#endif
-                       amd64_mov_reg_membase (code, arg_regs [i], AMD64_R11, i * sizeof (gpointer), 8);
+               /* load pointer to MethodArguments* into R11 */
+               amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, off_methodargs, sizeof (mgreg_t));
+               /* load pointer to iregs into R11 */ // TODO: struct offset
+               amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 8, sizeof (mgreg_t));
+
+               if (i < PARAM_REGS) {
+                       amd64_mov_reg_membase (code, param_regs [i], AMD64_R11, i * sizeof (mgreg_t), sizeof (mgreg_t));
                } else {
-                       g_error ("not tested yet.");
-                       amd64_push_reg (code, AMD64_RAX);
-                       amd64_mov_reg_membase (code, AMD64_RAX, AMD64_R11, i * sizeof (gpointer), 8);
-                       amd64_mov_membase_reg (code, AMD64_RBP, offset, AMD64_RAX, sizeof (gpointer));
-                       offset += sizeof (gpointer);
-                       amd64_pop_reg (code, AMD64_RAX);
+                       amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, i * sizeof (mgreg_t), sizeof (mgreg_t));
+                       amd64_mov_membase_reg (code, AMD64_RSP, stack_offset, AMD64_R11, sizeof (mgreg_t));
+                       stack_offset += sizeof (mgreg_t);
                }
                amd64_dec_reg_size (code, AMD64_RAX, 1);
        }
 
        for (i = 0; i < gregs_num; i++) {
-               x86_patch (exits [i], code);
+               x86_patch (label_gexits [i], code);
        }
 
-
-       amd64_pop_reg (code, AMD64_RAX);
-       amd64_pop_reg (code, AMD64_R11);
+       /* load target addr */
+       amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, off_targetaddr, sizeof (mgreg_t));
 
        /* call into native function */
        amd64_call_reg (code, AMD64_R11);
 
        /* load MethodArguments */
-       amd64_pop_reg (code, AMD64_R11);
+       amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, off_methodargs, sizeof (mgreg_t));
+
+       /* load is_float_ret */ // TODO: struct offset
+       amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 0x28, sizeof (mgreg_t));
+
+       /* check if a float return value is expected */
+       amd64_test_reg_reg (code, AMD64_R11, AMD64_R11);
+
+       label_is_float_ret = code;
+       x86_branch8 (code, X86_CC_NZ, 0, FALSE);
+
+
+
+       /* greg return */
+       /* load MethodArguments */
+       amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, off_methodargs, sizeof (mgreg_t));
        /* load retval */ // TODO: struct offset
-       amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 0x20, 8);
+       amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 0x20, sizeof (mgreg_t));
 
        amd64_test_reg_reg (code, AMD64_R11, AMD64_R11);
-       leave_tramp = code;
+       label_leave_tramp [0] = code;
        x86_branch8 (code, X86_CC_Z, 0, FALSE);
 
-       amd64_mov_membase_reg (code, AMD64_R11, 0, AMD64_RAX, 8);
+       amd64_mov_membase_reg (code, AMD64_R11, 0, AMD64_RAX, sizeof (mgreg_t));
 
-       x86_patch (leave_tramp, code);
-       amd64_ret (code);
+       label_leave_tramp [1] = code;
+       x86_jump8 (code, 0);
 
 
+
+       /* freg return */
+       x86_patch (label_is_float_ret, code);
+       /* load MethodArguments */
+       amd64_mov_reg_membase (code, AMD64_R11, AMD64_RBP, off_methodargs, sizeof (mgreg_t));
+       /* load retval */ // TODO: struct offset
+       amd64_mov_reg_membase (code, AMD64_R11, AMD64_R11, 0x20, sizeof (mgreg_t));
+
+       amd64_test_reg_reg (code, AMD64_R11, AMD64_R11);
+       label_leave_tramp [2] = code;
+       x86_branch8 (code, X86_CC_Z, 0, FALSE);
+
+       amd64_sse_movsd_membase_reg (code, AMD64_R11, 0, AMD64_XMM0);
+
+       for (i = 0; i < 3; i++)
+               x86_patch (label_leave_tramp [i], code);
+
+       amd64_alu_reg_imm (code, X86_ADD, AMD64_RSP, ALIGN_TO (framesize, MONO_ARCH_FRAME_ALIGNMENT));
+       amd64_pop_reg (code, AMD64_RBP);
+       amd64_ret (code);
+
        mono_arch_flush_icache (start, code - start);
        mono_profiler_code_buffer_new (start, code - start, MONO_PROFILER_CODE_BUFFER_EXCEPTION_HANDLING, NULL);
 
index 62039f7267901a805e94c8e1fb79c4c7c72a9dca..dc9b091bf6f95262b3dd0bec4a1903c88576e3d7 100644 (file)
@@ -93,6 +93,9 @@ MonoGCDescriptor mono_gc_make_descr_for_array (int vector, gsize *elem_bitmap, i
 /* simple interface for data structures needed in the runtime */
 MonoGCDescriptor mono_gc_make_descr_from_bitmap (gsize *bitmap, int numbits);
 
+/* Return a root descriptor for a vector with repeating refs bitmap */
+MonoGCDescriptor mono_gc_make_vector_descr (void);
+
 /* Return a root descriptor for a root with all refs */
 MonoGCDescriptor mono_gc_make_root_descr_all_refs (int numbits);
 
index cf89aedad4f5f7e10c46216141c0bc81ae4d8a9a..0138669a78897f120a97561e8f96b22edb5cfa57 100644 (file)
@@ -412,6 +412,7 @@ sgen_card_table_clear_cards (void)
        /*XXX we could do this in 2 ways. using mincore or iterating over all sections/los objects */
        sgen_major_collector_iterate_block_ranges (clear_cards);
        sgen_los_iterate_live_block_ranges (clear_cards);
+       sgen_wbroots_iterate_live_block_ranges (clear_cards);
 }
 
 static void
@@ -433,6 +434,7 @@ sgen_card_table_scan_remsets (ScanCopyContext ctx)
        /*First we copy*/
        sgen_major_collector_iterate_block_ranges (move_cards_to_shadow_table);
        sgen_los_iterate_live_block_ranges (move_cards_to_shadow_table);
+       sgen_wbroots_iterate_live_block_ranges (move_cards_to_shadow_table);
 
        /*Then we clear*/
        sgen_card_table_clear_cards ();
@@ -446,6 +448,8 @@ sgen_card_table_scan_remsets (ScanCopyContext ctx)
        SGEN_TV_GETTIME (atv);
        last_los_scan_time = SGEN_TV_ELAPSED (btv, atv);
        los_card_scan_time += last_los_scan_time;
+
+       sgen_wbroots_scan_card_table (ctx);
 }
 
 guint8*
@@ -488,6 +492,67 @@ sgen_card_table_dump_obj_card (GCObject *object, size_t size, void *dummy)
 }
 #endif
 
+/*
+ * Cardtable scanning
+ */
+
+#define MWORD_MASK (sizeof (mword) - 1)
+
+static inline int
+find_card_offset (mword card)
+{
+/*XXX Use assembly as this generates some pretty bad code */
+#if (defined(__i386__) || defined(__arm__)) && defined(__GNUC__)
+       return  (__builtin_ffs (card) - 1) / 8;
+#elif (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__)
+       return (__builtin_ffsll (card) - 1) / 8;
+#elif defined(__s390x__)
+       return (__builtin_ffsll (GUINT64_TO_LE(card)) - 1) / 8;
+#else
+       int i;
+       guint8 *ptr = (guint8 *) &card;
+       for (i = 0; i < sizeof (mword); ++i) {
+               if (ptr[i])
+                       return i;
+       }
+       return 0;
+#endif
+}
+
+guint8*
+sgen_find_next_card (guint8 *card_data, guint8 *end)
+{
+       mword *cards, *cards_end;
+       mword card;
+
+       while ((((mword)card_data) & MWORD_MASK) && card_data < end) {
+               if (*card_data)
+                       return card_data;
+               ++card_data;
+       }
+
+       if (card_data == end)
+               return end;
+
+       cards = (mword*)card_data;
+       cards_end = (mword*)((mword)end & ~MWORD_MASK);
+       while (cards < cards_end) {
+               card = *cards;
+               if (card)
+                       return (guint8*)cards + find_card_offset (card);
+               ++cards;
+       }
+
+       card_data = (guint8*)cards_end;
+       while (card_data < end) {
+               if (*card_data)
+                       return card_data;
+               ++card_data;
+       }
+
+       return end;
+}
+
 void
 sgen_cardtable_scan_object (GCObject *obj, mword block_obj_size, guint8 *cards, ScanCopyContext ctx)
 {
index 059fb77fa64925d61f73ff1311c1f7b979b7343e..a4fa1e32b6e91b2be1b3f281c21172bdbed6744c 100644 (file)
@@ -9,6 +9,7 @@
 
 /*WARNING: This function returns the number of cards regardless of overflow in case of overlapping cards.*/
 mword sgen_card_table_number_of_cards_in_range (mword address, mword size);
+guint8* sgen_find_next_card (guint8 *card_data, guint8 *end);
 
 void sgen_card_table_reset_region (mword start, mword end);
 void* sgen_card_table_align_pointer (void *ptr);
index 195894f8cbf1eecfa6997df325edc00fd9caf643..a78fb3dad57e7b8d3d3d31671ba54a5d24a13f05 100644 (file)
@@ -804,6 +804,15 @@ scan_roots_for_specific_ref (GCObject *key, int root_type)
                        }
                        break;
                }
+               case ROOT_DESC_VECTOR: {
+                       void **p;
+
+                       for (p = start_root; p < (void**)root->end_root; p++) {
+                               if (*p)
+                                       check_root_obj_specific_ref (root, key, (GCObject *)*p);
+                       }
+                       break;
+               }
                case ROOT_DESC_USER: {
                        SgenUserRootMarkFunc marker = sgen_get_user_descriptor_func (desc);
                        marker (start_root, check_root_obj_specific_ref_from_marker, NULL);
@@ -908,6 +917,15 @@ sgen_scan_for_registered_roots_in_domain (MonoDomain *domain, int root_type)
                        }
                        break;
                }
+               case ROOT_DESC_VECTOR: {
+                       void **p;
+
+                       for (p = start_root; p < (void**)root->end_root; p++) {
+                               if (*p)
+                                       check_obj_not_in_domain ((MonoObject **)*p);
+                       }
+                       break;
+               }
                case ROOT_DESC_USER: {
                        SgenUserRootMarkFunc marker = sgen_get_user_descriptor_func (desc);
                        marker (start_root, check_obj_not_in_domain_callback, NULL);
index 248b07b8f50fff935da561c90488a52af682ac17..f358c9da42977d736172a2d3fe15b8798ecf6970 100644 (file)
@@ -275,6 +275,12 @@ mono_gc_make_descr_from_bitmap (gsize *bitmap, int numbits)
        }
 }
 
+SgenDescriptor
+mono_gc_make_vector_descr (void)
+{
+       return MAKE_ROOT_DESC (ROOT_DESC_VECTOR, 0);
+}
+
 SgenDescriptor
 mono_gc_make_root_descr_all_refs (int numbits)
 {
index 54e1b7681fbe3fbb48a3c5385888b8b0d3567922..e072ca45d3267c1e21108f9eaafd7d33c0a62767 100644 (file)
@@ -114,6 +114,7 @@ enum {
        ROOT_DESC_BITMAP,
        ROOT_DESC_RUN_LEN, 
        ROOT_DESC_COMPLEX,
+       ROOT_DESC_VECTOR,
        ROOT_DESC_USER,
        ROOT_DESC_TYPE_MASK = 0x7,
        ROOT_DESC_TYPE_SHIFT = 3,
index 7c02172c6ee188b91fd9ded6a42c49a6d24d70a7..ec27de4224b9520a93998439738af18de6bbf08d 100644 (file)
@@ -858,6 +858,7 @@ static void
 precisely_scan_objects_from (void** start_root, void** end_root, char* n_start, char *n_end, SgenDescriptor desc, ScanCopyContext ctx)
 {
        CopyOrMarkObjectFunc copy_func = ctx.ops->copy_or_mark_object;
+       ScanPtrFieldFunc scan_field_func = ctx.ops->scan_ptr_field;
        SgenGrayQueue *queue = ctx.queue;
 
        switch (desc & ROOT_DESC_TYPE_MASK) {
@@ -892,6 +893,15 @@ precisely_scan_objects_from (void** start_root, void** end_root, char* n_start,
                }
                break;
        }
+       case ROOT_DESC_VECTOR: {
+               void **p;
+
+               for (p = start_root; p < end_root; p++) {
+                       if (*p)
+                               scan_field_func (NULL, (GCObject**)p, queue);
+               }
+               break;
+       }
        case ROOT_DESC_USER: {
                SgenUserRootMarkFunc marker = sgen_get_user_descriptor_func (desc);
                marker (start_root, single_arg_user_copy_or_mark, &ctx);
@@ -1481,13 +1491,16 @@ enqueue_scan_from_roots_jobs (SgenGrayQueue *gc_thread_gray_queue, char *heap_st
        scrrj->root_type = ROOT_TYPE_NORMAL;
        sgen_workers_enqueue_job (&scrrj->scan_job.job, enqueue);
 
-       scrrj = (ScanFromRegisteredRootsJob*)sgen_thread_pool_job_alloc ("scan from registered roots wbarrier", job_scan_from_registered_roots, sizeof (ScanFromRegisteredRootsJob));
-       scrrj->scan_job.ops = ops;
-       scrrj->scan_job.gc_thread_gray_queue = gc_thread_gray_queue;
-       scrrj->heap_start = heap_start;
-       scrrj->heap_end = heap_end;
-       scrrj->root_type = ROOT_TYPE_WBARRIER;
-       sgen_workers_enqueue_job (&scrrj->scan_job.job, enqueue);
+       if (current_collection_generation == GENERATION_OLD) {
+               /* During minors we scan the cardtable for these roots instead */
+               scrrj = (ScanFromRegisteredRootsJob*)sgen_thread_pool_job_alloc ("scan from registered roots wbarrier", job_scan_from_registered_roots, sizeof (ScanFromRegisteredRootsJob));
+               scrrj->scan_job.ops = ops;
+               scrrj->scan_job.gc_thread_gray_queue = gc_thread_gray_queue;
+               scrrj->heap_start = heap_start;
+               scrrj->heap_end = heap_end;
+               scrrj->root_type = ROOT_TYPE_WBARRIER;
+               sgen_workers_enqueue_job (&scrrj->scan_job.job, enqueue);
+       }
 
        /* Threads */
 
@@ -2599,6 +2612,94 @@ sgen_deregister_root (char* addr)
        UNLOCK_GC;
 }
 
+void
+sgen_wbroots_iterate_live_block_ranges (sgen_cardtable_block_callback cb)
+{
+       void **start_root;
+       RootRecord *root;
+       SGEN_HASH_TABLE_FOREACH (&roots_hash [ROOT_TYPE_WBARRIER], void **, start_root, RootRecord *, root) {
+               cb ((mword)start_root, (mword)root->end_root - (mword)start_root);
+       } SGEN_HASH_TABLE_FOREACH_END;
+}
+
+/* Root equivalent of sgen_client_cardtable_scan_object */
+static void
+sgen_wbroot_scan_card_table (void** start_root, mword size,  ScanCopyContext ctx)
+{
+       ScanPtrFieldFunc scan_field_func = ctx.ops->scan_ptr_field;
+       guint8 *card_data = sgen_card_table_get_card_scan_address ((mword)start_root);
+       guint8 *card_base = card_data;
+       mword card_count = sgen_card_table_number_of_cards_in_range ((mword)start_root, size);
+       guint8 *card_data_end = card_data + card_count;
+       mword extra_idx = 0;
+       char *obj_start = sgen_card_table_align_pointer (start_root);
+       char *obj_end = (char*)start_root + size;
+#ifdef SGEN_HAVE_OVERLAPPING_CARDS
+       guint8 *overflow_scan_end = NULL;
+#endif
+
+#ifdef SGEN_HAVE_OVERLAPPING_CARDS
+       /*Check for overflow and if so, setup to scan in two steps*/
+       if (card_data_end >= SGEN_SHADOW_CARDTABLE_END) {
+               overflow_scan_end = sgen_shadow_cardtable + (card_data_end - SGEN_SHADOW_CARDTABLE_END);
+               card_data_end = SGEN_SHADOW_CARDTABLE_END;
+       }
+
+LOOP_HEAD:
+#endif
+
+       card_data = sgen_find_next_card (card_data, card_data_end);
+
+       for (; card_data < card_data_end; card_data = sgen_find_next_card (card_data + 1, card_data_end)) {
+               size_t idx = (card_data - card_base) + extra_idx;
+               char *start = (char*)(obj_start + idx * CARD_SIZE_IN_BYTES);
+               char *card_end = start + CARD_SIZE_IN_BYTES;
+               char *elem = start, *first_elem = start;
+
+               /*
+                * Don't clean first and last card on 32bit systems since they
+                * may also be part from other roots.
+                */
+               if (card_data != card_base && card_data != (card_data_end - 1))
+                       sgen_card_table_prepare_card_for_scanning (card_data);
+
+               card_end = MIN (card_end, obj_end);
+
+               if (elem < (char*)start_root)
+                       first_elem = elem = (char*)start_root;
+
+               for (; elem < card_end; elem += SIZEOF_VOID_P) {
+                       if (*(GCObject**)elem)
+                               scan_field_func (NULL, (GCObject**)elem, ctx.queue);
+               }
+
+               binary_protocol_card_scan (first_elem, elem - first_elem);
+       }
+
+#ifdef SGEN_HAVE_OVERLAPPING_CARDS
+       if (overflow_scan_end) {
+               extra_idx = card_data - card_base;
+               card_base = card_data = sgen_shadow_cardtable;
+               card_data_end = overflow_scan_end;
+               overflow_scan_end = NULL;
+               goto LOOP_HEAD;
+       }
+#endif
+}
+
+void
+sgen_wbroots_scan_card_table (ScanCopyContext ctx)
+{
+       void **start_root;
+       RootRecord *root;
+
+       SGEN_HASH_TABLE_FOREACH (&roots_hash [ROOT_TYPE_WBARRIER], void **, start_root, RootRecord *, root) {
+               SGEN_ASSERT (0, (root->root_desc & ROOT_DESC_TYPE_MASK) == ROOT_DESC_VECTOR, "Unsupported root type");
+
+               sgen_wbroot_scan_card_table (start_root, (mword)root->end_root - (mword)start_root, ctx);
+       } SGEN_HASH_TABLE_FOREACH_END;
+}
+
 /*
  * ######################################################################
  * ########  Thread handling (stop/start code)
index ba7aee729406a55f2ae6bde264d7219e9e349620..a89a5471dd729c563d09721fcd4a5bd9ccdadf68 100644 (file)
@@ -832,6 +832,9 @@ void sgen_finalize_if (SgenObjectPredicateFunc predicate, void *user_data);
 void sgen_remove_finalizers_if (SgenObjectPredicateFunc predicate, void *user_data, int generation);
 void sgen_set_suspend_finalizers (void);
 
+void sgen_wbroots_iterate_live_block_ranges (sgen_cardtable_block_callback cb);
+void sgen_wbroots_scan_card_table (ScanCopyContext ctx);
+
 void sgen_register_disappearing_link (GCObject *obj, void **link, gboolean track, gboolean in_gc);
 
 GCObject* sgen_weak_link_get (void **link_addr);
index 6eb4d266fdc16d423a5ef48398c1cb7dec3e2a59..98d8917593cd385d6f77c5bdfed4facb5e96ef63 100644 (file)
@@ -240,7 +240,7 @@ SCAN_OBJECT_FUNCTION_NAME (GCObject *full_object, SgenDescriptor desc, SgenGrayQ
                GCObject *__old = *(ptr);                               \
                binary_protocol_scan_process_reference ((full_object), (ptr), __old); \
                if (__old && !sgen_ptr_in_nursery (__old)) {            \
-                       if (G_UNLIKELY (!sgen_ptr_in_nursery (ptr) &&   \
+                       if (G_UNLIKELY (full_object && !sgen_ptr_in_nursery (ptr) && \
                                        sgen_safe_object_is_small (__old, sgen_obj_get_descriptor (__old) & DESC_TYPE_MASK) && \
                                        major_block_is_evacuating (MS_BLOCK_FOR_OBJ (__old)))) { \
                                mark_mod_union_card ((full_object), (void**)(ptr), __old); \
@@ -249,7 +249,7 @@ SCAN_OBJECT_FUNCTION_NAME (GCObject *full_object, SgenDescriptor desc, SgenGrayQ
                                COPY_OR_MARK_FUNCTION_NAME ((ptr), __old, queue); \
                        }                                               \
                } else {                                                \
-                       if (G_UNLIKELY (sgen_ptr_in_nursery (__old) && !sgen_ptr_in_nursery ((ptr)) && !sgen_cement_is_forced (__old))) \
+                       if (G_UNLIKELY (full_object && sgen_ptr_in_nursery (__old) && !sgen_ptr_in_nursery ((ptr)) && !sgen_cement_is_forced (__old))) \
                                mark_mod_union_card ((full_object), (void**)(ptr), __old); \
                        }                                               \
                } while (0)
@@ -261,7 +261,7 @@ SCAN_OBJECT_FUNCTION_NAME (GCObject *full_object, SgenDescriptor desc, SgenGrayQ
                        PREFETCH_READ (__old);                  \
                        COPY_OR_MARK_FUNCTION_NAME ((ptr), __old, queue); \
                } else {                                                \
-                       if (G_UNLIKELY (sgen_ptr_in_nursery (__old) && !sgen_ptr_in_nursery ((ptr)) && !sgen_cement_is_forced (__old))) \
+                       if (G_UNLIKELY (full_object && sgen_ptr_in_nursery (__old) && !sgen_ptr_in_nursery ((ptr)) && !sgen_cement_is_forced (__old))) \
                                mark_mod_union_card ((full_object), (void**)(ptr), __old); \
                        }                                               \
                } while (0)
@@ -310,6 +310,12 @@ SCAN_VTYPE_FUNCTION_NAME (GCObject *full_object, char *start, SgenDescriptor des
 static void
 SCAN_PTR_FIELD_FUNCTION_NAME (GCObject *full_object, GCObject **ptr, SgenGrayQueue *queue)
 {
+       /*
+        * full_object is NULL if we scan unmanaged memory. This means we can't mark
+        * mod unions for it, so these types of roots currently don't have support
+        * for the concurrent collector (aka they need to be scanned as normal roots
+        * both in the start and finishing pause)
+        */
        HANDLE_PTR (ptr, NULL);
 }
 #endif
index b280749a46a3dd8f9d045cd6de5e6ae7ee4a7e16..5c4ec06a9ebda9b21afd80477086a42fe303ba00 100644 (file)
@@ -2809,6 +2809,7 @@ sgen_marksweep_init_internal (SgenMajorCollector *collector, gboolean is_concurr
 
        collector->major_ops_serial.copy_or_mark_object = major_copy_or_mark_object_canonical;
        collector->major_ops_serial.scan_object = major_scan_object_with_evacuation;
+       collector->major_ops_serial.scan_ptr_field = major_scan_ptr_field_with_evacuation;
        collector->major_ops_serial.drain_gray_stack = drain_gray_stack;
        if (is_concurrent) {
                collector->major_ops_concurrent_start.copy_or_mark_object = major_copy_or_mark_object_concurrent_canonical;
index 9b92493191ed1a08bad915c7ab7df8ecd6a5fcb5..9f5fd6addb19608c19acb1a7549eecf7000af369 100644 (file)
@@ -114,7 +114,7 @@ mono_conc_hashtable_new (GHashFunc hash_func, GEqualFunc key_equal_func)
 {
        MonoConcurrentHashTable *res = g_new0 (MonoConcurrentHashTable, 1);
        res->hash_func = hash_func ? hash_func : g_direct_hash;
-       res->equal_func = key_equal_func ? key_equal_func : g_direct_equal;
+       res->equal_func = key_equal_func;
        // res->equal_func = g_direct_equal;
        res->table = conc_table_new (INITIAL_SIZE);
        res->element_count = 0;
index fa9caa6759e36bb2cecb619b19822f56e08520e2..88f986c509492da698af9bab26a91a6628e2d889 100644 (file)
@@ -57,6 +57,7 @@ typedef struct _MonoErrorBoxed MonoErrorBoxed;
 
 MONO_BEGIN_DECLS
 
+MONO_RT_EXTERNAL_ONLY
 MONO_API void
 mono_error_init (MonoError *error);
 
index f16745292f51b9ea8239bda4efad0ec6e76bf8f1..dda2aafb936f4316201d8370105732c4e27df78e 100644 (file)
@@ -68,7 +68,7 @@
     </project>
     <project dir="class/System.Numerics" library="System.Numerics-basic">
       <boot>true</boot>
-      <flags>/codepage:65001 /nologo /noconfig -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -d:BOOTSTRAP_BASIC -nowarn:1699 -nostdlib -r:./../../class/lib/basic/mscorlib.dll -optimize /unsafe -nowarn:414 -nowarn:436 -r:./../../class/lib/basic/System.dll</flags>
+      <flags>/codepage:65001 /nologo /noconfig -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -d:BOOTSTRAP_BASIC -nowarn:1699 -nostdlib -r:./../../class/lib/basic/mscorlib.dll -optimize /unsafe -r:./../../class/lib/basic/System.dll</flags>
       <output>System.Numerics.dll</output>
       <built_sources></built_sources>
       <library_output>./../../class/lib/basic/System.Numerics.dll</library_output>
     </project>
     <project dir="class/System.Numerics" library="System.Numerics-build">
       <boot>false</boot>
-      <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/build/mscorlib.dll -optimize /unsafe -nowarn:414 -nowarn:436 -r:./../../class/lib/build/System.dll</flags>
+      <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/build/mscorlib.dll -optimize /unsafe -r:./../../class/lib/build/System.dll</flags>
       <output>System.Numerics.dll</output>
       <built_sources></built_sources>
       <library_output>./../../class/lib/build/System.Numerics.dll</library_output>
     </project>
     <project dir="class/System.Numerics" library="System.Numerics-net_4_x">
       <boot>false</boot>
-      <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize /unsafe -nowarn:414 -nowarn:436 -r:./../../class/lib/net_4_x/System.dll</flags>
+      <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize /unsafe -r:./../../class/lib/net_4_x/System.dll</flags>
       <output>System.Numerics.dll</output>
       <built_sources></built_sources>
       <library_output>./../../class/lib/net_4_x/System.Numerics.dll</library_output>
     </project>
     <project dir="class/System.Numerics" library="System.Numerics-tests-net_4_x">
       <boot>false</boot>
-      <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -r:./../../class/lib/net_4_x/System.Numerics.dll /unsafe -nowarn:414 -nowarn:436 -r:./../../class/lib/net_4_x/System.dll</flags>
+      <flags>/codepage:65001 /nologo /noconfig /deterministic -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:WIN_PLATFORM -nowarn:1699 -nostdlib -r:./../../class/lib/net_4_x/mscorlib.dll /debug:portable -optimize -r:./../../class/lib/net_4_x/System.Numerics.dll /unsafe -r:./../../class/lib/net_4_x/System.dll</flags>
       <output>net_4_x_System.Numerics_test.dll</output>
       <built_sources></built_sources>
       <library_output>net_4_x_System.Numerics_test.dll</library_output>