Merge pull request #1266 from esdrubal/datetimenewformat
authorMarek Safar <marek.safar@gmail.com>
Tue, 9 Sep 2014 14:29:34 +0000 (05:29 -0900)
committerMarek Safar <marek.safar@gmail.com>
Tue, 9 Sep 2014 14:29:34 +0000 (05:29 -0900)
Added time format with only offset.

193 files changed:
README.md
autogen.sh
configure.ac
data/Makefile.am
eglib/src/goutput.c
external/cecil
mcs/class/Commons.Xml.Relaxng/Test/NvdlValidatingReaderTests.cs
mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ResolveAssemblyReference.cs
mcs/class/Mono.CSharp/Mono.CSharp.csproj [new file with mode: 0644]
mcs/class/Mono.Data.Tds/Test/bug-4786.cs
mcs/class/Mono.Options/Test/Mono.Options/OptionContextTest.cs
mcs/class/Mono.Options/Test/Mono.Options/OptionSetTest.cs
mcs/class/Mono.Options/Test/Mono.Options/OptionTest.cs
mcs/class/Mono.Options/Test/Mono.Options/Utils.cs
mcs/class/System.Data.Linq/src/DbLinq/Data/Linq/DataContext.cs
mcs/class/System.Data.Services/Test/ChangeInterceptorAttributeTests.cs
mcs/class/System.Data.Services/Test/DataServiceExceptionTests.cs
mcs/class/System.Data.Services/Test/DataServiceTests.cs
mcs/class/System.Data.Services/Test/ETagAttributeTests.cs
mcs/class/System.Data.Services/Test/ExpandSegmentCollectionTests.cs
mcs/class/System.Data.Services/Test/ExpandSegmentTests.cs
mcs/class/System.Data.Services/Test/IgnorePropertiesAttributeTests.cs
mcs/class/System.Data.Services/Test/MimeTypeAttributeTests.cs
mcs/class/System.Data.Services/Test/QueryInterceptorAttributeTests.cs
mcs/class/System.Data/System.Data/DataRow.cs
mcs/class/System.Data/Test/System.Data.Common/DbDataAdapterTest.cs
mcs/class/System.Data/Test/System.Data.Common/DbDataReaderMock.cs
mcs/class/System.Data/Test/System.Data.Common/DbDataReaderTest.cs
mcs/class/System.Data/Test/System.Data/BinarySerializationTest.cs
mcs/class/System.Data/Test/System.Data/ConstraintExceptionTest.cs
mcs/class/System.Data/Test/System.Data/DBConcurrencyExceptionTest.cs
mcs/class/System.Data/Test/System.Data/DataRowTest2.cs
mcs/class/System.Data/Test/System.Data/DataSetTest2.cs
mcs/class/System.Data/Test/System.Data/DataTableCollectionTest2.cs
mcs/class/System.Data/Test/System.Data/DataTableTest2.cs
mcs/class/System.Data/Test/System.Data/DataTableTest3.cs
mcs/class/System.Data/Test/System.Data/DataTableTest4.cs
mcs/class/System.Data/Test/System.Data/DataTableTest5.cs
mcs/class/System.Data/Test/System.Data/DataViewTest2.cs
mcs/class/System.Data/Test/System.Data/DeletedRowInaccessibleExceptionTest.cs
mcs/class/System.Data/Test/System.Data/DuplicateNameExceptionTest.cs
mcs/class/System.Data/Test/System.Data/EvaluateExceptionTest.cs
mcs/class/System.Data/Test/System.Data/ForeignKeyConstraintTest2.cs
mcs/class/System.Data/Test/System.Data/InRowChangingEventExceptionTest.cs
mcs/class/System.Data/Test/System.Data/InvalidConstraintExceptionTest.cs
mcs/class/System.Data/Test/System.Data/MissingPrimaryKeyExceptionTest.cs
mcs/class/System.Data/Test/System.Data/NoNullAllowedExceptionTest.cs
mcs/class/System.Data/Test/System.Data/ReadOnlyExceptionTest.cs
mcs/class/System.Data/Test/System.Data/RowNotInTableExceptionTest.cs
mcs/class/System.Data/Test/System.Data/SyntaxErrorExceptionTest.cs
mcs/class/System.Data/Test/System.Data/TrailingSpaceTest.cs
mcs/class/System.Data/Test/System.Data/UniqueConstraintTest2.cs
mcs/class/System.Data/Test/System.Data/VersionNotFoundException.cs
mcs/class/System.Data/Test/System.Data/XmlDataLoaderTest.cs
mcs/class/System.Data/Test/System.Data/XmlDataReaderTest.cs
mcs/class/System.Drawing/Assembly/AssemblyInfo.cs
mcs/class/System.Drawing/System.Drawing.Design/UITypeEditor.cs
mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs
mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientTest.cs
mcs/class/System.Numerics/System.Numerics/BigInteger.cs
mcs/class/System.Numerics/Test/System.Numerics/BigIntegerTest.cs
mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs
mcs/class/System.ServiceModel/System.ServiceModel/ClientRealProxy.cs
mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs
mcs/class/System.ServiceModel/System.ServiceModel/ServiceRuntimeChannel.cs
mcs/class/System.ServiceModel/Test/System.ServiceModel.Channels/CommunicationObjectSyncTest.cs
mcs/class/System.ServiceProcess/Test/System.ServiceProcess/ServiceBaseTest.cs
mcs/class/System.Web.Extensions/System.Web.Script.Services/LogicalTypeInfo.cs
mcs/class/System.Web/System.Web/MimeTypes.cs
mcs/class/System.Windows.Forms.DataVisualization/Test/System.Windows.Forms.DataVisualization.Charting/AnnotationPathPointTest.cs
mcs/class/System.Windows.Forms.DataVisualization/Test/System.Windows.Forms.DataVisualization.Charting/AnovaResultTest.cs
mcs/class/System.Windows.Forms.DataVisualization/Test/System.Windows.Forms.DataVisualization.Charting/ArrowAnnotationTest.cs
mcs/class/System.Windows.Forms.DataVisualization/Test/System.Windows.Forms.DataVisualization.Charting/AxisScaleBreakStyleTest.cs
mcs/class/System.Windows.Forms.DataVisualization/Test/System.Windows.Forms.DataVisualization.Charting/ChartElementTest.cs
mcs/class/System.Windows.Forms.DataVisualization/Test/System.Windows.Forms.DataVisualization.Charting/DataPointTest.cs
mcs/class/System.XML/Test/System.Xml/XmlResolverTest.cs
mcs/class/System.XML/Test/System.Xml/XmlSecureResolverCas.cs
mcs/class/System.XML/Test/System.Xml/XmlSecureResolverTests.cs
mcs/class/System/System.IO.Ports/SerialPortStream.cs
mcs/class/System/System.Net/ServicePointManager.cs
mcs/class/System/System/Uri.cs
mcs/class/System/System/UriParser.cs
mcs/class/System/Test/System.Net/NetworkCredentialTest.cs
mcs/class/System/Test/System/UriTest.cs
mcs/class/System/mobile_System.dll.sources
mcs/class/WindowsBase/Test/System.IO.Packaging/FakePackage.cs
mcs/class/WindowsBase/Test/System.IO.Packaging/FakePackagePart.cs
mcs/class/WindowsBase/Test/System.IO.Packaging/FakePackagePartTests.cs
mcs/class/WindowsBase/Test/System.IO.Packaging/FakePackageTests.cs
mcs/class/WindowsBase/Test/System.IO.Packaging/FakeStream.cs
mcs/class/WindowsBase/Test/System.IO.Packaging/PackUriHelperTests.cs
mcs/class/WindowsBase/Test/System.IO.Packaging/PackagePartFileTests.cs
mcs/class/WindowsBase/Test/System.IO.Packaging/PackagePartStreamTests.cs
mcs/class/WindowsBase/Test/System.IO.Packaging/PackagePartTest.cs
mcs/class/WindowsBase/Test/System.IO.Packaging/PackageRelationshipTests.cs
mcs/class/WindowsBase/Test/System.IO.Packaging/PackageTest.cs
mcs/class/WindowsBase/Test/System.IO.Packaging/TestBase.cs
mcs/class/corlib/System.Text/UTF8Encoding.cs
mcs/class/corlib/System/DateTime.cs
mcs/class/corlib/Test/Mono/DataConvertTest.cs
mcs/class/corlib/Test/System.IO/DirectoryInfoTest.cs
mcs/class/corlib/Test/System.IO/DirectoryTest.cs
mcs/class/corlib/Test/System.Text/EncodingTester.cs [new file with mode: 0644]
mcs/class/corlib/Test/System.Text/UTF8EncodingTest.cs
mcs/class/corlib/Test/System/DateTimeTest.cs
mcs/class/corlib/Test/System/TimeZoneTest.cs
mcs/class/corlib/corlib_test.dll.sources
mcs/errors/cs0171-7.cs [new file with mode: 0644]
mcs/errors/cs1525-10.cs
mcs/mcs/class.cs
mcs/mcs/codegen.cs
mcs/mcs/cs-parser.jay
mcs/mcs/cs-tokenizer.cs
mcs/mcs/ecore.cs
mcs/mcs/expression.cs
mcs/mcs/membercache.cs
mcs/mcs/method.cs
mcs/mcs/module.cs
mcs/mcs/namespace.cs
mcs/mcs/statement.cs
mcs/tests/gtest-409.cs
mcs/tests/test-888.cs [deleted file]
mcs/tests/test-pattern-01.cs
mcs/tests/test-pattern-02.cs [new file with mode: 0644]
mcs/tests/test-pattern-03.cs [new file with mode: 0644]
mcs/tests/test-pattern-04.cs [new file with mode: 0644]
mcs/tests/test-pattern-05.cs [new file with mode: 0644]
mcs/tests/test-pattern-06.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_5.xml
mcs/tools/csharp/csharp.csproj [changed mode: 0755->0644]
mono/Makefile.am
mono/arch/Makefile.am
mono/arch/amd64/Makefile.am
mono/arch/amd64/tramp.c [deleted file]
mono/arch/ppc/Makefile.am
mono/arch/ppc/test.c [deleted file]
mono/arch/ppc/tramp.c [deleted file]
mono/arch/x86/Makefile.am
mono/arch/x86/test.c [deleted file]
mono/arch/x86/tramp.c [deleted file]
mono/interpreter/.gitignore [deleted file]
mono/interpreter/ChangeLog [deleted file]
mono/interpreter/Makefile.am [deleted file]
mono/interpreter/embed.h [deleted file]
mono/interpreter/hacks.h [deleted file]
mono/interpreter/interp.c [deleted file]
mono/interpreter/interp.h [deleted file]
mono/interpreter/main.c [deleted file]
mono/interpreter/mint.1 [deleted file]
mono/interpreter/mintops.c [deleted file]
mono/interpreter/mintops.def [deleted file]
mono/interpreter/mintops.h [deleted file]
mono/interpreter/transform.c [deleted file]
mono/io-layer/io-layer.h
mono/metadata/Makefile.am [new file with mode: 0644]
mono/metadata/Makefile.am.in [deleted file]
mono/metadata/class.c
mono/metadata/cominterop.c
mono/metadata/domain-internals.h
mono/metadata/domain.c
mono/metadata/loader.c
mono/metadata/metadata-internals.h
mono/metadata/metadata.c
mono/metadata/mono-config.c
mono/metadata/sgen-gc.c
mono/metadata/sgen-internal.c
mono/metadata/sgen-pinning.c
mono/metadata/sgen-pinning.h
mono/metadata/sgen-pointer-queue.c [new file with mode: 0644]
mono/metadata/sgen-pointer-queue.h [new file with mode: 0644]
mono/metadata/threads.c
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/debugger-agent.c
mono/mini/driver.c
mono/mini/exceptions-amd64.c
mono/mini/method-to-ir.c
mono/mini/mini-exceptions.c
mono/mini/mini-trampolines.c
mono/mini/mini.c
mono/mini/mini.h
mono/mini/tramp-amd64.c
mono/utils/Makefile.am
mono/utils/mono-logger.c
mono/utils/mono-threads-android.c [new file with mode: 0644]
mono/utils/mono-threads-freebsd.c [new file with mode: 0644]
mono/utils/mono-threads-linux.c [new file with mode: 0644]
mono/utils/mono-threads-mach.c
mono/utils/mono-threads-openbsd.c [new file with mode: 0644]
mono/utils/mono-threads-posix.c
mono/utils/mono-threads.c
mono/utils/sha1.c [new file with mode: 0644]
mono/utils/sha1.h [new file with mode: 0644]

index 609b9fa4660e7d9bd3a26ae24b6fa4e0e361ead4..b061956eee24f682e087c6d01b78bf1fad95dd74 100644 (file)
--- a/README.md
+++ b/README.md
@@ -494,16 +494,12 @@ Directory Roadmap
 
   * `dis/` - CIL executable Disassembler
 
-  * `cli/` - Common code for the JIT and the interpreter.
-
   * `io-layer/` - The I/O layer and system abstraction for 
 emulating the .NET IO model.
 
   * `cil/` - Common Intermediate Representation, XML
 definition of the CIL bytecodes.
 
- * `interp/` - Interpreter for CLI executables (obsolete).
-
  * `arch/` - Architecture specific portions.
 
 * `man/` - Manual pages for the various Mono commands and programs.
index 5213ecffd3c8f41d5c323cbbb2104d1a4663380f..d4a6ecaccbbb9de378559f6e8d9e4824f0ab0eee 100755 (executable)
@@ -123,7 +123,6 @@ if test x$has_ext_mod = xtrue; then
        popd
 else
        cat mono/mini/Makefile.am.in > mono/mini/Makefile.am
-       cat mono/metadata/Makefile.am.in > mono/metadata/Makefile.am
 fi
 
 
index a8b604edccb1e9d57083be279caf2721d770ff7a..0de87159a127f0997cc18d19a3ebe1ccb01a2181 100644 (file)
@@ -1,7 +1,7 @@
 # Process this file with autoconf to produce a configure script.
 #AC_PREREQ([2.62])
 
-AC_INIT(mono, [3.8.1],
+AC_INIT(mono, [3.10.1],
         [http://bugzilla.xamarin.com/enter_bug.cgi?classification=Mono])
 
 AC_CONFIG_SRCDIR([README.md])
@@ -2499,7 +2499,6 @@ TARGET="unknown"
 ACCESS_UNALIGNED="yes"
 
 JIT_SUPPORTED=no
-INTERP_SUPPORTED=no
 LIBC="libc.so.6"
 INTL="libc.so.6"
 SQLITE="libsqlite.so.0"
@@ -2512,7 +2511,6 @@ XINERAMA="libXinerama.so.1"
 sizeof_register="SIZEOF_VOID_P"
 
 jit_wanted=true
-interp_wanted=false
 sgen_supported=false
 boehm_supported=true
 case "$host" in
@@ -2940,18 +2938,10 @@ if test x$JIT_SUPPORTED = xyes; then
       USEJIT=true
       jit_status="Building and using the JIT"
    else
-      if $interp_wanted; then
-         jit_status="Building the JIT, defaulting to the interpreter"
-      else
-         AC_ERROR(No JIT or interpreter support available or selected.)
-      fi
+      AC_ERROR(No JIT support available or selected.)
    fi
 else
-   if test x$interp_wanted = xtrue; then
-      jit_status="interpreter"
-   else
-      AC_ERROR(No JIT or interpreter support available or selected.)
-   fi
+   AC_ERROR(No JIT support available or selected.)
 fi
 
 AM_CONDITIONAL(USE_JIT, test x$USEJIT = xtrue)
@@ -3358,7 +3348,6 @@ AM_CONDITIONAL(HOST_ARM64, test x$HOST = xARM64)
 AM_CONDITIONAL(CROSS_COMPILE, test "x$host" != "x$target")
 
 AM_CONDITIONAL(JIT_SUPPORTED, test x$JIT_SUPPORTED = xyes)
-AM_CONDITIONAL(INTERP_SUPPORTED, test x$interp_wanted = xtrue)
 AM_CONDITIONAL(INCLUDED_LIBGC, test x$libgc = xincluded)
 
 AC_SUBST(LIBC)
@@ -3378,11 +3367,7 @@ AC_SUBST(LDFLAGS)
 mono_build_root=`pwd`
 AC_SUBST(mono_build_root)
 
-if test x$USEJIT = xtrue; then
-  mono_runtime=mono/mini/mono
-else
-  mono_runtime=mono/interpreter/mint
-fi
+mono_runtime=mono/mini/mono
 AC_SUBST(mono_runtime)
 
 mono_cfg_root=$mono_build_root/runtime
@@ -3579,7 +3564,6 @@ mono/arch/arm/Makefile
 mono/arch/arm64/Makefile
 mono/arch/ia64/Makefile
 mono/arch/mips/Makefile
-mono/interpreter/Makefile
 mono/tests/Makefile
 mono/tests/tests-config
 mono/tests/assemblyresolve/Makefile
index 71cdc650fbceb57bdcc57da5a71af3e4869d8dce..32a13623cb9d66f4c247fcd2332b771859bc7793 100644 (file)
@@ -27,13 +27,8 @@ SGENPCFILE=
 endif
 
 if JIT_SUPPORTED
-if INTERP_SUPPORTED
-pkgconfig_DATA= mono.pc mono-2.pc mint.pc dotnet.pc dotnet35.pc wcf.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc monodoc.pc mono-lineeditor.pc system.web.extensions_1.0.pc \
-               system.web.extensions.design_1.0.pc system.web.mvc.pc system.web.mvc2.pc system.web.mvc3.pc aspnetwebstack.pc reactive.pc xbuild12.pc $(SGENPCFILE)
-else
 pkgconfig_DATA= mono.pc mono-2.pc dotnet.pc dotnet35.pc wcf.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc monodoc.pc mono-lineeditor.pc system.web.extensions_1.0.pc \
                system.web.extensions.design_1.0.pc system.web.mvc.pc system.web.mvc2.pc system.web.mvc3.pc aspnetwebstack.pc reactive.pc xbuild12.pc $(SGENPCFILE)
-endif
 else
 pkgconfig_DATA= mint.pc mono-nunit.pc mono-cairo.pc mono-options.pc cecil.pc monodoc.pc mono-lineeditor.pc
 endif
index 5a303881bc97cf72b4a78131d09ac006bdc71f45..1dc8bd6faff340d9a61d6aae1a097a766567e004 100644 (file)
@@ -74,7 +74,7 @@ g_printerr (const gchar *format, ...)
        if (!stderr_handler)
                stderr_handler = default_stderr_handler;
 
-       stdout_handler (msg);
+       stderr_handler (msg);
        free (msg);
 }
 
@@ -268,7 +268,7 @@ GPrintFunc
 g_set_printerr_handler (GPrintFunc func)
 {
        GPrintFunc old = stderr_handler;
-       stdout_handler = func;
+       stderr_handler = func;
        return old;
 }
 
index 89cfb1d4079002394010fd351628ad057c94422f..33d50b874fd527118bc361d83de3d494e8bb55e1 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 89cfb1d4079002394010fd351628ad057c94422f
+Subproject commit 33d50b874fd527118bc361d83de3d494e8bb55e1
index e7d600c5ea0db57e5fe69fff6cace5b0c7879b06..8f0ae73cf6d5f441285b60caaa75acd3f22a17a7 100644 (file)
@@ -13,7 +13,7 @@ using System.Xml;
 using Commons.Xml.Nvdl;
 using NUnit.Framework;
 
-namespace MonoTests.Commons.Xml.Nvdl
+namespace MonoTests.Commons.Xml.Relaxng
 {
        [TestFixture]
        public class NvdlValidatingReaderTests
index dae19bb79e7a5d101ef93749a4f57b6e7514784b..5a40c8e0c1ec4bdcec506fc628d05fde656eee88 100644 (file)
@@ -53,7 +53,6 @@ namespace Microsoft.Build.Tasks {
                bool            findRelatedFiles;
                bool            findSatellites;
                bool            findSerializationAssemblies;
-               string[]        installedAssemblyTables;
                ITaskItem[]     relatedFiles;
                ITaskItem[]     resolvedDependencyFiles;
                ITaskItem[]     resolvedFiles;
@@ -626,12 +625,15 @@ namespace Microsoft.Build.Tasks {
                        get { return findSerializationAssemblies; }
                        set { findSerializationAssemblies = value; }
                }
-/*             
-               public string[] InstalledAssemblyTables {
-                       get { return installedAssemblyTables; }
-                       set { installedAssemblyTables = value; }
-               }
-*/             
+
+               public
+#if NET_4_0
+               ITaskItem[]
+#else
+               string[]
+#endif
+               InstalledAssemblyTables { get; set; }
+
                [Output]
                public ITaskItem[] RelatedFiles {
                        get { return relatedFiles; }
diff --git a/mcs/class/Mono.CSharp/Mono.CSharp.csproj b/mcs/class/Mono.CSharp/Mono.CSharp.csproj
new file mode 100644 (file)
index 0000000..e4b905a
--- /dev/null
@@ -0,0 +1,265 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <ProductVersion>8.0.30703</ProductVersion>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectGuid>{817CE046-07E8-409D-84BF-A6EA4F2879DE}</ProjectGuid>\r
+    <OutputType>Library</OutputType>\r
+    <AppDesignerFolder>Properties</AppDesignerFolder>\r
+    <RootNamespace>Mono.CSharp</RootNamespace>\r
+    <AssemblyName>Mono.CSharp</AssemblyName>\r
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>\r
+    <FileAlignment>512</FileAlignment>\r
+    <FileUpgradeFlags>\r
+    </FileUpgradeFlags>\r
+    <OldToolsVersion>3.5</OldToolsVersion>\r
+    <UpgradeBackupLocation />\r
+    <PublishUrl>publish\</PublishUrl>\r
+    <Install>true</Install>\r
+    <InstallFrom>Disk</InstallFrom>\r
+    <UpdateEnabled>false</UpdateEnabled>\r
+    <UpdateMode>Foreground</UpdateMode>\r
+    <UpdateInterval>7</UpdateInterval>\r
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>\r
+    <UpdatePeriodically>false</UpdatePeriodically>\r
+    <UpdateRequired>false</UpdateRequired>\r
+    <MapFileExtensions>true</MapFileExtensions>\r
+    <ApplicationRevision>0</ApplicationRevision>\r
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>\r
+    <IsWebBootstrapper>false</IsWebBootstrapper>\r
+    <UseApplicationTrust>false</UseApplicationTrust>\r
+    <BootstrapperEnabled>true</BootstrapperEnabled>\r
+    <TargetFrameworkProfile />\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>bin\Debug\</OutputPath>\r
+    <DefineConstants>TRACE;DEBUG;NET_4_0</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <DebugType>pdbonly</DebugType>\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE;NET_4_0</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="System" />\r
+    <Reference Include="System.Core" />\r
+    <Reference Include="System.Xml" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="..\..\mcs\anonymous.cs">\r
+      <Link>anonymous.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\argument.cs">\r
+      <Link>argument.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\assembly.cs">\r
+      <Link>assembly.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\assign.cs">\r
+      <Link>assign.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\async.cs">\r
+      <Link>async.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\attribute.cs">\r
+      <Link>attribute.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\cfold.cs">\r
+      <Link>cfold.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\class.cs">\r
+      <Link>class.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\codegen.cs">\r
+      <Link>codegen.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\complete.cs">\r
+      <Link>complete.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\const.cs">\r
+      <Link>const.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\constant.cs">\r
+      <Link>constant.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\context.cs">\r
+      <Link>context.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\convert.cs">\r
+      <Link>convert.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\cs-tokenizer.cs">\r
+      <Link>cs-tokenizer.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\decl.cs">\r
+      <Link>decl.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\delegate.cs">\r
+      <Link>delegate.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\doc-bootstrap.cs">\r
+      <Link>doc-bootstrap.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\doc.cs">\r
+      <Link>doc.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\driver.cs">\r
+      <Link>driver.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\dynamic.cs">\r
+      <Link>dynamic.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\ecore.cs">\r
+      <Link>ecore.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\enum.cs">\r
+      <Link>enum.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\eval.cs">\r
+      <Link>eval.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\expression.cs">\r
+      <Link>expression.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\field.cs">\r
+      <Link>field.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\flowanalysis.cs">\r
+      <Link>flowanalysis.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\generic.cs">\r
+      <Link>generic.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\import.cs">\r
+      <Link>import.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\iterators.cs">\r
+      <Link>iterators.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\lambda.cs">\r
+      <Link>lambda.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\linq.cs">\r
+      <Link>linq.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\literal.cs">\r
+      <Link>literal.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\location.cs">\r
+      <Link>location.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\membercache.cs">\r
+      <Link>membercache.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\method.cs">\r
+      <Link>method.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\modifiers.cs">\r
+      <Link>modifiers.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\namespace.cs">\r
+      <Link>namespace.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\nullable.cs">\r
+      <Link>nullable.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\parameter.cs">\r
+      <Link>parameter.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\pending.cs">\r
+      <Link>pending.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\property.cs">\r
+      <Link>property.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\reflection.cs">\r
+      <Link>reflection.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\report.cs">\r
+      <Link>report.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\settings.cs">\r
+      <Link>settings.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\module.cs">\r
+      <Link>module.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\statement.cs">\r
+      <Link>statement.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\support.cs">\r
+      <Link>support.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\typemanager.cs">\r
+      <Link>typemanager.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\typespec.cs">\r
+      <Link>typespec.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\mcs\visit.cs">\r
+      <Link>visit.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\tools\monop\outline.cs">\r
+      <Link>outline.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\Mono.Security\Mono.Security.Cryptography\CryptoConvert.cs">\r
+      <Link>CryptoConvert.cs</Link>\r
+    </Compile>\r
+    <Compile Include="cs-parser.cs" />\r
+    <Compile Include="..\Mono.CompilerServices.SymbolWriter\MonoSymbolFile.cs">\r
+      <Link>MonoSymbolFile.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\Mono.CompilerServices.SymbolWriter\MonoSymbolTable.cs">\r
+      <Link>MonoSymbolTable.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\Mono.CompilerServices.SymbolWriter\MonoSymbolWriter.cs">\r
+      <Link>MonoSymbolWriter.cs</Link>\r
+    </Compile>\r
+    <Compile Include="..\Mono.CompilerServices.SymbolWriter\SourceMethodBuilder.cs">\r
+      <Link>SourceMethodBuilder.cs</Link>\r
+    </Compile>\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Folder Include="Properties\" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">\r
+      <Visible>False</Visible>\r
+      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>\r
+      <Install>false</Install>\r
+    </BootstrapperPackage>\r
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">\r
+      <Visible>False</Visible>\r
+      <ProductName>.NET Framework 3.5 SP1</ProductName>\r
+      <Install>true</Install>\r
+    </BootstrapperPackage>\r
+    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">\r
+      <Visible>False</Visible>\r
+      <ProductName>Windows Installer 3.1</ProductName>\r
+      <Install>true</Install>\r
+    </BootstrapperPackage>\r
+  </ItemGroup>\r
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\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
+  </Target>\r
+  <Target Name="AfterBuild">\r
+  </Target>\r
+  -->\r
+  <PropertyGroup>\r
+    <PreBuildEvent>"$(ProjectDir)..\..\jay\jay" -cvt &lt; "$(ProjectDir)..\..\jay\skeleton.cs" "$(ProjectDir)..\..\mcs\cs-parser.jay" &gt; "$(ProjectDir)cs-parser.cs"</PreBuildEvent>\r
+  </PropertyGroup>\r
+</Project>
\ No newline at end of file
index e8436a7decacd4b7420cacf7f664f72a84062f5e..91f8a06fc1a16b114f8a00c0b024fa95fcadb853 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-namespace bug4786test
+namespace MonoTests.Mono.Data.Tds
 {
        
   using NUnit.Framework;
-  using Mono.Data.Tds.Protocol;
+  using global::Mono.Data.Tds.Protocol;
   using System;
   using System.Net;
   using System.Net.Sockets;
index 8eb61b2c93b4f49c94c95b3e3b94e2f509982883..ec3fb02270f29741a46df43e7ef23cf4ac637b6f 100644 (file)
@@ -39,7 +39,7 @@ using NUnit.Framework;
 #if NDESK_OPTIONS
 namespace Tests.NDesk.Options
 #else
-namespace Tests.Mono.Options
+namespace MonoTests.Mono.Options
 #endif
 {
        [TestFixture]
index 086c6d9c8c24a6f76a4463ea00e16881c9d8daf7..688297a0f68d060f84063f884df8f0f5063007d6 100644 (file)
@@ -46,7 +46,7 @@ using NUnit.Framework;
 #if NDESK_OPTIONS
 namespace Tests.NDesk.Options
 #else
-namespace Tests.Mono.Options
+namespace MonoTests.Mono.Options
 #endif
 {
        class FooConverter : TypeConverter {
index 5242609162aa9f88e153f545a51ea2665dd0fd29..fad1b484784e37931a6839537606307fc9acb67f 100644 (file)
@@ -39,7 +39,7 @@ using NUnit.Framework;
 #if NDESK_OPTIONS
 namespace Tests.NDesk.Options
 #else
-namespace Tests.Mono.Options
+namespace MonoTests.Mono.Options
 #endif
 {
        class DefaultOption : Option {
index e5439aae4c373cd8070f991f3e42275c2dcc478e..074478e3e2159e32b6627d0b4ed754a21eee4492 100644 (file)
@@ -31,7 +31,7 @@ using System;
 #if NDESK_OPTIONS
 namespace Tests.NDesk.Options
 #else
-namespace Tests.Mono.Options
+namespace MonoTests.Mono.Options
 #endif
 {
        static class Utils {
index b6c229efb5eb0e815a2f7371a64a2480c6bd3eb7..acef0f904787c5d6f670ef532e27b7ee545c8fc0 100644 (file)
@@ -830,9 +830,12 @@ namespace DbLinq.Data.Linq
             }\r
         }\r
 \r
-               private static MethodInfo _WhereMethod = typeof(Queryable).GetMethods().First(m => m.Name == "Where");\r
+               private static MethodInfo _WhereMethod;\r
         internal object GetOtherTableQuery(Expression predicate, ParameterExpression parameter, Type otherTableType, IQueryable otherTable)\r
         {\r
+            if (_WhereMethod == null)\r
+                System.Threading.Interlocked.CompareExchange (ref _WhereMethod, typeof(Queryable).GetMethods().First(m => m.Name == "Where"), null);\r
+\r
             //predicate: other.EmployeeID== "WARTH"\r
             Expression lambdaPredicate = Expression.Lambda(predicate, parameter);\r
             //lambdaPredicate: other=>other.EmployeeID== "WARTH"\r
index d8d0e157a8e3da0967c0ad79d90ee0c580a62bf2..3cc769d05e392a59b270313d0255bd61dca45db9 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
 //\r
 \r
+using System;\r
+using System.Data.Services;\r
 using NUnit.Framework;\r
 \r
-namespace System.Data.Services.Tests {\r
+namespace MonoTests.System.Data.Services {\r
        [TestFixture]\r
        public class ChangeInterceptorAttributeTests {\r
                [Test]\r
@@ -45,4 +47,4 @@ namespace System.Data.Services.Tests {
                        Assert.AreEqual ("setName", ci.EntitySetName);\r
                }\r
        }\r
-}
\ No newline at end of file
+}\r
index 6058fc3e3863c1f95ad1facdc2710625b863f90c..5f9758a44c58099ba87943b41e093e1f1a0a2255 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
 //\r
 \r
+using System;\r
+using System.Data.Services;\r
 using NUnit.Framework;\r
 \r
-namespace System.Data.Services.Tests {\r
+namespace MonoTests.System.Data.Services {\r
        [TestFixture]\r
        public class DataServiceExceptionTests {\r
                [Test]\r
@@ -68,4 +70,4 @@ namespace System.Data.Services.Tests {
                        Assert.AreEqual (inner, ex.InnerException);\r
                }\r
        }\r
-}
\ No newline at end of file
+}\r
index 58b67859593f89afac981b48c01148e2f92ee0e3..2bcc6a9dd75da9de24b6477fbadf68f07a5d48c0 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
 //\r
 \r
+using System;\r
+using System.Data.Services;\r
 using NUnit.Framework;\r
 \r
-namespace System.Data.Services.Tests {\r
+namespace MonoTests.System.Data.Services {\r
        [TestFixture]\r
        public class DataServiceTests {\r
                [Test]\r
@@ -79,4 +81,4 @@ namespace System.Data.Services.Tests {
                        this.OnStartProcessingRequest (args);\r
                }\r
        }\r
-}
\ No newline at end of file
+}\r
index 8b40de6c5bd1233e0d10f62115799edd4ffdb758..706e02c6992927f46730373fbf3ce1c4caf33fa3 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
 //\r
 \r
+using System;\r
+using System.Data.Services;\r
 using System.Linq;\r
 using NUnit.Framework;\r
 \r
-namespace System.Data.Services.Tests {\r
+namespace MonoTests.System.Data.Services {\r
        [TestFixture]\r
        public class ETagAttributeTests {\r
                [Test]\r
@@ -63,4 +65,4 @@ namespace System.Data.Services.Tests {
                        Assert.AreEqual ("bar", e.PropertyNames[1]);\r
                }\r
        }\r
-}
\ No newline at end of file
+}\r
index e0eb629d5be8dc62b9e6f4e7c0b9039a5075f0b3..cd5e9a1d31ff48e74eb30913a43c95de41760264 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
 //\r
 \r
+using System.Data.Services;\r
 using System.Linq.Expressions;\r
 using NUnit.Framework;\r
 \r
-namespace System.Data.Services.Tests {\r
+namespace MonoTests.System.Data.Services {\r
        [TestFixture]\r
        public class ExpandSegmentCollectionTests {\r
                [Test]\r
@@ -101,4 +102,4 @@ namespace System.Data.Services.Tests {
                        Assert.IsFalse (esc.HasFilter);\r
                }\r
        }\r
-}
\ No newline at end of file
+}\r
index f64faa8fad22b9bdf8c2ad86f8033ec9e900fd67..ce6712c94e0a25dc16f81d3f1f5c8a795f8357fe 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
 //\r
 \r
+using System;\r
+using System.Data.Services;\r
 using System.Linq.Expressions;\r
 using NUnit.Framework;\r
 \r
-namespace System.Data.Services.Tests {\r
+namespace MonoTests.System.Data.Services {\r
        [TestFixture]\r
        public class ExpandSegmentTests {\r
                [Test]\r
@@ -84,4 +86,4 @@ namespace System.Data.Services.Tests {
                        { new ExpandSegment ("first", null), new ExpandSegment ("second", null), new ExpandSegment ("third", null) }));\r
                }\r
        }\r
-}
\ No newline at end of file
+}\r
index 04c17e3d3ce40f60e3d22ff5b8fbc9bb7b86d31e..090b3bf64bdb73c87376aadf57ad666bc0240328 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
 //\r
 \r
+using System;\r
+using System.Data.Services;\r
 using System.Linq;\r
 using NUnit.Framework;\r
 \r
-namespace System.Data.Services.Tests {\r
+namespace MonoTests.System.Data.Services {\r
        [TestFixture]\r
        public class IgnorePropertiesAttributeTests {\r
                [Test]\r
@@ -63,4 +65,4 @@ namespace System.Data.Services.Tests {
                        Assert.AreEqual ("bar", e.PropertyNames[1]);\r
                }\r
        }\r
-}
\ No newline at end of file
+}\r
index 6b5533ffa50ddb77b8a4520b2e376500bb832caa..824cab9fcb155a1e66bff9650c059a30abd490e6 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
 //\r
 \r
+using System.Data.Services;\r
 using NUnit.Framework;\r
 \r
-namespace System.Data.Services.Tests {\r
+namespace MonoTests.System.Data.Services {\r
        [TestFixture]\r
        public class MimeTypeAttributeTests {\r
                [Test]\r
@@ -39,4 +40,4 @@ namespace System.Data.Services.Tests {
                        Assert.AreEqual ("type", mt.MimeType);\r
                }\r
        }\r
-}
\ No newline at end of file
+}\r
index b483fbe1cdda5a5479e4029c88c039f6fc78bb59..e4b0147cccd2517566fa3cbb4dcdadecb9784b44 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
 //\r
 \r
+using System;\r
+using System.Data.Services;\r
 using NUnit.Framework;\r
 \r
-namespace System.Data.Services.Tests {\r
+namespace MonoTests.System.Data.Services {\r
        [TestFixture]\r
        public class QueryInterceptorAttributeTests {\r
                [Test]\r
@@ -45,4 +47,4 @@ namespace System.Data.Services.Tests {
                        new QueryInterceptorAttribute (null);\r
                }\r
        }\r
-}
\ No newline at end of file
+}\r
index 4207d16f878dbb43dea2f68edd7005a150ecf654..2d0df625f37bf7cbec2ba369d04a77211a4b7f20 100644 (file)
@@ -118,11 +118,11 @@ namespace System.Data {
                /// </summary>
                public bool HasErrors {
                        get {
-                               if (RowError != string.Empty)
+                               if (!string.IsNullOrEmpty (RowError))
                                        return true;
 
                                foreach (String columnError in ColumnErrors) {
-                                       if (columnError != null && columnError != string.Empty)
+                                       if (!string.IsNullOrEmpty (columnError))
                                                return true;
                                }
                                return false;
@@ -509,7 +509,7 @@ namespace System.Data {
                /// </summary>
                public string RowError {
                        get { return rowError; }
-                       set { rowError = value; }
+                       set { rowError = value ?? string.Empty; }
                }
 
                internal int IndexFromVersion (DataRowVersion version)
index c9a346ff28eed471877b45057b6c1eebb09d18d7..a3f69974e069e0589bd57e854293259a576922dd 100644 (file)
@@ -225,6 +225,7 @@ sqliteDataAdapter.Update (dataSet, "Primus");
                }
 
                [Test]
+               [Category ("NotWorking")] // Requires newer sqlite than is on wrench
                public void UpdateResetRowErrorCorrectly ()
                {
                        const string connectionString = "URI = file::memory:; Version = 3";
index 5d561b44dd5b0bb40eeea25e04c7c29ec0a09d18..2957cd73debe63d11638903dfdc85a5ad134a027 100644 (file)
@@ -31,7 +31,7 @@ using System.Data;
 using System.Data.Common;
 using System.IO;
 
-namespace Test.System.Data.Common
+namespace MonoTests.System.Data.Common
 {
        internal class DbDataReaderMock : DbDataReader
        {
index 0a7235f1b902b77543e5f6cd294cc859215fbbba..20d5c1ab0bf41c9e87f2eb16d793df4693eb67fe 100644 (file)
@@ -32,7 +32,7 @@ using System.Data;
 using System.Data.Common;
 using System.IO;
 
-namespace Test.System.Data.Common
+namespace MonoTests.System.Data.Common
 {
        [TestFixture]
        public class DbDataReaderTest
index 5eae92a3963e12b5c443040ea5557aa0b1cb6a1e..efbe64a1a4a2b29ce9fbd436d8e7f5ebb9782260 100644 (file)
@@ -12,6 +12,8 @@ using System.Threading;
 
 using NUnit.Framework;
 
+namespace MonoTests.System.Data
+{
 [TestFixture]
 public class BinarySerializationTest
 {
@@ -751,3 +753,4 @@ public class BinarySerializationTest
 }
 
 #endif
+}
index c98a03c5aa4ff500983fa2444722f9300cf11d1e..fe575137ea422e6e04fc7a0990dfd2c872c3814c 100644 (file)
@@ -33,7 +33,7 @@ using System.IO;
 using System.Data;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class ConstraintExceptionTest
        {
index bfae78d6e6e057709d733231cb755c06c32e3727..35e876ff51f1a38d92f41f3367878dda7ad84274 100644 (file)
@@ -31,7 +31,7 @@ using System.Data;
 
 using NUnit.Framework;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture]
        public class DBConcurrencyExceptionTest
index 4dc0d77495e8178801e83aa7ce4f0c293605bcc5..e3e7aac2857d0066399af79ba1f24b20f26f721d 100644 (file)
@@ -739,6 +739,21 @@ namespace MonoTests.System.Data
                        Assert.AreEqual(true , dr.HasErrors , "DRW48");
                }
 
+               [Test] public void HasErrorsWithNullError()
+               {
+                       DataTable dt = new DataTable("myTable"); 
+                       DataRow dr = dt.NewRow();
+
+                       // HasErrors (default)
+                       Assert.AreEqual(false, dr.HasErrors, "DRW47.2");
+
+                       dr.RowError = null;
+
+                       // HasErrors (set/get)
+                       Assert.AreEqual(string.Empty , dr.RowError , "DRW48.2");
+                       Assert.AreEqual(false , dr.HasErrors , "DRW49.2");
+               }
+
                [Test] public void HasVersion_ByDataRowVersion()
                {
                        DataTable t = new DataTable("atable");
index 27df0f589849c36eb477a933314db4f1f253993c..6e338558389714f5748b4d8369ab873ffd258984 100644 (file)
@@ -39,7 +39,7 @@ using System.Runtime.Serialization;
 using System.Runtime.Serialization.Formatters.Binary;
 using System.Globalization;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture]
        public class DataSetTest2
@@ -448,7 +448,7 @@ namespace MonoTests_System.Data
                        dt.Rows.Add(new object[] {2,"Value3","Value4"});
                        dt.Rows.Add(new object[] {3,"Value5","Value5"});
 
-                       System.Text.StringBuilder resultXML = new System.Text.StringBuilder();
+                       StringBuilder resultXML = new StringBuilder();
 
                        resultXML.Append("<" + ds.DataSetName  + "xmlns=\"namespace\">");
 
@@ -975,13 +975,13 @@ namespace MonoTests_System.Data
                [Test] public void Locale()
                {
                        DataSet ds = new DataSet("MyDataSet");
-                       System.Globalization.CultureInfo culInfo = System.Globalization.CultureInfo.CurrentCulture ;
+                       CultureInfo culInfo = CultureInfo.CurrentCulture ;
 
                        // Checking Locale default from system
                        Assert.AreEqual(culInfo, ds.Locale  , "DS156");
 
                        // Checking Locale get/set
-                       culInfo = new System.Globalization.CultureInfo("fr"); // = french
+                       culInfo = new CultureInfo("fr"); // = french
                        ds.Locale = culInfo ;
                        Assert.AreEqual(culInfo , ds.Locale , "DS157");
                }
@@ -1998,11 +1998,11 @@ namespace MonoTests_System.Data
                        ds1.Tables.Add(DataProvider.CreateParentDataTable());
                        ds1.Tables.Add(DataProvider.CreateChildDataTable());
 
-                       System.IO.MemoryStream ms = new System.IO.MemoryStream();
+                       MemoryStream ms = new MemoryStream();
                        //write xml  schema only
                        ds1.WriteXmlSchema(ms);
 
-                       System.IO.MemoryStream ms1 = new System.IO.MemoryStream(ms.GetBuffer());
+                       MemoryStream ms1 = new MemoryStream(ms.GetBuffer());
                        //copy schema
                        DataSet ds2 = new DataSet();
                        ds2.ReadXmlSchema(ms1);
@@ -2073,7 +2073,7 @@ namespace MonoTests_System.Data
                        Assert.AreEqual(0, ds2.Tables[1].Rows.Count , "DS282");
 
                        //try to delete the file
-                       System.IO.File.Delete(sTempFileName);
+                       File.Delete(sTempFileName);
                }
 
                [Test] public void ReadXmlSchema_ByTextReader()
@@ -2082,11 +2082,11 @@ namespace MonoTests_System.Data
                        ds1.Tables.Add(DataProvider.CreateParentDataTable());
                        ds1.Tables.Add(DataProvider.CreateChildDataTable());
 
-                       System.IO.StringWriter sw = new System.IO.StringWriter();
+                       StringWriter sw = new StringWriter();
                        //write xml file, schema only
                        ds1.WriteXmlSchema(sw);
 
-                       System.IO.StringReader sr = new System.IO.StringReader(sw.GetStringBuilder().ToString());
+                       StringReader sr = new StringReader(sw.GetStringBuilder().ToString());
                        //copy both data and schema
                        DataSet ds2 = new DataSet();
                        ds2.ReadXmlSchema(sr);
@@ -2122,14 +2122,14 @@ namespace MonoTests_System.Data
                        ds1.Tables.Add(DataProvider.CreateParentDataTable());
                        ds1.Tables.Add(DataProvider.CreateChildDataTable());
 
-                       System.IO.StringWriter sw = new System.IO.StringWriter();
-                       System.Xml.XmlTextWriter xmlTW = new System.Xml.XmlTextWriter(sw);
+                       StringWriter sw = new StringWriter();
+                       XmlTextWriter xmlTW = new XmlTextWriter(sw);
                        //write xml file, schema only
                        ds1.WriteXmlSchema(xmlTW);
                        xmlTW.Flush();
 
-                       System.IO.StringReader sr = new System.IO.StringReader(sw.ToString());
-                       System.Xml.XmlTextReader xmlTR = new System.Xml.XmlTextReader(sr);
+                       StringReader sr = new StringReader(sw.ToString());
+                       XmlTextReader xmlTR = new XmlTextReader(sr);
 
                        //copy both data and schema
                        DataSet ds2 = new DataSet();
@@ -2196,7 +2196,7 @@ namespace MonoTests_System.Data
                        Assert.AreEqual(ds2.Tables[1].Rows.Count, ds1.Tables[1].Rows.Count , "DS299");
 
                        //try to delete the file
-                       System.IO.File.Delete(sTempFileName);
+                       File.Delete(sTempFileName);
                }
 
                [Test]
@@ -2212,7 +2212,7 @@ namespace MonoTests_System.Data
                        ds1.Tables[1].Rows.Add(new object[] {7,2," ","          ",new DateTime(2000,1,1,0,0,0,0),35});
                        ds1.Tables[1].Rows.Add(new object[] {7,3,"","",new DateTime(2000,1,1,0,0,0,0),35});
 
-                       System.IO.MemoryStream ms = new System.IO.MemoryStream();
+                       MemoryStream ms = new MemoryStream();
                        //write xml file, data only
                        ds1.WriteXml(ms);
 
@@ -2241,7 +2241,7 @@ namespace MonoTests_System.Data
                {
                        string input = string.Empty;
 
-                       System.IO.StringReader sr;
+                       StringReader sr;
                        DataSet ds = new DataSet();
 
                        input += "<?xml version=\"1.0\"?>";
@@ -2261,7 +2261,7 @@ namespace MonoTests_System.Data
                        input += "              </Price>";
                        input += "</Stock>";
 
-                       sr = new System.IO.StringReader(input);
+                       sr = new StringReader(input);
 
                        ds.ReadXml(sr);
 
@@ -2311,7 +2311,7 @@ namespace MonoTests_System.Data
                {
                        DataSet ds = new DataSet("TestDataSet");
                        string input = string.Empty;
-                       System.IO.StringReader sr;
+                       StringReader sr;
 
                        input += "<?xml version=\"1.0\" standalone=\"yes\"?>";
                        input += "<Stocks><Stock name=\"MSFT\"><Company name=\"Microsoft Corp.\" /><Price type=\"high\"><Value>10.0</Value>";
@@ -2320,7 +2320,7 @@ namespace MonoTests_System.Data
                        input += "<Company name=\"General Electric\" /><Price type=\"high\"><Value>22.23</Value><Date>02/12/2001</Date></Price>";
                        input += "<Price type=\"low\"><Value>1.97</Value><Date>04/20/2003</Date></Price><Price type=\"current\"><Value>3.0</Value>";
                        input += "<Date>TODAY</Date></Price></Stock></Stocks>";
-                       sr = new System.IO.StringReader(input);
+                       sr = new StringReader(input);
                        ds.EnforceConstraints = false;
                        ds.ReadXml(sr);
 
@@ -2339,7 +2339,7 @@ namespace MonoTests_System.Data
                {
                        m_ds = new DataSet("Stocks");
                        string input = string.Empty;
-                       System.IO.StringReader sr;
+                       StringReader sr;
 
                        input += "<?xml version=\"1.0\"?>";
                        input += "<Stocks>";
@@ -2408,7 +2408,7 @@ namespace MonoTests_System.Data
                        input += "              </Stock>";
                        input += "</Stocks>";
 
-                       sr = new System.IO.StringReader(input);
+                       sr = new StringReader(input);
                        m_ds.EnforceConstraints = true;
                        m_ds.ReadXml(sr);
                        this.privateTestCase("TestCase 1", "Company", "name='Microsoft Corp.'", "Stock", "name='MSFT'", "DS320");
@@ -2444,14 +2444,14 @@ namespace MonoTests_System.Data
                        #region "TestCase 1 - Empty string"
                        // Empty string
                        DataSet ds = new DataSet();
-                       System.IO.StringReader sr = new System.IO.StringReader (string.Empty);
-                       System.Xml.XmlTextReader xReader = new System.Xml.XmlTextReader(sr);
+                       StringReader sr = new StringReader (string.Empty);
+                       XmlTextReader xReader = new XmlTextReader(sr);
                        try
                        {
                                ds.ReadXml (xReader);
                                Assert.Fail("DS335: ReadXml Failed to throw XmlException");
                        }
-                       catch (System.Xml.XmlException) {}
+                       catch (XmlException) {}
                        catch (AssertionException exc) {throw  exc;}
                        catch (Exception exc)
                        {
@@ -2635,8 +2635,8 @@ namespace MonoTests_System.Data
                private void PrivateTestCase(string a_name, string a_expected, string a_xmlData)
                {
                        DataSet ds = new DataSet();
-                       System.IO.StringReader sr = new System.IO.StringReader(a_xmlData) ;
-                       System.Xml.XmlTextReader xReader = new System.Xml.XmlTextReader(sr) ;
+                       StringReader sr = new StringReader(a_xmlData) ;
+                       XmlTextReader xReader = new XmlTextReader(sr) ;
                        ds.ReadXml (xReader);
                        Assert.AreEqual(a_expected, this.dataSetDescription(ds), "DS337");
                }
@@ -2681,8 +2681,8 @@ namespace MonoTests_System.Data
                        xmlData +=              "<c>3</c>";
                        xmlData +=    "</b>";
                        xmlData +=      "</a>";
-                       System.IO.StringReader sr = new System.IO.StringReader(xmlData) ;
-                       System.Xml.XmlTextReader xReader = new System.Xml.XmlTextReader(sr) ;
+                       StringReader sr = new StringReader(xmlData) ;
+                       XmlTextReader xReader = new XmlTextReader(sr) ;
                        ds.ReadXml (xReader);
                        Assert.AreEqual(3, ds.Tables["c"].Rows.Count, "DS338");
                }
@@ -2738,7 +2738,7 @@ namespace MonoTests_System.Data
                        ds1.Tables[1].Rows.Add(new object[] {7,2," ","          ",new DateTime(2000,1,1,0,0,0,0),35});
                        ds1.Tables[1].Rows.Add(new object[] {7,3,"","",new DateTime(2000,1,1,0,0,0,0),35});
 
-                       System.IO.StringWriter sw = new System.IO.StringWriter();
+                       StringWriter sw = new StringWriter();
                        //write xml file, data only
                        ds1.WriteXml(sw);
 
@@ -2747,7 +2747,7 @@ namespace MonoTests_System.Data
                        //clear the data
                        ds2.Clear();
 
-                       System.IO.StringReader sr = new System.IO.StringReader(sw.GetStringBuilder().ToString());
+                       StringReader sr = new StringReader(sw.GetStringBuilder().ToString());
                        ds2.ReadXml(sr);
 
                        //check xml data
@@ -2777,8 +2777,8 @@ namespace MonoTests_System.Data
                        ds1.Tables[1].Rows.Add(new object[] {7,2," ","          ",new DateTime(2000,1,1,0,0,0,0),35});
                        ds1.Tables[1].Rows.Add(new object[] {7,3,"","",new DateTime(2000,1,1,0,0,0,0),35});
 
-                       System.IO.StringWriter sw = new System.IO.StringWriter();
-                       System.Xml.XmlTextWriter xmlTW = new System.Xml.XmlTextWriter(sw);
+                       StringWriter sw = new StringWriter();
+                       XmlTextWriter xmlTW = new XmlTextWriter(sw);
 
                        //write xml file, data only
                        ds1.WriteXml(xmlTW);
@@ -2788,8 +2788,8 @@ namespace MonoTests_System.Data
                        DataSet ds2 = ds1.Copy();
                        //clear the data
                        ds2.Clear();
-                       System.IO.StringReader sr = new System.IO.StringReader(sw.ToString());
-                       System.Xml.XmlTextReader xmlTR = new System.Xml.XmlTextReader(sr);
+                       StringReader sr = new StringReader(sw.ToString());
+                       XmlTextReader xmlTR = new XmlTextReader(sr);
                        ds2.ReadXml(xmlTR);
 
                        //check xml data
@@ -2847,8 +2847,8 @@ namespace MonoTests_System.Data
 
                [Test] public void WriteXmlSchema_Relations_ForeignKeys ()
                {
-                       System.IO.MemoryStream ms = null;
-                       System.IO.MemoryStream ms1 = null;
+                       MemoryStream ms = null;
+                       MemoryStream ms1 = null;
 
                        DataSet ds1 = new DataSet();
 
@@ -2884,10 +2884,10 @@ namespace MonoTests_System.Data
                                new DataColumn[] {col1_5, col1_6},
                                new DataColumn[] {col2_5, col2_6});
 
-                       ms = new System.IO.MemoryStream();
+                       ms = new MemoryStream();
                        ds1.WriteXmlSchema (ms);
 
-                       ms1 = new System.IO.MemoryStream (ms.GetBuffer());
+                       ms1 = new MemoryStream (ms.GetBuffer());
                        DataSet ds2 = new DataSet();
                        ds2.ReadXmlSchema(ms1);
                
@@ -3096,18 +3096,18 @@ namespace MonoTests_System.Data
 
                [Test] public void WriteXml_ByTextWriterXmlWriteMode()
                {
-                       System.IO.StringReader sr = null;
-                       System.IO.StringWriter sw = null;
+                       StringReader sr = null;
+                       StringWriter sw = null;
 
                        try  // For real
                        {
                                // ReadXml - DataSetOut
 
                                DataSet oDataset = new DataSet("DataSetOut");
-                               sw = new System.IO.StringWriter();
-                               oDataset.WriteXml(sw,System.Data.XmlWriteMode.WriteSchema);
+                               sw = new StringWriter();
+                               oDataset.WriteXml(sw, XmlWriteMode.WriteSchema);
 
-                               sr = new System.IO.StringReader(sw.GetStringBuilder().ToString());
+                               sr = new StringReader(sw.GetStringBuilder().ToString());
                                oDataset = new DataSet("DataSetOut");
 
                                oDataset.ReadXml(sr);
@@ -3252,13 +3252,13 @@ namespace MonoTests_System.Data
                        {
                        DataSet ds = new DataSet();
                        string input = "<a><b><c>2</c></b></a>";
-                       System.IO.StringReader sr = new System.IO.StringReader(input) ;
-                       System.Xml.XmlTextReader xReader = new System.Xml.XmlTextReader(sr) ;
+                       StringReader sr = new StringReader(input) ;
+                       XmlTextReader xReader = new XmlTextReader(sr) ;
                        ds.ReadXml (xReader);
 
-                       System.Text.StringBuilder sb = new System.Text.StringBuilder();
-                       System.IO.StringWriter sw = new System.IO.StringWriter(sb);
-                       System.Xml.XmlTextWriter xWriter = new System.Xml.XmlTextWriter(sw);
+                       StringBuilder sb = new StringBuilder();
+                       StringWriter sw = new StringWriter(sb);
+                       XmlTextWriter xWriter = new XmlTextWriter(sw);
                        ds.WriteXml(xWriter);
                        string output = sb.ToString();
                        Assert.AreEqual(input,output, "DS76");
@@ -3267,20 +3267,20 @@ namespace MonoTests_System.Data
                        DataSet ds = new DataSet();
                        string input = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><a><b><c>2</c></b></a>";
                        string expectedOutput = "<a><b><c>2</c></b></a>";
-                       System.IO.StringReader sr = new System.IO.StringReader(input) ;
-                       System.Xml.XmlTextReader xReader = new System.Xml.XmlTextReader(sr) ;
+                       StringReader sr = new StringReader(input) ;
+                       XmlTextReader xReader = new XmlTextReader(sr) ;
                        ds.ReadXml (xReader);
                        
-                       System.Text.StringBuilder sb = new System.Text.StringBuilder();
-                       System.IO.StringWriter sw = new System.IO.StringWriter(sb);
-                       System.Xml.XmlTextWriter xWriter = new System.Xml.XmlTextWriter(sw);
+                       StringBuilder sb = new StringBuilder();
+                       StringWriter sw = new StringWriter(sb);
+                       XmlTextWriter xWriter = new XmlTextWriter(sw);
                        ds.WriteXml(xWriter);
                        string output = sb.ToString();
                        Assert.AreEqual(expectedOutput,output, "DS77");
                        }
                        {
                        DataSet ds = new DataSet("DSName"); 
-                       System.IO.StringWriter sr = new System.IO.StringWriter();
+                       StringWriter sr = new StringWriter();
                        ds.WriteXml(sr); 
                        Assert.AreEqual("<DSName />",sr.ToString(), "DS78");
                        }
@@ -3315,7 +3315,7 @@ namespace MonoTests_System.Data
                        ds.Tables.Remove("ChildTable");
 
                        //Get the xml representation of the dataset.
-                       System.IO.StringWriter sr = new System.IO.StringWriter();
+                       StringWriter sr = new StringWriter();
                        ds.WriteXml(sr); 
                        string xml = sr.ToString();
 
index 9229265648cbca2d79a1681bfcb4adf56cfbeb8d..053825e35015665dfdf6868a633467db11724263 100644 (file)
 
 using NUnit.Framework;
 using System;
+using System.Collections;
+using System.ComponentModel;
 using System.Data;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class DataTableCollectionTest2
        {
@@ -143,7 +145,7 @@ namespace MonoTests_System.Data
                {
                        counter = 0;
                        DataSet ds = new DataSet();
-                       ds.Tables.CollectionChanged+=new System.ComponentModel.CollectionChangeEventHandler(Tables_CollectionChanged);
+                       ds.Tables.CollectionChanged+=new CollectionChangeEventHandler(Tables_CollectionChanged);
                        ds.Tables.Add();
                        ds.Tables.Add();
                        Assert.AreEqual(2, counter, "DTC15");
@@ -153,7 +155,7 @@ namespace MonoTests_System.Data
                        Assert.AreEqual(4, counter, "DTC16");
                }
 
-               private void Tables_CollectionChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e)
+               private void Tables_CollectionChanged(object sender, CollectionChangeEventArgs e)
                {
                        counter++;
                }
@@ -163,7 +165,7 @@ namespace MonoTests_System.Data
                {
                        counter = 0;
                        DataSet ds = new DataSet();
-                       ds.Tables.CollectionChanging+=new System.ComponentModel.CollectionChangeEventHandler(Tables_CollectionChanging);
+                       ds.Tables.CollectionChanging+=new CollectionChangeEventHandler(Tables_CollectionChanging);
                        ds.Tables.Add();
                        ds.Tables.Add();
                        Assert.AreEqual(2, counter, "DTC17");
@@ -173,7 +175,7 @@ namespace MonoTests_System.Data
                        Assert.AreEqual(4, counter, "DTC18");
                }
 
-               private void Tables_CollectionChanging(object sender, System.ComponentModel.CollectionChangeEventArgs e)
+               private void Tables_CollectionChanging(object sender, CollectionChangeEventArgs e)
                {
                        counter++;
                }
@@ -233,7 +235,7 @@ namespace MonoTests_System.Data
                        ds.Tables.Add();
                        int count=0;
 
-                       System.Collections.IEnumerator myEnumerator = ds.Tables.GetEnumerator();
+                       IEnumerator myEnumerator = ds.Tables.GetEnumerator();
 
                        while (myEnumerator.MoveNext())
                        {
index 331875ac8886c9d01ebc3774f77198675581c5dc..bed6e55e50c5bccc433e7f9a4c69a7d37f7ffa0d 100644 (file)
@@ -36,7 +36,7 @@ using MonoTests.System.Data.Utils;
 
 using NUnit.Framework;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture]
        public class DataTableTest2
index 6fc2d64b20bc1fbd93e6b310804fe48314648cb5..c706778c67be54118837f1f1334d5d1a6a9bdfe8 100644 (file)
@@ -31,7 +31,7 @@ using System.Xml;
 
 using NUnit.Framework;
 
-namespace Monotests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture]
        public class DataTableTest3
index 2cdd5af913b61dc33046cc18a12503d5b11c9f24..c7cb3a35e8589a7ff23865c1ee4de501b322ad36 100644 (file)
@@ -31,7 +31,7 @@ using System.IO;
 using System.Xml;
 using NUnit.Framework;
 
-namespace Monotests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture]
        public class DataTableTest4
@@ -1600,7 +1600,7 @@ namespace Monotests_System.Data
                        DataSet ds = new DataSet ();
                        DataTable table = new DataTable ("ParentTable");
                        XmlReadMode mode = XmlReadMode.Auto;
-                       table.Columns.Add (new DataColumn ("id", System.Type.GetType ("System.Int32")));
+                       table.Columns.Add (new DataColumn ("id", Type.GetType ("System.Int32")));
                        ds.Tables.Add (table);
 
                        using (FileStream stream = new FileStream (tempFile, FileMode.Open)) {
@@ -1638,7 +1638,7 @@ namespace Monotests_System.Data
                        using (FileStream stream = new FileStream (tempFile, FileMode.Open)) {
                                DataSet ds = new DataSet ();
                                DataTable table = new DataTable ("Table1");
-                               table.Columns.Add (new DataColumn ("id", System.Type.GetType ("System.Int32")));
+                               table.Columns.Add (new DataColumn ("id", Type.GetType ("System.Int32")));
                                ds.Tables.Add (table);
 
                                try {
@@ -1852,7 +1852,7 @@ namespace Monotests_System.Data
                        DataTable table = new DataTable ("DummyTable");
                        //define the table schame partially with a column name which does not match with any
                        //table columns in the diffgram
-                       table.Columns.Add (new DataColumn ("WrongColumnName", System.Type.GetType ("System.String")));
+                       table.Columns.Add (new DataColumn ("WrongColumnName", Type.GetType ("System.String")));
 
                        XmlReadMode mode = XmlReadMode.Auto;
 
@@ -2013,8 +2013,8 @@ namespace Monotests_System.Data
                        Assert.AreEqual ("NewDataSet", table.DataSet.DataSetName, "#2");
                        Assert.AreEqual (2, table.Columns.Count, "#3");
                        Assert.AreEqual (2, table.Rows.Count, "#4");
-                       Assert.AreEqual (typeof (System.Int32), table.Columns [0].DataType, "#5");
-                       Assert.AreEqual (typeof (System.String), table.Columns [1].DataType, "#6");
+                       Assert.AreEqual (typeof (Int32), table.Columns [0].DataType, "#5");
+                       Assert.AreEqual (typeof (String), table.Columns [1].DataType, "#6");
                        Assert.AreEqual (1, table.Constraints.Count, "#7");
                        Assert.AreEqual (typeof (UniqueConstraint), table.Constraints [0].GetType (), "#8");
                        Assert.AreEqual (1, table.ChildRelations.Count, "#9");
@@ -2027,9 +2027,9 @@ namespace Monotests_System.Data
                        Assert.AreEqual ("NewDataSet", table1.DataSet.DataSetName, "#14");
                        Assert.AreEqual (3, table1.Columns.Count, "#15");
                        Assert.AreEqual (4, table1.Rows.Count, "#16");
-                       Assert.AreEqual (typeof (System.Int32), table1.Columns [0].DataType, "#17");
-                       Assert.AreEqual (typeof (System.String), table1.Columns [1].DataType, "#18");
-                       Assert.AreEqual (typeof (System.Int32), table1.Columns [2].DataType, "#19");
+                       Assert.AreEqual (typeof (Int32), table1.Columns [0].DataType, "#17");
+                       Assert.AreEqual (typeof (String), table1.Columns [1].DataType, "#18");
+                       Assert.AreEqual (typeof (Int32), table1.Columns [2].DataType, "#19");
                        Assert.AreEqual (2, table1.Constraints.Count, "#20");
                        Assert.AreEqual (typeof (UniqueConstraint), table1.Constraints [0].GetType (), "#21");
                        Assert.AreEqual (typeof (ForeignKeyConstraint), table1.Constraints [1].GetType (), "#22");
@@ -2045,8 +2045,8 @@ namespace Monotests_System.Data
                        Assert.AreEqual ("NewDataSet", table1.DataSet.DataSetName, "#29");
                        Assert.AreEqual (2, table1.Columns.Count, "#30");
                        Assert.AreEqual (8, table1.Rows.Count, "#31");
-                       Assert.AreEqual (typeof (System.Int32), table1.Columns [0].DataType, "#32");
-                       Assert.AreEqual (typeof (System.String), table1.Columns [1].DataType, "#33");
+                       Assert.AreEqual (typeof (Int32), table1.Columns [0].DataType, "#32");
+                       Assert.AreEqual (typeof (String), table1.Columns [1].DataType, "#33");
                        Assert.AreEqual (1, table1.Constraints.Count, "#34");
                        Assert.AreEqual (typeof (ForeignKeyConstraint), table1.Constraints [0].GetType (), "#35");
                        Assert.AreEqual (1, table1.ParentRelations.Count, "#36");
index 3bcbf75889ac8c89a15ee561957fbdbd16ddb2a0..0cacc8ea9ef6d14049eb719b59c85ede58820c05 100644 (file)
@@ -34,7 +34,7 @@ using System.Xml.Serialization;
 
 using NUnit.Framework;
 
-namespace Monotests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture]
        public class DataTableTest5
index f6c6b3f9a8c744fedf9c4eba711c0174bb1e8ccc..58ca232fb5324dd4d3717d9cf8c4d5f14ba6b608 100644 (file)
 
 using NUnit.Framework;
 using System;
-using System.IO;
+using System.Collections;
 using System.ComponentModel;
+using System.IO;
 using System.Data;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class DataViewTest2
        {
@@ -41,7 +42,7 @@ namespace MonoTests_System.Data
 
                class EventProperties  //hold the event properties to be checked
                {
-                       public System.ComponentModel.ListChangedType lstType ;
+                       public ListChangedType lstType ;
                        public int NewIndex;
                        public int OldIndex;
                }
@@ -508,7 +509,7 @@ namespace MonoTests_System.Data
                        //create the dataview for the table
                        DataView dv = new DataView(dt);
 
-                       System.Collections.IEnumerator ienm = null;
+                       IEnumerator ienm = null;
 
                        // GetEnumerator != null
                        ienm = dv.GetEnumerator();
@@ -549,7 +550,7 @@ namespace MonoTests_System.Data
                        DataView dv = new DataView(dt);
 
                        //add event handler
-                       dv.ListChanged +=new System.ComponentModel.ListChangedEventHandler(dv_ListChanged);
+                       dv.ListChanged +=new ListChangedEventHandler(dv_ListChanged);
 
                        // ----- Change Value ---------
                        evProp = null;
@@ -557,7 +558,7 @@ namespace MonoTests_System.Data
                        dv[1]["String1"] = "something";
                        Assert.AreEqual(true , evProp!=null , "DV58");
                        // change value - ListChangedType
-                       Assert.AreEqual(System.ComponentModel.ListChangedType.ItemChanged, evProp.lstType , "DV59");
+                       Assert.AreEqual(ListChangedType.ItemChanged, evProp.lstType , "DV59");
                        // change value - NewIndex
                        Assert.AreEqual(1, evProp.NewIndex, "DV60");
                        // change value - OldIndex
@@ -569,7 +570,7 @@ namespace MonoTests_System.Data
                        dv.AddNew();
                        Assert.AreEqual(true , evProp!=null , "DV62");
                        // Add New  - ListChangedType
-                       Assert.AreEqual(System.ComponentModel.ListChangedType.ItemAdded , evProp.lstType , "DV63");
+                       Assert.AreEqual(ListChangedType.ItemAdded , evProp.lstType , "DV63");
                        // Add New  - NewIndex
                        Assert.AreEqual(6, evProp.NewIndex, "DV64");
                        // Add New  - OldIndex
@@ -581,7 +582,7 @@ namespace MonoTests_System.Data
                        dv.Sort = "ParentId Desc";
                        Assert.AreEqual(true , evProp!=null , "DV66");
                        // sort - ListChangedType
-                       Assert.AreEqual(System.ComponentModel.ListChangedType.Reset , evProp.lstType , "DV67");
+                       Assert.AreEqual(ListChangedType.Reset , evProp.lstType , "DV67");
                        // sort - NewIndex
                        Assert.AreEqual(-1, evProp.NewIndex, "DV68");
                        // sort - OldIndex
@@ -627,12 +628,12 @@ namespace MonoTests_System.Data
 
                         Assert.AreEqual(true , evProp != null , "DV168");
                         // Clear DataTable - should emit ListChangedType.Reset
-                        Assert.AreEqual(System.ComponentModel.ListChangedType.Reset , evProp.lstType , "DV169");
+                        Assert.AreEqual(ListChangedType.Reset , evProp.lstType , "DV169");
                         // Clear DataTable - should clear view count
                         Assert.AreEqual(0, dt.DefaultView.Count , "DV169");
                 }
 
-               private void dv_ListChanged(object sender, System.ComponentModel.ListChangedEventArgs e)
+               private void dv_ListChanged(object sender, ListChangedEventArgs e)
                {
                        evProp = new EventProperties(); 
                        evProp.lstType = e.ListChangedType;
@@ -646,7 +647,7 @@ namespace MonoTests_System.Data
                        // this test also check DataView.Count property
 
                        DataRowView[] drvResult = null;
-                       System.Collections.ArrayList al = new System.Collections.ArrayList();
+                       ArrayList al = new ArrayList();
 
                        //create the source datatable
                        DataTable dt = DataProvider.CreateChildDataTable();
@@ -763,7 +764,7 @@ namespace MonoTests_System.Data
                         */
 
                        //DataRowView[] drvResult = null;
-                       System.Collections.ArrayList al = new System.Collections.ArrayList();
+                       ArrayList al = new ArrayList();
 
                        DataTable dt = DataProvider.CreateParentDataTable();
 
@@ -821,7 +822,7 @@ namespace MonoTests_System.Data
                private DataRow[] GetResultRows(DataTable dt,DataRowState State)
                {
                        //get expected rows
-                       System.Collections.ArrayList al = new System.Collections.ArrayList();
+                       ArrayList al = new ArrayList();
                        DataRowVersion drVer = DataRowVersion.Current;
 
                        //From MSDN -   The row the default version for the current DataRowState.
index 89fdeb547b13d933a74622fec9026b753c25994c..be2810330fddf8ba6edbcdf8c24638c5e3f9f601 100644 (file)
@@ -33,7 +33,7 @@ using System.IO;
 using System.Data;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class DeletedRowInaccessibleExceptionTest
        {
index c26a71db1e11ae773b65ca4c96f290022eb7b013..77cf583fc812c561064fc29f26d047a90e8188e8 100644 (file)
@@ -33,7 +33,7 @@ using System.IO;
 using System.Data;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class DuplicateNameExceptionTest
        {
index dd6fe52c914f2ffedbe03f8f97f8a3782162367c..a9c41f0c2a12f56d85cd7303be1d9b8919ca11e4 100644 (file)
@@ -33,7 +33,7 @@ using System.IO;
 using System.Data;
 //using GHTUtils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class EvaluateExceptionTest
        {
index c0ed174c96d8294fad4d7bb86e3783eff32108f1..591fef23f04fb1e4bc7635a1301a54a9ade878f1 100644 (file)
@@ -31,7 +31,7 @@ using System;
 using System.Data;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class ForeignKeyConstraintTest2
        {
index 08dd7f08c69d2e7b733b8c152a7918b14f74824a..549076cbb39f6688ec0a30ccd1e2a5a2f94e3620 100644 (file)
@@ -33,7 +33,7 @@ using System.IO;
 using System.Data;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class InRowChangingEventExceptionTest
        {
index 1aacff1ee9965f7b7ea5fb7734487c65bfd183ea..04c19bfc75f28e787360d1ed209c8c8ec6548692 100644 (file)
@@ -33,7 +33,7 @@ using System.IO;
 using System.Data;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class InvalidConstraintExceptionTest
        {
index 75791b325b489bac28c20459523260e00cb9b296..14404f2b35fc2143df86b7e1002cbde1b20ab140 100644 (file)
@@ -32,7 +32,7 @@ using System.Data;
 using NUnit.Framework;\r
 using MonoTests.System.Data.Utils;\r
 \r
-namespace MonoTests_System.Data\r
+namespace MonoTests.System.Data\r
 {\r
        [TestFixture]\r
        class MissingPrimaryKeyExceptionTest\r
@@ -57,4 +57,4 @@ namespace MonoTests_System.Data
                        tbl.Rows.Contains("Something");\r
                }\r
        }\r
-}
\ No newline at end of file
+}\r
index 5b1506a857d408f6c6f3aa14348c12f14e866113..45a5c5f3f762d508cc89571cad0f539d43d23d79 100644 (file)
@@ -33,7 +33,7 @@ using System.IO;
 using System.Data;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class NoNullAllowedExceptionTest
        {
index 4969ea0a93d047046039a32e68fb6a0979cdaf84..dd16e85714aa5860823c33ef4836ae819af6506b 100644 (file)
@@ -33,7 +33,7 @@ using System.IO;
 using System.Data;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class ReadOnlyExceptionTest
        {
index 349bdb8ae886b334967c49f0932bd579f9614bf5..edade0383541f3362b949d7071e2679d7dd0270a 100644 (file)
@@ -31,7 +31,7 @@ using System;
 using System.Data;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class RowNotInTableExceptionTest
        {
index 875be98389415f2cf205cf9a6943c9ac4592ff8f..e1e2b08e24b237d78c211613f045404f298efcdf 100644 (file)
@@ -32,7 +32,7 @@ using System.Text;
 using System.IO;
 using System.Data;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class SyntaxErrorExceptionTest
        {
index 788cc5a390e055d25202a4213235b389a6401e3c..8c6d6a0d86383af59377344454b631cb0f94c748 100644 (file)
@@ -2,7 +2,7 @@ using NUnit.Framework;
 using System;
 using System.Data;
 
-namespace Monotests_Mono.Data.SqlExpressions
+namespace MonoTests.System.Data
 {
        [TestFixture]
        public class ComparisonTest {
@@ -10,7 +10,7 @@ namespace Monotests_Mono.Data.SqlExpressions
                [Test]
                public void TestStringTrailingSpaceHandling () {
                        // test for bug 79695 - does not ignore certain trailing whitespace chars when comparing strings
-                       System.Data.DataTable dataTable = new System.Data.DataTable ("Person");
+                       DataTable dataTable = new DataTable ("Person");
                        dataTable.Columns.Add ("Name", typeof (string));
                        dataTable.Rows.Add (new object[] {"Mike   "}); 
                        DataRow[] selectedRows = dataTable.Select ("Name = 'Mike'");
index a21d94f1883a5e1dd815340d8139287a623ff198..4e0224430c0e3e1ed0d81d36d3cb3209a951bd1a 100644 (file)
@@ -31,7 +31,7 @@ using System;
 using System.Data;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture] public class UniqueConstraintTest2
        {
index 8c2e7a9f7f18aedbe716f7c8d3417cb2ebac0079..235e30890a2d95a99600bda401d95c5ff183066f 100644 (file)
@@ -32,7 +32,7 @@ using System.Data;
 using NUnit.Framework;
 using MonoTests.System.Data.Utils;
 
-namespace MonoTests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture]
        class VersionNotFoundExceptionTest
@@ -73,4 +73,4 @@ namespace MonoTests_System.Data
                        object obj = drParent[0,DataRowVersion.Original];
                }
        }
-}
\ No newline at end of file
+}
index dee7e6e378f4f8614c0d9646b41ef0ad74eb448f..2e0fe018304ee38cb5c7c7810d535c674cbcbeb2 100644 (file)
@@ -32,7 +32,7 @@ using System.Xml;
 
 using NUnit.Framework;
 
-namespace Monotests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture]
        public class XmlDataLoaderTest
@@ -74,7 +74,7 @@ namespace Monotests_System.Data
                        DataSet ds = new DataSet ("Set");
                        DataTable dt = new DataTable ("Test");
                        dt.Columns.Add ("CustName", typeof (String));
-                       dt.Columns.Add ("Type", typeof (System.Type));
+                       dt.Columns.Add ("Type", typeof (Type));
                        ds.Tables.Add (dt);
                        return ds;
                }
index 546db60bfb941b37a8bfc21cd94778fc45a2d628..9bff68d0b928a02d862b213a2f8c26293a52e7bf 100644 (file)
@@ -33,7 +33,7 @@ using System.Xml.Serialization;
 using System.Xml.Schema;
 using NUnit.Framework;
 
-namespace Monotests_System.Data
+namespace MonoTests.System.Data
 {
        [TestFixture]   
        public class XmlDataReaderTest
@@ -103,7 +103,7 @@ namespace Monotests_System.Data
                        StringReader sr = new StringReader (xml);
                        XmlTextReader xr = new XmlTextReader (sr);
                        DataTable tbl = new DataTable("CustomTypesTable");
-                       tbl.Columns.Add("Dummy", typeof(System.UInt32));
+                       tbl.Columns.Add("Dummy", typeof(UInt32));
                        tbl.Columns.Add("FuncXml", typeof(CustomTypeXml));
 
                        DataSet ds = new DataSet("CustomTypesData");
index 115adf5d92e99816cc711ffd306f3a2579a1f4ad..c036603b98a977a8a56d2b59c7b16d13974e3625 100644 (file)
@@ -56,7 +56,9 @@ using System.Runtime.InteropServices;
 
        [assembly: CLSCompliant (true)]
        [assembly: AssemblyDelaySign (true)]
+#if !MOBILE
        [assembly: AssemblyKeyFile("../msfinal.pub")]
+#endif
 
 [assembly: AssemblyFileVersion (Consts.FxFileVersion)]
 [assembly: CompilationRelaxations (CompilationRelaxations.NoStringInterning)]
index 1f53a32fa99388862ac5b872162faa57666403eb..76c66c3fccae8e6fb824f6cf9984facab85f98bf 100644 (file)
@@ -48,7 +48,9 @@ namespace System.Drawing.Design
                        editors [typeof (IList)] = "System.ComponentModel.Design.CollectionEditor, " + Consts.AssemblySystem_Design;
                        editors [typeof (ICollection)] = "System.ComponentModel.Design.CollectionEditor, " + Consts.AssemblySystem_Design;
                        editors [typeof (string[])] = "System.Windows.Forms.Design.StringArrayEditor, " + Consts.AssemblySystem_Design;
+#if !MOBILE
                        TypeDescriptor.AddEditorTable (typeof (UITypeEditor), editors);
+#endif
                }
                
                public UITypeEditor()
index 7f74497c60b8c83e56306dc25118c185f98764fe..b4de2a029cf96a7423ebae93c782e23ce6393748 100644 (file)
@@ -50,7 +50,6 @@ namespace System.Net.Http
                bool useProxy;
                ClientCertificateOption certificate;
                bool sentRequest;
-               HttpWebRequest wrequest;
                string connectionGroupName;
                bool disposed;
 
@@ -221,12 +220,9 @@ namespace System.Net.Http
 
                protected override void Dispose (bool disposing)
                {
-                       if (disposing) {
-                               if (wrequest != null) {
-                                       wrequest.ServicePoint.CloseConnectionGroup (wrequest.ConnectionGroupName);
-                                       Volatile.Write (ref wrequest, null);
-                               }
+                       if (disposing && !disposed) {
                                Volatile.Write (ref disposed, true);
+                               ServicePointManager.CloseConnectionGroup (connectionGroupName);
                        }
 
                        base.Dispose (disposing);
@@ -306,6 +302,8 @@ namespace System.Net.Http
                                item_headers.TryAddWithoutValidation (key, value);
                        }
 
+                       requestMessage.RequestUri = wr.ResponseUri;
+
                        return response;
                }
 
@@ -315,7 +313,7 @@ namespace System.Net.Http
                                throw new ObjectDisposedException (GetType ().ToString ());
 
                        Volatile.Write (ref sentRequest, true);
-                       wrequest = CreateWebRequest (request);
+                       var wrequest = CreateWebRequest (request);
 
                        if (request.Content != null) {
                                var headers = wrequest.Headers;
index d2871f60875b7ebafd8245f2958370f0f0bb40af..4b07313aafdbe23ee1b3a9658bfbc032c167afb0 100644 (file)
@@ -800,6 +800,30 @@ namespace MonoTests.System.Net.Http
                        }
                }
 
+               [Test]
+               public void RequestUriAfterRedirect ()
+               {
+                       var listener = CreateListener (l => {
+                               var request = l.Request;
+                               var response = l.Response;
+
+                               response.StatusCode = (int)HttpStatusCode.Moved;
+                               response.RedirectLocation = "http://xamarin.com/";
+                       });
+
+                       try {
+                               var chandler = new HttpClientHandler ();
+                               chandler.AllowAutoRedirect = true;
+                               var client = new HttpClient (chandler);
+
+                               var resp = client.GetAsync (LocalServer).Result;
+                               Assert.AreEqual ("http://xamarin.com/", resp.RequestMessage.RequestUri.AbsoluteUri, "#1");
+                       } finally {
+                               listener.Abort ();
+                               listener.Close ();
+                       }
+               }
+
                [Test]
                /*
                 * Properties may only be modified before sending the first request.
index 329f91eed1fc43d8ff8f0f4f52ab16320b22032d..93fb7b939e46e1910738b65158dc78de254b4a36 100644 (file)
@@ -1,10 +1,12 @@
 //
 // System.Numerics.BigInteger
 //
-// Rodrigo Kumpera (rkumpera@novell.com)
-
+// Authors:
+//     Rodrigo Kumpera (rkumpera@novell.com)
+//     Marek Safar  <marek.safar@gmail.com>
 //
 // Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2014 Xamarin Inc (http://www.xamarin.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -68,7 +70,6 @@ namespace System.Numerics {
                readonly uint[] data;
                readonly short sign;
 
-               static readonly uint[] ZERO = new uint [1];
                static readonly uint[] ONE = new uint [1] { 1 };
 
                BigInteger (short sign, uint[] data)
@@ -81,7 +82,7 @@ namespace System.Numerics {
                {
                        if (value == 0) {
                                sign = 0;
-                               data = ZERO;
+                               data = null;
                        } else if (value > 0) {
                                sign = 1;
                                data = new uint[] { (uint) value };
@@ -96,7 +97,7 @@ namespace System.Numerics {
                {
                        if (value == 0) {
                                sign = 0;
-                               data = ZERO;
+                               data = null;
                        } else {
                                sign = 1;
                                data = new uint [1] { value };
@@ -107,7 +108,7 @@ namespace System.Numerics {
                {
                        if (value == 0) {
                                sign = 0;
-                               data = ZERO;
+                               data = null;
                        } else if (value > 0) {
                                sign = 1;
                                uint low = (uint)value;
@@ -135,7 +136,7 @@ namespace System.Numerics {
                {
                        if (value == 0) {
                                sign = 0;
-                               data = ZERO;
+                               data = null;
                        } else {
                                sign = 1;
                                uint low = (uint)value;
@@ -180,7 +181,7 @@ namespace System.Numerics {
                                int exponent = Exponent (bytes);
                                if (exponent == 0) {
                                        sign = 0;
-                                       data = ZERO;
+                                       data = null;
                                        return;
                                }
 
@@ -217,7 +218,7 @@ namespace System.Numerics {
 
                        if (size == 0) {
                                sign = 0;
-                               data = ZERO;
+                               data = null;
                                return;
                        }
 
@@ -241,7 +242,7 @@ namespace System.Numerics {
 
                        if (len == 0 || (len == 1 && value [0] == 0)) {
                                sign = 0;
-                               data = ZERO;
+                               data = null;
                                return;
                        }
 
@@ -254,7 +255,7 @@ namespace System.Numerics {
                                while (value [len - 1] == 0) {
                                        if (--len == 0) {
                                                sign = 0;
-                                               data = ZERO;
+                                               data = null;
                                                return;
                                        }
                                }
@@ -456,12 +457,12 @@ namespace System.Numerics {
                }
 
                public static BigInteger Zero {
-                       get { return new BigInteger (0, ZERO); }
+                       get { return new BigInteger (0); }
                }
 
                public static explicit operator int (BigInteger value)
                {
-                       if (value.sign == 0)
+                       if (value.data == null)
                                return 0;
                        if (value.data.Length > 1)
                                throw new OverflowException ();
@@ -483,7 +484,7 @@ namespace System.Numerics {
                [CLSCompliantAttribute (false)]
                public static explicit operator uint (BigInteger value)
                {
-                       if (value.sign == 0)
+                       if (value.data == null)
                                return 0;
                        if (value.data.Length > 1 || value.sign == -1)
                                throw new OverflowException ();
@@ -527,7 +528,7 @@ namespace System.Numerics {
 
                public static explicit operator long (BigInteger value)
                {
-                       if (value.sign == 0)
+                       if (value.data == null)
                                return 0;
 
                        if (value.data.Length > 2)
@@ -569,7 +570,7 @@ namespace System.Numerics {
                [CLSCompliantAttribute (false)]
                public static explicit operator ulong (BigInteger value)
                {
-                       if (value.sign == 0)
+                       if (value.data == null)
                                return 0;
                        if (value.data.Length > 2 || value.sign == -1)
                                throw new OverflowException ();
@@ -584,9 +585,10 @@ namespace System.Numerics {
 
                public static explicit operator double (BigInteger value)
                {
-                       switch (value.data.Length) {
-                       case 0:
+                       if (value.data == null)
                                return 0.0;
+
+                       switch (value.data.Length) {
                        case 1:
                                return BuildDouble (value.sign, value.data [0], 0);
                        case 2:
@@ -613,7 +615,7 @@ namespace System.Numerics {
 
                public static explicit operator decimal (BigInteger value)
                {
-                       if (value.sign == 0)
+                       if (value.data == null)
                        return Decimal.Zero;
 
                        uint[] data = value.data;
@@ -703,7 +705,7 @@ namespace System.Numerics {
                        int r = CoreCompare (left.data, right.data);
 
                        if (r == 0)     
-                               return new BigInteger (0, ZERO);
+                               return Zero;
 
                        if (r > 0) //left > right
                                return new BigInteger (left.sign, CoreSub (left.data, right.data));
@@ -722,7 +724,7 @@ namespace System.Numerics {
                                int r = CoreCompare (left.data, right.data);
 
                                if (r == 0)     
-                                       return new BigInteger (0, ZERO);
+                                       return Zero;
 
                                if (r > 0) //left > right
                                        return new BigInteger (left.sign, CoreSub (left.data, right.data));
@@ -736,7 +738,7 @@ namespace System.Numerics {
                public static BigInteger operator* (BigInteger left, BigInteger right)
                {
                        if (left.sign == 0 || right.sign == 0)
-                               return new BigInteger (0, ZERO);
+                               return Zero;
 
                        if (left.data [0] == 1 && left.data.Length == 1) {
                                if (left.sign == 1)
@@ -797,7 +799,7 @@ namespace System.Numerics {
                        int i;
                        for (i = quotient.Length - 1; i >= 0 && quotient [i] == 0; --i) ;
                        if (i == -1)
-                               return new BigInteger (0, ZERO);
+                               return Zero;
                        if (i < quotient.Length - 1)
                                quotient = Resize (quotient, i + 1);
 
@@ -820,7 +822,7 @@ namespace System.Numerics {
                        int i;
                        for (i = remainder_value.Length - 1; i >= 0 && remainder_value [i] == 0; --i) ;
                        if (i == -1)
-                               return new BigInteger (0, ZERO);
+                               return Zero;
 
                        if (i < remainder_value.Length - 1)
                                remainder_value = Resize (remainder_value, i + 1);
@@ -829,7 +831,7 @@ namespace System.Numerics {
 
                public static BigInteger operator- (BigInteger value)
                {
-                       if (value.sign == 0)
+                       if (value.data == null)
                                return value;
                        return new BigInteger ((short)-value.sign, value.data);
                }
@@ -841,14 +843,14 @@ namespace System.Numerics {
 
                public static BigInteger operator++ (BigInteger value)
                {
-                       if (value.sign == 0)
+                       if (value.data == null)
                                return One;
 
                        short sign = value.sign;
                        uint[] data = value.data;
                        if (data.Length == 1) {
                                if (sign == -1 && data [0] == 1)
-                                       return new BigInteger (0, ZERO);
+                                       return Zero;
                                if (sign == 0)
                                        return new BigInteger (1, ONE);
                        }
@@ -863,14 +865,14 @@ namespace System.Numerics {
 
                public static BigInteger operator-- (BigInteger value)
                {
-                       if (value.sign == 0)
+                       if (value.data == null)
                                return MinusOne;
 
                        short sign = value.sign;
                        uint[] data = value.data;
                        if (data.Length == 1) {
                                if (sign == 1 && data [0] == 1)
-                                       return new BigInteger (0, ZERO);
+                                       return Zero;
                                if (sign == 0)
                                        return new BigInteger (-1, ONE);
                        }
@@ -935,7 +937,7 @@ namespace System.Numerics {
 
                        for (i = result.Length - 1; i >= 0 && result [i] == 0; --i) ;
                        if (i == -1)
-                               return new BigInteger (0, ZERO);
+                               return Zero;
        
                        if (i < result.Length - 1)
                                result = Resize (result, i + 1);
@@ -995,7 +997,7 @@ namespace System.Numerics {
 
                        for (i = result.Length - 1; i >= 0 && result [i] == 0; --i) ;
                        if (i == -1)
-                               return new BigInteger (0, ZERO);
+                               return Zero;
        
                        if (i < result.Length - 1)
                                result = Resize (result, i + 1);
@@ -1055,7 +1057,7 @@ namespace System.Numerics {
 
                        for (i = result.Length - 1; i >= 0 && result [i] == 0; --i) ;
                        if (i == -1)
-                               return new BigInteger (0, ZERO);
+                               return Zero;
        
                        if (i < result.Length - 1)
                                result = Resize (result, i + 1);
@@ -1065,7 +1067,7 @@ namespace System.Numerics {
 
                public static BigInteger operator~ (BigInteger value)
                {
-                       if (value.sign == 0)
+                       if (value.data == null)
                                return new BigInteger (-1, ONE);
 
                        uint[] data = value.data;
@@ -1099,7 +1101,7 @@ namespace System.Numerics {
 
                        for (i = result.Length - 1; i >= 0 && result [i] == 0; --i) ;
                        if (i == -1)
-                               return new BigInteger (0, ZERO);
+                               return Zero;
        
                        if (i < result.Length - 1)
                                result = Resize (result, i + 1);
@@ -1121,7 +1123,7 @@ namespace System.Numerics {
 
                public static BigInteger operator<< (BigInteger value, int shift)
                {
-                       if (shift == 0 || value.sign == 0)
+                       if (shift == 0 || value.data == null)
                                return value;
                        if (shift < 0)
                                return value >> -shift;
@@ -1177,7 +1179,7 @@ namespace System.Numerics {
 
                        if (size <= 0) {
                                if (sign == 1)
-                                       return new BigInteger (0, ZERO);
+                                       return Zero;
                                return new BigInteger (-1, ONE);
                        }
 
@@ -2142,7 +2144,7 @@ namespace System.Numerics {
                        int i;
                        for (i = remainder_value.Length - 1; i >= 0 && remainder_value [i] == 0; --i) ;
                        if (i == -1) {
-                               remainder = new BigInteger (0, ZERO);
+                               remainder = Zero;
                        } else {
                                if (i < remainder_value.Length - 1)
                                        remainder_value = Resize (remainder_value, i + 1);
@@ -2151,7 +2153,7 @@ namespace System.Numerics {
 
                        for (i = quotient.Length - 1; i >= 0 && quotient [i] == 0; --i) ;
                        if (i == -1)
-                               return new BigInteger (0, ZERO);
+                               return Zero;
                        if (i < quotient.Length - 1)
                                quotient = Resize (quotient, i + 1);
 
@@ -2264,7 +2266,7 @@ namespace System.Numerics {
                        if (baseValue == 0.0d || baseValue == Double.PositiveInfinity)
                                return value.IsOne ? 0 : double.NaN;
        
-                       if (value.sign == 0)
+                       if (value.data == null)
                                return double.NegativeInfinity;
 
                        int length = value.data.Length - 1;
index 817d13e40c18e84b240a9df1a85223468d2d227f..c4ad9e811ee5d1a30089b406f242bd3fe31c0787 100644 (file)
@@ -625,10 +625,12 @@ namespace MonoTests.System.Numerics
                        Assert.IsTrue (new BigInteger (1).IsOne, "#7");
                        Assert.IsTrue (new BigInteger (32).IsPowerOfTwo, "#8");
                        Assert.IsTrue (new BigInteger (0).IsZero, "#9");
+                       Assert.IsTrue (new BigInteger ().IsZero, "#9b");
                        Assert.AreEqual (0, new BigInteger (0).Sign, "#10");
                        Assert.AreEqual (-1, new BigInteger (-99999).Sign, "#11");
 
                        Assert.IsFalse (new BigInteger (0).IsPowerOfTwo, "#12");
+                       Assert.IsFalse (new BigInteger ().IsPowerOfTwo, "#12b");
                        Assert.IsFalse (new BigInteger (-16).IsPowerOfTwo, "#13");
                        Assert.IsTrue (new BigInteger (1).IsPowerOfTwo, "#14");
                }
@@ -647,6 +649,7 @@ namespace MonoTests.System.Numerics
                        Assert.AreEqual ("0000000005", new BigInteger (5).ToString ("d10"), "#2");
                        Assert.AreEqual ("0A8", new BigInteger (168).ToString ("X"), "#3");
                        Assert.AreEqual ("0", new BigInteger (0).ToString ("X"), "#4");
+                       Assert.AreEqual ("0", new BigInteger ().ToString ("X"), "#4b");
                        Assert.AreEqual ("1", new BigInteger (1).ToString ("X"), "#5");
                        Assert.AreEqual ("0A", new BigInteger (10).ToString ("X"), "#6");
                        Assert.AreEqual ("F6", new BigInteger (-10).ToString ("X"), "#7");
@@ -750,6 +753,7 @@ namespace MonoTests.System.Numerics
                        Assert.AreEqual (new byte[] { 0x7F }, new BigInteger (0x7F).ToByteArray (), "#10");
                        Assert.AreEqual (new byte[] { 0x45, 0xCC, 0xD0 }, new BigInteger (-0x2F33BB).ToByteArray (), "#11");
                        Assert.AreEqual (new byte[] { 0 }, new BigInteger (0).ToByteArray (), "#12");
+                       Assert.AreEqual (new byte[] { 0 }, new BigInteger ().ToByteArray (), "#13");
                }
 
                [Test]
@@ -886,6 +890,7 @@ namespace MonoTests.System.Numerics
                        Assert.AreEqual (-1m, (decimal)new BigInteger (-1), "#6");
                        Assert.AreEqual (9999999999999999999999999999m,
                                (decimal)new BigInteger (9999999999999999999999999999m), "#7");
+                       Assert.AreEqual (0m, (decimal)new BigInteger (), "#8");
                }
 
                [Test]
@@ -1276,6 +1281,9 @@ namespace MonoTests.System.Numerics
 
                        a = new BigInteger ();
                        Assert.AreEqual (BigInteger.Zero.GetHashCode (), a.GetHashCode (), "#15");
+
+                       a = new BigInteger ();
+                       Assert.AreEqual (BigInteger.Zero, a, "#16");
                }
 
                [Test]
index 702217017d0e7958d09fb9de1cc8bed125336b17..07952e04f14b259244d2670055584905efdcf213 100644 (file)
@@ -389,7 +389,7 @@ namespace System.ServiceModel
                                var od = cd.Operations.Find (methodName);
                                if (od == null)
                                        throw new ArgumentException (String.Format ("Operation '{0}' not found in the service contract '{1}' in namespace '{2}'", methodName, cd.Name, cd.Namespace));
-                               return Inner.Process (od.SyncMethod, methodName, args);
+                               return Inner.Process (od.SyncMethod, methodName, args, OperationContext.Current);
                        }
 
                        protected IAsyncResult BeginInvoke (string methodName, object [] args, AsyncCallback callback, object state)
index 1c94718b6b9660f8ff5782d89f8a23b4cbb98c8d..41d75e98f9cf83d16024f9373086d2d27c56cf99 100644 (file)
@@ -108,8 +108,7 @@ namespace System.ServiceModel
                                        // sync invocation
                                        pl = new object [inmsg.MethodBase.GetParameters ().Length];
                                        Array.Copy (inmsg.Args, pl, inmsg.ArgCount);
-                                       channel.Context = OperationContext.Current;
-                                       ret = channel.Process (inmsg.MethodBase, od.Name, pl);
+                                       ret = channel.Process (inmsg.MethodBase, od.Name, pl, OperationContext.Current);
                                        method = od.SyncMethod;
                                } else if (inmsg.MethodBase.Equals (od.BeginMethod)) {
                                        // async invocation
index 6d073e3d575e6b183be1c071f821c79f8fe14a89..3fa8170565cd4b7ad46264049e60374c21c25759 100644 (file)
@@ -46,9 +46,7 @@ namespace System.ServiceModel.MonoInternal
        {
                ContractDescription Contract { get; }
 
-               OperationContext Context { set; }
-
-               object Process (MethodBase method, string operationName, object [] parameters);
+               object Process (MethodBase method, string operationName, object [] parameters, OperationContext context);
 
                IAsyncResult BeginProcess (MethodBase method, string operationName, object [] parameters, AsyncCallback callback, object asyncState);
 
@@ -69,12 +67,11 @@ namespace System.ServiceModel.MonoInternal
                TimeSpan default_open_timeout, default_close_timeout;
                IChannel channel;
                IChannelFactory factory;
-               OperationContext context;
 
                #region delegates
                readonly ProcessDelegate _processDelegate;
 
-               delegate object ProcessDelegate (MethodBase method, string operationName, object [] parameters);
+               delegate object ProcessDelegate (MethodBase method, string operationName, object [] parameters, OperationContext context);
 
                readonly RequestDelegate requestDelegate;
 
@@ -149,10 +146,6 @@ namespace System.ServiceModel.MonoInternal
                        get { return channel as IDuplexChannel; }
                }
 
-               public OperationContext Context {
-                       set { context = value; }
-               }
-
                #region IClientChannel
 
                bool did_interactive_initialization;
@@ -445,42 +438,28 @@ namespace System.ServiceModel.MonoInternal
 
                public IAsyncResult BeginProcess (MethodBase method, string operationName, object [] parameters, AsyncCallback callback, object asyncState)
                {
-                       if (context != null)
-                               throw new InvalidOperationException ("another operation is in progress");
-                       context = OperationContext.Current;
-
-                       try {
-                               return _processDelegate.BeginInvoke (method, operationName, parameters, callback, asyncState);
-                       } catch {
-                               context = null;
-                               throw;
-                       }
+                       return _processDelegate.BeginInvoke (method, operationName, parameters, OperationContext.Current, callback, asyncState);
                }
 
                public object EndProcess (MethodBase method, string operationName, object [] parameters, IAsyncResult result)
                {
-                       try {
-                               if (result == null)
-                                       throw new ArgumentNullException ("result");
-                               if (parameters == null)
-                                       throw new ArgumentNullException ("parameters");
-                               // FIXME: the method arguments should be verified to be 
-                               // identical to the arguments in the corresponding begin method.
-                               return _processDelegate.EndInvoke (result);
-                       } finally {
-                               context = null;
-                       }
+                       if (result == null)
+                               throw new ArgumentNullException ("result");
+                       if (parameters == null)
+                               throw new ArgumentNullException ("parameters");
+                       // FIXME: the method arguments should be verified to be 
+                       // identical to the arguments in the corresponding begin method.
+                       return _processDelegate.EndInvoke (result);
                }
 
-               public object Process (MethodBase method, string operationName, object [] parameters)
+               public object Process (MethodBase method, string operationName, object [] parameters, OperationContext context)
                {
                        var previousContext = OperationContext.Current;
                        try {
                                // Inherit the context from the calling thread
-                               if (this.context != null) 
-                                       OperationContext.Current = this.context;
+                               OperationContext.Current = context;
 
-                               return DoProcess (method, operationName, parameters);
+                               return DoProcess (method, operationName, parameters, context);
                        } catch (Exception ex) {
                                throw;
                        } finally {
@@ -489,7 +468,7 @@ namespace System.ServiceModel.MonoInternal
                        }
                }
 
-               object DoProcess (MethodBase method, string operationName, object [] parameters)
+               object DoProcess (MethodBase method, string operationName, object [] parameters, OperationContext context)
                {
                        if (AllowInitializationUI)
                                DisplayInitializationUI ();
@@ -499,9 +478,9 @@ namespace System.ServiceModel.MonoInternal
                                Open ();
 
                        if (!od.IsOneWay)
-                               return Request (od, parameters);
+                               return Request (od, parameters, context);
                        else {
-                               Output (od, parameters);
+                               Output (od, parameters, context);
                                return null;
                        }
                }
@@ -519,17 +498,17 @@ namespace System.ServiceModel.MonoInternal
                        return od;
                }
 
-               void Output (OperationDescription od, object [] parameters)
+               void Output (OperationDescription od, object [] parameters, OperationContext context)
                {
                        ClientOperation op = runtime.Operations [od.Name];
-                       Send (CreateRequest (op, parameters), OperationTimeout);
+                       Send (CreateRequest (op, parameters, context), OperationTimeout);
                }
 
-               object Request (OperationDescription od, object [] parameters)
+               object Request (OperationDescription od, object [] parameters, OperationContext context)
                {
                        ClientOperation op = runtime.Operations [od.Name];
                        object [] inspections = new object [runtime.MessageInspectors.Count];
-                       Message req = CreateRequest (op, parameters);
+                       Message req = CreateRequest (op, parameters, context);
 
                        for (int i = 0; i < inspections.Length; i++)
                                inspections [i] = runtime.MessageInspectors [i].BeforeSendRequest (ref req, this);
@@ -621,7 +600,7 @@ namespace System.ServiceModel.MonoInternal
                }
                #endregion
 
-               Message CreateRequest (ClientOperation op, object [] parameters)
+               Message CreateRequest (ClientOperation op, object [] parameters, OperationContext context)
                {
                        MessageVersion version = message_version;
                        if (version == null)
index 0fe0d47b3dc2777ff48003b0e9cd779d1b938a1f..7bc548236271f373f9e7e80dc6740e6ce5fb2b71 100644 (file)
@@ -114,9 +114,9 @@ namespace System.ServiceModel.MonoInternal
                        return client.EndProcess (method, operationName, parameters, result);
                }
 
-               public object Process (MethodBase method, string operationName, object [] parameters)
+               public object Process (MethodBase method, string operationName, object [] parameters, OperationContext context)
                {
-                       return client.Process (method, operationName, parameters);
+                       return client.Process (method, operationName, parameters, context);
                }
        }
 
index 1650bead02ddac0ce64645d48697f94fc7f24207..798a77915f1087768fd516c00c5d492ece21ed14 100644 (file)
@@ -35,7 +35,7 @@ using System.ServiceModel.Channels;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Mono.Moonlight.UnitTesting;
 
-namespace MoonTest.ServiceModel {
+namespace MonoTests.System.ServiceModel.Channels {
 
        [TestClass]
        public class CommunicationObjectSyncTest {
index 7a3c014f7cd71f0bcb5eb79282668df632b030ae..ec6a3a236b88a82cb62652fa1e618524734e9c1d 100644 (file)
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
+using System.ComponentModel;
 using System.ServiceProcess;
 using NUnit.Framework;
 
-namespace Test
+namespace MonoTests.System.ServiceProcess
 {
        [TestFixture]
        public class ServiceBaseTest
@@ -84,7 +85,7 @@ namespace Test
                        /// <summary>
                        /// Required designer variable.
                        /// </summary>
-                       private System.ComponentModel.IContainer components = null;
+                       private IContainer components = null;
 
                        /// <summary>
                        /// Clean up any resources being used.
@@ -107,7 +108,7 @@ namespace Test
                        /// </summary>
                        private void InitializeComponent()
                        {
-                               components = new System.ComponentModel.Container();
+                               components = new Container();
                                this.ServiceName = "ServiceFoo";
                        }
 
index 5f8defbff8160ac7eae19f76d91b59a2e40c43da..a9b6fc01711cfdf2c8065d2831f4a75b374bdfcd 100644 (file)
@@ -411,7 +411,7 @@ if (typeof({0}) === 'undefined') {{", className);
                                var ret = new Dictionary <string, object> ();
 
                                for (int i = nvc.Count - 1; i >= 0; i--)
-                                       ret.Add (nvc.GetKey (i), JavaScriptSerializer.DefaultSerializer.DeserializeObjectInternal (nvc.Get (i)));
+                                       ret.Add (nvc.GetKey (i), nvc.Get (i));
 
                                return ret;
                        }
index 8b7bfcadf75a41aa4ff9e35cd3d8b40e9d1afecc..673507d1cf8b698f7efc6577a31f35dbc707e38f 100644 (file)
@@ -233,6 +233,7 @@ namespace System.Web
                        mimeTypes.Add ("la", "audio/nspaudio");
                        mimeTypes.Add ("lam", "audio/x-liveaudio");
                        mimeTypes.Add ("latex", "application/x-latex");
+                       mimeTypes.Add ("less", "text/css");
                        mimeTypes.Add ("list", "text/plain");
                        mimeTypes.Add ("lma", "audio/nspaudio");
                        mimeTypes.Add ("log", "text/plain");
@@ -529,7 +530,7 @@ namespace System.Web
                        mimeTypes.Add ("wmls", "text/vnd.wap.wmlscript");
                        mimeTypes.Add ("wml", "text/vnd.wap.wml");
                        mimeTypes.Add ("wmp", "video/x-ms-wmp");
-                       mimeTypes.Add ("woff", "application/x-woff");
+                       mimeTypes.Add ("woff", "application/font-woff");
                        mimeTypes.Add ("word", "application/msword");
                        mimeTypes.Add ("wp5", "application/wordperfect");
                        mimeTypes.Add ("wp6", "application/wordperfect");
index 1933373d27b926c26ab4ceb519469cd075a7cf64..a802e4b8c03843a2ed687bdf878c7e5190c60119 100644 (file)
@@ -27,7 +27,7 @@ using System;
 using System.Windows.Forms.DataVisualization.Charting;
 using NUnit.Framework;
 
-namespace ChartingTests
+namespace MonoTests.System.Windows.Forms.DataVisualization.Charting
 {
        [TestFixture]
        public class AnnotationPathPointTest
index 8a146d266bd2a3162969a938d158b6bee5033df2..ef1f648777da93d96114f4a010344fcc80c79306 100644 (file)
@@ -27,7 +27,7 @@ using System;
 using System.Windows.Forms.DataVisualization.Charting;
 using NUnit.Framework;
 
-namespace ChartingTests
+namespace MonoTests.System.Windows.Forms.DataVisualization.Charting
 {
        [TestFixture]
        public class AnovaResultTest
index ccc57005014163459fee5a4533b686e5c639717e..9fced81aadea58094b9509feeaf0bb83d5fcb7b5 100644 (file)
@@ -27,7 +27,7 @@ using System;
 using System.Windows.Forms.DataVisualization.Charting;
 using NUnit.Framework;
 
-namespace ChartingTests
+namespace MonoTests.System.Windows.Forms.DataVisualization.Charting
 {
        [TestFixture]
        public class ArrowAnnotationTest
index e820427d5260d7cc655d18308a687906b9f8c165..3871898efdf05407d3e5ffb4eb8e9ffe5412104c 100644 (file)
@@ -28,7 +28,7 @@ using System.Windows.Forms.DataVisualization.Charting;
 using NUnit.Framework;
 using System.Drawing;
 
-namespace ChartingTests
+namespace MonoTests.System.Windows.Forms.DataVisualization.Charting
 {
        [TestFixture]
        public class AxisScaleBreakStyleTest
index c7053c6a7ee0288ee452ac4b351d9cfa218e7ae0..3afeffe423854caae63430d95461a750e405c1e4 100644 (file)
@@ -27,7 +27,7 @@ using System;
 using System.Windows.Forms.DataVisualization.Charting;
 using NUnit.Framework;
 
-namespace ChartingTests
+namespace MonoTests.System.Windows.Forms.DataVisualization.Charting
 {
        [TestFixture]
        public class ChartElementTest
index 5431d77ea523091a3eeabaadee328658d8821ab6..ec98463aa9b0990689b5e26cc22fa1340fba00c6 100644 (file)
@@ -27,7 +27,7 @@ using System;
 using System.Windows.Forms.DataVisualization.Charting;
 using NUnit.Framework;
 
-namespace ChartingTests
+namespace MonoTests.System.Windows.Forms.DataVisualization.Charting
 {
        [TestFixture]
        public class DataPointTest
index fcdc34e7f7aa832cae1dbd499914aeb765d3b70b..80a46e5c99f670bf7e568c41d260ea40d7042ca5 100644 (file)
@@ -33,7 +33,7 @@ using System.Xml;
 
 using NUnit.Framework;
 
-namespace MonoTest.System.Xml {
+namespace MonoTests.System.Xml {
 
        [TestFixture]
        public class XmlResolverTest {
index 52de90d1414348ee23777ff29d52173e789c3237..2e5316c1ffe33da928b73aa592a33c054b2d8cc7 100644 (file)
@@ -38,7 +38,7 @@ using System.Security.Permissions;
 using System.Security.Policy;
 using System.Xml;
 
-using MonoTestsXml;
+using MonoTests.System.Xml;
 
 namespace MonoCasTests.System.Xml {
 
@@ -85,4 +85,4 @@ namespace MonoCasTests.System.Xml {
        }
 }
 
-#endif
\ No newline at end of file
+#endif
index c97407de984b032cb072d58e56720f1abf150171..a2eaa8b1064105a7c75e2423552132da9d59aa33 100644 (file)
@@ -20,7 +20,7 @@ using System.Security.Permissions;
 using System.Xml;
 using NUnit.Framework;
 
-namespace MonoTestsXml
+namespace MonoTests.System.Xml
 {
        [TestFixture]
        public class XmlSecureResolverTests
index dd4ac22f98b437552f13b1b52b35a3f9461c1be7..b9bac7306682880011612d11c10242988abe660c 100644 (file)
@@ -211,7 +211,10 @@ namespace System.IO.Ports
 
                ~SerialPortStream ()
                {
-                       Dispose (false);
+                       try {
+                               Dispose (false);
+                       } catch (IOException) {
+                       }
                }
 
                void CheckDisposed ()
index b6095b089045edf6cf02322bf6f38f380d268cca..dc7412d725a84529285fc1052eeaba5d046955ae 100644 (file)
@@ -369,6 +369,15 @@ namespace System.Net
                        
                        return sp;
                }
+
+               internal static void CloseConnectionGroup (string connectionGroupName)
+               {
+                       lock (servicePoints) {
+                               foreach (ServicePoint sp in servicePoints.Values) {
+                                       sp.CloseConnectionGroup (connectionGroupName);
+                               }
+                       }
+               }
                
 #if SECURITY_DEP
                internal class ChainValidationHelper {
index 105004e39c8b910fbbca5489174f90121a328528..fb9c14eead150e43c8385ea23551dc577d82fc1b 100644 (file)
@@ -1725,7 +1725,7 @@ namespace System {
                private UriParser Parser {
                        get {
                                if (parser == null) {
-                                       parser = UriParser.GetParser (Scheme);
+                                       parser = UriParser.GetParser (scheme);
                                        // no specific parser ? then use a default one
                                        if (parser == null)
                                                parser = new DefaultUriParser ("*");
@@ -1737,6 +1737,9 @@ namespace System {
 
                public string GetComponents (UriComponents components, UriFormat format)
                {
+                       if ((components & UriComponents.SerializationInfoString) == 0)
+                               EnsureAbsoluteUri ();
+
                        return Parser.GetComponents (this, components, format);
                }
 
index 8abfdc9b359b0e0c3893a080fe2119032efbb6f4..5eda9aadc17853ab9f3a9f4d89e9b80407f93e6b 100644 (file)
@@ -50,6 +50,16 @@ namespace System {
                        if ((format < UriFormat.UriEscaped) || (format > UriFormat.SafeUnescaped))
                                throw new ArgumentOutOfRangeException ("format");
 
+                       if ((components & UriComponents.SerializationInfoString) != 0) {
+                               if (components != UriComponents.SerializationInfoString)
+                                       throw new ArgumentOutOfRangeException ("components", "UriComponents.SerializationInfoString must not be combined with other UriComponents.");
+
+                               if (!uri.IsAbsoluteUri)
+                                       return UriHelper.FormatRelative (uri.OriginalString, "", format);
+
+                               components |= UriComponents.AbsoluteUri;
+                       }
+
                        return GetComponentsHelper (uri, components, format);
                }
 
index 610b4aca31f29e710058b4621f68e7ab1cfc8d15..dbe3255cd6893121155b8f82242724cb8090805f 100644 (file)
@@ -31,7 +31,7 @@ using System.Net;
 
 using NUnit.Framework;
 
-namespace MoonTest.System.Net {
+namespace MonoTests.System.Net {
 
        [TestFixture]
        public class NetworkCredentialTest {
index f0a67b7a7cd700cba440bd54e5f757874df0bd66..b3b33170c584a1912bc36937b57c60517dc91617 100644 (file)
@@ -1951,6 +1951,23 @@ namespace MonoTests.System
                        Assert.IsTrue (Uri.TryCreate (mainUri, uriPath, out result), "#1");
                        Assert.AreEqual ("http://www.imdb.com/title/tt0106521", result.ToString (), "#2");
                }
+
+               [Test]
+               public void GetSerializationInfoStringOnRelativeUri ()
+               {
+                       var uri = new Uri ("/relative/path", UriKind.Relative);
+                       var result = uri.GetComponents (UriComponents.SerializationInfoString, UriFormat.UriEscaped);
+
+                       Assert.AreEqual (uri.OriginalString, result);
+               }
+
+               [Test]
+               [ExpectedException (typeof (ArgumentOutOfRangeException))]
+               public void GetSerializationInfoStringException ()
+               {
+                       var uri = new Uri ("/relative/path", UriKind.Relative);
+                       uri.GetComponents (UriComponents.SerializationInfoString  | UriComponents.Host, UriFormat.UriEscaped);
+               }
        }
 
        // Tests non default IriParsing
index b8a2698a10de2385d1af4876be5626b4d84c7b23..6a014b9133a2a357906a1bb456b142adbc1da2c1 100644 (file)
@@ -318,6 +318,7 @@ System.IO.Compression/CompressionLevel.cs
 System.IO.Compression/CompressionMode.cs
 System.IO.Compression/DeflateStream.cs
 System.IO.Compression/GZipStream.cs
+System.IO/InternalBufferOverflowException.cs
 System.IO/InvalidDataException.cs
 System.IO/MonoSyncFileStream.cs
 System.Net.Cache/HttpCacheAgeControl.cs
index 54df0eb5e8e28d72e394ae86281e09446e29f964..2818cd5e4537502a2d7e3c4f6f5420eaed8bfe23 100644 (file)
 \r
 \r
 using System;\r
+using System.IO;\r
+using System.IO.Packaging;\r
 using System.Collections.Generic;\r
 \r
-namespace System.IO.Packaging.Tests {\r
+namespace MonoTests.System.IO.Packaging {\r
        \r
     public class FakePackage : Package {\r
         Dictionary<Uri, PackagePart> Parts { get; set; }\r
@@ -77,4 +79,4 @@ namespace System.IO.Packaging.Tests {
             return p;\r
         }\r
     }\r
-}
\ No newline at end of file
+}\r
index 9a7871c6ed02f91858349316464f2aeb85dcf561..1ca0bb20f05142116b2d70c22c41af1cb7e68aee 100644 (file)
 //
 
 using System;
+using System.IO;
+using System.IO.Packaging;
 using System.Collections.Generic;
 
-namespace System.IO.Packaging.Tests {
+namespace MonoTests.System.IO.Packaging {
     
     class FakePackagePart : PackagePart {
 
index 731aed62ff916e897e18bf711080db80e1d1168d..216a1686f6428b95a8420ffee66aa76e2ba53dab 100644 (file)
 using System;\r
 using System.Linq;\r
 using System.Collections.Generic;\r
+using System.IO;\r
+using System.IO.Packaging;\r
+using System.Xml;\r
 using NUnit.Framework;\r
 \r
-namespace System.IO.Packaging.Tests {\r
+namespace MonoTests.System.IO.Packaging {\r
 \r
     [TestFixture]\r
     public class FakePackagePartTests : TestBase {\r
@@ -146,7 +149,7 @@ namespace System.IO.Packaging.Tests {
         }\r
 \r
         [Test]\r
-        [ExpectedException (typeof (Xml.XmlException))]\r
+        [ExpectedException (typeof (XmlException))]\r
         public void CreateDupeRelationship ()\r
         {\r
             part.CreateRelationship (uris [1], TargetMode.External, "blah", "asda");\r
@@ -154,7 +157,7 @@ namespace System.IO.Packaging.Tests {
         }\r
 \r
         [Test]\r
-        [ExpectedException (typeof (Xml.XmlException))]\r
+        [ExpectedException (typeof (XmlException))]\r
         public void CreateDupeRelationshipId ()\r
         {\r
             part.CreateRelationship (uris [1], TargetMode.External, "blah", "asda");\r
index bd7515429275cdab4f3c716ab8bed833003eaef4..bfea3c84973f2a9d7e29f733c4559e65c4f964ad 100644 (file)
 \r
 using System;\r
 using System.Collections.Generic;\r
+using System.IO;\r
+using System.IO.Packaging;\r
 using System.Linq;\r
 using System.Text;\r
 using NUnit.Framework;\r
 \r
-namespace System.IO.Packaging.Tests\r
+namespace MonoTests.System.IO.Packaging\r
 {\r
 \r
     [TestFixture]\r
index b095375b177493115cd6b76205b8ab997de9a33f..aafc02e25ed48dedd352d737371a3ddceb8791e1 100644 (file)
 
 
 using System;
+using System.IO;
 using System.Collections.Generic;
 
-namespace System.IO.Packaging.Tests {
+namespace MonoTests.System.IO.Packaging {
 
     public class FakeStream : MemoryStream {
         public bool canRead;
index c5361214f7b39b36f4de2705940038e2b801055d..d231315a0e99c61db7d57265165ca0e110fb3f05 100644 (file)
@@ -8,7 +8,7 @@ using System;
 using System.IO.Packaging;\r
 using NUnit.Framework;\r
 \r
-namespace System.IO.Packaging.Tests {\r
+namespace MonoTests.System.IO.Packaging {\r
     \r
     [TestFixture]\r
     public class PackUriHelperTests {\r
index 3f2850b602b422780971c0c4c4b727a7a4f243e2..557e4a98b51923c28aa5292302624f7f8b987239 100644 (file)
@@ -3,7 +3,7 @@ using System.IO;
 using System.IO.Packaging;
 using NUnit.Framework;
 
-namespace System.IO.Packaging.Tests
+namespace MonoTests.System.IO.Packaging
 {
        [TestFixture]
        public class PackagePartFileTests
@@ -135,4 +135,4 @@ namespace System.IO.Packaging.Tests
                        }
                }
        }
-}
\ No newline at end of file
+}
index 915c2a09a98d321fa7cbcbc124d8f43d1ae85865..1bf60221082e42398a1ba92e8a0cffa6c52f1e16 100644 (file)
 \r
 using System;\r
 using System.Collections.Generic;\r
+using System.IO;\r
+using System.IO.Packaging;\r
 using System.Linq;\r
 using System.Text;\r
 using NUnit.Framework;\r
 \r
-namespace System.IO.Packaging.Tests {\r
+namespace MonoTests.System.IO.Packaging {\r
     \r
     [TestFixture]\r
     public class PackagePartStreamTests : TestBase {\r
@@ -190,4 +192,4 @@ namespace System.IO.Packaging.Tests {
             Assert.IsTrue (stream.Length > buffer.Length * 2, "#4");\r
         }\r
     }\r
-}
\ No newline at end of file
+}\r
index 07015c201733e137e947b9aad8c78ad347c0bca0..ad7eb968c3ad5bce626e29b73d8698c86e56d54a 100644 (file)
 \r
 using System;\r
 using System.Collections.Generic;\r
+using System.IO;\r
+using System.IO.Packaging;\r
 using System.Linq;\r
 using System.Text;\r
 using NUnit.Framework;\r
 using System.Xml;\r
 \r
-namespace System.IO.Packaging.Tests {\r
+namespace MonoTests.System.IO.Packaging {\r
 \r
     [TestFixture]\r
     public class PackagePartTest : TestBase {\r
index 8c4b031de9519a1a3abd7a94cce71a75a2b07f15..6ce92d31e57dddeea54db7eac175339197aa5b64 100644 (file)
 \r
 using System;\r
 using System.Collections.Generic;\r
+using System.IO;\r
+using System.IO.Packaging;\r
 using System.Linq;\r
 using System.Text;\r
 using System.Xml;\r
 using NUnit.Framework;\r
 \r
-namespace System.IO.Packaging.Tests {\r
+namespace MonoTests.System.IO.Packaging {\r
     \r
     [TestFixture]\r
     public class PackageRelationshipTests : TestBase {\r
index ae7c5945de99a1c20bf5690bb74b217cbbb2ac7f..933449052f315ffeeae6104c5434135423bf1793 100644 (file)
 \r
 using System;\r
 using System.Collections.Generic;\r
+using System.IO;\r
+using System.IO.Packaging;\r
 using System.Linq;\r
 using System.Text;\r
 using NUnit.Framework;\r
 \r
-namespace System.IO.Packaging.Tests {\r
+namespace MonoTests.System.IO.Packaging {\r
 \r
     [TestFixture]\r
     public class PackageTest : TestBase {\r
@@ -411,8 +413,8 @@ namespace System.IO.Packaging.Tests {
         [ExpectedException (typeof (FileFormatException))]\r
         public void WriteOnlyAccessExists ()\r
         {\r
-            System.IO.File.Create (path).Close ();\r
+            File.Create (path).Close ();\r
             package = Package.Open (path, FileMode.OpenOrCreate, FileAccess.Write);\r
         }\r
     }\r
-}
\ No newline at end of file
+}\r
index 6d8b43d057e901d348f2b66c17ddb0856c1e6ce1..28afcd43151a6d51bbe22dff0ba345dcf7ec8601 100644 (file)
 
 using System;
 using System.Collections.Generic;
+using System.IO;
+using System.IO.Packaging;
 using System.Linq;
 using System.Text;
 using NUnit.Framework;
 
-namespace System.IO.Packaging.Tests {
+namespace MonoTests.System.IO.Packaging {
     public abstract class TestBase {
 
         protected string contentType = "mime/type";
index cdddb802b16655d178764fbc25060586ed098dbb..1ea7a9ea86a810057f6af52dc673bbff9b0cba86 100644 (file)
@@ -436,7 +436,7 @@ fail_no_space:
        private unsafe static int InternalGetCharCount (
                byte[] bytes, int index, int count, uint leftOverBits,
                uint leftOverCount, object provider,
-               ref DecoderFallbackBuffer fallbackBuffer, ref byte [] bufferArg, bool flush)
+               ref DecoderFallbackBuffer fallbackBuffer, bool flush)
        {
                // Validate the parameters.
                if (bytes == null) {
@@ -453,22 +453,22 @@ fail_no_space:
                        return 0;
                fixed (byte *bptr = bytes)
                        return InternalGetCharCount (bptr + index, count,
-                               leftOverBits, leftOverCount, provider, ref fallbackBuffer, ref bufferArg, flush);
+                               leftOverBits, leftOverCount, provider, ref fallbackBuffer, flush);
        }
 
        private unsafe static int InternalGetCharCount (
-               byte* bytes, int count, uint leftOverBits,
+               byte* bytes, int byteCount, uint leftOverBits,
                uint leftOverCount, object provider,
-               ref DecoderFallbackBuffer fallbackBuffer, ref byte [] bufferArg, bool flush)
+               ref DecoderFallbackBuffer fallbackBuffer, bool flush)
        {
-               int index = 0;
+               int byteIndex = 0;
 
                int length = 0;
 
                if (leftOverCount == 0) {
-                       int end = index + count;
-                       for (; index < end; index++, count--) {
-                               if (bytes [index] < 0x80)
+                       int end = byteIndex + byteCount;
+                       for (; byteIndex < end; byteIndex++, byteCount--) {
+                               if (bytes [byteIndex] < 0x80)
                                        length++;
                                else
                                        break;
@@ -480,9 +480,11 @@ fail_no_space:
                uint leftBits = leftOverBits;
                uint leftSoFar = (leftOverCount & (uint)0x0F);
                uint leftSize = ((leftOverCount >> 4) & (uint)0x0F);
-               while (count > 0) {
-                       ch = (uint)(bytes[index++]);
-                       --count;
+
+               int byteEnd = byteIndex + byteCount;
+               for(; byteIndex < byteEnd; byteIndex++) {
+                       // Fetch the next character from the byte buffer.
+                       ch = (uint)(bytes[byteIndex]);
                        if (leftSize == 0) {
                                // Process a UTF-8 start character.
                                if (ch < (uint)0x0080) {
@@ -515,7 +517,7 @@ fail_no_space:
                                        leftSize = 6;
                                } else {
                                        // Invalid UTF-8 start character.
-                                       length += Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, index - 1, 1);
+                                       length += Fallback (provider, ref fallbackBuffer, bytes, byteIndex, 1);
                                }
                        } else {
                                // Process an extra byte in a multi-byte sequence.
@@ -544,34 +546,34 @@ fail_no_space:
                                                                break;
                                                        }
                                                        if (overlong) {
-                                                               length += Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, index - leftSoFar, leftSoFar);
+                                                               length += Fallback (provider, ref fallbackBuffer, bytes, byteIndex - leftSoFar, leftSoFar);
+                                                               --byteIndex; //process byte again
                                                        }
                                                        else if ((leftBits & 0xF800) == 0xD800) {
                                                                // UTF-8 doesn't use surrogate characters
-                                                               length += Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, index - leftSoFar, leftSoFar);
+                                                               length += Fallback (provider, ref fallbackBuffer, bytes, byteIndex - leftSoFar, leftSoFar);
                                                        }
                                                        else
                                                                ++length;
                                                } else if (leftBits < (uint)0x110000) {
                                                        length += 2;
                                                } else {
-                                                       length += Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, index - leftSoFar, leftSoFar);
+                                                       length += Fallback (provider, ref fallbackBuffer, bytes, byteIndex - leftSoFar, leftSoFar);
                                                }
                                                leftSize = 0;
                                        }
                                } else {
                                        // Invalid UTF-8 sequence: clear and restart.
-                                       length += Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, index - leftSoFar, leftSoFar);
+                                       length += Fallback (provider, ref fallbackBuffer, bytes, byteIndex - leftSoFar, leftSoFar);
                                        leftSize = 0;
-                                       --index;
-                                       ++count;
+                                       --byteIndex;
                                }
                        }
                }
                if (flush && leftSize != 0) {
                        // We had left-over bytes that didn't make up
                        // a complete UTF-8 character sequence.
-                       length += Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, index - leftSoFar, leftSoFar);
+                       length += Fallback (provider, ref fallbackBuffer, bytes, byteIndex - leftSoFar, leftSoFar);
                }
 
                // Return the final length to the caller.
@@ -579,7 +581,7 @@ fail_no_space:
        }
 
        // for GetCharCount()
-       static unsafe int Fallback (object provider, ref DecoderFallbackBuffer buffer, ref byte [] bufferArg, byte* bytes, long index, uint size)
+       static unsafe int Fallback (object provider, ref DecoderFallbackBuffer buffer, byte* bytes, long index, uint size)
        {
                if (buffer == null) {
                        DecoderFallback fb = provider as DecoderFallback;
@@ -588,20 +590,21 @@ fail_no_space:
                        else
                                buffer = ((Decoder) provider).FallbackBuffer;
                }
-               if (bufferArg == null)
-                       bufferArg = new byte [1];
-               int ret = 0;
-               for (int i = 0; i < size; i++) {
-                       bufferArg [0] = bytes [(int) index + i];
-                       buffer.Fallback (bufferArg, 0);
-                       ret += buffer.Remaining;
-                       buffer.Reset ();
-               }
+
+               var bufferArg = new byte [size];
+
+               for (int i = 0; i < size; i++)
+                       bufferArg [i] = bytes [(int) index + i];
+
+               buffer.Fallback (bufferArg, 0);
+               int ret = buffer.Remaining;
+               buffer.Reset ();
+
                return ret;
        }
 
        // for GetChars()
-       static unsafe void Fallback (object provider, ref DecoderFallbackBuffer buffer, ref byte [] bufferArg, byte* bytes, long byteIndex, uint size,
+       static unsafe void Fallback (object provider, ref DecoderFallbackBuffer buffer, byte* bytes, long byteIndex, uint size,
                char* chars, ref int charIndex)
        {
                if (buffer == null) {
@@ -611,23 +614,23 @@ fail_no_space:
                        else
                                buffer = ((Decoder) provider).FallbackBuffer;
                }
-               if (bufferArg == null)
-                       bufferArg = new byte [1];
-               for (int i = 0; i < size; i++) {
-                       bufferArg [0] = bytes [byteIndex + i];
-                       buffer.Fallback (bufferArg, 0);
-                       while (buffer.Remaining > 0)
-                               chars [charIndex++] = buffer.GetNextChar ();
-                       buffer.Reset ();
-               }
+
+               var bufferArg = new byte [size];
+
+               for (int i = 0; i < size; i++)
+                       bufferArg [i] = bytes [byteIndex + i];
+
+               buffer.Fallback (bufferArg, 0);
+               while (buffer.Remaining > 0)
+                       chars [charIndex++] = buffer.GetNextChar ();
+               buffer.Reset ();
        }
 
        // Get the number of characters needed to decode a byte buffer.
        public override int GetCharCount (byte[] bytes, int index, int count)
        {
                DecoderFallbackBuffer buf = null;
-               byte [] bufferArg = null;
-               return InternalGetCharCount (bytes, index, count, 0, 0, DecoderFallback, ref buf, ref bufferArg, true);
+               return InternalGetCharCount (bytes, index, count, 0, 0, DecoderFallback, ref buf, true);
        }
 
        [CLSCompliant (false)]
@@ -635,8 +638,7 @@ fail_no_space:
        public unsafe override int GetCharCount (byte* bytes, int count)
        {
                DecoderFallbackBuffer buf = null;
-               byte [] bufferArg = null;
-               return InternalGetCharCount (bytes, count, 0, 0, DecoderFallback, ref buf, ref bufferArg, true);
+               return InternalGetCharCount (bytes, count, 0, 0, DecoderFallback, ref buf, true);
        }
 
        // Get the characters that result from decoding a byte buffer.
@@ -644,7 +646,7 @@ fail_no_space:
                byte[] bytes, int byteIndex, int byteCount, char[] chars,
                int charIndex, ref uint leftOverBits, ref uint leftOverCount,
                object provider,
-               ref DecoderFallbackBuffer fallbackBuffer, ref byte [] bufferArg, bool flush)
+               ref DecoderFallbackBuffer fallbackBuffer, bool flush)
        {
                // Validate the parameters.
                if (bytes == null) {
@@ -668,10 +670,10 @@ fail_no_space:
 
                fixed (char* cptr = chars) {
                        if (byteCount == 0 || byteIndex == bytes.Length)
-                               return InternalGetChars (null, 0, cptr + charIndex, chars.Length - charIndex, ref leftOverBits, ref leftOverCount, provider, ref fallbackBuffer, ref bufferArg, flush);
+                               return InternalGetChars (null, 0, cptr + charIndex, chars.Length - charIndex, ref leftOverBits, ref leftOverCount, provider, ref fallbackBuffer, flush);
                        // otherwise...
                        fixed (byte* bptr = bytes)
-                               return InternalGetChars (bptr + byteIndex, byteCount, cptr + charIndex, chars.Length - charIndex, ref leftOverBits, ref leftOverCount, provider, ref fallbackBuffer, ref bufferArg, flush);
+                               return InternalGetChars (bptr + byteIndex, byteCount, cptr + charIndex, chars.Length - charIndex, ref leftOverBits, ref leftOverCount, provider, ref fallbackBuffer, flush);
                }
        }
 
@@ -679,7 +681,7 @@ fail_no_space:
                byte* bytes, int byteCount, char* chars, int charCount,
                ref uint leftOverBits, ref uint leftOverCount,
                object provider,
-               ref DecoderFallbackBuffer fallbackBuffer, ref byte [] bufferArg, bool flush)
+               ref DecoderFallbackBuffer fallbackBuffer, bool flush)
        {
                int charIndex = 0, byteIndex = 0;
                int length = charCount;
@@ -744,7 +746,7 @@ fail_no_space:
                                        leftSize = 6;
                                } else {
                                        // Invalid UTF-8 start character.
-                                       Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, byteIndex, 1, chars, ref posn);
+                                       Fallback (provider, ref fallbackBuffer, bytes, byteIndex, 1, chars, ref posn);
                                }
                        } else {
                                // Process an extra byte in a multi-byte sequence.
@@ -773,11 +775,12 @@ fail_no_space:
                                                                break;
                                                        }
                                                        if (overlong) {
-                                                               Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
+                                                               Fallback (provider, ref fallbackBuffer, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
+                                                               --byteIndex; //process byte again
                                                        }
                                                        else if ((leftBits & 0xF800) == 0xD800) {
                                                                // UTF-8 doesn't use surrogate characters
-                                                               Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
+                                                               Fallback (provider, ref fallbackBuffer, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
                                                        }
                                                        else {
                                                                if (posn >= length) {
@@ -797,13 +800,13 @@ fail_no_space:
                                                        chars[posn++] =
                                                                (char)((leftBits & (uint)0x3FF) + (uint)0xDC00);
                                                } else {
-                                                       Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
+                                                       Fallback (provider, ref fallbackBuffer, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
                                                }
                                                leftSize = 0;
                                        }
                                } else {
                                        // Invalid UTF-8 sequence: clear and restart.
-                                       Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
+                                       Fallback (provider, ref fallbackBuffer, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
                                        leftSize = 0;
                                        --byteIndex;
                                }
@@ -812,7 +815,7 @@ fail_no_space:
                if (flush && leftSize != 0) {
                        // We had left-over bytes that didn't make up
                        // a complete UTF-8 character sequence.
-                       Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
+                       Fallback (provider, ref fallbackBuffer, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
                }
                leftOverBits = leftBits;
                leftOverCount = (leftSoFar | (leftSize << 4));
@@ -830,7 +833,7 @@ fail_no_space:
                DecoderFallbackBuffer buf = null;
                byte [] bufferArg = null;
                return InternalGetChars (bytes, byteIndex, byteCount, chars, 
-                               charIndex, ref leftOverBits, ref leftOverCount, DecoderFallback, ref buf, ref bufferArg, true);
+                               charIndex, ref leftOverBits, ref leftOverCount, DecoderFallback, ref buf, true);
        }
 
        [CLSCompliant (false)]
@@ -838,11 +841,10 @@ fail_no_space:
        public unsafe override int GetChars (byte* bytes, int byteCount, char* chars, int charCount)
        {
                DecoderFallbackBuffer buf = null;
-               byte [] bufferArg = null;
                uint leftOverBits = 0;
                uint leftOverCount = 0;
                return InternalGetChars (bytes, byteCount, chars, 
-                               charCount, ref leftOverBits, ref leftOverCount, DecoderFallback, ref buf, ref bufferArg, true);
+                               charCount, ref leftOverBits, ref leftOverCount, DecoderFallback, ref buf, true);
        }
 
        // Get the maximum number of bytes needed to encode a
@@ -952,17 +954,15 @@ fail_no_space:
                public override int GetCharCount (byte[] bytes, int index, int count)
                {
                        DecoderFallbackBuffer buf = null;
-                       byte [] bufferArg = null;
                        return InternalGetCharCount (bytes, index, count,
-                               leftOverBits, leftOverCount, this, ref buf, ref bufferArg, false);
+                               leftOverBits, leftOverCount, this, ref buf, false);
                }
                public override int GetChars (byte[] bytes, int byteIndex,
                                                 int byteCount, char[] chars, int charIndex)
                {
                        DecoderFallbackBuffer buf = null;
-                       byte [] bufferArg = null;
                        return InternalGetChars (bytes, byteIndex, byteCount,
-                               chars, charIndex, ref leftOverBits, ref leftOverCount, this, ref buf, ref bufferArg, false);
+                               chars, charIndex, ref leftOverBits, ref leftOverCount, this, ref buf, false);
                }
 
        } // class UTF8Decoder
index 5a6eae01b3df6e92bab11a904d495d9f74128420..272f6996191aca2720a7537ada49959ed392fedc 100644 (file)
@@ -1467,6 +1467,25 @@ namespace System
                                        if (num_parsed == -1)
                                                return false;
                                        fractionalSeconds = decimalNumber / Math.Pow(10.0, num_parsed);
+
+                                       //Parse ISO8601 with an unlimited number of fractional digits.
+                                       if (!exact && num == 6 && hour != -1 && minute != -1 && second != -1) {
+                                               var total_num_parsed = num_parsed;
+                                               while (true) {
+                                                       valuePos += num_parsed;
+                                                       decimalNumber = (double) _ParseNumber (s, valuePos, 0, 1, leading_zeros, sloppy_parsing, out num_parsed);
+                                                       if (num_parsed < 1) {
+                                                               num_parsed = 0;
+                                                               break;
+                                                       }
+
+                                                       total_num_parsed += num_parsed;
+                                                       if (total_num_parsed > 15)
+                                                               continue; //not enough precision, ignore additional digits.
+
+                                                       fractionalSeconds += decimalNumber / Math.Pow (10.0, total_num_parsed);
+                                               }
+                                       }
                                        break;
                                case 't':
                                        if (!_ParseAmPm (s, valuePos, num > 0 ? 0 : 1, dfi, exact, out num_parsed, ref ampm))
index 89f99e918c1e8171764f7e89c7d1f16ebd3d0771..f02a6a7db40e47092dc2b446e020f1dc3992c20f 100644 (file)
@@ -8,7 +8,7 @@ using Mono;
 using NUnit.Framework.SyntaxHelpers;
 #endif
 
-namespace MonoTests {
+namespace MonoTests.Mono {
 
        [TestFixture]
        public class DataConverterTest
@@ -50,9 +50,9 @@ namespace MonoTests {
                [Test]
                public void StringAlignment ()
                {
-                       byte[] packed = Mono.DataConverter.Pack ("bz8", 1, TEST_STRING);
+                       byte[] packed = global::Mono.DataConverter.Pack ("bz8", 1, TEST_STRING);
                                
-                       IList unpacked = Mono.DataConverter.Unpack ("bz8", packed, 0);
+                       IList unpacked = global::Mono.DataConverter.Unpack ("bz8", packed, 0);
                        
                        Assert.AreEqual(1, (byte) unpacked[0]);
                        Assert.AreEqual(TEST_STRING, new string((char[]) unpacked[1]));
@@ -65,4 +65,4 @@ namespace MonoTests {
                        Assert.That ((f - 3.14f), Is.LessThanOrEqualTo (Single.Epsilon));
                }
        }
-}
\ No newline at end of file
+}
index 699f94be8031c1c8a562a270552f2c2cd2cb87dd..cbb58727eb4aa7308d307af536851de0aa4170dc 100644 (file)
@@ -1111,7 +1111,7 @@ namespace MonoTests.System.IO
                        try {
                                Directory.CreateDirectory (path);
                                Directory.CreateDirectory (dir);
-                               Mono.Unix.UnixSymbolicLinkInfo li = new Mono.Unix.UnixSymbolicLinkInfo (link);
+                               global::Mono.Unix.UnixSymbolicLinkInfo li = new global::Mono.Unix.UnixSymbolicLinkInfo (link);
                                li.CreateSymbolicLinkTo (dir);
 
                                DirectoryInfo info = new DirectoryInfo (path);
index 82536169f59ecfa67615e2e383643ab1c0dcef25..f2d7e03d3d6bee7329915f13f871845b0ae6ed77 100644 (file)
@@ -374,11 +374,11 @@ public class DirectoryTest
                string path = TempFolder + DSC + "ExistsAccessDenied";\r
 \r
                Directory.CreateDirectory (path);\r
-               Mono.Posix.Syscall.chmod (path, 0);\r
+               global::Mono.Posix.Syscall.chmod (path, 0);\r
                try {\r
                        Assert.IsFalse (Directory.Exists(path + DSC + "b"));\r
                } finally {\r
-                       Mono.Posix.Syscall.chmod (path, (Mono.Posix.FileMode) 755);\r
+                       global::Mono.Posix.Syscall.chmod (path, (global::Mono.Posix.FileMode) 755);\r
                        Directory.Delete (path);\r
                }\r
        }\r
diff --git a/mcs/class/corlib/Test/System.Text/EncodingTester.cs b/mcs/class/corlib/Test/System.Text/EncodingTester.cs
new file mode 100644 (file)
index 0000000..939d381
--- /dev/null
@@ -0,0 +1,116 @@
+//
+// EncodingTester.cs
+//
+// Author:
+//     Marcos Henrich  <marcos.henrich@xamarin.com>
+//
+// (C) 2014 Xamarin, Inc.
+// 
+
+using NUnit.Framework;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace MonoTests.System.Text
+{
+       class EncodingTester
+       {
+               class DecoderTestFallbackBuffer : DecoderFallbackBuffer
+               {
+                       DecoderFallbackBuffer buffer;
+                       private FallbackDelegate fallbackAction;
+
+                       public DecoderTestFallbackBuffer (DecoderReplacementFallback fallback, FallbackDelegate fallbackAction)
+                       {
+                               this.fallbackAction = fallbackAction;
+                               buffer = new DecoderReplacementFallbackBuffer (fallback);
+                       }
+
+                       public override bool Fallback (byte [] bytesUnknown, int index)
+                       {
+                               fallbackAction (bytesUnknown, index);
+                               return buffer.Fallback (bytesUnknown, index);
+                       }
+
+                       public override char GetNextChar ()
+                       {
+                               return buffer.GetNextChar ();
+                       }
+
+                       public override bool MovePrevious ()
+                       {
+                               return buffer.MovePrevious ();
+                       }
+
+                       public override int Remaining
+                       {
+                               get { return buffer.Remaining; }
+                       }
+
+                       public override void Reset ()
+                       {
+                               buffer.Reset ();
+                       }
+               }
+
+               class DecoderTestFallback : DecoderFallback
+               {
+                       private DecoderReplacementFallback fallback;
+                       private FallbackDelegate fallbackAction;
+
+                       public DecoderTestFallback (FallbackDelegate fallbackAction)
+                       {
+                               this.fallbackAction = fallbackAction;
+                       }
+
+                       public override DecoderFallbackBuffer CreateFallbackBuffer ()
+                       {
+                               fallback = new DecoderReplacementFallback ();
+                               return new DecoderTestFallbackBuffer (fallback, fallbackAction);
+                       }
+
+                       public override int MaxCharCount
+                       {
+                               get { return fallback.MaxCharCount; }
+                       }
+               }
+
+               public delegate void FallbackDelegate (byte [] bytesUnknown, int index);
+
+               Encoding encoding;
+
+               byte [][] expectedUnknownBytes;
+               int expectedUnknownBytesIndex;
+
+               public EncodingTester (string encodingName)
+               {
+                       var decoderFallback = new DecoderTestFallback (this.DecoderFallback);
+                       encoding = Encoding.GetEncoding (encodingName, new EncoderReplacementFallback(), decoderFallback);
+               }
+
+               private void DecoderFallback (byte [] bytesUnknown, int index)
+               {
+                       if (expectedUnknownBytesIndex == expectedUnknownBytes.Length)
+                               expectedUnknownBytesIndex = 0;
+
+                       var expectedBytes = expectedUnknownBytes [expectedUnknownBytesIndex++];
+                       Assert.AreEqual (expectedBytes, bytesUnknown);
+               }
+
+               public void TestDecoderFallback (byte [] data, string expectedString,  params byte [][] expectedUnknownBytes)
+               {
+                       lock (this)
+                       {
+                               this.expectedUnknownBytes = expectedUnknownBytes;
+                               this.expectedUnknownBytesIndex = 0;
+
+                               Assert.AreEqual (expectedString.Length, encoding.GetCharCount (data));
+                               Assert.AreEqual (expectedUnknownBytesIndex, expectedUnknownBytes.Length);
+
+                               Assert.AreEqual (expectedString, encoding.GetString (data));
+                               Assert.AreEqual (expectedUnknownBytesIndex, expectedUnknownBytes.Length);
+                       }
+               }
+       }
+}
\ No newline at end of file
index 91a465c13d3f80b37aef743ba5ec2c943af1f98c..8943ab6b099c8f0ed487bc74eb76a05d4fe953fe 100644 (file)
@@ -1198,5 +1198,88 @@ namespace MonoTests.System.Text
                        int charactersWritten = Encoding.UTF8.GetDecoder ().GetChars (bytes, 0, 0, chars, 10, false);
                        Assert.AreEqual (0, charactersWritten, "#3");
                }
+
+               [Test]
+               public void EncodingFallback ()
+               {
+               /*  Legal UTF-8 Byte Sequences
+                        *      1st             2nd             3rd             4th
+                        *      00..7F
+                        *      C2..DF  80..BF
+                        *      E0              A0..BF  80..BF
+                        *      E1..EF  80..BF  80..BF
+                        *      F0              90..BF  80..BF  80..BF
+                        *      F1..F3  80..BF  80..BF  80..BF
+                        *      F4              80..8F  80..BF  80..BF
+                        */
+
+                       var t = new EncodingTester ("utf-8");
+                       byte [] data;
+
+                       // Invalid 1st byte
+                       for (byte b = 0x80; b <= 0xC1; b++)     {
+                               data = new byte [] { b };
+                               t.TestDecoderFallback (data, "?", new byte [] { b });
+                       }
+
+                       ///Invalid 2nd byte
+                       //      C2..DF  80..BF
+                       for (byte b = 0xC2; b <= 0xDF; b++)     {
+                               data = new byte [] { b, 0x61 };
+                               t.TestDecoderFallback (data, "?a", new byte [] { b });
+                       }
+
+                       //      E0              A0..BF
+                       data =  new byte [] { 0xE0, 0x99};
+                       t.TestDecoderFallback (data, "?", new byte [] { 0xE0,  0x99});
+
+                       //      E1..EF  80..BF
+                       for (byte b = 0xE1; b <= 0xEF; b++)     {
+                               data = new byte [] { b, 0x61 };
+                               t.TestDecoderFallback (data, "?a", new byte [] { b });
+                       }
+
+                       //      F0              90..BF
+                       data =  new byte [] { 0xF0, 0x8F};
+                       t.TestDecoderFallback (data, "?", new byte [] { 0xF0, 0x8F });
+
+                       //      F1..F4  80..XX
+                       for (byte b = 0xF1; b <= 0xF4; b++)     {
+                               data = new byte [] { b, 0x61 };
+                               t.TestDecoderFallback (data, "?a", new byte [] { b });
+                       }
+
+                       //      C2..F3  XX..BF
+                       for (byte b = 0xC2; b <= 0xF3; b++)     {
+                               data = new byte [] { b, 0xC0 };
+                               t.TestDecoderFallback (data, "??", new byte [] { b }, new byte [] { 0xC0 });
+                       }
+
+                       // Invalid 3rd byte
+                       //      E0..F3  90..BF  80..BF
+                       for (byte b = 0xE0; b <= 0xF3; b++)     {
+                               data = new byte [] { b, 0xB0, 0x61 };
+                               t.TestDecoderFallback (data, "?a", new byte [] { b, 0xB0 });
+                               data = new byte [] { b, 0xB0, 0xC0 };
+                               t.TestDecoderFallback (data, "??", new byte [] { b, 0xB0 }, new byte [] { 0xC0 });
+                       }
+
+                       //      F4              80..8F  80..BF
+                       data = new byte [] { 0xF4, 0x8F, 0xC0 };
+                       t.TestDecoderFallback (data, "??", new byte [] { 0xF4, 0x8F }, new byte [] { 0xC0 });
+
+                       // Invalid 4th byte
+                       //      F0..F3  90..BF  80..BF  80..BF
+                       for (byte b = 0xF0; b <= 0xF3; b++)     {
+                               data = new byte [] { b, 0xB0, 0xB0, 0x61 };
+                               t.TestDecoderFallback (data, "?a", new byte [] { b, 0xB0, 0xB0 });
+                               data = new byte [] { b, 0xB0, 0xB0, 0xC0 };
+                               t.TestDecoderFallback (data, "??", new byte [] { b, 0xB0, 0xB0 }, new byte [] { 0xC0 });
+                       }
+
+                       //      F4              80..8F  80..BF 80..BF
+                       data = new byte [] { 0xF4, 0x8F, 0xB0, 0xC0 };
+                       t.TestDecoderFallback (data, "??", new byte [] { 0xF4, 0x8F, 0xB0 }, new byte [] { 0xC0 });
+               }
        }
 }
index 343e723be82e8b6ce8bf0145a4e4a57c93a78482..202c3d2117daee39605b931548930e986bc6324e 100644 (file)
@@ -2584,5 +2584,40 @@ namespace MonoTests.System
 
                        Assert.AreEqual (dt, parsed, "#1");
                }
+
+               [Test]
+               public void ISO8601FractionalDigits ()
+               {
+                       string date = "2014-08-25T01:20:23.601911612343423423465789789365674575676746756747467Z";
+                       long expectedTicks = 635445264236019116;
+
+                       var dt = DateTime.Parse (date, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
+
+                       Assert.AreEqual (expectedTicks, dt.Ticks);
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void ISO8601FractionalDigitsException1 ()
+               {
+                       string date = "2014-08-25T01:20:23.60191161234342342346578978936567457567:6746756747467Z";
+                       DateTime.Parse (date, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void ISO8601FractionalDigitsException2 ()
+               {
+                       string date = "2014-08-25T01:20:23.6019116-12343423423465789789365674575676746756747467Z";
+                       DateTime.Parse (date, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
+               }
+
+               [Test]
+               [ExpectedException (typeof (FormatException))]
+               public void ISO8601FractionalDigitsException3 ()
+               {
+                       string date = "2014-08-25T01:20:23.601911612343423423465789789365674575676746756747467%Z";
+                       DateTime.Parse (date, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
+               }
        }
 }
index 6f97c359ebc9c9c36e5b56bdbf6b76bcca114680..47915f722b425e2200c4b8fb3da81903950d05aa 100644 (file)
@@ -303,11 +303,12 @@ public class TimeZoneTest {
 
 
                        TimeZone tz = TimeZone.CurrentTimeZone;
-                       DaylightTime daylightChanges = tz.GetDaylightChanges(2007);
+                       int year = DateTime.Now.Year;
+                       DaylightTime daylightChanges = tz.GetDaylightChanges(year);
                        DateTime dst_end = daylightChanges.End;
 
                        if (dst_end == DateTime.MinValue)
-                               Assert.Ignore (tz.StandardName + " did not observe daylight saving time during 2007.");
+                               Assert.Ignore (tz.StandardName + " did not observe daylight saving time during " + year + ".");
 
                        var standardOffset = tz.GetUtcOffset(daylightChanges.Start.AddMinutes(-1));
 
index 1742ea7ff24e40857f3a9d32fdbd362b74367ce7..8cb367e813ee930123e25bbb3a9bb94b1d3fe62c 100644 (file)
@@ -394,6 +394,7 @@ System.Text/EncoderReplacementFallbackTest.cs
 System.Text/EncoderReplacementFallbackBufferTest.cs
 System.Text/EncoderTest.cs
 System.Text/EncodingTest.cs
+System.Text/EncodingTester.cs
 System.Text/EncodingInfoTest.cs
 System.Text/StringBuilderTest.cs
 System.Text/TestEncoding.cs
diff --git a/mcs/errors/cs0171-7.cs b/mcs/errors/cs0171-7.cs
new file mode 100644 (file)
index 0000000..ab2c5dd
--- /dev/null
@@ -0,0 +1,18 @@
+// CS0171: Field `S1.s2' must be fully assigned before control leaves the constructor
+// Line: 11
+
+using System;
+
+struct S1
+{
+       S2 s2;
+
+       public S1 (int arg)
+       {
+       }
+}
+
+struct S2
+{
+       int field;
+}
index ca5ff02ecb270baaec7876c3ec476a3c327c487b..3bd7f52d6da1ad822a9c929c94c563c729da4dc0 100755 (executable)
@@ -1,4 +1,4 @@
-// CS1525: Unexpected symbol `ref', expecting `.', `?', `[', `<operator>', or `identifier'
+// CS1525: Unexpected symbol `ref'
 // Line: 8
 
 public class Test
index cda04c0e840c340724df311555d8b98032efd8bf..e84aef93322521f3d66993ef9fbfbc3f109b14a5 100644 (file)
@@ -1373,7 +1373,7 @@ namespace Mono.CSharp
 
                public SourceMethodBuilder CreateMethodSymbolEntry ()
                {
-                       if (Module.DeclaringAssembly.SymbolWriter == null)
+                       if (Module.DeclaringAssembly.SymbolWriter == null || (ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
                                return null;
 
                        var source_file = GetCompilationSourceFile ();
index 55a061cf034c4191e9aef92ed25b9228a8e3582b..7ab8f746f5309cba33a02f1c96e3a47c457e2c6a 100644 (file)
@@ -222,6 +222,8 @@ namespace Mono.CSharp
 
                public List<TryFinally> TryFinallyUnwind { get; set; }
 
+               public Label RecursivePatternLabel { get; set; }
+
                #endregion
 
                public void AddStatementEpilog (IExpressionCleanup cleanupExpression)
index 726b1f6dcdd3a442f01b3273228c570a4dc5f031..45f719a37380cea8014eaa8119e4218557fc71c3 100644 (file)
@@ -2179,6 +2179,8 @@ operator_declarator
        : operator_type OPERATOR overloadable_operator OPEN_PARENS
          {
                valid_param_mod = ParameterModifierType.DefaultValue;
+               if ((Operator.OpType) $3 == Operator.OpType.Is)
+                       valid_param_mod |= ParameterModifierType.Out;
          }
          opt_formal_parameter_list CLOSE_PARENS
          {
@@ -2203,6 +2205,8 @@ operator_declarator
                                report.Error (1535, loc, "Overloaded unary operator `{0}' takes one parameter",
                                        Operator.GetName (op));
                        }
+               } else if (op == Operator.OpType.Is) {
+                       // TODO: Special checks for is operator
                } else {
                        if (p_count == 1) {
                                report.Error (1019, loc, "Overloadable unary operator expected");
@@ -2249,6 +2253,13 @@ overloadable_operator
         | OP_LT { $$ = Operator.OpType.LessThan; }
         | OP_GE { $$ = Operator.OpType.GreaterThanOrEqual; }
         | OP_LE { $$ = Operator.OpType.LessThanOrEqual; }
+       | IS
+         {
+               if (lang_version != LanguageVersion.Experimental)
+                       FeatureIsNotAvailable (GetLocation ($1), "is user operator");
+
+               $$ = Operator.OpType.Is;
+         }
        ;
 
 conversion_operator_declarator
@@ -3114,29 +3125,21 @@ member_type
 //
 type
        : type_expression_or_array
-       | VOID
-         {
-               Expression.Error_VoidInvalidInTheContext (GetLocation ($1), report);
-               $$ = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1));
-         }     
+       | void_invalid
        ;
        
 simple_type
        : type_expression
-       | VOID
-         {
-               Expression.Error_VoidInvalidInTheContext (GetLocation ($1), report);
-               $$ = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1));
-         }     
+       | void_invalid
        ;
        
 parameter_type
        : type_expression_or_array
        | VOID
          {
-               report.Error (1536, GetLocation ($1), "Invalid parameter type `void'");
+               report.Error (1536, GetLocation ($1), "Invalid parameter type `void'");
                $$ = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1));
-         }     
+         }
        ;
 
 type_expression_or_array
@@ -3164,7 +3167,19 @@ type_expression
          {
                $$ = new ComposedCast ((ATypeNameExpression) $1, (ComposedTypeSpecifier) $2);
          }
-       | builtin_types opt_nullable
+       | builtin_type_expression
+       ;
+
+void_invalid
+       : VOID
+         {
+               Expression.Error_VoidInvalidInTheContext (GetLocation ($1), report);
+               $$ = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1));
+         }
+       ;
+
+builtin_type_expression
+       : builtin_types opt_nullable
          {
                if ($2 != null)
                        $$ = new ComposedCast ((FullNamedExpression) $1, (ComposedTypeSpecifier) $2);
@@ -3236,7 +3251,7 @@ integral_type
 
 
 primary_expression
-       : primary_expression_or_type
+       : type_name_expression
        | literal
        | array_creation_expression
        | parenthesized_expression
@@ -3258,7 +3273,7 @@ primary_expression
        | undocumented_expressions
        ;
 
-primary_expression_or_type
+type_name_expression
        : simple_name_expr
        | IDENTIFIER GENERATE_COMPLETION {
                var lt = (LocatedToken) $1;
@@ -4258,11 +4273,25 @@ additive_expression
                $$ = new Binary (Binary.Operator.Subtraction, (Expression) $1, (Expression) $3);
                lbag.AddLocation ($$, GetLocation ($2));
          }
+       | additive_expression PLUS error
+         {
+               Error_SyntaxError (yyToken);
+
+               $$ = new Binary (Binary.Operator.Addition, (Expression) $1, null);
+               lbag.AddLocation ($$, GetLocation ($2));
+         }
+       | additive_expression MINUS error
+         {
+               Error_SyntaxError (yyToken);
+
+               $$ = new Binary (Binary.Operator.Subtraction, (Expression) $1, null);
+               lbag.AddLocation ($$, GetLocation ($2));
+         }
        | additive_expression AS type
          {
                $$ = new As ((Expression) $1, (Expression) $3, GetLocation ($2));
          }
-       | additive_expression IS type opt_identifier
+       | additive_expression IS pattern_type_expr opt_identifier
          {
                var is_expr = new Is ((Expression) $1, (Expression) $3, GetLocation ($2));
                if ($4 != null) {
@@ -4276,19 +4305,13 @@ additive_expression
 
                $$ = is_expr;
          }
-       | additive_expression PLUS error 
-         {
-               Error_SyntaxError (yyToken);
-
-               $$ = new Binary (Binary.Operator.Addition, (Expression) $1, null);
-               lbag.AddLocation ($$, GetLocation ($2));
-         }
-       | additive_expression MINUS error
+       | additive_expression IS pattern_expr
          {
-               Error_SyntaxError (yyToken);
+               var is_expr = new Is ((Expression) $1, (Expression) $3, GetLocation ($2));
+               if (lang_version != LanguageVersion.Experimental)
+                       FeatureIsNotAvailable (GetLocation ($2), "pattern matching");
 
-               $$ = new Binary (Binary.Operator.Subtraction, (Expression) $1, null);
-               lbag.AddLocation ($$, GetLocation ($2));
+               $$ = is_expr;
          }
        | additive_expression AS error
          {
@@ -4314,6 +4337,86 @@ additive_expression
          }
        ;
 
+pattern_type_expr
+       : variable_type
+       ;
+
+pattern_expr
+       : literal
+       | PLUS prefixed_unary_expression
+         {
+               $$ = new Unary (Unary.Operator.UnaryPlus, (Expression) $2, GetLocation ($1));
+         }
+       | MINUS prefixed_unary_expression
+         {
+               $$ = new Unary (Unary.Operator.UnaryNegation, (Expression) $2, GetLocation ($1));
+         }
+       | sizeof_expression
+       | default_value_expression
+       | STAR
+         {
+               $$ = new WildcardPattern (GetLocation ($1));
+         }
+       | pattern_expr_invocation
+       ;
+
+pattern_expr_invocation
+       : type_name_expression OPEN_PARENS opt_pattern_list CLOSE_PARENS
+         {
+               $$ = new RecursivePattern ((ATypeNameExpression) $1, (Arguments) $3, GetLocation ($2));
+         }
+       ;
+
+pattern
+       : pattern_expr
+       | pattern_type_expr opt_identifier
+         {
+               if ($2 != null) {
+                       var lt = (LocatedToken) $2;
+                       var variable = new LocalVariable (current_block, lt.Value, lt.Location);
+                       current_block.AddLocalName (variable);
+               }
+         }
+       ;
+
+opt_pattern_list
+       : /* empty */
+         {
+               $$ = new Arguments (0);
+         }
+       | pattern_list
+       ;
+
+pattern_list
+       : pattern_argument
+         {
+               Arguments args = new Arguments (4);
+               args.Add ((Argument) $1);
+               $$ = args;
+         }
+       | pattern_list COMMA pattern_argument
+         {
+               Arguments args = (Arguments) $1;
+               if (args [args.Count - 1] is NamedArgument && !($3 is NamedArgument))
+                       Error_NamedArgumentExpected ((NamedArgument) args [args.Count - 1]);
+
+               args.Add ((Argument) $3);
+               $$ = args;
+         }
+       ;
+
+pattern_argument
+       : pattern
+         {
+               $$ = new Argument ((Expression) $1);
+         }
+       | IDENTIFIER COLON pattern
+         {
+               var lt = (LocatedToken) $1;
+               $$ = new NamedArgument (lt.Value, lt.Location, (Expression) $3);
+         }
+       ;
+
 shift_expression
        : additive_expression
        | shift_expression OP_SHIFT_LEFT additive_expression
@@ -5370,7 +5473,7 @@ variable_type
  * > The expressions are converted into types during semantic analysis.
  */
 variable_type_simple
-       : primary_expression_or_type opt_nullable
+       : type_name_expression opt_nullable
          { 
                // Ok, the above "primary_expression" is there to get rid of
                // both reduce/reduce and shift/reduces in the grammar, it should
@@ -5386,51 +5489,23 @@ variable_type_simple
                // SimpleName is when you have
                // Blah i;
                
-               Expression expr = (Expression) $1;
+               var expr = (ATypeNameExpression) $1;
                if ($2 == null) {
-                       SimpleName sn = expr as SimpleName;
-                       if (sn != null && sn.Name == "var")
-                               $$ = new VarExpr (sn.Location);
+                       if (expr.Name == "var" && expr is SimpleName)
+                               $$ = new VarExpr (expr.Location);
                        else
                                $$ = $1;
-               } else if (expr is ATypeNameExpression) {
-                       $$ = new ComposedCast ((ATypeNameExpression)expr, (ComposedTypeSpecifier) $2);
                } else {
-                       Error_ExpectingTypeName (expr);
-                       $$ = null;
-               }
-         }
-       | primary_expression_or_type pointer_stars
-         {
-               ATypeNameExpression expr = $1 as ATypeNameExpression;
-
-               if (expr != null) {
                        $$ = new ComposedCast (expr, (ComposedTypeSpecifier) $2);
-               } else {
-                       Error_ExpectingTypeName ((Expression)$1);
-                       $$ = expr;
                }
          }
-       | builtin_types opt_nullable
+       | type_name_expression pointer_stars
          {
-               if ($2 == null)
-                       $$ = $1;
-               else
-                       $$ = new ComposedCast ((FullNamedExpression) $1, (ComposedTypeSpecifier) $2);
-         }
-       | builtin_types pointer_stars
-         {
-               $$ = new ComposedCast ((FullNamedExpression) $1, (ComposedTypeSpecifier) $2);
-         }
-       | VOID pointer_stars
-         {
-               $$ = new ComposedCast (new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1)), (ComposedTypeSpecifier) $2);
-         }       
-       | VOID
-         {
-               Expression.Error_VoidInvalidInTheContext (GetLocation ($1), report);
-               $$ = new TypeExpression (compiler.BuiltinTypes.Void, GetLocation ($1));
+               var expr = (ATypeNameExpression) $1;
+               $$ = new ComposedCast (expr, (ComposedTypeSpecifier) $2);
          }
+       | builtin_type_expression
+       | void_invalid
        ;
        
 pointer_stars
@@ -5747,6 +5822,16 @@ switch_label
                Error_SyntaxError (yyToken);
                $$ = new SwitchLabel ((Expression) $2, GetLocation ($1));
          }
+       | CASE pattern_expr_invocation COLON
+         {
+               if (lang_version != LanguageVersion.Experimental)
+                       FeatureIsNotAvailable (GetLocation ($2), "pattern matching");
+
+               $$ = new SwitchLabel ((Expression) $2, GetLocation ($1)) {
+                       PatternMatching = true
+               };
+               lbag.AddLocation ($$, GetLocation ($3));
+         }
        | DEFAULT_COLON
          {
                $$ = new SwitchLabel (null, GetLocation ($1));
@@ -7896,6 +7981,7 @@ static string GetTokenName (int token)
        case Token.OP_AND_ASSIGN:
        case Token.OP_XOR_ASSIGN:
        case Token.OP_OR_ASSIGN:
+       case Token.INTERR_OPERATOR:
                return "<operator>";
 
        case Token.BOOL:
index 8637fda87059a69b9566d7760db942ebc3aa9fc2..2147c145e6c74151380ea0962a61fc614b5f359f 100644 (file)
@@ -1319,7 +1319,6 @@ namespace Mono.CSharp
                                case Token.COMMA:
                                case Token.SEMICOLON:
                                case Token.OPEN_BRACE:
-                               case Token.CLOSE_PARENS:
                                case Token.IN:
                                        next_token = Token.INTERR_NULLABLE;
                                        break;
@@ -1334,6 +1333,10 @@ namespace Mono.CSharp
                                        ++parens;
                                        goto default;
 
+                               case Token.CLOSE_PARENS:
+                                       --parens;
+                                       goto default;
+
                                case Token.OP_GENERICS_LT:
                                case Token.OP_GENERICS_LT_DECL:
                                case Token.GENERIC_DIMENSION:
index 5729e21b3e7e9275a1fe18a577598f104e3fe16e..ee0fce5619152e4da989e0f99ec8db828969f0fa 100644 (file)
@@ -230,10 +230,10 @@ namespace Mono.CSharp {
                //
                public virtual TypeSpec ResolveAsType (IMemberContext mc, bool allowUnboundTypeArguments = false)
                {
-                       ResolveContext ec = new ResolveContext (mc);
-                       Expression e = Resolve (ec);
+                       var rc = mc as ResolveContext ?? new ResolveContext (mc);
+                       Expression e = Resolve (rc);
                        if (e != null)
-                               e.Error_UnexpectedKind (ec, ResolveFlags.Type, loc);
+                               e.Error_UnexpectedKind (rc, ResolveFlags.Type, loc);
 
                        return null;
                }
index 4fa922c0110f8f4278cecea17e40d6b036d503ac..ed2860b7766685aaa149d24bdfe5ce0e34b171d0 100644 (file)
@@ -1433,30 +1433,30 @@ namespace Mono.CSharp
                        return expr.ContainsEmitWithAwait ();
                }
 
-               protected override Expression DoResolve (ResolveContext ec)
+               protected Expression ResolveCommon (ResolveContext rc)
                {
-                       probe_type_expr = ProbeType.ResolveAsType (ec);
-                       if (probe_type_expr == null)
-                               return null;
-
-                       expr = expr.Resolve (ec);
+                       expr = expr.Resolve (rc);
                        if (expr == null)
                                return null;
 
+                       ResolveProbeType (rc);
+                       if (probe_type_expr == null)
+                               return this;
+
                        if (probe_type_expr.IsStatic) {
-                               ec.Report.Error (7023, loc, "The second operand of `is' or `as' operator cannot be static type `{0}'",
+                               rc.Report.Error (7023, loc, "The second operand of `is' or `as' operator cannot be static type `{0}'",
                                        probe_type_expr.GetSignatureForError ());
                                return null;
                        }
                        
                        if (expr.Type.IsPointer || probe_type_expr.IsPointer) {
-                               ec.Report.Error (244, loc, "The `{0}' operator cannot be applied to an operand of pointer type",
+                               rc.Report.Error (244, loc, "The `{0}' operator cannot be applied to an operand of pointer type",
                                        OperatorName);
                                return null;
                        }
 
                        if (expr.Type == InternalType.AnonymousMethod || expr.Type == InternalType.MethodGroup) {
-                               ec.Report.Error (837, loc, "The `{0}' operator cannot be applied to a lambda expression, anonymous method, or method group",
+                               rc.Report.Error (837, loc, "The `{0}' operator cannot be applied to a lambda expression, anonymous method, or method group",
                                        OperatorName);
                                return null;
                        }
@@ -1464,6 +1464,11 @@ namespace Mono.CSharp
                        return this;
                }
 
+               protected virtual void ResolveProbeType (ResolveContext rc)
+               {
+                       probe_type_expr = ProbeType.ResolveAsType (rc);
+               }
+
                public override void EmitSideEffect (EmitContext ec)
                {
                        expr.EmitSideEffect (ec);
@@ -1492,6 +1497,8 @@ namespace Mono.CSharp
        public class Is : Probe
        {
                Nullable.Unwrap expr_unwrap;
+               MethodSpec number_mg;
+               Arguments number_args;
 
                public Is (Expression expr, Expression probe_type, Location l)
                        : base (expr, probe_type, l)
@@ -1533,6 +1540,16 @@ namespace Mono.CSharp
 
                public override void Emit (EmitContext ec)
                {
+                       if (probe_type_expr == null) {
+                               if (ProbeType is WildcardPattern) {
+                                       expr.EmitSideEffect (ec);
+                                       ProbeType.Emit (ec);
+                               } else {
+                                       EmitPatternMatch (ec);
+                               }
+                               return;
+                       }
+
                        EmitLoad (ec);
 
                        if (expr_unwrap == null) {
@@ -1543,10 +1560,83 @@ namespace Mono.CSharp
 
                public override void EmitBranchable (EmitContext ec, Label target, bool on_true)
                {
-                       EmitLoad (ec);
+                       if (probe_type_expr == null) {
+                               EmitPatternMatch (ec);
+                       } else {
+                               EmitLoad (ec);
+                       }
+
                        ec.Emit (on_true ? OpCodes.Brtrue : OpCodes.Brfalse, target);
                }
 
+               void EmitPatternMatch (EmitContext ec)
+               {
+                       var no_match = ec.DefineLabel ();
+                       var end = ec.DefineLabel ();
+
+                       if (expr_unwrap != null) {
+                               expr_unwrap.EmitCheck (ec);
+
+                               if (ProbeType.IsNull) {
+                                       ec.EmitInt (0);
+                                       ec.Emit (OpCodes.Ceq);
+                                       return;
+                               }
+
+                               ec.Emit (OpCodes.Brfalse_S, no_match);
+                               expr_unwrap.Emit (ec);
+                               ProbeType.Emit (ec);
+                               ec.Emit (OpCodes.Ceq);
+                               ec.Emit (OpCodes.Br_S, end);
+                               ec.MarkLabel (no_match);
+                               ec.EmitInt (0);
+                               ec.MarkLabel (end);
+                               return;
+                       }
+
+                       if (number_args != null && number_args.Count == 3) {
+                               var ce = new CallEmitter ();
+                               ce.Emit (ec, number_mg, number_args, loc);
+                               return;
+                       }
+
+                       var probe_type = ProbeType.Type;
+
+                       Expr.Emit (ec);
+                       ec.Emit (OpCodes.Isinst, probe_type);
+                       ec.Emit (OpCodes.Dup);
+                       ec.Emit (OpCodes.Brfalse, no_match);
+
+                       var rp = ProbeType as RecursivePattern;
+                       if (rp != null)
+                               ec.RecursivePatternLabel = ec.DefineLabel ();
+
+                       if (number_mg != null) {
+                               var ce = new CallEmitter ();
+                               ce.Emit (ec, number_mg, number_args, loc);
+                       } else {
+                               if (TypeSpec.IsValueType (probe_type))
+                                       ec.Emit (OpCodes.Unbox_Any, probe_type);
+
+                               ProbeType.Emit (ec);
+                               if (rp != null) {
+                                       ec.EmitInt (1);
+                               } else {
+                                       ec.Emit (OpCodes.Ceq);
+                               }
+                       }
+                       ec.Emit (OpCodes.Br_S, end);
+                       ec.MarkLabel (no_match);
+
+                       ec.Emit (OpCodes.Pop);
+
+                       if (rp != null)
+                               ec.MarkLabel (ec.RecursivePatternLabel);
+
+                       ec.EmitInt (0);
+                       ec.MarkLabel (end);
+               }
+
                void EmitLoad (EmitContext ec)
                {
                        Label no_value_label = new Label ();
@@ -1594,9 +1684,15 @@ namespace Mono.CSharp
 
                protected override Expression DoResolve (ResolveContext rc)
                {
-                       if (base.DoResolve (rc) == null)
+                       if (ResolveCommon (rc) == null)
                                return null;
 
+                       type = rc.BuiltinTypes.Bool;
+                       eclass = ExprClass.Value;
+
+                       if (probe_type_expr == null)
+                               return ResolveMatchingExpression (rc);
+
                        var res = ResolveResultExpression (rc);
                        if (Variable != null) {
                                if (res is Constant)
@@ -1619,6 +1715,110 @@ namespace Mono.CSharp
                                fc.SetVariableAssigned (Variable.VariableInfo, true);
                }
 
+               protected override void ResolveProbeType (ResolveContext rc)
+               {
+                       if (!(ProbeType is TypeExpr) && rc.Module.Compiler.Settings.Version == LanguageVersion.Experimental) {
+                               if (ProbeType is PatternExpression) {
+                                       ProbeType.Resolve (rc);
+                                       return;
+                               }
+
+                               //
+                               // Have to use session recording because we don't have reliable type probing
+                               // mechanism (similar issue as in attributes resolving)
+                               //
+                               // TODO: This is still wrong because ResolveAsType can be destructive
+                               //
+                               var type_printer = new SessionReportPrinter ();
+                               var prev_recorder = rc.Report.SetPrinter (type_printer);
+
+                               probe_type_expr = ProbeType.ResolveAsType (rc);
+                               type_printer.EndSession ();
+
+                               if (probe_type_expr != null) {
+                                       type_printer.Merge (rc.Report.Printer);
+                                       rc.Report.SetPrinter (prev_recorder);
+                                       return;
+                               }
+
+                               var vexpr = ProbeType as VarExpr;
+                               if (vexpr != null && vexpr.InferType (rc, expr)) {
+                                       probe_type_expr = vexpr.Type;
+                                       rc.Report.SetPrinter (prev_recorder);
+                                       return;
+                               }
+
+                               var expr_printer = new SessionReportPrinter ();
+                               rc.Report.SetPrinter (expr_printer);
+                               ProbeType = ProbeType.Resolve (rc);
+                               expr_printer.EndSession ();
+
+                               if (ProbeType != null) {
+                                       expr_printer.Merge (rc.Report.Printer);
+                               } else {
+                                       type_printer.Merge (rc.Report.Printer);
+                               }
+
+                               rc.Report.SetPrinter (prev_recorder);
+                               return;
+                       }
+
+                       base.ResolveProbeType (rc);
+               }
+
+               Expression ResolveMatchingExpression (ResolveContext rc)
+               {
+                       var mc = ProbeType as Constant;
+                       if (mc != null) {
+                               if (!Convert.ImplicitConversionExists (rc, ProbeType, Expr.Type)) {
+                                       ProbeType.Error_ValueCannotBeConverted (rc, Expr.Type, false);
+                                       return null;
+                               }
+
+                               if (mc.IsNull)
+                                       return new Binary (Binary.Operator.Equality, Expr, mc).Resolve (rc);
+
+                               var c = Expr as Constant;
+                               if (c != null) {
+                                       c = ConstantFold.BinaryFold (rc, Binary.Operator.Equality, c, mc, loc);
+                                       if (c != null)
+                                               return c;
+                               }
+
+                               if (Expr.Type.IsNullableType) {
+                                       expr_unwrap = new Nullable.Unwrap (Expr);
+                                       expr_unwrap.Resolve (rc);
+                               } else if (ProbeType.Type.IsEnum || (ProbeType.Type.BuiltinType >= BuiltinTypeSpec.Type.Byte && ProbeType.Type.BuiltinType <= BuiltinTypeSpec.Type.Decimal)) {
+                                       var helper = rc.Module.CreatePatterMatchingHelper ();
+                                       number_mg = helper.NumberMatcher.Spec;
+
+                                       //
+                                       // There are actually 3 arguments but the first one is already on the stack
+                                       //
+                                       number_args = new Arguments (3);
+                                       if (!ProbeType.Type.IsEnum)
+                                               number_args.Add (new Argument (Expr));
+
+                                       number_args.Add (new Argument (Convert.ImplicitConversion (rc, ProbeType, rc.BuiltinTypes.Object, loc)));
+                                       number_args.Add (new Argument (new BoolLiteral (rc.BuiltinTypes, ProbeType.Type.IsEnum, loc)));
+                               }
+
+                               return this;
+                       }
+
+                       if (ProbeType is PatternExpression) {
+                               if (!(ProbeType is WildcardPattern) && !Convert.ImplicitConversionExists (rc, ProbeType, Expr.Type)) {
+                                       ProbeType.Error_ValueCannotBeConverted (rc, Expr.Type, false);
+                               }
+
+                               return this;
+                       }
+
+                       // TODO: Better error message
+                       rc.Report.Error (150, ProbeType.Location, "A constant value is expected");
+                       return this;
+               }
+
                Expression ResolveResultExpression (ResolveContext ec)
                {
                        TypeSpec d = expr.Type;
@@ -1638,9 +1838,7 @@ namespace Mono.CSharp
                                        d_is_nullable = true;
                                }
                        }
-
-                       type = ec.BuiltinTypes.Bool;
-                       eclass = ExprClass.Value;
+                               
                        TypeSpec t = probe_type_expr;
                        bool t_is_nullable = false;
                        if (t.IsNullableType) {
@@ -1767,12 +1965,233 @@ namespace Mono.CSharp
                }
        }
 
+       class WildcardPattern : PatternExpression
+       {
+               public WildcardPattern (Location loc)
+                       : base (loc)
+               {
+               }
+
+               protected override Expression DoResolve (ResolveContext rc)
+               {
+                       eclass = ExprClass.Value;
+                       type = rc.BuiltinTypes.Object;
+                       return this;
+               }
+
+               public override void Emit (EmitContext ec)
+               {
+                       ec.EmitInt (1);
+               }
+       }
+
+       class RecursivePattern : PatternExpression
+       {
+               MethodGroupExpr operator_mg;
+               Expression[] args_comparison;
+               Arguments operator_args;
+
+               public RecursivePattern (ATypeNameExpression typeExpresion, Arguments arguments, Location loc)
+                       : base (loc)
+               {
+                       Arguments = arguments;
+                       TypeExpression = typeExpresion;
+               }
+
+               public Arguments Arguments { get; private set; }
+
+               public ATypeNameExpression TypeExpression { get; private set; }
+
+               protected override Expression DoResolve (ResolveContext rc)
+               {
+                       type = TypeExpression.ResolveAsType (rc);
+                       if (type == null)
+                               return null;
+
+                       var operators = MemberCache.GetUserOperator (type, Operator.OpType.Is, true);
+                       if (operators == null) {
+                               Error_TypeDoesNotContainDefinition (rc, type, Operator.GetName (Operator.OpType.Is) + " operator");
+                               return null;
+                       }
+
+                       var ops = FindMatchingOverloads (operators);
+                       if (ops == null) {
+                               // TODO: better error message
+                               Error_TypeDoesNotContainDefinition (rc, type, Operator.GetName (Operator.OpType.Is) + " operator");
+                               return null;
+                       }
+
+                       bool dynamic_args;
+                       Arguments.Resolve (rc, out dynamic_args);
+                       if (dynamic_args)
+                               throw new NotImplementedException ("dynamic argument");
+
+                       var op = FindBestOverload (rc, ops);
+                       if (op == null) {
+                               // TODO: better error message
+                               Error_TypeDoesNotContainDefinition (rc, type, Operator.GetName (Operator.OpType.Is) + " operator");
+                               return null;
+                       }
+
+                       var op_types = op.Parameters.Types;
+                       operator_args = new Arguments (op_types.Length);
+                       operator_args.Add (new Argument (new EmptyExpression (type)));
+
+                       for (int i = 0; i < Arguments.Count; ++i) {
+                               // TODO: Needs releasing optimization
+                               var lt = new LocalTemporary (op_types [i + 1]);
+                               operator_args.Add (new Argument (lt, Argument.AType.Out));
+
+                               if (args_comparison == null)
+                                       args_comparison = new Expression[Arguments.Count];
+
+                               int arg_comp_index;
+                               Expression expr;
+
+                               var arg = Arguments [i];
+                               var named = arg as NamedArgument;
+                               if (named != null) {
+                                       arg_comp_index = op.Parameters.GetParameterIndexByName (named.Name) - 1;
+                                       expr = Arguments [arg_comp_index].Expr;
+                               } else {
+                                       arg_comp_index = i;
+                                       expr = arg.Expr;
+                               }
+
+                               if (expr is WildcardPattern) {
+                                       args_comparison [arg_comp_index] = new EmptyExpression (expr.Type);
+                                       continue;
+                               }
+
+                               var recursive = expr as RecursivePattern;
+                               if (recursive != null) {
+                                       recursive.SetParentInstance (lt);
+                               }
+
+                               expr = Convert.ImplicitConversionRequired (rc, expr, lt.Type, expr.Location);
+                               if (expr == null)
+                                       continue;
+
+                               if (expr is RecursivePattern) {
+                                       args_comparison [arg_comp_index] = expr;
+                                       continue;
+                               }
+
+                               // TODO: Better error handling
+                               args_comparison [arg_comp_index] = new Binary (Binary.Operator.Equality, lt, expr, expr.Location).Resolve (rc);
+                       }
+
+                       operator_mg = MethodGroupExpr.CreatePredefined (op, type, loc);
+
+                       eclass = ExprClass.Value;
+                       return this;
+               }
+
+               List<MethodSpec> FindMatchingOverloads (IList<MemberSpec> members)
+               {
+                       int arg_count = Arguments.Count + 1;
+                       List<MethodSpec> best = null;
+                       foreach (MethodSpec method in members) {
+                               var pm = method.Parameters;
+                               if (pm.Count != arg_count)
+                                       continue;
+
+                               // TODO: Needs more thorough checks elsewhere to avoid doing this every time
+                               bool ok = true;
+                               for (int ii = 1; ii < pm.Count; ++ii) {
+                                       if ((pm.FixedParameters [ii].ModFlags & Parameter.Modifier.OUT) == 0) {
+                                               ok = false;
+                                               break;
+                                       }
+                               }
+
+                               if (!ok)
+                                       continue;
+
+                               if (best == null)
+                                       best = new List<MethodSpec> ();
+
+                               best.Add (method);
+                       }
+
+                       return best;
+               }
+
+               MethodSpec FindBestOverload (ResolveContext rc, List<MethodSpec> methods)
+               {
+                       for (int ii = 0; ii < Arguments.Count; ++ii) {
+                               var arg = Arguments [ii];
+                               var expr = arg.Expr;
+                               if (expr is WildcardPattern)
+                                       continue;
+
+                               var na = arg as NamedArgument;
+                               for (int i = 0; i < methods.Count; ++i) {
+                                       var pd = methods [i].Parameters;
+
+                                       int index;
+                                       if (na != null) {
+                                               index = pd.GetParameterIndexByName (na.Name);
+                                               if (index < 1) {
+                                                       methods.RemoveAt (i--);
+                                                       continue;
+                                               }
+                                       } else {
+                                               index = ii + 1;
+                                       }
+
+                                       var m = pd.Types [index];
+                                       if (!Convert.ImplicitConversionExists (rc, expr, m))
+                                               methods.RemoveAt (i--);
+                               }
+                       }
+
+                       if (methods.Count != 1)
+                               return null;
+
+                       return methods [0];
+               }
+
+               public override void Emit (EmitContext ec)
+               {
+                       EmitBranchable (ec, ec.RecursivePatternLabel, false);
+               }
+
+               public override void EmitBranchable (EmitContext ec, Label target, bool on_true)
+               {
+                       operator_mg.EmitCall (ec, operator_args, false);
+                       ec.Emit (OpCodes.Brfalse, ec.RecursivePatternLabel);
+                       if (args_comparison != null) {
+                               foreach (var ac in args_comparison) {
+                                       ac.EmitBranchable (ec, ec.RecursivePatternLabel, false);
+                               }
+                       }
+               }
+
+               void SetParentInstance (LocalTemporary instance)
+               {
+                       operator_args [0] = new Argument (instance);
+               }
+       }
+
+       abstract class PatternExpression : Expression
+       {
+               protected PatternExpression (Location loc)
+               {
+                       this.loc = loc;
+               }
+
+               public override Expression CreateExpressionTree (ResolveContext ec)
+               {
+                       throw new NotImplementedException ();
+               }
+       }
+
        /// <summary>
        ///   Implementation of the `as' operator.
        /// </summary>
        public class As : Probe {
-               Expression resolved_type;
-               
+
                public As (Expression expr, Expression probe_type, Location l)
                        : base (expr, probe_type, l)
                {
@@ -1803,12 +2222,8 @@ namespace Mono.CSharp
 
                protected override Expression DoResolve (ResolveContext ec)
                {
-                       if (resolved_type == null) {
-                               resolved_type = base.DoResolve (ec);
-
-                               if (resolved_type == null)
-                                       return null;
-                       }
+                       if (ResolveCommon (ec) == null)
+                               return null;
 
                        type = probe_type_expr;
                        eclass = ExprClass.Value;
@@ -2556,11 +2971,16 @@ namespace Mono.CSharp
                }
 
                public Binary (Operator oper, Expression left, Expression right)
+                       : this (oper, left, right, left.Location)
+               {
+               }
+
+               public Binary (Operator oper, Expression left, Expression right, Location loc)
                {
                        this.oper = oper;
                        this.left = left;
                        this.right = right;
-                       this.loc = left.Location;
+                       this.loc = loc;
                }
 
                #region Properties
@@ -10402,6 +10822,10 @@ namespace Mono.CSharp
                        // nothing, as we only exist to not do anything.
                }
 
+               public override void EmitBranchable (EmitContext ec, Label target, bool on_true)
+               {
+               }
+
                public override void EmitSideEffect (EmitContext ec)
                {
                }
index 7336f1dbf858ade6e732cba67fd63fba724eb364..3837af2c2d8779e36d7cb82a064f3f5fbaeeb0e6 100644 (file)
@@ -697,14 +697,6 @@ namespace Mono.CSharp {
                                        if ((name_entry.Modifiers & Modifiers.STATIC) != 0)
                                                continue;
 
-                                       //
-                                       // Ignore user private fields for definite assignment. This is sort of unexpected but
-                                       // rationale is to have consistent results when using reference assemblies which don't
-                                       // include any private fields and full assemblies
-                                       //
-                                       if ((name_entry.Modifiers & (Modifiers.PRIVATE | Modifiers.BACKING_FIELD)) == Modifiers.PRIVATE)
-                                               continue;
-
                                        //
                                        // Fixed size buffers are not subject to definite assignment checking
                                        //
index aa54bc4a4d901113475761badf71da50625c1983..a78b99c6419bcf212b1a9e67b90586bed3371a7e 100644 (file)
@@ -2571,6 +2571,9 @@ namespace Mono.CSharp {
                        Implicit,
                        Explicit,
 
+                       // Pattern matching
+                       Is,
+
                        // Just because of enum
                        TOP
                };
@@ -2608,6 +2611,7 @@ namespace Mono.CSharp {
                        names [(int) OpType.LessThanOrEqual] = new string [] { "<=", "op_LessThanOrEqual" };
                        names [(int) OpType.Implicit] = new string [] { "implicit", "op_Implicit" };
                        names [(int) OpType.Explicit] = new string [] { "explicit", "op_Explicit" };
+                       names [(int) OpType.Is] = new string[] { "is", "op_Is" };
                }
 
                public Operator (TypeDefinition parent, OpType type, FullNamedExpression ret_type, Modifiers mod_flags, ParametersCompiled parameters,
index e7e02a0bf14d7f0a1fe29840919fcb06dac0f745..138ec61638f00ed03c0955b9f90684c96516fde6 100644 (file)
@@ -105,6 +105,141 @@ namespace Mono.CSharp
                }
 #endif
 
+               public sealed class PatternMatchingHelper : CompilerGeneratedContainer
+               {
+                       public PatternMatchingHelper (ModuleContainer module)
+                               : base (module, new MemberName ("<PatternMatchingHelper>", Location.Null),
+                                       Modifiers.STATIC | Modifiers.INTERNAL | Modifiers.DEBUGGER_HIDDEN)
+                       {
+                       }
+
+                       public Method NumberMatcher { get; private set; }
+
+                       protected override bool DoDefineMembers ()
+                       {
+                               if (!base.DoDefineMembers ())
+                                       return false;
+
+                               NumberMatcher = GenerateNumberMatcher ();
+                               return true;
+                       }
+
+                       Method GenerateNumberMatcher ()
+                       {
+                               var loc = Location;
+                               var parameters = ParametersCompiled.CreateFullyResolved (
+                                       new [] {
+                                               new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "obj", 0, null, loc),
+                                               new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "value", 0, null, loc),
+                                               new Parameter (new TypeExpression (Compiler.BuiltinTypes.Bool, loc), "enumType", 0, null, loc),
+                                       },
+                                       new [] {
+                                               Compiler.BuiltinTypes.Object,
+                                               Compiler.BuiltinTypes.Object,
+                                               Compiler.BuiltinTypes.Bool
+                                       });
+
+                               var m = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Bool, loc),
+                                       Modifiers.PUBLIC | Modifiers.STATIC | Modifiers.DEBUGGER_HIDDEN, new MemberName ("NumberMatcher", loc),
+                                       parameters, null);
+
+                               parameters [0].Resolve (m, 0);
+                               parameters [1].Resolve (m, 1);
+                               parameters [2].Resolve (m, 2);
+
+                               ToplevelBlock top_block = new ToplevelBlock (Compiler, parameters, loc);
+                               m.Block = top_block;
+
+                               //
+                               // if (enumType)
+                               //              return Equals (obj, value);
+                               //
+                               var equals_args = new Arguments (2);
+                               equals_args.Add (new Argument (top_block.GetParameterReference (0, loc)));
+                               equals_args.Add (new Argument (top_block.GetParameterReference (1, loc)));
+
+                               var if_type = new If (
+                                                     top_block.GetParameterReference (2, loc),
+                                                     new Return (new Invocation (new SimpleName ("Equals", loc), equals_args), loc),
+                                                     loc);
+
+                               top_block.AddStatement (if_type);
+
+                               //
+                               // if (obj is Enum || obj == null)
+                               //              return false;
+                               //
+
+                               var if_enum = new If (
+                                                     new Binary (Binary.Operator.LogicalOr,
+                                                             new Is (top_block.GetParameterReference (0, loc), new TypeExpression (Compiler.BuiltinTypes.Enum, loc), loc),
+                                                             new Binary (Binary.Operator.Equality, top_block.GetParameterReference (0, loc), new NullLiteral (loc))),
+                                                     new Return (new BoolLiteral (Compiler.BuiltinTypes, false, loc), loc),
+                                                     loc);
+
+                               top_block.AddStatement (if_enum);
+
+
+                               var system_convert = new MemberAccess (new QualifiedAliasMember ("global", "System", loc), "Convert", loc);
+                               var expl_block = new ExplicitBlock (top_block, loc, loc);
+
+                               //
+                               // var converted = System.Convert.ChangeType (obj, System.Convert.GetTypeCode (value));
+                               //
+                               var lv_converted = LocalVariable.CreateCompilerGenerated (Compiler.BuiltinTypes.Object, top_block, loc);
+
+                               var arguments_gettypecode = new Arguments (1);
+                               arguments_gettypecode.Add (new Argument (top_block.GetParameterReference (1, loc)));
+
+                               var gettypecode = new Invocation (new MemberAccess (system_convert, "GetTypeCode", loc), arguments_gettypecode);
+
+                               var arguments_changetype = new Arguments (1);
+                               arguments_changetype.Add (new Argument (top_block.GetParameterReference (0, loc)));
+                               arguments_changetype.Add (new Argument (gettypecode));
+
+                               var changetype = new Invocation (new MemberAccess (system_convert, "ChangeType", loc), arguments_changetype);
+
+                               expl_block.AddStatement (new StatementExpression (new SimpleAssign (new LocalVariableReference (lv_converted, loc), changetype, loc)));
+
+
+                               //
+                               // return converted.Equals (value)
+                               //
+                               var equals_arguments = new Arguments (1);
+                               equals_arguments.Add (new Argument (top_block.GetParameterReference (1, loc)));
+                               var equals_invocation = new Invocation (new MemberAccess (new LocalVariableReference (lv_converted, loc), "Equals"), equals_arguments);
+                               expl_block.AddStatement (new Return (equals_invocation, loc));
+
+                               var catch_block = new ExplicitBlock (top_block, loc, loc);
+                               catch_block.AddStatement (new Return (new BoolLiteral (Compiler.BuiltinTypes, false, loc), loc));
+                               top_block.AddStatement (new TryCatch (expl_block, new List<Catch> () {
+                                       new Catch (catch_block, loc)
+                               }, loc, false));
+
+                               m.Define ();
+                               m.PrepareEmit ();
+                               AddMember (m);
+
+                               return m;
+                       }
+               }
+
+               PatternMatchingHelper pmh;
+
+               public PatternMatchingHelper CreatePatterMatchingHelper ()
+               {
+                       if (pmh == null) {
+                               pmh = new PatternMatchingHelper (this);
+
+                               pmh.CreateContainer ();
+                               pmh.DefineContainer ();
+                               pmh.Define ();
+                               AddCompilerGeneratedClass (pmh);
+                       }
+
+                       return pmh;
+               }
+
                public CharSet? DefaultCharSet;
                public TypeAttributes DefaultCharSetType = TypeAttributes.AnsiClass;
 
index 1af77f12fd6674932d081d7a7b282113f3415505..970e2ca024ef6b6270953f4c8fe816ba14cd7596 100644 (file)
@@ -488,7 +488,21 @@ namespace Mono.CSharp {
 
                public void RemoveContainer (TypeContainer tc)
                {
-                       types.Remove (tc.Basename);
+                       IList<TypeSpec> found;
+                       if (types.TryGetValue (tc.MemberName.Name, out found)) {
+                               for (int i = 0; i < found.Count; ++i) {
+                                       if (tc.MemberName.Arity != found [i].Arity)
+                                               continue;
+
+                                       if (found.Count == 1)
+                                               types.Remove (tc.MemberName.Name);
+                                       else
+                                               found.RemoveAt (i);
+
+                                       break;
+                               }
+                       }
+
                        cached_types.Remove (tc.Basename);
                }
 
index 441d65780c1fe7095e5ab81f6536b7abc8b220ca..e46dca447eb4696c322dae674237ffbb2bcc4e40 100644 (file)
@@ -4471,6 +4471,8 @@ namespace Mono.CSharp {
                        }
                }
 
+               public bool PatternMatching { get; set; }
+
                public bool SectionStart { get; set; }
 
                public Label GetILLabel (EmitContext ec)
@@ -4508,21 +4510,33 @@ namespace Mono.CSharp {
                // Resolves the expression, reduces it to a literal if possible
                // and then converts it to the requested type.
                //
-               bool ResolveAndReduce (BlockContext rc)
+               bool ResolveAndReduce (BlockContext bc)
                {
                        if (IsDefault)
                                return true;
 
-                       var c = label.ResolveLabelConstant (rc);
+                       var switch_statement = bc.Switch;
+
+                       if (PatternMatching) {
+                               label = new Is (switch_statement.ExpressionValue, label, loc).Resolve (bc);
+                               return label != null;
+                       }
+
+                       var c = label.ResolveLabelConstant (bc);
                        if (c == null)
                                return false;
 
-                       if (rc.Switch.IsNullable && c is NullLiteral) {
+                       if (switch_statement.IsNullable && c is NullLiteral) {
                                converted = c;
                                return true;
                        }
 
-                       converted = c.ImplicitConversionRequired (rc, rc.Switch.SwitchType);
+                       if (switch_statement.IsPatternMatching) {
+                               label = new Is (switch_statement.ExpressionValue, label, loc).Resolve (bc);
+                               return true;
+                       }
+
+                       converted = c.ImplicitConversionRequired (bc, switch_statement.SwitchType);
                        return converted != null;
                }
 
@@ -4728,12 +4742,24 @@ namespace Mono.CSharp {
                        }
                }
 
+               public bool IsPatternMatching {
+                       get {
+                               return new_expr == null && SwitchType != null;
+                       }
+               }
+
                public List<SwitchLabel> RegisteredLabels {
                        get {
                                return case_labels;
                        }
                }
 
+               public VariableReference ExpressionValue {
+                       get {
+                               return value;
+                       }
+               }
+
                //
                // Determines the governing type for a switch.  The returned
                // expression might be the expression from the switch, or an
@@ -4843,6 +4869,9 @@ namespace Mono.CSharp {
                                return;
                        }
 
+                       if (sl.Converted == null)
+                               return;
+
                        try {
                                if (string_labels != null) {
                                        string string_value = sl.Converted.GetValue () as string;
@@ -4851,7 +4880,7 @@ namespace Mono.CSharp {
                                        else
                                                string_labels.Add (string_value, sl);
                                } else {
-                                       if (sl.Converted is NullLiteral) {
+                                       if (sl.Converted.IsNull) {
                                                case_null = sl;
                                        } else {
                                                labels.Add (sl.Converted.GetValueAsLong (), sl);
@@ -5066,39 +5095,44 @@ namespace Mono.CSharp {
                                }
                        }
 
+                       Expression switch_expr;
                        if (new_expr == null) {
-                               if (Expr.Type != InternalType.ErrorType) {
-                                       ec.Report.Error (151, loc,
-                                               "A switch expression of type `{0}' cannot be converted to an integral type, bool, char, string, enum or nullable type",
-                                               Expr.Type.GetSignatureForError ());
-                               }
+                               if (ec.Module.Compiler.Settings.Version != LanguageVersion.Experimental) {
+                                       if (Expr.Type != InternalType.ErrorType) {
+                                               ec.Report.Error (151, loc,
+                                                       "A switch expression of type `{0}' cannot be converted to an integral type, bool, char, string, enum or nullable type",
+                                                       Expr.Type.GetSignatureForError ());
+                                       }
 
-                               return false;
-                       }
+                                       return false;
+                               }
 
-                       SwitchType = new_expr.Type;
-                       if (SwitchType.IsNullableType) {
-                               new_expr = unwrap = Nullable.Unwrap.Create (new_expr, true);
-                               SwitchType = Nullable.NullableInfo.GetUnderlyingType (SwitchType);
-                       }
+                               switch_expr = Expr;
+                               SwitchType = Expr.Type;
+                       } else {
+                               switch_expr = new_expr;
+                               SwitchType = new_expr.Type;
+                               if (SwitchType.IsNullableType) {
+                                       new_expr = unwrap = Nullable.Unwrap.Create (new_expr, true);
+                                       SwitchType = Nullable.NullableInfo.GetUnderlyingType (SwitchType);
+                               }
 
-                       if (SwitchType.BuiltinType == BuiltinTypeSpec.Type.Bool && ec.Module.Compiler.Settings.Version == LanguageVersion.ISO_1) {
-                               ec.Report.FeatureIsNotAvailable (ec.Module.Compiler, loc, "switch expression of boolean type");
-                               return false;
-                       }
+                               if (SwitchType.BuiltinType == BuiltinTypeSpec.Type.Bool && ec.Module.Compiler.Settings.Version == LanguageVersion.ISO_1) {
+                                       ec.Report.FeatureIsNotAvailable (ec.Module.Compiler, loc, "switch expression of boolean type");
+                                       return false;
+                               }
 
-                       if (block.Statements.Count == 0)
-                               return true;
+                               if (block.Statements.Count == 0)
+                                       return true;
 
-                       if (SwitchType.BuiltinType == BuiltinTypeSpec.Type.String) {
-                               string_labels = new Dictionary<string, SwitchLabel> ();
-                       } else {
-                               labels = new Dictionary<long, SwitchLabel> ();
+                               if (SwitchType.BuiltinType == BuiltinTypeSpec.Type.String) {
+                                       string_labels = new Dictionary<string, SwitchLabel> ();
+                               } else {
+                                       labels = new Dictionary<long, SwitchLabel> ();
+                               }
                        }
 
-                       case_labels = new List<SwitchLabel> ();
-
-                       var constant = new_expr as Constant;
+                       var constant = switch_expr as Constant;
 
                        //
                        // Don't need extra variable for constant switch or switch with
@@ -5108,7 +5142,7 @@ namespace Mono.CSharp {
                                //
                                // Store switch expression for comparison purposes
                                //
-                               value = new_expr as VariableReference;
+                               value = switch_expr as VariableReference;
                                if (value == null && !HasOnlyDefaultSection ()) {
                                        var current_block = ec.CurrentBlock;
                                        ec.CurrentBlock = Block;
@@ -5119,6 +5153,8 @@ namespace Mono.CSharp {
                                }
                        }
 
+                       case_labels = new List<SwitchLabel> ();
+
                        Switch old_switch = ec.Switch;
                        ec.Switch = this;
                        var parent_los = ec.EnclosingLoopOrSwitch;
@@ -5411,6 +5447,11 @@ namespace Mono.CSharp {
 
                                var constant = label.Converted;
 
+                               if (constant == null) {
+                                       label.Label.EmitBranchable (ec, label.GetILLabel (ec), true);
+                                       continue;
+                               }
+
                                if (equal_method != null) {
                                        value.Emit (ec);
                                        constant.Emit (ec);
@@ -5436,6 +5477,11 @@ namespace Mono.CSharp {
 
                void EmitDispatch (EmitContext ec)
                {
+                       if (IsPatternMatching) {
+                               EmitShortSwitch (ec);
+                               return;
+                       }
+
                        if (value == null) {
                                //
                                // Constant switch, we've already done the work if there is only 1 label
@@ -5483,12 +5529,14 @@ namespace Mono.CSharp {
 
                        if (value != null) {
                                ec.Mark (loc);
+
+                               var switch_expr = new_expr ?? Expr;
                                if (IsNullable) {
                                        unwrap.EmitCheck (ec);
                                        ec.Emit (OpCodes.Brfalse, nullLabel);
-                                       value.EmitAssign (ec, new_expr, false, false);
-                               } else if (new_expr != value) {
-                                       value.EmitAssign (ec, new_expr, false, false);
+                                       value.EmitAssign (ec, switch_expr, false, false);
+                               } else if (switch_expr != value) {
+                                       value.EmitAssign (ec, switch_expr, false, false);
                                }
 
 
index 1d2a5ad00fa628e21febda28d8547cff4713be55..2071b625c3a40ca8c51338cbaf98ede4ae7c6cca 100644 (file)
@@ -150,6 +150,11 @@ public class ConditionalParsing
                }
        }
 
+       void Test_18 (bool b, Action a)
+       {
+               var e = b ? () => { } : a;
+       }
+
        static void Helper<T> (T arg)
        {
        }
diff --git a/mcs/tests/test-888.cs b/mcs/tests/test-888.cs
deleted file mode 100644 (file)
index 6cf0d50..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-using System;
-
-// C#6 change
-
-struct S1
-{
-       S2 s2;
-
-       public S1 (int arg)
-       {
-       }
-}
-
-struct S2
-{
-       int field;
-}
-
-class X
-{
-       public static void Main ()
-       {
-       }
-}
\ No newline at end of file
index f9d627f0e67d4326b4920b3b643b8f8075fd5e35..6db67fb16726fcc16c64a92e004451554f8ff008 100644 (file)
@@ -7,7 +7,7 @@ class TypePattern
        public static int Main ()
        {
                object o = 3;
-               bool r = o is string t1;
+               bool r = o is System.String t1;
                if (t1 != null)
                        return 1;
 
diff --git a/mcs/tests/test-pattern-02.cs b/mcs/tests/test-pattern-02.cs
new file mode 100644 (file)
index 0000000..695775e
--- /dev/null
@@ -0,0 +1,93 @@
+// Compiler options: -langversion:experimental
+
+using System;
+
+enum MyEnum : short
+{
+       V_4 = 4
+}
+
+class ConstantPattern
+{
+       static bool Generic<T> (T t) where T : class
+       {
+               return t is default (T);
+       }
+
+       public static int Main ()
+       {
+               bool b4 = false;
+               b4 = !b4;
+               object o = "x";
+               bool r1 = o is "y";
+               if (r1)
+                       return 1;
+
+               r1 = o is "x";
+               if (!r1)
+                       return 2;
+
+               string s = "o";
+               if (s is null)
+                       return 3;
+
+               if (s is "oo")
+                       return 4;
+
+               if (!(s is "o"))
+                       return 5;
+
+               int? o3 = 4;
+               bool r3 = o3 is null;
+               if (r3)
+                       return 6;
+               
+               r3 = o3 is 4;
+               if (!r3)
+                       return 7;
+
+               object o4 = (byte?)255;
+               var ggg = o4 is 255;
+               if (!ggg)
+                       return 8;
+
+               if (o4 is null)
+                       return 9;
+
+               object o5 = (double)-255;
+               if (!(o5 is -byte.MaxValue))
+                       return 10;
+
+               object o6 = MyEnum.V_4;
+               bool r4 = o6 is 4;
+               if (r4)
+                       return 11;
+
+               r4 = o6 is MyEnum.V_4;
+               if (!r4)
+                       return 12;
+
+               ConstantPattern o7 = new ConstantPattern ();
+               if (!(o7 is ConstantPattern))
+                       return 13;
+
+               if (!(o7 is object))
+                       return 14;
+
+               object o8 = true;
+               if (o8 is false)
+                       return 15;
+
+               if (!(o8 is true))
+                       return 16;
+
+               if (Generic (""))
+                       return 17;
+
+               if (!Generic<Delegate> (null))
+                       return 18;
+
+               Console.WriteLine ("ok");
+               return 0;
+       }
+}
\ No newline at end of file
diff --git a/mcs/tests/test-pattern-03.cs b/mcs/tests/test-pattern-03.cs
new file mode 100644 (file)
index 0000000..c4793bd
--- /dev/null
@@ -0,0 +1,14 @@
+// Compiler options: -langversion:experimental
+
+class WildcardPattern
+{
+       static int Main ()
+       {
+               long? o = 1;
+               bool b = o is *;
+               if (!b)
+                       return 1;
+
+               return 0;
+       }
+}
\ No newline at end of file
diff --git a/mcs/tests/test-pattern-04.cs b/mcs/tests/test-pattern-04.cs
new file mode 100644 (file)
index 0000000..dff391c
--- /dev/null
@@ -0,0 +1,77 @@
+// Compiler options: -langversion:experimental
+
+using System;
+
+class RecursivePattern
+{
+       static int Main ()
+       {
+               object o = null;
+               bool b = o is C1 (8);
+               if (b)
+                       return 1;
+
+               o = new C1 ();
+               b = o is C1 (-4);
+               if (b)
+                       return 2;
+
+               b = o is C1 (8);
+               if (!b)
+                       return 3;
+
+               b = o is C1 (C1 (9), C1 (8));
+               if (b)
+                       return 4;
+
+               b = o is C1 (C1 (*), C1 (8));
+               if (!b)
+                       return 41;
+
+               b = o is C1 (0);
+               if (b)
+                       return 5;
+
+               ValueType vt = new S ();
+               b = vt is S (null, 0);
+               if (b)
+                       return 6;
+
+               b = vt is S (8, 0);
+               if (b)
+                       return 7;
+
+               b = vt is S (8, 2);
+               if (!b)
+                       return 8;
+
+               Console.WriteLine ("ok");
+               return 0;
+       }
+}
+
+class C1
+{
+       public static bool operator is (C1 c, out int x)
+       {
+               x = 8;
+               return true;
+       }
+
+       public static bool operator is (C1 c, out C1 c2, out C1 c3)
+       {
+               c2 = null;
+               c3 = null;
+               return true;
+       }
+}
+
+struct S
+{
+       public static bool operator is (S s, out int? x, out decimal d)
+       {
+               x = 8;
+               d = 2;
+               return true;
+       }
+}
\ No newline at end of file
diff --git a/mcs/tests/test-pattern-05.cs b/mcs/tests/test-pattern-05.cs
new file mode 100644 (file)
index 0000000..7553acd
--- /dev/null
@@ -0,0 +1,39 @@
+// Compiler options: -langversion:experimental
+
+using System;
+
+class RecursiveNamedPattern
+{
+       public static int Main ()
+       {
+               object o = new C ();
+               bool b = o is C (name2: "", name1: -2);
+               if (b)
+                       return 1;
+
+               b = o is C (name2: "n2", name1: -2);
+               if (!b)
+                       return 2;
+
+               b = o is C ();
+               if (b)
+                       return 3;
+
+               return 0;
+       }
+}
+
+class C
+{
+       public static bool operator is (C c, out long name1, out string name2)
+       {
+               name1 = -2;
+               name2 = "n2";
+               return true;
+       }
+
+       public static bool operator is (C c)
+       {
+               return false;
+       }
+}
\ No newline at end of file
diff --git a/mcs/tests/test-pattern-06.cs b/mcs/tests/test-pattern-06.cs
new file mode 100644 (file)
index 0000000..3b54b84
--- /dev/null
@@ -0,0 +1,68 @@
+// Compiler options: -langversion:experimental
+
+using System;
+
+class RecursiveNamedPattern
+{
+       public static int Main ()
+       {
+               if (Switch_1 (null) != 4)
+                       return 1;
+
+               if (Switch_1 ("x") != 5)
+                       return 2;
+
+               if (Switch_1 (1) != 1)
+                       return 3;
+
+               if (Switch_1 (new C1 ()) != 3)
+                       return 4;
+
+               if (Switch_1 ((byte?) 1) != 1)
+                       return 5;
+
+               if (Switch_2 (new C1 ()) != 3)
+                       return 10;
+
+               if (Switch_2 (null) != 2)
+                       return 11;
+
+               Console.WriteLine ("ok");
+               return 0;
+       }
+
+       static int Switch_1 (object o)
+       {
+               switch (o) {
+                       case 1:
+                               return 1;
+                       case C1 (3):
+                               return 2;
+                       case C1 (2):
+                               return 3;
+                       case null:
+                               return 4;
+                       default:
+                               return 5;
+               }
+       }
+
+       static int Switch_2 (C1 o)
+       {
+               switch (o) {
+                       case null:
+                               return 2;
+               }
+
+               return 3;
+       }
+}
+
+public class C1
+{
+       public static bool operator is (C1 c1, out int i)
+       {
+               i = 2;
+               return true;
+       }
+}
index 7068645c0470c1e53d7523e8a3a209936a220ed9..12fab60c02747f28b228efaed3554d42812f04d4 100644 (file)
       <method name="Int32 &lt;Test_12&gt;m__0(System.Object)" attrs="145">\r
         <size>10</size>\r
       </method>\r
+      <method name="Void Test_18(Boolean, System.Action)" attrs="129">\r
+        <size>44</size>\r
+      </method>\r
+      <method name="Void &lt;Test_18&gt;m__1(System.Object)" attrs="145">\r
+        <size>2</size>\r
+      </method>\r
     </type>\r
   </test>\r
   <test name="gtest-410.cs">\r
       </method>\r
     </type>\r
   </test>\r
-  <test name="test-888.cs">\r
-    <type name="S1">\r
-      <method name="Void .ctor(Int32)" attrs="6278">\r
-        <size>2</size>\r
-      </method>\r
-    </type>\r
-    <type name="X">\r
-      <method name="Void Main()" attrs="150">\r
-        <size>2</size>\r
-      </method>\r
-      <method name="Void .ctor()" attrs="6278">\r
-        <size>7</size>\r
-      </method>\r
-    </type>\r
-  </test>\r
   <test name="test-889.cs">\r
     <type name="Test">\r
       <method name="Void Main()" attrs="145">\r
       </method>\r
     </type>\r
   </test>\r
+  <test name="test-pattern-01.cs">\r
+    <type name="TypePattern">\r
+      <method name="Int32 Main()" attrs="150">\r
+        <size>227</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
+  <test name="test-pattern-02.cs">\r
+    <type name="ConstantPattern">\r
+      <method name="Int32 Main()" attrs="150">\r
+        <size>633</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+    <type name="&lt;PatternMatchingHelper&gt;">\r
+      <method name="Boolean NumberMatcher(System.Object, System.Object, Boolean)" attrs="150">\r
+        <size>69</size>\r
+      </method>\r
+    </type>\r
+    <type name="ConstantPattern">\r
+      <method name="Boolean Generic[T](T)" attrs="145">\r
+        <size>28</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
+  <test name="test-pattern-03.cs">\r
+    <type name="WildcardPattern">\r
+      <method name="Int32 Main()" attrs="145">\r
+        <size>33</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
+  <test name="test-pattern-04.cs">\r
+    <type name="RecursivePattern">\r
+      <method name="Int32 Main()" attrs="145">\r
+        <size>750</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+    <type name="C1">\r
+      <method name="Boolean op_Is(C1, Int32 ByRef)" attrs="2198">\r
+        <size>13</size>\r
+      </method>\r
+      <method name="Boolean op_Is(C1, C1 ByRef, C1 ByRef)" attrs="2198">\r
+        <size>16</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+    <type name="S">\r
+      <method name="Boolean op_Is(S, System.Nullable`1[System.Int32] ByRef, System.Decimal ByRef)" attrs="2198">\r
+        <size>34</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
+  <test name="test-pattern-05.cs">\r
+    <type name="RecursiveNamedPattern">\r
+      <method name="Int32 Main()" attrs="150">\r
+        <size>204</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+    <type name="C">\r
+      <method name="Boolean op_Is(C, Int64 ByRef, System.String ByRef)" attrs="2198">\r
+        <size>22</size>\r
+      </method>\r
+      <method name="Boolean op_Is(C)" attrs="2198">\r
+        <size>10</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
+  <test name="test-pattern-06.cs">\r
+    <type name="RecursiveNamedPattern">\r
+      <method name="Int32 Main()" attrs="150">\r
+        <size>182</size>\r
+      </method>\r
+      <method name="Int32 Switch_1(System.Object)" attrs="145">\r
+        <size>149</size>\r
+      </method>\r
+      <method name="Int32 Switch_2(C1)" attrs="145">\r
+        <size>28</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+    <type name="C1">\r
+      <method name="Boolean op_Is(C1, Int32 ByRef)" attrs="2198">\r
+        <size>13</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+    <type name="&lt;PatternMatchingHelper&gt;">\r
+      <method name="Boolean NumberMatcher(System.Object, System.Object, Boolean)" attrs="150">\r
+        <size>69</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
   <test name="test-primary-ctor-01.cs">\r
     <type name="Simple">\r
       <method name="Int32 get_Property()" attrs="2177">\r
old mode 100755 (executable)
new mode 100644 (file)
index c046e20..607b1e0
@@ -3,7 +3,7 @@
   <PropertyGroup>\r
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
-    <ProductVersion>9.0.30729</ProductVersion>\r
+    <ProductVersion>8.0.30703</ProductVersion>\r
     <SchemaVersion>2.0</SchemaVersion>\r
     <ProjectGuid>{0831DD4E-B428-4D6C-90B1-2206DBD4F92E}</ProjectGuid>\r
     <OutputType>Exe</OutputType>\r
@@ -43,6 +43,7 @@
     <WarningLevel>4</WarningLevel>\r
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
     <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>\r
+    <Externalconsole>true</Externalconsole>\r
   </PropertyGroup>\r
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
     <DebugType>pdbonly</DebugType>\r
index 495f16922edfe722c816e02232eea5a225f35191..df1a9c1c22e4d59de1b439105db13c9955aa2961 100644 (file)
@@ -1,5 +1,5 @@
 if CROSS_COMPILING
-SUBDIRS = arch utils io-layer cil metadata $(interpreter_dir) mini dis profiler
+SUBDIRS = arch utils io-layer cil metadata mini dis profiler
 else
 if INSTALL_MONOTOUCH
 SUBDIRS = utils io-layer metadata arch mini profiler
@@ -26,7 +26,7 @@ monotouch-do-clean:
          (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$target); \
     done;
 else
-SUBDIRS = arch utils io-layer cil metadata $(interpreter_dir) mini dis monograph tests unit-tests benchmark profiler
+SUBDIRS = arch utils io-layer cil metadata mini dis monograph tests unit-tests benchmark profiler
 endif
 endif
-DIST_SUBDIRS = arch utils io-layer cil metadata interpreter mini dis monograph tests unit-tests benchmark profiler
+DIST_SUBDIRS = arch utils io-layer cil metadata mini dis monograph tests unit-tests benchmark profiler
index 3d687949f92a8ed21f1e339eca6ead21c9e74615..87416872f6e325499d4c927ee1638c680ad9fa66 100644 (file)
@@ -2,23 +2,9 @@ DIST_SUBDIRS = x86 ppc sparc arm arm64 s390x amd64 ia64 mips
 
 AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
 
-if INTERP_SUPPORTED
-SUBDIRS = $(arch_target)
-else
 if ARM
 # arm needs to build some stuff even in JIT mode
 SUBDIRS = $(arch_target)
-endif
-endif
-
-if INTERP_SUPPORTED
-
-noinst_LTLIBRARIES = libmonoarch.la
-
-libmonoarch_la_SOURCES = unknown.c
-
-libmonoarch_la_LIBADD = $(arch_target)/libmonoarch-$(arch_target).la
-
 endif
 
 EXTRA_DIST = ChangeLog
index 3c728263190b068d699783b5071bbe75e27f2481..47daaaff699919d11129c4b362b7bec1c7e0fa6e 100644 (file)
@@ -1,7 +1,2 @@
-
-AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
-
-noinst_LTLIBRARIES = libmonoarch-amd64.la
-
-libmonoarch_amd64_la_SOURCES = tramp.c amd64-codegen.h
+EXTRA_DIST =  amd64-codegen.h
 
diff --git a/mono/arch/amd64/tramp.c b/mono/arch/amd64/tramp.c
deleted file mode 100644 (file)
index 6dbec93..0000000
+++ /dev/null
@@ -1,1054 +0,0 @@
-/*
- * Create trampolines to invoke arbitrary functions.
- * 
- * Copyright (C) Ximian Inc.
- * 
- * Author: 
- *   Zalman Stern
- * Based on code by:
- *   Paolo Molaro (lupus@ximian.com)
- *   Dietmar Maurer (dietmar@ximian.com)
- * 
- * To understand this code, one will want to the calling convention section of the ABI sepc at:
- *     http://x86-64.org/abi.pdf
- * and the AMD64 architecture docs found at amd.com .
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <string.h>
-#include "amd64-codegen.h"
-#include "mono/metadata/class.h"
-#include "mono/metadata/tabledefs.h"
-#include "mono/interpreter/interp.h"
-#include "mono/metadata/appdomain.h"
-#include "mono/metadata/marshal.h"
-
-/*
- * The resulting function takes the form:
- * void func (void (*callme)(), void *retval, void *this_obj, stackval *arguments);
- */
-#define FUNC_ADDR_POS  8
-#define RETVAL_POS     12
-#define THIS_POS       16
-#define ARGP_POS       20
-#define LOC_POS        -4
-
-#define ARG_SIZE       sizeof (stackval)
-
-#define MAX_INT_ARG_REGS       6
-#define MAX_FLOAT_ARG_REGS     8
-
-// TODO get these right. They are upper bounds anyway, so it doesn't much matter.
-#define PUSH_INT_STACK_ARG_SIZE                16
-#define MOVE_INT_REG_ARG_SIZE          16
-#define PUSH_FLOAT_STACK_ARG_SIZE      16
-#define MOVE_FLOAT_REG_ARG_SIZE                16
-#define COPY_STRUCT_STACK_ARG_SIZE     16
-
-/* Maps an argument number (starting at 0) to the register it is passed in (if it fits).
- * E.g. int foo(int bar, int quux) has the foo arg in RDI and the quux arg in RSI
- * There is no such map for floating point args as they go in XMM0-XMM7 in order and thus the
- * index is the register number.
- */
-static int int_arg_regs[] = { AMD64_RDI, AMD64_RSI, AMD64_RDX, AMD64_RCX, AMD64_R8, AMD64_R9 };
-
-/* This next block of code resolves the ABI rules for passing structures in the argument registers.
- * These basically amount to "Use up to two registers if they are all integer or all floating point.
- * If the structure is bigger than two registers or would be in one integer register and one floating point,
- * it is passed in memory instead.
- *
- * It is possible this code needs to be recursive to be correct in the case when one of the structure members
- * is itself a structure.
- *
- * The 80-bit floating point stuff is ignored.
- */
-typedef enum {
-       ARG_IN_MEMORY,
-       ARG_IN_INT_REGS,
-       ARG_IN_FLOAT_REGS
-} struct_arg_type;
-
-static struct_arg_type compute_arg_type(MonoType *type)
-{
-       guint32 simpletype = type->type;
-
-       switch (simpletype) {
-               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:
-                       return ARG_IN_INT_REGS;
-                       break;
-               case MONO_TYPE_VALUETYPE: {
-                       if (type->data.klass->enumtype)
-                               return ARG_IN_INT_REGS;
-                       return ARG_IN_MEMORY;
-                       break;
-               }
-               case MONO_TYPE_R4:
-               case MONO_TYPE_R8:
-                       return ARG_IN_FLOAT_REGS;
-                       break;
-               default:
-                       g_error ("Can't trampoline 0x%x", type->type);
-       }
-
-       return ARG_IN_MEMORY;
-}
-
-static struct_arg_type value_type_info(MonoClass *klass, int *native_size, int *regs_used, int *offset1, int *size1, int *offset2, int *size2)
-{
-       MonoMarshalType *info = mono_marshal_load_type_info (klass);
-
-       *native_size = info->native_size;
-
-       if (info->native_size > 8 || info->num_fields > 2)
-       {
-               *regs_used = 0;
-               *offset1 = -1;
-               *offset2 = -1;
-               return ARG_IN_MEMORY;
-       }
-
-       if (info->num_fields == 1)
-       {
-               struct_arg_type result = compute_arg_type(info->fields[0].field->type);
-               if (result != ARG_IN_MEMORY)
-               {
-                       *regs_used = 1;
-                       *offset1 = info->fields[0].offset;
-                       *size1 = mono_marshal_type_size (info->fields[0].field->type, info->fields[0].mspec, NULL, 1, 1);
-               } 
-               else
-               {
-                       *regs_used = 0;
-                       *offset1 = -1;
-               }
-
-               *offset2 = -1;
-               return result;
-       }
-
-       struct_arg_type result1 = compute_arg_type(info->fields[0].field->type);
-       struct_arg_type result2 = compute_arg_type(info->fields[0].field->type);
-
-       if (result1 == result2 && result1 != ARG_IN_MEMORY)
-       {
-               *regs_used = 2;
-               *offset1 = info->fields[0].offset;
-               *size1 = mono_marshal_type_size (info->fields[0].field->type, info->fields[0].mspec, NULL, 1, 1);
-               *offset2 = info->fields[1].offset;
-               *size2 = mono_marshal_type_size (info->fields[1].field->type, info->fields[1].mspec, NULL, 1, 1);
-               return result1;
-       }
-
-       return ARG_IN_MEMORY;
-}
-
-MonoPIFunc
-mono_arch_create_trampoline (MonoMethodSignature *sig, gboolean string_ctor)
-{
-       unsigned char *p, *code_buffer;
-       guint32 stack_size = 0, code_size = 50;
-       guint32 arg_pos, simpletype;
-       int i;
-       static GHashTable *cache = NULL;
-       MonoPIFunc res;
-
-       guint32 int_arg_regs_used = 0;
-       guint32 float_arg_regs_used = 0;
-       guint32 next_int_arg_reg = 0;
-       guint32 next_float_arg_reg = 0;
-       /* Indicates that the return value is filled in inside the called function. */
-       int retval_implicit = 0;
-       char *arg_in_reg_bitvector; /* A set index by argument number saying if it is in a register
-                                      (integer or floating point according to type) */
-
-       if (!cache) 
-               cache = g_hash_table_new ((GHashFunc)mono_signature_hash, 
-                                         (GCompareFunc)mono_metadata_signature_equal);
-
-       if ((res = (MonoPIFunc)g_hash_table_lookup (cache, sig)))
-               return res;
-
-       if (sig->ret->type == MONO_TYPE_VALUETYPE && !sig->ret->byref && !sig->ret->data.klass->enumtype) {
-               int_arg_regs_used++;
-               code_size += MOVE_INT_REG_ARG_SIZE;
-       }
-
-       if (sig->hasthis) {
-               int_arg_regs_used++;
-               code_size += MOVE_INT_REG_ARG_SIZE;
-       }
-       
-       /* Run through stuff to calculate code size and argument bytes that will be pushed on stack (stack_size). */
-       for (i = 0; i < sig->param_count; ++i) {
-               if (sig->params [i]->byref)
-                       simpletype = MONO_TYPE_PTR;
-               else
-                       simpletype = sig->params [i]->type;
-enum_calc_size:
-               switch (simpletype) {
-               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:
-                       if (int_arg_regs_used++ > MAX_INT_ARG_REGS) {
-                               stack_size += 8;
-                               code_size += PUSH_INT_STACK_ARG_SIZE;
-                       }
-                       else
-                               code_size += MOVE_INT_REG_ARG_SIZE;
-                       break;
-               case MONO_TYPE_VALUETYPE: {
-                       int size;
-                       int arg_type;
-                       int regs_used;
-                       int offset1;
-                       int size1;
-                       int offset2;
-                       int size2;
-
-                       if (sig->params [i]->data.klass->enumtype) {
-                               simpletype = sig->params [i]->data.klass->enum_basetype->type;
-                               goto enum_calc_size;
-                       }
-
-                       arg_type = value_type_info(sig->params [i]->data.klass, &size, &regs_used, &offset1, &size1, &offset2, &size2);
-                       if (arg_type == ARG_IN_INT_REGS &&
-                           (int_arg_regs_used + regs_used) <= MAX_INT_ARG_REGS)
-                       {
-                               code_size += MOVE_INT_REG_ARG_SIZE;
-                               int_arg_regs_used += regs_used;
-                               break;
-                       }
-
-                       if (arg_type == ARG_IN_FLOAT_REGS &&
-                           (float_arg_regs_used + regs_used) <= MAX_FLOAT_ARG_REGS)
-                       {
-                               code_size += MOVE_FLOAT_REG_ARG_SIZE;
-                               float_arg_regs_used += regs_used;
-                               break;
-                       }
-
-                       /* Else item is in memory. */
-
-                       stack_size += size + 7;
-                       stack_size &= ~7;
-                       code_size += COPY_STRUCT_STACK_ARG_SIZE;
-
-                       break;
-               }
-               case MONO_TYPE_R4:
-               case MONO_TYPE_R8:
-                       if (float_arg_regs_used++ > MAX_FLOAT_ARG_REGS) {
-                               stack_size += 8;
-                               code_size += PUSH_FLOAT_STACK_ARG_SIZE;
-                       }
-                       else
-                               code_size += MOVE_FLOAT_REG_ARG_SIZE;
-                       break;
-               default:
-                       g_error ("Can't trampoline 0x%x", sig->params [i]->type);
-               }
-       }
-       /*
-        * FIXME: take into account large return values.
-        * (Comment carried over from IA32 code. Not sure what it means :-)
-        */
-
-       code_buffer = p = alloca (code_size);
-
-       /*
-        * Standard function prolog.
-        */
-       amd64_push_reg (p, AMD64_RBP);
-       amd64_mov_reg_reg (p, AMD64_RBP, AMD64_RSP, 8);
-       /*
-        * and align to 16 byte boundary...
-        */
-
-       if (sig->ret->type == MONO_TYPE_VALUETYPE && !sig->ret->byref) {
-               MonoClass *klass = sig->ret->data.klass;
-               if (!klass->enumtype) {
-                       retval_implicit = 1;
-               }
-       }
-
-       if (sig->ret->byref || string_ctor || !(retval_implicit || sig->ret->type == MONO_TYPE_VOID)) {
-               /* Push the retval register so it is saved across the call. It will be addressed via RBP later. */
-               amd64_push_reg (p, AMD64_RSI);
-               stack_size += 8;
-       }
-
-       /* Ensure stack is 16 byte aligned when entering called function as required by calling convention. 
-        * Getting this wrong results in a general protection fault on an SSE load or store somewhere in the
-        * code called under the trampoline.
-        */
-       if ((stack_size & 15) != 0)
-               amd64_alu_reg_imm (p, X86_SUB, AMD64_RSP, 16 - (stack_size & 15));
-
-       /*
-        * On entry to generated function:
-        *     RDI has target function address
-        *     RSI has return value location address
-        *     RDX has this pointer address
-        *     RCX has the pointer to the args array.
-        *
-        * Inside the stub function:
-        *     R10 holds the pointer to the args 
-        *     R11 holds the target function address.
-        *     The return value address is pushed on the stack.
-        *     The this pointer is moved into the first arg register at the start.
-        *
-        * Optimization note: we could keep the args pointer in RCX and then
-        * load over itself at the end. Ditto the callee addres could be left in RDI in some cases.
-        */
-
-       /* Move args pointer to temp register. */
-       amd64_mov_reg_reg (p, AMD64_R10, AMD64_RCX, 8);
-       amd64_mov_reg_reg (p, AMD64_R11, AMD64_RDI, 8);
-
-       /* First args register gets return value pointer, if need be.
-         * Note that "byref" equal true means the called function returns a pointer.
-         */
-       if (retval_implicit) {
-               amd64_mov_reg_reg (p, int_arg_regs[next_int_arg_reg], AMD64_RSI, 8);
-               next_int_arg_reg++;
-       }
-
-       /* this pointer goes in next args register. */
-       if (sig->hasthis) {
-               amd64_mov_reg_reg (p, int_arg_regs[next_int_arg_reg], AMD64_RDX, 8);
-               next_int_arg_reg++;
-       }
-
-       /*
-        * Generate code to handle arguments in registers. Stack arguments will happen in a loop after this.
-        */
-       arg_in_reg_bitvector = (char *)alloca((sig->param_count + 7) / 8);
-       memset(arg_in_reg_bitvector, 0, (sig->param_count + 7) / 8);
-
-       /* First, load all the arguments that are passed in registers into the appropriate registers.
-        * Below there is another loop to handle arguments passed on the stack.
-        */
-       for (i = 0; i < sig->param_count; i++) {
-               arg_pos = ARG_SIZE * i;
-
-               if (sig->params [i]->byref)
-                       simpletype = MONO_TYPE_PTR;
-               else
-                       simpletype = sig->params [i]->type;
-enum_marshal:
-               switch (simpletype) {
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-               case MONO_TYPE_CHAR:
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_PTR:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_STRING:
-               case MONO_TYPE_SZARRAY:
-               case MONO_TYPE_I8:
-               case MONO_TYPE_U8:
-               case MONO_TYPE_CLASS:
-                       if (next_int_arg_reg < MAX_INT_ARG_REGS) {
-                               amd64_mov_reg_membase (p, int_arg_regs[next_int_arg_reg], AMD64_R10, arg_pos, 8);
-                               next_int_arg_reg++;
-                               arg_in_reg_bitvector[i >> 3] |= (1 << (i & 7));
-                       }
-                       break;
-               case MONO_TYPE_R4:
-                       if (next_float_arg_reg < MAX_FLOAT_ARG_REGS) {
-                               amd64_movss_reg_membase (p, next_float_arg_reg, AMD64_R10, arg_pos);
-                               next_float_arg_reg++;
-                               arg_in_reg_bitvector[i >> 3] |= (1 << (i & 7));
-                       }
-                       break;
-               case MONO_TYPE_R8:
-                       if (next_float_arg_reg < MAX_FLOAT_ARG_REGS) {
-                               amd64_movsd_reg_membase (p, next_float_arg_reg, AMD64_R10, arg_pos);
-                               next_float_arg_reg++;
-                               arg_in_reg_bitvector[i >> 3] |= (1 << (i & 7));
-                       }
-                       break;
-               case MONO_TYPE_VALUETYPE: {
-                       if (!sig->params [i]->data.klass->enumtype) {
-                               int size;
-                               int arg_type;
-                               int regs_used;
-                               int offset1;
-                               int size1;
-                               int offset2;
-                               int size2;
-
-                               arg_type = value_type_info(sig->params [i]->data.klass, &size, &regs_used, &offset1, &size1, &offset2, &size2);
-
-                               if (arg_type == ARG_IN_INT_REGS &&
-                                   (next_int_arg_reg + regs_used) <= MAX_INT_ARG_REGS)
-                               {
-                                       amd64_mov_reg_membase (p, int_arg_regs[next_int_arg_reg], AMD64_R10, arg_pos + offset1, size1);
-                                       next_int_arg_reg++;
-                                       if (regs_used > 1)
-                                       {
-                                               amd64_mov_reg_membase (p, int_arg_regs[next_int_arg_reg], AMD64_R10, arg_pos + offset2, size2);
-                                               next_int_arg_reg++;
-                                       }
-                                       arg_in_reg_bitvector[i >> 3] |= (1 << (i & 7));
-                                       break;
-                               }
-
-                               if (arg_type == ARG_IN_FLOAT_REGS &&
-                                   (next_float_arg_reg + regs_used) <= MAX_FLOAT_ARG_REGS)
-                               {
-                                       if (size1 == 4)
-                                               amd64_movss_reg_membase (p, next_float_arg_reg, AMD64_R10, arg_pos + offset1);
-                                       else
-                                               amd64_movsd_reg_membase (p, next_float_arg_reg, AMD64_R10, arg_pos + offset1);
-                                       next_float_arg_reg++;
-
-                                       if (regs_used > 1)
-                                       {
-                                               if (size2 == 4)
-                                                       amd64_movss_reg_membase (p, next_float_arg_reg, AMD64_R10, arg_pos + offset2);
-                                               else
-                                                       amd64_movsd_reg_membase (p, next_float_arg_reg, AMD64_R10, arg_pos + offset2);
-                                               next_float_arg_reg++;
-                                       }
-                                       arg_in_reg_bitvector[i >> 3] |= (1 << (i & 7));
-                                       break;
-                               }
-
-                               /* Structs in memory are handled in the next loop. */
-                       } else {
-                               /* it's an enum value */
-                               simpletype = sig->params [i]->data.klass->enum_basetype->type;
-                               goto enum_marshal;
-                       }
-                       break;
-               }
-               default:
-                       g_error ("Can't trampoline 0x%x", sig->params [i]->type);
-               }
-       }
-
-       /* Handle stack arguments, pushing the rightmost argument first. */
-       for (i = sig->param_count; i > 0; --i) {
-               arg_pos = ARG_SIZE * (i - 1);
-               if (sig->params [i - 1]->byref)
-                       simpletype = MONO_TYPE_PTR;
-               else
-                       simpletype = sig->params [i - 1]->type;
-enum_marshal2:
-               switch (simpletype) {
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-               case MONO_TYPE_CHAR:
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_PTR:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_STRING:
-               case MONO_TYPE_SZARRAY:
-               case MONO_TYPE_I8:
-               case MONO_TYPE_U8:
-               case MONO_TYPE_CLASS:
-                       if ((arg_in_reg_bitvector[(i - 1) >> 3] & (1 << ((i - 1) & 7))) == 0) {
-                               amd64_push_membase (p, AMD64_R10, arg_pos);
-                       }
-                       break;
-               case MONO_TYPE_R4:
-                       if ((arg_in_reg_bitvector[(i - 1) >> 3] & (1 << ((i - 1) & 7))) == 0) {
-                               amd64_push_membase (p, AMD64_R10, arg_pos);
-                       }
-                       break;
-               case MONO_TYPE_R8:
-                       if ((arg_in_reg_bitvector[(i - 1) >> 3] & (1 << ((i - 1) & 7))) == 0) {
-                               amd64_push_membase (p, AMD64_R10, arg_pos);
-                       }
-                       break;
-               case MONO_TYPE_VALUETYPE:
-                       if (!sig->params [i - 1]->data.klass->enumtype) {
-                               if ((arg_in_reg_bitvector[(i - 1) >> 3] & (1 << ((i - 1) & 7))) == 0)
-                               {
-                                       int ss = mono_class_native_size (sig->params [i - 1]->data.klass, NULL);
-                                       ss += 7;
-                                       ss &= ~7;
-
-                                       amd64_alu_reg_imm(p, X86_SUB, AMD64_RSP, ss);
-                                       /* Count register */
-                                       amd64_mov_reg_imm(p, AMD64_RCX, ss);
-                                       /* Source register */
-                                       amd64_lea_membase(p, AMD64_RSI, AMD64_R10, arg_pos);
-                                       /* Dest register */
-                                       amd64_mov_reg_reg(p, AMD64_RDI, AMD64_RSP, 8);
-
-                                       /* AMD64 calling convention guarantees direction flag is clear at call boundary. */
-                                       x86_prefix(p, AMD64_REX(AMD64_REX_W));
-                                       x86_prefix(p, X86_REP_PREFIX);
-                                       x86_movsb(p);
-                               }
-                       } else {
-                               /* it's an enum value */
-                               simpletype = sig->params [i - 1]->data.klass->enum_basetype->type;
-                               goto enum_marshal2;
-                       }
-                       break;
-               default:
-                       g_error ("Can't trampoline 0x%x", sig->params [i - 1]->type);
-               }
-       }
-
-        /* TODO: Set RAL to number of XMM registers used in case this is a varags function? */
-       /* 
-        * Insert call to function 
-        */
-       amd64_call_reg (p, AMD64_R11);
-
-       if (sig->ret->byref || string_ctor || !(retval_implicit || sig->ret->type == MONO_TYPE_VOID)) {
-               amd64_mov_reg_membase(p, AMD64_RSI, AMD64_RBP, -8, SIZEOF_VOID_P);
-       }
-       /*
-        * Handle retval.
-        * Small integer and pointer values are in EAX.
-        * Long integers are in EAX:EDX.
-        * FP values are on the FP stack.
-        */
-
-       if (sig->ret->byref || string_ctor) {
-               simpletype = MONO_TYPE_PTR;
-       } else {
-               simpletype = sig->ret->type;
-       }
-       enum_retvalue:
-       switch (simpletype) {
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-                       amd64_mov_regp_reg (p, AMD64_RSI, X86_EAX, 1);
-                       break;
-               case MONO_TYPE_CHAR:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-                       amd64_mov_regp_reg (p, AMD64_RSI, X86_EAX, 2);
-                       break;
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_CLASS:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_SZARRAY:
-               case MONO_TYPE_ARRAY:
-               case MONO_TYPE_STRING: 
-               case MONO_TYPE_PTR:
-                       amd64_mov_regp_reg (p, AMD64_RSI, X86_EAX, 8);
-                       break;
-               case MONO_TYPE_R4:
-                       amd64_movss_regp_reg (p, AMD64_RSI, AMD64_XMM0);
-                       break;
-               case MONO_TYPE_R8:
-                       amd64_movsd_regp_reg (p, AMD64_RSI, AMD64_XMM0);
-                       break;
-               case MONO_TYPE_I8:
-                       amd64_mov_regp_reg (p, AMD64_RSI, X86_EAX, 8);
-                       break;
-               case MONO_TYPE_VALUETYPE: {
-                       int size;
-                       int arg_type;
-                       int regs_used;
-                       int offset1;
-                       int size1;
-                       int offset2;
-                       int size2;
-
-                       if (sig->ret->data.klass->enumtype) {
-                               simpletype = sig->ret->data.klass->enum_basetype->type;
-                               goto enum_retvalue;
-                       }
-
-                       arg_type = value_type_info(sig->params [i]->data.klass, &size, &regs_used, &offset1, &size1, &offset2, &size2);
-
-                       if (arg_type == ARG_IN_INT_REGS)
-                       {
-                               amd64_mov_membase_reg (p, AMD64_RSI, offset1, AMD64_RAX, size1);
-                               if (regs_used > 1)
-                                       amd64_mov_membase_reg (p, AMD64_RSI, offset2, AMD64_RDX, size2);
-                               break;
-                       }
-
-                       if (arg_type == ARG_IN_FLOAT_REGS)
-                       {
-                               if (size1 == 4)
-                                       amd64_movss_membase_reg (p, AMD64_RSI, offset1, AMD64_XMM0);
-                               else
-                                       amd64_movsd_membase_reg (p, AMD64_RSI, offset1, AMD64_XMM0);
-
-                               if (regs_used > 1)
-                               {
-                                       if (size2 == 4)
-                                               amd64_movss_membase_reg (p, AMD64_RSI, offset2, AMD64_XMM1);
-                                       else
-                                               amd64_movsd_membase_reg (p, AMD64_RSI, offset2, AMD64_XMM1);
-                               }
-                               break;
-                       }
-
-                       /* Else result should have been stored in place already. */
-                       break;
-               }
-               case MONO_TYPE_VOID:
-                       break;
-               default:
-                       g_error ("Can't handle as return value 0x%x", sig->ret->type);
-       }
-
-       /*
-        * Standard epilog.
-        */
-       amd64_leave (p);
-       amd64_ret (p);
-
-       g_assert (p - code_buffer < code_size);
-       res = (MonoPIFunc)g_memdup (code_buffer, p - code_buffer);
-
-       g_hash_table_insert (cache, sig, res);
-
-       return res;
-}
-
-/*
- * Returns a pointer to a native function that can be used to
- * call the specified method.
- * The function created will receive the arguments according
- * to the call convention specified in the method.
- * This function works by creating a MonoInvocation structure,
- * filling the fields in and calling ves_exec_method on it.
- * Still need to figure out how to handle the exception stuff
- * across the managed/unmanaged boundary.
- */
-void *
-mono_arch_create_method_pointer (MonoMethod *method)
-{
-       MonoMethodSignature *sig;
-       MonoJitInfo *ji;
-       unsigned char *p, *code_buffer;
-       guint32 simpletype;
-       gint32 local_size;
-       gint32 stackval_pos;
-       gint32 mono_invocation_pos;
-       int i, cpos;
-       int *vtbuf;
-       int *rbpoffsets;
-       int int_arg_regs_used = 0;
-       int float_arg_regs_used = 0;
-       int stacked_args_size = 0; /* bytes of register passed arguments pushed on stack for safe keeping. Used to get alignment right. */
-       int next_stack_arg_rbp_offset = 16;
-       int retval_ptr_rbp_offset = 0;
-       int this_reg = -1; /* Remember register this ptr is in. */
-
-       /*
-        * 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->method = method;
-               ji->code_size = 1;
-               ji->code_start = ((MonoMethodPInvoke*) method)->addr;
-
-               mono_jit_info_table_add (mono_get_root_domain (), ji);
-               return ((MonoMethodPInvoke*) method)->addr;
-       }
-
-       sig = method->signature;
-
-       code_buffer = p = alloca (512); /* FIXME: check for overflows... */
-       vtbuf = alloca (sizeof(int)*sig->param_count);
-       rbpoffsets = alloca (sizeof(int)*sig->param_count);
-
-
-       /*
-        * Standard function prolog.
-        */
-       amd64_push_reg (p, AMD64_RBP);
-       amd64_mov_reg_reg (p, AMD64_RBP, AMD64_RSP, 8);
-
-       /* If there is an implicit return value pointer in the first args reg, save it now so
-        * the result can be stored through the pointer at the end.
-        */
-       if (sig->ret->type == MONO_TYPE_VALUETYPE && !sig->ret->byref && !sig->ret->data.klass->enumtype) 
-       {
-               amd64_push_reg (p, int_arg_regs[int_arg_regs_used]);
-               int_arg_regs_used++;
-               stacked_args_size += 8;
-               retval_ptr_rbp_offset = -stacked_args_size;
-       }
-
-       /*
-        * If there is a this pointer, remember the number of the register it is in.
-        */
-       if (sig->hasthis) {
-               this_reg = int_arg_regs[int_arg_regs_used++];
-       }
-
-       /* Put all arguments passed in registers on the stack.
-        * Record offsets from RBP to each argument.
-        */
-       cpos = 0;
-
-       for (i = 0; i < sig->param_count; i++) {
-               if (sig->params [i]->byref)
-                       simpletype = MONO_TYPE_PTR;
-               else
-                       simpletype = sig->params [i]->type;
-enum_calc_size:
-               switch (simpletype) {
-               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:
-                       if (int_arg_regs_used < MAX_INT_ARG_REGS) {
-                               amd64_push_reg (p, int_arg_regs[int_arg_regs_used]);
-                               int_arg_regs_used++;
-                               stacked_args_size += 8;
-                               rbpoffsets[i] = -stacked_args_size;
-                       }
-                       else
-                       {
-                               rbpoffsets[i] = next_stack_arg_rbp_offset;
-                               next_stack_arg_rbp_offset += 8;
-                       }
-                       break;
-               case MONO_TYPE_VALUETYPE: {
-                       if (sig->params [i]->data.klass->enumtype) {
-                               simpletype = sig->params [i]->data.klass->enum_basetype->type;
-                               goto enum_calc_size;
-                       }
-                       else
-                       {
-                               int size;
-                               int arg_type;
-                               int regs_used;
-                               int offset1;
-                               int size1;
-                               int offset2;
-                               int size2;
-
-                               arg_type = value_type_info(sig->params [i]->data.klass, &size, &regs_used, &offset1, &size1, &offset2, &size2);
-
-                               if (arg_type == ARG_IN_INT_REGS &&
-                                   (int_arg_regs_used + regs_used) <= MAX_INT_ARG_REGS)
-                               {
-                                       amd64_alu_reg_imm (p, X86_SUB, AMD64_RSP, size);
-                                       stacked_args_size += size;
-                                       rbpoffsets[i] = stacked_args_size;
-
-                                       amd64_mov_reg_membase (p, int_arg_regs[int_arg_regs_used], AMD64_RSP, offset1, size1);
-                                       int_arg_regs_used++;
-                                       if (regs_used > 1)
-                                       {
-                                               amd64_mov_reg_membase (p, int_arg_regs[int_arg_regs_used], AMD64_RSP, offset2, size2);
-                                               int_arg_regs_used++;
-                                       }
-                                       break;
-                               }
-
-                               if (arg_type == ARG_IN_FLOAT_REGS &&
-                                   (float_arg_regs_used + regs_used) <= MAX_FLOAT_ARG_REGS)
-                               {
-                                       amd64_alu_reg_imm (p, X86_SUB, AMD64_RSP, size);
-                                       stacked_args_size += size;
-                                       rbpoffsets[i] = stacked_args_size;
-
-                                       if (size1 == 4)
-                                               amd64_movss_reg_membase (p, float_arg_regs_used, AMD64_RSP, offset1);
-                                       else
-                                               amd64_movsd_reg_membase (p, float_arg_regs_used, AMD64_RSP, offset1);
-                                       float_arg_regs_used++;
-
-                                       if (regs_used > 1)
-                                       {
-                                               if (size2 == 4)
-                                                       amd64_movss_reg_membase (p, float_arg_regs_used, AMD64_RSP, offset2);
-                                               else
-                                                       amd64_movsd_reg_membase (p, float_arg_regs_used, AMD64_RSP, offset2);
-                                               float_arg_regs_used++;
-                                       }
-                                       break;
-                               }
-
-                               rbpoffsets[i] = next_stack_arg_rbp_offset;
-                               next_stack_arg_rbp_offset += size;
-                       }
-                       break;
-               }
-               case MONO_TYPE_R4:
-                       if (float_arg_regs_used < MAX_FLOAT_ARG_REGS) {
-                               amd64_alu_reg_imm (p, X86_SUB, AMD64_RSP, 8);
-                               amd64_movss_regp_reg (p, AMD64_RSP, float_arg_regs_used);
-                               float_arg_regs_used++;
-                               stacked_args_size += 8;
-                               rbpoffsets[i] = -stacked_args_size;
-                       }
-                       else
-                       {
-                               rbpoffsets[i] = next_stack_arg_rbp_offset;
-                               next_stack_arg_rbp_offset += 8;
-                       }
-                       break;
-               case MONO_TYPE_R8:
-                       stacked_args_size += 8;
-                       if (float_arg_regs_used < MAX_FLOAT_ARG_REGS) {
-                               amd64_alu_reg_imm (p, X86_SUB, AMD64_RSP, 8);
-                               amd64_movsd_regp_reg (p, AMD64_RSP, float_arg_regs_used);
-                               float_arg_regs_used++;
-                               stacked_args_size += 8;
-                               rbpoffsets[i] = -stacked_args_size;
-                       }
-                       else
-                       {
-                               rbpoffsets[i] = next_stack_arg_rbp_offset;
-                               next_stack_arg_rbp_offset += 8;
-                       }
-                       break;
-               default:
-                       g_error ("Can't trampoline 0x%x", sig->params [i]->type);
-               }
-       }
-
-       local_size = sizeof (MonoInvocation) + sizeof (stackval) * (sig->param_count + 1) + stacked_args_size;
-
-       local_size += 15;
-       local_size &= ~15;
-
-       stackval_pos = -local_size;
-       mono_invocation_pos = stackval_pos + sizeof (stackval) * (sig->param_count + 1);
-
-       /* stacked_args_size has already been pushed onto the stack. Make room for the rest of it. */
-       amd64_alu_reg_imm (p, X86_SUB, AMD64_RSP, local_size - stacked_args_size);
-
-       /* Be careful not to trash any arg regs before saving this_reg to MonoInvocation structure below. */
-
-       /*
-        * Initialize MonoInvocation fields, first the ones known now.
-        */
-       amd64_alu_reg_reg (p, X86_XOR, AMD64_RAX, AMD64_RAX);
-       amd64_mov_membase_reg (p, AMD64_RBP, (mono_invocation_pos + G_STRUCT_OFFSET (MonoInvocation, ex)), AMD64_RAX, SIZEOF_VOID_P);
-       amd64_mov_membase_reg (p, AMD64_RBP, (mono_invocation_pos + G_STRUCT_OFFSET (MonoInvocation, ex_handler)), AMD64_RAX, SIZEOF_VOID_P);
-       amd64_mov_membase_reg (p, AMD64_RBP, (mono_invocation_pos + G_STRUCT_OFFSET (MonoInvocation, parent)), AMD64_RAX, SIZEOF_VOID_P);
-       /*
-        * Set the method pointer.
-        */
-       amd64_mov_membase_imm (p, AMD64_RBP, (mono_invocation_pos + G_STRUCT_OFFSET (MonoInvocation, method)), (long)method, SIZEOF_VOID_P);
-
-       /*
-        * Handle this.
-        */
-       if (sig->hasthis)
-               amd64_mov_membase_reg(p, AMD64_RBP, (mono_invocation_pos + G_STRUCT_OFFSET (MonoInvocation, obj)), this_reg, SIZEOF_VOID_P);
-
-       /*
-        * Handle the arguments. stackval_pos is the offset from RBP of the stackval in the MonoInvocation args array .
-        * arg_pos is the offset from RBP to the incoming arg on the stack.
-        * We just call stackval_from_data to handle all the (nasty) issues....
-        */
-       amd64_lea_membase (p, AMD64_RAX, AMD64_RBP, stackval_pos);
-       amd64_mov_membase_reg (p, AMD64_RBP, (mono_invocation_pos + G_STRUCT_OFFSET (MonoInvocation, stack_args)), AMD64_RAX, SIZEOF_VOID_P);
-       for (i = 0; i < sig->param_count; ++i) {
-/* Need to call stackval_from_data (MonoType *type, stackval *result, char *data, gboolean pinvoke); */
-               amd64_mov_reg_imm (p, AMD64_R11, stackval_from_data);
-               amd64_mov_reg_imm (p, int_arg_regs[0], sig->params[i]);
-               amd64_lea_membase (p, int_arg_regs[1], AMD64_RBP, stackval_pos);
-               amd64_lea_membase (p, int_arg_regs[2], AMD64_RBP, rbpoffsets[i]);
-               amd64_mov_reg_imm (p, int_arg_regs[3], sig->pinvoke);
-               amd64_call_reg (p, AMD64_R11);
-               stackval_pos += sizeof (stackval);
-#if 0
-               /* fixme: alignment */
-               if (sig->pinvoke)
-                       arg_pos += mono_type_native_stack_size (sig->params [i], &align);
-               else
-                       arg_pos += mono_type_stack_size (sig->params [i], &align);
-#endif
-       }
-
-       /*
-        * Handle the return value storage area.
-        */
-       amd64_lea_membase (p, AMD64_RAX, AMD64_RBP, stackval_pos);
-       amd64_mov_membase_reg (p, AMD64_RBP, (mono_invocation_pos + G_STRUCT_OFFSET (MonoInvocation, retval)), AMD64_RAX, SIZEOF_VOID_P);
-       if (sig->ret->type == MONO_TYPE_VALUETYPE && !sig->ret->byref) {
-               MonoClass *klass  = sig->ret->data.klass;
-               if (!klass->enumtype) {
-                       amd64_mov_reg_membase (p, AMD64_RCX, AMD64_RBP, retval_ptr_rbp_offset, SIZEOF_VOID_P);
-                       amd64_mov_membase_reg (p, AMD64_RBP, stackval_pos, AMD64_RCX, SIZEOF_VOID_P);
-               }
-       }
-
-       /*
-        * Call the method.
-        */
-       amd64_lea_membase (p, int_arg_regs[0], AMD64_RBP, mono_invocation_pos);
-       amd64_mov_reg_imm (p, AMD64_R11, ves_exec_method);
-       amd64_call_reg (p, AMD64_R11);
-       
-       /*
-        * Move the return value to the proper place.
-        */
-       amd64_lea_membase (p, AMD64_RAX, AMD64_RBP, stackval_pos);
-       if (sig->ret->byref) {
-               amd64_mov_reg_membase (p, AMD64_RAX, AMD64_RAX, 0, SIZEOF_VOID_P);
-       } else {
-               int simpletype = sig->ret->type;        
-       enum_retvalue:
-               switch (sig->ret->type) {
-               case MONO_TYPE_VOID:
-                       break;
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-                       amd64_movzx_reg_membase (p, AMD64_RAX, AMD64_RAX, 0, 1);
-                       break;
-               case MONO_TYPE_CHAR:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-                       amd64_movzx_reg_membase (p, AMD64_RAX, AMD64_RAX, 0, 2);
-                       break;
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_STRING:
-               case MONO_TYPE_CLASS:
-                       amd64_movzx_reg_membase (p, AMD64_RAX, AMD64_RAX, 0, 4);
-                       break;
-               case MONO_TYPE_I8:
-                       amd64_movzx_reg_membase (p, AMD64_RAX, AMD64_RAX, 0, 8);
-                       break;
-               case MONO_TYPE_R4:
-                       amd64_movss_regp_reg (p, AMD64_RAX, AMD64_XMM0);
-                       break;
-               case MONO_TYPE_R8:
-                       amd64_movsd_regp_reg (p, AMD64_RAX, AMD64_XMM0);
-                       break;
-               case MONO_TYPE_VALUETYPE: {
-                       int size;
-                       int arg_type;
-                       int regs_used;
-                       int offset1;
-                       int size1;
-                       int offset2;
-                       int size2;
-
-                       if (sig->ret->data.klass->enumtype) {
-                               simpletype = sig->ret->data.klass->enum_basetype->type;
-                               goto enum_retvalue;
-                       }
-
-                       arg_type = value_type_info(sig->params [i]->data.klass, &size, &regs_used, &offset1, &size1, &offset2, &size2);
-
-                       if (arg_type == ARG_IN_INT_REGS)
-                       {
-                               if (regs_used > 1)
-                                       amd64_mov_membase_reg (p, AMD64_RAX, offset2, AMD64_RDX, size2);
-                               amd64_mov_membase_reg (p, AMD64_RAX, offset1, AMD64_RAX, size1);
-                               break;
-                       }
-
-                       if (arg_type == ARG_IN_FLOAT_REGS)
-                       {
-                               if (size1 == 4)
-                                       amd64_movss_membase_reg (p, AMD64_RAX, offset1, AMD64_XMM0);
-                               else
-                                       amd64_movsd_membase_reg (p, AMD64_RAX, offset1, AMD64_XMM0);
-
-                               if (regs_used > 1)
-                               {
-                                       if (size2 == 4)
-                                               amd64_movss_membase_reg (p, AMD64_RAX, offset2, AMD64_XMM1);
-                                       else
-                                               amd64_movsd_membase_reg (p, AMD64_RAX, offset2, AMD64_XMM1);
-                               }
-                               break;
-                       }
-
-                       /* Else result should have been stored in place already. IA32 code has a stackval_to_data call here, which
-                        * looks wrong to me as the pointer in the stack val being converted is setup to point to the output area anyway.
-                        * It all looks a bit suspect anyway.
-                        */
-                       break;
-               }
-               default:
-                       g_error ("Type 0x%x not handled yet in thunk creation", sig->ret->type);
-                       break;
-               }
-       }
-       
-       /*
-        * Standard epilog.
-        */
-       amd64_leave (p);
-       amd64_ret (p);
-
-       g_assert (p - code_buffer < 512);
-
-       ji = g_new0 (MonoJitInfo, 1);
-       ji->method = method;
-       ji->code_size = p - code_buffer;
-       ji->code_start = g_memdup (code_buffer, p - code_buffer);
-
-       mono_jit_info_table_add (mono_get_root_domain (), ji);
-
-       return ji->code_start;
-}
index a4e2d5d2e7ca8d6e23bb7d7bb34a0a0d0f928d0e..9b209ef9400885145960cb9cbf37cf2b12703c67 100644 (file)
@@ -1,11 +1 @@
-if INTERP_SUPPORTED
-
-AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
-
-noinst_LTLIBRARIES = libmonoarch-ppc.la
-
-libmonoarch_ppc_la_SOURCES = tramp.c ppc-codegen.h
-
-noinst_PROGRAMS = test
-
-endif
+EXTRA_DIST = ppc-codegen.h
\ No newline at end of file
diff --git a/mono/arch/ppc/test.c b/mono/arch/ppc/test.c
deleted file mode 100644 (file)
index c19358d..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "ppc-codegen.h"
-#include <stdio.h>
-
-/* don't run the resulting program, it will destroy your computer,
- * just objdump -d it to inspect we generated the correct assembler.
- * On Mac OS X use otool[64] -v -t
- */
-
-int main() {
-       guint8 code [16000];
-       guint8 *p = code;
-       guint8 *cp;
-
-       printf (".text\n.align 4\n.globl main\n");
-#ifndef __APPLE__
-       printf (".type main,@function\n");
-#endif
-       printf ("main:\n");
-
-       ppc_stwu (p, ppc_r1, -32, ppc_r1);
-       ppc_mflr (p, ppc_r0);
-       ppc_stw  (p, ppc_r31, 28, ppc_r1);
-       ppc_or   (p, ppc_r1, ppc_r2, ppc_r3);
-       ppc_mr   (p, ppc_r31, ppc_r1);
-       ppc_lwz  (p, ppc_r11, 0, ppc_r1);
-       ppc_mtlr (p, ppc_r0);
-       ppc_blr  (p);
-       ppc_addi (p, ppc_r6, ppc_r6, 16);
-                    
-       for (cp = code; cp < p; cp++) {
-               printf (".byte 0x%x\n", *cp);
-       }            
-                    
-       return 0;    
-}
diff --git a/mono/arch/ppc/tramp.c b/mono/arch/ppc/tramp.c
deleted file mode 100644 (file)
index 6bb1896..0000000
+++ /dev/null
@@ -1,895 +0,0 @@
-/*
- * Create trampolines to invoke arbitrary functions.
- * 
- * Copyright (C) Radek Doulik
- * 
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <string.h>
-#include "ppc-codegen.h"
-#include "mono/metadata/class.h"
-#include "mono/metadata/tabledefs.h"
-#include "mono/interpreter/interp.h"
-#include "mono/metadata/appdomain.h"
-
-#ifdef NEED_MPROTECT
-#include <sys/mman.h>
-#include <limits.h>    /* for PAGESIZE */
-#ifndef PAGESIZE
-#define PAGESIZE 4096
-#endif
-#endif
-
-#define DEBUG(x)
-
-/* gpointer
-fake_func (gpointer (*callme)(gpointer), stackval *retval, void *this_obj, stackval *arguments)
-{
-       guint32 i = 0xc002becd;
-
-       callme = (gpointer) 0x100fabcd;
-
-       *(gpointer*)retval = (gpointer)(*callme) (arguments [0].data.p, arguments [1].data.p, arguments [2].data.p);
-       *(gdouble*) retval = (gdouble)(*callme) (arguments [0].data.f);
-
-       return (gpointer) (*callme) (((MonoType *)arguments [0]. data.p)->data.klass);
-} */
-
-#define MIN_CACHE_LINE 8
-
-static void inline
-flush_icache (guint8 *code, guint size)
-{
-       guint i;
-       guint8 *p;
-
-       p = code;
-       for (i = 0; i < size; i += MIN_CACHE_LINE, p += MIN_CACHE_LINE) {
-               asm ("dcbst 0,%0;" : : "r"(p) : "memory");
-       }
-       asm ("sync");
-       p = code;
-       for (i = 0; i < size; i += MIN_CACHE_LINE, p += MIN_CACHE_LINE) {
-               asm ("icbi 0,%0; sync;" : : "r"(p) : "memory");
-       }
-       asm ("sync");
-       asm ("isync");
-}
-
-static void
-disassemble (guint8 *code, int size)
-{
-       int i;
-       FILE *ofd;
-       const char *tmp = g_getenv("TMP");
-       char *as_file;
-       char *o_file;
-       char *cmd;
-
-       if (tmp == NULL)
-               tmp = "/tmp";
-       as_file = g_strdup_printf ("%s/test.s", tmp);    
-
-       if (!(ofd = fopen (as_file, "w")))
-               g_assert_not_reached ();
-
-       fprintf (ofd, "tmp:\n");
-
-       for (i = 0; i < size; ++i) 
-               fprintf (ofd, ".byte %d\n", (unsigned int) code [i]);
-
-       fclose (ofd);
-#ifdef __APPLE__
-#define DIS_CMD "otool -V -v -t"
-#else
-#define DIS_CMD "objdump -d"
-#endif
-       o_file = g_strdup_printf ("%s/test.o", tmp);    
-       cmd = g_strdup_printf ("as %s -o %s", as_file, o_file);
-       system (cmd); 
-       g_free (cmd);
-       cmd = g_strdup_printf (DIS_CMD " %s", o_file);
-       system (cmd);
-       g_free (cmd);
-       g_free (o_file);
-       g_free (as_file);
-}
-
-
-#define NOT_IMPLEMENTED(x) \
-                g_error ("FIXME: %s is not yet implemented. (trampoline)", x);
-
-#define PROLOG_INS 8
-#define CALL_INS   2
-#define EPILOG_INS 6
-#define FLOAT_REGS 8
-#define GENERAL_REGS 8
-#ifdef __APPLE__
-#define MINIMAL_STACK_SIZE 10
-#define ALWAYS_ON_STACK(s) s
-#define FP_ALSO_IN_REG(s) s
-#define RET_ADDR_OFFSET 8
-#define STACK_PARAM_OFFSET 24
-#else
-#define MINIMAL_STACK_SIZE 5
-#define ALWAYS_ON_STACK(s)
-#define FP_ALSO_IN_REG(s) s
-#define ALIGN_DOUBLES
-#define RET_ADDR_OFFSET 4
-#define STACK_PARAM_OFFSET 8
-#endif
-
-static void inline
-add_general (guint *gr, guint *stack_size, guint *code_size, gboolean simple)
-{
-       if (simple) {
-               if (*gr >= GENERAL_REGS) {
-                       *stack_size += 4;
-                       *code_size += 8;    /* load from stack, save on stack */
-               } else {
-                       ALWAYS_ON_STACK (*stack_size += 4);
-                       *code_size += 4;    /* load from stack */
-               }
-       } else {
-               if (*gr >= GENERAL_REGS - 1) {
-                       *stack_size += 8;
-#ifdef ALIGN_DOUBLES
-                       *stack_size += (*stack_size % 8);
-#endif
-                       *code_size += 16;   /* 2x load from stack, 2x save to stack */
-               } else {
-                       ALWAYS_ON_STACK (*stack_size += 8);
-                       *code_size += 8;   /* 2x load from stack */
-               }
-#ifdef ALIGN_DOUBLES
-               if ((*gr) & 1)
-                       (*gr) ++;
-#endif
-               (*gr) ++;
-       }
-       (*gr) ++;
-}
-
-static void inline
-calculate_sizes (MonoMethodSignature *sig, guint *stack_size, guint *code_size, gboolean string_ctor, gboolean *use_memcpy)
-{
-       guint i, fr, gr;
-       guint32 simpletype;
-
-       fr = gr = 0;
-       *stack_size = MINIMAL_STACK_SIZE*4;
-       *code_size  = (PROLOG_INS + CALL_INS + EPILOG_INS)*4;
-
-       if (sig->hasthis) {
-               add_general (&gr, stack_size, code_size, TRUE);
-       }
-        DEBUG(printf("params: %d\n", sig->param_count));
-       for (i = 0; i < sig->param_count; ++i) {
-                DEBUG(printf("param %d: ", i));
-               if (sig->params [i]->byref) {
-                        DEBUG(printf("byref\n"));
-                       add_general (&gr, stack_size, code_size, TRUE);
-                       continue;
-               }
-               simpletype = sig->params [i]->type;
-       enum_calc_size:
-               switch (simpletype) {
-               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_CLASS:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_STRING:
-                       add_general (&gr, stack_size, code_size, TRUE);
-                       break;
-               case MONO_TYPE_SZARRAY:
-                       add_general (&gr, stack_size, code_size, TRUE);
-                       *code_size += 4;
-                       break;
-               case MONO_TYPE_VALUETYPE: {
-                       gint size;
-                       if (sig->params [i]->data.klass->enumtype) {
-                               simpletype = sig->params [i]->data.klass->enum_basetype->type;
-                               goto enum_calc_size;
-                       }
-                       size = mono_class_value_size (sig->params [i]->data.klass, NULL);
-                       if (size != 4) {
-                               DEBUG(printf ("copy %d bytes struct on stack\n",
-                                             mono_class_value_size (sig->params [i]->data.klass, NULL)));
-                               *use_memcpy = TRUE;
-                               *code_size += 8*4;
-                               *stack_size += (size + 3) & (~3);
-                               if (gr > GENERAL_REGS) {
-                                       *code_size += 4;
-                                       *stack_size += 4;
-                               }
-                       } else {
-                               DEBUG(printf ("load %d bytes struct\n",
-                                             mono_class_value_size (sig->params [i]->data.klass, NULL)));
-                               add_general (&gr, stack_size, code_size, TRUE);
-                               *code_size += 4;
-                       }
-                       break;
-               }
-               case MONO_TYPE_I8:
-                       add_general (&gr, stack_size, code_size, FALSE);
-                       break;
-               case MONO_TYPE_R4:
-                       if (fr < 7) {
-                               *code_size += 4;
-                               fr ++;
-                               FP_ALSO_IN_REG (gr ++);
-                               ALWAYS_ON_STACK (*stack_size += 4);
-                       } else {
-                               NOT_IMPLEMENTED ("R4 arg");
-                       }
-                       break;
-               case MONO_TYPE_R8:
-                       if (fr < 7) {
-                               *code_size += 4;
-                               fr ++;
-                               FP_ALSO_IN_REG (gr += 2);
-                               ALWAYS_ON_STACK (*stack_size += 8);
-                       } else {
-                               NOT_IMPLEMENTED ("R8 arg");
-                       }
-                       break;
-               default:
-                       g_error ("Can't trampoline 0x%x", sig->params [i]->type);
-               }
-       }
-
-       if (sig->ret->byref || string_ctor) {
-               *code_size += 8;
-       } else {
-               simpletype = sig->ret->type;
-enum_retvalue:
-               switch (simpletype) {
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-               case MONO_TYPE_CHAR:
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_CLASS:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_R4:
-               case MONO_TYPE_R8:
-               case MONO_TYPE_SZARRAY:
-               case MONO_TYPE_ARRAY:
-               case MONO_TYPE_STRING:
-                       *code_size += 8;
-                       break;
-               case MONO_TYPE_I8:
-                       *code_size += 12;
-                       break;
-               case MONO_TYPE_VALUETYPE:
-                       if (sig->ret->data.klass->enumtype) {
-                               simpletype = sig->ret->data.klass->enum_basetype->type;
-                               goto enum_retvalue;
-                       }
-                       *code_size += 2*4;
-                       break;
-               case MONO_TYPE_VOID:
-                       break;
-               default:
-                       g_error ("Can't handle as return value 0x%x", sig->ret->type);
-               }
-       }
-
-       if (*use_memcpy) {
-               *stack_size += 2*4;           /* for r14, r15 */
-               *code_size += 6*4;
-               if (sig->hasthis) {
-                       *stack_size += 4;     /* for r16 */
-                       *code_size += 4;
-               }
-       }
-
-       /* align stack size to 16 */
-       DEBUG (printf ("      stack size: %d (%d)\n       code size: %d\n", (*stack_size + 15) & ~15, *stack_size, *code_size));
-       *stack_size = (*stack_size + 15) & ~15;
-}
-
-static inline guint8 *
-emit_prolog (guint8 *p, MonoMethodSignature *sig, guint stack_size)
-{
-       /* function prolog */
-       ppc_stwu (p, ppc_r1, -stack_size, ppc_r1);     /* sp      <--- sp - stack_size, sp[0] <---- sp save sp, alloc stack */
-       ppc_mflr (p, ppc_r0);                          /* r0      <--- LR */
-       ppc_stw  (p, ppc_r31, stack_size - 4, ppc_r1); /* sp[+4]  <--- r31     save r31 */
-       ppc_stw  (p, ppc_r0, stack_size + RET_ADDR_OFFSET, ppc_r1);  /* sp[-4]  <--- LR      save return address for "callme" */
-       ppc_mr   (p, ppc_r31, ppc_r1);                 /* r31     <--- sp */
-
-       return p;
-}
-
-#define ARG_BASE ppc_r12
-#define ARG_SIZE sizeof (stackval)
-#define SAVE_4_IN_GENERIC_REGISTER \
-       if (gr < GENERAL_REGS) { \
-               ppc_lwz  (p, ppc_r3 + gr, i*ARG_SIZE, ARG_BASE); \
-               gr ++; \
-               ALWAYS_ON_STACK (stack_par_pos += 4); \
-       } else { \
-               ppc_lwz  (p, ppc_r11, i*ARG_SIZE, ARG_BASE); \
-               ppc_stw  (p, ppc_r11, stack_par_pos, ppc_r1); \
-               stack_par_pos += 4; \
-       }
-#define SAVE_4_VAL_IN_GENERIC_REGISTER \
-       if (gr < GENERAL_REGS) { \
-               ppc_lwz  (p, ppc_r3 + gr, i*ARG_SIZE, ARG_BASE); \
-               ppc_lwz  (p, ppc_r3 + gr, 0, ppc_r3 + gr); \
-               gr ++; \
-               ALWAYS_ON_STACK (stack_par_pos += 4); \
-       } else { \
-               ppc_lwz  (p, ppc_r11, i*ARG_SIZE, ARG_BASE); \
-               ppc_lwz  (p, ppc_r11, 0, ppc_r11); \
-               ppc_stw  (p, ppc_r11, stack_par_pos, ppc_r1); \
-               stack_par_pos += 4; \
-       }
-
-inline static guint8*
-emit_save_parameters (guint8 *p, MonoMethodSignature *sig, guint stack_size, gboolean use_memcpy)
-{
-       guint i, fr, gr, stack_par_pos, struct_pos, cur_struct_pos;
-       guint32 simpletype;
-
-       fr = gr = 0;
-       stack_par_pos = STACK_PARAM_OFFSET;
-
-       ppc_stw  (p, ppc_r4, stack_size - 12, ppc_r31);               /* preserve "retval", sp[+8] */
-
-       if (use_memcpy) {
-               ppc_stw  (p, ppc_r14, stack_size - 16, ppc_r31);      /* save r14 */
-               ppc_stw  (p, ppc_r15, stack_size - 20, ppc_r31);      /* save r15 */
-               ppc_mr   (p, ppc_r14, ppc_r3);                        /* keep "callme" in register */
-               ppc_mr   (p, ppc_r15, ppc_r6);                        /* keep "arguments" in register */
-       } else {
-               ppc_mr   (p, ppc_r12, ppc_r6);                        /* keep "arguments" in register */
-               ppc_mr   (p, ppc_r0, ppc_r3);                         /* keep "callme" in register */
-       }
-
-       if (sig->hasthis) {
-               if (use_memcpy) {
-                       ppc_stw  (p, ppc_r16, stack_size - 24, ppc_r31);      /* save r16 */
-                       ppc_mr   (p, ppc_r16, ppc_r5);
-               } else
-                       ppc_mr (p, ppc_r3, ppc_r5);
-               gr ++;
-                ALWAYS_ON_STACK (stack_par_pos += 4);
-       }
-
-       if (use_memcpy) {
-               cur_struct_pos = struct_pos = stack_par_pos;
-               for (i = 0; i < sig->param_count; ++i) {
-                       if (sig->params [i]->byref)
-                               continue;
-                       if (sig->params [i]->type == MONO_TYPE_VALUETYPE && !sig->params [i]->data.klass->enumtype) {
-                               gint size;
-
-                               size = mono_class_value_size (sig->params [i]->data.klass, NULL);
-                               if (size != 4) {
-                                       /* call memcpy */
-                                       ppc_addi (p, ppc_r3, ppc_r1, stack_par_pos);
-                                       ppc_lwz  (p, ppc_r4, i*16, ppc_r15);
-                                       /* FIXME check if size > 0xffff */
-                                       ppc_li   (p, ppc_r5, size & 0xffff);
-                                       ppc_lis  (p, ppc_r0, (guint32) memcpy >> 16);
-                                       ppc_ori  (p, ppc_r0, ppc_r0, (guint32) memcpy & 0xffff);
-                                       ppc_mtlr (p, ppc_r0);
-                                       ppc_blrl (p);
-                                       stack_par_pos += (size + 3) & (~3);
-                               }
-                       }
-               }
-
-               if (sig->hasthis) {
-                       ppc_mr   (p, ppc_r3, ppc_r16);
-                       ppc_lwz  (p, ppc_r16, stack_size - 24, ppc_r31);      /* restore r16 */
-               }
-               ppc_mr   (p, ppc_r0,  ppc_r14);
-               ppc_mr   (p, ppc_r12, ppc_r15);
-               ppc_lwz  (p, ppc_r14, stack_size - 16, ppc_r31);      /* restore r14 */
-               ppc_lwz  (p, ppc_r15, stack_size - 20, ppc_r31);      /* restore r15 */
-       }
-
-       if (sig->ret->type == MONO_TYPE_VALUETYPE && !sig->ret->byref) {
-               MonoClass *klass = sig->ret->data.klass;
-               if (!klass->enumtype) {
-                       gint size = mono_class_native_size (klass, NULL);
-
-                       DEBUG(printf ("retval value type size: %d\n", size));
-                       if (size > 8) {
-                               ppc_lwz (p, ppc_r3, stack_size - 12, ppc_r31);
-                               ppc_lwz (p, ppc_r3, 0, ppc_r3);
-                               gr ++;
-                                ALWAYS_ON_STACK (stack_par_pos += 4);
-                       } else {
-                               NOT_IMPLEMENTED ("retval valuetype <= 8 bytes");
-                       }
-               }
-       }
-
-       for (i = 0; i < sig->param_count; ++i) {
-               if (sig->params [i]->byref) {
-                       SAVE_4_IN_GENERIC_REGISTER;
-                       continue;
-               }
-               simpletype = sig->params [i]->type;
-       enum_calc_size:
-               switch (simpletype) {
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-               case MONO_TYPE_CHAR:
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_PTR:
-               case MONO_TYPE_CLASS:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_STRING:
-               case MONO_TYPE_SZARRAY:
-                       SAVE_4_IN_GENERIC_REGISTER;
-                       break;
-               case MONO_TYPE_VALUETYPE: {
-                       gint size;
-                       if (sig->params [i]->data.klass->enumtype) {
-                               simpletype = sig->params [i]->data.klass->enum_basetype->type;
-                               goto enum_calc_size;
-                       }
-                       size = mono_class_value_size (sig->params [i]->data.klass, NULL);
-                       if (size == 4) {
-                               SAVE_4_VAL_IN_GENERIC_REGISTER;
-                       } else {
-                               if (gr < GENERAL_REGS) {
-                                       ppc_addi (p, ppc_r3 + gr, ppc_r1, cur_struct_pos);
-                                       gr ++;
-                               } else {
-                                       ppc_lwz  (p, ppc_r11, cur_struct_pos, ppc_r1);
-                                       ppc_stw  (p, ppc_r11, stack_par_pos, ppc_r1);
-                                       stack_par_pos += 4;
-                               }
-                               cur_struct_pos += (size + 3) & (~3);
-                       }
-                       break;
-               }
-               case MONO_TYPE_I8:
-DEBUG(printf("Mono_Type_i8. gr = %d, arg_base = %d\n", gr, ARG_BASE));                
-#ifdef ALIGN_DOUBLES
-                       if (gr & 1)
-                               gr++;
-#endif
-                       if (gr < 7) {
-                               ppc_lwz  (p, ppc_r3 + gr, i*ARG_SIZE, ARG_BASE);
-                               ppc_lwz  (p, ppc_r3 + gr + 1, i*ARG_SIZE + 4, ARG_BASE);
-                               ALWAYS_ON_STACK (stack_par_pos += 8);
-                       } else if (gr == 7) {
-                                ppc_lwz  (p, ppc_r3 + gr, i*ARG_SIZE, ARG_BASE);
-                               ppc_lwz  (p, ppc_r11, i*ARG_SIZE + 4,  ARG_BASE);
-                                ppc_stw  (p, ppc_r11, stack_par_pos + 4, ppc_r1);
-                               stack_par_pos += 8;
-                        } else {
-                                ppc_lwz  (p, ppc_r11, i*ARG_SIZE, ARG_BASE);
-                                ppc_stw  (p, ppc_r11, stack_par_pos, ppc_r1);
-                               ppc_lwz  (p, ppc_r11, i*ARG_SIZE + 4,  ARG_BASE);
-                                ppc_stw  (p, ppc_r11, stack_par_pos + 4, ppc_r1);
-                               stack_par_pos += 8;
-                       }
-                       gr += 2;
-                       break;
-               case MONO_TYPE_R4:
-                       if (fr < 7) {
-                               ppc_lfs  (p, ppc_f1 + fr, i*ARG_SIZE, ARG_BASE);
-                               fr ++;
-                                FP_ALSO_IN_REG (gr ++);
-                                ALWAYS_ON_STACK (stack_par_pos += 4);
-                       } else {
-                               NOT_IMPLEMENTED ("r4 on stack");
-                       }
-                       break;
-               case MONO_TYPE_R8:
-                       if (fr < 7) {
-                               ppc_lfd  (p, ppc_f1 + fr, i*ARG_SIZE, ARG_BASE);
-                               fr ++;
-                                FP_ALSO_IN_REG (gr += 2);
-                                ALWAYS_ON_STACK (stack_par_pos += 8);
-                       } else {
-                               NOT_IMPLEMENTED ("r8 on stack");
-                       }
-                       break;
-               default:
-                       g_error ("Can't trampoline 0x%x", sig->params [i]->type);
-               }
-       }
-
-       return p;
-}
-
-static inline guint8 *
-alloc_code_memory (guint code_size)
-{
-       guint8 *p;
-
-#ifdef NEED_MPROTECT
-       p = g_malloc (code_size + PAGESIZE - 1);
-
-       /* Align to a multiple of PAGESIZE, assumed to be a power of two */
-       p = (char *)(((int) p + PAGESIZE-1) & ~(PAGESIZE-1));
-#else
-       p = g_malloc (code_size);
-#endif
-       DEBUG (printf ("           align: %p (%d)\n", p, (guint)p % 4));
-
-       return p;
-}
-
-/* static MonoString*
-mono_string_new_wrapper (const char *text)
-{
-       return text ? mono_string_new (mono_domain_get (), text) : NULL;
-} */
-
-static inline guint8 *
-emit_call_and_store_retval (guint8 *p, MonoMethodSignature *sig, guint stack_size, gboolean string_ctor)
-{
-       guint32 simpletype;
-
-       /* call "callme" */
-       ppc_mtlr (p, ppc_r0);
-       ppc_blrl (p);
-
-       /* get return value */
-       if (sig->ret->byref || string_ctor) {
-               ppc_lwz  (p, ppc_r9, stack_size - 12, ppc_r31);        /* load "retval" address */
-               ppc_stw  (p, ppc_r3, 0, ppc_r9);                       /* save return value (r3) to "retval" */
-       } else {
-               simpletype = sig->ret->type;
-enum_retvalue:
-               switch (simpletype) {
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-                       ppc_lwz  (p, ppc_r9, stack_size - 12, ppc_r31);        /* load "retval" address */
-                       ppc_stb  (p, ppc_r3, 0, ppc_r9);                       /* save return value (r3) to "retval" */
-                       break;
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-               case MONO_TYPE_CHAR:
-                       ppc_lwz  (p, ppc_r9, stack_size - 12, ppc_r31);        /* load "retval" address */
-                       ppc_sth  (p, ppc_r3, 0, ppc_r9);                       /* save return value (r3) to "retval" */
-                       break;
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_CLASS:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_SZARRAY:
-               case MONO_TYPE_ARRAY:
-               case MONO_TYPE_STRING:
-                       ppc_lwz  (p, ppc_r9, stack_size - 12, ppc_r31);        /* load "retval" address */
-                       ppc_stw  (p, ppc_r3, 0, ppc_r9);                       /* save return value (r3) to "retval" */
-                       break;
-               case MONO_TYPE_R4:
-                       ppc_lwz  (p, ppc_r9, stack_size - 12, ppc_r31);        /* load "retval" address */
-                       ppc_stfs (p, ppc_f1, 0, ppc_r9);                       /* save return value (f1) to "retval" */
-                       break;
-               case MONO_TYPE_R8:
-                       ppc_lwz  (p, ppc_r9, stack_size - 12, ppc_r31);        /* load "retval" address */
-                       ppc_stfd (p, ppc_f1, 0, ppc_r9);                       /* save return value (f1) to "retval" */
-                       break;
-               case MONO_TYPE_I8:
-                       ppc_lwz  (p, ppc_r9, stack_size - 12, ppc_r31);        /* load "retval" address */
-                       ppc_stw  (p, ppc_r3, 0, ppc_r9);                       /* save return value (r3) to "retval" */
-                       ppc_stw  (p, ppc_r4, 4, ppc_r9);                       /* save return value (r3) to "retval" */
-                       break;
-               case MONO_TYPE_VALUETYPE:
-                       if (sig->ret->data.klass->enumtype) {
-                               simpletype = sig->ret->data.klass->enum_basetype->type;
-                               goto enum_retvalue;
-                       }
-                       break;
-               case MONO_TYPE_VOID:
-                       break;
-               default:
-                       g_error ("Can't handle as return value 0x%x", sig->ret->type);
-               }
-       }
-
-       return p;
-}
-
-static inline guint8 *
-emit_epilog (guint8 *p, MonoMethodSignature *sig, guint stack_size)
-{
-       /* function epilog */
-       ppc_lwz  (p, ppc_r11, 0,  ppc_r1);        /* r11     <--- sp[0]   load backchain from caller's function */
-       ppc_lwz  (p, ppc_r0, RET_ADDR_OFFSET, ppc_r11);         /* r0      <--- r11[4]  load return address */
-       ppc_mtlr (p, ppc_r0);                     /* LR      <--- r0      set return address */
-       ppc_lwz  (p, ppc_r31, -4, ppc_r11);       /* r31     <--- r11[-4] restore r31 */
-       ppc_mr   (p, ppc_r1, ppc_r11);            /* sp      <--- r11     restore stack */
-       ppc_blr  (p);                             /* return */
-
-       return p;
-}
-
-MonoPIFunc
-mono_arch_create_trampoline (MonoMethodSignature *sig, gboolean string_ctor)
-{
-       guint8 *p, *code_buffer;
-       guint stack_size, code_size;
-       gboolean use_memcpy = FALSE;
-
-       DEBUG (printf ("\nPInvoke [start emiting]\n"));
-       calculate_sizes (sig, &stack_size, &code_size, string_ctor, &use_memcpy);
-
-       p = code_buffer = alloc_code_memory (code_size);
-       p = emit_prolog (p, sig, stack_size);
-       p = emit_save_parameters (p, sig, stack_size, use_memcpy);
-       p = emit_call_and_store_retval (p, sig, stack_size, string_ctor);
-       p = emit_epilog (p, sig, stack_size);
-
-       /* {
-               guchar *cp;
-               printf (".text\n.align 4\n.globl main\n.type main,@function\nmain:\n");
-               for (cp = code_buffer; cp < p; cp++) {
-                       printf (".byte 0x%x\n", *cp);
-               }
-               } */
-
-#ifdef NEED_MPROTECT
-       if (mprotect (code_buffer, 1024, PROT_READ | PROT_WRITE | PROT_EXEC)) {
-               g_error ("Cannot mprotect trampoline\n");
-       }
-#endif
-
-       DEBUG (printf ("emited code size: %d\n", p - code_buffer));
-       flush_icache (code_buffer, p - code_buffer);
-
-       DEBUG (printf ("PInvoke [end emiting]\n"));
-
-       return (MonoPIFunc) code_buffer;
-       /* return fake_func; */
-}
-
-
-#ifdef __APPLE__
-#define MINV_POS  40  /* MonoInvocation structure offset on stack - STACK_PARAM_OFFSET + 4 pointer args for stackval_from_data */
-#else
-#define MINV_POS  8   /* MonoInvocation structure offset on stack */
-#endif
-#define STACK_POS (MINV_POS - sizeof (stackval) * sig->param_count)
-#define OBJ_POS   8
-#define TYPE_OFFSET (G_STRUCT_OFFSET (stackval, type))
-
-/*
- * Returns a pointer to a native function that can be used to
- * call the specified method.
- * The function created will receive the arguments according
- * to the call convention specified in the method.
- * This function works by creating a MonoInvocation structure,
- * filling the fields in and calling ves_exec_method on it.
- * Still need to figure out how to handle the exception stuff
- * across the managed/unmanaged boundary.
- */
-void *
-mono_arch_create_method_pointer (MonoMethod *method)
-{
-       MonoMethodSignature *sig;
-       MonoJitInfo *ji;
-       guint8 *p, *code_buffer;
-       guint i, align = 0, code_size, stack_size, stackval_arg_pos, local_pos, local_start, reg_param = 0, stack_param,
-               cpos, vt_cur;
-       gint *vtbuf;
-       guint32 simpletype;
-
-       code_size = 1024;
-       stack_size = 1024;
-       stack_param = 0;
-
-       sig = mono_method_signature (method);
-
-       p = code_buffer = g_malloc (code_size);
-
-       DEBUG (printf ("\nDelegate [start emiting] %s\n", mono_method_get_name (method)));
-
-       /* prolog */
-       ppc_stwu (p, ppc_r1, -stack_size, ppc_r1);     /* sp      <--- sp - stack_size, sp[0] <---- sp save sp, alloc stack */
-       ppc_mflr (p, ppc_r0);                          /* r0      <--- LR */
-       ppc_stw  (p, ppc_r31, stack_size - 4, ppc_r1); /* sp[+4]  <--- r31     save r31 */
-       ppc_stw  (p, ppc_r0, stack_size + RET_ADDR_OFFSET, ppc_r1);  /* sp[-4]  <--- LR      save return address for "callme" */
-       ppc_mr   (p, ppc_r31, ppc_r1);                 /* r31     <--- sp */
-
-       /* let's fill MonoInvocation */
-       /* first zero some fields */
-       ppc_li   (p, ppc_r0, 0);
-       ppc_stw  (p, ppc_r0, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, ex)), ppc_r31);
-       ppc_stw  (p, ppc_r0, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, ex_handler)), ppc_r31);
-       ppc_stw  (p, ppc_r0, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, parent)), ppc_r31);
-
-       /* set method pointer */
-       ppc_lis  (p, ppc_r0,     (guint32) method >> 16);
-       ppc_ori  (p, ppc_r0, ppc_r0, (guint32) method & 0xffff);
-       ppc_stw  (p, ppc_r0, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, method)), ppc_r31);
-
-       local_start = local_pos = MINV_POS + sizeof (MonoInvocation) + (sig->param_count + 1) * sizeof (stackval);
-
-       if (sig->hasthis) {
-               ppc_stw  (p, ppc_r3, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, obj)), ppc_r31);
-               reg_param = 1;
-       } 
-
-       if (sig->param_count) {
-               gint save_count = MIN (8, sig->param_count + sig->hasthis);
-               for (i = reg_param; i < save_count; i ++) {
-                       ppc_stw (p, ppc_r3 + i, local_pos, ppc_r31);
-                       local_pos += 4;
-                       DEBUG (printf ("save r%d\n", 4 + i));
-               }
-       }
-
-       /* prepare space for valuetypes */
-       vt_cur = local_pos;
-       vtbuf = alloca (sizeof(int)*sig->param_count);
-       cpos = 0;
-       for (i = 0; i < sig->param_count; i++) {
-               MonoType *type = sig->params [i];
-               vtbuf [i] = -1;
-               if (type->type == MONO_TYPE_VALUETYPE) {
-                       MonoClass *klass = type->data.klass;
-                       gint size;
-
-                       if (klass->enumtype)
-                               continue;
-                       size = mono_class_native_size (klass, &align);
-                       cpos += align - 1;
-                       cpos &= ~(align - 1);
-                       vtbuf [i] = cpos;
-                       cpos += size;
-               }       
-       }
-       cpos += 3;
-       cpos &= ~3;
-
-       local_pos += cpos;
-
-       /* set MonoInvocation::stack_args */
-       stackval_arg_pos = MINV_POS + sizeof (MonoInvocation);
-       ppc_addi (p, ppc_r0, ppc_r31, stackval_arg_pos);
-       ppc_stw  (p, ppc_r0, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, stack_args)), ppc_r31);
-
-       /* add stackval arguments */
-       for (i = 0; i < sig->param_count; ++i) {
-               if (reg_param < 8) {
-                       ppc_addi (p, ppc_r5, ppc_r31, local_start + i*4);
-                       reg_param ++;
-               } else {
-                       ppc_addi (p, ppc_r5, stack_size + 8 + stack_param, ppc_r31);
-                       stack_param ++;
-               }
-               ppc_lis  (p, ppc_r3, (guint32) sig->params [i] >> 16);
-
-               if (vtbuf [i] >= 0) {
-                       ppc_addi (p, ppc_r4, ppc_r31, vt_cur);
-                       ppc_stw  (p, ppc_r4, stackval_arg_pos, ppc_r31);
-                       ppc_addi (p, ppc_r4, ppc_r31, stackval_arg_pos);
-                       ppc_lwz  (p, ppc_r5, 0, ppc_r5);
-                       vt_cur += vtbuf [i];
-               } else {
-                       ppc_addi (p, ppc_r4, ppc_r31, stackval_arg_pos);
-               }
-               ppc_ori  (p, ppc_r3, ppc_r3, (guint32) sig->params [i] & 0xffff);
-               ppc_lis  (p, ppc_r0, (guint32) stackval_from_data >> 16);
-               ppc_li   (p, ppc_r6, sig->pinvoke);
-               ppc_ori  (p, ppc_r0, ppc_r0, (guint32) stackval_from_data & 0xffff);
-               ppc_mtlr (p, ppc_r0);
-               ppc_blrl (p);
-
-               stackval_arg_pos += sizeof (stackval);
-       }
-
-       /* return value storage */
-       if (sig->param_count) {
-               ppc_addi (p, ppc_r0, ppc_r31, stackval_arg_pos);
-       }
-       ppc_stw  (p, ppc_r0, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, retval)), ppc_r31);
-
-       /* call ves_exec_method */
-       ppc_lis  (p, ppc_r0,     (guint32) ves_exec_method >> 16);
-       ppc_addi (p, ppc_r3, ppc_r31, MINV_POS);
-       ppc_ori  (p, ppc_r0, ppc_r0, (guint32) ves_exec_method & 0xffff);
-       ppc_mtlr (p, ppc_r0);
-       ppc_blrl (p);
-
-       /* move retval from stackval to proper place (r3/r4/...) */
-       if (sig->ret->byref) {
-               DEBUG (printf ("ret by ref\n"));
-               ppc_lwz (p, ppc_r3, stackval_arg_pos, ppc_r31);
-       } else {
-       enum_retvalue:
-               switch (sig->ret->type) {
-               case MONO_TYPE_VOID:
-                       break;
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-                       ppc_lbz (p, ppc_r3, stackval_arg_pos, ppc_r31);
-                       break;
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-                       ppc_lhz (p, ppc_r3, stackval_arg_pos, ppc_r31);
-                       break;
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_STRING:
-               case MONO_TYPE_CLASS:
-                       ppc_lwz (p, ppc_r3, stackval_arg_pos, ppc_r31);
-                       break;
-               case MONO_TYPE_I8:
-                       ppc_lwz (p, ppc_r3, stackval_arg_pos, ppc_r31);
-                       ppc_lwz (p, ppc_r4, stackval_arg_pos + 4, ppc_r31);
-                       break;
-               case MONO_TYPE_R4:
-                       ppc_lfs (p, ppc_f1, stackval_arg_pos, ppc_r31);
-                       break;
-               case MONO_TYPE_R8:
-                       ppc_lfd (p, ppc_f1, stackval_arg_pos, ppc_r31);
-                       break;
-               case MONO_TYPE_VALUETYPE:
-                       if (sig->ret->data.klass->enumtype) {
-                               simpletype = sig->ret->data.klass->enum_basetype->type;
-                               goto enum_retvalue;
-                       }
-                       NOT_IMPLEMENTED ("value type as ret val from delegate");
-                       break;
-               default:
-                       g_error ("Type 0x%x not handled yet in thunk creation", sig->ret->type);
-                       break;
-               }
-       }
-
-       /* epilog */
-       ppc_lwz  (p, ppc_r11, 0,  ppc_r1);        /* r11     <--- sp[0]   load backchain from caller's function */
-       ppc_lwz  (p, ppc_r0, RET_ADDR_OFFSET, ppc_r11);         /* r0      <--- r11[4]  load return address */
-       ppc_mtlr (p, ppc_r0);                     /* LR      <--- r0      set return address */
-       ppc_lwz  (p, ppc_r31, -4, ppc_r11);       /* r31     <--- r11[-4] restore r31 */
-       ppc_mr   (p, ppc_r1, ppc_r11);            /* sp      <--- r11     restore stack */
-       ppc_blr  (p);                             /* return */
-
-       DEBUG (printf ("emited code size: %d\n", p - code_buffer));
-       DEBUG (disassemble (code_buffer, p - code_buffer));
-       flush_icache (code_buffer, p - code_buffer);
-
-       DEBUG (printf ("Delegate [end emiting]\n"));
-
-       ji = g_new0 (MonoJitInfo, 1);
-       ji->method = method;
-       ji->code_size = p - code_buffer;
-       ji->code_start = code_buffer;
-
-       mono_jit_info_table_add (mono_get_root_domain (), ji);
-
-       return ji->code_start;
-}
index 977823705adf9bcf977f924524c39650bf94cf87..bab0f9e54d67e10480e47df6f55faa254602e2b0 100644 (file)
@@ -1,9 +1 @@
-if INTERP_SUPPORTED
-
-AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
-
-noinst_LTLIBRARIES = libmonoarch-x86.la
-
-libmonoarch_x86_la_SOURCES = tramp.c x86-codegen.h
-
-endif
+EXTRA_DIST = x86-codegen.h
\ No newline at end of file
diff --git a/mono/arch/x86/test.c b/mono/arch/x86/test.c
deleted file mode 100644 (file)
index 3511e8f..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-#include "x86-codegen.h"
-#include <stdio.h>
-
-/* don't run the resulting program, it will destroy your computer,
- * just objdump -d it to inspect we generated the correct assembler.
- */
-
-int main() {
-       unsigned char code [16000];
-       unsigned char *p = code;
-       unsigned char *target, *start, *end;
-       unsigned long mem_addr = 0xdeadbeef;
-       int size, i;
-
-       printf (".text\n.align 4\n.globl main\n.type main,@function\nmain:\n");
-
-       x86_prolog (p, 16, X86_CALLER_REGS);
-
-       x86_cmpxchg_reg_reg (p, X86_EAX, X86_EBP);
-       x86_cmpxchg_membase_reg (p, X86_EAX, 12, X86_EBP);
-
-       x86_xchg_reg_reg (p, X86_EAX, X86_EBP, 4);
-       x86_xchg_reg_reg (p, X86_EAX, X86_EBP, 1); // FIXME?
-       x86_xchg_membase_reg (p, X86_EAX, 12, X86_EBP, 4);
-       x86_xchg_membase_reg (p, X86_EAX, 12, X86_EBP, 2);
-       x86_xchg_membase_reg (p, X86_EAX, 12, X86_EBX, 1); // FIXME?
-
-       x86_inc_reg (p, X86_EAX);
-       x86_inc_mem (p, mem_addr);
-       x86_inc_membase (p, X86_ESP, 4);
-       
-       x86_nop (p);
-       x86_nop (p);
-       
-       x86_dec_reg (p, X86_EAX);
-       x86_dec_reg (p, X86_ECX);
-       x86_dec_mem (p, mem_addr);
-       x86_dec_membase (p, X86_ESP, 4);
-       
-       x86_not_reg (p, X86_EDX);
-       x86_not_reg (p, X86_ECX);
-       x86_not_mem (p, mem_addr);
-       x86_not_membase (p, X86_ESP, 4);
-       x86_not_membase (p, X86_ESP, 0x4444444);
-       x86_not_membase (p, X86_EBP, 0x4444444);
-       x86_not_membase (p, X86_ECX, 0x4444444);
-       x86_not_membase (p, X86_EDX, 0);
-       x86_not_membase (p, X86_EBP, 0);
-
-       x86_neg_reg (p, X86_EAX);
-       x86_neg_reg (p, X86_ECX);
-       x86_neg_mem (p, mem_addr);
-       x86_neg_membase (p, X86_ESP, 8);
-
-       x86_alu_reg_imm (p, X86_ADD, X86_EAX, 5);
-       x86_alu_reg_imm (p, X86_ADD, X86_EBX, -10);
-       x86_alu_reg_imm (p, X86_SUB, X86_EDX, 7);
-       x86_alu_reg_imm (p, X86_OR, X86_ESP, 0xffffedaf);
-       x86_alu_reg_imm (p, X86_CMP, X86_ECX, 1);
-       x86_alu_mem_imm (p, X86_ADC, mem_addr, 2);
-       x86_alu_membase_imm (p, X86_ADC, X86_ESP, -4, 4);
-       x86_alu_membase_imm (p, X86_ADC, X86_ESP, -12, 0xffffedaf);
-
-       x86_alu_mem_reg (p, X86_SUB, mem_addr, X86_EDX);
-       x86_alu_reg_reg (p, X86_ADD, X86_EAX, X86_EBX);
-       x86_alu_reg_mem (p, X86_ADD, X86_EAX, mem_addr);
-       x86_alu_reg_imm (p, X86_ADD, X86_EAX, 0xdeadbeef);
-       x86_alu_reg_membase (p, X86_XOR, X86_EDX, X86_ESP, 4);
-       x86_alu_membase_reg (p, X86_XOR, X86_EBP, 8, X86_ESI);
-
-       x86_test_reg_imm (p, X86_EAX, 16);
-       x86_test_reg_imm (p, X86_EDX, -16);
-       x86_test_mem_imm (p, mem_addr, 1);
-       x86_test_membase_imm (p, X86_EBP, 8, 1);
-
-       x86_test_reg_reg (p, X86_EAX, X86_EDX);
-       x86_test_mem_reg (p, mem_addr, X86_EDX);
-       x86_test_membase_reg (p, X86_ESI, 4, X86_EDX);
-
-       x86_shift_reg_imm (p, X86_SHL, X86_EAX, 1);
-       x86_shift_reg_imm (p, X86_SHL, X86_EDX, 2);
-
-       x86_shift_mem_imm (p, X86_SHL, mem_addr, 2);
-       x86_shift_membase_imm (p, X86_SHLR, X86_EBP, 8, 4);
-
-       /*
-        * Shift by CL
-        */
-       x86_shift_reg (p, X86_SHL, X86_EAX);
-       x86_shift_mem (p, X86_SHL, mem_addr);
-
-       x86_mul_reg (p, X86_EAX, 0);
-       x86_mul_reg (p, X86_EAX, 1);
-       x86_mul_membase (p, X86_EBP, 8, 1);
-
-       x86_imul_reg_reg (p, X86_EBX, X86_EDX);
-       x86_imul_reg_membase (p, X86_EBX, X86_EBP, 12);
-
-       x86_imul_reg_reg_imm (p, X86_EBX, X86_EDX, 10);
-       x86_imul_reg_mem_imm (p, X86_EBX, mem_addr, 20);
-       x86_imul_reg_membase_imm (p, X86_EBX, X86_EBP, 16, 300);
-
-       x86_div_reg (p, X86_EDX, 0);
-       x86_div_reg (p, X86_EDX, 1);
-       x86_div_mem (p, mem_addr, 1);
-       x86_div_membase (p, X86_ESI, 4, 1);
-
-       x86_mov_mem_reg (p, mem_addr, X86_EAX, 4);
-       x86_mov_mem_reg (p, mem_addr, X86_EAX, 2);
-       x86_mov_mem_reg (p, mem_addr, X86_EAX, 1);
-       x86_mov_membase_reg (p, X86_EBP, 4, X86_EAX, 1);
-
-       x86_mov_regp_reg (p, X86_EAX, X86_EAX, 4);
-       x86_mov_membase_reg (p, X86_EAX, 0, X86_EAX, 4);
-       x86_mov_reg_membase (p, X86_EAX, X86_EAX, 0, 4);
-       x86_mov_reg_memindex (p, X86_ECX, X86_EAX, 34, X86_EDX, 2, 4);
-       x86_mov_reg_memindex (p, X86_ECX, X86_NOBASEREG, 34, X86_EDX, 2, 4);
-       x86_mov_memindex_reg (p, X86_EAX, X86_EAX, 0, X86_EDX, 2, 4);
-       x86_mov_reg_reg (p, X86_EAX, X86_EAX, 1);
-       x86_mov_reg_reg (p, X86_EAX, X86_EAX, 4);
-       x86_mov_reg_mem (p, X86_EAX, mem_addr, 4);
-       
-       x86_mov_reg_imm (p, X86_EAX, 10);
-       x86_mov_mem_imm (p, mem_addr, 54, 4);
-       x86_mov_mem_imm (p, mem_addr, 54, 1);
-
-       x86_lea_mem (p, X86_EDX, mem_addr);
-       /* test widen */
-       x86_widen_memindex (p, X86_EDX, X86_ECX, 0, X86_EBX, 2, 1, 0);
-       
-       x86_cdq (p);
-       x86_wait (p);
-
-       x86_fp_op_mem (p, X86_FADD, mem_addr, 1);
-       x86_fp_op_mem (p, X86_FSUB, mem_addr, 0);
-       x86_fp_op (p, X86_FSUB, 2);
-       x86_fp_op_reg (p, X86_FMUL, 1, 0);
-       x86_fstp (p, 2);
-       x86_fcompp (p);
-       x86_fnstsw (p);
-       x86_fnstcw (p, mem_addr);
-       x86_fnstcw_membase (p, X86_ESP, -8);
-
-       x86_fldcw_membase (p, X86_ESP, -8);
-       x86_fchs (p);
-       x86_frem (p);
-       x86_fxch (p, 3);
-       x86_fcomip (p, 3);
-       x86_fld_membase (p, X86_ESP, -8, 1);
-       x86_fld_membase (p, X86_ESP, -8, 0);
-       x86_fld80_membase (p, X86_ESP, -8);
-       x86_fild_membase (p, X86_ESP, -8, 1);
-       x86_fild_membase (p, X86_ESP, -8, 0);
-       x86_fld_reg (p, 4);
-       x86_fldz (p);
-       x86_fld1 (p);
-       
-       x86_fst (p, mem_addr, 1, 0);
-       x86_fst (p, mem_addr, 1, 1);
-       x86_fst (p, mem_addr, 0, 1);
-       
-       x86_fist_pop_membase (p, X86_EDX, 4, 1);
-       x86_fist_pop_membase (p, X86_EDX, 4, 0);
-
-       x86_push_reg (p, X86_EBX);
-       x86_push_membase (p, X86_EBP, 8);
-       x86_push_imm (p, -1);
-       x86_pop_reg (p, X86_EBX);
-
-       x86_pushad (p);
-       x86_pushfd (p);
-       x86_popfd (p);
-       x86_popad (p);
-
-       target = p;
-
-       start = p;
-       x86_jump32 (p, mem_addr);
-       x86_patch (start, target);
-       start = p;
-       x86_jump8 (p, 12);
-       x86_patch (start, target);
-       x86_jump_reg (p, X86_EAX);
-       x86_jump_membase (p, X86_EDX, 16);
-
-       x86_jump_code (p, target);
-
-       x86_branch8 (p, X86_CC_EQ, 54, 1);
-       x86_branch32 (p, X86_CC_LT, 54, 0);
-       x86_branch (p, X86_CC_GT, target, 0);
-       x86_branch_disp (p, X86_CC_NE, -4, 0);
-
-       x86_set_reg (p, X86_CC_EQ, X86_EAX, 0);
-       x86_set_membase (p, X86_CC_LE, X86_EBP, -8, 0);
-
-       x86_call_code (p, printf);
-       x86_call_reg (p, X86_ECX);
-
-       x86_sahf (p);
-       
-       x86_fsin (p);
-       x86_fcos (p);
-       x86_fabs (p);
-       x86_fpatan (p);
-       x86_fprem (p);
-       x86_fprem1 (p);
-       x86_frndint (p);
-       x86_fsqrt (p);
-       x86_fptan (p);
-       
-       x86_leave (p);
-       x86_ret (p);
-       x86_ret_imm (p, 24);
-       
-       x86_cmov_reg (p, X86_CC_GT, 1, X86_EAX, X86_EDX);
-       x86_cmov_membase (p, X86_CC_GT, 0, X86_EAX, X86_EDX, -4);
-
-       x86_nop (p);
-       x86_epilog (p, X86_CALLER_REGS);
-
-       size = p-code;
-       for (i = 0; i < size; ++i)
-               printf (".byte %d\n", (unsigned int) code [i]);
-       return 0;
-}
diff --git a/mono/arch/x86/tramp.c b/mono/arch/x86/tramp.c
deleted file mode 100644 (file)
index fab5a55..0000000
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * Create trampolines to invoke arbitrary functions.
- * 
- * Copyright (C) Ximian Inc.
- * 
- * Authors: 
- *   Paolo Molaro (lupus@ximian.com)
- *   Dietmar Maurer (dietmar@ximian.com)
- * 
- */
-
-#include "config.h"
-#include <stdlib.h>
-#include <string.h>
-#include "x86-codegen.h"
-#include "mono/metadata/class.h"
-#include "mono/metadata/tabledefs.h"
-#include "mono/interpreter/interp.h"
-#include "mono/metadata/appdomain.h"
-#include "mono/metadata/marshal.h"
-
-/*
- * The resulting function takes the form:
- * void func (void (*callme)(), void *retval, void *this_obj, stackval *arguments);
- */
-#define FUNC_ADDR_POS  8
-#define RETVAL_POS     12
-#define THIS_POS       16
-#define ARGP_POS       20
-#define LOC_POS        -4
-
-#define ARG_SIZE       sizeof (stackval)
-
-MonoPIFunc
-mono_arch_create_trampoline (MonoMethodSignature *sig, gboolean string_ctor)
-{
-       unsigned char *p, *code_buffer;
-       guint32 stack_size = 0, code_size = 50;
-       guint32 arg_pos, simpletype;
-       int i, stringp;
-       static GHashTable *cache = NULL;
-       MonoPIFunc res;
-
-       if (!cache) 
-               cache = g_hash_table_new ((GHashFunc)mono_signature_hash, 
-                                         (GCompareFunc)mono_metadata_signature_equal);
-
-       if ((res = (MonoPIFunc)g_hash_table_lookup (cache, sig)))
-               return res;
-
-       if (sig->hasthis) {
-               stack_size += sizeof (gpointer);
-               code_size += 10;
-       }
-       
-       if (sig->ret->type == MONO_TYPE_VALUETYPE && !sig->ret->byref && !sig->ret->data.klass->enumtype) {
-               stack_size += sizeof (gpointer);
-               code_size += 5;
-       }
-
-       for (i = 0; i < sig->param_count; ++i) {
-               if (sig->params [i]->byref) {
-                       stack_size += sizeof (gpointer);
-                       code_size += 20;
-                       continue;
-               }
-               simpletype = sig->params [i]->type;
-enum_calc_size:
-               switch (simpletype) {
-               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:
-                       stack_size += 4;
-                       code_size += i < 10 ? 5 : 8;
-                       break;
-               case MONO_TYPE_VALUETYPE: {
-                       int size;
-                       if (sig->params [i]->data.klass->enumtype) {
-                               simpletype = sig->params [i]->data.klass->enum_basetype->type;
-                               goto enum_calc_size;
-                       }
-                       if ((size = mono_class_native_size (sig->params [i]->data.klass, NULL)) != 4) {
-                               stack_size += size + 3;
-                               stack_size &= ~3;
-                               code_size += 32;
-                       } else {
-                               stack_size += 4;
-                               code_size += i < 10 ? 5 : 8;
-                       }
-                       break;
-               }
-               case MONO_TYPE_I8:
-                       stack_size += 8;
-                       code_size += i < 10 ? 5 : 8;
-                       break;
-               case MONO_TYPE_R4:
-                       stack_size += 4;
-                       code_size += i < 10 ? 10 : 13;
-                       break;
-               case MONO_TYPE_R8:
-                       stack_size += 8;
-                       code_size += i < 10 ? 7 : 10;
-                       break;
-               default:
-                       g_error ("Can't trampoline 0x%x", sig->params [i]->type);
-               }
-       }
-       /*
-        * FIXME: take into account large return values.
-        */
-
-       code_buffer = p = alloca (code_size);
-
-       /*
-        * Standard function prolog.
-        */
-       x86_push_reg (p, X86_EBP);
-       x86_mov_reg_reg (p, X86_EBP, X86_ESP, 4);
-       /*
-        * and align to 16 byte boundary...
-        */
-       stack_size += 15;
-       stack_size &= ~15;
-
-       if (stack_size)
-               x86_alu_reg_imm (p, X86_SUB, X86_ESP, stack_size);
-
-       /*
-        * EDX has the pointer to the args.
-        */
-       x86_mov_reg_membase (p, X86_EDX, X86_EBP, ARGP_POS, 4);
-
-       /*
-        * Push arguments in reverse order.
-        */
-       stringp = 0;
-       for (i = sig->param_count; i; --i) {
-               arg_pos = ARG_SIZE * (i - 1);
-               if (sig->params [i - 1]->byref) {
-                       x86_push_membase (p, X86_EDX, arg_pos);
-                       continue;
-               }
-               simpletype = sig->params [i - 1]->type;
-enum_marshal:
-               switch (simpletype) {
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-               case MONO_TYPE_CHAR:
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_PTR:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_STRING:
-                       x86_push_membase (p, X86_EDX, arg_pos);
-                       break;
-               case MONO_TYPE_R4:
-                       x86_alu_reg_imm (p, X86_SUB, X86_ESP, 4);
-                       x86_fld_membase (p, X86_EDX, arg_pos, TRUE);
-                       x86_fst_membase (p, X86_ESP, 0, FALSE, TRUE);
-                       break;
-               case MONO_TYPE_CLASS:
-                       x86_push_membase (p, X86_EDX, arg_pos);
-                       break;
-               case MONO_TYPE_SZARRAY:
-                       x86_push_membase (p, X86_EDX, arg_pos);
-                       break;
-               case MONO_TYPE_VALUETYPE:
-                       if (!sig->params [i - 1]->data.klass->enumtype) {
-                               int size = mono_class_native_size (sig->params [i - 1]->data.klass, NULL);
-                               if (size == 4) {
-                                       /* it's a structure that fits in 4 bytes, need to push the value pointed to */
-                                       x86_mov_reg_membase (p, X86_EAX, X86_EDX, arg_pos, 4);
-                                       x86_push_regp (p, X86_EAX);
-                               } else {
-                                       int ss = size;
-                                       ss += 3;
-                                       ss &= ~3;
-
-                                       x86_alu_reg_imm (p, X86_SUB, X86_ESP, ss);
-                                       x86_push_imm (p, size);
-                                       x86_push_membase (p, X86_EDX, arg_pos);
-                                       x86_lea_membase (p, X86_EAX, X86_ESP, 2*4);
-                                       x86_push_reg (p, X86_EAX);
-                                       x86_mov_reg_imm (p, X86_EAX, memcpy);
-                                       x86_call_reg (p, X86_EAX);
-                                       x86_alu_reg_imm (p, X86_ADD, X86_ESP, 12);
-                                       /* memcpy might clobber EDX so restore it */
-                                       x86_mov_reg_membase (p, X86_EDX, X86_EBP, ARGP_POS, 4);
-                               }
-                       } else {
-                               /* it's an enum value */
-                               simpletype = sig->params [i - 1]->data.klass->enum_basetype->type;
-                               goto enum_marshal;
-                       }
-                       break;
-               case MONO_TYPE_I8:
-               case MONO_TYPE_U8:
-               case MONO_TYPE_R8:
-                       x86_push_membase (p, X86_EDX, arg_pos + 4);
-                       x86_push_membase (p, X86_EDX, arg_pos);
-                       break;
-               default:
-                       g_error ("Can't trampoline 0x%x", sig->params [i - 1]->type);
-               }
-       }
-
-       if (sig->hasthis) {
-               if (sig->call_convention != MONO_CALL_THISCALL) {
-                       x86_mov_reg_membase (p, X86_EDX, X86_EBP, THIS_POS, 4);
-                       x86_push_reg (p, X86_EDX);
-               } else {
-                       x86_mov_reg_membase (p, X86_ECX, X86_EBP, THIS_POS, 4);
-               }
-       }
-
-       if (sig->ret->type == MONO_TYPE_VALUETYPE && !sig->ret->byref) {
-               MonoClass *klass = sig->ret->data.klass;
-               if (!klass->enumtype) {
-                       x86_mov_reg_membase (p, X86_ECX, X86_EBP, RETVAL_POS, 4);
-                       x86_push_membase (p, X86_ECX, 0);
-               }
-       }
-
-       /* 
-        * Insert call to function 
-        */
-       x86_mov_reg_membase (p, X86_EDX, X86_EBP, FUNC_ADDR_POS, 4);
-       x86_call_reg (p, X86_EDX);
-
-       /*
-        * Handle retval.
-        * Small integer and pointer values are in EAX.
-        * Long integers are in EAX:EDX.
-        * FP values are on the FP stack.
-        */
-
-       if (sig->ret->byref || string_ctor) {
-               x86_mov_reg_membase (p, X86_ECX, X86_EBP, RETVAL_POS, 4);
-               x86_mov_regp_reg (p, X86_ECX, X86_EAX, 4);
-       } else {
-               simpletype = sig->ret->type;
-       enum_retvalue:
-               switch (simpletype) {
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-                       x86_mov_reg_membase (p, X86_ECX, X86_EBP, RETVAL_POS, 4);
-                       x86_mov_regp_reg (p, X86_ECX, X86_EAX, 1);
-                       break;
-               case MONO_TYPE_CHAR:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-                       x86_mov_reg_membase (p, X86_ECX, X86_EBP, RETVAL_POS, 4);
-                       x86_mov_regp_reg (p, X86_ECX, X86_EAX, 2);
-                       break;
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_CLASS:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_SZARRAY:
-               case MONO_TYPE_ARRAY:
-                       x86_mov_reg_membase (p, X86_ECX, X86_EBP, RETVAL_POS, 4);
-                       x86_mov_regp_reg (p, X86_ECX, X86_EAX, 4);
-                       break;
-               case MONO_TYPE_STRING: 
-                       x86_mov_reg_membase (p, X86_ECX, X86_EBP, RETVAL_POS, 4);
-                       x86_mov_regp_reg (p, X86_ECX, X86_EAX, 4);
-                       break;
-               case MONO_TYPE_R4:
-                       x86_mov_reg_membase (p, X86_ECX, X86_EBP, RETVAL_POS, 4);
-                       x86_fst_membase (p, X86_ECX, 0, FALSE, TRUE);
-                       break;
-               case MONO_TYPE_R8:
-                       x86_mov_reg_membase (p, X86_ECX, X86_EBP, RETVAL_POS, 4);
-                       x86_fst_membase (p, X86_ECX, 0, TRUE, TRUE);
-                       break;
-               case MONO_TYPE_I8:
-                       x86_mov_reg_membase (p, X86_ECX, X86_EBP, RETVAL_POS, 4);
-                       x86_mov_regp_reg (p, X86_ECX, X86_EAX, 4);
-                       x86_mov_membase_reg (p, X86_ECX, 4, X86_EDX, 4);
-                       break;
-               case MONO_TYPE_VALUETYPE:
-                       if (sig->ret->data.klass->enumtype) {
-                               simpletype = sig->ret->data.klass->enum_basetype->type;
-                               goto enum_retvalue;
-                       }
-               case MONO_TYPE_VOID:
-                       break;
-               default:
-                       g_error ("Can't handle as return value 0x%x", sig->ret->type);
-               }
-       }
-
-       /*
-        * Standard epilog.
-        */
-       x86_leave (p);
-       x86_ret (p);
-
-       g_assert (p - code_buffer < code_size);
-       res = (MonoPIFunc)g_memdup (code_buffer, p - code_buffer);
-
-       g_hash_table_insert (cache, sig, res);
-
-       return res;
-}
-
-#define MINV_POS  (- sizeof (MonoInvocation))
-#define STACK_POS (MINV_POS - sizeof (stackval) * sig->param_count)
-#define TYPE_OFFSET (G_STRUCT_OFFSET (stackval, type))
-
-/*
- * Returns a pointer to a native function that can be used to
- * call the specified method.
- * The function created will receive the arguments according
- * to the call convention specified in the method.
- * This function works by creating a MonoInvocation structure,
- * filling the fields in and calling ves_exec_method on it.
- * Still need to figure out how to handle the exception stuff
- * across the managed/unmanaged boundary.
- */
-void *
-mono_arch_create_method_pointer (MonoMethod *method)
-{
-       MonoMethodSignature *sig;
-       MonoJitInfo *ji;
-       unsigned char *p, *code_buffer;
-       gint32 local_size;
-       gint32 stackval_pos, arg_pos = 8;
-       int i, size, align, cpos;
-       int *vtbuf;
-
-       sig = method->signature;
-
-       code_buffer = p = alloca (512); /* FIXME: check for overflows... */
-       vtbuf = alloca (sizeof(int)*sig->param_count);
-
-       local_size = sizeof (MonoInvocation) + sizeof (stackval) * (sig->param_count + 1);
-
-       local_size += 7;
-       local_size &= ~7;
-
-       stackval_pos = -local_size;
-
-       cpos = 0;
-       for (i = 0; i < sig->param_count; i++) {
-               MonoType *type = sig->params [i];
-               vtbuf [i] = -1;
-               if (type->type == MONO_TYPE_VALUETYPE) {
-                       MonoClass *klass = type->data.klass;
-                       if (klass->enumtype)
-                               continue;
-                       size = mono_class_native_size (klass, &align);
-                       cpos += align - 1;
-                       cpos &= ~(align - 1);
-                       vtbuf [i] = cpos;
-                       cpos += size;
-               }       
-       }
-
-       cpos += 7;
-       cpos &= ~7;
-
-       local_size += cpos;
-
-       /*
-        * Standard function prolog.
-        */
-       x86_push_reg (p, X86_EBP);
-       x86_mov_reg_reg (p, X86_EBP, X86_ESP, 4);
-       x86_alu_reg_imm (p, X86_SUB, X86_ESP, local_size);
-
-       /*
-        * Initialize MonoInvocation fields, first the ones known now.
-        */
-       x86_mov_reg_imm (p, X86_EAX, 0);
-       x86_mov_membase_reg (p, X86_EBP, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, ex)), X86_EAX, 4);
-       x86_mov_membase_reg (p, X86_EBP, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, ex_handler)), X86_EAX, 4);
-       x86_mov_membase_reg (p, X86_EBP, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, parent)), X86_EAX, 4);
-       /*
-        * Set the method pointer.
-        */
-       x86_mov_membase_imm (p, X86_EBP, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, method)), (int)method, 4);
-
-       if (sig->ret->type == MONO_TYPE_VALUETYPE && !sig->ret->byref && !sig->ret->data.klass->enumtype) 
-               arg_pos += 4;
-
-       /*
-        * Handle this.
-        */
-       if (sig->hasthis) {
-               if (sig->call_convention != MONO_CALL_THISCALL) {
-                       /*
-                        * Grab it from the stack, otherwise it's already in ECX.
-                        */
-                       x86_mov_reg_membase (p, X86_ECX, X86_EBP, arg_pos, 4);
-                       arg_pos += 4;
-               }
-               x86_mov_membase_reg (p, X86_EBP, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, obj)), X86_ECX, 4);
-       }
-       /*
-        * Handle the arguments. stackval_pos is the posset of the stackval array from EBP.
-        * arg_pos is the offset from EBP to the incoming arg on the stack.
-        * We just call stackval_from_data to handle all the (nasty) issues....
-        */
-       x86_lea_membase (p, X86_EAX, X86_EBP, stackval_pos);
-       x86_mov_membase_reg (p, X86_EBP, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, stack_args)), X86_EAX, 4);
-       for (i = 0; i < sig->param_count; ++i) {
-               if (vtbuf [i] >= 0) {
-                       x86_lea_membase (p, X86_EAX, X86_EBP, - local_size + vtbuf [i]);
-                       x86_mov_membase_reg (p, X86_EBP, stackval_pos, X86_EAX, 4);
-               }
-               x86_mov_reg_imm (p, X86_ECX, stackval_from_data);
-               x86_lea_membase (p, X86_EDX, X86_EBP, arg_pos);
-               x86_lea_membase (p, X86_EAX, X86_EBP, stackval_pos);
-               x86_push_imm (p, sig->pinvoke);
-               x86_push_reg (p, X86_EDX);
-               x86_push_reg (p, X86_EAX);
-               x86_push_imm (p, sig->params [i]);
-               x86_call_reg (p, X86_ECX);
-               x86_alu_reg_imm (p, X86_SUB, X86_ESP, 16);
-               stackval_pos += sizeof (stackval);
-               /* fixme: alignment */
-               if (sig->pinvoke)
-                       arg_pos += mono_type_native_stack_size (sig->params [i], &align);
-               else
-                       arg_pos += mono_type_stack_size (sig->params [i], &align);
-       }
-
-       /*
-        * Handle the return value storage area.
-        */
-       x86_lea_membase (p, X86_EAX, X86_EBP, stackval_pos);
-       x86_mov_membase_reg (p, X86_EBP, (MINV_POS + G_STRUCT_OFFSET (MonoInvocation, retval)), X86_EAX, 4);
-       if (sig->ret->type == MONO_TYPE_VALUETYPE && !sig->ret->byref) {
-               MonoClass *klass  = sig->ret->data.klass;
-               if (!klass->enumtype) {
-                       x86_mov_reg_membase (p, X86_ECX, X86_EBP, 8, 4);
-                       x86_mov_membase_reg (p, X86_EBP, stackval_pos, X86_ECX, 4);
-               }
-       }
-
-       /*
-        * Call the method.
-        */
-       x86_lea_membase (p, X86_EAX, X86_EBP, MINV_POS);
-       x86_push_reg (p, X86_EAX);
-       x86_mov_reg_imm (p, X86_EDX, ves_exec_method);
-       x86_call_reg (p, X86_EDX);
-       
-       /*
-        * Move the return value to the proper place.
-        */
-       x86_lea_membase (p, X86_EAX, X86_EBP, stackval_pos);
-       if (sig->ret->byref) {
-               x86_mov_reg_membase (p, X86_EAX, X86_EAX, 0, 4);
-       } else {
-               int simpletype = sig->ret->type;        
-       enum_retvalue:
-               switch (sig->ret->type) {
-               case MONO_TYPE_VOID:
-                       break;
-               case MONO_TYPE_BOOLEAN:
-               case MONO_TYPE_I1:
-               case MONO_TYPE_U1:
-                       x86_mov_reg_membase (p, X86_EAX, X86_EAX, 0, 1);
-                       break;
-               case MONO_TYPE_CHAR:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_U2:
-                       x86_mov_reg_membase (p, X86_EAX, X86_EAX, 0, 2);
-                       break;
-               case MONO_TYPE_I4:
-               case MONO_TYPE_U4:
-               case MONO_TYPE_I:
-               case MONO_TYPE_U:
-               case MONO_TYPE_OBJECT:
-               case MONO_TYPE_STRING:
-               case MONO_TYPE_CLASS:
-                       x86_mov_reg_membase (p, X86_EAX, X86_EAX, 0, 4);
-                       break;
-               case MONO_TYPE_I8:
-                       x86_mov_reg_membase (p, X86_EDX, X86_EAX, 4, 4);
-                       x86_mov_reg_membase (p, X86_EAX, X86_EAX, 0, 4);
-                       break;
-               case MONO_TYPE_R8:
-                       x86_fld_membase (p, X86_EAX, 0, TRUE);
-                       break;
-               case MONO_TYPE_VALUETYPE:
-                       if (sig->ret->data.klass->enumtype) {
-                               simpletype = sig->ret->data.klass->enum_basetype->type;
-                               goto enum_retvalue;
-                       }
-               
-                       x86_push_imm (p, sig->pinvoke);
-                       x86_push_membase (p, X86_EBP, stackval_pos);
-                       x86_push_reg (p, X86_EAX);
-                       x86_push_imm (p, sig->ret);
-                       x86_mov_reg_imm (p, X86_ECX, stackval_to_data);
-                       x86_call_reg (p, X86_ECX);
-                       x86_alu_reg_imm (p, X86_SUB, X86_ESP, 16);
-                       
-                       break;
-               default:
-                       g_error ("Type 0x%x not handled yet in thunk creation", sig->ret->type);
-                       break;
-               }
-       }
-       
-       /*
-        * Standard epilog.
-        */
-       x86_leave (p);
-       x86_ret (p);
-
-       g_assert (p - code_buffer < 512);
-
-       ji = g_new0 (MonoJitInfo, 1);
-       ji->method = method;
-       ji->code_size = p - code_buffer;
-       ji->code_start = g_memdup (code_buffer, p - code_buffer);
-
-       mono_jit_info_table_add (mono_get_root_domain (), ji);
-
-       return ji->code_start;
-}
diff --git a/mono/interpreter/.gitignore b/mono/interpreter/.gitignore
deleted file mode 100644 (file)
index 58fbb5d..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-/Makefile
-/Makefile.in
-/mint
-/*.o
-/.libs
-/.deps
-/interp.lo
-/libmint.la
-/*.lo
-/semantic.cache
-/TAGS
diff --git a/mono/interpreter/ChangeLog b/mono/interpreter/ChangeLog
deleted file mode 100644 (file)
index 80baebf..0000000
+++ /dev/null
@@ -1,1376 +0,0 @@
-2009-11-10  Andrew Jorgensen  <ajorgensen@novell.com>
-
-       * Makefile.am: mint man page should be conditional also
-
-2009-03-20  Zoltan Varga  <vargaz@gmail.com>
-
-       * interp.c: Change location of gc_wrapper.h.
-
-2007-06-04  Mark Probst  <mark.probst@gmail.com>
-
-       * interp.c, interp.h (RuntimeMethod): Due to the jit_code_hash
-       change in MonoDomain this had to be changed slightly, too.
-
-2006-05-09  Miguel de Icaza  <miguel@novell.com>
-
-       * interp.c (ves_exec_method_with_context): Pass a temporary to the
-       mono_load_remote_field routine, instead of passing a NULL.
-
-Thu Aug 4 20:09:40 BST 2005 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: a real zombie is supposed to at least walk.
-       Compilation fix.
-
-2005-03-07  Zoltan Varga  <vargaz@freemail.hu>
-
-       * transform.c (generate): Add CEE_MONO_NOT_TAKEN.
-
-2005-01-31  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * interp.c: fix typo
-
-2005-01-29  Ben Maurer  <bmaurer@ximian.com>
-
-       * *: MonoMethod->signature might be NULL now. You *MUST* use
-       mono_method_signature.
-
-2005-01-20 Bernie Solomon  <bernard@ugsolutions.com>
-
-       * interp.c: mono_init_icall got renamed
-
-2005-01-03  Zoltan Varga  <vargaz@freemail.hu>
-
-       * transform.c (generate): Handle MONO_CLASSCONST.
-
-2004-12-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
-
-       * interp.c: fix the build. Dunno if it's correct.
-
-2004-12-02  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * mintops.def:
-       * transform.c:
-       * interp.c: cope with new thread interruption icall
-
-2004-11-12  Ben Maurer  <bmaurer@ximian.com>
-
-       * transform.c: Fix bug with delegates in interp.
-
-2004-11-10  Lluis Sanchez Gual  <lluis@novell.com>
-
-       * interp.c: Added MonoRemotingTarget parameter to signature
-       interp_create_remoting_trampoline.
-
-Tue Nov 9 17:28:48 CET 2004 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: update to exception clause structure changes.
-
-2004-11-08  Ben Maurer  <bmaurer@ximian.com>
-
-       * interp.c: warning free
-
-2004-10-29  Zoltan Varga  <vargaz@freemail.hu>
-
-       * Makefile.am (libgc_libs): Do some automake magic so libmono/mono
-       depends on libmonogc.
-
-Wed Sep 22 19:06:02 CEST 2004 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: updates for stack walk interface.
-
-2004-09-09  Lluis Sanchez Gual  <lluis@novell.com>
-
-       * interp.c: In interp_walk_stack, don't crash if the context is not set
-         (this may happen if the method is called by unmanaged code).
-
-2004-08-17 Ben Maurer  <bmaurer@users.sourceforge.net>
-
-       * interp.c: thread local alloc
-
-2004-08-05  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * interp.c: (mono_interp_init) use g_thread_supported
-       to stop multiple g_thread_init calls.
-       Also attach domain to thread like mono_jit_init
-
-2004-07-31  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * interp.h: add mono_interp_ftnptr_to_delegate 
-
-       * transform.c (generate): use mono_interp_ftnptr_to_delegate
-       as ical function.
-
-       * interp.c: add mono_interp_ftnptr_to_delegate to create
-       interpreter style delegate. fixes pinvoke3
-
-2004-07-28  Lluis Sanchez Gual  <lluis@novell.com>
-
-       * interp.c: Use mono_init_from_assembly instead of mono_init.
-
-2004-07-27  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * transform.c (mono_interp_transform_method):
-       quick fix to cope with the fake ptr classes
-
-2004-07-26  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * mintops.def: more options on ICALL op code
-
-       * interp.c: cope with exception in ICALL ops, more of them
-
-       * transforms.c: more ICALL opcodes
-
-2004-07-21  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * mintops.def: rename the ICALL op codes to give a better
-       clue about their signature.
-
-       * transform.c (generate): use new ICALL types and add
-       a case for two args + a result
-
-       * interp.c (ves_exec_method_with_context): new ICALL
-       op codes.
-
-2004-07-21  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * mintops.def: add MINT_DUP_VT
-
-       * transform.c (generate): cope with CEE_DUP on value type
-
-       * interp.c (ves_exec_method_with_context): implement MINT_DUP_VT
-       (interp_mono_runtime_invoke): don't unbox this for valuetypes
-       here as it is now done in the callers.
-
-2004-07-09  Ben Maurer  <bmaurer@ximian.com>
-       
-       * interp.c: register gc roots
-
-2004-07-08  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c mintops.def transform.c: Replace CEE_MONO_PROC<x> with
-       CEE_MONO_ICALL.
-
-2004-07-05  Zoltan Varga  <vargaz@freemail.hu>
-
-       * mintops.h: Applied patch from Marcin Krzyzanowski (krzak@pld-linux.org). Add support for unaligned access on little endian machines.
-
-       * interp.c:Applied patch from Marcin Krzyzanowski (krzak@pld-linux.org). Fix crash seen on amd64.
-
-2004-06-24  David Waite  <mass@akuma.org>
-
-       * interp.c:  change to C90-style comments from C99/C++-style
-
-Mon Jun 21 14:06:03 CEST 2004 Paolo Molaro <lupus@ximian.com>
-
-       * interp.h: API updates.
-
-2004-05-21  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * transform.c: ignore new LMF opcodes 
-
-2004-05-20  Lluis Sanchez Gual  <lluis@ximian.com>
-
-       * interp.c, interp.h: Use the new methods for handling thread.abort.
-
-2004-05-04  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c (ves_exec_method_with_context): Disable explicit assignment
-       of 'esi' to the ip variable, since it causes register allocation errors
-       on some versions of gcc. Fixes #58010.
-
-2004-04-29  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * transform.c (generate): missed a couple
-       of places that should use ADD_CODE so buffer
-       gets grown properly.
-
-       * interp.c (interp_mono_runtime_invoke): 
-       restore state better on catching exception
-       via longjmp here
-
-2004-04-29  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * transform.c:
-       * interp.c:
-       Implement STARG for valuetypes as mcs needs it.
-
-2004-04-28  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * transform.c: Make sure ENSURE_I4 is called on
-       32 bit machines too. 
-       (mono_interp_transform_method): allow some stack
-       space for tracing to work.
-
-2004-04-26  David Waite  <mass@akuma.org>
-
-       * interp.h: remove comma from end of enumeration constants
-       declarations
-
-2004-04-21  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * interp.h: put in space for old type field
-       for PPC as tramp.c assumes it. Quick fix until that's fixed.
-
-       * interp.c: reenable instruction tracing for DEBUG_INTERP
-
-2004-04-19  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * Makefile.am:
-       * interp.h:
-       * interp.c: now interprets different VM code
-       * mintops.h:
-       * mintops.def:
-       * mintops.c: definition of new VM code
-       * transform.c: convert CIL to new VM code
-
-2004-04-14  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c (ves_exec_method_with_context): Add support for STRWLPARRAY 
-       marshalling convention.
-
-2004-03-29  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * interp.c interp.h: remove child from MonoInvocation
-       as it isn't used.
-
-2004-03-25  Martin Baulig  <martin@ximian.com>
-
-       * interp.c (stackval_from_data): Added MONO_TYPE_GENERICINST.
-       (stackval_to_data): Added MONO_TYPE_GENERICINST.
-       (calc_offsets): Use mono_class_get_full() and mono_get_method_full().
-       (ves_exec_method_with_context): Likewise.
-
-2004-03-04  Lluis Sanchez Gual <lluis@ximian.com>
-
-       * interp.c: Get the type of transparent proxies from its remote_class.
-
-2004-02-02  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c (ves_exec_method_with_context): Add new marshalling 
-       conventions.
-
-2004-01-22  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c (mono_main): Remove call to mono_verify_corlib (), since
-       the verification code is not up-to-date.
-
-2004-01-19  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * interp.c (ves_exec_method_with_context):
-       get_native_wrapper removed and  call 
-       mono_marshal_get_native_wrapper directly
-       with new DllNotFoundException handling
-
-Mon Jan 19 17:52:33 CET 2004 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: eliminate CSIZE macro.
-
-2004-01-15  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c (ves_array_set): Check for ArrayTypeMismatchException.
-
-2004-01-12  Gonzalo Paniagua Javier <gonzalo@ximian.com>
-
-       * interp.c: call setlocale (). Fixes bug #52100.
-
-2003-12-19  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * embed.h, main.c: new files to enable embedding
-       the interpreter
-
-        * interp.c: make main callable from main.c
-       rearrange main for embedding
-
-       * Makefile.am: changes now most code is in a library
-
-2003-11-21  Lluis Sanchez Gual <lluis@ximian.com>
-
-       * interp.c: Added support for context static fields.
-
-2003-10-31  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c (mono_create_method_pointer): New function which contains
-       the arch independent part of method wrapper creation. Add a cache
-       for the wrapper code, since Delegate::Equals depends on the wrapper
-       address being constant for a method. Fixes #50366.
-
-2003-10-30  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * interp.c: (ves_exec_method_with_context)
-       we need to lookup internal calls now.
-       don't free type in CEE_SIZEOF.
-       fix CEE_NEWOBJ inside wrapper methods
-
-2003-10-24  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c: Update after appdomain changes.
-
-2003-10-13  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * interp.c - set large stack size on HP 64bit
-
-2003-10-02  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * hacks.h - work round HP 64 bit problem with isunordered
-
-2003-10-03  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c (dump_frame): Avoid crash on frames without a method. Patch
-       sam@superduper.net (sam clegg). Fixes #46197.
-       (ves_exec_method_with_context): Fix unbox casting.
-
-2003-09-25  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * interp.c - reinstate use of mono_marshal_get_delegate_invoke
-       for ordering and fix CALLI to handle wrapper. More wrapper handling
-       in CALL and LDSTR. Add another string conversion case.
-
-2003-09-25  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c (ves_exec_method): Fix warning.
-       (ves_exec_method_with_context): Fix CGT_UN and CLT_UN. Patch by
-       David Waite (mass@akuma.org).
-
-2003-9-24  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * interp.c: I broke calling native delegates reinstate
-       old code for the moment.
-
-2003-9-22  Bernie Solomon  <bernard@ugsolutions.com>
-
-       * interp.c: use mono_marshal_get_delegate_invoke to get delegate 
-       invocation order consistent. Fix THROW_EX, fix ip in overflow 
-       exceptions.
-
-Fri Sep 12 10:42:08 CEST 2003 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c, interp.h: patch from Bernie Solomon <bernard@ugsolutions.com>:
-       64 bit/opcodes/exception handling fixes.
-
-2003-08-30  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c: Use mono_field_from_token () in the appropriate places.
-       This simplifies the code and also fixes #48051.
-
-2003-08-27  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c (main): Fix the order of initialization calls so it maches 
-       the order in the JIT.Patch by Bernie Solomon (bernard@ugsolutions.com).
-       Also remove the unused ms mutex.
-       
-       * interp.c: Get rid of metadata_section.
-       
-2003-08-22  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c (main): Call g_thread_init () to make glib thread-safe. 
-       Fixes #47682. Thanks to Laurent Morichetti (l_m@pacbell.net) for 
-       reporting this.
-
-2003-08-18  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c: Get rid of duplicate definition of CHECK_MUL_OVERFLOW.
-       * interp.h interp.c: Get rid of VAL_VALUETA, use VAL_MP instead. Fix
-       the INITOBJ opcode which was the only user of VALUETA.
-
-2003-08-16  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c (ves_exec_method): Implemented mul.ovf correctly for int32
-       and int64. Implement the conv.ovf opcodes for all argument types.
-
-2003-08-15  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c (ves_exec_method): Handle non-valuetypes in CEE_STOBJ.
-       Fixes #46781.
-       (ves_exec_method): Added support for the synchronized flag to the
-       interpreter. Also fixed the CALLI opcode, and made exception handling
-       work though the managed-unmanaged barrier.
-
-Fri Jul 25 19:06:27 CEST 2003 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: updates for new instructions.
-
-2003-07-22  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c: Use the new metadata_section lock instead of metadata_lock.
-       Patch by Bernie Solomon (bernard@ugsolutions.com).
-
-Fri Jul 18 15:11:44 CEST 2003 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: 64 bit fixes from Laurent Morichetti <l_m@pacbell.net>.
-       Install cleanup function.
-
-2003-07-13  Zoltan Varga  <vargaz@freemail.hu>
-
-       * interp.c: Keep alloca()-d data on a free list to prevent stack
-       overflow errors when valuetypes are allocated in a loop. Fixes
-       #27420. Is the new code still faster than using malloc/free ?
-
-       * interp.c (ves_array_get): Add index checking to ves_array_get/set.
-       Fixes decimal-array.exe.
-
-       * interp.c (interp_mono_runtime_invoke): Unbox value type instances
-       before calling the method. Fixes appdomain2.exe.
-
-       * interp.c: Fix warnings.
-       
-       * interp.c: Report unhandled exceptions correctly.
-
-       * interp.c: Implement CEE_ISINST and CEE_CASTCLASS using 
-       mono_object_isinst. Fixes bug #45539 and reflection-enum.exe.
-
-Tue May 27 16:36:41 CEST 2003 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: don't use relative numbering stuff.
-
-Tue May 27 12:18:44 CEST 2003 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: update for mono_class_vtable() changes.
-
-Tue May 13 16:43:18 CEST 2003 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: handle thread static fields.
-
-Sun Apr 27 13:27:59 CEST 2003 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: check for arraytypemismatch.
-
-2003-04-23  Martin Baulig  <martin@ximian.com>
-
-       * interp.c: When running with --dieonex, use the debugging code to
-       print source lines in the backtrace.
-
-2003-02-09  Gonzalo Paniagua Javier <gonzalo@ximian.com>
-
-       * interp.c: added a dummy mono_runtime_install_handlers function to
-       avoid crashing when ves_pinvoke_method tries to call it.
-
-2003-02-06  Piers Haken        <piersh@friskit.com>
-
-       * interp.c: warning cleanups
-
-2002-11-15  Dick Porter  <dick@ximian.com>
-
-       * interp.c: mono_runtime_init() now has an extra parameter for
-       thread attaching.
-
-2002-10-31  Dick Porter  <dick@ximian.com>
-
-       * Makefile.am: The previous automake-1.6 fix broke automake-1.4 on
-       cygwin.  Try again.
-
-2002-09-27  Dick Porter  <dick@ximian.com>
-
-       * interp.c: Tell glib what the program name is, by passing it the
-       name of the managed file we're executing
-
-2002-08-28  Dick Porter  <dick@ximian.com>
-
-       * interp.c: mono_set_rootdir() doesnt take any args now
-
-       * Makefile.am: Export HOST_CC and turn on optimisation for w32 builds
-
-2002-08-28  Nick Drochak  <ndrochak@gol.com>
-
-       * interp.c: check and throw exception if needed for overflow on 
-       multiplication of integer types.
-
-2002-08-07  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (interp_walk_stack): removed the createdelegate icall
-
-2002-08-02  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (get_virtual_method): support proxies
-       (ves_exec_method): impl. LDFLD/STFLD for proxies.
-
-Fri Aug 2 13:00:41 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c, interp.h: implemented exception trap for runtime_invoke
-       and handle exceptions across managed/unmanaged boundaries.
-
-2002-08-01  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (stackval_from_data): add pinvoke argument
-       (stackval_to_data): add pinvoke argument. We need consider the
-       fact that unmanages structures may have different sizes.
-       (ves_pinvoke_method): do not call stackval_from_data if the result
-       is a value type.
-
-Wed Jul 31 17:47:11 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: simplified some more branch code.
-
-Wed Jul 31 16:50:42 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fixed indentation, simplified some code.
-
-Wed Jul 31 14:29:43 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fix so that mint can at least get to executing Main().
-
-2002-07-31  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c: use the new marshaling code. better delegate/remoting 
-       support.
-       (ves_exec_method): bug fix - directly jump to handle_exception.
-
-2002-07-29  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (main): install compile_method handler
-
-Wed Jul 24 13:02:12 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: implemented stack walking function.
-
-Fri Jul 19 14:21:18 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fix float boxing on LE systems.
-
-Sat Jul 13 19:54:56 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: advance ip in conv.r.un.
-
-2002-07-01  Dick Porter  <dick@ximian.com>
-
-       * interp.c (ves_exec): Removed unneeded argument to
-       mono_runtime_run_main()
-
-2002-06-25  Dick Porter  <dick@ximian.com>
-
-       * interp.c (ves_exec): Pass the assembly to mono_runtime_run_main
-
-Wed Jun 19 17:01:37 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: un-broke after stack trace changes.
-
-Fri May 31 16:17:20 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c, hacks.h: compiler compatibility fixes.
-
-Fri May 31 13:25:57 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c, mint.1: added --config command line option.
-
-Thu May 30 14:14:16 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: lookup P/Invoke method addr only when needed.
-
-2002-05-29  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): free type in CEE_SIZEOF
-
-Tue May 28 16:10:49 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fixed SIZEOF to work with typedef/typeref.
-
-Fri May 24 15:33:50 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: added partial async delegate and remoting support.
-
-Thu May 23 18:45:38 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: special case string ctors in invoke.
-       Handle null object in throw. Misc integer type mismatch fixes.
-
-2002-05-23  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_runtime_method): share more code with the jit.
-
-Wed May 22 12:31:40 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fixed finally handling. In trace mode show
-       exception handling operations and the contents of the stack in the same
-       line as the executing instruction.
-
-2002-05-20  Miguel de Icaza  <miguel@ximian.com>
-
-       * interp.c: Updated help display.
-
-2002-05-20  Radek Doulik  <rodo@ximian.com>
-
-       * interp.c (dump_stack): print boxed values for --noptr
-       (ves_exec_method): use stackval_to_data as pointed out by lupus
-
-2002-05-17  Radek Doulik  <rodo@ximian.com>
-
-       * interp.c (dump_stack): if --noptr then print content of strings
-       in form [str:<printed string>]
-
-2002-05-16  Radek Doulik  <rodo@ximian.com>
-
-       * interp.c (ves_exec_method): use data.i instead of data.l in i32
-       case
-       (ves_exec_method): set type in I64 <--> I32 conversions
-
-2002-05-15  Radek Doulik  <rodo@ximian.com>
-
-       * interp.c (ves_runtime_method): moved stackval_from_data call
-       inside #else branch, consulted on irc with lupus
-
-2002-05-15  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): use new mono_unhandled_exception()
-
-2002-05-14  Radek Doulik  <rodo@ximian.com>
-
-       * interp.c: introduced new --noptr option to suppres pointer
-       address printing. I find this useful for comparing trace outputs
-       while porting to ppc
-
-Tue May 14 16:37:55 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: some finally handling fixes and compilation fixes for
-       changes in the runtime lib.
-
-2002-04-30  Dick Porter  <dick@ximian.com>
-
-       * interp.c: Tell glib to not abort when g_log() etc print
-       recursively
-
-Mon Apr 22 16:52:03 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: handle muslticast delegates. Implement a couple more
-       convert opcodes. Pretend we spend some time jitting...
-
-2002-04-20  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): support internalcall String constructors
-
-2002-04-19  Dan Lewis  <dihlewis@yahoo.co.uk>
-       
-       * interp.c: support for new szarray format.
-
-Tue Apr 16 20:12:58 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: removed profiling code (moved to common library).
-       Implemented inlining for some special methods.
-
-2002-04-15     Patrik Torstensson <patrik.torstensson@labs2.com>
-
-       * interp.c: Using fullnames when adding icall's (array)
-
-Wed Apr 10 16:07:23 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: quick implementation for opcodes needed by the new parse
-       routines in corlib.
-
-Tue Apr 9 13:08:26 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: make the interp thread-safe wrt the metadata lib.
-
-Mon Apr 8 17:15:48 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: display return value with --trace.
-       Call mono_runtime_init ().
-
-2002-04-06  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (interp_mono_runtime_invoke): handle more types,
-       removed runtime_exec_main
-
-Thu Apr 4 11:36:52 CEST 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: don't try to get an IL opcode for runtime and internal
-       call methods.
-
-Thu Mar 28 16:54:51 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: spring warning cleanup.
-
-Thu Mar 28 12:03:28 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: check obj address in stfld.
-
-2002-03-27  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): CASTCLASS: fix for transparent proxy
-
-Tue Mar 26 20:09:10 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: set frame->ip before dumping the stack trace.
-
-Tue Mar 26 19:54:45 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: remove glib mem vtable code.
-
-2002-03-26  Dick Porter  <dick@ximian.com>
-
-       * interp.c: Show thread ID's in trace output.
-               
-       New option "--traceclassinit" to put debug output around
-       runtime_class_init().
-
-       Make sure all options are displayed in usage().
-
-Tue Mar 26 17:03:14 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: support fieldrefs when accessing instance fields.
-
-Mon Mar 25 12:59:52 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: allow tracing to be done on a per-method basis.
-       Fix interp_mono_runtime_invoke() to deal correcttly with the return
-       value. Disable glib mem vtable setting.
-
-Thu Mar 21 18:08:37 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: set stack trace info when throwing an exception.
-
-Thu Mar 21 17:32:46 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: intern strings before executing a method (and don't 
-       intern command line arguments anymore). Add sanity checks in alloca
-       use.
-
-Sat Mar 16 19:15:18 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: restore frame on return from unmanaged calls.
-       Add support for continuing execution up to x IL insn.
-       Fix exception handling when an exception is raised in the catch
-       handler of the same method that issued the first one.
-
-2002-03-11  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_runtime_method): set method_info field
-
-Mon Mar 11 14:48:07 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: corlib consistency checls moved to libmetadata.
-
-Mon Mar 11 11:27:27 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: use the new facilities in debug-helpers to
-       disassemble CIL code and match method names to MonoMethods.
-
-Thu Mar 7 17:20:59 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: Boehm-GC enable. Fix some overflow opcodes.
-
-Tue Mar 5 18:12:40 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fix non-debug build and some more opcode work.
-
-Mon Mar 4 11:21:44 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: print the address of 'this' in tracing mode.
-
-Thu Feb 28 19:18:59 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: add checks for more binary consistency.
-
-2002-02-27  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (interp_mono_runtime_invoke): use alloca instead of g_new0
-
-Tue Feb 26 11:43:34 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: added profiling for object creation.
-
-Mon Feb 25 17:37:07 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: use correct value for guint64 max.
-
-2002-02-22  Radek Doulik  <rodo@ximian.com>
-
-       * interp.c: s/gulong/guint64 as it differs on ppc
-
-Wed Feb 20 22:18:40 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: more complete runtime_invoke () implementation.
-       Fixed castclass/isinst to work correctly with arrays.
-
-Tue Feb 19 20:21:14 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: implement the runtime_invoke function.
-
-Mon Feb 18 15:49:20 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fix alignment code. Make sure to init classes
-       in more cases. Command-line arguments are interned.
-
-2002-02-16  Radek Doulik  <rodo@ximian.com>
-
-       * interp.c (ves_exec_method): test type of sp [-1] instead of sp
-       [0], because sp [-1] is the value going to be shifted, fixed in
-       CEE_SHL, CEE_SHR, CEE_UN opcodes)
-
-Sat Feb 16 12:00:24 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fixed cut&paste error for ldind.r4 and ldind.r8.
-
-Fri Feb 15 15:07:27 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: use strrchr instead of rindex. use _isnan and _finite on
-       win32 systems.
-
-2002-02-14  Jeffrey Stedfast  <fejj@ximian.com>
-
-       * interp.c (ves_exec_method): replace 
-       'g_assert (sp->type = VAL_VALUETA)' with 
-       'g_assert (sp->type == VAL_VALUETA)' otherwise
-       the assert always passes. FIXME: should the test have been !=?
-
-2002-02-14  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (stackval_from_data): fix for MONO_TYPE_PTR
-
-Wed Feb 13 16:17:38 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fixed newobj implementation for valuetypes bug found by
-       dietmar. sub.ovf dummy code.
-
-Tue Feb 12 14:08:47 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * hacks.h: check against redefining preprocessor symbol.
-       * interp.c: fix profile info to return more sensible results.
-
-Mon Feb 11 13:05:29 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: added "die on exception" command line argument.
-       When we segfault, set the message in the exception to "Segmentation
-       fault" so people can recognise what's going on.
-
-2002-02-10  Miguel de Icaza  <miguel@ximian.com>
-
-       * interp.c (ves_exec_method): Compare the element_class type token
-       in the class we got as well, instead of the element class vs the
-       toplevel class.
-
-       This fixes the invalid cast exceptions during unboxing
-
-Fri Feb 8 13:01:03 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: use opcode information from libmetadata.
-
-2002-02-05  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): CEE_UNBOX: use element_class for
-       type check.
-
-2002-02-04  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (main): impl. __array_Address icall
-
-Fri Feb 1 16:03:53 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: exception fixes. Use mono_method_pointer_get ()
-       to easy porting to other archs. Some support for overflow detection.
-
-2002-01-25  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c, jit.c (main): install runtime_exec_main handler
-       (main): bug fix - call TlsAlloc () before we execute code
-
-2002-01-23  Dick Porter  <dick@ximian.com>
-
-       * interp.c: Added some kludges to cope with CONV_OVF_I2,
-       CONV_OVF_I4 and ADD_OVF so that number formatting works.  Also
-       initialise and cleanup the network support.
-
-Thu Jan 10 20:59:59 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c, interp.h: add a flag to mono_create_trampoline ()
-       to handle runtime methods.
-
-Sat Jan 5 15:45:14 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: allow classname:method name in --debug argument.
-       Fix box opcode for valuetypes. Fix a few opcode to take a 16 bit
-       index instead of 32 (stloc, ldloc, starg, etc.).
-
-Thu Jan 3 23:19:27 CET 2002 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: temporary mul.ovf, mul.ovf.un, add.ovf.un implementations
-       to get the compiler going.
-
-Mon Dec 24 17:23:45 CET 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fix ldc.i8.
-
-Thu Dec 20 20:09:48 CET 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fix delegate method invocation to handle both
-       static and instance methods.
-
-Tue Dec 18 18:48:50 CET 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: make segv_handler static, handle runtime methods in stack
-       trace.
-
-Thu Dec 13 20:24:28 CET 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: correctly handle exceptions generated in C code.
-       Install an handler for SIGSEGV. Bare-bones profiler and hook for the
-       verifier.
-
-Mon Dec 3 17:15:44 CET 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: call mono_init() after registering internal calls.
-
-2001-11-30  Dick Porter  <dick@ximian.com>
-
-       * interp.c: Replace get_named_exception() with
-       mono_exception_from_name()
-
-Fri Nov 30 12:05:21 CET 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: calculate locals and args offsets only once
-       per method call. Cache trampoline code as well.
-
-2001-11-23  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): bug fix for exception5.cs
-
-Mon Nov 19 11:33:00 CET 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: start adding support for handling exceptions across
-       managed/unmanaged boundaries. Cleanup Delegate method invocation.
-       Pass the correct target object in Delegate::Invoke and use the correct
-       'this' pointer in ldvirtftn (bugs pointed out by Dietmar).
-
-Thu Nov 15 17:40:24 CET 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: handle enums with underlying type different from int32.
-       More checks for C structs <-> C# objects consistency.
-
-Wed Nov 14 19:23:00 CET 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: move the stack frame dumping code to a function so it can
-       be called from the debugger. Fix virtual method lookup for interfaces.
-       Throw exceptions instead of aborting in more places.
-       Print also the message in an exception. Updates for field renames in
-       corlib.
-
-2001-11-09  Dick Porter  <dick@ximian.com>
-
-       * Makefile.am (mint_LDADD): Don't need THREAD_LIBS any more
-
-2001-11-07  Miguel de Icaza  <miguel@ximian.com>
-
-       * interp.c: Include stdlib to kill warning.
-       (check_corlib): Adjust format encodings to remove warnings.
-
-Wed Nov 7 15:47:36 CET 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: updates for changes in array code.
-
-Fri Nov 2 19:06:54 CET 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: hanlde field refs. Throw an exception on NULL references.
-       Check consistency of corlib types with the C struct representation.
-
-2001-10-25  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): use relative numbering for runtime
-       type checks (and make it work with interfaces)
-
-2001-10-15  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c: removed newobj()
-
-2001-10-10  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (get_virtual_method): use the vtable
-       (arch_compile_method): added to compute vtable entry
-
-Mon Oct 8 16:14:40 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: use the accessors provided in object.h to deal with
-       MonoArrays. Updates for API renames in metadata. Throw exception
-       in ldelema if index is out of bounds.
-
-Mon Oct 8 10:44:25 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fixes for changes in metadata.
-
-2001-10-04  Dick Porter  <dick@ximian.com>
-
-       * interp.c (ves_runtime_method): init_class() the
-       mono_defaults.delegate_class
-       Include mono-endian.h not endian.h
-
-Tue Oct 2 18:51:25 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: set frame->ip in the leave opcode. Make db_methods static.
-
-Sun Sep 30 11:57:15 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: compiler and ANSI C portability fixes.
-
-Fri Sep 28 19:37:46 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: Implemented ldtoken, conv.ovf.i. Use MonoClass->byval_arg
-       (and remove related kludges). Don't choke on access to arrays of
-       references. Throw an exception when an internalcall or P/Invoke
-       function don't have an implementation. Throw and EngineException
-       for unimplemented opcodes.
-
-Tue Sep 25 11:12:35 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fixed get_virtual_method () to deal with interface
-       methods better.
-
-Mon Sep 24 18:50:25 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: catch a few more error conditions with exceptions instead of
-       erroring out.
-       Don't use g_print() in stack traces because it doesn't work with
-       some float values.
-       When we call an instance method of a valuetype class, unbox the 'this'
-       argument if it is an object.
-       Use mono_ldstr () to implement the ldstr opcode: it takes care of
-       interning the string if necessary.
-       Implemented new opcodes: ckfinite, cgt.un, clt.un, ldvirtftn, ldarga.
-       Fixes to handle NaNs when comparing doubles.
-       Make sure the loaded assembly has an entry point defined.
-       Fixed portability bugs in neg and not opcodes.
-
-2001-09-24  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): LDC_I4: 8bit constants are signed
-       (ves_exec_method): bug fix for NOT/NEG
-       (main): fix bug in parameter parsing
-
-2001-09-23  Dick Porter  <dick@ximian.com>
-
-       * Makefile.am (mint_LDADD): rename PTHREAD_LIBS to THREAD_LIBS
-
-2001-09-23  Dick Porter  <dick@ximian.com>
-
-       * interp.c (main): Do some thread setup and cleanup around the
-       call to ves_exec()
-
-2001-09-21  Dick Porter  <dick@ximian.com>
-
-       * Makefile.am (mint_LDADD): Added PTHREAD_LIBS to the link line
-
-Thu Sep 20 16:32:42 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: implemented some more opcodes: calli, rem.un,
-       shr.un, conv.u, cpobj, stobj, conv.r.un, conv.ovf.i1.un,
-       conv.ovf.i2.un, conv.ovf.i4.un, conv.ovf.i8.un, conv.ovf.i.un,
-       conv.ovf.u1.un, conv.ovf.u2.un, conv.ovf.u4.un, conv.ovf.u8.un,
-       conv.ovf.u.un.
-       Fix some 64 bit issues in the array element access code and a small bug.
-       Throw an exception on index out of range instead of asserting.
-       Throw an exception on a NULL array instead of dying.
-       Stomped a memory corruption bug (.cctor methods were freed after
-       executing them, but they are stores in MonoClass now...).
-       Added a simple facility to invoke the debugger when a named
-       function is entered (use the cmdline option --debug method_name).
-       * interp.h: fix 64 bit issue.
-
-Tue Sep 18 13:21:33 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fix some 64 bit issues. Safer support for delegates.
-
-2001-09-12  Miguel de Icaza  <miguel@ximian.com>
-
-       * interp.c (ves_exec_method): implement conv.u8 opcode. 
-
-Mon Sep 10 20:20:36 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: endian fixes, comments.
-
-Fri Sep 7 18:45:38 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c, interp.h: make ves_exec_method () and stackval_from_data ()
-       non static. Implement a couple of runtime methods needed to
-       use delegates (ves_runtime_method ()).
-       Implemented ldftn opcode.
-
-Thu Sep 6 15:41:24 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * Makefile.am: link to libmonoarch.
-       * interp.h, interp.c: use mono_create_trampoline ().
-       Pass the command line arguments to Main (String[]) methods.
-
-2001-08-30  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_pinvoke_method): removed the libffi dependency
-
-2001-08-29  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_array_set): moved from icall.c
-       (ves_array_get): moved from icall.c
-
-       * icall.c: moved to metadata/icall.c
-
-Wed Aug 29 12:46:06 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: some small optimizations. Fixes to do signed
-       compares when needed. Change C++ comments into C.
-       Implemented cgt, clt. Added --opcode-count cmdline switch.
-
-2001-08-28  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): better check for value types (get
-       the class to detect if we have a value type), implemented CEE_CONV_U1,
-       CEE_CONV_U2, CEE_CEQ
-       
-
-Mon Aug 27 21:30:30 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: warn and exit when Main () expects the cmdline arguments
-       instead of creashing.
-
-Mon Aug 27 20:16:37 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: merge isinst/castclass handling. Hopefully implement
-       the right semantics for handling callvirt correctly (changes
-       here and there to support it). Integrate bugfix from Dietmar quickly
-       so he needs to handle the cvs conflict:-)
-
-Mon Aug 27 12:20:32 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fix compilation and updates for changes in metadata/.
-
-2001-08-26  Miguel de Icaza  <miguel@ximian.com>
-
-       * interp.c (main): Add option handling for the interpreter,
-       support the `--trace' option.
-
-Sun Aug 26 23:04:46 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: get in a dummy virtual method dispatch.
-       Added support for int64, native int and native uint as arguments.
-       Added debug enter/leave for icall and pinvoke methods, too.
-       Implement opcodes conv.i, conv.i8, ldelema.
-
-Sun Aug 26 11:37:30 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.h, interp.c: load also a MonoClass pointer when we load
-       an address on the stack. Implemented conv.i1, conv.i2, con.i4,
-       conv.u4, conv.r4, conv.r8. Print the arguments in the stack trace
-       and the name of the exception.
-
-Sat Aug 25 15:56:03 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: Implemented some opcodes: starg.s, ldobj, isinst,
-       ldarg, starg, ldloc, ldloca, stloc, initobj, cpblk, sizeof.
-
-Sat Aug 25 12:57:36 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: handle enumerations specially (not as valuetypes).
-
-Fri Aug 24 19:34:04 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.h, interp.c: add support for valuetypes.
-
-Fri Aug 24 16:09:20 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: updates for merge of MonoParam in MonoType.
-
-Thu Aug 23 12:04:34 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: removed beforefieldinit check, it's a useless flag.
-       Added a couple more test cases to tests/ dir.
-
-2001-08-22  Miguel de Icaza  <miguel@ximian.com>
-
-       * interp.c (usage): Add version information
-       (ves_pinvoke_method): Typo fix.
-
-Wed Aug 22 20:37:51 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: simplified init_class (). Make sure a class
-       is fully initialized before executing a method in the class.
-       Search for the class constructor only on beforefieldinit classes.
-       Implement a bunch of opcodes: br, brfalse, brtrue, beq, bge,
-       bgt, blt, ble, bne.un, bge.un, bgt.un, ble.un, blt.un, stind.i,
-       ldflda, ldsflda, ldelem.i8, stelem.i8, leave.
-
-Wed Aug 22 16:34:03 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: Updates for changes in metadata/. Better output in debug mode
-       and in the stack trace. Completed rethrow handling
-
-Tue Aug 21 18:56:19 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: new macro INIT_FRAME() to properly
-       initialize a MonoInvocation. Fixed a couple of buglets in exception code:
-       increase stack pointer when pushing the exception for catch blocks,
-       initialize frame->ex_handler to NULL, correctly try all the
-       catch blocks (don't incorrectly fallback on filter handling).
-       Added a couple more checks where we may need to throw an
-       exception. Added more exception creation functions.
-       Changed stackval_from_data() to take the target stackval as
-       argument. Implemented a couple more opcodes.
-       * interp.h: prepare stackval for value type code.
-
-2001-08-21  Miguel de Icaza  <miguel@ximian.com>
-
-       * Makefile.am (mint_LDADD): Renamed interpreter to mint.
-
-2001-08-21  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (get_named_exception): use the right constructor.
-
-Mon Aug 20 18:58:36 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fix buglet with the leave.s opcode.
-
-2001-08-20  Dietmar Maurer  <dietmar@ximian.com>
-
-       * icall.c: changed everything to support the new calling convention
-
-       * hacks.h: added some macros for FreeBSD 
-
-       * interp.c (get_named_exception): use mono_object_new instead of
-       newobj, initialize the stack before we call the constructor.
-
-Sat Aug 18 12:43:38 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c, interp.h: added support code to create exceptions.
-       Changed interncal calling convnetion over to MonoInvocation, to support
-       exceptions, walking the stack back and forward and passing the 'this'
-       pointer separately (remove the cludges required before to pass this on the
-       stack). Use alloca heavily for both local vars and a copy of the incoming 
-       arguments. Init local vars to zero.
-       Simplify stackval_from_data() and stackval_to_data() to only take a pointer
-       instead of pointer + offset.
-       Implement a few exceptions-related opcodes and the code to run finally, fault and
-       catch blocks as well as a stack trace if no handler is found.
-       
-2001-08-16  Alex Graveley  <alex@ximian.com>
-
-       * Makefile.am (mono_int_LDADD): Link with ../../libffi/libffi.a
-       instead of ../../libffi/.libs/libffi.a.
-
-2001-08-10  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): impl CASTCLASS
-
-       * icall.c: moved the internal call stuff to this file
-
-       * interp.c (ves_exec_method): impl. BOX/UNBOX
-       (ves_icall_System_Array_GetValue): impl.
-       (ves_icall_System_Array_SetValue): impl.
-       added myself to Authors
-
-2001-08-09  Dietmar Maurer  <dietmar@ximian.com>
-
-       * implemented arrays, but you will need a modified version of 
-       Array.cs to get arrays working (will commit soon)
-       
-       * interp.c (ves_icall_array_Set): impl.
-       (ves_icall_array_Get): impl.
-       (ves_icall_array_ctor): impl.
-       (ves_icall_System_Array_GetRank): impl.
-       (ves_icall_System_Array_GetLength): impl.
-       (ves_icall_System_Array_GetLowerBound): impl.
-       (mono_lookup_internal_call): impl.
-
-2001-08-06  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): impl. NEWARR
-       (ves_exec_method): impl. most LDELEM/STELEM opcodes, LDLEN
-       (newarr): impl.
-       (mono_get_ansi_string): impl.
-       (mono_lookup_internal_call): impl.
-       (ves_exec_method): implemented internal calls
-
-2001-08-05  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_pinvoke_method): removed all static vars.
-
-2001-08-02  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): found a way to do unordered
-       compares, implemented CEE_BNE_UN_S, CEE_BGE_UN_S, CEE_BGT_UN_S, 
-       CEE_BLE_UN_S, CEE_BLT_UN_S
-       
-Wed Aug 1 22:51:38 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: handle also MONO_TYPE_CLASS to/from the stack.
-       Change locals to be a memory blob, instead of the structured
-       (but wrong) stackval. Implement bne.un.s opcode. Make the program
-       exit with the error code from Main().
-
-2001-08-01  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_exec_method): implemented LDSTR
-
-2001-07-31  Miguel de Icaza  <miguel@ximian.com>
-
-       * interp.c (GET_NATI): Switched from using nati_t to cli/types.h
-       m_i type.  Maybe we should rename the types to be m_i_t instead of
-       m_i alone.
-       
-       Make the code compile after I broke it.
-
-Tue Jul 31 23:46:33 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: fix cleanup.
-       * Makefile.am: don't link with disassembler library.
-
-2001-07-31  Miguel de Icaza  <miguel@ximian.com>
-
-       (ves_exec_method): Cleanup of the source code.
-
-Tue Jul 31 20:13:59 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: implement stind.*, ldind.*, ldloca.s opcodes.
-       Provide better tracing with DEBUG_INTERP.
-
-Tue Jul 31 17:52:53 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: massive namespace cleanup.
-
-Mon Jul 30 20:09:58 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: update to use mono_method->name.
-
-Fri Jul 27 20:54:00 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: start implementing callvirt. Classes with
-       class constructors are properly initialized when needed.
-       Fix error introduced in version 1.17.
-
-Fri Jul 27 14:03:19 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: implement static field loading and storing.
-
-2001-07-27  Dietmar Maurer  <dietmar@ximian.com>
-
-       * interp.c (ves_pinvoke_method): impl.
-
-Fri Jul 27 11:49:19 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: Removed some debugging printouts. Made stackval_to_data
-       static. Handle also instance methods in CALL opcode. Fix ret to properly
-       deal with void functions. Fixed constructor to leave the object on
-       the stack.
-
-Thu Jul 26 13:24:51 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c: ves_exec_method () doesn't take a MonoImage arg
-       anymore. Use the method cache in MonoImage. Updates to
-       mache recent changes in metadata. 
-       Fix newobj code to use new metadata features. Call the class
-       constructor after allocationg the object. Implemented load field
-       and store field opcodes (the support functions need to be finished).
-       
-Tue Jul 24 16:51:09 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * interp.c, hacks.h: moved a few ugly macros out of the code.
-       Implemented switch opcode.
-
-2001-07-23  Miguel de Icaza  <miguel@ximian.com>
-
-       * interp.c (newobj): Added function to handle newobj opcode.
-
-2001-07-18  Miguel de Icaza  <miguel@ximian.com>
-
-       * interp.c (ves_exec_method): Make the interpreter abort with more
-       information than it currently does.
-
-       Enable the slow processor, as it is easier to debug.
-
-Sun Jul 15 17:50:23 CEST 2001 Paolo Molaro <lupus@ximian.com>
-
-       * Started changelog.
-       * interp.c: use new mono_get_method () function to get the complete
-       info on a method invocation: we support now method invocation with
-       multiple (or zero) simple arguments and with or without a return value.
-       Implement also a couple more opcodes.
diff --git a/mono/interpreter/Makefile.am b/mono/interpreter/Makefile.am
deleted file mode 100644 (file)
index 4cea044..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-AM_CPPFLAGS =                          \
-       -I$(top_srcdir)                 \
-       $(LIBGC_CPPFLAGS)               \
-       $(GLIB_CFLAGS)
-
-if HOST_WIN32
-export HOST_CC
-# The mingw math.h has "extern inline" functions that dont appear in libs, so
-# optimisation is required to actually inline them
-AM_CFLAGS = -O
-endif
-
-if INTERP_SUPPORTED
-bin_PROGRAMS = mint
-
-lib_LTLIBRARIES = libmint.la
-
-man_MANS = mint.1
-endif
-
-mint_SOURCES =         \
-       main.c
-
-mint_LDADD =           \
-       libmint.la
-
-libmint_la_SOURCES =   \
-       hacks.h         \
-       interp.h        \
-       interp.c        \
-       mintops.h       \
-       mintops.def     \
-       mintops.c       \
-       transform.c
-
-libmintincludedir = $(includedir)/mono-$(API_VER)/mono/interpreter
-
-libmintinclude_HEADERS =       \
-       embed.h
-
-# This is needed for automake dependency generation
-if INCLUDED_LIBGC
-libgc_libs=../../libgc/libmonogc.la
-else
-libgc_libs=$(LIBGC_LIBS)
-endif
-
-libmint_la_LIBADD =                            \
-       ../arch/libmonoarch.la          \
-       ../metadata/libmonoruntime.la   \
-       ../io-layer/libwapi.la          \
-       ../utils/libmonoutils.la        \
-       $(libgc_libs)                   \
-       $(GLIB_LIBS)                    \
-       $(LIBICONV)                     \
-       $(ICU_LIBS)                     \
-       -lm
-
-EXTRA_DIST = $(man_MANS)
diff --git a/mono/interpreter/embed.h b/mono/interpreter/embed.h
deleted file mode 100644 (file)
index b3a5449..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-#include <mono/metadata/object.h>
-#include <mono/metadata/appdomain.h>
-
-int
-mono_main (int argc, char* argv[]);
-
-MonoDomain *
-mono_interp_init(const char *file);
-
-int
-mono_interp_exec(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]);
-
-void        
-mono_interp_cleanup(MonoDomain *domain);
-
diff --git a/mono/interpreter/hacks.h b/mono/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/interpreter/interp.c b/mono/interpreter/interp.c
deleted file mode 100644 (file)
index 4525ff6..0000000
+++ /dev/null
@@ -1,4515 +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/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 <mono/os/util.h>
-
-#include "interp.h"
-#include "mintops.h"
-#include "embed.h"
-#include "hacks.h"
-
-#define OPDEF(a,b,c,d,e,f,g,h,i,j) \
-       a = i,
-
-enum {
-#include "mono/cil/opcode.def"
-       CEE_LASTOP
-};
-#undef OPDEF
-
-/* 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
-
-static gint *abort_requested;
-
-/* If true, then we output the opcodes as we interpret them */
-static int global_tracing = 0;
-static int global_no_pointers = 0;
-
-int mono_interp_traceopt = 0;
-
-static int debug_indent_level = 0;
-
-#define INIT_FRAME(frame,parent_frame,obj_this,method_args,method_retval,mono_method)  \
-       do {    \
-               (frame)->parent = (parent_frame);       \
-               (frame)->obj = (obj_this);      \
-               (frame)->stack_args = (method_args);    \
-               (frame)->retval = (method_retval);      \
-               (frame)->runtime_method = mono_interp_get_runtime_method (mono_method); \
-               (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 guint32 thread_context_id = 0;
-
-#define DEBUG_INTERP 1
-#define COUNT_OPS 0
-#if DEBUG_INTERP
-
-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;
-}
-
-#define DEBUG_ENTER()  \
-       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 ("(%u) Entering %s (", GetCurrentThreadId(), 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 ("(%u) Leaving %s", GetCurrentThreadId(),  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
-
-#define DEBUG_ENTER()
-#define DEBUG_LEAVE()
-
-#endif
-
-static void
-interp_ex_handler (MonoException *ex) {
-       ThreadContext *context = TlsGetValue (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 (ex->stack_trace);
-               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 (ex->message);
-                       fprintf(stderr, ": %s", m);
-                       g_free(m);
-               }
-               fprintf(stderr, "\n");
-               fprintf(stderr, "%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 (ex->message);
-                               fprintf(stderr, ": %s", m);
-                               g_free(m);
-                       }
-                       strace = mono_string_to_utf8 (ex->stack_trace);
-                       fprintf(stderr, "\n");
-                       fprintf(stderr, "%s\n", strace);
-                       g_free (strace);
-               }
-               /* wait for other threads to also collapse */
-               Sleep(1000);
-               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)
-{
-       fprintf (stderr, "Execution aborted in method: %s::%s\n", mh->klass->name, mh->name);
-       fprintf (stderr, "Line=%d IP=0x%04x, Aborted execution\n", line,
-                ip-(const unsigned short *)mono_method_get_header (mh)->code);
-       g_print ("0x%04x %02x\n",
-                ip-(const unsigned short *)mono_method_get_header (mh)->code, *ip);
-       if (sp > stack)
-               printf ("\t[%d] 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 gpointer
-interp_create_remoting_trampoline (MonoMethod *method, MonoRemotingTarget target)
-{
-       return mono_interp_get_runtime_method (mono_marshal_get_remoting_invoke_for_target (method, target));
-}
-
-static mono_mutex_t runtime_method_lookup_section;
-
-RuntimeMethod*
-mono_interp_get_runtime_method (MonoMethod *method)
-{
-       MonoDomain *domain = mono_domain_get ();
-       RuntimeMethod *rtm;
-
-       mono_mutex_lock (&runtime_method_lookup_section);
-       if ((rtm = mono_internal_hash_table_lookup (&domain->jit_code_hash, method))) {
-               mono_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_mutex_unlock (&runtime_method_lookup_section);
-
-       return rtm;
-}
-
-static gpointer
-interp_create_trampoline (MonoMethod *method)
-{
-       if (method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
-               method = mono_marshal_get_synchronized_wrapper (method);
-       return mono_interp_get_runtime_method (method);
-}
-
-static inline RuntimeMethod*
-get_virtual_method (RuntimeMethod *runtime_method, MonoObject *obj)
-{
-       MonoMethod *m = runtime_method->method;
-
-       if ((m->flags & METHOD_ATTRIBUTE_FINAL) || !(m->flags & METHOD_ATTRIBUTE_VIRTUAL)) {
-               if (obj->vtable->klass == mono_defaults.transparent_proxy_class) 
-                       return mono_interp_get_runtime_method (mono_marshal_get_remoting_invoke (m));
-               else if (m->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
-                       return mono_interp_get_runtime_method (mono_marshal_get_synchronized_wrapper (m));
-               else
-                       return runtime_method;
-       }
-
-       if (m->klass->flags & TYPE_ATTRIBUTE_INTERFACE) {
-               return ((RuntimeMethod **)obj->vtable->interface_offsets [m->klass->interface_id]) [m->slot];
-       } else {
-               return ((RuntimeMethod **)obj->vtable->vtable) [m->slot];
-       }
-}
-
-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 (type->data.klass->enum_basetype, result, data, pinvoke);
-                       return;
-               } else {
-                       int size;
-                       
-                       if (pinvoke)
-                               size = mono_class_native_size (type->data.klass, NULL);
-                       else
-                               size = mono_class_value_size (type->data.klass, NULL);
-                       memcpy (result->data.vt, data, size);
-               }
-               return;
-       default:
-               g_warning ("got type 0x%02x", type->type);
-               g_assert_not_reached ();
-       }
-}
-
-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 (type->data.klass->enum_basetype, val, data, pinvoke);
-                       return;
-               } else {
-                       int size;
-
-                       if (pinvoke)
-                               size = mono_class_native_size (type->data.klass, NULL);
-                       else
-                               size = mono_class_value_size (type->data.klass, NULL);
-
-                       memcpy (data, val->data.p, size);
-               }
-               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)
-{
-       guint32 *lengths;
-       guint32 *lower_bounds;
-       int i;
-
-       lengths = alloca (sizeof (guint32) * 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 = lengths;
-               lengths += klass->rank;
-       }
-       return (MonoObject*)mono_array_new_full (domain, klass, lengths, lower_bounds);
-}
-
-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->obj;
-       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 0 /* FIX */
-       if (sp [ac->rank].data.p && !mono_object_isinst (sp [ac->rank].data.p, mono_object_class (o)->element_class)) {
-               frame->ex = mono_get_exception_array_type_mismatch ();
-               FILL_IN_TRACE (frame->ex, frame);
-               return;
-       }
-#endif
-
-       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->obj;
-       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->obj;
-       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 = TlsGetValue (thread_context_id);
-       MonoInvocation *frame;
-       int il_offset;
-       MonoMethodHeader *hd;
-
-       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 (method);
-                       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 void 
-ves_pinvoke_method (MonoInvocation *frame, MonoMethodSignature *sig, MonoFunc addr, gboolean string_ctor, ThreadContext *context)
-{
-       jmp_buf env;
-       MonoPIFunc func;
-       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;
-
-       if (frame->runtime_method) {
-               func = frame->runtime_method->func;
-       } else {
-               func = mono_arch_create_trampoline (sig, string_ctor);
-       }
-
-       context->current_frame = frame;
-       context->managed_code = 0;
-
-       func (addr, &frame->retval->data.p, frame->obj, frame->stack_args);
-
-       context->managed_code = 1;
-       /* domain can only be changed by native code */
-       context->domain = mono_domain_get ();
-
-       if (*abort_requested)
-               mono_thread_interruption_checkpoint ();
-       
-       if (string_ctor) {
-               stackval_from_data (&mono_defaults.string_class->byval_arg, 
-                                   frame->retval, (char*)&frame->retval->data.p, sig->pinvoke);
-       } else 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;
-}
-
-static void
-interp_delegate_ctor (MonoDomain *domain, MonoObject *this, MonoObject *target, RuntimeMethod *runtime_method)
-{
-       MonoDelegate *delegate = (MonoDelegate *)this;
-
-       delegate->method_info = mono_method_get_object (domain, runtime_method->method, NULL);
-       delegate->target = target;
-
-       if (target && target->vtable->klass == mono_defaults.transparent_proxy_class) {
-               MonoMethod *method = mono_marshal_get_remoting_invoke (runtime_method->method);
-               delegate->method_ptr = mono_interp_get_runtime_method (method);
-       } 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 ();
-
-       d = (MonoDelegate*)mono_object_new (domain, klass);
-
-       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 (ji->method));
-
-       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->obj;
-
-       mono_class_init (method->klass);
-       
-       if (obj && mono_object_isinst (obj, mono_defaults.multicastdelegate_class)) {
-               if (*name == '.' && (strcmp (name, ".ctor") == 0)) {
-                       interp_delegate_ctor (context->domain, obj, frame->stack_args[0].data.p, frame->stack_args[1].data.p);
-                       return;
-               }
-       }
-
-       if (obj && mono_object_isinst (obj, mono_defaults.array_class)) {
-               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, "[%lld/0x%0llx] ", 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:
-               g_string_append_printf (str, "[%lld/0x%0llx] ", s->data.l, s->data.l);
-               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)
-               return g_string_free (str, FALSE);
-
-       if (signature->hasthis)
-               g_string_append_printf (str, "%p ", inv->obj);
-
-       for (i = 0; i < signature->param_count; ++i)
-               dump_stackval (str, inv->stack_args + 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;
-       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 (method);
-
-                               if (hd != NULL) {
-                                       if (inv->ip) {
-                                               opname = mono_interp_opname [*inv->ip];
-                                               codep = inv->ip - inv->runtime_method->code;
-                                       } else 
-                                               opname = "";
-       
-                                       source = mono_debug_source_location_from_il_offset (method, codep, NULL);
-                               }
-                       }
-                       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;
-
-       for (i = 0, inv = top; inv; inv = inv->parent)
-               if (inv->runtime_method != NULL)
-                       ++i;
-
-       res = mono_array_new (domain, mono_defaults.int_class, 2 * i);
-
-       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
-
-static MonoObject*
-interp_mono_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc)
-{
-       MonoInvocation frame;
-       ThreadContext * volatile context = TlsGetValue (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);
-       ThreadContext context_struct;
-       MonoInvocation *old_frame = NULL;
-       jmp_buf env;
-
-       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 
-                       TlsSetValue (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;
-               TlsSetValue (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 (context->domain, klass);
-               ret = ((char*)retval) + sizeof (MonoObject);
-               if (!sig->ret->data.klass->enumtype)
-                       result.data.vt = ret;
-               break;
-       default:
-               retval = mono_object_new (context->domain, klass);
-               ret = ((char*)retval) + sizeof (MonoObject);
-               break;
-       }
-
-       for (i = 0; i < sig->param_count; ++i) {
-               if (sig->params [i]->byref) {
-                       args [i].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 [i].data.i = *(MonoBoolean*)params [i];
-                       break;
-               case MONO_TYPE_U2:
-               case MONO_TYPE_I2:
-               case MONO_TYPE_CHAR:
-                       args [i].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 [i].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 [i].data.l = *(gint64*)params [i];
-                       break;
-               case MONO_TYPE_VALUETYPE:
-                       if (sig->params [i]->data.klass->enumtype) {
-                               type = sig->params [i]->data.klass->enum_basetype->type;
-                               goto handle_enum;
-                       } else {
-                               args [i].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 [i].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);
-       INIT_FRAME(&frame,context->current_frame,obj,args,&result,method);
-       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)
-               TlsSetValue (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_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 MonoGHashTable *method_pointer_hash = NULL;
-
-static void *
-mono_create_method_pointer (MonoMethod *method)
-{
-       gpointer addr;
-       MonoJitInfo *ji;
-
-       mono_mutex_lock (&create_method_pointer_mutex);
-       if (!method_pointer_hash) {
-               MONO_GC_REGISTER_ROOT (method_pointer_hash);
-               method_pointer_hash = mono_g_hash_table_new (NULL, NULL);
-       }
-       addr = mono_g_hash_table_lookup (method_pointer_hash, method);
-       if (addr) {
-               mono_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->method = method;
-               ji->code_size = 1;
-               ji->code_start = addr = ((MonoMethodPInvoke*) method)->addr;
-
-               mono_jit_info_table_add (mono_get_root_domain (), ji);
-       }               
-       else
-               addr = mono_arch_create_method_pointer (method);
-
-       mono_g_hash_table_insert (method_pointer_hash, method, addr);
-       mono_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 (); \
-               g_print ("(%u) ", GetCurrentThreadId()); \
-               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;
-       char *locals;
-       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;
-
-       DEBUG_ENTER ();
-
-       if (!frame->runtime_method->transformed) {
-               context->managed_code = 0;
-               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 = (char *)sp + rtm->stack_size;
-#if DEBUG_INTERP
-       vtalloc = vt_sp;
-#endif
-       locals = 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);
-                       char *ret_vt_sp = vt_sp;
-                       vt_sp -= READ32(ip + 2);
-                       if (ret_size > 0) {
-                               memmove (vt_sp, ret_vt_sp, ret_size);
-                               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 = (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;
-                       child_frame.stack_args = sp;
-                       if (csignature->hasthis) {
-                               --sp;
-                               child_frame.obj = sp->data.p;
-                       } else {
-                               child_frame.obj = NULL;
-                       }
-                       if (csignature->hasthis &&
-                                       ((MonoObject *)child_frame.obj)->vtable->klass == mono_defaults.transparent_proxy_class) {
-                               child_frame.runtime_method = mono_interp_get_runtime_method (
-                                                               mono_marshal_get_remoting_invoke (child_frame.runtime_method->method));
-                       } else if (child_frame.runtime_method->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) 
-                               child_frame.runtime_method = mono_interp_get_runtime_method (
-                                                               mono_marshal_get_native_wrapper (child_frame.runtime_method->method));
-
-                       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;
-                       child_frame.stack_args = sp;
-                       if (csignature->hasthis) {
-                               --sp;
-                               child_frame.obj = sp->data.p;
-                       } else {
-                               child_frame.obj = NULL;
-                       }
-                       ves_pinvoke_method (&child_frame, csignature, (MonoFunc) 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;
-                       child_frame.stack_args = sp;
-                       if (child_frame.runtime_method->hasthis) {
-                               --sp;
-                               child_frame.obj = sp->data.p;
-                       } else {
-                               child_frame.obj = NULL;
-                       }
-                       if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->valuetype &&
-                                       ((MonoObject *)child_frame.obj)->vtable->klass == mono_defaults.transparent_proxy_class) {
-                               child_frame.runtime_method = mono_interp_get_runtime_method (
-                                                               mono_marshal_get_remoting_invoke (child_frame.runtime_method->method));
-                       }
-                       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;
-                       child_frame.stack_args = sp;
-                       if (child_frame.runtime_method->hasthis) {
-                               --sp;
-                               child_frame.obj = sp->data.p;
-                       } else {
-                               child_frame.obj = NULL;
-                       }
-
-                       if (child_frame.runtime_method->hasthis && !child_frame.runtime_method->valuetype &&
-                                       ((MonoObject *)child_frame.obj)->vtable->klass == mono_defaults.transparent_proxy_class) {
-                               child_frame.runtime_method = mono_interp_get_runtime_method (
-                                                               mono_marshal_get_remoting_invoke (child_frame.runtime_method->method));
-                       }
-
-                       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;
-                       child_frame.stack_args = sp;
-                       --sp;
-                       child_frame.obj = this_arg = sp->data.p;
-                       if (!this_arg)
-                               THROW_EX (mono_get_exception_null_reference(), ip - 2);
-                       child_frame.runtime_method = get_virtual_method (child_frame.runtime_method, this_arg);
-
-                       if (this_arg->vtable->klass->valuetype && child_frame.runtime_method->valuetype) {
-                               child_frame.obj = (char *)this_arg + sizeof(MonoObject);
-                       }
-
-                       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;
-                       child_frame.stack_args = sp;
-                       --sp;
-                       child_frame.obj = this_arg = sp->data.p;
-                       if (!this_arg)
-                               THROW_EX (mono_get_exception_null_reference(), ip - 2);
-                       child_frame.runtime_method = get_virtual_method (child_frame.runtime_method, this_arg);
-
-                       if (this_arg->vtable->klass->valuetype && child_frame.runtime_method->valuetype) {
-                               child_frame.obj = (char *)this_arg + sizeof(MonoObject);
-                       }
-
-                       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_CALLINT)
-                       ves_pinvoke_method (frame, mono_method_signature (frame->runtime_method->method), ((MonoMethodPInvoke*) frame->runtime_method->method)->addr, 
-                                   frame->runtime_method->method->string_ctor, context);
-                       if (frame->ex) {
-                               rtm = NULL;
-                               goto handle_exception;
-                       }
-                       goto exit_frame;
-               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)
-                       ++ip;
-                       sp[-1].data.p = *(gpointer*)sp[-1].data.p;
-                       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);
-                       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);
-                       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;
-                       }
-
-                       /*
-                        * First arg is the object.
-                        */
-                       if (newobj_class->valuetype) {
-                               if (!newobj_class->enumtype && (newobj_class->byval_arg.type == MONO_TYPE_VALUETYPE)) {
-                                       child_frame.obj = vt_sp;
-                                       valuetype_this.data.p = vt_sp;
-                               } else {
-                                       memset (&valuetype_this, 0, sizeof (stackval));
-                                       child_frame.obj = &valuetype_this;
-                               }
-                       } else {
-                               if (newobj_class != mono_defaults.string_class) {
-                                       context->managed_code = 0;
-                                       o = mono_object_new (context->domain, newobj_class);
-                                       context->managed_code = 1;
-                                       if (*abort_requested)
-                                               mono_thread_interruption_checkpoint ();
-                                       child_frame.obj = o;
-                               } else {
-                                       child_frame.retval = &retval;
-                               }
-                       }
-
-                       if (csig->param_count) {
-                               sp -= csig->param_count;
-                               child_frame.stack_args = sp;
-                       } else {
-                               child_frame.stack_args = NULL;
-                       }
-
-                       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)) {
-                               if (c->marshalbyref) {
-                                       if (!mono_object_isinst_mbyref (o, c))
-                                               THROW_EX (mono_get_exception_invalid_cast (), ip);
-                               } else {
-                                       MonoVTable *vt = o->vtable;
-                                       MonoClass *oklass = vt->klass;
-                                       if (c->flags & TYPE_ATTRIBUTE_INTERFACE) {
-                                               if (c->interface_id > vt->max_interface_id ||
-                                                   vt->interface_offsets [c->interface_id] == 0) {
-                                                       THROW_EX (mono_get_exception_invalid_cast (), ip);
-                                               }
-                                       } else if (c->rank) {
-                                               if (!mono_object_isinst (o, c))
-                                                       THROW_EX (mono_get_exception_invalid_cast (), ip);
-                                       } else if (!mono_class_has_parent (oklass, c)) {
-                                               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)) {
-                               if (c->marshalbyref) {
-                                       if (!mono_object_isinst_mbyref (o, c))
-                                               sp [-1].data.p = NULL;
-                               } else {
-                                       MonoVTable *vt = o->vtable;
-                                       MonoClass *oklass = vt->klass;
-                                       if (c->flags & TYPE_ATTRIBUTE_INTERFACE) {
-                                               if (c->interface_id > vt->max_interface_id ||
-                                                   vt->interface_offsets [c->interface_id] == 0) {
-                                                       sp [-1].data.p = NULL;
-                                               }
-                                       } else if (c->rank) {
-                                               if (!mono_object_isinst (o, c))
-                                                       sp [-1].data.p = NULL;
-                                       } else if (!mono_class_has_parent (oklass, c)) {
-                                               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);
-
-                       if (!(mono_object_isinst (o, c) || 
-                                 ((o->vtable->klass->rank == 0) && 
-                                  (o->vtable->klass->element_class == c->element_class))))
-                               THROW_EX (mono_get_exception_invalid_cast (), ip);
-
-                       sp [-1].data.p = (char *)o + sizeof (MonoObject);
-                       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 (o->vtable->klass == mono_defaults.transparent_proxy_class) {
-                               MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
-
-                               addr = mono_load_remote_field (o, klass, field, &tmp);
-                       } 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 (o->vtable->klass == mono_defaults.transparent_proxy_class) {
-                               MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
-                               addr = mono_load_remote_field (o, klass, field, &tmp);
-                       } 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 (o->vtable->klass == mono_defaults.transparent_proxy_class) {
-                               MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
-                               mono_store_remote_field (o, klass, field, &sp [-1].data);
-                       } 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 (o->vtable->klass == mono_defaults.transparent_proxy_class) {
-                               MonoClass *klass = ((MonoTransparentProxy*)o)->remote_class->proxy_class;
-                               mono_store_remote_field (o, klass, field, &sp [-1].data);
-                       } 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)];
-                       MonoVTable *vt = mono_class_vtable (context->domain, field->parent);
-                       gpointer addr;
-
-                       if (!vt->initialized) {
-                               frame->ip = ip;
-                               mono_runtime_class_init (vt);
-                       }
-                       ip += 2;
-
-                       if (context->domain->special_static_fields && (addr = g_hash_table_lookup (context->domain->special_static_fields, field)))
-                               sp->data.p = mono_get_special_static_data (GPOINTER_TO_UINT (addr));
-                       else
-                               sp->data.p = (char*)(vt->data) + field->offset;
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDSFLD) {
-                       MonoVTable *vt;
-                       MonoClassField *field;
-                       gpointer addr;
-
-                       field = rtm->data_items[*(guint16 *)(ip + 1)];
-                       vt = rtm->data_items [*(guint16 *)(ip + 2)];
-                       if (!vt->initialized) {
-                               frame->ip = ip;
-                               mono_runtime_class_init (vt);
-                       }
-                       ip += 3;
-                       if (context->domain->special_static_fields && (addr = g_hash_table_lookup (context->domain->special_static_fields, field)))
-                               addr = mono_get_special_static_data (GPOINTER_TO_UINT (addr));
-                       else
-                               addr = (char*)(vt->data) + field->offset;
-
-                       stackval_from_data (field->type, sp, addr, FALSE);
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDSFLD_I4) {
-                       MonoClassField *field = rtm->data_items[*(guint16 *)(ip + 1)];
-                       MonoVTable *vt = rtm->data_items [*(guint16 *)(ip + 2)];
-                       if (!vt->initialized) {
-                               frame->ip = ip;
-                               mono_runtime_class_init (vt);
-                       }
-                       ip += 3;
-                       sp->data.i = * (gint32 *)((char*)(vt->data) + field->offset);
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDSFLD_O) {
-                       MonoClassField *field = rtm->data_items[*(guint16 *)(ip + 1)];
-                       MonoVTable *vt = rtm->data_items [*(guint16 *)(ip + 2)];
-                       if (!vt->initialized) {
-                               frame->ip = ip;
-                               mono_runtime_class_init (vt);
-                       }
-                       ip += 3;
-                       sp->data.p = * (gpointer *)((char*)(vt->data) + field->offset);
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_LDSFLD_VT) {
-                       MonoVTable *vt;
-                       MonoClassField *field;
-                       guint32 token;
-                       gpointer addr;
-                       int size;
-
-                       token = * (guint16 *)(ip + 1);
-                       size = READ32(ip + 2);
-                       field = rtm->data_items[token];
-                       ip += 4;
-                                               
-                       vt = mono_class_vtable (context->domain, field->parent);
-                       if (!vt->initialized) {
-                               frame->ip = ip - 2;
-                               mono_runtime_class_init (vt);
-                       }
-                       
-                       if (context->domain->special_static_fields && (addr = g_hash_table_lookup (context->domain->special_static_fields, field)))
-                               addr = mono_get_special_static_data (GPOINTER_TO_UINT (addr));
-                       else
-                               addr = (char*)(vt->data) + field->offset;
-
-                       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) {
-                       MonoVTable *vt;
-                       MonoClassField *field;
-                       guint32 token;
-                       gpointer addr;
-
-                       token = * (guint16 *)(ip + 1);
-                       field = rtm->data_items[token];
-                       ip += 2;
-                       --sp;
-
-                       vt = mono_class_vtable (context->domain, field->parent);
-                       if (!vt->initialized) {
-                               frame->ip = ip - 2;
-                               mono_runtime_class_init (vt);
-                       }
-                       
-                       if (context->domain->special_static_fields && (addr = g_hash_table_lookup (context->domain->special_static_fields, field)))
-                               addr = mono_get_special_static_data (GPOINTER_TO_UINT (addr));
-                       else
-                               addr = (char*)(vt->data) + field->offset;
-
-                       stackval_to_data (field->type, sp, addr, FALSE);
-                       MINT_IN_BREAK;
-               }
-               MINT_IN_CASE(MINT_STSFLD_VT) {
-                       MonoVTable *vt;
-                       MonoClassField *field;
-                       guint32 token;
-                       gpointer addr;
-                       int size;
-
-                       token = * (guint16 *)(ip + 1);
-                       size = READ32(ip + 2);
-                       field = rtm->data_items[token];
-                       ip += 4;
-                                               
-                       vt = mono_class_vtable (context->domain, field->parent);
-                       if (!vt->initialized) {
-                               frame->ip = ip - 2;
-                               mono_runtime_class_init (vt);
-                       }
-                       
-                       if (context->domain->special_static_fields && (addr = g_hash_table_lookup (context->domain->special_static_fields, field)))
-                               addr = mono_get_special_static_data (GPOINTER_TO_UINT (addr));
-                       else
-                               addr = (char*)(vt->data) + field->offset;
-                       --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)];
-
-                       if (c->byval_arg.type == MONO_TYPE_VALUETYPE && !c->enumtype) {
-                               int size = mono_class_value_size (c, NULL);
-                               sp [-1].data.p = mono_value_box (context->domain, c, sp [-1].data.p);
-                               size = (size + 7) & ~7;
-                               vt_sp -= size;
-                       }                               
-                       else {
-                               stackval_to_data (&c->byval_arg, &sp [-1], (char*)&sp [-1], FALSE);
-                               sp [-1].data.p = mono_value_box (context->domain, c, &sp [-1]);
-                       }
-                       ip += 2;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_NEWARR)
-                       sp [-1].data.p = (MonoObject*) mono_array_new (context->domain, rtm->data_items[*(guint16 *)(ip + 1)], sp [-1].data.i);
-                       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) {
-                       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;
-                       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) {
-                       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:
-                               if (sp [2].data.p && !mono_object_isinst (sp [2].data.p, mono_object_class (o)->element_class))
-                                       THROW_EX (mono_get_exception_array_type_mismatch (), ip);
-                               mono_array_set ((MonoArray *)o, gpointer, aindex, sp [2].data.p);
-                               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 (!finite(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_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 (context->domain, rtm->data_items [*(guint16 *)(ip + 1)]);
-                       ip += 2;
-                       sp++;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_MONO_FREE)
-                       ++ip;
-                       --sp;
-                       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 (m, sp->data.p);
-                       ++sp;
-                       MINT_IN_BREAK;
-               }
-
-               MINT_IN_CASE(MINT_LDTHIS)
-                       sp->data.p = frame->obj;
-                       ++ip;
-                       ++sp; 
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_STTHIS)
-                       --sp; 
-                       frame->obj = sp->data.p;
-                       ++ip;
-                       MINT_IN_BREAK;
-               MINT_IN_CASE(MINT_LDTHISA)
-                       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) {
-                                               if (mono_object_isinst ((MonoObject*)frame->ex, clause->data.catch_class)) {
-                                                       /* 
-                                                        * 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 (method);
-               
-#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;
-               MonoMethodHeader *header = mono_method_get_header (frame->runtime_method->method);
-               
-#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 = (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 = TlsGetValue (thread_context_id);
-       ThreadContext context_struct;
-       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;
-               TlsSetValue (thread_context_id, context);
-       }
-       frame->ip = NULL;
-       frame->parent = context->current_frame;
-       frame->runtime_method = mono_interp_get_runtime_method (frame->method);
-       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)
-               TlsSetValue (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;
-       MonoObject *exc = NULL;
-       int rval;
-
-       method = mono_get_method (image, mono_image_get_entry_point (image), NULL);
-       if (!method)
-               g_error ("No entry point method found in %s", mono_image_get_filename (image));
-
-       rval = mono_runtime_run_main (method, argc, argv, &exc);
-       if (exc != NULL)
-               mono_unhandled_exception (exc);
-
-       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"
-                "\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);
-}
-
-#ifdef RUN_TEST
-static void
-test_load_class (MonoImage* image)
-{
-       MonoTableInfo  *t = &image->tables [MONO_TABLE_TYPEDEF];
-       MonoClass *klass;
-       int i;
-
-       for (i = 1; i <= t->rows; ++i) {
-               klass = mono_class_get (image, MONO_TOKEN_TYPE_DEF | i);
-               mono_class_init (klass);
-       }
-}
-#endif
-
-static void
-add_signal_handler (int signo, void (*handler)(int))
-{
-#ifdef HOST_WIN32
-       signal (signo, handler);
-#else
-       struct sigaction sa;
-
-       sa.sa_handler = handler;
-       sigemptyset (&sa.sa_mask);
-       sa.sa_flags = 0;
-
-       g_assert (sigaction (signo, &sa, NULL) != -1);
-#endif
-}
-
-static void
-segv_handler (int signum)
-{
-       ThreadContext *context = TlsGetValue (thread_context_id);
-       MonoException *segv_exception;
-
-       if (context == NULL)
-               return;
-       segv_exception = mono_get_exception_null_reference ();
-       segv_exception->message = mono_string_new (mono_domain_get (), "Null Reference (SIGSEGV)");
-       mono_raise_exception (segv_exception);
-}
-
-
-static void
-quit_handler (int signum)
-{
-       ThreadContext *context = TlsGetValue (thread_context_id);
-       MonoException *quit_exception;
-
-       if (context == NULL)
-               return;
-       quit_exception = mono_get_exception_execution_engine ("Interrupted (SIGQUIT).");
-       mono_raise_exception (quit_exception);
-}
-
-static void
-abrt_handler (int signum)
-{
-       ThreadContext *context = TlsGetValue (thread_context_id);
-       MonoException *abrt_exception;
-
-       if (context == NULL)
-               return;
-       abrt_exception = mono_get_exception_execution_engine ("Abort (SIGABRT).");
-       mono_raise_exception (abrt_exception);
-}
-
-static void
-thread_abort_handler (int signum)
-{
-       ThreadContext *context = TlsGetValue (thread_context_id);
-       MonoException *exc;
-
-       if (context == NULL)
-               return;
-
-       exc = mono_thread_request_interruption (context->managed_code); 
-       if (exc) mono_raise_exception (exc);
-}
-
-static MonoBoolean
-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 = TlsGetValue (thread_context_id);
-       MonoInvocation *inv = context->current_frame;
-       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)
-               *method = inv == NULL ? NULL : mono_method_get_object (context->domain, inv->runtime_method->method, NULL);
-       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 *
-ves_icall_get_trace (MonoException *exc, gint32 skip, MonoBoolean need_file_info)
-{
-       MonoDomain *domain = mono_domain_get ();
-       MonoArray *res;
-       MonoArray *ta = exc->trace_ips;
-       int i, len;
-
-       if (ta == NULL) {
-               /* Exception is not thrown yet */
-               return mono_array_new (domain, mono_defaults.stack_frame_class, 0);
-       }
-       
-       len = mono_array_length (ta);
-
-       res = mono_array_new (domain, mono_defaults.stack_frame_class, len > skip ? len - skip : 0);
-
-       for (i = skip; i < len / 2; i++) {
-               MonoStackFrame *sf = (MonoStackFrame *)mono_object_new (domain, mono_defaults.stack_frame_class);
-               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 (domain, rtm->method, NULL);
-                       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;
-
-       mono_assert (delegate_class->parent == mono_defaults.multicastdelegate_class);
-
-       delegate = mono_object_new (mono_object_domain (type), delegate_class);
-
-       interp_delegate_ctor (mono_object_domain (type), delegate, target, mono_interp_get_runtime_method (info->method));
-
-       return delegate;
-}
-
-
-typedef struct
-{
-       MonoDomain *domain;
-       int enable_debugging;
-       char *file;
-       int argc;
-       char **argv;
-} MainThreadArgs;
-
-static void main_thread_handler (gpointer user_data)
-{
-       MainThreadArgs *main_args=(MainThreadArgs *)user_data;
-       MonoAssembly *assembly;
-
-       if (main_args->enable_debugging) {
-               mono_debug_init (MONO_DEBUG_FORMAT_MONO);
-               mono_debug_init_1 (main_args->domain);
-       }
-
-       assembly = mono_domain_assembly_open (main_args->domain,
-                                             main_args->file);
-
-       if (!assembly){
-               fprintf (stderr, "Can not open image %s\n", main_args->file);
-               exit (1);
-       }
-
-       if (main_args->enable_debugging)
-               mono_debug_init_2 (assembly);
-
-#ifdef RUN_TEST
-       test_load_class (assembly->image);
-#else
-
-       ves_exec (main_args->domain, assembly, main_args->argc, main_args->argv);
-#endif
-}
-
-static void
-mono_runtime_install_handlers (void)
-{
-       add_signal_handler (SIGSEGV, segv_handler);
-       add_signal_handler (SIGINT, quit_handler);
-       add_signal_handler (SIGABRT, abrt_handler);
-       add_signal_handler (mono_thread_get_abort_signal (), thread_abort_handler);
-}
-
-static void
-quit_function (MonoDomain *domain, gpointer user_data)
-{
-       mono_profiler_shutdown ();
-       
-       mono_runtime_cleanup (domain);
-       mono_domain_free (domain, TRUE);
-
-}
-
-void
-mono_interp_cleanup(MonoDomain *domain)
-{
-       quit_function (domain, NULL);
-}
-
-int
-mono_interp_exec(MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[])
-{
-       return ves_exec (domain, assembly, argc, argv);
-}
-
-MonoDomain *
-mono_interp_init(const char *file)
-{
-       MonoDomain *domain;
-
-       g_set_prgname (file);
-       mono_set_rootdir ();
-       
-       g_log_set_always_fatal (G_LOG_LEVEL_ERROR);
-       g_log_set_fatal_mask (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR);
-
-       if (!g_thread_supported ())
-               g_thread_init (NULL);
-
-       thread_context_id = TlsAlloc ();
-       TlsSetValue (thread_context_id, NULL);
-       mono_mutex_init_recursive (&runtime_method_lookup_section);
-       mono_mutex_init_recursive (&create_method_pointer_mutex);
-
-       mono_runtime_install_handlers ();
-       mono_interp_transform_init ();
-       mono_install_compile_method (mono_create_method_pointer);
-       mono_install_runtime_invoke (interp_mono_runtime_invoke);
-       mono_install_remoting_trampoline (interp_create_remoting_trampoline);
-       mono_install_trampoline (interp_create_trampoline);
-
-       mono_install_handler (interp_ex_handler);
-       mono_install_stack_walk (interp_walk_stack);
-       mono_install_runtime_cleanup (quit_function);
-       abort_requested = mono_thread_interruption_request_flag ();
-
-       domain = mono_init_from_assembly (file, file);
-#ifdef __hpux /* generates very big stack frames */
-       mono_threads_set_default_stacksize(32*1024*1024);
-#endif
-       mono_icall_init ();
-       mono_add_internal_call ("System.Diagnostics.StackFrame::get_frame_info", ves_icall_get_frame_info);
-       mono_add_internal_call ("System.Diagnostics.StackTrace::get_trace", ves_icall_get_trace);
-       mono_add_internal_call ("Mono.Runtime::mono_runtime_install_handlers", mono_runtime_install_handlers);
-       mono_add_internal_call ("System.Delegate::CreateDelegate_internal", ves_icall_System_Delegate_CreateDelegate_internal);
-
-       mono_register_jit_icall (mono_thread_interruption_checkpoint, "mono_thread_interruption_checkpoint", mono_create_icall_signature ("void"), FALSE);
-
-       mono_runtime_init (domain, NULL, NULL);
-
-
-       mono_thread_attach (domain);
-       return domain;
-}
-
-int 
-mono_main (int argc, char *argv [])
-{
-       MonoDomain *domain;
-       int retval = 0, i;
-       char *file, *config_file = NULL;
-       int enable_debugging = FALSE;
-       MainThreadArgs main_args;
-       const char *error;
-
-       setlocale (LC_ALL, "");
-       if (argc < 2)
-               usage ();
-
-       MONO_GC_PRE_INIT ();
-       
-       for (i = 1; i < argc && argv [i][0] == '-'; i++){
-               if (strcmp (argv [i], "--trace") == 0)
-                       global_tracing = 1;
-               if (strcmp (argv [i], "--noptr") == 0)
-                       global_no_pointers = 1;
-               if (strcmp (argv [i], "--traceops") == 0)
-                       global_tracing = 2;
-               if (strcmp (argv [i], "--traceopt") == 0)
-                       ++mono_interp_traceopt;
-               if (strcmp (argv [i], "--dieonex") == 0) {
-                       die_on_exception = 1;
-                       enable_debugging = 1;
-               }
-               if (strcmp (argv [i], "--print-vtable") == 0)
-                       mono_print_vtable = TRUE;
-               if (strcmp (argv [i], "--profile") == 0)
-                       mono_profiler_load (NULL);
-               if (strcmp (argv [i], "--config") == 0)
-                       config_file = argv [++i];
-               if (strcmp (argv [i], "--help") == 0)
-                       usage ();
-#if DEBUG_INTERP
-               if (strcmp (argv [i], "--debug") == 0) {
-                       MonoMethodDesc *desc = mono_method_desc_new (argv [++i], FALSE);
-                       if (!desc)
-                               g_error ("Invalid method name '%s'", argv [i]);
-                       db_methods = g_list_append (db_methods, desc);
-               }
-               if (strcmp (argv [i], "--nested") == 0)
-                       nested_trace = 1;
-#endif
-       }
-       
-       file = argv [i];
-
-       if (!file)
-               usage ();
-
-       domain = mono_interp_init(file);
-       mono_config_parse (config_file);
-
-       error = mono_check_corlib_version ();
-       if (error) {
-               fprintf (stderr, "Corlib not in sync with this runtime: %s\n", error);
-               fprintf (stderr, "Download a newer corlib at http://www.go-mono.com/daily.\n");
-               exit (1);
-       }
-
-       main_args.domain=domain;
-       main_args.file=file;
-       main_args.argc=argc-i;
-       main_args.argv=argv+i;
-       main_args.enable_debugging=enable_debugging;
-       
-       mono_runtime_exec_managed_code (domain, main_thread_handler,
-                                       &main_args);
-
-       quit_function (domain, NULL);
-
-       /* Get the return value from System.Environment.ExitCode */
-       retval=mono_environment_exitcode_get ();
-
-#if COUNT_OPS
-       for (i = 0; i < 512; i++)
-               if (opcode_counts[i] != 0)
-                       printf("%s %d\n", mono_interp_opname[i], opcode_counts[i]);
-#endif
-       return retval;
-}
diff --git a/mono/interpreter/interp.h b/mono/interpreter/interp.h
deleted file mode 100644 (file)
index 0953e5a..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-#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 (*MonoFunc) (void);
-typedef void (*MonoPIFunc) (MonoFunc callme, void *retval, void *obj_this, stackval *arguments);
-
-/* 
- * 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 */
-       void           *obj;    /* this - 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;
-
-void mono_init_icall (void);
-
-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);
-
-void inline stackval_from_data (MonoType *type, stackval *result, char *data, gboolean pinvoke);
-void inline stackval_to_data (MonoType *type, stackval *val, char *data, gboolean pinvoke);
-void ves_exec_method (MonoInvocation *frame);
-
-/*
- * defined in an arch specific file.
- */
-MonoPIFunc
-mono_arch_create_trampoline (MonoMethodSignature *sig, gboolean string_ctor);
-
-RuntimeMethod *
-mono_interp_get_runtime_method (MonoMethod *method);
-
-void *mono_arch_create_method_pointer (MonoMethod *method);
-
-extern int mono_interp_traceopt;
diff --git a/mono/interpreter/main.c b/mono/interpreter/main.c
deleted file mode 100644 (file)
index 70b5d96..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#include "interp.h"
-#include "embed.h"
-
-int
-main (int argc, char* argv[])
-{
-       return mono_main (argc, argv);
-}
-
diff --git a/mono/interpreter/mint.1 b/mono/interpreter/mint.1
deleted file mode 100644 (file)
index 77e00c3..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-.\" 
-.\" mint manual page.
-.\" (C) Ximian, Inc. 
-.\" Author:
-.\"   Miguel de Icaza (miguel@gnu.org)
-.\"
-.TH Mono "Mono 1.0"
-.SH NAME
-mint \- Mono ECMA-CLI interpreter.
-.SH SYNOPSIS
-.PP
-.B mint
-[\-\-help] [\-\-opcode\-count] [\-\-trace] [\-\-traceops] [\-\-profile]
-[\-\-config filename] [\-\-debug method]
-program.exe [arguments...]
-.SH DESCRIPTION
-The \fImint\fP program is an interpreter for ECMA CLI byte codes.  It
-executes the bytecodes contains in 
-.I program.exe
-and optionally passes
-the
-.I arguments
-to it. 
-.SH OPTIONS
-The following Generic options are supported:
-.TP
-.I "--help", "-h"
-Displays usage instructions.
-.TP
-.I "--config filename"
-Load the specified configuration file instead of the default one(s).
-The default files are /etc/mono/config and ~/.mono/config or the file
-specified in the MONO_CONFIG environment variable, if set.
-.TP
-.I "--trace"
-Traces execution showing when methods are entered and left.
-.I "--traceops"
-Traces execution at the instruction level and displays the stack contents.
-.I "--traceclassinit"
-Shows when classes are initialized
-.TP
-.I "--noptr"
-Suppresses printing of pointer addresses in trace output.
-.TP
-.I "--profile"
-Performs runtime profiling of the code and displays statistics at the
-end of execution.
-.TP
-.I "--opcode-count"
-Displays the number of opcodes executed.
-.TP
-.I "--dieonex"
-Aborts execution upon hitting an exception.
-.TP
-.I "--debug method"
-Debugs the method whose name is `method'.  You can specify the method
-like this: `class:method' or `class::method'
-.TP
-.I "--opcode-count"
-Displays the number of opcodes executed
-.PP
-.SH ENVIRONMENT VARIABLES
-.TP
-.I "MONO_PATH"
-Provides a search path to mono and mint where to look for library files.
-Directories are separated by the platform path separator (colons on unix). Example:
-.B /home/username/lib:/usr/local/mono/lib
-.PP
-.SH FILES
-Assemblies are lodaed from the installation lib directory.  If you set
-`prefix' to /usr, the assemblies will be located in /usr/lib.
-.PP
-/etc/mono/config, ~/.mono/config
-.IP
-Mono runtime configuration file.  See the mono-config(5) manual page
-for more information.
-.SH MAILING LISTS
-Visit http://mail.ximian.com/mailman/mono-list for details.
-.SH WEB SITE
-Visit: http://www.go-mono.com for details
-.SH SEE ALSO
-.BR mono(1), monodis(1)
diff --git a/mono/interpreter/mintops.c b/mono/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/interpreter/mintops.def b/mono/interpreter/mintops.def
deleted file mode 100644 (file)
index 550ba65..0000000
+++ /dev/null
@@ -1,510 +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_LDTHIS, "ldthis", 1, MintOpNoArgs)
-
-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_STTHIS, "stthis", 1, MintOpNoArgs)
-
-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", 3, MintOpTwoShorts)
-OPDEF(MINT_LDSFLD_I4, "ldsfld.i4", 3, MintOpTwoShorts)
-OPDEF(MINT_LDSFLD_O, "ldsfld.o", 3, MintOpTwoShorts)
-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", 1, MintOpNoArgs)
-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_CALLINT, "callint", 1, MintOpNoArgs)
-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", 2, MintOpClassToken) 
-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_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_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_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/interpreter/mintops.h b/mono/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/interpreter/transform.c b/mono/interpreter/transform.c
deleted file mode 100644 (file)
index 2bd3f25..0000000
+++ /dev/null
@@ -1,3049 +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>
-
-#define OPDEF(a,b,c,d,e,f,g,h,i,j) \
-       a = i,
-
-enum {
-#include "mono/cil/opcode.def"
-       CEE_LASTOP
-};
-#undef OPDEF
-
-#include "mintops.h"
-#include "interp.h"
-
-#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 = type->data.klass->enum_basetype;
-                       goto enum_type;
-               } else
-                       return MINT_TYPE_VT;
-       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;
-       if (n == 0 && mono_method_signature (td->method)->hasthis) {
-               if (td->method->klass->valuetype)
-                       mt = MINT_TYPE_P;
-               else {
-                       mt = MINT_TYPE_O;
-                       klass = td->method->klass;
-               }
-               ADD_CODE(td, MINT_LDTHIS);
-       } else {
-               MonoType *type;
-               n -= mono_method_signature (td->method)->hasthis;
-               type = mono_method_signature (td->method)->params [n];
-               mt = mint_type (type);
-               if (mt == MINT_TYPE_VT) {
-                       gint32 size;
-                       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);
-                       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);             
-                       klass = type->data.klass;
-               } 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);
-       if (n == 0 && mono_method_signature (td->method)->hasthis)
-               ADD_CODE(td, MINT_STTHIS);
-       else {
-               MonoType *type;
-               n -= mono_method_signature (td->method)->hasthis;
-               type = mono_method_signature (td->method)->params [n];
-               mt = mint_type (type);
-               if (mt == MINT_TYPE_VT) {
-                       gint32 size;
-                       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 = mono_method_signature (td->method)->params [n];
-       int mt = mint_type (type);
-       if (mt == MINT_TYPE_VT) {
-               gint32 size;
-               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_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) {
-               gint32 size = mono_class_value_size (type->data.klass, NULL);
-               PUSH_VT(td, size);
-               ADD_CODE(td, MINT_LDLOC_VT);
-               ADD_CODE(td, offset); /*FIX for large offset */
-               WRITE32(td, &size);
-               klass = type->data.klass;
-       } else {
-               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) {
-               gint32 size = mono_class_value_size (type->data.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 {
-               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
-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;
-       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);
-       }
-
-       for (i = 0; i < signature->param_count; i++)
-               store_inarg(&td, i);
-
-       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_%04x %s %-10s -> IL_%04x, sp %d, %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: {
-                       int n = ((guint8 *)td.ip)[1];
-                       if (n == 0 && signature->hasthis) 
-                               ADD_CODE(&td, MINT_LDTHISA);
-                       else {
-                               ADD_CODE(&td, MINT_LDARGA);
-                               ADD_CODE(&td, td.rtm->arg_offsets [n - signature->hasthis]);
-                       }
-                       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 (m)));
-                       td.ip += 5;
-                       break;
-               }
-               case CEE_CALLVIRT: /* Fall through */
-               case CEE_CALLI:    /* Fall through */
-               case CEE_CALL: {
-                       MonoMethod *m;
-                       MonoMethodSignature *csignature;
-                       int virtual = *td.ip == CEE_CALLVIRT;
-                       int calli = *td.ip == CEE_CALLI;
-                       int i;
-                       guint32 vt_stack_used = 0;
-                       guint32 vt_res_size = 0;
-                       int op = -1;
-                       int native = 0;
-                       int is_void = 0;
-
-                       token = read32 (td.ip + 1);
-                       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);
-                               m = NULL;
-                       } else {
-                               if (method->wrapper_type == MONO_WRAPPER_NONE)
-                                       m = mono_get_method_full (image, token, NULL, generic_context);
-                               else
-                                       m = (MonoMethod *)mono_method_get_wrapper_data (method, token);
-                               csignature = mono_method_signature (m);
-                               if (m->klass == mono_defaults.string_class) {
-                                       if (m->name [0] == 'g') {
-                                               if (strcmp (m->name, "get_Chars") == 0)
-                                                       op = MINT_GETCHR;
-                                               else if (strcmp (m->name, "get_Length") == 0)
-                                                       op = MINT_STRLEN;
-                                       }
-                               } else if (m->klass == mono_defaults.array_class) {
-                                       if (strcmp (m->name, "get_Rank") == 0)
-                                               op = MINT_ARRAY_RANK;
-                                       else if (strcmp (m->name, "get_Length") == 0)
-                                               op = MINT_LDLEN;
-                               }
-                       }
-                       CHECK_STACK(&td, csignature->param_count + csignature->hasthis);
-                       if (!calli && (!virtual || (m->flags & METHOD_ATTRIBUTE_VIRTUAL) == 0) &&
-                               (m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) == 0 && 
-                               (m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) == 0) {
-                               int called_inited = mono_class_vtable (domain, m->klass)->initialized;
-                               MonoMethodHeader *mheader = mono_method_get_header (m);
-
-                               if (/*mono_metadata_signature_equal (method->signature, m->signature) */ method == m && *(td.ip + 5) == CEE_RET) {
-                                       int offset;
-                                       if (mono_interp_traceopt)
-                                               g_print ("Optimize tail call of %s.%s\n", m->klass->name, m->name);
-                                       for (i = csignature->param_count - 1; i >= 0; --i)
-                                               store_arg (&td, i + csignature->hasthis);
-
-                                       if (csignature->hasthis) {
-                                               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;
-                                       break;
-                               } 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", m->klass->name, m->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;
-                                               break;
-                                       }
-                               }
-                       }
-                       if (method->wrapper_type == MONO_WRAPPER_NONE && m != NULL) {
-                               if (m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
-                                       m = mono_marshal_get_native_wrapper (m);
-                               if (!virtual && m->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
-                                       m = mono_marshal_get_synchronized_wrapper (m);
-                       }
-                       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;
-                                       if (csignature->pinvoke && method->wrapper_type != MONO_WRAPPER_NONE)
-                                               size = mono_class_native_size (csignature->params [i]->data.klass, NULL);
-                                       else
-                                               size = mono_class_value_size (csignature->params [i]->data.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 = NULL;
-                               if (mt == MINT_TYPE_VT) {
-                                       if (csignature->pinvoke && method->wrapper_type != MONO_WRAPPER_NONE)
-                                               vt_res_size = mono_class_native_size (csignature->ret->data.klass, NULL);
-                                       else
-                                               vt_res_size = mono_class_value_size (csignature->ret->data.klass, NULL);
-                                       PUSH_VT(&td, vt_res_size);
-                                       klass = csignature->ret->data.klass;
-                               } else if (mt == MINT_TYPE_O)
-                                       klass = mono_class_from_mono_type (csignature->ret);
-                               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);
-                               ADD_CODE(&td, get_data_item_index (&td,  calli? (void *)csignature : (void *)mono_interp_get_runtime_method (m)));
-                       }
-                       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;
-                       }
-                       break;
-               }
-               case CEE_RET: {
-                       int vt_size = 0;
-                       if (signature->ret->type != MONO_TYPE_VOID) {
-                               --td.sp;
-                               if (mint_type(signature->ret) == MINT_TYPE_VT) {
-                                       vt_size = mono_class_value_size (signature->ret->data.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_warning ("%s.%s: CEE_RET: value type stack: %d", td.method->klass->name, td.method->name, td.vt_sp);
-                       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);
-                       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;
-                       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 (klass->byval_arg.type == MONO_TYPE_VALUETYPE && !klass->byval_arg.data.klass->enumtype) {
-                               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 (m)));
-                       if (klass->byval_arg.type == MONO_TYPE_VALUETYPE) {
-                               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) {
-                                       gint32 size = mono_class_value_size (csignature->params [i]->data.klass, 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);
-                       
-                       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_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);
-                       mt = mint_type(field->type);
-                       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);
-                       }
-                       klass = NULL;
-                       if (mt == MINT_TYPE_VT) {
-                               int size = mono_class_value_size (field->type->data.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;
-                       SET_TYPE(td.sp - 1, stack_type [mt], 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) {
-                               int size = mono_class_value_size (field->type->data.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) {
-                               int size = mono_class_value_size (field->type->data.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);
-                               if (!domain->special_static_fields || !g_hash_table_lookup (domain->special_static_fields, field)) {
-                                       if (mt == MINT_TYPE_O)
-                                               td.new_ip [-2] = MINT_LDSFLD_O;
-                                       else if (mt == MINT_TYPE_I4)
-                                               td.new_ip [-2] = MINT_LDSFLD_I4;
-                               }
-                               ADD_CODE(&td, get_data_item_index (&td, mono_class_vtable (domain, field->parent)));
-                       }
-                       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) {
-                               int size = mono_class_value_size (field->type->data.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);
-                       g_assert (klass->valuetype);
-                       if (klass->byval_arg.type == MONO_TYPE_VALUETYPE && !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));
-                       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_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;
-#if 0
-               case CEE_LDELEM: 
-               case CEE_STELEM: 
-               case CEE_UNBOX_ANY: 
-
-               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_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
-                                                       g_assert_not_reached();
-                                               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)
-                                               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;
-                       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 (m)));
-                               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) 
-                                       ADD_CODE(&td, MINT_LDTHISA);
-                               else {
-                                       ADD_CODE(&td, MINT_LDARGA);
-                                       ADD_CODE(&td, td.rtm->arg_offsets [n - signature->hasthis]); /* 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;
-#if 0
-                       case CEE_CONSTRAINED_: {
-                               guint32 token;
-                               /* FIXME: implement */
-                               ++ip;
-                               token = read32 (ip);
-                               ip += 4;
-                               break;
-                       }
-#endif
-                       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: {
-                               guint32 align;
-                               gint32 size;
-                               token = read32 (td.ip + 1);
-                               td.ip += 5;
-                               if (mono_metadata_token_table (token) == MONO_TABLE_TYPESPEC) {
-                                       MonoType *type = mono_type_create_from_typespec (image, token);
-                                       size = mono_type_size (type, &align);
-                               } else {
-                                       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 at 0x%x\n", *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_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;
-
-       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_mutex_lock(&calc_section);
-               if (runtime_method->transformed) {
-                       mono_mutex_unlock(&calc_section);
-                       mono_profiler_method_end_jit (method, 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)) {
-                       runtime_method->code = g_malloc(sizeof(short));
-                       runtime_method->code[0] = MINT_CALLINT;
-                       if (((MonoMethodPInvoke*) method)->addr == NULL)
-                               ((MonoMethodPInvoke*) method)->addr = mono_lookup_internal_call (method);
-                       runtime_method->func = mono_arch_create_trampoline (mono_method_signature (method), method->string_ctor);
-               } 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);
-                               } 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_mutex_unlock(&calc_section);
-                       mono_profiler_method_end_jit (method, MONO_PROFILE_OK);
-                       return NULL;
-               }
-               method = nm;
-               header = mono_method_get_header (nm);
-               mono_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 (!(class->flags & TYPE_ATTRIBUTE_INTERFACE) && class->interface_offsets != NULL)
-                                       mono_class_vtable (domain, class);
-                       }
-                       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);
-                                       return mono_get_exception_missing_method ();
-                               }
-                               mono_class_init (m->klass);
-                               if (!(m->klass->flags & TYPE_ATTRIBUTE_INTERFACE))
-                                       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 ();
-               }
-       }
-
-       /* the rest needs to be locked so it is only done once */
-       mono_mutex_lock(&calc_section);
-       if (runtime_method->transformed) {
-               mono_mutex_unlock(&calc_section);
-               g_free (is_bb_start);
-               mono_profiler_method_end_jit (method, 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->param_count * sizeof(guint32));
-       for (i = 0; i < signature->param_count; ++i) {
-               if (signature->pinvoke) {
-                       size = mono_type_native_stack_size (signature->params [i], &align);
-                       align = 8;
-               }
-               else
-                       size = mono_type_stack_size (signature->params [i], &align);
-               offset += align - 1;
-               offset &= ~(align - 1);
-               runtime_method->arg_offsets [i] = 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, MONO_PROFILE_OK);
-       runtime_method->transformed = TRUE;
-       mono_mutex_unlock(&calc_section);
-
-       return NULL;
-}
-
index 394799bc86cf25f1cae52d9f289f1f4073541dc2..6b21f056ca26eef00e231f6fbbd461d8b5b4f36c 100755 (executable)
@@ -21,9 +21,9 @@
  * Declare as __GetProcessId for unsupported targets. */
 #define GetProcessId __GetProcessId
 #endif
-#include <winsock2.h>
 #include <windows.h>
 #include <winbase.h>
+#include <winsock2.h>
 /*
  * The mingw version says:
  * /usr/i686-pc-mingw32/sys-root/mingw/include/ws2tcpip.h:38:2: error: #error "ws2tcpip.h is not compatible with winsock.h. Include winsock2.h instead."
diff --git a/mono/metadata/Makefile.am b/mono/metadata/Makefile.am
new file mode 100644 (file)
index 0000000..bfa08c4
--- /dev/null
@@ -0,0 +1,345 @@
+if HOST_WIN32
+win32_sources = \
+       console-win32.c
+
+platform_sources = $(win32_sources)
+
+# Use -m here. This will use / as directory separator (C:/WINNT).
+# The files that use MONO_ASSEMBLIES and/or MONO_CFG_DIR replace the
+# / by \ if running under WIN32.
+if CROSS_COMPILING
+assembliesdir = ${libdir}
+confdir = ${sysconfdir}
+else
+assembliesdir = `cygpath -m "${libdir}"`
+confdir = `cygpath -m "${sysconfdir}"`
+endif
+export HOST_CC
+# The mingw math.h has "extern inline" functions that dont appear in libs, so
+# optimisation is required to actually inline them
+AM_CFLAGS = -O
+else
+
+assembliesdir = $(exec_prefix)/lib
+confdir = $(sysconfdir)
+unix_sources = \
+       console-unix.c
+
+platform_sources = $(unix_sources)
+endif
+
+if SHARED_MONO
+if SUPPORT_BOEHM
+bin_PROGRAMS = pedump
+endif
+endif
+
+#
+# libtool is not capable of creating static/shared versions of the same
+# convenience lib, so we have to do it ourselves
+#
+if SUPPORT_SGEN
+if DISABLE_EXECUTABLES
+shared_sgen_libraries = libmonoruntimesgen.la 
+else
+if SHARED_MONO
+shared_sgen_libraries = libmonoruntimesgen.la 
+endif
+endif
+sgen_libraries = $(shared_sgen_libraries) libmonoruntimesgen-static.la 
+endif
+
+if SUPPORT_BOEHM
+if DISABLE_EXECUTABLES
+shared_boehm_libraries = libmonoruntime.la
+else
+if SHARED_MONO
+shared_boehm_libraries = libmonoruntime.la
+endif
+endif
+boehm_libraries = $(shared_boehm_libraries) libmonoruntime-static.la
+endif
+
+if DISABLE_EXECUTABLES
+noinst_LTLIBRARIES = $(shared_sgen_libraries) $(shared_boehm_libraries)
+else
+noinst_LTLIBRARIES = $(boehm_libraries) $(sgen_libraries)
+endif
+
+AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/mono $(LIBGC_CPPFLAGS) $(GLIB_CFLAGS) -DMONO_BINDIR=\"$(bindir)/\" -DMONO_ASSEMBLIES=\"$(assembliesdir)\" -DMONO_CFG_DIR=\"$(confdir)\"
+
+#
+# Make sure any prefix changes are updated in the binaries too.
+#
+#  assembly.c uses MONO_ASSEMBLIES
+#  mono-config.c uses MONO_CFG_DIR
+#
+# This won't result in many more false positives than AC_DEFINEing them
+# in configure.ac.
+#
+assembly.lo mono-config.lo: Makefile
+
+CLEANFILES = mono-bundle.stamp
+
+libmonoruntime_static_la_LIBADD = $(bundle_obj) $(libmonoruntime_la_LIBADD)
+
+null_sources = \
+       console-null.c
+
+null_gc_sources = \
+       null-gc.c
+
+common_sources = \
+       $(platform_sources)     \
+       assembly.c              \
+       attach.h                \
+       attach.c                \
+       char-conversions.h      \
+       cil-coff.h              \
+       class.c                 \
+       class-internals.h       \
+       cominterop.c            \
+       cominterop.h            \
+       console-io.h            \
+       coree.c                 \
+       coree.h                 \
+       culture-info.h          \
+       culture-info-tables.h   \
+       debug-helpers.c         \
+       debug-mono-symfile.h    \
+       debug-mono-symfile.c    \
+       decimal.c               \
+       decimal.h               \
+       domain-internals.h      \
+       environment.c           \
+       environment.h           \
+       exception.c             \
+       exception.h             \
+       file-io.c               \
+       file-io.h               \
+       filewatcher.c           \
+       filewatcher.h           \
+       gc-internal.h           \
+       gc-memfuncs.c           \
+       icall.c                 \
+       icall-def.h             \
+       image.c                 \
+       loader.c                \
+       locales.c               \
+       locales.h               \
+       lock-tracer.c           \
+       lock-tracer.h           \
+       marshal.c               \
+       marshal.h               \
+       mempool.c               \
+       mempool.h               \
+       mempool-internals.h     \
+       metadata.c              \
+       metadata-verify.c       \
+       metadata-internals.h    \
+       method-builder.h        \
+       method-builder.c        \
+       mono-basic-block.c      \
+       mono-basic-block.h      \
+       mono-config.c           \
+       mono-cq.c               \
+       mono-cq.h               \
+       mono-debug.h            \
+       mono-debug.c            \
+       mono-debug-debugger.h   \
+       mono-debug-debugger.c   \
+       mono-endian.c           \
+       mono-endian.h           \
+       mono-hash.h             \
+       mono-mlist.c            \
+       mono-mlist.h            \
+       mono-perfcounters.c     \
+       mono-perfcounters.h     \
+       mono-perfcounters-def.h \
+       mono-ptr-array.h        \
+       mono-wsq.c              \
+       mono-wsq.h              \
+       monitor.h               \
+       nacl-stub.c             \
+       normalization-tables.h  \
+       number-formatter.h      \
+       object-internals.h      \
+       opcodes.c               \
+       socket-io.c             \
+       socket-io.h             \
+       process.c               \
+       process.h               \
+       profiler.c              \
+       profiler-private.h      \
+       rand.h                  \
+       rand.c                  \
+       runtime.c               \
+       security.c              \
+       security.h              \
+       security-core-clr.c     \
+       security-core-clr.h     \
+       security-manager.c      \
+       security-manager.h      \
+       string-icalls.c         \
+       string-icalls.h         \
+       sysmath.h               \
+       sysmath.c               \
+       tabledefs.h             \
+       threads.c               \
+       threads-types.h         \
+       threadpool.c            \
+       threadpool.h            \
+       threadpool-internals.h  \
+       verify.c                \
+       verify-internals.h      \
+       wrapper-types.h \
+       reflection-internals.h  \
+       file-mmap-posix.c       \
+       file-mmap-windows.c     \
+       file-mmap.h     \
+       object-offsets.h        \
+       abi-details.h   \
+       metadata-cross-helpers.c
+
+
+# These source files have compile time dependencies on GC code
+gc_dependent_sources = \
+       appdomain.c     \
+       domain.c        \
+       gc.c            \
+       monitor.c       \
+       mono-hash.c     \
+       object.c        \
+       reflection.c
+
+boehm_sources = \
+       boehm-gc.c
+
+sgen_sources = \
+       sgen-os-posix.c         \
+       sgen-os-mach.c          \
+       sgen-os-win32.c         \
+       sgen-gc.c               \
+       sgen-internal.c         \
+       sgen-marksweep.c        \
+       sgen-marksweep-fixed.c  \
+       sgen-marksweep-par.c    \
+       sgen-marksweep-fixed-par.c      \
+       sgen-los.c              \
+       sgen-protocol.c \
+       sgen-bridge.c           \
+       sgen-bridge.h           \
+       sgen-old-bridge.c               \
+       sgen-new-bridge.c               \
+       sgen-tarjan-bridge.c            \
+       sgen-toggleref.c                \
+       sgen-toggleref.h                \
+       sgen-gc.h               \
+       sgen-conf.h             \
+       sgen-archdep.h          \
+       sgen-cardtable.c        \
+       sgen-cardtable.h        \
+       sgen-pointer-queue.c    \
+       sgen-pointer-queue.h    \
+       sgen-pinning.c  \
+       sgen-pinning.h  \
+       sgen-pinning-stats.c    \
+       sgen-workers.c  \
+       sgen-workers.h  \
+       sgen-gray.c     \
+       sgen-gray.h     \
+       sgen-major-copy-object.h \
+       sgen-minor-copy-object.h \
+       sgen-copy-object.h \
+       sgen-major-scan-object.h \
+       sgen-minor-scan-object.h \
+       sgen-protocol.h         \
+       sgen-scan-object.h      \
+       sgen-nursery-allocator.c        \
+       sgen-hash-table.c       \
+       sgen-hash-table.h       \
+       sgen-descriptor.c               \
+       sgen-descriptor.h               \
+       sgen-alloc.c            \
+       sgen-debug.c            \
+       sgen-simple-nursery.c   \
+       sgen-split-nursery.c    \
+       sgen-memory-governor.c  \
+       sgen-memory-governor.h  \
+       sgen-stw.c                              \
+       sgen-fin-weak-hash.c    \
+       sgen-layout-stats.c     \
+       sgen-layout-stats.h     \
+       sgen-qsort.c    \
+       sgen-qsort.h
+
+libmonoruntime_la_SOURCES = $(common_sources) $(gc_dependent_sources) $(null_gc_sources) $(boehm_sources)
+libmonoruntime_la_CFLAGS = $(BOEHM_DEFINES)
+
+libmonoruntimesgen_la_SOURCES = $(common_sources) $(gc_dependent_sources) $(sgen_sources)
+libmonoruntimesgen_la_CFLAGS = $(SGEN_DEFINES)
+
+libmonoruntime_static_la_SOURCES = $(libmonoruntime_la_SOURCES)
+libmonoruntime_static_la_LDFLAGS = -static
+libmonoruntime_static_la_CFLAGS = $(BOEHM_DEFINES)
+
+libmonoruntimesgen_static_la_SOURCES = $(libmonoruntimesgen_la_SOURCES)
+libmonoruntimesgen_static_la_LDFLAGS = -static
+libmonoruntimesgen_static_la_CFLAGS = $(SGEN_DEFINES)
+
+libmonoruntimeincludedir = $(includedir)/mono-$(API_VER)/mono/metadata
+
+libmonoruntimeinclude_HEADERS = \
+       assembly.h              \
+       attrdefs.h              \
+       appdomain.h             \
+       blob.h                  \
+       class.h                 \
+       debug-helpers.h         \
+       debug-mono-symfile.h    \
+       threads.h               \
+       environment.h           \
+       exception.h             \
+       image.h                 \
+       loader.h                \
+       metadata.h              \
+       mono-config.h           \
+       mono-debug.h            \
+       mono-gc.h               \
+       sgen-bridge.h           \
+       object.h                \
+       opcodes.h               \
+       profiler.h              \
+       reflection.h            \
+       row-indexes.h           \
+       tokentype.h             \
+       verify.h                
+
+if DTRACE_G_REQUIRED
+
+PEDUMP_DTRACE_OBJECT = pedump-dtrace.$(OBJEXT)
+
+pedump-dtrace.$(OBJEXT): $(top_srcdir)/data/mono.d libmonoruntime.la ../io-layer/libwapi.la ../utils/libmonoutils.la
+       DTRACE="$(DTRACE)" DTRACEFLAGS="$(DTRACEFLAGS)" AR="$(AR)" $(SHELL) $(top_srcdir)/data/dtrace-prelink.sh \
+       --pic pedump-dtrace.$(OBJEXT) $(top_srcdir)/data/mono.d libmonoruntime.la ../io-layer/libwapi.la ../utils/libmonoutils.la
+
+else
+PEDUMP_DTRACE_OBJECT = 
+endif
+
+if SHARED_MONO
+if SUPPORT_BOEHM
+pedump_SOURCES =               \
+       pedump.c
+
+pedump_LDADD = libmonoruntime.la ../io-layer/libwapi.la ../utils/libmonoutils.la \
+       $(LIBGC_LIBS) $(GLIB_LIBS) -lm $(LIBICONV) $(PEDUMP_DTRACE_OBJECT)
+
+if PLATFORM_DARWIN
+pedump_LDFLAGS=-framework CoreFoundation -framework Foundation
+endif
+endif
+endif
+
+EXTRA_DIST = make-bundle.pl sample-bundle $(win32_sources) $(unix_sources) $(null_sources) runtime.h \
+               tpool-poll.c tpool-epoll.c tpool-kqueue.c
diff --git a/mono/metadata/Makefile.am.in b/mono/metadata/Makefile.am.in
deleted file mode 100644 (file)
index 731c05c..0000000
+++ /dev/null
@@ -1,349 +0,0 @@
-if HOST_WIN32
-win32_sources = \
-       console-win32.c
-
-platform_sources = $(win32_sources)
-
-# Use -m here. This will use / as directory separator (C:/WINNT).
-# The files that use MONO_ASSEMBLIES and/or MONO_CFG_DIR replace the
-# / by \ if running under WIN32.
-if CROSS_COMPILING
-assembliesdir = ${libdir}
-confdir = ${sysconfdir}
-else
-assembliesdir = `cygpath -m "${libdir}"`
-confdir = `cygpath -m "${sysconfdir}"`
-endif
-export HOST_CC
-# The mingw math.h has "extern inline" functions that dont appear in libs, so
-# optimisation is required to actually inline them
-AM_CFLAGS = -O
-else
-
-assembliesdir = $(exec_prefix)/lib
-confdir = $(sysconfdir)
-unix_sources = \
-       console-unix.c
-
-platform_sources = $(unix_sources)
-endif
-
-if SHARED_MONO
-if SUPPORT_BOEHM
-bin_PROGRAMS = pedump
-endif
-endif
-
-#
-# libtool is not capable of creating static/shared versions of the same
-# convenience lib, so we have to do it ourselves
-#
-if SUPPORT_SGEN
-if DISABLE_EXECUTABLES
-shared_sgen_libraries = libmonoruntimesgen.la 
-else
-if SHARED_MONO
-shared_sgen_libraries = libmonoruntimesgen.la 
-endif
-endif
-sgen_libraries = $(shared_sgen_libraries) libmonoruntimesgen-static.la 
-endif
-
-if SUPPORT_BOEHM
-if DISABLE_EXECUTABLES
-shared_boehm_libraries = libmonoruntime.la
-else
-if SHARED_MONO
-shared_boehm_libraries = libmonoruntime.la
-endif
-endif
-boehm_libraries = $(shared_boehm_libraries) libmonoruntime-static.la
-endif
-
-if DISABLE_EXECUTABLES
-noinst_LTLIBRARIES = $(shared_sgen_libraries) $(shared_boehm_libraries)
-else
-noinst_LTLIBRARIES = $(boehm_libraries) $(sgen_libraries)
-endif
-
-AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/mono $(LIBGC_CPPFLAGS) $(GLIB_CFLAGS) -DMONO_BINDIR=\"$(bindir)/\" -DMONO_ASSEMBLIES=\"$(assembliesdir)\" -DMONO_CFG_DIR=\"$(confdir)\"
-
-#
-# Make sure any prefix changes are updated in the binaries too.
-#
-#  assembly.c uses MONO_ASSEMBLIES
-#  mono-config.c uses MONO_CFG_DIR
-#
-# This won't result in many more false positives than AC_DEFINEing them
-# in configure.ac.
-#
-assembly.lo mono-config.lo: Makefile
-
-CLEANFILES = mono-bundle.stamp
-
-libmonoruntime_static_la_LIBADD = $(bundle_obj) $(libmonoruntime_la_LIBADD)
-
-null_sources = \
-       console-null.c
-
-null_gc_sources = \
-       null-gc.c
-
-common_sources = \
-       $(platform_sources)     \
-       assembly.c              \
-       attach.h                \
-       attach.c                \
-       char-conversions.h      \
-       cil-coff.h              \
-       class.c                 \
-       class-internals.h       \
-       cominterop.c            \
-       cominterop.h            \
-       console-io.h            \
-       coree.c                 \
-       coree.h                 \
-       culture-info.h          \
-       culture-info-tables.h   \
-       debug-helpers.c         \
-       debug-mono-symfile.h    \
-       debug-mono-symfile.c    \
-       decimal.c               \
-       decimal.h               \
-       domain-internals.h      \
-       environment.c           \
-       environment.h           \
-       exception.c             \
-       exception.h             \
-       file-io.c               \
-       file-io.h               \
-       filewatcher.c           \
-       filewatcher.h           \
-       gc-internal.h           \
-       gc-memfuncs.c           \
-       icall.c                 \
-       icall-def.h             \
-       image.c                 \
-       loader.c                \
-       locales.c               \
-       locales.h               \
-       lock-tracer.c           \
-       lock-tracer.h           \
-       marshal.c               \
-       marshal.h               \
-       mempool.c               \
-       mempool.h               \
-       mempool-internals.h     \
-       metadata.c              \
-       metadata-verify.c       \
-       metadata-internals.h    \
-       method-builder.h        \
-       method-builder.c        \
-       mono-basic-block.c      \
-       mono-basic-block.h      \
-       mono-config.c           \
-       mono-cq.c               \
-       mono-cq.h               \
-       mono-debug.h            \
-       mono-debug.c            \
-       mono-debug-debugger.h   \
-       mono-debug-debugger.c   \
-       mono-endian.c           \
-       mono-endian.h           \
-       mono-hash.h             \
-       mono-mlist.c            \
-       mono-mlist.h            \
-       mono-perfcounters.c     \
-       mono-perfcounters.h     \
-       mono-perfcounters-def.h \
-       mono-ptr-array.h        \
-       mono-wsq.c              \
-       mono-wsq.h              \
-       monitor.h               \
-       nacl-stub.c             \
-       normalization-tables.h  \
-       number-formatter.h      \
-       object-internals.h      \
-       opcodes.c               \
-       socket-io.c             \
-       socket-io.h             \
-       process.c               \
-       process.h               \
-       profiler.c              \
-       profiler-private.h      \
-       rand.h                  \
-       rand.c                  \
-       runtime.c               \
-       security.c              \
-       security.h              \
-       security-core-clr.c     \
-       security-core-clr.h     \
-       security-manager.c      \
-       security-manager.h      \
-       string-icalls.c         \
-       string-icalls.h         \
-       sysmath.h               \
-       sysmath.c               \
-       tabledefs.h             \
-       threads.c               \
-       threads-types.h         \
-       threadpool.c            \
-       threadpool.h            \
-       threadpool-internals.h  \
-       verify.c                \
-       verify-internals.h      \
-       wrapper-types.h \
-       reflection-internals.h  \
-       file-mmap-posix.c       \
-       file-mmap-windows.c     \
-       file-mmap.h     \
-       object-offsets.h        \
-       abi-details.h   \
-       metadata-cross-helpers.c
-
-
-# These source files have compile time dependencies on GC code
-gc_dependent_sources = \
-       appdomain.c     \
-       domain.c        \
-       gc.c            \
-       monitor.c       \
-       mono-hash.c     \
-       object.c        \
-       reflection.c
-
-boehm_sources = \
-       boehm-gc.c
-
-sgen_sources = \
-       sgen-os-posix.c         \
-       sgen-os-mach.c          \
-       sgen-os-win32.c         \
-       sgen-gc.c               \
-       sgen-internal.c         \
-       sgen-marksweep.c        \
-       sgen-marksweep-fixed.c  \
-       sgen-marksweep-par.c    \
-       sgen-marksweep-fixed-par.c      \
-       sgen-los.c              \
-       sgen-protocol.c \
-       sgen-bridge.c           \
-       sgen-bridge.h           \
-       sgen-old-bridge.c               \
-       sgen-new-bridge.c               \
-       sgen-tarjan-bridge.c            \
-       sgen-toggleref.c                \
-       sgen-toggleref.h                \
-       sgen-gc.h               \
-       sgen-conf.h             \
-       sgen-archdep.h          \
-       sgen-cardtable.c        \
-       sgen-cardtable.h        \
-       sgen-pinning.c  \
-       sgen-pinning.h  \
-       sgen-pinning-stats.c    \
-       sgen-workers.c  \
-       sgen-workers.h  \
-       sgen-gray.c     \
-       sgen-gray.h     \
-       sgen-major-copy-object.h \
-       sgen-minor-copy-object.h \
-       sgen-copy-object.h \
-       sgen-major-scan-object.h \
-       sgen-minor-scan-object.h \
-       sgen-protocol.h         \
-       sgen-scan-object.h      \
-       sgen-nursery-allocator.c        \
-       sgen-hash-table.c       \
-       sgen-hash-table.h       \
-       sgen-descriptor.c               \
-       sgen-descriptor.h               \
-       sgen-alloc.c            \
-       sgen-debug.c            \
-       sgen-simple-nursery.c   \
-       sgen-split-nursery.c    \
-       sgen-memory-governor.c  \
-       sgen-memory-governor.h  \
-       sgen-stw.c                              \
-       sgen-fin-weak-hash.c    \
-       sgen-layout-stats.c     \
-       sgen-layout-stats.h     \
-       sgen-qsort.c    \
-       sgen-qsort.h
-
-libmonoruntime_la_SOURCES = $(common_sources) $(gc_dependent_sources) $(null_gc_sources) $(boehm_sources)
-libmonoruntime_la_CFLAGS = $(BOEHM_DEFINES)
-
-libmonoruntimesgen_la_SOURCES = $(common_sources) $(gc_dependent_sources) $(sgen_sources)
-libmonoruntimesgen_la_CFLAGS = $(SGEN_DEFINES)
-
-libmonoruntime_static_la_SOURCES = $(libmonoruntime_la_SOURCES)
-libmonoruntime_static_la_LDFLAGS = -static
-libmonoruntime_static_la_CFLAGS = $(BOEHM_DEFINES)
-
-libmonoruntimesgen_static_la_SOURCES = $(libmonoruntimesgen_la_SOURCES)
-libmonoruntimesgen_static_la_LDFLAGS = -static
-libmonoruntimesgen_static_la_CFLAGS = $(SGEN_DEFINES)
-
-libmonoruntimeincludedir = $(includedir)/mono-$(API_VER)/mono/metadata
-
-libmonoruntimeinclude_HEADERS = \
-       assembly.h              \
-       attrdefs.h              \
-       appdomain.h             \
-       blob.h                  \
-       class.h                 \
-       debug-helpers.h         \
-       debug-mono-symfile.h    \
-       threads.h               \
-       environment.h           \
-       exception.h             \
-       image.h                 \
-       loader.h                \
-       metadata.h              \
-       mono-config.h           \
-       mono-debug.h            \
-       mono-gc.h               \
-       sgen-bridge.h           \
-       object.h                \
-       opcodes.h               \
-       profiler.h              \
-       reflection.h            \
-       row-indexes.h           \
-       tokentype.h             \
-       verify.h                
-
-if DTRACE_G_REQUIRED
-
-PEDUMP_DTRACE_OBJECT = pedump-dtrace.$(OBJEXT)
-
-pedump-dtrace.$(OBJEXT): $(top_srcdir)/data/mono.d libmonoruntime.la ../io-layer/libwapi.la ../utils/libmonoutils.la
-       DTRACE="$(DTRACE)" DTRACEFLAGS="$(DTRACEFLAGS)" AR="$(AR)" $(SHELL) $(top_srcdir)/data/dtrace-prelink.sh \
-       --pic pedump-dtrace.$(OBJEXT) $(top_srcdir)/data/mono.d libmonoruntime.la ../io-layer/libwapi.la ../utils/libmonoutils.la
-
-else
-PEDUMP_DTRACE_OBJECT = 
-endif
-
-if SHARED_MONO
-if SUPPORT_BOEHM
-pedump_SOURCES =               \
-       pedump.c
-
-pedump_LDADD = libmonoruntime.la ../io-layer/libwapi.la ../utils/libmonoutils.la \
-       $(LIBGC_LIBS) $(GLIB_LIBS) -lm $(LIBICONV) $(PEDUMP_DTRACE_OBJECT)
-
-if PLATFORM_DARWIN
-pedump_LDFLAGS=-framework CoreFoundation -framework Foundation
-endif
-endif
-endif
-
-EXTRA_DIST = make-bundle.pl sample-bundle $(win32_sources) $(unix_sources) $(null_sources) runtime.h \
-               tpool-poll.c tpool-epoll.c tpool-kqueue.c Makefile.am.in
-
-if HAS_EXTENSION_MODULE
-else
-Makefile.am: Makefile.am.in
-       cp $< $@
-endif
index d438803266c9de14353e3f53d8573be775264e57..21e026a59d399e0134500d12394acbbca32bdfb4 100644 (file)
@@ -52,6 +52,9 @@ gboolean mono_print_vtable = FALSE;
 guint32 inflated_classes, inflated_classes_size, inflated_methods_size;
 guint32 classes_size, class_ext_size;
 
+/* Low level lock which protects data structures in this module */
+static mono_mutex_t classes_mutex;
+
 /* Function supplied by the runtime to find classes by name using information from the AOT file */
 static MonoGetClassFromName get_class_from_name = NULL;
 
@@ -100,6 +103,18 @@ static int record_gclass_instantiation;
 static GSList *gclass_recorded_list;
 typedef gboolean (*gclass_record_func) (MonoClass*, void*);
 
+static inline void
+classes_lock (void)
+{
+       mono_locks_acquire (&classes_mutex, ClassesLock);
+}
+
+static inline void
+classes_unlock (void)
+{
+       mono_locks_release (&classes_mutex, ClassesLock);
+}
+
 /* 
  * LOCKING: loader lock must be held until pairing disable_gclass_recording is called.
 */
@@ -2030,7 +2045,7 @@ create_array_method (MonoClass *class, const char *name, MonoMethodSignature *si
  * mono_class_setup_methods:
  * @class: a class
  *
- *   Initializes the 'methods' array in the klass.
+ *   Initializes the 'methods' array in CLASS.
  * Calling this method should be avoided if possible since it allocates a lot 
  * of long-living MonoMethod structures.
  * Methods belonging to an interface are assigned a sequential slot starting
@@ -2041,19 +2056,12 @@ create_array_method (MonoClass *class, const char *name, MonoMethodSignature *si
 void
 mono_class_setup_methods (MonoClass *class)
 {
-       int i;
+       int i, count;
        MonoMethod **methods;
 
        if (class->methods)
                return;
 
-       mono_loader_lock ();
-
-       if (class->methods) {
-               mono_loader_unlock ();
-               return;
-       }
-
        if (class->generic_class) {
                MonoError error;
                MonoClass *gklass = class->generic_class->container_class;
@@ -2062,17 +2070,16 @@ mono_class_setup_methods (MonoClass *class)
                if (!gklass->exception_type)
                        mono_class_setup_methods (gklass);
                if (gklass->exception_type) {
-                       /*FIXME make exception_data less opaque so it's possible to dup it here*/
+                       /* FIXME make exception_data less opaque so it's possible to dup it here */
                        mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
-                       mono_loader_unlock ();
                        return;
                }
 
                /* The + 1 makes this always non-NULL to pass the check in mono_class_setup_methods () */
-               class->method.count = gklass->method.count;
-               methods = mono_class_alloc0 (class, sizeof (MonoMethod*) * (class->method.count + 1));
+               count = gklass->method.count;
+               methods = mono_class_alloc0 (class, sizeof (MonoMethod*) * (count + 1));
 
-               for (i = 0; i < class->method.count; i++) {
+               for (i = 0; i < count; i++) {
                        methods [i] = mono_class_inflate_generic_method_full_checked (
                                gklass->methods [i], class, mono_class_get_context (class), &error);
                        if (!mono_error_ok (&error)) {
@@ -2081,7 +2088,6 @@ mono_class_setup_methods (MonoClass *class)
 
                                g_free (method);
                                mono_error_cleanup (&error);
-                               mono_loader_unlock ();
                                return;                         
                        }
                }
@@ -2092,18 +2098,18 @@ mono_class_setup_methods (MonoClass *class)
                int count_generic = 0, first_generic = 0;
                int method_num = 0;
 
-               class->method.count = 3 + (class->rank > 1? 2: 1);
+               count = 3 + (class->rank > 1? 2: 1);
 
                mono_class_setup_interfaces (class, &error);
                g_assert (mono_error_ok (&error)); /*FIXME can this fail for array types?*/
 
                if (class->interface_count) {
                        count_generic = generic_array_methods (class);
-                       first_generic = class->method.count;
-                       class->method.count += class->interface_count * count_generic;
+                       first_generic = count;
+                       count += class->interface_count * count_generic;
                }
 
-               methods = mono_class_alloc0 (class, sizeof (MonoMethod*) * class->method.count);
+               methods = mono_class_alloc0 (class, sizeof (MonoMethod*) * count);
 
                sig = mono_metadata_signature_alloc (class->image, class->rank);
                sig->ret = &mono_defaults.void_class->byval_arg;
@@ -2157,8 +2163,9 @@ mono_class_setup_methods (MonoClass *class)
                for (i = 0; i < class->interface_count; i++)
                        setup_generic_array_ifaces (class, class->interfaces [i], methods, first_generic + i * count_generic);
        } else {
-               methods = mono_class_alloc (class, sizeof (MonoMethod*) * class->method.count);
-               for (i = 0; i < class->method.count; ++i) {
+               count = class->method.count;
+               methods = mono_class_alloc (class, sizeof (MonoMethod*) * count);
+               for (i = 0; i < count; ++i) {
                        int idx = mono_metadata_translate_token_index (class->image, MONO_TABLE_METHOD, class->method.first + i + 1);
                        methods [i] = mono_get_method (class->image, MONO_TOKEN_METHOD_DEF | idx, class);
                }
@@ -2167,18 +2174,24 @@ mono_class_setup_methods (MonoClass *class)
        if (MONO_CLASS_IS_INTERFACE (class)) {
                int slot = 0;
                /*Only assign slots to virtual methods as interfaces are allowed to have static methods.*/
-               for (i = 0; i < class->method.count; ++i) {
+               for (i = 0; i < count; ++i) {
                        if (methods [i]->flags & METHOD_ATTRIBUTE_VIRTUAL)
                                methods [i]->slot = slot++;
                }
        }
 
-       /* Needed because of the double-checking locking pattern */
-       mono_memory_barrier ();
+       mono_image_lock (class->image);
 
-       class->methods = methods;
+       if (!class->methods) {
+               class->method.count = count;
 
-       mono_loader_unlock ();
+               /* Needed because of the double-checking locking pattern */
+               mono_memory_barrier ();
+
+               class->methods = methods;
+       }
+
+       mono_image_unlock (class->image);
 }
 
 /*
@@ -2296,7 +2309,13 @@ mono_class_get_vtable_size (MonoClass *klass)
        return klass->vtable_size;
 }
 
-/*This method can fail the class.*/
+/*
+ * mono_class_setup_properties:
+ *
+ *   Initialize class->ext.property and class->ext.properties.
+ *
+ * This method can fail the class.
+ */
 static void
 mono_class_setup_properties (MonoClass *class)
 {
@@ -2305,19 +2324,11 @@ mono_class_setup_properties (MonoClass *class)
        MonoTableInfo *msemt = &class->image->tables [MONO_TABLE_METHODSEMANTICS];
        MonoProperty *properties;
        guint32 last;
+       int first, count;
 
        if (class->ext && class->ext->properties)
                return;
 
-       mono_loader_lock ();
-
-       if (class->ext && class->ext->properties) {
-               mono_loader_unlock ();
-               return;
-       }
-
-       mono_class_alloc_ext (class);
-
        if (class->generic_class) {
                MonoClass *gklass = class->generic_class->container_class;
 
@@ -2325,15 +2336,12 @@ mono_class_setup_properties (MonoClass *class)
                mono_class_setup_properties (gklass);
                if (gklass->exception_type) {
                        mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
-                       mono_loader_unlock ();                  
                        return;
                }
 
-               class->ext->property = gklass->ext->property;
-
-               properties = mono_class_new0 (class, MonoProperty, class->ext->property.count + 1);
+               properties = mono_class_new0 (class, MonoProperty, gklass->ext->property.count + 1);
 
-               for (i = 0; i < class->ext->property.count; i++) {
+               for (i = 0; i < gklass->ext->property.count; i++) {
                        MonoProperty *prop = &properties [i];
 
                        *prop = gklass->ext->properties [i];
@@ -2347,20 +2355,19 @@ mono_class_setup_properties (MonoClass *class)
 
                        prop->parent = class;
                }
+
+               first = gklass->ext->property.first;
+               count = gklass->ext->property.count;
        } else {
-               int first = mono_metadata_properties_from_typedef (class->image, mono_metadata_token_index (class->type_token) - 1, &last);
-               int count = last - first;
+               first = mono_metadata_properties_from_typedef (class->image, mono_metadata_token_index (class->type_token) - 1, &last);
+               count = last - first;
 
                if (count) {
                        mono_class_setup_methods (class);
-                       if (class->exception_type) {
-                               mono_loader_unlock ();
+                       if (class->exception_type)
                                return;
-                       }
                }
 
-               class->ext->property.first = first;
-               class->ext->property.count = count;
                properties = mono_class_alloc0 (class, sizeof (MonoProperty) * count);
                for (i = first; i < last; ++i) {
                        mono_metadata_decode_table_row (class->image, MONO_TABLE_PROPERTY, i, cols, MONO_PROPERTY_SIZE);
@@ -2393,13 +2400,27 @@ mono_class_setup_properties (MonoClass *class)
                        }
                }
        }
-       /*Flush any pending writes as we do double checked locking on class->properties */
+
+       mono_class_alloc_ext (class);
+
+       mono_image_lock (class->image);
+
+       if (class->ext->properties) {
+               /* We leak 'properties' which was allocated from the image mempool */
+               mono_image_unlock (class->image);
+               return;
+       }
+
+       class->ext->property.first = first;
+       class->ext->property.count = count;
+
+       /* Flush any pending writes as we do double checked locking on class->ext->properties */
        mono_memory_barrier ();
 
        /* Leave this assignment as the last op in the function */
        class->ext->properties = properties;
 
-       mono_loader_unlock ();
+       mono_image_unlock (class->image);
 }
 
 static MonoMethod**
@@ -2433,15 +2454,6 @@ mono_class_setup_events (MonoClass *class)
        if (class->ext && class->ext->events)
                return;
 
-       mono_loader_lock ();
-
-       if (class->ext && class->ext->events) {
-               mono_loader_unlock ();
-               return;
-       }
-
-       mono_class_alloc_ext (class);
-
        if (class->generic_class) {
                MonoClass *gklass = class->generic_class->container_class;
                MonoGenericContext *context;
@@ -2449,18 +2461,19 @@ mono_class_setup_events (MonoClass *class)
                mono_class_setup_events (gklass);
                if (gklass->exception_type) {
                        mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
-                       mono_loader_unlock ();
                        return;
                }
 
-               class->ext->event = gklass->ext->event;
-               class->ext->events = mono_class_new0 (class, MonoEvent, class->ext->event.count);
+               first = gklass->ext->event.first;
+               count = gklass->ext->event.count;
 
-               if (class->ext->event.count)
+               events = mono_class_new0 (class, MonoEvent, count);
+
+               if (count)
                        context = mono_class_get_context (class);
 
-               for (i = 0; i < class->ext->event.count; i++) {
-                       MonoEvent *event = &class->ext->events [i];
+               for (i = 0; i < count; i++) {
+                       MonoEvent *event = &events [i];
                        MonoEvent *gevent = &gklass->ext->events [i];
 
                        event->parent = class;
@@ -2473,89 +2486,97 @@ mono_class_setup_events (MonoClass *class)
 #endif
                        event->attrs = gevent->attrs;
                }
+       } else {
+               first = mono_metadata_events_from_typedef (class->image, mono_metadata_token_index (class->type_token) - 1, &last);
+               count = last - first;
 
-               mono_loader_unlock ();
-               return;
-       }
-
-       first = mono_metadata_events_from_typedef (class->image, mono_metadata_token_index (class->type_token) - 1, &last);
-       count = last - first;
-
-       if (count) {
-               mono_class_setup_methods (class);
-               if (class->exception_type) {
-                       mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
-                       mono_loader_unlock ();
-                       return;
+               if (count) {
+                       mono_class_setup_methods (class);
+                       if (class->exception_type) {
+                               mono_class_set_failure (class, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Generic type definition failed to load"));
+                               return;
+                       }
                }
-       }
-       class->ext->event.first = first;
-       class->ext->event.count = count;
-       events = mono_class_alloc0 (class, sizeof (MonoEvent) * class->ext->event.count);
-       for (i = first; i < last; ++i) {
-               MonoEvent *event = &events [i - first];
 
-               mono_metadata_decode_table_row (class->image, MONO_TABLE_EVENT, i, cols, MONO_EVENT_SIZE);
-               event->parent = class;
-               event->attrs = cols [MONO_EVENT_FLAGS];
-               event->name = mono_metadata_string_heap (class->image, cols [MONO_EVENT_NAME]);
+               events = mono_class_alloc0 (class, sizeof (MonoEvent) * count);
+               for (i = first; i < last; ++i) {
+                       MonoEvent *event = &events [i - first];
 
-               startm = mono_metadata_methods_from_event (class->image, i, &endm);
-               for (j = startm; j < endm; ++j) {
-                       MonoMethod *method;
+                       mono_metadata_decode_table_row (class->image, MONO_TABLE_EVENT, i, cols, MONO_EVENT_SIZE);
+                       event->parent = class;
+                       event->attrs = cols [MONO_EVENT_FLAGS];
+                       event->name = mono_metadata_string_heap (class->image, cols [MONO_EVENT_NAME]);
 
-                       mono_metadata_decode_row (msemt, j, cols, MONO_METHOD_SEMA_SIZE);
+                       startm = mono_metadata_methods_from_event (class->image, i, &endm);
+                       for (j = startm; j < endm; ++j) {
+                               MonoMethod *method;
 
-                       if (class->image->uncompressed_metadata)
-                               /* It seems like the MONO_METHOD_SEMA_METHOD column needs no remapping */
-                               method = mono_get_method (class->image, MONO_TOKEN_METHOD_DEF | cols [MONO_METHOD_SEMA_METHOD], class);
-                       else
-                               method = class->methods [cols [MONO_METHOD_SEMA_METHOD] - 1 - class->method.first];
+                               mono_metadata_decode_row (msemt, j, cols, MONO_METHOD_SEMA_SIZE);
 
-                       switch (cols [MONO_METHOD_SEMA_SEMANTICS]) {
-                       case METHOD_SEMANTIC_ADD_ON:
-                               event->add = method;
-                               break;
-                       case METHOD_SEMANTIC_REMOVE_ON:
-                               event->remove = method;
-                               break;
-                       case METHOD_SEMANTIC_FIRE:
-                               event->raise = method;
-                               break;
-                       case METHOD_SEMANTIC_OTHER: {
+                               if (class->image->uncompressed_metadata)
+                                       /* It seems like the MONO_METHOD_SEMA_METHOD column needs no remapping */
+                                       method = mono_get_method (class->image, MONO_TOKEN_METHOD_DEF | cols [MONO_METHOD_SEMA_METHOD], class);
+                               else
+                                       method = class->methods [cols [MONO_METHOD_SEMA_METHOD] - 1 - class->method.first];
+
+                               switch (cols [MONO_METHOD_SEMA_SEMANTICS]) {
+                               case METHOD_SEMANTIC_ADD_ON:
+                                       event->add = method;
+                                       break;
+                               case METHOD_SEMANTIC_REMOVE_ON:
+                                       event->remove = method;
+                                       break;
+                               case METHOD_SEMANTIC_FIRE:
+                                       event->raise = method;
+                                       break;
+                               case METHOD_SEMANTIC_OTHER: {
 #ifndef MONO_SMALL_CONFIG
-                               int n = 0;
-
-                               if (event->other == NULL) {
-                                       event->other = g_new0 (MonoMethod*, 2);
-                               } else {
-                                       while (event->other [n])
-                                               n++;
-                                       event->other = g_realloc (event->other, (n + 2) * sizeof (MonoMethod*));
-                               }
-                               event->other [n] = method;
-                               /* NULL terminated */
-                               event->other [n + 1] = NULL;
+                                       int n = 0;
+
+                                       if (event->other == NULL) {
+                                               event->other = g_new0 (MonoMethod*, 2);
+                                       } else {
+                                               while (event->other [n])
+                                                       n++;
+                                               event->other = g_realloc (event->other, (n + 2) * sizeof (MonoMethod*));
+                                       }
+                                       event->other [n] = method;
+                                       /* NULL terminated */
+                                       event->other [n + 1] = NULL;
 #endif
-                               break;
-                       }
-                       default:
-                               break;
+                                       break;
+                               }
+                               default:
+                                       break;
+                               }
                        }
                }
        }
-       /*Flush any pending writes as we do double checked locking on class->properties */
+
+       mono_class_alloc_ext (class);
+
+       mono_image_lock (class->image);
+
+       if (class->ext->events) {
+               mono_image_unlock (class->image);
+               return;
+       }
+
+       class->ext->event.first = first;
+       class->ext->event.count = count;
+
+       /* Flush any pending writes as we do double checked locking on class->ext.events */
        mono_memory_barrier ();
 
        /* Leave this assignment as the last op in the function */
        class->ext->events = events;
 
-       mono_loader_unlock ();
+       mono_image_unlock (class->image);
 }
 
 /*
  * Global pool of interface IDs, represented as a bitset.
- * LOCKING: this is supposed to be accessed with the loader lock held.
+ * LOCKING: Protected by the classes lock.
  */
 static MonoBitSet *global_interface_bitset = NULL;
 
@@ -2570,18 +2591,18 @@ static MonoBitSet *global_interface_bitset = NULL;
 void
 mono_unload_interface_ids (MonoBitSet *bitset)
 {
-       mono_loader_lock ();
+       classes_lock ();
        mono_bitset_sub (global_interface_bitset, bitset);
-       mono_loader_unlock ();
+       classes_unlock ();
 }
 
 void
 mono_unload_interface_id (MonoClass *class)
 {
        if (global_interface_bitset && class->interface_id) {
-               mono_loader_lock ();
+               classes_lock ();
                mono_bitset_clear (global_interface_bitset, class->interface_id);
-               mono_loader_unlock ();
+               classes_unlock ();
        }
 }
 
@@ -2591,7 +2612,7 @@ mono_unload_interface_id (MonoClass *class)
  *
  * Assign a unique integer ID to the interface represented by @class.
  * The ID will positive and as small as possible.
- * LOCKING: this is supposed to be called with the loader lock held.
+ * LOCKING: Acquires the classes lock.
  * Returns: the new ID.
  */
 static guint
@@ -2601,6 +2622,8 @@ mono_get_unique_iid (MonoClass *class)
        
        g_assert (MONO_CLASS_IS_INTERFACE (class));
 
+       classes_lock ();
+
        if (!global_interface_bitset) {
                global_interface_bitset = mono_bitset_new (128, 0);
        }
@@ -2628,6 +2651,8 @@ mono_get_unique_iid (MonoClass *class)
                mono_bitset_set (class->image->interface_bitset, iid);
        }
 
+       classes_unlock ();
+
 #ifndef MONO_SMALL_CONFIG
        if (mono_print_vtable) {
                int generic_id;
@@ -5060,14 +5085,11 @@ mono_class_init (MonoClass *class)
                } else {
                        class->vtable_size = szarray_vtable_size[slot];
                }
-               class->has_finalize_inited = TRUE;
        } else if (class->generic_class && !MONO_CLASS_IS_INTERFACE (class)) {
                MonoClass *gklass = class->generic_class->container_class;
 
                /* Generic instance case */
                class->ghcimpl = gklass->ghcimpl;
-               class->has_finalize = mono_class_has_finalizer (gklass);
-               class->has_finalize_inited = TRUE;
                class->has_cctor = gklass->has_cctor;
 
                mono_class_setup_vtable (gklass);
@@ -5184,55 +5206,61 @@ mono_class_init (MonoClass *class)
 gboolean
 mono_class_has_finalizer (MonoClass *klass)
 {
-       if (!klass->has_finalize_inited) {
-               MonoClass *class = klass;
+       MonoClass *class = klass;
+       gboolean has_finalize = FALSE;
 
-               mono_loader_lock ();
+       if (klass->has_finalize_inited)
+               return klass->has_finalize;
 
-               /* Interfaces and valuetypes are not supposed to have finalizers */
-               if (!(MONO_CLASS_IS_INTERFACE (class) || class->valuetype)) {
-                       MonoMethod *cmethod = NULL;
+       /* Interfaces and valuetypes are not supposed to have finalizers */
+       if (!(MONO_CLASS_IS_INTERFACE (class) || class->valuetype)) {
+               MonoMethod *cmethod = NULL;
 
-                       if (class->parent && class->parent->has_finalize) {
-                               class->has_finalize = 1;
-                       } else {
-                               if (class->parent) {
-                                       /*
-                                        * Can't search in metadata for a method named Finalize, because that
-                                        * ignores overrides.
-                                        */
-                                       mono_class_setup_vtable (class);
-                                       if (class->exception_type || mono_loader_get_last_error ())
-                                               goto leave;
+               if (class->rank == 1 && class->byval_arg.type == MONO_TYPE_SZARRAY) {
+               } else if (class->generic_class) {
+                       MonoClass *gklass = class->generic_class->container_class;
+
+                       has_finalize = mono_class_has_finalizer (gklass);
+               } else if (class->parent && class->parent->has_finalize) {
+                       has_finalize = TRUE;
+               } else {
+                       if (class->parent) {
+                               /*
+                                * Can't search in metadata for a method named Finalize, because that
+                                * ignores overrides.
+                                */
+                               mono_class_setup_vtable (class);
+                               if (class->exception_type || mono_loader_get_last_error ())
+                                       cmethod = NULL;
+                               else
                                        cmethod = class->vtable [finalize_slot];
-                               }
+                       }
 
-                               if (cmethod) {
-                                       g_assert (class->vtable_size > finalize_slot);
+                       if (cmethod) {
+                               g_assert (class->vtable_size > finalize_slot);
 
-                                       class->has_finalize = 0;
-                                       if (class->parent) { 
-                                               if (cmethod->is_inflated)
-                                                       cmethod = ((MonoMethodInflated*)cmethod)->declaring;
-                                               if (cmethod != default_finalize) {
-                                                       class->has_finalize = 1;
-                                               }
-                                       }
+                               if (class->parent) {
+                                       if (cmethod->is_inflated)
+                                               cmethod = ((MonoMethodInflated*)cmethod)->declaring;
+                                       if (cmethod != default_finalize)
+                                               has_finalize = TRUE;
                                }
                        }
                }
+       }
+
+       mono_image_lock (klass->image);
+
+       if (!klass->has_finalize_inited) {
+               klass->has_finalize = has_finalize ? 1 : 0;
 
                mono_memory_barrier ();
                klass->has_finalize_inited = TRUE;
-
-               mono_loader_unlock ();
        }
 
-       return klass->has_finalize;
+       mono_image_unlock (klass->image);
 
- leave:
-       mono_loader_unlock ();
-       return FALSE;
+       return klass->has_finalize;
 }
 
 gboolean
@@ -6075,7 +6103,7 @@ set_anon_gparam_class (MonoGenericParam *param, gboolean is_mvar, MonoClass *kla
        }
        ht = is_mvar ? image->mvar_cache_slow : image->var_cache_slow;
        if (!ht) {
-               mono_loader_lock ();
+               mono_image_lock (image);
                ht = is_mvar ? image->mvar_cache_slow : image->var_cache_slow;
                if (!ht) {
                        ht = g_hash_table_new (NULL, NULL);
@@ -6085,7 +6113,7 @@ set_anon_gparam_class (MonoGenericParam *param, gboolean is_mvar, MonoClass *kla
                        else
                                image->var_cache_slow = ht;
                }
-               mono_loader_unlock ();
+               mono_image_unlock (image);
        }
 
        g_hash_table_insert (ht, GINT_TO_POINTER (n), klass);
@@ -6837,11 +6865,17 @@ mono_class_get_field_default_value (MonoClassField *field, MonoTypeEnum *def_typ
        g_assert (field->type->attrs & FIELD_ATTRIBUTE_HAS_DEFAULT);
 
        if (!klass->ext || !klass->ext->field_def_values) {
-               mono_loader_lock ();
+               MonoFieldDefaultValue *def_values;
+
                mono_class_alloc_ext (klass);
+
+               def_values = mono_class_alloc0 (klass, sizeof (MonoFieldDefaultValue) * klass->field.count);
+
+               mono_image_lock (klass->image);
+               mono_memory_barrier ();
                if (!klass->ext->field_def_values)
-                       klass->ext->field_def_values = mono_class_alloc0 (klass, sizeof (MonoFieldDefaultValue) * klass->field.count);
-               mono_loader_unlock ();
+                       klass->ext->field_def_values = def_values;
+               mono_image_unlock (klass->image);
        }
 
        field_index = mono_field_get_index (field);
@@ -8878,6 +8912,58 @@ mono_class_get_interfaces (MonoClass* klass, gpointer *iter)
        return NULL;
 }
 
+static void
+setup_nested_types (MonoClass *klass)
+{
+       MonoError error;
+       GList *classes, *nested_classes, *l;
+       int i;
+
+       if (klass->nested_classes_inited)
+               return;
+
+       if (!klass->type_token)
+               klass->nested_classes_inited = TRUE;
+
+       i = mono_metadata_nesting_typedef (klass->image, klass->type_token, 1);
+       classes = NULL;
+       while (i) {
+               MonoClass* nclass;
+               guint32 cols [MONO_NESTED_CLASS_SIZE];
+               mono_metadata_decode_row (&klass->image->tables [MONO_TABLE_NESTEDCLASS], i - 1, cols, MONO_NESTED_CLASS_SIZE);
+               nclass = mono_class_create_from_typedef (klass->image, MONO_TOKEN_TYPE_DEF | cols [MONO_NESTED_CLASS_NESTED], &error);
+               if (!mono_error_ok (&error)) {
+                       /*FIXME don't swallow the error message*/
+                       mono_error_cleanup (&error);
+
+                       i = mono_metadata_nesting_typedef (klass->image, klass->type_token, i + 1);
+                       continue;
+               }
+
+               classes = g_list_prepend (classes, nclass);
+
+               i = mono_metadata_nesting_typedef (klass->image, klass->type_token, i + 1);
+       }
+
+       mono_class_alloc_ext (klass);
+
+       nested_classes = NULL;
+       for (l = classes; l; l = l->next)
+               nested_classes = g_list_prepend_image (klass->image, nested_classes, l->data);
+       g_list_free (classes);
+
+       mono_image_lock (klass->image);
+
+       mono_memory_barrier ();
+       if (!klass->nested_classes_inited) {
+               klass->ext->nested_classes = nested_classes;
+               mono_memory_barrier ();
+               klass->nested_classes_inited = TRUE;
+       }
+
+       mono_image_unlock (klass->image);
+}
+
 /**
  * mono_class_get_nested_types
  * @klass: the MonoClass to act on
@@ -8894,40 +8980,12 @@ mono_class_get_interfaces (MonoClass* klass, gpointer *iter)
 MonoClass*
 mono_class_get_nested_types (MonoClass* klass, gpointer *iter)
 {
-       MonoError error;
        GList *item;
-       int i;
 
        if (!iter)
                return NULL;
-       if (!klass->nested_classes_inited) {
-               if (!klass->type_token)
-                       klass->nested_classes_inited = TRUE;
-               mono_loader_lock ();
-               if (!klass->nested_classes_inited) {
-                       i = mono_metadata_nesting_typedef (klass->image, klass->type_token, 1);
-                       while (i) {
-                               MonoClass* nclass;
-                               guint32 cols [MONO_NESTED_CLASS_SIZE];
-                               mono_metadata_decode_row (&klass->image->tables [MONO_TABLE_NESTEDCLASS], i - 1, cols, MONO_NESTED_CLASS_SIZE);
-                               nclass = mono_class_create_from_typedef (klass->image, MONO_TOKEN_TYPE_DEF | cols [MONO_NESTED_CLASS_NESTED], &error);
-                               if (!mono_error_ok (&error)) {
-                                       /*FIXME don't swallow the error message*/
-                                       mono_error_cleanup (&error);
-
-                                       i = mono_metadata_nesting_typedef (klass->image, klass->type_token, i + 1);
-                                       continue;
-                               }
-                               mono_class_alloc_ext (klass);
-                               klass->ext->nested_classes = g_list_prepend_image (klass->image, klass->ext->nested_classes, nclass);
-
-                               i = mono_metadata_nesting_typedef (klass->image, klass->type_token, i + 1);
-                       }
-               }
-               mono_memory_barrier ();
-               klass->nested_classes_inited = TRUE;
-               mono_loader_unlock ();
-       }
+       if (!klass->nested_classes_inited)
+               setup_nested_types (klass);
 
        if (!*iter) {
                /* start from the first */
@@ -9068,15 +9126,19 @@ mono_field_get_rva (MonoClassField *field)
        guint32 rva;
        int field_index;
        MonoClass *klass = field->parent;
+       MonoFieldDefaultValue *field_def_values;
 
        g_assert (field->type->attrs & FIELD_ATTRIBUTE_HAS_FIELD_RVA);
 
        if (!klass->ext || !klass->ext->field_def_values) {
-               mono_loader_lock ();
                mono_class_alloc_ext (klass);
+
+               field_def_values = mono_class_alloc0 (klass, sizeof (MonoFieldDefaultValue) * klass->field.count);
+
+               mono_image_lock (klass->image);
                if (!klass->ext->field_def_values)
-                       klass->ext->field_def_values = mono_class_alloc0 (klass, sizeof (MonoFieldDefaultValue) * klass->field.count);
-               mono_loader_unlock ();
+                       klass->ext->field_def_values = field_def_values;
+               mono_image_unlock (klass->image);
        }
 
        field_index = mono_field_get_index (field);
@@ -9397,6 +9459,8 @@ mono_class_get_exception_data (MonoClass *klass)
 void
 mono_classes_init (void)
 {
+       mono_mutex_init (&classes_mutex);
+
        mono_counters_register ("Inflated methods size",
                                                        MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &inflated_methods_size);
        mono_counters_register ("Inflated classes",
@@ -9420,6 +9484,7 @@ mono_classes_cleanup (void)
        if (global_interface_bitset)
                mono_bitset_free (global_interface_bitset);
        global_interface_bitset = NULL;
+       mono_mutex_destroy (&classes_mutex);
 }
 
 /**
@@ -10024,15 +10089,22 @@ mono_class_setup_interface_id (MonoClass *class)
  * mono_class_alloc_ext:
  *
  *   Allocate klass->ext if not already done.
- * LOCKING: Assumes the loader lock is held.
  */
 void
 mono_class_alloc_ext (MonoClass *klass)
 {
-       if (!klass->ext) {
-               klass->ext = mono_class_alloc0 (klass, sizeof (MonoClassExt));
-               class_ext_size += sizeof (MonoClassExt);
-       }
+       MonoClassExt *ext;
+
+       if (klass->ext)
+               return;
+
+       ext = mono_class_alloc0 (klass, sizeof (MonoClassExt));
+       mono_image_lock (klass->image);
+       mono_memory_barrier ();
+       if (!klass->ext)
+               klass->ext = ext;
+       class_ext_size += sizeof (MonoClassExt);
+       mono_image_unlock (klass->image);
 }
 
 /*
@@ -10045,53 +10117,62 @@ mono_class_alloc_ext (MonoClass *klass)
 void
 mono_class_setup_interfaces (MonoClass *klass, MonoError *error)
 {
-       int i;
+       int i, interface_count;
+       MonoClass **interfaces;
 
        mono_error_init (error);
 
        if (klass->interfaces_inited)
                return;
 
-       mono_loader_lock ();
-
-       if (klass->interfaces_inited) {
-               mono_loader_unlock ();
-               return;
-       }
-
        if (klass->rank == 1 && klass->byval_arg.type != MONO_TYPE_ARRAY) {
                MonoType *args [1];
 
                /* generic IList, ICollection, IEnumerable */
-               klass->interface_count = mono_defaults.generic_ireadonlylist_class ? 2 : 1;
-               klass->interfaces = mono_image_alloc0 (klass->image, sizeof (MonoClass*) * klass->interface_count);
+               interface_count = mono_defaults.generic_ireadonlylist_class ? 2 : 1;
+               interfaces = mono_image_alloc0 (klass->image, sizeof (MonoClass*) * interface_count);
 
                args [0] = &klass->element_class->byval_arg;
-               klass->interfaces [0] = mono_class_bind_generic_parameters (
+               interfaces [0] = mono_class_bind_generic_parameters (
                        mono_defaults.generic_ilist_class, 1, args, FALSE);
-               if (klass->interface_count > 1)
-                       klass->interfaces [1] = mono_class_bind_generic_parameters (
+               if (interface_count > 1)
+                       interfaces [1] = mono_class_bind_generic_parameters (
                           mono_defaults.generic_ireadonlylist_class, 1, args, FALSE);
        } else if (klass->generic_class) {
                MonoClass *gklass = klass->generic_class->container_class;
 
-               klass->interface_count = gklass->interface_count;
-               klass->interfaces = mono_class_new0 (klass, MonoClass *, klass->interface_count);
-               for (i = 0; i < klass->interface_count; i++) {
-                       klass->interfaces [i] = mono_class_inflate_generic_class_checked (gklass->interfaces [i], mono_generic_class_get_context (klass->generic_class), error);
+               mono_class_setup_interfaces (gklass, error);
+               if (!mono_error_ok (error)) {
+                       mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not setup the interfaces"));
+                       return;
+               }
+
+               interface_count = gklass->interface_count;
+               interfaces = mono_class_new0 (klass, MonoClass *, interface_count);
+               for (i = 0; i < interface_count; i++) {
+                       interfaces [i] = mono_class_inflate_generic_class_checked (gklass->interfaces [i], mono_generic_class_get_context (klass->generic_class), error);
                        if (!mono_error_ok (error)) {
                                mono_class_set_failure (klass, MONO_EXCEPTION_TYPE_LOAD, g_strdup ("Could not setup the interfaces"));
-                               klass->interfaces = NULL;
                                return;
                        }
                }
+       } else {
+               interface_count = 0;
+               interfaces = NULL;
        }
 
-       mono_memory_barrier ();
+       mono_image_lock (klass->image);
 
-       klass->interfaces_inited = TRUE;
+       if (!klass->interfaces_inited) {
+               klass->interface_count = interface_count;
+               klass->interfaces = interfaces;
 
-       mono_loader_unlock ();
+               mono_memory_barrier ();
+
+               klass->interfaces_inited = TRUE;
+       }
+
+       mono_image_unlock (klass->image);
 }
 
 static void
index b3ed7197d4f5db149c8a75e49ff130cf9c521775..6b98212f4ca9dc2114fd4782c5ca2ad5c3c662b1 100644 (file)
@@ -2068,8 +2068,17 @@ mono_marshal_free_ccw (MonoObject* object)
                MonoObject* handle_target = mono_gchandle_get_target (ccw_iter->gc_handle);
 
                /* Looks like the GC NULLs the weakref handle target before running the
-                * finalizer. So if we get a NULL target, destroy the CCW as well. */
-               if (!handle_target || handle_target == object) {
+                * finalizer. So if we get a NULL target, destroy the CCW as well.
+                * Unless looking up the object from the CCW shows it not the right object.
+               */
+               gboolean destroy_ccw = !handle_target || handle_target == object;
+               if (!handle_target) {
+                       MonoCCWInterface* ccw_entry = g_hash_table_lookup (ccw_iter->vtable_hash, mono_class_get_iunknown_class ());
+                       if (!(ccw_entry && object == cominterop_get_ccw_object (ccw_entry, FALSE)))
+                               destroy_ccw = FALSE;
+               }
+
+               if (destroy_ccw) {
                        /* remove all interfaces */
                        g_hash_table_foreach_remove (ccw_iter->vtable_hash, mono_marshal_free_ccw_entry, NULL);
                        g_hash_table_destroy (ccw_iter->vtable_hash);
index 119f173dd0980763320410d7eb7cdc22a6c775d0..24989f49afdf023e2c9fe55de278998f64019a9a 100644 (file)
@@ -175,6 +175,7 @@ typedef struct
 typedef struct
 {
        guint32 stack_size;
+       guint32 epilog_size;
 } MonoArchEHJitInfo;
 
 typedef struct {
index f7e22bb99f91b4960575ce46a89c21f84388e4da..b1b912f4e9bf501d4de270ccddde431bc4d0ad3f 100644 (file)
@@ -138,6 +138,9 @@ static const MonoRuntimeInfo supported_runtimes[] = {
 static MonoCreateDomainFunc create_domain_hook;
 static MonoFreeDomainFunc free_domain_hook;
 
+/* AOT cache configuration */
+static MonoAotCacheConfig aot_cache_config;
+
 /* This is intentionally not in the header file, so people don't misuse it. */
 extern void _mono_debug_init_corlib (MonoDomain *domain);
 
@@ -2776,3 +2779,9 @@ mono_enable_debug_domain_unload (gboolean enable)
 {
        debug_domain_unload = enable;
 }
+
+MonoAotCacheConfig *
+mono_get_aot_cache_config (void)
+{
+       return &aot_cache_config;
+}
index 7cbc0810c00a585771a779980e266b96da26add4..0f0ab038e9654b212506a28d8017d3d58d3ead85 100644 (file)
@@ -395,9 +395,9 @@ find_cached_memberref_sig (MonoImage *image, guint32 sig_idx)
 {
        gpointer res;
 
-       mono_loader_lock ();
+       mono_image_lock (image);
        res = g_hash_table_lookup (image->memberref_signatures, GUINT_TO_POINTER (sig_idx));
-       mono_loader_unlock ();
+       mono_image_unlock (image);
 
        return res;
 }
@@ -407,7 +407,7 @@ cache_memberref_sig (MonoImage *image, guint32 sig_idx, gpointer sig)
 {
        gpointer prev_sig;
 
-       mono_loader_lock ();
+       mono_image_lock (image);
        prev_sig = g_hash_table_lookup (image->memberref_signatures, GUINT_TO_POINTER (sig_idx));
        if (prev_sig) {
                /* Somebody got in before us */
@@ -418,8 +418,7 @@ cache_memberref_sig (MonoImage *image, guint32 sig_idx, gpointer sig)
                /* An approximation based on glib 2.18 */
                memberref_sig_cache_size += sizeof (gpointer) * 4;
        }
-
-       mono_loader_unlock ();
+       mono_image_unlock (image);
 
        return sig;
 }
@@ -1230,27 +1229,29 @@ mono_dllmap_insert (MonoImage *assembly, const char *dll, const char *func, cons
 
        mono_loader_init ();
 
-       mono_loader_lock ();
-
        if (!assembly) {
                entry = g_malloc0 (sizeof (MonoDllMap));
                entry->dll = dll? g_strdup (dll): NULL;
                entry->target = tdll? g_strdup (tdll): NULL;
                entry->func = func? g_strdup (func): NULL;
                entry->target_func = tfunc? g_strdup (tfunc): NULL;
+
+               mono_loader_lock ();
                entry->next = global_dll_map;
                global_dll_map = entry;
+               mono_loader_unlock ();
        } else {
                entry = mono_image_alloc0 (assembly, sizeof (MonoDllMap));
                entry->dll = dll? mono_image_strdup (assembly, dll): NULL;
                entry->target = tdll? mono_image_strdup (assembly, tdll): NULL;
                entry->func = func? mono_image_strdup (assembly, func): NULL;
                entry->target_func = tfunc? mono_image_strdup (assembly, tfunc): NULL;
+
+               mono_image_lock (assembly);
                entry->next = assembly->dll_map;
                assembly->dll_map = entry;
+               mono_image_unlock (assembly);
        }
-
-       mono_loader_unlock ();
 }
 
 static void
@@ -1369,14 +1370,14 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char
        mono_dllmap_lookup (image, orig_scope, import, &new_scope, &import);
 
        if (!module) {
-               mono_loader_lock ();
+               mono_image_lock (image);
                if (!image->pinvoke_scopes) {
                        image->pinvoke_scopes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
                        image->pinvoke_scope_filenames = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
                }
                module = g_hash_table_lookup (image->pinvoke_scopes, new_scope);
                found_name = g_hash_table_lookup (image->pinvoke_scope_filenames, new_scope);
-               mono_loader_unlock ();
+               mono_image_unlock (image);
                if (module)
                        cached = TRUE;
                if (found_name)
@@ -1542,12 +1543,12 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char
        if (!cached) {
                mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
                                        "DllImport loaded library '%s'.", found_name);
-               mono_loader_lock ();
+               mono_image_lock (image);
                if (!g_hash_table_lookup (image->pinvoke_scopes, new_scope)) {
                        g_hash_table_insert (image->pinvoke_scopes, g_strdup (new_scope), module);
                        g_hash_table_insert (image->pinvoke_scope_filenames, g_strdup (new_scope), g_strdup (found_name));
                }
-               mono_loader_unlock ();
+               mono_image_unlock (image);
        }
 
        mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
@@ -1917,17 +1918,11 @@ MonoMethod *
 mono_get_method_constrained_with_method (MonoImage *image, MonoMethod *method, MonoClass *constrained_class,
                             MonoGenericContext *context)
 {
-       MonoMethod *result;
-
        g_assert (method);
 
-       mono_loader_lock ();
-
-       result = get_method_constrained (image, method, constrained_class, context);
-
-       mono_loader_unlock ();
-       return result;  
+       return get_method_constrained (image, method, constrained_class, context);
 }
+
 /**
  * mono_get_method_constrained:
  *
@@ -1943,17 +1938,12 @@ mono_get_method_constrained (MonoImage *image, guint32 token, MonoClass *constra
 {
        MonoMethod *result;
 
-       mono_loader_lock ();
-
        *cil_method = mono_get_method_from_token (image, token, NULL, context, NULL);
-       if (!*cil_method) {
-               mono_loader_unlock ();
+       if (!*cil_method)
                return NULL;
-       }
 
        result = get_method_constrained (image, *cil_method, constrained_class, context);
 
-       mono_loader_unlock ();
        return result;
 }
 
@@ -2370,7 +2360,7 @@ mono_method_signature_checked (MonoMethod *m, MonoError *error)
        const char *sig;
        gboolean can_cache_signature;
        MonoGenericContainer *container;
-       MonoMethodSignature *signature = NULL;
+       MonoMethodSignature *signature = NULL, *sig2;
        guint32 sig_offset;
 
        /* We need memory barriers below because of the double-checked locking pattern */ 
@@ -2380,34 +2370,31 @@ mono_method_signature_checked (MonoMethod *m, MonoError *error)
        if (m->signature)
                return m->signature;
 
-       mono_loader_lock ();
-
-       if (m->signature) {
-               mono_loader_unlock ();
-               return m->signature;
-       }
+       img = m->klass->image;
 
        if (m->is_inflated) {
                MonoMethodInflated *imethod = (MonoMethodInflated *) m;
                /* the lock is recursive */
                signature = mono_method_signature (imethod->declaring);
                signature = inflate_generic_signature_checked (imethod->declaring->klass->image, signature, mono_method_get_context (m), error);
-               if (!mono_error_ok (error)) {
-                       mono_loader_unlock ();
+               if (!mono_error_ok (error))
                        return NULL;
-               }
 
                inflated_signatures_size += mono_metadata_signature_size (signature);
 
+               mono_image_lock (img);
+
                mono_memory_barrier ();
-               m->signature = signature;
-               mono_loader_unlock ();
+               if (!m->signature)
+                       m->signature = signature;
+
+               mono_image_unlock (img);
+
                return m->signature;
        }
 
        g_assert (mono_metadata_token_table (m->token) == MONO_TABLE_METHOD);
        idx = mono_metadata_token_index (m->token);
-       img = m->klass->image;
 
        sig = mono_metadata_blob_heap (img, sig_offset = mono_metadata_decode_row_col (&img->tables [MONO_TABLE_METHOD], idx - 1, MONO_METHOD_SIGNATURE));
 
@@ -2424,28 +2411,33 @@ mono_method_signature_checked (MonoMethod *m, MonoError *error)
        if (mono_metadata_method_has_param_attrs (img, idx))
                can_cache_signature = FALSE;
 
-       if (can_cache_signature)
+       if (can_cache_signature) {
+               mono_image_lock (img);
                signature = g_hash_table_lookup (img->method_signatures, sig);
+               mono_image_unlock (img);
+       }
 
        if (!signature) {
                const char *sig_body;
                /*TODO we should cache the failure result somewhere*/
-               if (!mono_verifier_verify_method_signature (img, sig_offset, error)) {
-                       mono_loader_unlock ();
+               if (!mono_verifier_verify_method_signature (img, sig_offset, error))
                        return NULL;
-               }
 
                size = mono_metadata_decode_blob_size (sig, &sig_body);
 
                signature = mono_metadata_parse_method_signature_full (img, container, idx, sig_body, NULL);
                if (!signature) {
                        mono_error_set_from_loader_error (error);
-                       mono_loader_unlock ();
                        return NULL;
                }
 
-               if (can_cache_signature)
-                       g_hash_table_insert (img->method_signatures, (gpointer)sig, signature);
+               if (can_cache_signature) {
+                       mono_image_lock (img);
+                       sig2 = g_hash_table_lookup (img->method_signatures, sig);
+                       if (!sig2)
+                               g_hash_table_insert (img->method_signatures, (gpointer)sig, signature);
+                       mono_image_unlock (img);
+               }
 
                signatures_size += mono_metadata_signature_size (signature);
        }
@@ -2453,17 +2445,14 @@ mono_method_signature_checked (MonoMethod *m, MonoError *error)
        /* Verify metadata consistency */
        if (signature->generic_param_count) {
                if (!container || !container->is_method) {
-                       mono_loader_unlock ();
                        mono_error_set_method_load (error, m->klass, m->name, "Signature claims method has generic parameters, but generic_params table says it doesn't for method 0x%08x from image %s", idx, img->name);
                        return NULL;
                }
                if (container->type_argc != signature->generic_param_count) {
-                       mono_loader_unlock ();
                        mono_error_set_method_load (error, m->klass, m->name, "Inconsistent generic parameter count.  Signature says %d, generic_params table says %d for method 0x%08x from image %s", signature->generic_param_count, container->type_argc, idx, img->name);
                        return NULL;
                }
        } else if (container && container->is_method && container->type_argc) {
-               mono_loader_unlock ();
                mono_error_set_method_load (error, m->klass, m->name, "generic_params table claims method has generic parameters, but signature says it doesn't for method 0x%08x from image %s", idx, img->name);
                return NULL;
        }
@@ -2494,17 +2483,20 @@ mono_method_signature_checked (MonoMethod *m, MonoError *error)
                case PINVOKE_ATTRIBUTE_CALL_CONV_GENERIC:
                case PINVOKE_ATTRIBUTE_CALL_CONV_GENERICINST:
                default:
-                       mono_loader_unlock ();
                        mono_error_set_method_load (error, m->klass, m->name, "unsupported calling convention : 0x%04x for method 0x%08x from image %s", piinfo->piflags, idx, img->name);
                        return NULL;
                }
                signature->call_convention = conv;
        }
 
+       mono_image_lock (img);
+
        mono_memory_barrier ();
-       m->signature = signature;
+       if (!m->signature)
+               m->signature = signature;
+
+       mono_image_unlock (img);
 
-       mono_loader_unlock ();
        return m->signature;
 }
 
@@ -2561,26 +2553,32 @@ mono_method_get_header (MonoMethod *method)
        if ((method->flags & METHOD_ATTRIBUTE_ABSTRACT) || (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) || (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) || (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
                return NULL;
 
+       img = method->klass->image;
+
        if (method->is_inflated) {
                MonoMethodInflated *imethod = (MonoMethodInflated *) method;
-               MonoMethodHeader *header;
+               MonoMethodHeader *header, *iheader;
 
-               mono_loader_lock ();
+               header = mono_method_get_header (imethod->declaring);
+               if (!header)
+                       return NULL;
+
+               iheader = inflate_generic_header (header, mono_method_get_context (method));
+               mono_metadata_free_mh (header);
+
+               mono_image_lock (img);
 
                if (imethod->header) {
-                       mono_loader_unlock ();
+                       mono_metadata_free_mh (iheader);
+                       mono_image_unlock (img);
                        return imethod->header;
                }
 
-               header = mono_method_get_header (imethod->declaring);
-               if (!header) {
-                       mono_loader_unlock ();
-                       return NULL;
-               }
+               mono_memory_barrier ();
+               imethod->header = iheader;
+
+               mono_image_unlock (img);
 
-               imethod->header = inflate_generic_header (header, mono_method_get_context (method));
-               mono_loader_unlock ();
-               mono_metadata_free_mh (header);
                return imethod->header;
        }
 
@@ -2596,7 +2594,6 @@ mono_method_get_header (MonoMethod *method)
         */
        g_assert (mono_metadata_token_table (method->token) == MONO_TABLE_METHOD);
        idx = mono_metadata_token_index (method->token);
-       img = method->klass->image;
        rva = mono_metadata_decode_row_col (&img->tables [MONO_TABLE_METHOD], idx - 1, MONO_METHOD_RVA);
 
        if (!mono_verifier_verify_method_header (img, rva, NULL))
@@ -2630,7 +2627,8 @@ mono_method_get_flags (MonoMethod *method, guint32 *iflags)
  * Find the method index in the metadata methodDef table.
  */
 guint32
-mono_method_get_index (MonoMethod *method) {
+mono_method_get_index (MonoMethod *method)
+{
        MonoClass *klass = method->klass;
        int i;
 
@@ -2654,4 +2652,3 @@ mono_method_get_index (MonoMethod *method) {
        }
        return 0;
 }
-
index 5ffb254c1ba227b8dcb0a80e98e281e0f17e9ec5..b04b811d123f6835b15106f721c9729d3773612f 100644 (file)
@@ -228,7 +228,7 @@ struct _MonoImage {
        MonoConcurrentHashTable *field_cache; /*protected by the image lock*/
 
        /* indexed by typespec tokens. */
-       GHashTable *typespec_cache;
+       GHashTable *typespec_cache; /* protected by the image lock */
        /* indexed by token */
        GHashTable *memberref_signatures;
        GHashTable *helper_signatures;
@@ -317,6 +317,7 @@ struct _MonoImage {
        MonoDllMap *dll_map;
 
        /* interfaces IDs from this image */
+       /* protected by the classes lock */
        MonoBitSet *interface_bitset;
 
        /* when the image is being closed, this is abused as a list of
@@ -523,6 +524,19 @@ struct _MonoMethodSignature {
        MonoType     *params [MONO_ZERO_LEN_ARRAY];
 };
 
+/*
+ * AOT cache configuration loaded from config files.
+ * Doesn't really belong here.
+ */
+typedef struct {
+       /*
+        * Enable aot caching for applications whose main assemblies are in
+        * this list.
+        */
+       GSList *apps;
+       GSList *assemblies;
+} MonoAotCacheConfig;
+
 #define MONO_SIZEOF_METHOD_SIGNATURE (sizeof (struct _MonoMethodSignature) - MONO_ZERO_LEN_ARRAY * SIZEOF_VOID_P)
 
 static inline gboolean
@@ -785,5 +799,7 @@ MonoMethod *mono_get_method_constrained_with_method (MonoImage *image, MonoMetho
 
 void mono_type_set_alignment (MonoTypeEnum type, int align) MONO_INTERNAL;
 
+MonoAotCacheConfig *mono_get_aot_cache_config (void) MONO_INTERNAL;
+
 #endif /* __MONO_METADATA_INTERNALS_H__ */
 
index 091ab5046e3c2b45db4e17c1e1559f5e8f41c57b..03cac47ce37bacdeb29dff3658ccc2a284b64610 100644 (file)
@@ -5293,46 +5293,39 @@ mono_type_create_from_typespec (MonoImage *image, guint32 type_spec)
        guint32 len;
        MonoType *type, *type2;
 
-       mono_loader_lock ();
-
+       mono_image_lock (image);
        type = g_hash_table_lookup (image->typespec_cache, GUINT_TO_POINTER (type_spec));
-       if (type) {
-               mono_loader_unlock ();
+       mono_image_unlock (image);
+       if (type)
                return type;
-       }
 
        t = &image->tables [MONO_TABLE_TYPESPEC];
 
        mono_metadata_decode_row (t, idx-1, cols, MONO_TYPESPEC_SIZE);
        ptr = mono_metadata_blob_heap (image, cols [MONO_TYPESPEC_SIGNATURE]);
 
-       if (!mono_verifier_verify_typespec_signature (image, cols [MONO_TYPESPEC_SIGNATURE], type_spec, NULL)) {
-               mono_loader_unlock ();
+       if (!mono_verifier_verify_typespec_signature (image, cols [MONO_TYPESPEC_SIGNATURE], type_spec, NULL))
                return NULL;
-       }
 
        len = mono_metadata_decode_value (ptr, &ptr);
 
        type = mono_metadata_parse_type_internal (image, NULL, MONO_PARSE_TYPE, 0, TRUE, ptr, &ptr);
-       if (!type) {
-               mono_loader_unlock ();
+       if (!type)
                return NULL;
-       }
-
-       type2 = g_hash_table_lookup (image->typespec_cache, GUINT_TO_POINTER (type_spec));
-
-       if (type2) {
-               mono_loader_unlock ();
-               return type2;
-       }
 
        type2 = mono_metadata_type_dup (image, type);
-       g_hash_table_insert (image->typespec_cache, GUINT_TO_POINTER (type_spec), type2);
        mono_metadata_free_type (type);
 
-       mono_loader_unlock ();
+       mono_image_lock (image);
+       type = g_hash_table_lookup (image->typespec_cache, GUINT_TO_POINTER (type_spec));
+       /* We might leak some data in the image mempool if found */
+       if (!type) {
+               g_hash_table_insert (image->typespec_cache, GUINT_TO_POINTER (type_spec), type2);
+               type = type2;
+       }
+       mono_image_unlock (image);
 
-       return type2;
+       return type;
 }
 
 
index 5d7d9429b1ddaa16f4a5c96ae3e5206d17e5d0f4..1e85012dd0fb002c192bb4b0c973ddfb8b02bcb1 100644 (file)
@@ -357,6 +357,54 @@ legacyUEP_handler = {
        NULL, /* finish */
 };
 
+static void
+aot_cache_start (gpointer user_data,
+                                const gchar         *element_name,
+                                const gchar        **attribute_names,
+                                const gchar        **attribute_values)
+{
+       int i;
+       MonoAotCacheConfig *config;
+
+       if (strcmp (element_name, "aotcache") != 0)
+               return;
+
+       config = mono_get_aot_cache_config ();
+
+       /* Per-app configuration */
+       for (i = 0; attribute_names [i]; ++i) {
+               if (!strcmp (attribute_names [i], "app")) {
+                       config->apps = g_slist_prepend (config->apps, g_strdup (attribute_values [i]));
+                       return;
+               }
+       }
+
+       /* Global configuration */
+       for (i = 0; attribute_names [i]; ++i) {
+               if (!strcmp (attribute_names [i], "assemblies")) {
+                       char **parts, **ptr;
+                       char *part;
+
+                       parts = g_strsplit (attribute_values [i], " ", -1);
+                       for (ptr = parts; ptr && *ptr; ptr ++) {
+                               part = *ptr;
+                               config->assemblies = g_slist_prepend (config->assemblies, g_strdup (part));
+                       }
+                       g_strfreev (parts);
+               }
+       }
+}
+
+static const MonoParseHandler
+aot_cache_handler = {
+       "aotcache",
+       NULL, /* init */
+       aot_cache_start,
+       NULL, /* text */
+       NULL, /* end */
+       NULL, /* finish */
+};
+
 static int inited = 0;
 
 static void
@@ -366,6 +414,7 @@ mono_config_init (void)
        config_handlers = g_hash_table_new (g_str_hash, g_str_equal);
        g_hash_table_insert (config_handlers, (gpointer) dllmap_handler.element_name, (gpointer) &dllmap_handler);
        g_hash_table_insert (config_handlers, (gpointer) legacyUEP_handler.element_name, (gpointer) &legacyUEP_handler);
+       g_hash_table_insert (config_handlers, (gpointer) aot_cache_handler.element_name, (gpointer) &aot_cache_handler);
 }
 
 void
@@ -407,7 +456,6 @@ mono_config_parse_file_with_context (ParseState *state, const char *filename)
        if (!g_file_get_contents (filename, &text, &len, NULL))
                return 0;
 
-
        offset = 0;
        if (len > 3 && text [0] == '\xef' && text [1] == (gchar) '\xbb' && text [2] == '\xbf')
                offset = 3; /* Skip UTF-8 BOM */
index 8e1d05e166338ccc7606093caec3133feb864a64..890001a8cb27ad093d8c2ae19984c84b873d7eee 100644 (file)
@@ -2299,7 +2299,7 @@ collect_nursery (SgenGrayQueue *unpin_queue, gboolean finish_up_concurrent_mark)
        /* pin cemented objects */
        sgen_cement_iterate (pin_stage_object_callback, NULL);
        /* identify pinned objects */
-       sgen_optimize_pin_queue (0);
+       sgen_optimize_pin_queue ();
        sgen_pinning_setup_section (nursery_section);
        ctx.scan_func = NULL;
        ctx.copy_func = NULL;
@@ -2418,7 +2418,7 @@ collect_nursery (SgenGrayQueue *unpin_queue, gboolean finish_up_concurrent_mark)
        sgen_workers_reset_data ();
 
        if (objects_pinned) {
-               sgen_optimize_pin_queue (0);
+               sgen_optimize_pin_queue ();
                sgen_pinning_setup_section (nursery_section);
        }
 
@@ -2584,7 +2584,7 @@ major_copy_or_mark_from_roots (size_t *old_next_pin_slot, gboolean finish_up_con
                        sgen_cement_reset ();
        }
 
-       sgen_optimize_pin_queue (0);
+       sgen_optimize_pin_queue ();
 
        /*
         * The concurrent collector doesn't move objects, neither on
@@ -2889,7 +2889,7 @@ major_finish_collection (const char *reason, size_t old_next_pin_slot, gboolean
 
                /*This is slow, but we just OOM'd*/
                sgen_pin_queue_clear_discarded_entries (nursery_section, old_next_pin_slot);
-               sgen_optimize_pin_queue (0);
+               sgen_optimize_pin_queue ();
                sgen_find_section_pin_queue_start_end (nursery_section);
                objects_pinned = 0;
        }
@@ -3835,11 +3835,11 @@ sgen_thread_register (SgenThreadInfo* info, void *addr)
        binary_protocol_thread_register ((gpointer)mono_thread_info_get_tid (info));
 
        /* On win32, stack_start_limit should be 0, since the stack can grow dynamically */
-#ifndef HOST_WIN32
        mono_thread_info_get_stack_bounds (&staddr, &stsize);
-#endif
        if (staddr) {
+#ifndef HOST_WIN32
                info->stack_start_limit = staddr;
+#endif
                info->stack_end = staddr + stsize;
        } else {
                gsize stack_bottom = (gsize)addr;
index 37ac5c6f32938df1f2260cbcf863e0a9db8d3d3b..9474d7cec5acf7c72e0ace70cd3c1b5cae8b92b7 100644 (file)
 #include "metadata/sgen-memory-governor.h"
 
 /* keep each size a multiple of ALLOC_ALIGN */
+#if SIZEOF_VOID_P == 4
 static const int allocator_sizes [] = {
           8,   16,   24,   32,   40,   48,   64,   80,
-         96,  128,  160,  192,  224,  248,  320,  384,
-        448,  528,  584,  680,  816, 1088, 1360, 2040,
-       2336, 2728, 3272, 4088, 5456, 8184 };
+         96,  128,  160,  192,  224,  248,  296,  320,
+        384,  448,  504,  528,  584,  680,  816, 1088,
+       1360, 2040, 2336, 2728, 3272, 4088, 5456, 8184 };
+#else
+static const int allocator_sizes [] = {
+          8,   16,   24,   32,   40,   48,   64,   80,
+         96,  128,  160,  192,  224,  248,  320,  328,
+        384,  448,  528,  584,  680,  816, 1016, 1088,
+       1360, 2040, 2336, 2728, 3272, 4088, 5456, 8184 };
+#endif
 
 #define NUM_ALLOCATORS (sizeof (allocator_sizes) / sizeof (int))
 
index 523c7737b14e4108143c7a45b2f3ca22421cd4ca..d91692d42e94dee71dd2ce0463341091b44dc0e9 100644 (file)
 #include "metadata/sgen-gc.h"
 #include "metadata/sgen-pinning.h"
 #include "metadata/sgen-protocol.h"
+#include "metadata/sgen-pointer-queue.h"
 
-static void** pin_queue;
-static size_t pin_queue_size = 0;
-static size_t next_pin_slot = 0;
+static SgenPointerQueue pin_queue;
 static size_t last_num_pinned = 0;
 
 #define PIN_HASH_SIZE 1024
@@ -43,20 +42,8 @@ sgen_init_pinning (void)
 void
 sgen_finish_pinning (void)
 {
-       last_num_pinned = next_pin_slot;
-       next_pin_slot = 0;
-}
-
-static void
-realloc_pin_queue (void)
-{
-       size_t new_size = pin_queue_size? pin_queue_size + pin_queue_size/2: 1024;
-       void **new_pin = sgen_alloc_internal_dynamic (sizeof (void*) * new_size, INTERNAL_MEM_PIN_QUEUE, TRUE);
-       memcpy (new_pin, pin_queue, sizeof (void*) * next_pin_slot);
-       sgen_free_internal_dynamic (pin_queue, sizeof (void*) * pin_queue_size, INTERNAL_MEM_PIN_QUEUE);
-       pin_queue = new_pin;
-       pin_queue_size = new_size;
-       SGEN_LOG (4, "Reallocated pin queue to size: %zd", new_size);
+       last_num_pinned = pin_queue.next_slot;
+       sgen_pointer_queue_clear (&pin_queue);
 }
 
 void
@@ -69,37 +56,19 @@ sgen_pin_stage_ptr (void *ptr)
 
        pin_hash_filter [hash_idx] = ptr;
 
-       if (next_pin_slot >= pin_queue_size)
-               realloc_pin_queue ();
-
-       pin_queue [next_pin_slot++] = ptr;
-}
-
-static size_t
-optimized_pin_queue_search (void *addr)
-{
-       size_t first = 0, last = next_pin_slot;
-       while (first < last) {
-               size_t middle = first + ((last - first) >> 1);
-               if (addr <= pin_queue [middle])
-                       last = middle;
-               else
-                       first = middle + 1;
-       }
-       g_assert (first == last);
-       return first;
+       sgen_pointer_queue_add (&pin_queue, ptr);
 }
 
 void**
 sgen_find_optimized_pin_queue_area (void *start, void *end, size_t *num)
 {
        size_t first, last;
-       first = optimized_pin_queue_search (start);
-       last = optimized_pin_queue_search (end);
+       first = sgen_pointer_queue_search (&pin_queue, start);
+       last = sgen_pointer_queue_search (&pin_queue, end);
        *num = last - first;
        if (first == last)
                return NULL;
-       return pin_queue + first;
+       return pin_queue.data + first;
 }
 
 void
@@ -114,21 +83,21 @@ sgen_find_section_pin_queue_start_end (GCMemSection *section)
 void
 sgen_pinning_setup_section (GCMemSection *section)
 {
-       section->pin_queue_start = pin_queue;
-       section->pin_queue_num_entries = next_pin_slot;
+       section->pin_queue_start = pin_queue.data;
+       section->pin_queue_num_entries = pin_queue.next_slot;
 }
 
 void
 sgen_pinning_trim_queue_to_section (GCMemSection *section)
 {
-       next_pin_slot = section->pin_queue_num_entries;
+       pin_queue.next_slot = section->pin_queue_num_entries;
 }
 
 void
 sgen_pin_queue_clear_discarded_entries (GCMemSection *section, size_t max_pin_slot)
 {
        void **start = section->pin_queue_start + section->pin_queue_num_entries;
-       void **end = pin_queue + max_pin_slot;
+       void **end = pin_queue.data + max_pin_slot;
        void *addr;
 
        if (!start)
@@ -144,30 +113,15 @@ sgen_pin_queue_clear_discarded_entries (GCMemSection *section, size_t max_pin_sl
 
 /* reduce the info in the pin queue, removing duplicate pointers and sorting them */
 void
-sgen_optimize_pin_queue (size_t start_slot)
+sgen_optimize_pin_queue (void)
 {
-       void **start, **cur, **end;
-       /* sort and uniq pin_queue: we just sort and we let the rest discard multiple values */
-       /* it may be better to keep ranges of pinned memory instead of individually pinning objects */
-       SGEN_LOG (5, "Sorting pin queue, size: %zd", next_pin_slot);
-       if ((next_pin_slot - start_slot) > 1)
-               sgen_sort_addresses (pin_queue + start_slot, next_pin_slot - start_slot);
-       start = cur = pin_queue + start_slot;
-       end = pin_queue + next_pin_slot;
-       while (cur < end) {
-               *start = *cur++;
-               while (*start == *cur && cur < end)
-                       cur++;
-               start++;
-       };
-       next_pin_slot = start - pin_queue;
-       SGEN_LOG (5, "Pin queue reduced to size: %zd", next_pin_slot);
+       sgen_pointer_queue_sort_uniq (&pin_queue);
 }
 
 size_t
 sgen_get_pinned_count (void)
 {
-       return next_pin_slot;
+       return pin_queue.next_slot;
 }
 
 void
@@ -176,8 +130,9 @@ sgen_dump_pin_queue (void)
        int i;
 
        for (i = 0; i < last_num_pinned; ++i) {
-               SGEN_LOG (3, "Bastard pinning obj %p (%s), size: %zd", pin_queue [i], sgen_safe_name (pin_queue [i]), sgen_safe_object_get_size (pin_queue [i]));
-       }       
+               void *ptr = pin_queue.data [i];
+               SGEN_LOG (3, "Bastard pinning obj %p (%s), size: %zd", ptr, sgen_safe_name (ptr), sgen_safe_object_get_size (ptr));
+       }
 }
 
 typedef struct _CementHashEntry CementHashEntry;
index ef41df24d2f688fb7688c7f8e202faf2a7305673..46db46536cdfe21a93fe2f29239caa82aa328197 100644 (file)
@@ -28,7 +28,7 @@ enum {
 };
 
 void sgen_pin_stage_ptr (void *ptr) MONO_INTERNAL;
-void sgen_optimize_pin_queue (size_t start_slot) MONO_INTERNAL;
+void sgen_optimize_pin_queue (void) MONO_INTERNAL;
 void sgen_init_pinning (void) MONO_INTERNAL;
 void sgen_finish_pinning (void) MONO_INTERNAL;
 void sgen_pin_queue_clear_discarded_entries (GCMemSection *section, size_t max_pin_slot) MONO_INTERNAL;
diff --git a/mono/metadata/sgen-pointer-queue.c b/mono/metadata/sgen-pointer-queue.c
new file mode 100644 (file)
index 0000000..fe49160
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * sgen-pointer-queue.c: A pointer queue that can be sorted.
+ *
+ * Copyright (C) 2014 Xamarin Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License 2.0 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License 2.0 along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "metadata/sgen-gc.h"
+#include "metadata/sgen-pointer-queue.h"
+
+#ifdef HAVE_SGEN_GC
+
+void
+sgen_pointer_queue_clear (SgenPointerQueue *queue)
+{
+       queue->next_slot = 0;
+}
+
+static void
+realloc_queue (SgenPointerQueue *queue)
+{
+       size_t new_size = queue->size ? queue->size + queue->size/2 : 1024;
+       void **new_data = sgen_alloc_internal_dynamic (sizeof (void*) * new_size, INTERNAL_MEM_PIN_QUEUE, TRUE);
+       memcpy (new_data, queue->data, sizeof (void*) * queue->next_slot);
+       sgen_free_internal_dynamic (queue->data, sizeof (void*) * queue->size, INTERNAL_MEM_PIN_QUEUE);
+       queue->data = new_data;
+       queue->size = new_size;
+       SGEN_LOG (4, "Reallocated pointer queue to size: %lu", new_size);
+}
+
+void
+sgen_pointer_queue_add (SgenPointerQueue *queue, void *ptr)
+{
+       if (queue->next_slot >= queue->size)
+               realloc_queue (queue);
+
+       queue->data [queue->next_slot++] = ptr;
+}
+
+size_t
+sgen_pointer_queue_search (SgenPointerQueue *queue, void *addr)
+{
+       size_t first = 0, last = queue->next_slot;
+       while (first < last) {
+               size_t middle = first + ((last - first) >> 1);
+               if (addr <= queue->data [middle])
+                       last = middle;
+               else
+                       first = middle + 1;
+       }
+       g_assert (first == last);
+       return first;
+}
+
+void
+sgen_pointer_queue_sort_uniq (SgenPointerQueue *queue)
+{
+       void **start, **cur, **end;
+       /* sort and uniq pin_queue: we just sort and we let the rest discard multiple values */
+       /* it may be better to keep ranges of pinned memory instead of individually pinning objects */
+       SGEN_LOG (5, "Sorting pointer queue, size: %lu", queue->next_slot);
+       if (queue->next_slot > 1)
+               sgen_sort_addresses (queue->data, queue->next_slot);
+       start = cur = queue->data;
+       end = queue->data + queue->next_slot;
+       while (cur < end) {
+               *start = *cur++;
+               while (*start == *cur && cur < end)
+                       cur++;
+               start++;
+       };
+       queue->next_slot = start - queue->data;
+       SGEN_LOG (5, "Pointer queue reduced to size: %lu", queue->next_slot);
+}
+
+#endif
diff --git a/mono/metadata/sgen-pointer-queue.h b/mono/metadata/sgen-pointer-queue.h
new file mode 100644 (file)
index 0000000..031870f
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * sgen-pointer-queue.h: A pointer queue that can be sorted.
+ *
+ * Copyright (C) 2014 Xamarin Inc
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License 2.0 as published by the Free Software Foundation;
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License 2.0 along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __MONO_SGEN_POINTER_QUEUE_H__
+#define __MONO_SGEN_POINTER_QUEUE_H__
+
+typedef struct {
+       void **data;
+       size_t size;
+       size_t next_slot;
+} SgenPointerQueue;
+
+void sgen_pointer_queue_add (SgenPointerQueue *queue, void *ptr) MONO_INTERNAL;
+void sgen_pointer_queue_clear (SgenPointerQueue *queue) MONO_INTERNAL;
+void sgen_pointer_queue_sort_uniq (SgenPointerQueue *queue) MONO_INTERNAL;
+size_t sgen_pointer_queue_search (SgenPointerQueue *queue, void *addr) MONO_INTERNAL;
+
+#endif
index 67df295370b4690937b2805267309468881fe376..a0e5f8469d6d1d5e7154b9b9f7ecd30d1b52995d 100644 (file)
@@ -651,7 +651,7 @@ static guint32 WINAPI start_wrapper_internal(void *data)
 
        /* if the name was set before starting, we didn't invoke the profiler callback */
        if (internal->name && (internal->flags & MONO_THREAD_FLAG_NAME_SET)) {
-               char *tname = g_utf16_to_utf8 (internal->name, -1, NULL, NULL, NULL);
+               char *tname = g_utf16_to_utf8 (internal->name, internal->name_len, NULL, NULL, NULL);
                mono_profiler_thread_name (internal->tid, tname);
                g_free (tname);
        }
index 3c805ddae8cadf198c5f2b9d8ad9c3d39d0ec1b3..e54fc05083e9a4cabebbb5659899343041712a6d 100644 (file)
@@ -149,6 +149,7 @@ typedef struct MonoAotOptions {
        char *mtriple;
        char *llvm_path;
        char *instances_logfile_path;
+       char *logfile;
 } MonoAotOptions;
 
 typedef struct MonoAotStats {
@@ -244,6 +245,7 @@ typedef struct MonoAotCompile {
        int objc_selector_index, objc_selector_index_2;
        GPtrArray *objc_selectors;
        GHashTable *objc_selector_to_index;
+       FILE *logfile;
        FILE *instances_logfile;
 } MonoAotCompile;
 
@@ -303,6 +305,38 @@ get_patch_name (int info)
 static char*
 get_plt_entry_debug_sym (MonoAotCompile *acfg, MonoJumpInfo *ji, GHashTable *cache);
 
+static void
+aot_printf (MonoAotCompile *acfg, const gchar *format, ...)
+{
+       FILE *output;
+       va_list args;
+
+       if (acfg->logfile)
+               output = acfg->logfile;
+       else
+               output = stdout;
+
+       va_start (args, format);
+       vfprintf (output, format, args);
+       va_end (args);
+}
+
+static void
+aot_printerrf (MonoAotCompile *acfg, const gchar *format, ...)
+{
+       FILE *output;
+       va_list args;
+
+       if (acfg->logfile)
+               output = acfg->logfile;
+       else
+               output = stderr;
+
+       va_start (args, format);
+       vfprintf (output, format, args);
+       va_end (args);
+}
+
 /* Wrappers around the image writer functions */
 
 static inline void
@@ -3113,7 +3147,7 @@ add_extra_method_with_depth (MonoAotCompile *acfg, MonoMethod *method, int depth
                method = mini_get_shared_method (method);
 
        if (acfg->aot_opts.log_generics)
-               printf ("%*sAdding method %s.\n", depth, "", mono_method_full_name (method, TRUE));
+               aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_full_name (method, TRUE));
 
        add_method_full (acfg, method, TRUE, depth);
 }
@@ -3929,7 +3963,7 @@ add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth,
                return;
 
        if (acfg->aot_opts.log_generics)
-               printf ("%*sAdding generic instance %s [%s].\n", depth, "", mono_type_full_name (&klass->byval_arg), ref);
+               aot_printf (acfg, "%*sAdding generic instance %s [%s].\n", depth, "", mono_type_full_name (&klass->byval_arg), ref);
 
        g_hash_table_insert (acfg->ginst_hash, klass, klass);
 
@@ -3979,7 +4013,7 @@ add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth,
                method = mono_marshal_get_delegate_invoke (method, NULL);
 
                if (acfg->aot_opts.log_generics)
-                       printf ("%*sAdding method %s.\n", depth, "", mono_method_full_name (method, TRUE));
+                       aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_full_name (method, TRUE));
 
                add_method (acfg, method);
        }
@@ -5333,18 +5367,7 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg)
                encoded = mono_unwind_ops_encode (cfg->unwind_ops, &encoded_len);
 
                unwind_desc = get_unwind_info_offset (acfg, encoded, encoded_len);
-               g_assert (unwind_desc < 0xffff);
-               if (cfg->has_unwind_info_for_epilog) {
-                       /*
-                        * The lower 16 bits identify the unwind descriptor, the upper 16 bits contain the offset of
-                        * the start of the epilog from the end of the method.
-                        */
-                       g_assert (cfg->code_size - cfg->epilog_begin < 0xffff);
-                       encode_value (((cfg->code_size - cfg->epilog_begin) << 16) | unwind_desc, p, &p);
-                       g_free (encoded);
-               } else {
-                       encode_value (unwind_desc, p, &p);
-               }
+               encode_value (unwind_desc, p, &p);
        } else {
                encode_value (jinfo->unwind_info, p, &p);
        }
@@ -5443,6 +5466,7 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg)
 
                eh_info = mono_jit_info_get_arch_eh_info (jinfo);
                encode_value (eh_info->stack_size, p, &p);
+               encode_value (eh_info->epilog_size, p, &p);
        }
 
        if (jinfo->has_generic_jit_info) {
@@ -6361,6 +6385,8 @@ mono_aot_parse_options (const char *aot_options, MonoAotOptions *opts)
                        opts->instances_logfile_path = g_strdup (arg + strlen ("log-instances="));
                } else if (str_begins_with (arg, "log-instances")) {
                        opts->log_instances = TRUE;
+               } else if (str_begins_with (arg, "internal-logfile=")) {
+                       opts->logfile = g_strdup (arg + strlen ("internal-logfile="));
                } else if (str_begins_with (arg, "mtriple=")) {
                        opts->mtriple = g_strdup (arg + strlen ("mtriple="));
                } else if (str_begins_with (arg, "llvm-path=")) {
@@ -7024,7 +7050,7 @@ mono_aot_patch_info_dup (MonoJumpInfo* ji)
  *   Emit the LLVM code into an LLVM bytecode file, and compile it using the LLVM
  * tools.
  */
-static void
+static gboolean
 emit_llvm_file (MonoAotCompile *acfg)
 {
        char *command, *opts, *tempbc;
@@ -7104,10 +7130,9 @@ emit_llvm_file (MonoAotCompile *acfg)
        opts = g_strdup ("-targetlibinfo -no-aa -basicaa -notti -instcombine -simplifycfg -sroa -domtree -early-cse -lazy-value-info -correlated-propagation -simplifycfg -instcombine -simplifycfg -reassociate -domtree -loops -loop-simplify -lcssa -loop-rotate -licm -lcssa -loop-unswitch -instcombine -scalar-evolution -loop-simplify -lcssa -indvars -loop-idiom -loop-deletion -loop-unroll -memdep -gvn -memdep -memcpyopt -sccp -instcombine -lazy-value-info -correlated-propagation -domtree -memdep -adce -simplifycfg -instcombine -strip-dead-prototypes -domtree -verify");
 #if 1
        command = g_strdup_printf ("%sopt -f %s -o \"%s.opt.bc\" \"%s.bc\"", acfg->aot_opts.llvm_path, opts, acfg->tmpbasename, acfg->tmpbasename);
-       printf ("Executing opt: %s\n", command);
-       if (system (command) != 0) {
-               exit (1);
-       }
+       aot_printf (acfg, "Executing opt: %s\n", command);
+       if (system (command) != 0)
+               return FALSE;
 #endif
        g_free (opts);
 
@@ -7133,11 +7158,11 @@ emit_llvm_file (MonoAotCompile *acfg)
 
        command = g_strdup_printf ("%sllc %s -disable-gnu-eh-frame -enable-mono-eh-frame -o \"%s\" \"%s.opt.bc\"", acfg->aot_opts.llvm_path, acfg->llc_args->str, acfg->tmpfname, acfg->tmpbasename);
 
-       printf ("Executing llc: %s\n", command);
+       aot_printf (acfg, "Executing llc: %s\n", command);
 
-       if (system (command) != 0) {
-               exit (1);
-       }
+       if (system (command) != 0)
+               return FALSE;
+       return TRUE;
 }
 #endif
 
@@ -8381,7 +8406,7 @@ emit_dwarf_info (MonoAotCompile *acfg)
 #endif
 }
 
-static void
+static gboolean
 collect_methods (MonoAotCompile *acfg)
 {
        int mindex, i;
@@ -8395,9 +8420,9 @@ collect_methods (MonoAotCompile *acfg)
                method = mono_get_method (acfg->image, token, NULL);
 
                if (!method) {
-                       printf ("Failed to load method 0x%x from '%s'.\n", token, image->name);
-                       printf ("Run with MONO_LOG_LEVEL=debug for more information.\n");
-                       exit (1);
+                       aot_printerrf (acfg, "Failed to load method 0x%x from '%s'.\n", token, image->name);
+                       aot_printerrf (acfg, "Run with MONO_LOG_LEVEL=debug for more information.\n");
+                       return FALSE;
                }
                        
                /* Load all methods eagerly to skip the slower lazy loading code */
@@ -8461,6 +8486,7 @@ collect_methods (MonoAotCompile *acfg)
 
        if (acfg->aot_opts.full_aot)
                add_wrappers (acfg);
+       return TRUE;
 }
 
 static void
@@ -8573,9 +8599,9 @@ compile_asm (MonoAotCompile *acfg)
 #endif
 
        if (acfg->aot_opts.asm_only) {
-               printf ("Output file: '%s'.\n", acfg->tmpfname);
+               aot_printf (acfg, "Output file: '%s'.\n", acfg->tmpfname);
                if (acfg->aot_opts.static_link)
-                       printf ("Linking symbol: '%s'.\n", acfg->static_linking_symbol);
+                       aot_printf (acfg, "Linking symbol: '%s'.\n", acfg->static_linking_symbol);
                return 0;
        }
 
@@ -8588,7 +8614,7 @@ compile_asm (MonoAotCompile *acfg)
                objfile = g_strdup_printf ("%s.o", acfg->tmpfname);
        }
        command = g_strdup_printf ("%s%s %s %s -o %s %s", tool_prefix, AS_NAME, AS_OPTIONS, acfg->as_args ? acfg->as_args->str : "", objfile, acfg->tmpfname);
-       printf ("Executing the native assembler: %s\n", command);
+       aot_printf (acfg, "Executing the native assembler: %s\n", command);
        if (system (command) != 0) {
                g_free (command);
                g_free (objfile);
@@ -8598,8 +8624,8 @@ compile_asm (MonoAotCompile *acfg)
        g_free (command);
 
        if (acfg->aot_opts.static_link) {
-               printf ("Output file: '%s'.\n", objfile);
-               printf ("Linking symbol: '%s'.\n", acfg->static_linking_symbol);
+               aot_printf (acfg, "Output file: '%s'.\n", objfile);
+               aot_printf (acfg, "Linking symbol: '%s'.\n", acfg->static_linking_symbol);
                g_free (objfile);
                return 0;
        }
@@ -8616,7 +8642,7 @@ compile_asm (MonoAotCompile *acfg)
 #else
        command = g_strdup_printf ("%sld %s -shared -o %s %s.o", tool_prefix, LD_OPTIONS, tmp_outfile_name, acfg->tmpfname);
 #endif
-       printf ("Executing the native linker: %s\n", command);
+       aot_printf (acfg, "Executing the native linker: %s\n", command);
        if (system (command) != 0) {
                g_free (tmp_outfile_name);
                g_free (outfile_name);
@@ -8638,7 +8664,7 @@ compile_asm (MonoAotCompile *acfg)
         * happens a lot in emit_and_reloc_code (), so we need to get rid of them.
         */
        command = g_strdup_printf ("%sstrip --strip-symbol=\\$a --strip-symbol=\\$d %s", tool_prefix, tmp_outfile_name);
-       printf ("Stripping the binary: %s\n", command);
+       aot_printf (acfg, "Stripping the binary: %s\n", command);
        if (system (command) != 0) {
                g_free (tmp_outfile_name);
                g_free (outfile_name);
@@ -8652,7 +8678,7 @@ compile_asm (MonoAotCompile *acfg)
 
 #if defined(TARGET_MACH)
        command = g_strdup_printf ("dsymutil %s", outfile_name);
-       printf ("Executing dsymutil: %s\n", command);
+       aot_printf (acfg, "Executing dsymutil: %s\n", command);
        if (system (command) != 0) {
                return 1;
        }
@@ -8666,7 +8692,7 @@ compile_asm (MonoAotCompile *acfg)
        g_free (objfile);
 
        if (acfg->aot_opts.save_temps)
-               printf ("Retained input file.\n");
+               aot_printf (acfg, "Retained input file.\n");
        else
                unlink (acfg->tmpfname);
 
@@ -8771,15 +8797,6 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
        TV_DECLARE (atv);
        TV_DECLARE (btv);
 
-#if !defined(MONO_ARCH_GSHAREDVT_SUPPORTED) || !defined(ENABLE_GSHAREDVT)
-       if (opts & MONO_OPT_GSHAREDVT) {
-               fprintf (stderr, "-O=gsharedvt not supported on this platform.\n");
-               exit (1);
-       }
-#endif
-
-       printf ("Mono Ahead of Time compiler - compiling assembly %s\n", image->name);
-
        acfg = acfg_create (ass, opts);
 
        memset (&acfg->aot_opts, 0, sizeof (acfg->aot_opts));
@@ -8796,21 +8813,34 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
 
        mono_aot_parse_options (aot_options, &acfg->aot_opts);
 
+       if (acfg->aot_opts.logfile) {
+               acfg->logfile = fopen (acfg->aot_opts.logfile, "a+");
+       }
+
        if (acfg->aot_opts.static_link)
                acfg->aot_opts.autoreg = TRUE;
 
        //acfg->aot_opts.print_skipped_methods = TRUE;
 
+#if !defined(MONO_ARCH_GSHAREDVT_SUPPORTED) || !defined(ENABLE_GSHAREDVT)
+       if (opts & MONO_OPT_GSHAREDVT) {
+               aot_printerrf (acfg, "-O=gsharedvt not supported on this platform.\n");
+               return 1;
+       }
+#endif
+
+       aot_printf (acfg, "Mono Ahead of Time compiler - compiling assembly %s\n", image->name);
+
 #ifndef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
        if (acfg->aot_opts.full_aot) {
-               printf ("--aot=full is not supported on this platform.\n");
+               aot_printerrf (acfg, "--aot=full is not supported on this platform.\n");
                return 1;
        }
 #endif
 
        if (acfg->aot_opts.direct_pinvoke && !acfg->aot_opts.static_link) {
-               fprintf (stderr, "The 'direct-pinvoke' AOT option also requires the 'static' AOT option.\n");
-               exit (1);
+               aot_printerrf (acfg, "The 'direct-pinvoke' AOT option also requires the 'static' AOT option.\n");
+               return 1;
        }
 
        if (acfg->aot_opts.static_link)
@@ -8823,7 +8853,7 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                opt->gen_seq_points = TRUE;
 
                if (!mono_debug_enabled ()) {
-                       fprintf (stderr, "The soft-debug AOT option requires the --debug option.\n");
+                       aot_printerrf (acfg, "The soft-debug AOT option requires the --debug option.\n");
                        return 1;
                }
                acfg->flags |= MONO_AOT_FILE_FLAG_DEBUG;
@@ -8835,8 +8865,8 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                acfg->flags |= MONO_AOT_FILE_FLAG_WITH_LLVM;
 
                if (acfg->aot_opts.soft_debug) {
-                       fprintf (stderr, "The 'soft-debug' option is not supported when compiling with LLVM.\n");
-                       exit (1);
+                       aot_printerrf (acfg, "The 'soft-debug' option is not supported when compiling with LLVM.\n");
+                       return 1;
                }
        }
 
@@ -8846,8 +8876,8 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
        if (acfg->aot_opts.instances_logfile_path) {
                acfg->instances_logfile = fopen (acfg->aot_opts.instances_logfile_path, "w");
                if (!acfg->instances_logfile) {
-                       fprintf (stderr, "Unable to create logfile: '%s'.\n", acfg->aot_opts.instances_logfile_path);
-                       exit (1);
+                       aot_printerrf (acfg, "Unable to create logfile: '%s'.\n", acfg->aot_opts.instances_logfile_path);
+                       return 1;
                }
        }
 
@@ -8893,7 +8923,9 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                mono_set_partial_sharing_supported (TRUE);
        */
 
-       collect_methods (acfg);
+       res = collect_methods (acfg);
+       if (!res)
+               return 1;
 
        acfg->cfgs_size = acfg->methods->len + 32;
        acfg->cfgs = g_new0 (MonoCompile*, acfg->cfgs_size);
@@ -8945,6 +8977,8 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
 
 #ifdef ENABLE_LLVM
        if (acfg->llvm) {
+               gboolean res;
+
                if (acfg->aot_opts.asm_only) {
                        if (acfg->aot_opts.outfile) {
                                acfg->tmpfname = g_strdup_printf ("%s", acfg->aot_opts.outfile);
@@ -8958,7 +8992,9 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                        acfg->tmpfname = g_strdup_printf ("%s.s", acfg->tmpbasename);
                }
 
-               emit_llvm_file (acfg);
+               res = emit_llvm_file (acfg);
+               if (!res)
+                       return FALSE;
        }
 #endif
 
@@ -8976,7 +9012,7 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
 
                acfg->fp = fopen (tmp_outfile_name, "w");
                if (!acfg->fp) {
-                       printf ("Unable to create temporary file '%s': %s\n", tmp_outfile_name, strerror (errno));
+                       aot_printf (acfg, "Unable to create temporary file '%s': %s\n", tmp_outfile_name, strerror (errno));
                        return 1;
                }
 
@@ -9000,7 +9036,7 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                        }
                }
                if (acfg->fp == 0) {
-                       fprintf (stderr, "Unable to open file '%s': %s\n", acfg->tmpfname, strerror (errno));
+                       aot_printerrf (acfg, "Unable to open file '%s': %s\n", acfg->tmpfname, strerror (errno));
                        return 1;
                }
                acfg->w = img_writer_create (acfg->fp, FALSE);
@@ -9037,7 +9073,7 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
 
        if (!acfg->aot_opts.nodebug || acfg->aot_opts.dwarf_debug) {
                if (acfg->aot_opts.dwarf_debug && !mono_debug_enabled ()) {
-                       fprintf (stderr, "The dwarf AOT option requires the --debug option.\n");
+                       aot_printerrf (acfg, "The dwarf AOT option requires the --debug option.\n");
                        return 1;
                }
                acfg->dwarf = mono_dwarf_writer_create (acfg->w, NULL, 0, FALSE, !acfg->gas_line_numbers);
@@ -9125,7 +9161,7 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
 
        all_sizes = acfg->stats.code_size + acfg->stats.info_size + acfg->stats.ex_info_size + acfg->stats.unwind_info_size + acfg->stats.class_info_size + acfg->stats.got_info_size + acfg->stats.offsets_size + acfg->stats.plt_size;
 
-       printf ("Code: %d(%d%%) Info: %d(%d%%) Ex Info: %d(%d%%) Unwind Info: %d(%d%%) Class Info: %d(%d%%) PLT: %d(%d%%) GOT Info: %d(%d%%) Offsets: %d(%d%%) GOT: %d\n",
+       aot_printf (acfg, "Code: %d(%d%%) Info: %d(%d%%) Ex Info: %d(%d%%) Unwind Info: %d(%d%%) Class Info: %d(%d%%) PLT: %d(%d%%) GOT Info: %d(%d%%) Offsets: %d(%d%%) GOT: %d\n",
                        acfg->stats.code_size, acfg->stats.code_size * 100 / all_sizes,
                        acfg->stats.info_size, acfg->stats.info_size * 100 / all_sizes,
                        acfg->stats.ex_info_size, acfg->stats.ex_info_size * 100 / all_sizes,
@@ -9135,19 +9171,19 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                        acfg->stats.got_info_size, acfg->stats.got_info_size * 100 / all_sizes,
                        acfg->stats.offsets_size, acfg->stats.offsets_size * 100 / all_sizes,
                        (int)(acfg->got_offset * sizeof (gpointer)));
-       printf ("Compiled: %d/%d (%d%%)%s, No GOT slots: %d (%d%%), Direct calls: %d (%d%%)\n", 
+       aot_printf (acfg, "Compiled: %d/%d (%d%%)%s, No GOT slots: %d (%d%%), Direct calls: %d (%d%%)\n", 
                        acfg->stats.ccount, acfg->stats.mcount, acfg->stats.mcount ? (acfg->stats.ccount * 100) / acfg->stats.mcount : 100,
                        llvm_stats_msg,
                        acfg->stats.methods_without_got_slots, acfg->stats.mcount ? (acfg->stats.methods_without_got_slots * 100) / acfg->stats.mcount : 100,
                        acfg->stats.direct_calls, acfg->stats.all_calls ? (acfg->stats.direct_calls * 100) / acfg->stats.all_calls : 100);
        if (acfg->stats.genericcount)
-               printf ("%d methods are generic (%d%%)\n", acfg->stats.genericcount, acfg->stats.mcount ? (acfg->stats.genericcount * 100) / acfg->stats.mcount : 100);
+               aot_printf (acfg, "%d methods are generic (%d%%)\n", acfg->stats.genericcount, acfg->stats.mcount ? (acfg->stats.genericcount * 100) / acfg->stats.mcount : 100);
        if (acfg->stats.abscount)
-               printf ("%d methods contain absolute addresses (%d%%)\n", acfg->stats.abscount, acfg->stats.mcount ? (acfg->stats.abscount * 100) / acfg->stats.mcount : 100);
+               aot_printf (acfg, "%d methods contain absolute addresses (%d%%)\n", acfg->stats.abscount, acfg->stats.mcount ? (acfg->stats.abscount * 100) / acfg->stats.mcount : 100);
        if (acfg->stats.lmfcount)
-               printf ("%d methods contain lmf pointers (%d%%)\n", acfg->stats.lmfcount, acfg->stats.mcount ? (acfg->stats.lmfcount * 100) / acfg->stats.mcount : 100);
+               aot_printf (acfg, "%d methods contain lmf pointers (%d%%)\n", acfg->stats.lmfcount, acfg->stats.mcount ? (acfg->stats.lmfcount * 100) / acfg->stats.mcount : 100);
        if (acfg->stats.ocount)
-               printf ("%d methods have other problems (%d%%)\n", acfg->stats.ocount, acfg->stats.mcount ? (acfg->stats.ocount * 100) / acfg->stats.mcount : 100);
+               aot_printf (acfg, "%d methods have other problems (%d%%)\n", acfg->stats.ocount, acfg->stats.mcount ? (acfg->stats.ocount * 100) / acfg->stats.mcount : 100);
 
        TV_GETTIME (atv);
        res = img_writer_emit_writeout (acfg->w);
@@ -9159,7 +9195,7 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
                int err = rename (tmp_outfile_name, outfile_name);
 
                if (err) {
-                       printf ("Unable to rename '%s' to '%s': %s\n", tmp_outfile_name, outfile_name, strerror (errno));
+                       aot_printf (acfg, "Unable to rename '%s' to '%s': %s\n", tmp_outfile_name, outfile_name, strerror (errno));
                        return 1;
                }
        } else {
@@ -9175,13 +9211,13 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
        if (acfg->aot_opts.stats) {
                int i;
 
-               printf ("GOT slot distribution:\n");
+               aot_printf (acfg, "GOT slot distribution:\n");
                for (i = 0; i < MONO_PATCH_INFO_NONE; ++i)
                        if (acfg->stats.got_slot_types [i])
-                               printf ("\t%s: %d (%d)\n", get_patch_name (i), acfg->stats.got_slot_types [i], acfg->stats.got_slot_info_sizes [i]);
+                               aot_printf (acfg, "\t%s: %d (%d)\n", get_patch_name (i), acfg->stats.got_slot_types [i], acfg->stats.got_slot_info_sizes [i]);
        }
 
-       printf ("JIT time: %d ms, Generation time: %d ms, Assembly+Link time: %d ms.\n", acfg->stats.jit_time / 1000, acfg->stats.gen_time / 1000, acfg->stats.link_time / 1000);
+       aot_printf (acfg, "JIT time: %d ms, Generation time: %d ms, Assembly+Link time: %d ms.\n", acfg->stats.jit_time / 1000, acfg->stats.gen_time / 1000, acfg->stats.link_time / 1000);
 
        acfg_free (acfg);
        
index 9babde72e88d4747f973d962878709d4719a1562..272616f04d95fd73d38360b23cc88f5ecd5039ca 100644 (file)
 #include <mono/utils/mono-mmap.h>
 #include "mono/utils/mono-compiler.h"
 #include <mono/utils/mono-counters.h>
+#include <mono/utils/mono-digest.h>
 
 #include "mini.h"
 #include "version.h"
 
 #ifndef DISABLE_AOT
 
+#ifdef TARGET_OSX
+#define ENABLE_AOT_CACHE
+#endif
+
 #ifdef TARGET_WIN32
 #define SHARED_EXT ".dll"
 #elif ((defined(__ppc__) || defined(__powerpc__) || defined(__ppc64__)) || defined(__MACH__)) && !defined(__linux__)
@@ -167,15 +172,11 @@ static GHashTable *ji_to_amodule;
 
 /*
  * Whenever to AOT compile loaded assemblies on demand and store them in
- * a cache under $HOME/.mono/aot-cache.
+ * a cache.
  */
-static gboolean use_aot_cache = FALSE;
+static gboolean enable_aot_cache = FALSE;
 
-/*
- * Whenever to spawn a new process to AOT a file or do it in-process. Only relevant if
- * use_aot_cache is TRUE.
- */
-static gboolean spawn_compiler = TRUE;
+static gboolean mscorlib_aot_loaded;
 
 /* For debugging */
 static gint32 mono_last_aot_method = -1;
@@ -243,7 +244,7 @@ load_image (MonoAotModule *amodule, int index, gboolean set_error)
 
        assembly = mono_assembly_load (&amodule->image_names [index], amodule->assembly->basedir, &status);
        if (!assembly) {
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT module %s is unusable because dependency %s is not found.\n", amodule->aot_name, amodule->image_names [index].name);
+               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable because dependency %s is not found.\n", amodule->aot_name, amodule->image_names [index].name);
                amodule->out_of_date = TRUE;
 
                if (set_error) {
@@ -255,7 +256,7 @@ load_image (MonoAotModule *amodule, int index, gboolean set_error)
        }
 
        if (strcmp (assembly->image->guid, amodule->image_guids [index])) {
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT module %s is unusable (GUID of dependent assembly %s doesn't match (expected '%s', got '%s').\n", amodule->aot_name, amodule->image_names [index].name, amodule->image_guids [index], assembly->image->guid);
+               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable (GUID of dependent assembly %s doesn't match (expected '%s', got '%s').\n", amodule->aot_name, amodule->image_names [index].name, amodule->image_guids [index], assembly->image->guid);
                amodule->out_of_date = TRUE;
                return NULL;
        }
@@ -1272,132 +1273,286 @@ decode_resolve_method_ref (MonoAotModule *module, guint8 *buf, guint8 **endbuf)
        return decode_resolve_method_ref_with_target (module, NULL, buf, endbuf);
 }
 
+#ifdef ENABLE_AOT_CACHE
+
+/* AOT CACHE */
+
+/*
+ * FIXME:
+ * - Add options for controlling the cache size
+ * - Handle full cache by deleting old assemblies lru style
+ * - Maybe add a threshold after an assembly is AOT compiled
+ * - Add options for enabling this for specific main assemblies
+ */
+
+/* The cache directory */
+static char *cache_dir;
+
+/* The number of assemblies AOTed in this run */
+static int cache_count;
+
+/* Whenever to AOT in-process */
+static gboolean in_process;
+
 static void
-create_cache_structure (void)
+collect_assemblies (gpointer data, gpointer user_data)
 {
-       const char *home;
-       char *tmp;
-       int err;
+       MonoAssembly *ass = data;
+       GSList **l = user_data;
 
-       home = g_get_home_dir ();
-       if (!home)
-               return;
+       *l = g_slist_prepend (*l, ass);
+}
 
-       tmp = g_build_filename (home, ".mono", NULL);
-       if (!g_file_test (tmp, G_FILE_TEST_IS_DIR)) {
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT creating directory %s", tmp);
-#ifdef HOST_WIN32
-               err = mkdir (tmp);
-#else
-               err = mkdir (tmp, 0777);
-#endif
-               if (err) {
-                       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT failed: %s", g_strerror (errno));
-                       g_free (tmp);
-                       return;
-               }
+#define SHA1_DIGEST_LENGTH 20
+
+/*
+ * get_aot_config_hash:
+ *
+ *   Return a hash for all the version information an AOT module depends on.
+ */
+static G_GNUC_UNUSED char*
+get_aot_config_hash (MonoAssembly *assembly)
+{
+       char *build_info;
+       GSList *l, *assembly_list = NULL;
+       GString *s;
+       int i;
+       guint8 digest [SHA1_DIGEST_LENGTH];
+       char *digest_str;
+
+       build_info = mono_get_runtime_build_info ();
+
+       s = g_string_new (build_info);
+
+       mono_assembly_foreach (collect_assemblies, &assembly_list);
+
+       /*
+        * The assembly list includes the current assembly as well, no need
+        * to add it.
+        */
+       for (l = assembly_list; l; l = l->next) {
+               MonoAssembly *ass = l->data;
+
+               g_string_append (s, "_");
+               g_string_append (s, ass->aname.name);
+               g_string_append (s, "_");
+               g_string_append (s, ass->image->guid);
        }
-       g_free (tmp);
-       tmp = g_build_filename (home, ".mono", "aot-cache", NULL);
-       if (!g_file_test (tmp, G_FILE_TEST_IS_DIR)) {
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT creating directory %s", tmp);
-#ifdef HOST_WIN32
-               err = mkdir (tmp);
-#else
-               err = mkdir (tmp, 0777);
-#endif
-               if (err) {
-                       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT failed: %s", g_strerror (errno));
-                       g_free (tmp);
-                       return;
-               }
+
+       for (i = 0; i < s->len; ++i) {
+               if (!isalnum (s->str [i]) && s->str [i] != '-')
+                       s->str [i] = '_';
        }
-       g_free (tmp);
+
+       mono_sha1_get_digest ((guint8*)s->str, s->len, digest);
+
+       digest_str = g_malloc0 ((SHA1_DIGEST_LENGTH * 2) + 1);
+       for (i = 0; i < SHA1_DIGEST_LENGTH; ++i)
+               sprintf (digest_str + (i * 2), "%02x", digest [i]);
+
+       mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: file dependencies: %s, hash %s", s->str, digest_str);
+
+       g_string_free (s, TRUE);
+
+       return digest_str;
+}
+
+static void
+aot_cache_init (void)
+{
+       if (mono_aot_only)
+               return;
+       enable_aot_cache = TRUE;
+       in_process = TRUE;
 }
 
 /*
- * load_aot_module_from_cache:
- *
- *  Experimental code to AOT compile loaded assemblies on demand. 
+ * aot_cache_load_module:
  *
- * FIXME: 
- * - Add environment variable MONO_AOT_CACHE_OPTIONS
- * - Add options for controlling the cache size
- * - Handle full cache by deleting old assemblies lru style
- * - Add options for excluding assemblies during development
- * - Maybe add a threshold after an assembly is AOT compiled
- * - invoking a new mono process is a security risk
- * - recompile the AOT module if one of its dependencies changes
+ *   Load the AOT image corresponding to ASSEMBLY from the aot cache, AOTing it if neccessary.
  */
 static MonoDl*
-load_aot_module_from_cache (MonoAssembly *assembly, char **aot_name)
+aot_cache_load_module (MonoAssembly *assembly, char **aot_name)
 {
-       char *fname, *cmd, *tmp2, *aot_options;
+       MonoAotCacheConfig *config;
+       GSList *l;
+       char *fname, *tmp2, *aot_options, *failure_fname;
        const char *home;
        MonoDl *module;
        gboolean res;
-       gchar *out, *err;
        gint exit_status;
+       char *hash;
+       int pid;
+       gboolean enabled;
+       FILE *failure_file;
 
        *aot_name = NULL;
 
        if (image_is_dynamic (assembly->image))
                return NULL;
 
-       create_cache_structure ();
+       /* Check in the list of assemblies enabled for aot caching */
+       config = mono_get_aot_cache_config ();
+
+       enabled = FALSE;
+       if (config->apps) {
+               MonoDomain *domain = mono_domain_get ();
+               MonoAssembly *entry_assembly = domain->entry_assembly;
 
-       home = g_get_home_dir ();
+               // FIXME: This cannot be used for mscorlib during startup, since entry_assembly is not set yet
+               for (l = config->apps; l; l = l->next) {
+                       char *n = l->data;
 
-       tmp2 = g_strdup_printf ("%s-%s%s", assembly->image->assembly_name, assembly->image->guid, SHARED_EXT);
-       fname = g_build_filename (home, ".mono", "aot-cache", tmp2, NULL);
+                       if ((entry_assembly && !strcmp (entry_assembly->aname.name, n)) || (!entry_assembly && !strcmp (assembly->aname.name, n)))
+                               break;
+               }
+               if (l)
+                       enabled = TRUE;
+       }
+
+       if (!enabled) {
+               for (l = config->assemblies; l; l = l->next) {
+                       char *n = l->data;
+
+                       if (!strcmp (assembly->aname.name, n))
+                               break;
+               }
+               if (l)
+                       enabled = TRUE;
+       }
+       if (!enabled)
+               return NULL;
+
+       if (!cache_dir) {
+               home = g_get_home_dir ();
+               if (!home)
+                       return NULL;
+               cache_dir = g_strdup_printf ("%s/Library/Caches/mono/aot-cache", home);
+               if (!g_file_test (cache_dir, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_DIR))
+                       g_mkdir_with_parents (cache_dir, 0777);
+       }
+
+       /*
+        * The same assembly can be used in multiple configurations, i.e. multiple
+     * versions of the runtime, with multiple versions of dependent assemblies etc.
+        * To handle this, we compute a version string containing all this information, hash it,
+        * and use the hash as a filename suffix.
+        */
+       hash = get_aot_config_hash (assembly);
+
+       tmp2 = g_strdup_printf ("%s-%s%s", assembly->image->assembly_name, hash, SHARED_EXT);
+       fname = g_build_filename (cache_dir, tmp2, NULL);
        *aot_name = fname;
        g_free (tmp2);
 
-       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT trying to load from cache: '%s'.", fname);
+       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: loading from cache: '%s'.", fname);
        module = mono_dl_open (fname, MONO_DL_LAZY, NULL);
 
-       if (!module) {
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT not found.");
+       if (module)
+               return module;
 
-               mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT precompiling assembly '%s'... ", assembly->image->name);
+       if (!strcmp (assembly->aname.name, "mscorlib") && !mscorlib_aot_loaded)
+               /*
+                * Can't AOT this during startup, so we AOT it when called later from
+                * mono_aot_get_method ().
+                */
+               return NULL;
 
-               aot_options = g_strdup_printf ("outfile=%s", fname);
+       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: not found.");
 
-               if (spawn_compiler) {
-                       /* FIXME: security */
-                       /* FIXME: Has to pass the assembly loading path to the child process */
-                       cmd = g_strdup_printf ("mono -O=all --aot=%s %s", aot_options, assembly->image->name);
+       /* Only AOT one assembly per run to avoid slowing down execution too much */
+       if (cache_count > 0)
+               return NULL;
+       cache_count ++;
+
+       /* Check for previous failure */
+       failure_fname = g_strdup_printf ("%s.failure", fname);
+       failure_file = fopen (failure_fname, "r");
+       if (failure_file) {
+               mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: assembly '%s' previously failed to compile '%s' ('%s')... ", assembly->image->name, fname, failure_fname);
+               g_free (failure_fname);
+               return NULL;
+       } else {
+               g_free (failure_fname);
+               fclose (failure_file);
+       }
 
-                       res = g_spawn_command_line_sync (cmd, &out, &err, &exit_status, NULL);
+       mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: compiling assembly '%s'... ", assembly->image->name);
 
-#if !defined(HOST_WIN32) && !defined(__ppc__) && !defined(__ppc64__) && !defined(__powerpc__)
-                       if (res) {
-                               if (!WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) == 0))
-                                       mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT failed: %s.", err);
-                               else
-                                       mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT succeeded.");
-                               g_free (out);
-                               g_free (err);
-                       }
-#endif
-                       g_free (cmd);
-               } else {
+       /*
+        * We need to invoke the AOT compiler here. There are multiple approaches:
+        * - spawn a new runtime process. This can be hard when running with mkbundle, and
+        * its hard to make the new process load the same set of assemblies.
+        * - doing it in-process. This exposes the current process to bugs/leaks/side effects of
+        * the AOT compiler.
+        * - fork a new process and do the work there.
+        */
+       if (in_process) {
+               aot_options = g_strdup_printf ("outfile=%s,internal-logfile=%s.log", fname, fname);
+               /* Maybe due this in another thread ? */
+               res = mono_compile_assembly (assembly, mono_parse_default_optimizations (NULL), aot_options);
+               if (!res) {
+                       failure_fname = g_strdup_printf ("%s.failure", fname);
+                       failure_file = fopen (failure_fname, "a+");
+                       fclose (failure_file);
+                       g_free (failure_fname);
+               }
+       } else {
+               /*
+                * - Avoid waiting for the aot process to finish ?
+                *   (less overhead, but multiple processes could aot the same assembly at the same time)
+                */
+               pid = fork ();
+               if (pid == 0) {
+                       FILE *logfile;
+                       char *logfile_name;
+
+                       /* Child */
+
+                       logfile_name = g_strdup_printf ("%s/aot.log", cache_dir);
+                       logfile = fopen (logfile_name, "a+");
+                       g_free (logfile_name);
+
+                       dup2 (fileno (logfile), 1);
+                       dup2 (fileno (logfile), 2);
+
+                       aot_options = g_strdup_printf ("outfile=%s", fname);
                        res = mono_compile_assembly (assembly, mono_parse_default_optimizations (NULL), aot_options);
                        if (!res) {
-                               mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT failed.");
+                               exit (1);
                        } else {
-                               mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT succeeded.");
+                               exit (0);
                        }
+               } else {
+                       /* Parent */
+                       waitpid (pid, &exit_status, 0);
+                       if (!WIFEXITED (exit_status) && (WEXITSTATUS (exit_status) == 0))
+                               mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: failed.");
+                       else
+                               mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: succeeded.");
                }
-
-               module = mono_dl_open (fname, MONO_DL_LAZY, NULL);
-
-               g_free (aot_options);
        }
 
+       module = mono_dl_open (fname, MONO_DL_LAZY, NULL);
+
        return module;
 }
 
+#else
+
+static void
+aot_cache_init (void)
+{
+}
+
+static MonoDl*
+aot_cache_load_module (MonoAssembly *assembly, char **aot_name)
+{
+       return NULL;
+}
+
+#endif
+
 static void
 find_symbol (MonoDl *module, gpointer *globals, const char *name, gpointer *value)
 {
@@ -1596,16 +1751,17 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
                info = NULL;
        mono_aot_unlock ();
 
+       sofile = NULL;
+
        if (info) {
                /* Statically linked AOT module */
-               sofile = NULL;
                aot_name = g_strdup_printf ("%s", assembly->aname.name);
                mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "Found statically linked AOT module '%s'.\n", aot_name);
                globals = info->globals;
        } else {
-               if (use_aot_cache)
-                       sofile = load_aot_module_from_cache (assembly, &aot_name);
-               else {
+               if (enable_aot_cache)
+                       sofile = aot_cache_load_module (assembly, &aot_name);
+               if (!sofile) {
                        char *err;
                        aot_name = g_strdup_printf ("%s%s", assembly->image->name, SHARED_EXT);
 
@@ -1652,7 +1808,7 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
                        fprintf (stderr, "Failed to load AOT module '%s' while running in aot-only mode: %s.\n", aot_name, msg);
                        exit (1);
                } else {
-                       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT module %s is unusable: %s.\n", aot_name, msg);
+                       mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: module %s is unusable: %s.\n", aot_name, msg);
                }
                g_free (msg);
                g_free (aot_name);
@@ -1873,14 +2029,14 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
        }
 
        if (amodule->out_of_date) {
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT Module %s is unusable because a dependency is out-of-date.\n", assembly->image->name);
+               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: Module %s is unusable because a dependency is out-of-date.\n", assembly->image->name);
                if (mono_aot_only) {
                        fprintf (stderr, "Failed to load AOT module '%s' while running in aot-only mode because a dependency cannot be found or it is out of date.\n", aot_name);
                        exit (1);
                }
        }
        else
-               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT loaded AOT Module for %s.\n", assembly->image->name);
+               mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: loaded AOT Module for %s.\n", assembly->image->name);
 }
 
 /*
@@ -1943,8 +2099,7 @@ mono_aot_init (void)
 
        if (g_getenv ("MONO_LASTAOT"))
                mono_last_aot_method = atoi (g_getenv ("MONO_LASTAOT"));
-       if (g_getenv ("MONO_AOT_CACHE"))
-               use_aot_cache = TRUE;
+       aot_cache_init ();
 }
 
 void
@@ -2537,6 +2692,7 @@ decode_exception_debug_info (MonoAotModule *amodule, MonoDomain *domain,
 
                eh_info = mono_jit_info_get_arch_eh_info (jinfo);
                eh_info->stack_size = decode_value (p, &p);
+               eh_info->epilog_size = decode_value (p, &p);
        }
 
        if (async) {
@@ -2696,8 +2852,7 @@ mono_aot_get_unwind_info (MonoJitInfo *ji, guint32 *unwind_info_len)
                mono_aot_unlock ();
        }
 
-       /* The upper 16 bits of ji->unwind_info might contain the epilog offset */
-       p = amodule->unwind_info + (ji->unwind_info & 0xffff);
+       p = amodule->unwind_info + ji->unwind_info;
        *unwind_info_len = decode_value (p, &p);
        return p;
 }
@@ -3324,7 +3479,7 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
                        if (!method)
                                method = mono_get_method (image, token, NULL);
                        full_name = mono_method_full_name (method, TRUE);
-                       mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT NOT FOUND: %s.", full_name);
+                       mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT: NOT FOUND: %s.", full_name);
                        g_free (full_name);
                }
                return NULL;
@@ -3443,7 +3598,7 @@ load_method (MonoDomain *domain, MonoAotModule *amodule, MonoImage *image, MonoM
                if (!jinfo)
                        jinfo = mono_aot_find_jit_info (domain, amodule->assembly->image, code);
 
-               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT FOUND method %s [%p - %p %p]", full_name, code, code + jinfo->code_size, info);
+               mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT: FOUND method %s [%p - %p %p]", full_name, code, code + jinfo->code_size, info);
                g_free (full_name);
        }
 
@@ -3639,6 +3794,15 @@ mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
        MonoAotModule *amodule = klass->image->aot_module;
        guint8 *code;
 
+       if (enable_aot_cache && !amodule && domain->entry_assembly && klass->image == mono_defaults.corlib) {
+               /* This cannot be AOTed during startup, so do it now */
+               if (!mscorlib_aot_loaded) {
+                       mscorlib_aot_loaded = TRUE;
+                       load_aot_module (klass->image->assembly, NULL);
+                       amodule = klass->image->aot_module;
+               }
+       }
+
        if (!amodule)
                return NULL;
 
@@ -4149,7 +4313,7 @@ load_function_full (MonoAotModule *amodule, const char *name, MonoTrampInfo **ou
        if (!code)
                g_error ("Symbol '%s' not found in AOT file '%s'.\n", name, amodule->aot_name);
 
-       mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT FOUND function '%s' in AOT file '%s'.", name, amodule->aot_name);
+       mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "AOT: FOUND function '%s' in AOT file '%s'.", name, amodule->aot_name);
 
        /* Load info */
 
@@ -4770,7 +4934,7 @@ mono_aot_set_make_unreadable (gboolean unreadable)
        make_unreadable = unreadable;
 
        if (make_unreadable && !inited) {
-               mono_counters_register ("AOT pagefaults", MONO_COUNTER_JIT | MONO_COUNTER_INT, &n_pagefaults);
+               mono_counters_register ("AOT: pagefaults", MONO_COUNTER_JIT | MONO_COUNTER_INT, &n_pagefaults);
        }               
 }
 
index 6249ed00c66ba26ebb3dc652efcc9ced30b49b7d..5919430186944c79d1bc0037ae77e8d81457d584 100644 (file)
@@ -1581,7 +1581,7 @@ transport_handshake (void)
 
        /* Read answer */
        res = transport_recv (buf, strlen (handshake_msg));
-       if ((res != strlen (handshake_msg)) || (memcmp (buf, handshake_msg, strlen (handshake_msg) != 0))) {
+       if ((res != strlen (handshake_msg)) || (memcmp (buf, handshake_msg, strlen (handshake_msg)) != 0)) {
                fprintf (stderr, "debugger-agent: DWP handshake failed.\n");
                return FALSE;
        }
index 2929e813a4dfdf33ad9e44052ffa0766366bb9c1..7b34b18df0e92c976e0dd49e31927121a4c50103 100644 (file)
@@ -1903,6 +1903,11 @@ mono_main (int argc, char* argv[])
                mono_load_coree (argv [i]);
 #endif
 
+       /* Parse gac loading options before loading assemblies. */
+       if (mono_compile_aot || action == DO_EXEC || action == DO_DEBUGGER) {
+               mono_config_parse (config_file);
+       }
+
        mono_set_defaults (mini_verbose, opt);
        domain = mini_init (argv [i], forced_version);
 
@@ -1968,11 +1973,6 @@ mono_main (int argc, char* argv[])
                break;
        }
 
-       /* Parse gac loading options before loading assemblies. */
-       if (mono_compile_aot || action == DO_EXEC || action == DO_DEBUGGER) {
-               mono_config_parse (config_file);
-       }
-
 #ifdef MONO_JIT_INFO_TABLE_TEST
        if (test_jit_info_table)
                jit_info_table_test (domain);
index 2a253a8cef8b5e52f6a0d4c1f4506d3f52970bc9..12b4ef31dde102e27377b1ed2d0f4f65f740112e 100644 (file)
@@ -604,7 +604,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
                printf ("%s %p %p\n", ji->d.method->name, ji->code_start, ip);
                mono_print_unwind_info (unwind_info, unwind_info_len);
                */
-               epilog = (guint8*)ji->code_start + ji->code_size - (ji->unwind_info >> 16);
+               epilog = (guint8*)ji->code_start + ji->code_size - mono_jinfo_get_epilog_size (ji);
  
                regs [AMD64_RAX] = new_ctx->rax;
                regs [AMD64_RBX] = new_ctx->rbx;
index 27f26a14a7681dc22de0be5515179fa8b677c389..8a52d6a7a230e4255476b916593de4a1140d59d1 100644 (file)
@@ -12155,8 +12155,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                guint32 val;
                                int ialign;
 
-                               GSHAREDVT_FAILURE (*ip);
-
                                CHECK_STACK_OVF (1);
                                CHECK_OPSIZE (6);
                                token = read32 (ip + 2);
@@ -12168,6 +12166,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                        CHECK_TYPELOAD (klass);
                                        mono_class_init (klass);
                                        val = mono_type_size (&klass->byval_arg, &ialign);
+
+                                       if (mini_is_gsharedvt_klass (cfg, klass))
+                                               GSHAREDVT_FAILURE (*ip);
                                }
                                EMIT_NEW_ICONST (cfg, ins, val);
                                *sp++= ins;
index 7659466cd243880bbea1d68d553d76a3a6dace32..5993ddddb63364b5b9834e3ea006d7260079572e 100644 (file)
@@ -2759,6 +2759,16 @@ mono_jinfo_get_unwind_info (MonoJitInfo *ji, guint32 *unwind_info_len)
        if (ji->from_aot)
                return mono_aot_get_unwind_info (ji, unwind_info_len);
        else
-               /* The upper 16 bits of ji->unwind_info might contain the epilog offset */
-               return mono_get_cached_unwind_info (ji->unwind_info & 0xffff, unwind_info_len);
+               return mono_get_cached_unwind_info (ji->unwind_info, unwind_info_len);
+}
+
+int
+mono_jinfo_get_epilog_size (MonoJitInfo *ji)
+{
+       MonoArchEHJitInfo *info;
+
+       info = mono_jit_info_get_arch_eh_info (ji);
+       g_assert (info);
+
+       return info->epilog_size;
 }
index acb623366fde2d9b67d54882947e6aa3b95be750..f65dab8c1e77f6220613e59111a84dd927597b90 100644 (file)
@@ -983,7 +983,7 @@ create_delegate_trampoline_data (MonoDomain *domain, MonoClass *klass, MonoMetho
        invoke = mono_get_delegate_invoke (klass);
        g_assert (invoke);
 
-       tramp_data = mono_domain_alloc (domain, sizeof (MonoDelegateTrampInfo));
+       tramp_data = mono_domain_alloc0 (domain, sizeof (MonoDelegateTrampInfo));
        tramp_data->invoke = invoke;
        tramp_data->invoke_sig = mono_method_signature (invoke);
        tramp_data->impl_this = mono_arch_get_delegate_invoke_impl (mono_method_signature (invoke), TRUE);
index 03e0eb7f8b316a1e3239cae16922762e878f89e2..a31e9003a13596f56a2bff26c347a6bd75ae4be1 100644 (file)
@@ -4354,6 +4354,9 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
                if (stack_size)
                        arch_eh_info_size = sizeof (MonoArchEHJitInfo);
        }
+
+       if (cfg->has_unwind_info_for_epilog && !arch_eh_info_size)
+               arch_eh_info_size = sizeof (MonoArchEHJitInfo);
                
        if (cfg->try_block_holes) {
                for (tmp = cfg->try_block_holes; tmp; tmp = tmp->next) {
@@ -4651,16 +4654,13 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
                unwind_desc = mono_cache_unwind_info (unwind_info, info_len);
 
                if (cfg->has_unwind_info_for_epilog) {
-                       /*
-                        * The lower 16 bits identify the unwind descriptor, the upper 16 bits contain the offset of
-                        * the start of the epilog from the end of the method.
-                        */
-                       g_assert (unwind_desc < 0xffff);
-                       g_assert (cfg->code_size - cfg->epilog_begin < 0xffff);
-                       jinfo->unwind_info = ((cfg->code_size - cfg->epilog_begin) << 16) | unwind_desc;
-               } else {
-                       jinfo->unwind_info = unwind_desc;
+                       MonoArchEHJitInfo *info;
+
+                       info = mono_jit_info_get_arch_eh_info (jinfo);
+                       g_assert (info);
+                       info->epilog_size = cfg->code_size - cfg->epilog_begin;
                }
+               jinfo->unwind_info = unwind_desc;
                g_free (unwind_info);
        } else {
                jinfo->unwind_info = cfg->used_int_regs;
index cccdc09561637a012045b0ec0c9b0e06cd766168..4bb5ad1d7d4641a6e6a275e2d41567e5550cb4d7 100644 (file)
 #endif
 
 /* Version number of the AOT file format */
-#define MONO_AOT_FILE_VERSION 101
+#define MONO_AOT_FILE_VERSION 102
 
 //TODO: This is x86/amd64 specific.
 #define mono_simd_shuffle_mask(a,b,c,d) ((a) | ((b) << 2) | ((c) << 4) | ((d) << 6))
@@ -2511,6 +2511,7 @@ typedef gboolean (*MonoExceptionFrameWalk)      (MonoMethod *method, gpointer ip
 gboolean mono_exception_walk_trace              (MonoException *ex, MonoExceptionFrameWalk func, gpointer user_data);
 void mono_restore_context                       (MonoContext *ctx) MONO_INTERNAL;
 guint8* mono_jinfo_get_unwind_info              (MonoJitInfo *ji, guint32 *unwind_info_len) MONO_INTERNAL;
+int  mono_jinfo_get_epilog_size                 (MonoJitInfo *ji) MONO_INTERNAL;
 
 gboolean
 mono_find_jit_info_ext (MonoDomain *domain, MonoJitTlsData *jit_tls, 
index 50d57970fe6e791d268f64c6662dbe49cf3a23ab..9ba8502250f72f86aaf5dd58682fef27ebbdf4c7 100644 (file)
@@ -973,7 +973,7 @@ mono_arch_create_monitor_enter_trampoline (MonoTrampInfo **info, gboolean aot)
 
        unwind_ops = mono_arch_get_cie_program ();
 
-       if (mono_thread_get_tls_offset () != -1) {
+       if (!aot && mono_thread_get_tls_offset () != -1) {
                /* MonoObject* obj is in RDI */
                /* is obj null? */
                amd64_test_reg_reg (code, AMD64_RDI, AMD64_RDI);
@@ -1098,7 +1098,7 @@ mono_arch_create_monitor_exit_trampoline (MonoTrampInfo **info, gboolean aot)
 
        unwind_ops = mono_arch_get_cie_program ();
 
-       if (mono_thread_get_tls_offset () != -1) {
+       if (!aot && mono_thread_get_tls_offset () != -1) {
                /* MonoObject* obj is in RDI */
                /* is obj null? */
                amd64_test_reg_reg (code, AMD64_RDI, AMD64_RDI);
index 801a1777460081f7279e917ffeeb917676588e6b..c5464d16b168375dc3ac31375765a299ebeaa97b 100644 (file)
@@ -99,6 +99,10 @@ monoutils_sources = \
        mono-threads-mach.c     \
        mono-threads-mach-helper.c      \
        mono-threads-windows.c  \
+       mono-threads-linux.c    \
+       mono-threads-freebsd.c  \
+       mono-threads-openbsd.c  \
+       mono-threads-android.c  \
        mono-threads.h  \
        mono-tls.h      \
        mono-tls.c      \
@@ -112,7 +116,9 @@ monoutils_sources = \
        bsearch.c       \
        mono-signal-handler.h   \
        mono-conc-hashtable.h   \
-       mono-conc-hashtable.c
+       mono-conc-hashtable.c   \
+       sha1.h          \
+       sha1.c
 
 arch_sources = 
 
index cd3a838049e77d41ed4b3e368890400c7375a48e..a6be2717e5832dd07bf50c881218d5c1b20def75 100644 (file)
@@ -16,6 +16,7 @@ static MonoTraceMask current_mask             = MONO_TRACE_ALL;
 
 static const char      *mono_log_domain        = "Mono";
 static GQueue          *level_stack            = NULL;
+static MonoPrintCallback print_callback, printerr_callback;
 
 /**
  * mono_trace_init:
@@ -295,6 +296,17 @@ mono_trace_set_log_handler (MonoLogCallback callback, void *user_data)
        g_log_set_default_handler (log_adapter, user_data);
 }
 
+static void
+print_handler (const char *string)
+{
+       print_callback (string, TRUE);
+}
+
+static void
+printerr_handler (const char *string)
+{
+       printerr_callback (string, FALSE);
+}
 
 /**
  * mono_trace_set_print_handler:
@@ -308,7 +320,8 @@ void
 mono_trace_set_print_handler (MonoPrintCallback callback)
 {
        g_assert (callback);
-       g_set_print_handler (callback);
+       print_callback = callback;
+       g_set_print_handler (print_handler);
 }
 
 /**
@@ -323,5 +336,6 @@ void
 mono_trace_set_printerr_handler (MonoPrintCallback callback)
 {
        g_assert (callback);
-       g_set_printerr_handler (callback);
+       printerr_callback = callback;
+       g_set_print_handler (printerr_handler);
 }
diff --git a/mono/utils/mono-threads-android.c b/mono/utils/mono-threads-android.c
new file mode 100644 (file)
index 0000000..a72ee81
--- /dev/null
@@ -0,0 +1,9 @@
+#include <config.h>
+
+#if defined(PLATFORM_ANDROID)
+
+#ifdef ENABLE_EXTENSION_MODULE
+#include "../../../mono-extensions/mono/utils/mono-threads-android.c"
+#endif
+
+#endif
diff --git a/mono/utils/mono-threads-freebsd.c b/mono/utils/mono-threads-freebsd.c
new file mode 100644 (file)
index 0000000..7cbbca1
--- /dev/null
@@ -0,0 +1,24 @@
+#include <config.h>
+
+#if defined(__FreeBSD__)
+
+#include <pthread.h>
+#include <pthread_np.h>
+
+void
+mono_threads_core_get_stack_bounds (guint8 **staddr, size_t *stsize)
+{
+       pthread_attr_t attr;
+       guint8 *current = (guint8*)&attr;
+
+       *staddr = NULL;
+       *stsize = (size_t)-1;
+
+       pthread_attr_init (&attr);
+       pthread_attr_get_np (pthread_self (), &attr);
+
+       pthread_attr_getstack (&attr, (void**)staddr, stsize);
+       pthread_attr_destroy (&attr);
+}
+
+#endif
diff --git a/mono/utils/mono-threads-linux.c b/mono/utils/mono-threads-linux.c
new file mode 100644 (file)
index 0000000..e2ee61c
--- /dev/null
@@ -0,0 +1,21 @@
+#include <config.h>
+
+#if defined(__linux__) && !defined(PLATFORM_ANDROID)
+
+#include <mono/utils/mono-threads.h>
+#include <pthread.h>
+
+void
+mono_threads_core_get_stack_bounds (guint8 **staddr, size_t *stsize)
+{
+       pthread_attr_t attr;
+
+       *staddr = NULL;
+       *stsize = (size_t)-1;
+
+       pthread_getattr_np (pthread_self (), &attr);
+       pthread_attr_getstack (&attr, (void**)staddr, stsize);
+       pthread_attr_destroy (&attr);
+}
+
+#endif
index f4ad2637e57e51c2f04688c586e67870e05041c4..4ed6820e900d934de2c45d939021e943a04b02d3 100644 (file)
 
 #if defined(__MACH__)
 
+/* For pthread_main_np, pthread_get_stackaddr_np and pthread_get_stacksize_np */
+#define _DARWIN_C_SOURCE 1
+
 #include <mono/utils/mach-support.h>
 #include <mono/utils/mono-compiler.h>
 #include <mono/utils/mono-semaphore.h>
 #include <mono/utils/mono-threads.h>
 #include <mono/utils/hazard-pointer.h>
+#include <mono/utils/mono-mmap.h>
 #include <mono/metadata/gc-internal.h>
 #include <mono/metadata/appdomain.h>
 #include <mono/metadata/threads-types.h>
 
-#include <pthread.h>
-#include <errno.h>
-
 void
 mono_threads_init_platform (void)
 {
@@ -148,4 +149,24 @@ mono_threads_core_set_name (MonoNativeThreadId tid, const char *name)
        /* pthread_setnmae_np() on Mac is not documented and doesn't receive thread id. */
 }
 
+void
+mono_threads_core_get_stack_bounds (guint8 **staddr, size_t *stsize)
+{
+       *staddr = (guint8*)pthread_get_stackaddr_np (pthread_self());
+       *stsize = pthread_get_stacksize_np (pthread_self());
+
+#ifdef TARGET_OSX
+       /*
+        * Mavericks reports stack sizes as 512kb:
+        * http://permalink.gmane.org/gmane.comp.java.openjdk.hotspot.devel/11590
+        * https://bugs.openjdk.java.net/browse/JDK-8020753
+        */
+       if (pthread_main_np () && *stsize == 512 * 1024)
+               *stsize = 2048 * mono_pagesize ();
+#endif
+
+       /* staddr points to the start of the stack, not the end */
+       *staddr -= *stsize;
+}
+
 #endif
diff --git a/mono/utils/mono-threads-openbsd.c b/mono/utils/mono-threads-openbsd.c
new file mode 100644 (file)
index 0000000..96a9622
--- /dev/null
@@ -0,0 +1,32 @@
+#include <config.h>
+
+#if defined(__OpenBSD__)
+
+#include <pthread.h>
+#include <pthread_np.h>
+
+void
+mono_threads_core_get_stack_bounds (guint8 **staddr, size_t *stsize)
+{
+       /* TODO :   Determine if this code is actually still needed. It may already be covered by the case above. */
+       pthread_attr_t attr;
+       guint8 *current = (guint8*)&attr;
+
+       *staddr = NULL;
+       *stsize = (size_t)-1;
+
+       pthread_attr_init (&attr);
+
+       stack_t ss;
+       int rslt;
+
+       rslt = pthread_stackseg_np (pthread_self (), &ss);
+       g_assert (rslt == 0);
+
+       *staddr = (guint8*)((size_t)ss.ss_sp - ss.ss_size);
+       *stsize = ss.ss_size;
+
+       pthread_attr_destroy (&attr);
+}
+
+#endif
index 8a21c553054ececad51ede4fa23538c47ce95490..ce087bbc36bb4e5d7b9d5e12f1885d7a0a5dcd27 100644 (file)
@@ -9,17 +9,6 @@
 
 #include <config.h>
 
-#if defined(TARGET_OSX)
-/* For pthread_main_np () */
-#define _DARWIN_C_SOURCE 1
-#include <pthread.h>
-#endif
-
-#if defined(__OpenBSD__) || defined(__FreeBSD__)
-#include <pthread.h>
-#include <pthread_np.h>
-#endif
-
 #include <mono/utils/mono-compiler.h>
 #include <mono/utils/mono-semaphore.h>
 #include <mono/utils/mono-threads.h>
 extern int tkill (pid_t tid, int signal);
 #endif
 
-#if defined(PLATFORM_MACOSX) && defined(HAVE_PTHREAD_GET_STACKADDR_NP)
-void *pthread_get_stackaddr_np(pthread_t);
-size_t pthread_get_stacksize_np(pthread_t);
-#endif
-
 #if defined(_POSIX_VERSION) || defined(__native_client__)
 #include <sys/resource.h>
 #include <signal.h>
@@ -185,113 +169,6 @@ mono_threads_core_resume_created (MonoThreadInfo *info, MonoNativeThreadId tid)
        MONO_SEM_POST (&info->create_suspended_sem);
 }
 
-void
-mono_threads_core_get_stack_bounds (guint8 **staddr, size_t *stsize)
-{
-#if defined(HAVE_PTHREAD_GET_STACKSIZE_NP) && defined(HAVE_PTHREAD_GET_STACKADDR_NP)
-       /* Mac OS X */
-       *staddr = (guint8*)pthread_get_stackaddr_np (pthread_self());
-       *stsize = pthread_get_stacksize_np (pthread_self());
-
-#ifdef TARGET_OSX
-       /*
-        * Mavericks reports stack sizes as 512kb:
-        * http://permalink.gmane.org/gmane.comp.java.openjdk.hotspot.devel/11590
-        * https://bugs.openjdk.java.net/browse/JDK-8020753
-        */
-       if (pthread_main_np () && *stsize == 512 * 1024)
-               *stsize = 2048 * mono_pagesize ();
-#endif
-
-       /* staddr points to the start of the stack, not the end */
-       *staddr -= *stsize;
-
-       /* When running under emacs, sometimes staddr is not aligned to a page size */
-       *staddr = (guint8*)((gssize)*staddr & ~(mono_pagesize() - 1));
-       return;
-
-#elif (defined(HAVE_PTHREAD_GETATTR_NP) || defined(HAVE_PTHREAD_ATTR_GET_NP)) && defined(HAVE_PTHREAD_ATTR_GETSTACK)
-       /* Linux, BSD */
-
-       pthread_attr_t attr;
-       guint8 *current = (guint8*)&attr;
-
-       *staddr = NULL;
-       *stsize = (size_t)-1;
-
-       pthread_attr_init (&attr);
-
-#if     defined(HAVE_PTHREAD_GETATTR_NP)
-       /* Linux */
-       pthread_getattr_np (pthread_self(), &attr);
-
-#elif   defined(HAVE_PTHREAD_ATTR_GET_NP)
-       /* BSD */
-       pthread_attr_get_np (pthread_self(), &attr);
-
-#else
-#error         Cannot determine which API is needed to retrieve pthread attributes.
-#endif
-
-       pthread_attr_getstack (&attr, (void**)staddr, stsize);
-       pthread_attr_destroy (&attr);
-
-       if (*staddr)
-               g_assert ((current > *staddr) && (current < *staddr + *stsize));
-
-       /* When running under emacs, sometimes staddr is not aligned to a page size */
-       *staddr = (guint8*)((gssize)*staddr & ~(mono_pagesize () - 1));
-       return;
-
-#elif defined(__OpenBSD__)
-       /* OpenBSD */
-       /* TODO :   Determine if this code is actually still needed. It may already be covered by the case above. */
-
-       pthread_attr_t attr;
-       guint8 *current = (guint8*)&attr;
-
-       *staddr = NULL;
-       *stsize = (size_t)-1;
-
-       pthread_attr_init (&attr);
-
-       stack_t ss;
-       int rslt;
-
-       rslt = pthread_stackseg_np(pthread_self(), &ss);
-       g_assert (rslt == 0);
-
-       *staddr = (guint8*)((size_t)ss.ss_sp - ss.ss_size);
-       *stsize = ss.ss_size;
-
-       pthread_attr_destroy (&attr);
-
-       if (*staddr)
-               g_assert ((current > *staddr) && (current < *staddr + *stsize));
-
-       /* When running under emacs, sometimes staddr is not aligned to a page size */
-       *staddr = (guint8*)((gssize)*staddr & ~(mono_pagesize () - 1));
-       return;
-
-#elif defined(sun) || defined(__native_client__)
-       /* Solaris/Illumos, NaCl */
-       pthread_attr_t attr;
-       pthread_attr_init (&attr);
-       pthread_attr_getstacksize (&attr, &stsize);
-       pthread_attr_destroy (&attr);
-       *staddr = NULL;
-       return;
-
-#else
-       /* FIXME:   It'd be better to use the 'error' preprocessor macro here so we know
-                   at compile-time if the target platform isn't supported. */
-#warning "Unable to determine how to retrieve a thread's stack-bounds for this platform in 'mono_thread_get_stack_bounds()'."
-       *staddr = NULL;
-       *stsize = 0;
-       return;
-#endif
-}
-
 gboolean
 mono_threads_core_yield (void)
 {
index 195a919c3e74edfea257ca795968c5f5bb8830a1..cbb768aea8cc1b5a88a42878794704b4e1e2e73e 100644 (file)
@@ -14,6 +14,7 @@
 #include <mono/utils/mono-tls.h>
 #include <mono/utils/hazard-pointer.h>
 #include <mono/utils/mono-memory-model.h>
+#include <mono/utils/mono-mmap.h>
 
 #include <errno.h>
 
@@ -787,7 +788,16 @@ mono_threads_create_thread (LPTHREAD_START_ROUTINE start, gpointer arg, guint32
 void
 mono_thread_info_get_stack_bounds (guint8 **staddr, size_t *stsize)
 {
+       guint8 *current = (guint8 *)&stsize;
        mono_threads_core_get_stack_bounds (staddr, stsize);
+       if (!*staddr)
+               return;
+
+       /* Sanity check the result */
+       g_assert ((current > *staddr) && (current < *staddr + *stsize));
+
+       /* When running under emacs, sometimes staddr is not aligned to a page size */
+       *staddr = (guint8*)((gssize)*staddr & ~(mono_pagesize () - 1));
 }
 
 gboolean
diff --git a/mono/utils/sha1.c b/mono/utils/sha1.c
new file mode 100644 (file)
index 0000000..7dec326
--- /dev/null
@@ -0,0 +1,176 @@
+/*     $OpenBSD: sha1.c,v 1.22 2012/08/27 21:05:43 miod Exp $  */
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ *
+ * Test Vectors (from FIPS PUB 180-1)
+ * "abc"
+ *   A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+ * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ *   84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+ * A million repetitions of "a"
+ *   34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+ */
+
+#include <sys/param.h>
+#include <string.h>
+#include <stdint.h>
+#include <sha1.h>
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/*
+ * blk0() and blk() perform the initial expand.
+ * I got the idea of expanding during the round function from SSLeay
+ */
+#if BYTE_ORDER == LITTLE_ENDIAN
+# define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
+    |(rol(block->l[i],8)&0x00FF00FF))
+#else
+# define blk0(i) block->l[i]
+#endif
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+    ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/*
+ * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1
+ */
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+typedef union {
+       guint8 c[64];
+       guint32 l[16];
+} CHAR64LONG16;
+
+/*
+ * Hash a single 512-bit block. This is the core of the algorithm.
+ */
+void
+SHA1Transform(guint32 state[5], const guint8 buffer[SHA1_BLOCK_LENGTH])
+{
+       guint32 a, b, c, d, e;
+       guint8 workspace[SHA1_BLOCK_LENGTH];
+       CHAR64LONG16 *block = (CHAR64LONG16 *)workspace;
+
+       (void)memcpy(block, buffer, SHA1_BLOCK_LENGTH);
+
+       /* Copy context->state[] to working vars */
+       a = state[0];
+       b = state[1];
+       c = state[2];
+       d = state[3];
+       e = state[4];
+
+       /* 4 rounds of 20 operations each. Loop unrolled. */
+       R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+       R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+       R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+       R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+       R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+       R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+       R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+       R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+       R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+       R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+       R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+       R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+       R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+       R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+       R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+       R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+       R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+       R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+       R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+       R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+
+       /* Add the working vars back into context.state[] */
+       state[0] += a;
+       state[1] += b;
+       state[2] += c;
+       state[3] += d;
+       state[4] += e;
+
+       /* Wipe variables */
+       a = b = c = d = e = 0;
+}
+
+
+/*
+ * SHA1Init - Initialize new context
+ */
+void
+SHA1Init(SHA1_CTX *context)
+{
+
+       /* SHA1 initialization constants */
+       context->count = 0;
+       context->state[0] = 0x67452301;
+       context->state[1] = 0xEFCDAB89;
+       context->state[2] = 0x98BADCFE;
+       context->state[3] = 0x10325476;
+       context->state[4] = 0xC3D2E1F0;
+}
+
+
+/*
+ * Run your data through this.
+ */
+void
+SHA1Update(SHA1_CTX *context, const guint8 *data, size_t len)
+{
+       size_t i, j;
+
+       j = (size_t)((context->count >> 3) & 63);
+       context->count += (len << 3);
+       if ((j + len) > 63) {
+               (void)memcpy(&context->buffer[j], data, (i = 64-j));
+               SHA1Transform(context->state, context->buffer);
+               for ( ; i + 63 < len; i += 64)
+                       SHA1Transform(context->state, (guint8 *)&data[i]);
+               j = 0;
+       } else {
+               i = 0;
+       }
+       (void)memcpy(&context->buffer[j], &data[i], len - i);
+}
+
+
+/*
+ * Add padding and return the message digest.
+ */
+void
+SHA1Pad(SHA1_CTX *context)
+{
+       guint8 finalcount[8];
+       guint i;
+
+       for (i = 0; i < 8; i++) {
+               finalcount[i] = (guint8)((context->count >>
+                   ((7 - (i & 7)) * 8)) & 255);        /* Endian independent */
+       }
+       SHA1Update(context, (guint8 *)"\200", 1);
+       while ((context->count & 504) != 448)
+               SHA1Update(context, (guint8 *)"\0", 1);
+       SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
+}
+
+void
+SHA1Final(guint8 digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context)
+{
+       guint i;
+
+       SHA1Pad(context);
+       if (digest) {
+               for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
+                       digest[i] = (guint8)
+                          ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+               }
+               memset(context, 0, sizeof(*context));
+       }
+}
diff --git a/mono/utils/sha1.h b/mono/utils/sha1.h
new file mode 100644 (file)
index 0000000..5885182
--- /dev/null
@@ -0,0 +1,50 @@
+/*     $OpenBSD: sha1.h,v 1.24 2012/12/05 23:19:57 deraadt Exp $       */
+
+/*
+ * SHA-1 in C
+ * By Steve Reid <steve@edmweb.com>
+ * 100% Public Domain
+ */
+
+#ifndef _SHA1_H
+#define _SHA1_H
+
+#include <glib.h>
+
+#define        SHA1_BLOCK_LENGTH               64
+#define        SHA1_DIGEST_LENGTH              20
+#define        SHA1_DIGEST_STRING_LENGTH       (SHA1_DIGEST_LENGTH * 2 + 1)
+
+typedef struct {
+    guint32 state[5];
+    guint64 count;
+    guint8 buffer[SHA1_BLOCK_LENGTH];
+} SHA1_CTX;
+
+G_BEGIN_DECLS
+void SHA1Init(SHA1_CTX *);
+void SHA1Pad(SHA1_CTX *);
+void SHA1Transform(guint32 [5], const guint8 [SHA1_BLOCK_LENGTH]);
+void SHA1Update(SHA1_CTX *, const guint8 *, size_t);
+void SHA1Final(guint8 [SHA1_DIGEST_LENGTH], SHA1_CTX *);
+char *SHA1End(SHA1_CTX *, char *);
+char *SHA1File(const char *, char *);
+char *SHA1FileChunk(const char *, char *, off_t, off_t);
+char *SHA1Data(const guint8 *, size_t, char *);
+G_END_DECLS
+
+#define HTONDIGEST(x) do {                                              \
+        x[0] = htonl(x[0]);                                             \
+        x[1] = htonl(x[1]);                                             \
+        x[2] = htonl(x[2]);                                             \
+        x[3] = htonl(x[3]);                                             \
+        x[4] = htonl(x[4]); } while (0)
+
+#define NTOHDIGEST(x) do {                                              \
+        x[0] = ntohl(x[0]);                                             \
+        x[1] = ntohl(x[1]);                                             \
+        x[2] = ntohl(x[2]);                                             \
+        x[3] = ntohl(x[3]);                                             \
+        x[4] = ntohl(x[4]); } while (0)
+
+#endif /* _SHA1_H */