Compare commits

...
Author SHA1 Message Date
Rodrigo Kumpera bcc380d6ba [runtime] Instrument mono_domain_alloc 2014-09-16 18:16:47 -04:00
Rodrigo Kumpera 8516f578ee [runtime] Instrument image and image set mempool allocation. 2014-09-16 16:58:17 -04:00
Rodrigo Kumpera feaa6e19fb [runtime] Implement runtime valloc reporting. 2014-09-08 19:24:31 -04:00
Rodrigo Kumpera e8953e705c Properly name all sgen_alloc_os_memory. 2014-09-08 17:12:58 -04:00
Rodrigo Kumpera 130f08e943 Add reporting to jitinfo. 2014-09-08 17:11:11 -04:00
Rodrigo Kumpera 89558be055 [runtime] Finish metadata reporting. 2014-09-08 16:55:45 -04:00
Rodrigo Kumpera f2c8417122 [runtime] Proposed implementation of the memory profiler.
To get a small taste of it in action run the following program with it:

sing System;
using System.Net;
using System.Runtime.InteropServices;
using System.Linq;

public class Test
{
	[DllImport ("__Internal")]
	public static extern void mono_memprof_dump ();

	static int MethodThatDoesLinq () {
		int[] x = new[] { 1,2,3,4};
		var k = x.Where (_ => _ <= 100).Select (_ => _ + 1);
		int r = 0;
		foreach (var v in k)
			r += v;
		return r;
	}
	public static void Main ()
	{
		mono_memprof_dump ();
		MethodThatDoesLinq ();
		Console.WriteLine ("----------------------");
		mono_memprof_dump ();
	}
}
2014-09-08 02:27:09 -04:00
Zoltan Varga 4b6a2c8f89 Fix a warning. 2014-09-05 20:07:13 -04:00
Zoltan Varga 729bbe4041 [jit] Store the epilog length in MonoArchEHJitInfo instead of encoding it in jinfo->unwind_desc, since the latter can overflow for methods with large epilogs. Fixes #22685. 2014-09-05 18:07:42 -04:00
Zoltan Varga 3795639a4a Fix the linux build. 2014-09-05 17:18:18 -04:00
Zoltan Varga c8c4bd9a78 [runtime] Fix the linux build. 2014-09-05 15:46:19 -04:00
Martin Baulig 24fbaedcd2 [WCF]: Actually fix #22179 to allow concurrent requests.
Pass the 'OperationContext' around in a parameter instead of storing it
in an instance field to make this thread-safe.
2014-09-05 18:59:21 +02:00
Zoltan Varga 385f84f18c [aot] Emit aot logging information to a per-assembly file when using the AOT cache. Cache aot failures. 2014-09-04 23:31:50 -04:00
Zoltan Varga 4f916f178b [aot] Print error messages to the aot logfile as well, avoid exiting the process on failures. 2014-09-04 20:06:53 -04:00
Zoltan Varga 39c87f6f69 [aot] Allow the redirection of output messages from the AOT compiler to a logfile. 2014-09-04 19:11:30 -04:00
Zoltan Varga d84d1a94a0 Fix the build. 2014-09-04 17:38:16 -04:00
Zoltan Varga ad8236ebb8 [runtime] Get rid of the Makefile.am.in->Makefile.am change in metadata/, its not needed. 2014-09-04 17:34:36 -04:00
Marek Safar 2b88d02356 [mcs] recursive pattern with named arguments 2014-09-04 15:12:21 +02:00
Marek Safar 806b95d844 [mcs] recursive pattern matching 2014-09-04 10:37:50 +02:00
Marek Safar e83f4a2ab3 Merge pull request #1254 from vkargov/master
[corlib] Take daylight change info for the current year in TimeZoneTest.cs
2014-09-03 20:30:38 -09:00
Alexis Christoforides 5d80954463 Bump Mono version -> 3.10.1 2014-09-04 00:15:40 -04:00
Zoltan Varga c7b3d5c3ba Revert "[build] Include mono/utils into the extensions module."
This reverts commit b760456501.

Revert this as it is not needed.
2014-09-03 21:20:33 -04:00
Zoltan Varga f746fe8d1b Revert "[build] Deps tracking for mono/utils/Makefile.am when extension module is disabled."
This reverts commit a2e939a8a3.

Revert this as is not needed.
2014-09-03 21:20:11 -04:00
Zoltan Varga d2cee144fe [sgen] Use mono_thread_info_get_stack_bounds () on win32 as well, the stack bottom value returned by it is correct, only the stack top value is unusable, since windows dynamically extends the stack. 2014-09-03 18:15:15 -04:00
Rodrigo Kumpera 43177ef54b [utils] Add android extension point to threading. 2014-09-03 16:58:30 -04:00
Rodrigo Kumpera a2e939a8a3 [build] Deps tracking for mono/utils/Makefile.am when extension module is disabled. 2014-09-03 16:34:18 -04:00
Rodrigo Kumpera b760456501 [build] Include mono/utils into the extensions module. 2014-09-03 16:32:30 -04:00
Rodrigo Kumpera 748fefa1d7 [runtime] Cleanup the horrible ifdef hell that is the stack bounds discovery code.
This split a single chunk of intractable ifdef hell into a beautiful set of per-target
files.

This will allow us to actually figure out what's going on on each target.
2014-09-03 16:30:35 -04:00
Zoltan Varga 4c1155f40a Merge pull request #1252 from alesliehughes/master
Stop warning about winsock2.h being included before windows.h
2014-09-03 14:44:32 -04:00
Vladimir Kargov 59668db7f4 [corlib] In a TimeZone test, UtcOffset is taken for the current year, so take DaylightChanges for the current year as well. 2014-09-03 16:36:35 +04:00
Alistair Leslie-Hughes ec2b629fa9 Stop warning about winsock2.h being included before windows.h
This change is released under the MIT license.
2014-09-03 19:51:11 +10:00
Zoltan Varga f9b27e2e73 Fix a warning. 2014-09-02 21:10:11 -04:00
Zoltan Varga 541639c3bb [runtime] Load the runtime config file before initializing the runtime, so it can pick up the aot-cache configuration information. 2014-09-02 20:25:16 -04:00
Zoltan Varga 883f9399f4 [runtime] Add an 'app' attribute to the 'aotcache' config section to specify which apps should use the AOT cache. 2014-09-02 20:22:05 -04:00
Marek Safar b5fcd926f8 Merge pull request #1251 from esdrubal/utf8encoding
UTF8Encoding Fallback
2014-09-02 06:43:40 -09:00
Marcos Henrich f79c64942e Changed overlong byte to be processed again.
The byte is processed again because it can be the begin of a new multi-byte encoded character.
2014-09-02 23:14:09 +08:00
Marcos Henrich 91fa140dd0 Changed UTF8Encoding to call fallback with whole byte sequences.
Removed unnecessary parameters ref byte [] bufferArg.
This changes are required by UTF8EncodingTest.EncodingFallback that in some cases is expecting multibyte values..
2014-09-02 22:57:26 +08:00
Marcos Henrich 3d332ac26d Added UTF8EncodingTest.EncodingFallback.
EncodingFallback tests for multiple invalid inputs the unknownBytes that are given to the DecoderFallback.
2014-09-02 22:55:52 +08:00
Miguel de Icaza a7b779648b Bring fix for Cecil, includes fix for F#/Fody 2014-09-02 10:49:41 -04:00
Marcos Henrich 60aa49b35b Added class EncodingTester that can be used to test fallbacks.
EncodingTester is a testing helper class with a method TestDecoderFallback that makes DecoderFalback testing  easier.
2014-09-02 22:42:54 +08:00
Marek Habersack 10d4e76525 Do not specify key file when building for mobile, it should be passed on command line 2014-09-02 14:32:12 +02:00
Marcos Henrich 09bb2dc4bd Changed InternalGetCharCount to iterate the bytes as InternalGetChars. 2014-09-02 18:38:20 +08:00
Marek Safar fca9b48556 [mcs] more nonliteral constants pattern matching 2014-09-02 11:55:45 +02:00
Marek Habersack 38b25dc65a This method is internal in the mobile profile 2014-09-02 00:33:44 +02:00
Marek Habersack 14fba61b9d Added System.IO.InternalBufferOverflowException class to the mobile profile 2014-09-01 22:24:36 +02:00
Marek Habersack 58684cf2c4 Merge pull request #1249 from mattleibow/master
[system.data] DataRows with a NULL RowError incorrectly indicated HasError
2014-09-01 21:47:43 +02:00
Zoltan Varga eeb1227133 [runtime] Further reduce the usage of the loader lock in the metadata code by moving code out of locked regions and using the image lock instead. 2014-09-01 14:39:06 -04:00
Matthew Leibowitz a3c1bebc45 [system.data] DataRows with a NULL RowError incorrectly indicated HasError:
- MS.NET allows RowError to be set to NULL, but will convert it to string.Empty
2014-09-01 11:03:03 -07:00
Zoltan Varga bd8782b061 [runtime] Use a separate lock to protect global data structures in classes.c. 2014-09-01 13:05:25 -04:00
Zoltan Varga 03e4fe45d7 Disable a sys.data test which fails on wrench because of an old sqlite version. 2014-09-01 12:51:53 -04:00
Zoltan Varga f6ae9f133d Bump version to 3.10. 2014-09-01 11:47:11 -04:00
Zoltan Varga 00612b8049 [runtime] Factor out the nested types computation code from mono_class_get_nested_types () and reorganize it so most of the work is done outside the loader lock. 2014-09-01 11:40:56 -04:00
Zoltan Varga ea77a1201c [runtime] Use the image locks in many places instead of the loader lock. 2014-09-01 11:40:56 -04:00
Zoltan Varga 98ef62b1d1 [runtime] Remove a missed mono_loader_unlock () from mono_metadata_get_header (). 2014-09-01 11:40:55 -04:00
Zoltan Varga c73f87c669 [runtime] Reorganize mono_method_signature_checked () so most of the work is done outside the loader lock. 2014-09-01 11:40:55 -04:00
Zoltan Varga e043529add [runtime] Reorganize mono_method_get_header () so most of the work is done outside the loader lock. 2014-09-01 11:40:55 -04:00
Zoltan Varga 6730dfbf80 [runtime] Remove locking from the mono_get_method_constrained_... () functions, its not needed. 2014-09-01 11:40:55 -04:00
Zoltan Varga f5a0a351c2 [runtime] Reorganize mono_class_setup_interfaces () so most of the work is done outside the loader lock. 2014-09-01 11:40:54 -04:00
Zoltan Varga ff9b6836d2 [runtime] Move the initialization of class->has_finalize into mono_class_has_finalizer () in most cases. 2014-09-01 11:40:54 -04:00
Zoltan Varga e87e75fe3a [runtime] Reorganize mono_class_setup_methods () so most of the work is done outside the loader lock. 2014-09-01 11:40:54 -04:00
Zoltan Varga a3f28b43f7 [runtime] Reorganize mono_class_has_finalizer () so most of the work is done outside the loader lock. 2014-09-01 11:40:54 -04:00
Zoltan Varga 042114b194 [runtime] Reorganize mono_class_setup_events () so most of the work is done outside the loader lock. 2014-09-01 11:40:53 -04:00
Zoltan Varga 8dac2761fc [runtime] Reorganize mono_class_setup_properties () so most of the work is done outside the loader lock. 2014-09-01 11:40:53 -04:00
Zoltan Varga 7704a952f6 [runtime] Use the image lock in mono_type_from_typespec () instead of the loader lock. Also do most of the work outside the lock. 2014-09-01 11:40:53 -04:00
Rodrigo Kumpera 2c6b6ff553 Merge pull request #1246 from schani/feature-separate-pointer-queue
[sgen] Refactor pointer queue out of pinning code.
2014-09-01 10:13:41 -04:00
Marek Safar 79ea6ce4d0 Put back csharp project removed in 0450000dc4 2014-09-01 14:58:32 +02:00
Marek Safar 20c85188ab [mcs] Fix removing incomplete generic types from eval cache. Fixes #22393 2014-09-01 14:57:23 +02:00
Marek Safar 05feed5de7 [mcs] Parsing of ternary expressions whose then condition is a lambda. Fixes #22523 2014-09-01 13:26:48 +02:00
Marek Safar 11ac4dfb22 [mcs] Remove wrong test 2014-09-01 13:22:21 +02:00
Marek Safar 6e6ad378c0 Fixes c2ac44d3dd 2014-09-01 12:43:32 +02:00
Marek Safar c2ac44d3dd [system.data.linq] Delay reflection hit to actual execution point. Workarounds #22522 2014-09-01 11:22:57 +02:00
Marek Safar bcf33452dd [system.net.http] Update RequestMessage.RequestUri.AbsoluteUri after redirect. Fixes #22383 2014-09-01 10:10:30 +02:00
Zoltan Varga 5646004e39 [runtime] Fix the windows build. 2014-08-31 04:34:18 -04:00
Marek Safar 01bc7c1923 [mcs] Revert to broken native csc definite assignment for structs 2014-08-30 14:04:16 +02:00
Marek Safar c8b482d640 [mcs] nonliteral constants pattern matching 2014-08-30 14:04:16 +02:00
Marek Safar 723dc9ad6f [xbuild] Fix InstalledAssemblyTables signature 2014-08-30 14:04:15 +02:00
Marek Safar 8897b572c7 [mcs] simple constants pattern matching 2014-08-30 14:04:15 +02:00
Zoltan Varga 644ff6b019 [aot] Fix full-aot support when the AOT cache is enabled. 2014-08-29 23:47:33 -04:00
Zoltan Varga 567c08843d [jit] Avoid hardcoding tls offsets into the aot versions of the monitor enter/exit trampolines on amd64. 2014-08-29 23:47:01 -04:00
Zoltan Varga f8db51ecb4 [jit] Avoid uninitialized fields in the MonoDelegateTrampInfo structure. 2014-08-29 19:30:15 -04:00
Zoltan Varga 34df6ae34b [runtime] Fix reading past the end of a string when setting the native thread name. 2014-08-29 19:29:48 -04:00
Zoltan Varga 96b74d362a [runtime] Fix a problem introduced by 522663cdfa. 2014-08-29 17:42:37 -04:00
Zoltan Varga 522663cdfa [runtime] Add an adapter between the MonoPrintCallback and the eglib GPrintFunc types. 2014-08-29 17:03:23 -04:00
Mark Probst 2f126c13e8 [sgen] Refactor pointer queue out of pinning code. 2014-08-29 13:33:34 -07:00
Tom Hindle bb672ad95e Fix mono_marshal_free_ccw (). Fixes #22414. 2014-08-29 16:05:50 -04:00
Zoltan Varga bfc3336224 [bcl] Catch exceptions thrown by SerialPortStream.Dispose () when called from the finalizer. Fixes #15514. 2014-08-29 15:06:25 -04:00
Zoltan Varga abfd4b5732 [sdb] Fix the checking of the handshake message. 2014-08-29 15:04:40 -04:00
Zoltan Varga b8766a812d [runtime] Add functionality for AOTing assemblies on demand when they are first used. Configurable using a new "aotconfig" config element, i.e. <aotcache assemblies="mscorlib System"/>. 2014-08-29 15:02:52 -04:00
Zoltan Varga 8dea307fa4 [runtime] Add Steve Reid's public domain SHA1 code. 2014-08-29 15:01:26 -04:00
123 changed files with 4118 additions and 1315 deletions

No files matched your search

-1
View File
@@ -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
+1 -1
View 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])
+8
View File
@@ -57,6 +57,14 @@ typedef struct {
Slot *slot;
} Iter;
size_t
mono_eg_hashtable_get_memory_size (GHashTable *hashtable)
{
return sizeof (GHashTable) +
hashtable->in_use * sizeof (Slot) +
hashtable->table_size * sizeof (Slot*);
}
static const guint prime_tbl[] = {
11, 19, 37, 73, 109, 163, 251, 367, 557, 823, 1237,
1861, 2777, 4177, 6247, 9371, 14057, 21089, 31627,
+2
View File
@@ -467,6 +467,8 @@ guint g_spaced_primes_closest (guint x);
#define g_hash_table_insert(h,k,v) g_hash_table_insert_replace ((h),(k),(v),FALSE)
#define g_hash_table_replace(h,k,v) g_hash_table_insert_replace ((h),(k),(v),TRUE)
size_t mono_eg_hashtable_get_memory_size (GHashTable *hashtable);
gboolean g_direct_equal (gconstpointer v1, gconstpointer v2);
guint g_direct_hash (gconstpointer v1);
gboolean g_int_equal (gconstpointer v1, gconstpointer v2);
+1 -1
@@ -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; }
+265
View File
@@ -0,0 +1,265 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{817CE046-07E8-409D-84BF-A6EA4F2879DE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mono.CSharp</RootNamespace>
<AssemblyName>Mono.CSharp</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;NET_4_0</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NET_4_0</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\mcs\anonymous.cs">
<Link>anonymous.cs</Link>
</Compile>
<Compile Include="..\..\mcs\argument.cs">
<Link>argument.cs</Link>
</Compile>
<Compile Include="..\..\mcs\assembly.cs">
<Link>assembly.cs</Link>
</Compile>
<Compile Include="..\..\mcs\assign.cs">
<Link>assign.cs</Link>
</Compile>
<Compile Include="..\..\mcs\async.cs">
<Link>async.cs</Link>
</Compile>
<Compile Include="..\..\mcs\attribute.cs">
<Link>attribute.cs</Link>
</Compile>
<Compile Include="..\..\mcs\cfold.cs">
<Link>cfold.cs</Link>
</Compile>
<Compile Include="..\..\mcs\class.cs">
<Link>class.cs</Link>
</Compile>
<Compile Include="..\..\mcs\codegen.cs">
<Link>codegen.cs</Link>
</Compile>
<Compile Include="..\..\mcs\complete.cs">
<Link>complete.cs</Link>
</Compile>
<Compile Include="..\..\mcs\const.cs">
<Link>const.cs</Link>
</Compile>
<Compile Include="..\..\mcs\constant.cs">
<Link>constant.cs</Link>
</Compile>
<Compile Include="..\..\mcs\context.cs">
<Link>context.cs</Link>
</Compile>
<Compile Include="..\..\mcs\convert.cs">
<Link>convert.cs</Link>
</Compile>
<Compile Include="..\..\mcs\cs-tokenizer.cs">
<Link>cs-tokenizer.cs</Link>
</Compile>
<Compile Include="..\..\mcs\decl.cs">
<Link>decl.cs</Link>
</Compile>
<Compile Include="..\..\mcs\delegate.cs">
<Link>delegate.cs</Link>
</Compile>
<Compile Include="..\..\mcs\doc-bootstrap.cs">
<Link>doc-bootstrap.cs</Link>
</Compile>
<Compile Include="..\..\mcs\doc.cs">
<Link>doc.cs</Link>
</Compile>
<Compile Include="..\..\mcs\driver.cs">
<Link>driver.cs</Link>
</Compile>
<Compile Include="..\..\mcs\dynamic.cs">
<Link>dynamic.cs</Link>
</Compile>
<Compile Include="..\..\mcs\ecore.cs">
<Link>ecore.cs</Link>
</Compile>
<Compile Include="..\..\mcs\enum.cs">
<Link>enum.cs</Link>
</Compile>
<Compile Include="..\..\mcs\eval.cs">
<Link>eval.cs</Link>
</Compile>
<Compile Include="..\..\mcs\expression.cs">
<Link>expression.cs</Link>
</Compile>
<Compile Include="..\..\mcs\field.cs">
<Link>field.cs</Link>
</Compile>
<Compile Include="..\..\mcs\flowanalysis.cs">
<Link>flowanalysis.cs</Link>
</Compile>
<Compile Include="..\..\mcs\generic.cs">
<Link>generic.cs</Link>
</Compile>
<Compile Include="..\..\mcs\import.cs">
<Link>import.cs</Link>
</Compile>
<Compile Include="..\..\mcs\iterators.cs">
<Link>iterators.cs</Link>
</Compile>
<Compile Include="..\..\mcs\lambda.cs">
<Link>lambda.cs</Link>
</Compile>
<Compile Include="..\..\mcs\linq.cs">
<Link>linq.cs</Link>
</Compile>
<Compile Include="..\..\mcs\literal.cs">
<Link>literal.cs</Link>
</Compile>
<Compile Include="..\..\mcs\location.cs">
<Link>location.cs</Link>
</Compile>
<Compile Include="..\..\mcs\membercache.cs">
<Link>membercache.cs</Link>
</Compile>
<Compile Include="..\..\mcs\method.cs">
<Link>method.cs</Link>
</Compile>
<Compile Include="..\..\mcs\modifiers.cs">
<Link>modifiers.cs</Link>
</Compile>
<Compile Include="..\..\mcs\namespace.cs">
<Link>namespace.cs</Link>
</Compile>
<Compile Include="..\..\mcs\nullable.cs">
<Link>nullable.cs</Link>
</Compile>
<Compile Include="..\..\mcs\parameter.cs">
<Link>parameter.cs</Link>
</Compile>
<Compile Include="..\..\mcs\pending.cs">
<Link>pending.cs</Link>
</Compile>
<Compile Include="..\..\mcs\property.cs">
<Link>property.cs</Link>
</Compile>
<Compile Include="..\..\mcs\reflection.cs">
<Link>reflection.cs</Link>
</Compile>
<Compile Include="..\..\mcs\report.cs">
<Link>report.cs</Link>
</Compile>
<Compile Include="..\..\mcs\settings.cs">
<Link>settings.cs</Link>
</Compile>
<Compile Include="..\..\mcs\module.cs">
<Link>module.cs</Link>
</Compile>
<Compile Include="..\..\mcs\statement.cs">
<Link>statement.cs</Link>
</Compile>
<Compile Include="..\..\mcs\support.cs">
<Link>support.cs</Link>
</Compile>
<Compile Include="..\..\mcs\typemanager.cs">
<Link>typemanager.cs</Link>
</Compile>
<Compile Include="..\..\mcs\typespec.cs">
<Link>typespec.cs</Link>
</Compile>
<Compile Include="..\..\mcs\visit.cs">
<Link>visit.cs</Link>
</Compile>
<Compile Include="..\..\tools\monop\outline.cs">
<Link>outline.cs</Link>
</Compile>
<Compile Include="..\Mono.Security\Mono.Security.Cryptography\CryptoConvert.cs">
<Link>CryptoConvert.cs</Link>
</Compile>
<Compile Include="cs-parser.cs" />
<Compile Include="..\Mono.CompilerServices.SymbolWriter\MonoSymbolFile.cs">
<Link>MonoSymbolFile.cs</Link>
</Compile>
<Compile Include="..\Mono.CompilerServices.SymbolWriter\MonoSymbolTable.cs">
<Link>MonoSymbolTable.cs</Link>
</Compile>
<Compile Include="..\Mono.CompilerServices.SymbolWriter\MonoSymbolWriter.cs">
<Link>MonoSymbolWriter.cs</Link>
</Compile>
<Compile Include="..\Mono.CompilerServices.SymbolWriter\SourceMethodBuilder.cs">
<Link>SourceMethodBuilder.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PreBuildEvent>"$(ProjectDir)..\..\jay\jay" -cvt &lt; "$(ProjectDir)..\..\jay\skeleton.cs" "$(ProjectDir)..\..\mcs\cs-parser.jay" &gt; "$(ProjectDir)cs-parser.cs"</PreBuildEvent>
</PropertyGroup>
</Project>
@@ -830,9 +830,12 @@ namespace DbLinq.Data.Linq
}
}
private static MethodInfo _WhereMethod = typeof(Queryable).GetMethods().First(m => m.Name == "Where");
private static MethodInfo _WhereMethod;
internal object GetOtherTableQuery(Expression predicate, ParameterExpression parameter, Type otherTableType, IQueryable otherTable)
{
if (_WhereMethod == null)
System.Threading.Interlocked.CompareExchange (ref _WhereMethod, typeof(Queryable).GetMethods().First(m => m.Name == "Where"), null);
//predicate: other.EmployeeID== "WARTH"
Expression lambdaPredicate = Expression.Lambda(predicate, parameter);
//lambdaPredicate: other=>other.EmployeeID== "WARTH"
+3 -3
View 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)
@@ -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";
@@ -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");
@@ -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)]
@@ -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()
@@ -306,6 +306,8 @@ namespace System.Net.Http
item_headers.TryAddWithoutValidation (key, value);
}
requestMessage.RequestUri = wr.ResponseUri;
return response;
}
@@ -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.
@@ -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)
@@ -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
@@ -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)
@@ -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);
}
}
@@ -211,7 +211,10 @@ namespace System.IO.Ports
~SerialPortStream ()
{
Dispose (false);
try {
Dispose (false);
} catch (IOException) {
}
}
void CheckDisposed ()
@@ -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
+60 -60
View 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
@@ -0,0 +1,116 @@
//
// EncodingTester.cs
//
// Author:
// Marcos Henrich <[email protected]>
//
// (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);
}
}
}
}
@@ -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 });
}
}
}
+3 -2
View 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));
+1
View 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
+18
View File
@@ -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;
}
+1 -1
View File
@@ -1,4 +1,4 @@
// CS1525: Unexpected symbol `ref', expecting `.', `?', `[', `<operator>', or `identifier'
// CS1525: Unexpected symbol `ref'
// Line: 8
public class Test
+1 -1
View 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 ();
+2
View 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)
+135 -64
View 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
| 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.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));
$$ = is_expr;
}
| additive_expression AS error
{
@@ -4314,6 +4337,81 @@ 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
| invocation_expression
| default_value_expression
| STAR
{
$$ = new WildcardPattern (GetLocation ($1));
}
| 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
{
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 +5468,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 +5484,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
@@ -7896,6 +7966,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:
+4 -1
View 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:
+3 -3
View 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;
}
+443 -23
View 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,106 @@ 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) {
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 +1834,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 +1961,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 +2218,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 +2967,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 +10818,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)
{
}
-8
View 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
//
+4
View 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,
+128
View File
@@ -105,6 +105,134 @@ 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 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);
top_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);
top_block.AddStatement (new Return (equals_invocation, loc));
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;
+15 -1
View 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);
}
+5
View 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)
{
}
-24
View File
@@ -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 ()
{
}
}
+1 -1
View 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;
+93
View File
@@ -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;
}
}
+14
View File
@@ -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;
}
}
+77
View File
@@ -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;
}
}
+39
View File
@@ -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;
}
}
+93 -15
View File
@@ -14465,6 +14465,12 @@
<method name="Int32 &lt;Test_12&gt;m__0(System.Object)" attrs="145">
<size>10</size>
</method>
<method name="Void Test_18(Boolean, System.Action)" attrs="129">
<size>44</size>
</method>
<method name="Void &lt;Test_18&gt;m__1(System.Object)" attrs="145">
<size>2</size>
</method>
</type>
</test>
<test name="gtest-410.cs">
@@ -50358,21 +50364,6 @@
</method>
</type>
</test>
<test name="test-888.cs">
<type name="S1">
<method name="Void .ctor(Int32)" attrs="6278">
<size>2</size>
</method>
</type>
<type name="X">
<method name="Void Main()" attrs="150">
<size>2</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
<test name="test-889.cs">
<type name="Test">
<method name="Void Main()" attrs="145">
@@ -68442,6 +68433,93 @@
</method>
</type>
</test>
<test name="test-pattern-01.cs">
<type name="TypePattern">
<method name="Int32 Main()" attrs="150">
<size>227</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
<test name="test-pattern-02.cs">
<type name="ConstantPattern">
<method name="Int32 Main()" attrs="150">
<size>633</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
<type name="&lt;PatternMatchingHelper&gt;">
<method name="Boolean NumberMatcher(System.Object, System.Object, Boolean)" attrs="150">
<size>54</size>
</method>
</type>
<type name="ConstantPattern">
<method name="Boolean Generic[T](T)" attrs="145">
<size>28</size>
</method>
</type>
</test>
<test name="test-pattern-03.cs">
<type name="WildcardPattern">
<method name="Int32 Main()" attrs="145">
<size>33</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
<test name="test-pattern-04.cs">
<type name="RecursivePattern">
<method name="Int32 Main()" attrs="145">
<size>750</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
<type name="C1">
<method name="Boolean op_Is(C1, Int32 ByRef)" attrs="2198">
<size>13</size>
</method>
<method name="Boolean op_Is(C1, C1 ByRef, C1 ByRef)" attrs="2198">
<size>16</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
<type name="S">
<method name="Boolean op_Is(S, System.Nullable`1[System.Int32] ByRef, System.Decimal ByRef)" attrs="2198">
<size>34</size>
</method>
</type>
</test>
<test name="test-pattern-05.cs">
<type name="RecursiveNamedPattern">
<method name="Int32 Main()" attrs="150">
<size>204</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
<type name="C">
<method name="Boolean op_Is(C, Int64 ByRef, System.String ByRef)" attrs="2198">
<size>22</size>
</method>
<method name="Boolean op_Is(C)" attrs="2198">
<size>10</size>
</method>
<method name="Void .ctor()" attrs="6278">
<size>7</size>
</method>
</type>
</test>
<test name="test-primary-ctor-01.cs">
<type name="Simple">
<method name="Int32 get_Property()" attrs="2177">
Executable → Regular
+2 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0831DD4E-B428-4D6C-90B1-2206DBD4F92E}</ProjectGuid>
<OutputType>Exe</OutputType>
@@ -43,6 +43,7 @@
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<Externalconsole>true</Externalconsole>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
+1 -1
View File
@@ -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."
@@ -171,6 +171,8 @@ common_sources = \
process.h \
profiler.c \
profiler-private.h \
memory-profiler.h \
memory-profiler.c \
rand.h \
rand.c \
runtime.c \
@@ -239,6 +241,8 @@ sgen_sources = \
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 \
@@ -341,9 +345,3 @@ 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
+1 -1
View File
@@ -925,7 +925,7 @@ create_allocator (int atype, int tls_key)
mono_mb_free (mb);
mono_method_get_header (res)->init_locals = FALSE;
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (AllocatorWrapperInfo));
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (AllocatorWrapperInfo), "wrapper-info");
info->gc_name = "boehm";
info->alloc_type = atype;
mono_marshal_set_wrapper_info (res, info);
+356 -275
View File
File diff suppressed because it is too large. Load diff
+12 -3
View File
@@ -1918,7 +1918,7 @@ cominterop_get_ccw (MonoObject* object, MonoClass* itf)
if (!ccw_entry) {
int vtable_index = method_count-1+start_slot;
vtable = mono_image_alloc0 (klass->image, sizeof (gpointer)*(method_count+start_slot));
vtable = mono_image_alloc0 (klass->image, sizeof (gpointer)*(method_count+start_slot), "ccw-vtable");
memcpy (vtable, iunknown, sizeof (iunknown));
if (start_slot == 7)
memcpy (vtable+3, idispatch, sizeof (idispatch));
@@ -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);
+5 -2
View File
@@ -175,6 +175,7 @@ typedef struct
typedef struct
{
guint32 stack_size;
guint32 epilog_size;
} MonoArchEHJitInfo;
typedef struct {
@@ -480,10 +481,10 @@ gboolean
mono_is_shadow_copy_enabled (MonoDomain *domain, const gchar *dir_name) MONO_INTERNAL;
gpointer
mono_domain_alloc (MonoDomain *domain, guint size) MONO_INTERNAL;
mono_domain_alloc (MonoDomain *domain, guint size, const char *what) MONO_INTERNAL;
gpointer
mono_domain_alloc0 (MonoDomain *domain, guint size) MONO_INTERNAL;
mono_domain_alloc0 (MonoDomain *domain, guint size, const char *what) MONO_INTERNAL;
gpointer
mono_domain_alloc0_lock_free (MonoDomain *domain, guint size) MONO_INTERNAL;
@@ -660,4 +661,6 @@ MonoJitInfo* mono_jit_info_table_find_internal (MonoDomain *domain, char *addr,
void mono_enable_debug_domain_unload (gboolean enable);
size_t mono_hashtable_get_memory_size (MonoGHashTable *hashtable);
#endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */
+48 -11
View File
@@ -16,6 +16,7 @@
#include <sys/stat.h>
#include <mono/metadata/gc-internal.h>
#include <mono/metadata/memory-profiler.h>
#include <mono/utils/atomic.h>
#include <mono/utils/mono-compiler.h>
@@ -42,6 +43,7 @@
#include <metadata/threads.h>
#include <metadata/profiler-private.h>
#include <mono/metadata/coree.h>
#include <mono/metadata/memory-profiler.h>
//#define DEBUG_DOMAIN_UNLOAD 1
@@ -138,6 +140,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);
@@ -200,6 +205,7 @@ static MonoJitInfoTableChunk*
jit_info_table_new_chunk (void)
{
MonoJitInfoTableChunk *chunk = g_new0 (MonoJitInfoTableChunk, 1);
mono_profiler_add_allocation ("jittable:table-chunk", sizeof (MonoJitInfoTableChunk));
chunk->refcount = 1;
return chunk;
@@ -208,7 +214,9 @@ jit_info_table_new_chunk (void)
static MonoJitInfoTable *
jit_info_table_new (MonoDomain *domain)
{
MonoJitInfoTable *table = g_malloc0 (MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*));
size_t size = MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*);
MonoJitInfoTable *table = g_malloc0 (size);
mono_profiler_add_allocation ("jittable:table", size);
table->domain = domain;
table->num_chunks = 1;
@@ -230,8 +238,10 @@ jit_info_table_free (MonoJitInfoTable *table)
if (table->domain->num_jit_info_tables <= 1) {
GSList *list;
for (list = table->domain->jit_info_free_queue; list; list = list->next)
for (list = table->domain->jit_info_free_queue; list; list = list->next) {
mono_profiler_remove_allocation ("jittable:info", sizeof (MonoJitInfo));
g_free (list->data);
}
g_slist_free (table->domain->jit_info_free_queue);
table->domain->jit_info_free_queue = NULL;
@@ -253,15 +263,19 @@ jit_info_table_free (MonoJitInfoTable *table)
for (j = 0; j < num_elements; ++j) {
MonoJitInfo *ji = chunk->data [j];
if (IS_JIT_INFO_TOMBSTONE (ji))
if (IS_JIT_INFO_TOMBSTONE (ji)) {
mono_profiler_remove_allocation ("jittable:tombstone", sizeof (MonoJitInfo));
g_free (ji);
}
}
mono_profiler_remove_allocation ("jittable:table-chunk", sizeof (MonoJitInfoTableChunk));
g_free (chunk);
}
mono_domain_unlock (domain);
mono_profiler_remove_allocation ("jittable:table", MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*) * table->num_chunks);
g_free (table);
}
@@ -477,6 +491,7 @@ jit_info_table_check (MonoJitInfoTable *table)
static MonoJitInfoTable*
jit_info_table_realloc (MonoJitInfoTable *old)
{
size_t table_size;
int i;
int num_elements = jit_info_table_num_elements (old);
int required_size;
@@ -493,9 +508,11 @@ jit_info_table_realloc (MonoJitInfoTable *old)
}
g_assert (num_chunks > 0);
new = g_malloc (MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*) * num_chunks);
table_size = MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*) * num_chunks;
new = g_malloc (table_size);
new->domain = old->domain;
new->num_chunks = num_chunks;
mono_profiler_add_allocation ("jittable:table", table_size);
for (i = 0; i < num_chunks; ++i)
new->chunks [i] = jit_info_table_new_chunk ();
@@ -562,9 +579,10 @@ jit_info_table_split_chunk (MonoJitInfoTableChunk *chunk, MonoJitInfoTableChunk
static MonoJitInfoTable*
jit_info_table_copy_and_split_chunk (MonoJitInfoTable *table, MonoJitInfoTableChunk *chunk)
{
MonoJitInfoTable *new_table = g_malloc (MONO_SIZEOF_JIT_INFO_TABLE
+ sizeof (MonoJitInfoTableChunk*) * (table->num_chunks + 1));
size_t size = MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*) * (table->num_chunks + 1);
MonoJitInfoTable *new_table = g_malloc (size);
int i, j;
mono_profiler_add_allocation ("jittable:table", size);
new_table->domain = table->domain;
new_table->num_chunks = table->num_chunks + 1;
@@ -610,9 +628,10 @@ jit_info_table_purify_chunk (MonoJitInfoTableChunk *old)
static MonoJitInfoTable*
jit_info_table_copy_and_purify_chunk (MonoJitInfoTable *table, MonoJitInfoTableChunk *chunk)
{
MonoJitInfoTable *new_table = g_malloc (MONO_SIZEOF_JIT_INFO_TABLE
+ sizeof (MonoJitInfoTableChunk*) * table->num_chunks);
size_t size = MONO_SIZEOF_JIT_INFO_TABLE + sizeof (MonoJitInfoTableChunk*) * table->num_chunks;
MonoJitInfoTable *new_table = g_malloc (size);
int i, j;
mono_profiler_add_allocation ("jittable:table", size);
new_table->domain = table->domain;
new_table->num_chunks = table->num_chunks;
@@ -772,6 +791,7 @@ static MonoJitInfo*
mono_jit_info_make_tombstone (MonoJitInfo *ji)
{
MonoJitInfo *tombstone = g_new0 (MonoJitInfo, 1);
mono_profiler_add_allocation ("jittable:tombstone", sizeof (MonoJitInfo));
tombstone->code_start = ji->code_start;
tombstone->code_size = ji->code_size;
@@ -789,6 +809,7 @@ mono_jit_info_free_or_queue (MonoDomain *domain, MonoJitInfo *ji)
if (domain->num_jit_info_tables <= 1) {
/* Can it actually happen that we only have one table
but ji is still hazardous? */
mono_profiler_remove_allocation ("jittable:info", sizeof (MonoJitInfo));
mono_thread_hazardous_free_or_queue (ji, g_free, TRUE, FALSE);
} else {
domain->jit_info_free_queue = g_slist_prepend (domain->jit_info_free_queue, ji);
@@ -873,6 +894,7 @@ mono_jit_info_add_aot_module (MonoImage *image, gpointer start, gpointer end)
ji->code_start = start;
ji->code_size = (guint8*)end - (guint8*)start;
jit_info_table_add (mono_root_domain, &mono_root_domain->aot_modules, ji);
mono_profiler_add_allocation ("jittable:aot-info", sizeof (MonoJitInfo));
mono_domain_unlock (mono_root_domain);
}
@@ -1062,7 +1084,7 @@ lock_free_mempool_chunk_new (LockFreeMempool *mp, int len)
size = mono_pagesize ();
while (size - sizeof (LockFreeMempoolChunk) < len)
size += mono_pagesize ();
chunk = mono_valloc (0, size, MONO_MMAP_READ|MONO_MMAP_WRITE);
chunk = mono_valloc (0, size, MONO_MMAP_READ|MONO_MMAP_WRITE, "lock-free-mempool");
g_assert (chunk);
chunk->mem = ALIGN_PTR_TO ((char*)chunk + sizeof (LockFreeMempoolChunk), 16);
chunk->size = ((char*)chunk + size) - (char*)chunk->mem;
@@ -1278,6 +1300,8 @@ mono_domain_create (void)
domain = mono_gc_alloc_fixed (sizeof (MonoDomain), domain_gc_desc);
mono_gc_register_root ((char*)&(domain->MONO_DOMAIN_FIRST_GC_TRACKED), G_STRUCT_OFFSET (MonoDomain, MONO_DOMAIN_LAST_GC_TRACKED) - G_STRUCT_OFFSET (MonoDomain, MONO_DOMAIN_FIRST_GC_TRACKED), NULL);
#endif
mono_profiler_register_memory_domain (domain, MEMDOM_APPDOMAIN);
domain->shadow_serial = shadow_serial;
domain->domain = NULL;
domain->setup = NULL;
@@ -1364,6 +1388,9 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
#endif
/* init before wapi so we can record large mallocs */
mono_memory_profiler_init ();
#ifndef HOST_WIN32
wapi_init ();
#endif
@@ -1949,6 +1976,8 @@ mono_domain_free (MonoDomain *domain, gboolean force)
GSList *tmp;
gpointer *p;
mono_profiler_free_memory_domain (domain);
if ((domain == mono_root_domain) && !force) {
g_warning ("cant unload root domain");
return;
@@ -2190,7 +2219,7 @@ mono_domain_get_id (MonoDomain *domain)
* LOCKING: Acquires the domain lock.
*/
gpointer
mono_domain_alloc (MonoDomain *domain, guint size)
mono_domain_alloc (MonoDomain *domain, guint size, const char *what)
{
gpointer res;
@@ -2198,6 +2227,7 @@ mono_domain_alloc (MonoDomain *domain, guint size)
#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters->loader_bytes += size;
#endif
mono_profiler_add_mempool_alloc (domain, size, what);
res = mono_mempool_alloc (domain->mp, size);
mono_domain_unlock (domain);
@@ -2210,7 +2240,7 @@ mono_domain_alloc (MonoDomain *domain, guint size)
* LOCKING: Acquires the domain lock.
*/
gpointer
mono_domain_alloc0 (MonoDomain *domain, guint size)
mono_domain_alloc0 (MonoDomain *domain, guint size, const char *what)
{
gpointer res;
@@ -2218,6 +2248,7 @@ mono_domain_alloc0 (MonoDomain *domain, guint size)
#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters->loader_bytes += size;
#endif
mono_profiler_add_mempool_alloc (domain, size, what);
res = mono_mempool_alloc0 (domain->mp, size);
mono_domain_unlock (domain);
@@ -2776,3 +2807,9 @@ mono_enable_debug_domain_unload (gboolean enable)
{
debug_domain_unload = enable;
}
MonoAotCacheConfig *
mono_get_aot_cache_config (void)
{
return &aot_cache_config;
}
+13 -7
View File
@@ -34,6 +34,7 @@
#include <mono/utils/atomic.h>
#include <mono/metadata/class-internals.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/memory-profiler.h>
#include <mono/metadata/object-internals.h>
#include <mono/metadata/security-core-clr.h>
#include <mono/metadata/verify-internals.h>
@@ -946,6 +947,7 @@ do_mono_image_load (MonoImage *image, MonoImageOpenStatus *status,
GSList *errors = NULL;
mono_profiler_module_event (image, MONO_PROFILE_START_LOAD);
mono_profiler_register_memory_domain (image, MEMDOM_IMAGE);
mono_image_init (image);
@@ -1528,6 +1530,7 @@ mono_image_close_except_pools (MonoImage *image)
#endif
mono_profiler_module_event (image, MONO_PROFILE_START_UNLOAD);
mono_profiler_free_memory_domain (image);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_ASSEMBLY, "Unloading image %s [%p].", image->name, image);
@@ -2227,7 +2230,7 @@ mono_image_has_authenticode_entry (MonoImage *image)
}
gpointer
mono_image_alloc (MonoImage *image, guint size)
mono_image_alloc (MonoImage *image, guint size, const char *what)
{
gpointer res;
@@ -2235,6 +2238,7 @@ mono_image_alloc (MonoImage *image, guint size)
mono_perfcounters->loader_bytes += size;
#endif
mono_image_lock (image);
mono_profiler_add_mempool_alloc (image, size, what);
res = mono_mempool_alloc (image->mempool, size);
mono_image_unlock (image);
@@ -2242,7 +2246,7 @@ mono_image_alloc (MonoImage *image, guint size)
}
gpointer
mono_image_alloc0 (MonoImage *image, guint size)
mono_image_alloc0 (MonoImage *image, guint size, const char *what)
{
gpointer res;
@@ -2250,6 +2254,7 @@ mono_image_alloc0 (MonoImage *image, guint size)
mono_perfcounters->loader_bytes += size;
#endif
mono_image_lock (image);
mono_profiler_add_mempool_alloc (image, size, what);
res = mono_mempool_alloc0 (image->mempool, size);
mono_image_unlock (image);
@@ -2257,7 +2262,7 @@ mono_image_alloc0 (MonoImage *image, guint size)
}
char*
mono_image_strdup (MonoImage *image, const char *s)
mono_image_strdup (MonoImage *image, const char *s, const char *what)
{
char *res;
@@ -2265,6 +2270,7 @@ mono_image_strdup (MonoImage *image, const char *s)
mono_perfcounters->loader_bytes += strlen (s);
#endif
mono_image_lock (image);
mono_profiler_add_mempool_alloc (image, strlen (s) + 1, what);
res = mono_mempool_strdup (image->mempool, s);
mono_image_unlock (image);
@@ -2272,11 +2278,11 @@ mono_image_strdup (MonoImage *image, const char *s)
}
GList*
g_list_prepend_image (MonoImage *image, GList *list, gpointer data)
g_list_prepend_image (MonoImage *image, GList *list, gpointer data, const char *what)
{
GList *new_list;
new_list = mono_image_alloc (image, sizeof (GList));
new_list = mono_image_alloc (image, sizeof (GList), what);
new_list->data = data;
new_list->prev = list ? list->prev : NULL;
new_list->next = list;
@@ -2290,11 +2296,11 @@ g_list_prepend_image (MonoImage *image, GList *list, gpointer data)
}
GSList*
g_slist_append_image (MonoImage *image, GSList *list, gpointer data)
g_slist_append_image (MonoImage *image, GSList *list, gpointer data, const char *what)
{
GSList *new_list;
new_list = mono_image_alloc (image, sizeof (GSList));
new_list = mono_image_alloc (image, sizeof (GSList), what);
new_list->data = data;
new_list->next = NULL;
+71 -74
View 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;
entry = mono_image_alloc0 (assembly, sizeof (MonoDllMap), "dll-map");
entry->dll = dll? mono_image_strdup (assembly, dll, "dll-name"): NULL;
entry->target = tdll? mono_image_strdup (assembly, tdll, "dll-target"): NULL;
entry->func = func? mono_image_strdup (assembly, func, "dll-func"): NULL;
entry->target_func = tfunc? mono_image_strdup (assembly, tfunc, "dll-target_func"): 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,
@@ -1721,9 +1722,9 @@ mono_get_method_from_token (MonoImage *image, guint32 token, MonoClass *klass,
if ((cols [2] & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(cols [1] & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)) {
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethodPInvoke));
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethodPInvoke), "method-pinvoke");
} else {
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethod));
result = (MonoMethod *)mono_image_alloc0 (image, sizeof (MonoMethod), "method");
methods_size += sizeof (MonoMethod);
}
@@ -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;
}
+8 -8
View File
@@ -1145,7 +1145,7 @@ mono_mb_emit_exception_marshal_directive (MonoMethodBuilder *mb, char *msg)
char *s;
if (!mb->dynamic) {
s = mono_image_strdup (mb->method->klass->image, msg);
s = mono_image_strdup (mb->method->klass->image, msg, "mb-exception-message");
g_free (msg);
} else {
s = g_strdup (msg);
@@ -2726,7 +2726,7 @@ mono_wrapper_info_create (MonoMethodBuilder *mb, WrapperSubtype subtype)
{
WrapperInfo *info;
info = mono_image_alloc0 (mb->method->klass->image, sizeof (WrapperInfo));
info = mono_image_alloc0 (mb->method->klass->image, sizeof (WrapperInfo), "wrapper-info");
info->subtype = subtype;
return info;
}
@@ -3583,7 +3583,7 @@ mono_marshal_get_xappdomain_dispatch (MonoMethod *method, int *marshal_types, in
/* try */
main_clause = mono_image_alloc0 (method->klass->image, sizeof (MonoExceptionClause));
main_clause = mono_image_alloc0 (method->klass->image, sizeof (MonoExceptionClause), "mb-exception-clause");
main_clause->try_offset = mono_mb_get_label (mb);
/* Clean the call context */
@@ -4942,7 +4942,7 @@ emit_runtime_invoke_body (MonoMethodBuilder *mb, MonoClass *target_klass, MonoMe
labels [2] = mono_mb_emit_branch (mb, CEE_LEAVE);
/* Add a try clause around the call */
clause = mono_image_alloc0 (target_klass->image, sizeof (MonoExceptionClause));
clause = mono_image_alloc0 (target_klass->image, sizeof (MonoExceptionClause), "mb-exception-clause");
clause->flags = MONO_EXCEPTION_CLAUSE_NONE;
clause->data.catch_class = mono_defaults.exception_class;
clause->try_offset = labels [1];
@@ -5234,7 +5234,7 @@ mono_marshal_get_runtime_invoke_dynamic (void)
pos = mono_mb_emit_branch (mb, CEE_LEAVE);
clause = mono_image_alloc0 (mono_defaults.corlib, sizeof (MonoExceptionClause));
clause = mono_image_alloc0 (mono_defaults.corlib, sizeof (MonoExceptionClause), "mb-exception-clause");
clause->flags = MONO_EXCEPTION_CLAUSE_FILTER;
clause->try_len = mono_mb_get_label (mb);
@@ -10534,7 +10534,7 @@ mono_marshal_get_synchronized_wrapper (MonoMethod *method)
/* this */
this_local = mono_mb_add_local (mb, &mono_defaults.object_class->byval_arg);
clause = mono_image_alloc0 (method->klass->image, sizeof (MonoExceptionClause));
clause = mono_image_alloc0 (method->klass->image, sizeof (MonoExceptionClause), "mb-exception-clause");
clause->flags = MONO_EXCEPTION_CLAUSE_FINALLY;
#endif
@@ -12300,7 +12300,7 @@ mono_marshal_load_type_info (MonoClass* klass)
layout = klass->flags & TYPE_ATTRIBUTE_LAYOUT_MASK;
/* The mempool is protected by the loader lock */
info = mono_image_alloc0 (klass->image, MONO_SIZEOF_MARSHAL_TYPE + sizeof (MonoMarshalField) * count);
info = mono_image_alloc0 (klass->image, MONO_SIZEOF_MARSHAL_TYPE + sizeof (MonoMarshalField) * count, "marshal-type-info");
info->num_fields = count;
/* Try to find a size for this type in metadata */
@@ -12904,7 +12904,7 @@ mono_marshal_get_thunk_invoke_wrapper (MonoMethod *method)
mono_mb_emit_byte (mb, CEE_STIND_REF);
/* try */
clause = mono_image_alloc0 (image, sizeof (MonoExceptionClause));
clause = mono_image_alloc0 (image, sizeof (MonoExceptionClause), "mb-exception-clause");
clause->try_offset = mono_mb_get_label (mb);
/* push method's args */
+80
View File
@@ -0,0 +1,80 @@
MEMDOM_TYPE_START(MonoImage)
MEMDOM_FIELD(MonoImage, mempool, MEMPOOL)
MEMDOM_FIELD(MonoImage, method_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, class_cache, INTERNAL_HASHTABLE)
MEMDOM_FIELD(MonoImage, methodref_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, field_cache, CONC_HASHTABLE)
MEMDOM_FIELD(MonoImage, typespec_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, memberref_signatures, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, helper_signatures, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, method_signatures, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, name_cache, NESTED_G_HASHTABLE)
MEMDOM_FIELD(MonoImage, array_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, ptr_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, szarray_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_begin_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_end_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, runtime_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, runtime_invoke_vtype_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_abstract_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_bound_static_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, runtime_invoke_direct_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, runtime_invoke_vcall_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, managed_wrapper_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, native_wrapper_aot_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, native_func_wrapper_aot_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, remoting_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, synchronized_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, unbox_wrapper_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, cominterop_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, cominterop_wrapper_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, thunk_invoke_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, wrapper_param_names, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, synchronized_generic_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, array_accessor_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, ldfld_wrapper_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, ldflda_wrapper_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, stfld_wrapper_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, isinst_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, castclass_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, proxy_isinst_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, rgctx_template_hash, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_invoke_generic_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_begin_invoke_generic_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, delegate_end_invoke_generic_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, property_hash, PROPERTY_HASHTABLE)
MEMDOM_FIELD(MonoImage, var_cache_slow, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, mvar_cache_slow, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, pinvoke_scopes, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, pinvoke_scope_filenames, G_HASHTABLE)
MEMDOM_FIELD(MonoImage, gsharedvt_types, G_HASHTABLE)
MEMDOM_TYPE_END()
MEMDOM_TYPE_START(MonoDomain)
MEMDOM_FIELD(MonoDomain, mp, MEMPOOL)
MEMDOM_FIELD(MonoDomain, env, MONO_HASHTABLE)
MEMDOM_FIELD(MonoDomain, ldstr_table, MONO_HASHTABLE)
MEMDOM_FIELD(MonoDomain, type_hash, MONO_HASHTABLE)
MEMDOM_FIELD(MonoDomain, refobject_hash, MONO_HASHTABLE)
MEMDOM_FIELD(MonoDomain, type_init_exception_hash, MONO_HASHTABLE)
MEMDOM_FIELD(MonoDomain, delegate_hash_table, MONO_HASHTABLE)
MEMDOM_FIELD(MonoDomain, proxy_vtable_hash, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, jit_code_hash, INTERNAL_HASHTABLE)
// MEMDOM_FIELD(MonoDomain, jit_info_table, JIT_INFO_TABLE)
// MEMDOM_FIELD(MonoDomain, aot_modules, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, special_static_fields, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, finalizable_objects_hash, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, method_rgctx_hash, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, generic_virtual_cases, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, generic_virtual_thunks, G_HASHTABLE)
MEMDOM_FIELD(MonoDomain, ftnptrs_hash, G_HASHTABLE)
MEMDOM_TYPE_END()
MEMDOM_TYPE_START(MonoImageSet)
MEMDOM_FIELD(MonoImageSet, gclass_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImageSet, ginst_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImageSet, gmethod_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImageSet, gsignature_cache, G_HASHTABLE)
MEMDOM_FIELD(MonoImageSet, mempool, MEMPOOL)
MEMDOM_TYPE_END()
+458
View File
@@ -0,0 +1,458 @@
#include <mono/metadata/memory-profiler.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/image.h>
#include <mono/utils/mono-mutex.h>
#include <mono/utils/mono-internal-hash.h>
#include <mono/utils/mono-conc-hashtable.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/atomic.h>
typedef enum
{
MEMPOOL,
G_HASHTABLE,
NESTED_G_HASHTABLE,
MONO_HASHTABLE,
INTERNAL_HASHTABLE,
CONC_HASHTABLE,
PROPERTY_HASHTABLE,
ITEM_KIND_MAX,
} MemDomItemKind;
typedef struct {
MemDomItemKind type;
int offset;
const char *name;
} ItemDesc;
#define MEMDOM_TYPE_START(TYPE) static ItemDesc descriptor_ ## TYPE [] = {
#define MEMDOM_FIELD(TYPE,FIELD,KIND) { KIND, G_STRUCT_OFFSET (TYPE, FIELD), #FIELD },
#define MEMDOM_TYPE_END() { ITEM_KIND_MAX } };
#include "memory-domain-def.h"
static mono_mutex_t memprof_mutex;
static GHashTable *mem_domains, *global_allocs;
typedef struct {
gpointer address;
MemoryDomainKind kind;
size_t extra_alloc;
GHashTable *mempool_allocs;
} MemDomain;
typedef struct {
const char *tag;
size_t alloc_bytes;
size_t alloc_count;
} AllocInfo;
static inline void
memprof_lock (void)
{
mono_mutex_lock (&memprof_mutex);
}
static inline void
memprof_unlock (void)
{
mono_mutex_unlock (&memprof_mutex);
}
static void
free_memdom (gpointer arg)
{
MemDomain *dom = arg;
g_hash_table_destroy (dom->mempool_allocs);
g_free (dom);
}
void
mono_memory_profiler_init (void)
{
mono_mutex_init (&memprof_mutex);
mem_domains = g_hash_table_new_full (mono_aligned_addr_hash, NULL, NULL, free_memdom);
global_allocs = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
}
void
mono_profiler_register_memory_domain (gpointer domain, MemoryDomainKind kind)
{
MemDomain *dom = g_new0 (MemDomain, 1);
dom->address = domain;
dom->kind = kind;
dom->mempool_allocs = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
memprof_lock ();
g_hash_table_insert (mem_domains, domain, dom);
memprof_unlock ();
}
void
mono_profiler_free_memory_domain (gpointer domain)
{
memprof_lock ();
g_hash_table_remove (mem_domains, domain);
memprof_unlock ();
}
static void
add_alloc_to_hashtable (GHashTable *hash, const char *tag, gsize size)
{
AllocInfo *info = g_hash_table_lookup (hash, tag);
if (!info) {
info = g_new0 (AllocInfo, 1);
info->tag = tag;
g_hash_table_insert (hash, (char*)tag, info);
}
info->alloc_bytes += size;
info->alloc_count++;
}
void
mono_profiler_add_mempool_alloc (gpointer domain, gsize size, const char *tag)
{
MemDomain *dom;
memprof_lock ();
dom = g_hash_table_lookup (mem_domains, domain);
if (!dom)
g_print ("WARNING could not find memdom %p\n", domain);
else
add_alloc_to_hashtable (dom->mempool_allocs, tag, size);
memprof_unlock ();
}
void
mono_profiler_add_allocation (const char *tag, gsize size)
{
memprof_lock ();
add_alloc_to_hashtable (global_allocs, tag, size);
memprof_unlock ();
}
void
mono_profiler_remove_allocation (const char *tag, gsize size)
{
AllocInfo *info;
memprof_lock ();
info = g_hash_table_lookup (global_allocs, tag);
if (info)
info->alloc_bytes -= size;
memprof_unlock ();
}
typedef struct {
const char *tag;
gpointer address;
size_t size;
} VAllocRecord;
#define VALLOC_ENTRIES (4096 / sizeof (VAllocRecord) - 1)
typedef struct _VAllocRecordBucket VAllocRecordBucket;
struct _VAllocRecordBucket{
int index;
VAllocRecordBucket *next_bucket;
VAllocRecord entries [VALLOC_ENTRIES];
};
static VAllocRecordBucket *current_bucket;
static VAllocRecordBucket*
alloc_bucket (void)
{
VAllocRecordBucket *old, *bucket;
old = current_bucket;
if (old && old->index < VALLOC_ENTRIES)
return old;
bucket = mono_valloc (NULL, sizeof (VAllocRecordBucket), MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON, NULL);
bucket->index = 0;
do {
old = current_bucket;
bucket->next_bucket = old;
} while (InterlockedCompareExchangePointer ((gpointer)&current_bucket, bucket, old) != old);
return bucket;
}
static VAllocRecord*
get_next_record (void)
{
VAllocRecordBucket *bucket;
int index;
retry:
bucket = current_bucket;
if (!current_bucket)
bucket = alloc_bucket ();
while (bucket->index >= VALLOC_ENTRIES)
bucket = alloc_bucket ();
index = InterlockedIncrement (&bucket->index) - 1;
if (index >= VALLOC_ENTRIES)
goto retry;
return &bucket->entries [index];
}
#define ALIGN_TO(val,align) ((((guint64)val) + ((align) - 1)) & ~((align) - 1))
void
mono_profiler_valloc (gpointer address, size_t size, const char *tag)
{
VAllocRecord *record;
if (!tag)
return;
record = get_next_record ();
record->tag = tag;
record->address = address;
record->size = ALIGN_TO (size, 4096);
}
void
mono_profiler_vfree (gpointer address, size_t size)
{
VAllocRecord *record;
record = get_next_record ();
record->tag = NULL;
record->address = address;
record->size = ALIGN_TO (size, 4096);
}
#if (SIZEOF_VOID_P == 4)
#define UINT_TO_POINTER(u) ((void*)(guint32)(u))
#define POINTER_TO_UINT(p) ((guint32)(void*)(p))
#elif (SIZEOF_VOID_P == 8)
#define UINT_TO_POINTER(u) ((void*)(guint64)(u))
#define POINTER_TO_UINT(p) ((guint64)(void*)(p))
#else
#error Bad size of void pointer
#endif
static void
cat_add_val (GHashTable *hash, const char *tag, size_t new_val)
{
size_t cur_val = POINTER_TO_UINT (g_hash_table_lookup (hash, tag));
g_hash_table_replace (hash, (char*)tag, UINT_TO_POINTER (cur_val + new_val));
}
//This sucks, but tracking partial vfree makes it really complicated
static const char *
find_cat (gpointer address, gpointer limit)
{
int i;
const char *cat = NULL;
VAllocRecordBucket *bucket = current_bucket;
for (bucket = current_bucket; bucket; bucket = bucket->next_bucket) {
for (i = 0; i < MIN (bucket->index, VALLOC_ENTRIES); ++i) {
VAllocRecord *r = &bucket->entries [i];
if (r == limit)
return cat;
if (!r->tag)
continue;
if (r->address <= address && ((char*)r->address + r->size) > (char*)address)
cat = r->tag;
}
}
g_error ("should not happen");
}
static void
cat_del_val (GHashTable *hash, gpointer address, size_t size, gpointer record)
{
size_t cur_val;
const char *cat = find_cat (address, record);
if (!cat) {
printf ("bad vfree %p\n", address);
return;
}
cur_val = POINTER_TO_UINT (g_hash_table_lookup (hash, cat));
g_hash_table_replace (hash, (char*)cat, UINT_TO_POINTER (cur_val - size));
}
static void
dump_cat_alloc (gpointer key, gpointer val, gpointer user_data)
{
printf ("\t%s %zd\n", key, POINTER_TO_UINT (val));
}
//TODO sumarize alloc records
static size_t
dump_valloc (void)
{
int i, entries = 0;
size_t total_alloc = 0, total_free = 0;
VAllocRecordBucket *bucket = current_bucket;
GHashTable *per_cat_alloc = g_hash_table_new (g_str_hash, g_str_equal);
for (bucket = current_bucket; bucket; bucket = bucket->next_bucket) {
for (i = 0; i < MIN (bucket->index, VALLOC_ENTRIES); ++i) {
VAllocRecord *r = &bucket->entries [i];
++entries;
if (r->tag) {
total_alloc += r->size;
cat_add_val (per_cat_alloc, r->tag, r->size);
} else {
total_free += r->size;
cat_del_val (per_cat_alloc, r->address, r->size, r);
}
}
}
g_hash_table_foreach (per_cat_alloc, dump_cat_alloc, NULL);
printf ("VALLOC summary %zd allocated %zd freed - %zd active %d entries\n", total_alloc, total_free, total_alloc - total_free, entries);
g_hash_table_destroy (per_cat_alloc);
return total_alloc;
}
static void
add_nested_hashes (gpointer key, gpointer value, gpointer user_data)
{
GHashTable *prop_hash = (GHashTable*)value;
size_t *size = user_data;
*size += mono_eg_hashtable_get_memory_size (prop_hash);
}
//TODO account for the key/value sizes unique to the cached entry
static size_t
dump_desc (ItemDesc *desc, gpointer *domain)
{
gpointer *slot = (gpointer*)((char*)domain + desc->offset);
size_t size;
const char *kind;
switch (desc->type) {
case MEMPOOL:
if (!*slot)
return 0;
size = mono_mempool_get_allocated (*slot);
kind = "mempool";
break;
case G_HASHTABLE:
if (!*slot)
return 0;
size = mono_eg_hashtable_get_memory_size (*slot);
kind = "g_hashtable";
break;
case NESTED_G_HASHTABLE:
if (!*slot)
return 0;
size = mono_eg_hashtable_get_memory_size (*slot);
g_hash_table_foreach (*slot, add_nested_hashes, &size);
kind = "nested_g_hashtable";
break;
case MONO_HASHTABLE:
if (!*slot)
return 0;
size = mono_hashtable_get_memory_size (*slot);
kind = "mono_hashtable";
break;
case INTERNAL_HASHTABLE:
size = mono_internal_hashtable_get_memory_size ((MonoInternalHashTable*)slot);
kind = "internal_hashtable";
break;
case CONC_HASHTABLE:
if (!*slot)
return 0;
size = mono_conc_hashtable_get_memory_size (*slot);
kind = "conc_hashtable";
break;
case PROPERTY_HASHTABLE:
if (!*slot)
return 0;
size = mono_property_hash_get_memory_size (*slot);
kind = "property_hashtable";
break;
default:
g_assert (0);
}
printf ("\t%s:%s size %zd\n", kind, desc->name, size);
return size;
}
static void
dump_allocs (gpointer key, gpointer val, gpointer user_data)
{
size_t *md_total = user_data;
AllocInfo *info = val;
printf ("\t%s: %zd (%zd allocs)\n", info->tag, info->alloc_bytes, info->alloc_count);
*md_total += info->alloc_bytes;
}
static size_t
dump_memdom (MemDomain *dom, int domsize, ItemDesc *descriptor, char *name)
{
size_t tracked_count = 0;
int i;
size_t total = domsize + dom->extra_alloc;
printf ("%s: size %d extra malloc %zd\n", name, domsize, dom->extra_alloc);
for (i = 0; descriptor [i].type != ITEM_KIND_MAX; ++i)
total += dump_desc (&descriptor [i], dom->address);
printf ("mempool:\n");
g_hash_table_foreach (dom->mempool_allocs, dump_allocs, &tracked_count);
printf ("--total: %zd (mempool tracked %zd)\n\n", total, tracked_count);
g_free (name);
return total;
}
static void
dump_domain (gpointer key, gpointer val, gpointer user_data)
{
size_t *md_total = user_data;
MemDomain *dom = val;
switch (dom->kind) {
case MEMDOM_APPDOMAIN: {
MonoDomain *domain = dom->address;
*md_total += dump_memdom (dom, sizeof (MonoDomain), descriptor_MonoDomain, g_strdup_printf ("domain_%d", domain->domain_id));
break;
}
case MEMDOM_IMAGE: {
MonoImage *image = dom->address;
*md_total += dump_memdom (dom, sizeof (MonoImage), descriptor_MonoImage, g_strdup_printf ("image_%s", image->module_name));
break;
}
case MEMDOM_IMAGE_SET: {
MonoImageSet *set = dom->address;
int i;
GString* name = g_string_new (0);
g_string_append_printf (name, "imageset");
for (i = 0; i < set->nimages; ++i)
g_string_append_printf(name, "_%s", set->images [i]->module_name);
*md_total += dump_memdom (dom, sizeof (MonoImageSet), descriptor_MonoImageSet, g_string_free (name, FALSE));
break;
}
default:
g_assert (0);
}
}
void
mono_memprof_dump (void)
{
size_t grand_total = 0;
memprof_lock ();
printf ("---Alloc Domains---\n");
g_hash_table_foreach (mem_domains, dump_domain, &grand_total);
printf ("---Allocations---\n");
g_hash_table_foreach (global_allocs, dump_allocs, &grand_total);
printf ("---VALLOC---\n");
grand_total += dump_valloc ();
printf ("---------- grand total: %zd\n", grand_total);
memprof_unlock ();
}
+31
View File
@@ -0,0 +1,31 @@
#ifndef __MONO_METADATA_MEMPROF_H__
#define __MONO_METADATA_MEMPROF_H__
#include <glib.h>
#include <mono/utils/mono-compiler.h>
typedef enum {
MEMDOM_APPDOMAIN,
MEMDOM_IMAGE,
MEMDOM_IMAGE_SET,
MEMDOM_MAX,
} MemoryDomainKind;
void mono_profiler_register_memory_domain (gpointer domain, MemoryDomainKind kind) MONO_INTERNAL;
void mono_profiler_free_memory_domain (gpointer domain) MONO_INTERNAL;
void mono_profiler_add_mempool_alloc (gpointer domain, gsize size, const char *tag) MONO_INTERNAL;
/*use this for large allocations that are not automtically tracked */
void mono_profiler_add_allocation (const char *tag, gsize size) MONO_INTERNAL;
void mono_profiler_remove_allocation (const char *tag, gsize size) MONO_INTERNAL;
void mono_profiler_valloc (gpointer address, size_t size, const char *tag) MONO_INTERNAL;
void mono_profiler_vfree (gpointer address, size_t size) MONO_INTERNAL;
void mono_memory_profiler_init (void) MONO_INTERNAL;
void mono_memprof_dump (void);
#endif
+27 -11
View 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
@@ -552,21 +566,21 @@ void
mono_image_check_for_module_cctor (MonoImage *image) MONO_INTERNAL;
gpointer
mono_image_alloc (MonoImage *image, guint size) MONO_INTERNAL;
mono_image_alloc (MonoImage *image, guint size, const char *what) MONO_INTERNAL;
gpointer
mono_image_alloc0 (MonoImage *image, guint size) MONO_INTERNAL;
mono_image_alloc0 (MonoImage *image, guint size, const char *what) MONO_INTERNAL;
#define mono_image_new0(image,type,size) ((type *) mono_image_alloc0 (image, sizeof (type)* (size)))
#define mono_image_new0(image,type,size,what) ((type *) mono_image_alloc0 (image, sizeof (type)* (size), what))
char*
mono_image_strdup (MonoImage *image, const char *s) MONO_INTERNAL;
mono_image_strdup (MonoImage *image, const char *s, const char *what) MONO_INTERNAL;
GList*
g_list_prepend_image (MonoImage *image, GList *list, gpointer data) MONO_INTERNAL;
g_list_prepend_image (MonoImage *image, GList *list, gpointer data, const char *what) MONO_INTERNAL;
GSList*
g_slist_append_image (MonoImage *image, GSList *list, gpointer data) MONO_INTERNAL;
g_slist_append_image (MonoImage *image, GSList *list, gpointer data, const char *what) MONO_INTERNAL;
void
mono_image_lock (MonoImage *image) MONO_INTERNAL;
@@ -601,15 +615,15 @@ void
mono_image_append_class_to_reflection_info_set (MonoClass *klass) MONO_INTERNAL;
gpointer
mono_image_set_alloc (MonoImageSet *set, guint size) MONO_INTERNAL;
mono_image_set_alloc (MonoImageSet *set, guint size, const char *what) MONO_INTERNAL;
gpointer
mono_image_set_alloc0 (MonoImageSet *set, guint size) MONO_INTERNAL;
mono_image_set_alloc0 (MonoImageSet *set, guint size, const char *what) MONO_INTERNAL;
char*
mono_image_set_strdup (MonoImageSet *set, const char *s) MONO_INTERNAL;
mono_image_set_strdup (MonoImageSet *set, const char *s, const char *what) MONO_INTERNAL;
#define mono_image_set_new0(image,type,size) ((type *) mono_image_set_alloc0 (image, sizeof (type)* (size)))
#define mono_image_set_new0(image,type,size,what) ((type *) mono_image_set_alloc0 (image, sizeof (type)* (size), what))
MonoType*
mono_metadata_get_shared_type (MonoType *type) MONO_INTERNAL;
@@ -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__ */
+45 -45
View File
@@ -26,6 +26,7 @@
#include "marshal.h"
#include "debug-helpers.h"
#include "abi-details.h"
#include "memory-profiler.h"
#include <mono/utils/mono-error-internals.h>
#include <mono/utils/bsearch.h>
@@ -1268,7 +1269,7 @@ mono_metadata_parse_array_internal (MonoImage *m, MonoGenericContainer *containe
MonoArrayType *array;
MonoType *etype;
array = transient ? g_malloc0 (sizeof (MonoArrayType)) : mono_image_alloc0 (m, sizeof (MonoArrayType));
array = transient ? g_malloc0 (sizeof (MonoArrayType)) : mono_image_alloc0 (m, sizeof (MonoArrayType), "array-type");
etype = mono_metadata_parse_type_full (m, container, MONO_PARSE_TYPE, 0, ptr, &ptr);
if (!etype)
return NULL;
@@ -1277,13 +1278,13 @@ mono_metadata_parse_array_internal (MonoImage *m, MonoGenericContainer *containe
array->numsizes = mono_metadata_decode_value (ptr, &ptr);
if (array->numsizes)
array->sizes = transient ? g_malloc0 (sizeof (int) * array->numsizes) : mono_image_alloc0 (m, sizeof (int) * array->numsizes);
array->sizes = transient ? g_malloc0 (sizeof (int) * array->numsizes) : mono_image_alloc0 (m, sizeof (int) * array->numsizes, "array-sizes");
for (i = 0; i < array->numsizes; ++i)
array->sizes [i] = mono_metadata_decode_value (ptr, &ptr);
array->numlobounds = mono_metadata_decode_value (ptr, &ptr);
if (array->numlobounds)
array->lobounds = transient ? g_malloc0 (sizeof (int) * array->numlobounds) : mono_image_alloc0 (m, sizeof (int) * array->numlobounds);
array->lobounds = transient ? g_malloc0 (sizeof (int) * array->numlobounds) : mono_image_alloc0 (m, sizeof (int) * array->numlobounds, "array-lobounds");
for (i = 0; i < array->numlobounds; ++i)
array->lobounds [i] = mono_metadata_decode_signed_value (ptr, &ptr);
@@ -1581,7 +1582,7 @@ mono_metadata_parse_type_internal (MonoImage *m, MonoGenericContainer *container
int size;
size = MONO_SIZEOF_TYPE + ((gint32)count) * sizeof (MonoCustomMod);
type = transient ? g_malloc0 (size) : mono_image_alloc0 (m, size);
type = transient ? g_malloc0 (size) : mono_image_alloc0 (m, size, "type-with-mods");
type->num_mods = count;
if (count > 64)
g_warning ("got more than 64 modifiers in type");
@@ -1660,7 +1661,7 @@ mono_metadata_parse_type_internal (MonoImage *m, MonoGenericContainer *container
/* printf ("%x %x %c %s\n", type->attrs, type->num_mods, type->pinned ? 'p' : ' ', mono_type_full_name (type)); */
if (type == &stype) {
type = transient ? g_malloc (MONO_SIZEOF_TYPE) : mono_image_alloc (m, MONO_SIZEOF_TYPE);
type = transient ? g_malloc (MONO_SIZEOF_TYPE) : mono_image_alloc (m, MONO_SIZEOF_TYPE, "type");
memcpy (type, &stype, MONO_SIZEOF_TYPE);
}
return type;
@@ -1812,7 +1813,7 @@ mono_metadata_signature_alloc (MonoImage *m, guint32 nparams)
{
MonoMethodSignature *sig;
sig = mono_image_alloc0 (m, MONO_SIZEOF_METHOD_SIGNATURE + ((gint32)nparams) * sizeof (MonoType*));
sig = mono_image_alloc0 (m, MONO_SIZEOF_METHOD_SIGNATURE + ((gint32)nparams) * sizeof (MonoType*), "signature");
sig->param_count = nparams;
sig->sentinelpos = -1;
@@ -1827,7 +1828,7 @@ mono_metadata_signature_dup_internal (MonoImage *image, MonoMemPool *mp, MonoMet
sigsize = MONO_SIZEOF_METHOD_SIGNATURE + sig->param_count * sizeof (MonoType *);
if (image) {
ret = mono_image_alloc (image, sigsize);
ret = mono_image_alloc (image, sigsize, "signature-dup");
} else if (mp) {
ret = mono_mempool_alloc (mp, sigsize);
} else {
@@ -2256,6 +2257,8 @@ get_image_set (MonoImage **images, int nimages)
set->nimages = nimages;
set->images = g_new0 (MonoImage*, nimages);
mono_mutex_init_recursive (&set->lock);
mono_profiler_register_memory_domain (set, MEMDOM_IMAGE_SET);
for (i = 0; i < nimages; ++i)
set->images [i] = images [i];
set->gclass_cache = g_hash_table_new_full (mono_generic_class_hash, mono_generic_class_equal, NULL, (GDestroyNotify)free_generic_class);
@@ -2283,6 +2286,7 @@ static void
delete_image_set (MonoImageSet *set)
{
int i;
mono_profiler_free_memory_domain (set);
g_hash_table_destroy (set->gclass_cache);
g_hash_table_destroy (set->ginst_cache);
@@ -2318,13 +2322,14 @@ mono_image_set_unlock (MonoImageSet *set)
}
gpointer
mono_image_set_alloc (MonoImageSet *set, guint size)
mono_image_set_alloc (MonoImageSet *set, guint size, const char *what)
{
gpointer res;
mono_image_set_lock (set);
if (!set->mempool)
set->mempool = mono_mempool_new_size (1024);
mono_profiler_add_mempool_alloc (set, size, what);
res = mono_mempool_alloc (set->mempool, size);
mono_image_set_unlock (set);
@@ -2332,13 +2337,14 @@ mono_image_set_alloc (MonoImageSet *set, guint size)
}
gpointer
mono_image_set_alloc0 (MonoImageSet *set, guint size)
mono_image_set_alloc0 (MonoImageSet *set, guint size, const char *what)
{
gpointer res;
mono_image_set_lock (set);
if (!set->mempool)
set->mempool = mono_mempool_new_size (1024);
mono_profiler_add_mempool_alloc (set, size, what);
res = mono_mempool_alloc0 (set->mempool, size);
mono_image_set_unlock (set);
@@ -2346,13 +2352,14 @@ mono_image_set_alloc0 (MonoImageSet *set, guint size)
}
char*
mono_image_set_strdup (MonoImageSet *set, const char *s)
mono_image_set_strdup (MonoImageSet *set, const char *s, const char *what)
{
char *res;
mono_image_set_lock (set);
if (!set->mempool)
set->mempool = mono_mempool_new_size (1024);
mono_profiler_add_mempool_alloc (set, strlen (s) + 1, what);
res = mono_mempool_strdup (set->mempool, s);
mono_image_set_unlock (set);
@@ -2851,7 +2858,7 @@ mono_metadata_get_generic_inst (int type_argc, MonoType **type_argv)
ginst = g_hash_table_lookup (set->ginst_cache, ginst);
if (!ginst) {
ginst = mono_image_set_alloc0 (set, size);
ginst = mono_image_set_alloc0 (set, size, "generic-inst");
#ifndef MONO_SMALL_CONFIG
ginst->id = ++next_generic_inst_id;
#endif
@@ -2921,11 +2928,11 @@ mono_metadata_lookup_generic_class (MonoClass *container_class, MonoGenericInst
}
if (is_dynamic) {
MonoDynamicGenericClass *dgclass = mono_image_set_new0 (set, MonoDynamicGenericClass, 1);
MonoDynamicGenericClass *dgclass = mono_image_set_new0 (set, MonoDynamicGenericClass, 1, "sre-dynamic-generic-class");
gclass = &dgclass->generic_class;
gclass->is_dynamic = 1;
} else {
gclass = mono_image_set_new0 (set, MonoGenericClass, 1);
gclass = mono_image_set_new0 (set, MonoGenericClass, 1, "generic-class");
}
gclass->is_tb_open = is_tb_open;
@@ -3086,7 +3093,7 @@ mono_metadata_parse_generic_param (MonoImage *m, MonoGenericContainer *generic_c
/* Create dummy MonoGenericParam */
MonoGenericParam *param;
param = mono_image_alloc0 (m, sizeof (MonoGenericParam));
param = mono_image_alloc0 (m, sizeof (MonoGenericParam), "generic-param");
param->num = index;
param->image = m;
@@ -4038,7 +4045,7 @@ mono_metadata_interfaces_from_typedef_full (MonoImage *meta, guint32 index, Mono
if (heap_alloc_result)
result = g_new0 (MonoClass*, pos - start);
else
result = mono_image_alloc0 (meta, sizeof (MonoClass*) * (pos - start));
result = mono_image_alloc0 (meta, sizeof (MonoClass*) * (pos - start), "class-typedef-interface-list");
pos = start;
while (pos < tdef->rows) {
@@ -4889,7 +4896,7 @@ mono_metadata_type_dup (MonoImage *image, const MonoType *o)
if (o->num_mods)
sizeof_o += o->num_mods * sizeof (MonoCustomMod);
r = image ? mono_image_alloc0 (image, sizeof_o) : g_malloc (sizeof_o);
r = image ? mono_image_alloc0 (image, sizeof_o, "type-dup") : g_malloc (sizeof_o);
memcpy (r, o, sizeof_o);
@@ -5293,56 +5300,49 @@ 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;
}
static char*
mono_image_strndup (MonoImage *image, const char *data, guint len)
mono_image_strndup (MonoImage *image, const char *data, guint len, const char *what)
{
char *res;
if (!image)
return g_strndup (data, len);
res = mono_image_alloc (image, len + 1);
res = mono_image_alloc (image, len + 1, what);
memcpy (res, data, len);
res [len] = 0;
return res;
@@ -5368,7 +5368,7 @@ mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image
/* fixme: this is incomplete, but I cant find more infos in the specs */
if (image)
res = mono_image_alloc0 (image, sizeof (MonoMarshalSpec));
res = mono_image_alloc0 (image, sizeof (MonoMarshalSpec), "marshal-spec");
else
res = g_new0 (MonoMarshalSpec, 1);
@@ -5419,11 +5419,11 @@ mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image
ptr += len;
/* read custom marshaler type name */
len = mono_metadata_decode_value (ptr, &ptr);
res->data.custom_data.custom_name = mono_image_strndup (image, ptr, len);
res->data.custom_data.custom_name = mono_image_strndup (image, ptr, len, "marshal-spec-custom-name");
ptr += len;
/* read cookie string */
len = mono_metadata_decode_value (ptr, &ptr);
res->data.custom_data.cookie = mono_image_strndup (image, ptr, len);
res->data.custom_data.cookie = mono_image_strndup (image, ptr, len, "marshal-spec-cookie");
res->data.custom_data.image = parent_image;
}
@@ -5809,7 +5809,7 @@ get_constraints (MonoImage *image, int owner, MonoClass ***constraints, MonoGene
}
if (!found)
return TRUE;
res = mono_image_alloc0 (image, sizeof (MonoClass*) * (found + 1));
res = mono_image_alloc0 (image, sizeof (MonoClass*) * (found + 1), "generic-constraints");
for (i = 0, tmp = cons; i < found; ++i, tmp = tmp->next) {
res [i] = tmp->data;
}
@@ -5939,7 +5939,7 @@ mono_metadata_load_generic_params (MonoImage *image, guint32 token, MonoGenericC
mono_metadata_decode_row (tdef, i - 1, cols, MONO_GENERICPARAM_SIZE);
params = NULL;
n = 0;
container = mono_image_alloc0 (image, sizeof (MonoGenericContainer));
container = mono_image_alloc0 (image, sizeof (MonoGenericContainer), "generic-container");
container->image = image;
do {
n++;
@@ -5958,7 +5958,7 @@ mono_metadata_load_generic_params (MonoImage *image, guint32 token, MonoGenericC
} while (cols [MONO_GENERICPARAM_OWNER] == owner);
container->type_argc = n;
container->type_params = mono_image_alloc0 (image, sizeof (MonoGenericParamFull) * n);
container->type_params = mono_image_alloc0 (image, sizeof (MonoGenericParamFull) * n, "generic-container-params");
memcpy (container->type_params, params, sizeof (MonoGenericParamFull) * n);
g_free (params);
container->parent = parent_container;
+7 -7
View File
@@ -155,20 +155,20 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
{
/* Realloc the method info into a mempool */
method = mono_image_alloc0 (image, sizeof (MonoMethodWrapper));
method = mono_image_alloc0 (image, sizeof (MonoMethodWrapper), "mb-method-wrapper");
memcpy (method, mb->method, sizeof (MonoMethodWrapper));
mw = (MonoMethodWrapper*) method;
if (mb->no_dup_name)
method->name = mb->name;
else
method->name = mono_image_strdup (image, mb->name);
method->name = mono_image_strdup (image, mb->name, "mb-method-name");
#ifndef DISABLE_JIT
mw->header = header = (MonoMethodHeader *)
mono_image_alloc0 (image, MONO_SIZEOF_METHOD_HEADER + mb->locals * sizeof (MonoType *));
mono_image_alloc0 (image, MONO_SIZEOF_METHOD_HEADER + mb->locals * sizeof (MonoType *), "mb-method-header");
header->code = mono_image_alloc (image, mb->pos);
header->code = mono_image_alloc (image, mb->pos, "mb-method-code");
memcpy ((char*)header->code, mb->code, mb->pos);
for (i = 0, l = mb->locals_list; l; l = l->next, i++) {
@@ -205,7 +205,7 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
if (method_is_dynamic (method))
data = g_malloc (sizeof (gpointer) * (i + 1));
else
data = mono_image_alloc (image, sizeof (gpointer) * (i + 1));
data = mono_image_alloc (image, sizeof (gpointer) * (i + 1), "mb-method-data");
/* store the size in the first element */
data [0] = GUINT_TO_POINTER (i);
i = 1;
@@ -232,9 +232,9 @@ mono_mb_create_method (MonoMethodBuilder *mb, MonoMethodSignature *signature, in
#endif
if (mb->param_names) {
char **param_names = mono_image_alloc0 (image, signature->param_count * sizeof (gpointer));
char **param_names = mono_image_alloc0 (image, signature->param_count * sizeof (gpointer), "mb-param-name-list");
for (i = 0; i < signature->param_count; ++i)
param_names [i] = mono_image_strdup (image, mb->param_names [i]);
param_names [i] = mono_image_strdup (image, mb->param_names [i], "mb-param-name");
mono_image_lock (image);
if (!image->wrapper_param_names)
+2 -2
View File
@@ -1034,7 +1034,7 @@ mono_monitor_get_fast_enter_method (MonoMethod *monitor_enter_method)
res = register_fastpath (mono_mb_create_method (mb, mono_signature_no_pinvoke (monitor_enter_method), 5), fast_path_idx);
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (WrapperInfo));
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (WrapperInfo), "monitor-wrapper-info");
info->subtype = is_v4 ? WRAPPER_SUBTYPE_FAST_MONITOR_ENTER_V4 : WRAPPER_SUBTYPE_FAST_MONITOR_ENTER;
mono_marshal_set_wrapper_info (res, info);
@@ -1195,7 +1195,7 @@ mono_monitor_get_fast_exit_method (MonoMethod *monitor_exit_method)
res = register_fastpath (mono_mb_create_method (mb, mono_signature_no_pinvoke (monitor_exit_method), 5), FASTPATH_EXIT);
mono_mb_free (mb);
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (WrapperInfo));
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (WrapperInfo), "monitor-wrapper-info");
info->subtype = WRAPPER_SUBTYPE_FAST_MONITOR_EXIT;
mono_marshal_set_wrapper_info (res, info);
+49 -1
View 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 */
+8
View File
@@ -477,6 +477,14 @@ mono_g_hash_table_print_stats (MonoGHashTable *table)
printf ("Size: %d Table Size: %d Max Chain Length: %d\n", table->in_use, table->table_size, max_chain_size);
}
size_t
mono_hashtable_get_memory_size (MonoGHashTable *hashtable)
{
return sizeof (MonoGHashTable) +
hashtable->in_use * sizeof (Slot) +
hashtable->table_size * sizeof (Slot*);
}
#ifdef HAVE_SGEN_GC
/* GC marker function */
+1 -1
View File
@@ -1614,7 +1614,7 @@ char *
mono_string_to_utf8_ignore (MonoString *s) MONO_INTERNAL;
char *
mono_string_to_utf8_image_ignore (MonoImage *image, MonoString *s) MONO_INTERNAL;
mono_string_to_utf8_image_ignore (MonoImage *image, MonoString *s, const char *what) MONO_INTERNAL;
char *
mono_string_to_utf8_mp_ignore (MonoMemPool *mp, MonoString *s) MONO_INTERNAL;
+21 -21
View File
@@ -85,7 +85,7 @@ static void
free_main_args (void);
static char *
mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s, gboolean ignore_error, MonoError *error);
mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s, gboolean ignore_error, const char *what, MonoError *error);
#define ldstr_lock() mono_mutex_lock (&ldstr_section)
@@ -1492,7 +1492,7 @@ init_thunk_free_lists (MonoDomain *domain)
{
if (domain->thunk_free_lists)
return;
domain->thunk_free_lists = mono_domain_alloc0 (domain, sizeof (gpointer) * NUM_FREE_LISTS);
domain->thunk_free_lists = mono_domain_alloc0 (domain, sizeof (gpointer) * NUM_FREE_LISTS, "thunk-free-lists");
}
static int
@@ -1714,7 +1714,7 @@ mono_method_add_generic_virtual_invocation (MonoDomain *domain, MonoVTable *vtab
/* If not found, make a new one */
if (!gvc) {
gvc = mono_domain_alloc (domain, sizeof (GenericVirtualCase));
gvc = mono_domain_alloc (domain, sizeof (GenericVirtualCase), "generic-virtual-case");
gvc->method = method;
gvc->code = code;
gvc->count = 0;
@@ -1937,7 +1937,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean
mono_stats.used_class_count++;
mono_stats.class_vtable_size += vtable_size;
interface_offsets = mono_domain_alloc0 (domain, vtable_size);
interface_offsets = mono_domain_alloc0 (domain, vtable_size, "runtime-vtable");
if (ARCH_USE_IMT)
vt = (MonoVTable*) ((char*)interface_offsets + imt_table_bytes);
@@ -1988,7 +1988,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean
if (bitmap != default_bitmap)
g_free (bitmap);
} else {
vt->vtable [class->vtable_size] = mono_domain_alloc0 (domain, class_size);
vt->vtable [class->vtable_size] = mono_domain_alloc0 (domain, class_size, "static-data");
}
vt->has_static_fields = TRUE;
mono_stats.class_static_data_size += class_size;
@@ -2149,7 +2149,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean
/* this is a bounded memory retention issue: may want to
* handle it differently when we'll have a rcu-like system.
*/
runtime_info = mono_image_alloc0 (class->image, MONO_SIZEOF_CLASS_RUNTIME_INFO + new_size * sizeof (gpointer));
runtime_info = mono_image_alloc0 (class->image, MONO_SIZEOF_CLASS_RUNTIME_INFO + new_size * sizeof (gpointer), "runtime-info");
runtime_info->max_domain = new_size - 1;
/* copy the stuff from the older info */
if (old_info) {
@@ -2266,7 +2266,7 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
mono_stats.class_vtable_size += vtsize + extra_interface_vtsize;
interface_offsets = mono_domain_alloc0 (domain, vtsize + extra_interface_vtsize);
interface_offsets = mono_domain_alloc0 (domain, vtsize + extra_interface_vtsize, "runtime-vtable-proxy");
if (ARCH_USE_IMT)
pvt = (MonoVTable*) (interface_offsets + MONO_IMT_SIZE);
else
@@ -2304,7 +2304,7 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
#ifdef COMPRESSED_INTERFACE_BITMAP
bitmap = g_malloc0 (bsize);
#else
bitmap = mono_domain_alloc0 (domain, bsize);
bitmap = mono_domain_alloc0 (domain, bsize, "interface bitmap");
#endif
if (! ARCH_USE_IMT) {
@@ -2358,7 +2358,7 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
#ifdef COMPRESSED_INTERFACE_BITMAP
bcsize = mono_compress_bitmap (NULL, bitmap, bsize);
pvt->interface_bitmap = mono_domain_alloc0 (domain, bcsize);
pvt->interface_bitmap = mono_domain_alloc0 (domain, bcsize, "interface bitmap");
mono_compress_bitmap (pvt->interface_bitmap, bitmap, bsize);
g_free (bitmap);
#else
@@ -2489,7 +2489,7 @@ static gpointer*
copy_remote_class_key (MonoDomain *domain, gpointer *key)
{
int key_size = (GPOINTER_TO_UINT (key [0]) + 1) * sizeof (gpointer);
gpointer *mp_key = mono_domain_alloc (domain, key_size);
gpointer *mp_key = mono_domain_alloc (domain, key_size, "remote-class-key");
memcpy (mp_key, key, key_size);
@@ -2536,12 +2536,12 @@ mono_remote_class (MonoDomain *domain, MonoString *class_name, MonoClass *proxy_
key = mp_key;
if (proxy_class->flags & TYPE_ATTRIBUTE_INTERFACE) {
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*));
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*), "remote-class");
rc->interface_count = 1;
rc->interfaces [0] = proxy_class;
rc->proxy_class = mono_defaults.marshalbyrefobject_class;
} else {
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS);
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS, "remote-class");
rc->interface_count = 0;
rc->proxy_class = proxy_class;
}
@@ -2582,7 +2582,7 @@ clone_remote_class (MonoDomain *domain, MonoRemoteClass* remote_class, MonoClass
if (extra_class->flags & TYPE_ATTRIBUTE_INTERFACE) {
int i,j;
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*) * (remote_class->interface_count + 1));
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*) * (remote_class->interface_count + 1), "remote-class");
rc->proxy_class = remote_class->proxy_class;
rc->interface_count = remote_class->interface_count + 1;
@@ -2597,7 +2597,7 @@ clone_remote_class (MonoDomain *domain, MonoRemoteClass* remote_class, MonoClass
rc->interfaces [j] = extra_class;
} else {
// Replace the old class. The interface array is the same
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*) * remote_class->interface_count);
rc = mono_domain_alloc (domain, MONO_SIZEOF_REMOTE_CLASS + sizeof(MonoClass*) * remote_class->interface_count, "remote-class");
rc->proxy_class = extra_class;
rc->interface_count = remote_class->interface_count;
if (rc->interface_count > 0)
@@ -5674,9 +5674,9 @@ mono_string_to_utf8_ignore (MonoString *s)
* Same as mono_string_to_utf8_ignore, but allocate the string from the image mempool.
*/
char *
mono_string_to_utf8_image_ignore (MonoImage *image, MonoString *s)
mono_string_to_utf8_image_ignore (MonoImage *image, MonoString *s, const char *what)
{
return mono_string_to_utf8_internal (NULL, image, s, TRUE, NULL);
return mono_string_to_utf8_internal (NULL, image, s, TRUE, what, NULL);
}
/**
@@ -5688,7 +5688,7 @@ mono_string_to_utf8_image_ignore (MonoImage *image, MonoString *s)
char *
mono_string_to_utf8_mp_ignore (MonoMemPool *mp, MonoString *s)
{
return mono_string_to_utf8_internal (mp, NULL, s, TRUE, NULL);
return mono_string_to_utf8_internal (mp, NULL, s, TRUE, NULL, NULL);
}
@@ -5801,7 +5801,7 @@ mono_string_from_utf32 (mono_unichar4 *data)
}
static char *
mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s, gboolean ignore_error, MonoError *error)
mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s, gboolean ignore_error, const char *what, MonoError *error)
{
char *r;
char *mp_s;
@@ -5822,7 +5822,7 @@ mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s,
if (mp)
mp_s = mono_mempool_alloc (mp, len);
else
mp_s = mono_image_alloc (image, len);
mp_s = mono_image_alloc (image, len, what);
memcpy (mp_s, r, len);
@@ -5840,7 +5840,7 @@ mono_string_to_utf8_internal (MonoMemPool *mp, MonoImage *image, MonoString *s,
char *
mono_string_to_utf8_image (MonoImage *image, MonoString *s, MonoError *error)
{
return mono_string_to_utf8_internal (NULL, image, s, FALSE, error);
return mono_string_to_utf8_internal (NULL, image, s, FALSE, NULL, error);
}
/**
@@ -5852,7 +5852,7 @@ mono_string_to_utf8_image (MonoImage *image, MonoString *s, MonoError *error)
char *
mono_string_to_utf8_mp (MonoMemPool *mp, MonoString *s, MonoError *error)
{
return mono_string_to_utf8_internal (mp, NULL, s, FALSE, error);
return mono_string_to_utf8_internal (mp, NULL, s, FALSE, NULL, error);
}
+60 -60
View File
@@ -278,10 +278,10 @@ sigbuffer_free (SigBuffer *buf)
* from the C heap.
*/
static gpointer
image_g_malloc (MonoImage *image, guint size)
image_g_malloc (MonoImage *image, guint size, const char *what)
{
if (image)
return mono_image_alloc (image, size);
return mono_image_alloc (image, size, what);
else
return g_malloc (size);
}
@@ -294,30 +294,30 @@ image_g_malloc (MonoImage *image, guint size)
* from the C heap.
*/
static gpointer
image_g_malloc0 (MonoImage *image, guint size)
image_g_malloc0 (MonoImage *image, guint size, const char *what)
{
if (image)
return mono_image_alloc0 (image, size);
return mono_image_alloc0 (image, size, what);
else
return g_malloc0 (size);
}
#ifndef DISABLE_REFLECTION_EMIT
static char*
image_strdup (MonoImage *image, const char *s)
image_strdup (MonoImage *image, const char *s, const char *what)
{
if (image)
return mono_image_strdup (image, s);
return mono_image_strdup (image, s, what);
else
return g_strdup (s);
}
#endif
#define image_g_new(image,struct_type, n_structs) \
((struct_type *) image_g_malloc (image, ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
#define image_g_new(image,struct_type, n_structs,what) \
((struct_type *) image_g_malloc (image, ((gsize) sizeof (struct_type)) * ((gsize) (n_structs)), what))
#define image_g_new0(image,struct_type, n_structs) \
((struct_type *) image_g_malloc0 (image, ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
#define image_g_new0(image,struct_type, n_structs,what) \
((struct_type *) image_g_malloc0 (image, ((gsize) sizeof (struct_type)) * ((gsize) (n_structs)), what))
static void
@@ -949,7 +949,7 @@ method_encode_clauses (MonoImage *image, MonoDynamicImage *assembly, MonoReflect
guint32 finally_start;
int i, j, clause_index;;
clauses = image_g_new0 (image, MonoExceptionClause, num_clauses);
clauses = image_g_new0 (image, MonoExceptionClause, num_clauses, "sre-exception-clauses");
clause_index = 0;
for (i = mono_array_length (ilgen->ex_handlers) - 1; i >= 0; --i) {
@@ -1218,7 +1218,7 @@ mono_custom_attrs_from_builders (MonoImage *alloc_img, MonoImage *image, MonoArr
}
count -= not_visible;
ainfo = image_g_malloc0 (alloc_img, MONO_SIZEOF_CUSTOM_ATTR_INFO + sizeof (MonoCustomAttrEntry) * count);
ainfo = image_g_malloc0 (alloc_img, MONO_SIZEOF_CUSTOM_ATTR_INFO + sizeof (MonoCustomAttrEntry) * count, "sre-custom-attribure-info");
ainfo->image = image;
ainfo->num_attrs = count;
@@ -1227,7 +1227,7 @@ mono_custom_attrs_from_builders (MonoImage *alloc_img, MonoImage *image, MonoArr
for (i = 0; i < count; ++i) {
cattr = (MonoReflectionCustomAttr*)mono_array_get (cattrs, gpointer, i);
if (custom_attr_visible (image, cattr)) {
unsigned char *saved = mono_image_alloc (image, mono_array_length (cattr->data));
unsigned char *saved = mono_image_alloc (image, mono_array_length (cattr->data), "sre-custom-attr");
memcpy (saved, mono_array_addr (cattr->data, char, 0), mono_array_length (cattr->data));
ainfo->attrs [index].ctor = cattr->ctor->method;
ainfo->attrs [index].data = saved;
@@ -9357,7 +9357,7 @@ parameters_to_signature (MonoImage *image, MonoArray *parameters) {
count = parameters? mono_array_length (parameters): 0;
sig = image_g_malloc0 (image, MONO_SIZEOF_METHOD_SIGNATURE + sizeof (MonoType*) * count);
sig = image_g_malloc0 (image, MONO_SIZEOF_METHOD_SIGNATURE + sizeof (MonoType*) * count, "sre-signature");
sig->param_count = count;
sig->sentinelpos = -1; /* FIXME */
for (i = 0; i < count; ++i)
@@ -9948,7 +9948,7 @@ mono_reflection_setup_internal_class (MonoReflectionTypeBuilder *tb)
return;
}
klass = mono_image_alloc0 (&tb->module->dynamic_image->image, sizeof (MonoClass));
klass = mono_image_alloc0 (&tb->module->dynamic_image->image, sizeof (MonoClass), "sre-class");
klass->image = &tb->module->dynamic_image->image;
@@ -10068,11 +10068,11 @@ mono_reflection_create_generic_class (MonoReflectionTypeBuilder *tb)
g_assert (tb->generic_container && (tb->generic_container->owner.klass == klass));
klass->generic_container = mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer));
klass->generic_container = mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer), "sre-generic-container");
klass->generic_container->owner.klass = klass;
klass->generic_container->type_argc = count;
klass->generic_container->type_params = mono_image_alloc0 (klass->image, sizeof (MonoGenericParamFull) * count);
klass->generic_container->type_params = mono_image_alloc0 (klass->image, sizeof (MonoGenericParamFull) * count, "sre-generic-container-params");
klass->is_generic = 1;
@@ -10149,7 +10149,7 @@ mono_marshal_spec_from_builder (MonoImage *image, MonoAssembly *assembly,
{
MonoMarshalSpec *res;
res = image_g_new0 (image, MonoMarshalSpec, 1);
res = image_g_new0 (image, MonoMarshalSpec, 1, "sre-marshal-spec");
res->native = minfo->type;
switch (minfo->type) {
@@ -10268,9 +10268,9 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
if ((rmb->attrs & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(rmb->iattrs & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
m = (MonoMethod *)image_g_new0 (image, MonoMethodPInvoke, 1);
m = (MonoMethod *)image_g_new0 (image, MonoMethodPInvoke, 1, "sre-method-pinvoke");
else
m = (MonoMethod *)image_g_new0 (image, MonoMethodWrapper, 1);
m = (MonoMethod *)image_g_new0 (image, MonoMethodWrapper, 1, "sre-method-wrapper");
wrapperm = (MonoMethodWrapper*)m;
@@ -10278,7 +10278,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
m->slot = -1;
m->flags = rmb->attrs;
m->iflags = rmb->iattrs;
m->name = mono_string_to_utf8_image_ignore (image, rmb->name);
m->name = mono_string_to_utf8_image_ignore (image, rmb->name, "sre-method-name");
m->klass = klass;
m->signature = sig;
m->sre_method = TRUE;
@@ -10294,9 +10294,9 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
} else if (m->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
m->signature->pinvoke = 1;
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1);
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1, "sre-method-aux");
method_aux->dllentry = rmb->dllentry ? mono_string_to_utf8_image (image, rmb->dllentry, &error) : image_strdup (image, m->name);
method_aux->dllentry = rmb->dllentry ? mono_string_to_utf8_image (image, rmb->dllentry, &error) : image_strdup (image, m->name, "sre-dllentry");
g_assert (mono_error_ok (&error));
method_aux->dll = mono_string_to_utf8_image (image, rmb->dll, &error);
g_assert (mono_error_ok (&error));
@@ -10339,9 +10339,9 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
}
}
header = image_g_malloc0 (image, MONO_SIZEOF_METHOD_HEADER + num_locals * sizeof (MonoType*));
header = image_g_malloc0 (image, MONO_SIZEOF_METHOD_HEADER + num_locals * sizeof (MonoType*), "sre-method-header");
header->code_size = code_size;
header->code = image_g_malloc (image, code_size);
header->code = image_g_malloc (image, code_size, "sre-method-code");
memcpy ((char*)header->code, code, code_size);
header->max_stack = max_stack;
header->init_locals = rmb->init_locals;
@@ -10351,7 +10351,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
MonoReflectionLocalBuilder *lb =
mono_array_get (rmb->ilgen->locals, MonoReflectionLocalBuilder*, i);
header->locals [i] = image_g_new0 (image, MonoType, 1);
header->locals [i] = image_g_new0 (image, MonoType, 1, "sre-localvar");
memcpy (header->locals [i], mono_reflection_type_get_handle ((MonoReflectionType*)lb->type), MONO_SIZEOF_TYPE);
}
@@ -10371,7 +10371,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
g_assert (container);
container->type_argc = count;
container->type_params = image_g_new0 (image, MonoGenericParamFull, count);
container->type_params = image_g_new0 (image, MonoGenericParamFull, count, "sre-generic-container-params");
container->owner.method = m;
m->is_generic = TRUE;
@@ -10415,7 +10415,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
m->wrapper_type = MONO_WRAPPER_DYNAMIC_METHOD;
mw->method_data = data = image_g_new (image, gpointer, rmb->nrefs + 1);
mw->method_data = data = image_g_new (image, gpointer, rmb->nrefs + 1, "sre-method-data");
data [0] = GUINT_TO_POINTER (rmb->nrefs);
for (i = 0; i < rmb->nrefs; ++i)
data [i + 1] = rmb->refs [i];
@@ -10426,8 +10426,8 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
/* Parameter info */
if (rmb->pinfo) {
if (!method_aux)
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1);
method_aux->param_names = image_g_new0 (image, char *, mono_method_signature (m)->param_count + 1);
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1, "sre-method-aux");
method_aux->param_names = image_g_new0 (image, char *, mono_method_signature (m)->param_count + 1, "sre-method-param-name-list");
for (i = 0; i <= m->signature->param_count; ++i) {
MonoReflectionParamBuilder *pb;
if ((pb = mono_array_get (rmb->pinfo, MonoReflectionParamBuilder*, i))) {
@@ -10444,8 +10444,8 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
const char *p2;
if (!method_aux->param_defaults) {
method_aux->param_defaults = image_g_new0 (image, guint8*, m->signature->param_count + 1);
method_aux->param_default_types = image_g_new0 (image, guint32, m->signature->param_count + 1);
method_aux->param_defaults = image_g_new0 (image, guint8*, m->signature->param_count + 1, "sre-method-param-default-value-list");
method_aux->param_default_types = image_g_new0 (image, guint32, m->signature->param_count + 1, "sre-method-param-default-type-list");
}
assembly = (MonoDynamicImage*)klass->image;
idx = encode_constant (assembly, pb->def_value, &def_type);
@@ -10453,7 +10453,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
p = assembly->blob.data + idx;
len = mono_metadata_decode_blob_size (p, &p2);
len += p2 - p;
method_aux->param_defaults [i] = image_g_malloc (image, len);
method_aux->param_defaults [i] = image_g_malloc (image, len, "sre-method-param-default-value");
method_aux->param_default_types [i] = def_type;
memcpy ((gpointer)method_aux->param_defaults [i], p, len);
}
@@ -10464,7 +10464,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
}
if (pb->cattrs) {
if (!method_aux->param_cattr)
method_aux->param_cattr = image_g_new0 (image, MonoCustomAttrInfo*, m->signature->param_count + 1);
method_aux->param_cattr = image_g_new0 (image, MonoCustomAttrInfo*, m->signature->param_count + 1, "sre-method-aux-custom-attribute");
method_aux->param_cattr [i] = mono_custom_attrs_from_builders (image, klass->image, pb->cattrs);
}
}
@@ -10479,7 +10479,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
if ((pb = mono_array_get (rmb->pinfo, MonoReflectionParamBuilder*, i))) {
if (pb->marshal_info) {
if (specs == NULL)
specs = image_g_new0 (image, MonoMarshalSpec*, sig->param_count + 1);
specs = image_g_new0 (image, MonoMarshalSpec*, sig->param_count + 1, "sre-marshal-space-list");
specs [pb->position] =
mono_marshal_spec_from_builder (image, klass->image->assembly, pb->marshal_info);
}
@@ -10487,7 +10487,7 @@ reflection_methodbuilder_to_mono_method (MonoClass *klass,
}
if (specs != NULL) {
if (!method_aux)
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1);
method_aux = image_g_new0 (image, MonoReflectionMethodAux, 1, "sre-method-aux");
method_aux->param_marshall = specs;
}
@@ -10827,9 +10827,9 @@ mono_reflection_generic_class_initialize (MonoReflectionGenericClass *type, Mono
dgclass->count_fields = fields ? mono_array_length (fields) : 0;
dgclass->fields = mono_image_set_new0 (gclass->owner, MonoClassField, dgclass->count_fields);
dgclass->field_objects = mono_image_set_new0 (gclass->owner, MonoObject*, dgclass->count_fields);
dgclass->field_generic_types = mono_image_set_new0 (gclass->owner, MonoType*, dgclass->count_fields);
dgclass->fields = mono_image_set_new0 (gclass->owner, MonoClassField, dgclass->count_fields, "sre-generic-class-field-list");
dgclass->field_objects = mono_image_set_new0 (gclass->owner, MonoObject*, dgclass->count_fields, "sre-generic-class-field-object-list");
dgclass->field_generic_types = mono_image_set_new0 (gclass->owner, MonoType*, dgclass->count_fields, "sre-generic-class-field-generic-type-list");
for (i = 0; i < dgclass->count_fields; i++) {
MonoObject *obj = mono_array_get (fields, gpointer, i);
@@ -10855,7 +10855,7 @@ mono_reflection_generic_class_initialize (MonoReflectionGenericClass *type, Mono
if (inflated_field) {
g_free (inflated_field);
} else {
dgclass->fields [i].name = mono_image_set_strdup (gclass->owner, dgclass->fields [i].name);
dgclass->fields [i].name = mono_image_set_strdup (gclass->owner, dgclass->fields [i].name, "sre-generic-class-field-name");
}
}
@@ -10915,7 +10915,7 @@ fix_partial_generic_class (MonoClass *klass)
if (klass->method.count != gklass->method.count) {
klass->method.count = gklass->method.count;
klass->methods = mono_image_alloc (klass->image, sizeof (MonoMethod*) * (klass->method.count + 1));
klass->methods = mono_image_alloc (klass->image, sizeof (MonoMethod*) * (klass->method.count + 1), "sre-class-method-list");
for (i = 0; i < klass->method.count; i++) {
klass->methods [i] = mono_class_inflate_generic_method_full (
@@ -10925,7 +10925,7 @@ fix_partial_generic_class (MonoClass *klass)
if (klass->interface_count && klass->interface_count != gklass->interface_count) {
klass->interface_count = gklass->interface_count;
klass->interfaces = mono_image_alloc (klass->image, sizeof (MonoClass*) * gklass->interface_count);
klass->interfaces = mono_image_alloc (klass->image, sizeof (MonoClass*) * gklass->interface_count, "sre-class-inferface-list");
klass->interfaces_packed = NULL; /*make setup_interface_offsets happy*/
for (i = 0; i < gklass->interface_count; ++i) {
@@ -10940,7 +10940,7 @@ fix_partial_generic_class (MonoClass *klass)
if (klass->field.count != gklass->field.count) {
klass->field.count = gklass->field.count;
klass->fields = image_g_new0 (klass->image, MonoClassField, klass->field.count);
klass->fields = image_g_new0 (klass->image, MonoClassField, klass->field.count, "sre-class-field-list");
for (i = 0; i < klass->field.count; i++) {
klass->fields [i] = gklass->fields [i];
@@ -10980,7 +10980,7 @@ ensure_runtime_vtable (MonoClass *klass)
num = tb->ctors? mono_array_length (tb->ctors): 0;
num += tb->num_methods;
klass->method.count = num;
klass->methods = mono_image_alloc (klass->image, sizeof (MonoMethod*) * num);
klass->methods = mono_image_alloc (klass->image, sizeof (MonoMethod*) * num, "sre-class-method-list");
num = tb->ctors? mono_array_length (tb->ctors): 0;
for (i = 0; i < num; ++i)
klass->methods [i] = ctorbuilder_to_mono_method (klass, mono_array_get (tb->ctors, MonoReflectionCtorBuilder*, i));
@@ -10991,7 +10991,7 @@ ensure_runtime_vtable (MonoClass *klass)
if (tb->interfaces) {
klass->interface_count = mono_array_length (tb->interfaces);
klass->interfaces = mono_image_alloc (klass->image, sizeof (MonoClass*) * klass->interface_count);
klass->interfaces = mono_image_alloc (klass->image, sizeof (MonoClass*) * klass->interface_count, "sre-class-interface-list");
for (i = 0; i < klass->interface_count; ++i) {
MonoType *iface = mono_type_array_get_and_resolve (tb->interfaces, i);
klass->interfaces [i] = mono_class_from_mono_type (iface);
@@ -11152,9 +11152,9 @@ typebuilder_setup_fields (MonoClass *klass, MonoError *error)
return;
}
klass->fields = image_g_new0 (image, MonoClassField, klass->field.count);
klass->fields = image_g_new0 (image, MonoClassField, klass->field.count, "sre-class-field-list");
mono_class_alloc_ext (klass);
klass->ext->field_def_values = image_g_new0 (image, MonoFieldDefaultValue, klass->field.count);
klass->ext->field_def_values = image_g_new0 (image, MonoFieldDefaultValue, klass->field.count, "sre-class-field-def-values");
/*
This is, guess what, a hack.
The issue is that the runtime doesn't know how to setup the fields of a typebuider and crash.
@@ -11181,7 +11181,7 @@ typebuilder_setup_fields (MonoClass *klass, MonoError *error)
if ((fb->attrs & FIELD_ATTRIBUTE_HAS_FIELD_RVA) && (rva_data = fb->rva_data)) {
char *base = mono_array_addr (rva_data, char, 0);
size_t size = mono_array_length (rva_data);
char *data = mono_image_alloc (klass->image, size);
char *data = mono_image_alloc (klass->image, size, "sre-class-rva-data");
memcpy (data, base, size);
klass->ext->field_def_values [i].data = data;
}
@@ -11202,7 +11202,7 @@ typebuilder_setup_fields (MonoClass *klass, MonoError *error)
p = assembly->blob.data + idx;
len = mono_metadata_decode_blob_size (p, &p2);
len += p2 - p;
klass->ext->field_def_values [i].data = mono_image_alloc (image, len);
klass->ext->field_def_values [i].data = mono_image_alloc (image, len, "sre-class-field-def-values");
memcpy ((gpointer)klass->ext->field_def_values [i].data, p, len);
}
}
@@ -11223,12 +11223,12 @@ typebuilder_setup_properties (MonoClass *klass, MonoError *error)
mono_error_init (error);
if (!klass->ext)
klass->ext = image_g_new0 (image, MonoClassExt, 1);
klass->ext = image_g_new0 (image, MonoClassExt, 1, "sre-class-ext");
klass->ext->property.count = tb->properties ? mono_array_length (tb->properties) : 0;
klass->ext->property.first = 0;
properties = image_g_new0 (image, MonoProperty, klass->ext->property.count);
properties = image_g_new0 (image, MonoProperty, klass->ext->property.count, "sre-class-property-list");
klass->ext->properties = properties;
for (i = 0; i < klass->ext->property.count; ++i) {
pb = mono_array_get (tb->properties, MonoReflectionPropertyBuilder*, i);
@@ -11248,14 +11248,14 @@ typebuilder_setup_properties (MonoClass *klass, MonoError *error)
const char *p, *p2;
MonoDynamicImage *assembly = (MonoDynamicImage*)klass->image;
if (!klass->ext->prop_def_values)
klass->ext->prop_def_values = image_g_new0 (image, MonoFieldDefaultValue, klass->ext->property.count);
klass->ext->prop_def_values = image_g_new0 (image, MonoFieldDefaultValue, klass->ext->property.count, "sre-class-property-def-value-list");
properties [i].attrs |= PROPERTY_ATTRIBUTE_HAS_DEFAULT;
idx = encode_constant (assembly, pb->def_value, &klass->ext->prop_def_values [i].def_type);
/* Copy the data from the blob since it might get realloc-ed */
p = assembly->blob.data + idx;
len = mono_metadata_decode_blob_size (p, &p2);
len += p2 - p;
klass->ext->prop_def_values [i].data = mono_image_alloc (image, len);
klass->ext->prop_def_values [i].data = mono_image_alloc (image, len, "sre-class-property-def-value");
memcpy ((gpointer)klass->ext->prop_def_values [i].data, p, len);
}
}
@@ -11307,12 +11307,12 @@ typebuilder_setup_events (MonoClass *klass, MonoError *error)
mono_error_init (error);
if (!klass->ext)
klass->ext = image_g_new0 (image, MonoClassExt, 1);
klass->ext = image_g_new0 (image, MonoClassExt, 1, "sre-class-ext");
klass->ext->event.count = tb->events ? mono_array_length (tb->events) : 0;
klass->ext->event.first = 0;
events = image_g_new0 (image, MonoEvent, klass->ext->event.count);
events = image_g_new0 (image, MonoEvent, klass->ext->event.count, "sre-class-event-list");
klass->ext->events = events;
for (i = 0; i < klass->ext->event.count; ++i) {
eb = mono_array_get (tb->events, MonoReflectionEventBuilder*, i);
@@ -11331,7 +11331,7 @@ typebuilder_setup_events (MonoClass *klass, MonoError *error)
#ifndef MONO_SMALL_CONFIG
if (eb->other_methods) {
int j;
events [i].other = image_g_new0 (image, MonoMethod*, mono_array_length (eb->other_methods) + 1);
events [i].other = image_g_new0 (image, MonoMethod*, mono_array_length (eb->other_methods) + 1, "sre-class-event-other-list");
for (j = 0; j < mono_array_length (eb->other_methods); ++j) {
MonoReflectionMethodBuilder *mb =
mono_array_get (eb->other_methods,
@@ -11482,7 +11482,7 @@ mono_reflection_create_runtime_class (MonoReflectionTypeBuilder *tb)
for (i = 0; i < mono_array_length (tb->subtypes); ++i) {
MonoReflectionTypeBuilder *subtb = mono_array_get (tb->subtypes, MonoReflectionTypeBuilder*, i);
mono_class_alloc_ext (klass);
klass->ext->nested_classes = g_list_prepend_image (klass->image, klass->ext->nested_classes, mono_class_from_mono_type (mono_reflection_type_get_handle ((MonoReflectionType*)subtb)));
klass->ext->nested_classes = g_list_prepend_image (klass->image, klass->ext->nested_classes, mono_class_from_mono_type (mono_reflection_type_get_handle ((MonoReflectionType*)subtb)), "sre-class-nested-classes");
}
}
@@ -11562,7 +11562,7 @@ mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam
image = &gparam->tbuilder->module->dynamic_image->image;
param = mono_image_new0 (image, MonoGenericParamFull, 1);
param = mono_image_new0 (image, MonoGenericParamFull, 1, "sre-generic-param");
param->info.name = mono_string_to_utf8_image (image, gparam->name, &error);
g_assert (mono_error_ok (&error));
@@ -11572,7 +11572,7 @@ mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam
if (!gparam->mbuilder->generic_container) {
MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *)gparam->mbuilder->type;
MonoClass *klass = mono_class_from_mono_type (mono_reflection_type_get_handle ((MonoReflectionType*)tb));
gparam->mbuilder->generic_container = mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer));
gparam->mbuilder->generic_container = mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer), "sre-generic-param-mcontainer");
gparam->mbuilder->generic_container->is_method = TRUE;
/*
* Cannot set owner.method, since the MonoMethod is not created yet.
@@ -11584,7 +11584,7 @@ mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam
} else if (gparam->tbuilder) {
if (!gparam->tbuilder->generic_container) {
MonoClass *klass = mono_class_from_mono_type (mono_reflection_type_get_handle ((MonoReflectionType*)gparam->tbuilder));
gparam->tbuilder->generic_container = mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer));
gparam->tbuilder->generic_container = mono_image_alloc0 (klass->image, sizeof (MonoGenericContainer), "sre-generic-param-tcontainer");
gparam->tbuilder->generic_container->owner.klass = klass;
}
param->param.owner = gparam->tbuilder->generic_container;
+2 -2
View File
@@ -836,7 +836,7 @@ create_allocator (int atype)
mono_mb_patch_short_branch (mb, pos);
clause = mono_image_alloc0 (mono_defaults.corlib, sizeof (MonoExceptionClause));
clause = mono_image_alloc0 (mono_defaults.corlib, sizeof (MonoExceptionClause), "sgen-exception-clause");
clause->try_offset = mono_mb_get_label (mb);
/* vtable->klass->sizes.element_size */
@@ -1048,7 +1048,7 @@ create_allocator (int atype)
mono_mb_free (mb);
mono_method_get_header (res)->init_locals = FALSE;
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (AllocatorWrapperInfo));
info = mono_image_alloc0 (mono_defaults.corlib, sizeof (AllocatorWrapperInfo), "sgen-wrapper-info");
info->gc_name = "sgen";
info->alloc_type = atype;
mono_marshal_set_wrapper_info (res, info);
+6 -6
View 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;
+1 -1
View File
@@ -129,7 +129,7 @@ sgen_alloc_internal_dynamic (size_t size, int type, gboolean assert_on_failure)
void *p;
if (size > allocator_sizes [NUM_ALLOCATORS - 1]) {
p = sgen_alloc_os_memory (size, SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE, NULL);
p = sgen_alloc_os_memory (size, SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE, "huge internal alloc");
if (!p)
sgen_assert_memory_alloc (NULL, size, description_for_type (type));
} else {
+3 -3
View File
@@ -229,7 +229,7 @@ get_los_section_memory (size_t size)
if (!sgen_memgov_try_alloc_space (LOS_SECTION_SIZE, SPACE_LOS))
return NULL;
section = sgen_alloc_os_memory_aligned (LOS_SECTION_SIZE, LOS_SECTION_SIZE, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, NULL);
section = sgen_alloc_os_memory_aligned (LOS_SECTION_SIZE, LOS_SECTION_SIZE, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, "LOS section");
if (!section)
return NULL;
@@ -347,7 +347,7 @@ sgen_los_alloc_large_inner (MonoVTable *vtable, size_t size)
#ifdef LOS_DUMMY
if (!los_segment)
los_segment = sgen_alloc_os_memory (LOS_SEGMENT_SIZE, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, NULL);
los_segment = sgen_alloc_os_memory (LOS_SEGMENT_SIZE, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, "LOS segment");
los_segment_index = ALIGN_UP (los_segment_index);
obj = (LOSObject*)(los_segment + los_segment_index);
@@ -368,7 +368,7 @@ sgen_los_alloc_large_inner (MonoVTable *vtable, size_t size)
alloc_size += pagesize - 1;
alloc_size &= ~(pagesize - 1);
if (sgen_memgov_try_alloc_space (alloc_size, SPACE_LOS)) {
obj = sgen_alloc_os_memory (alloc_size, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, NULL);
obj = sgen_alloc_os_memory (alloc_size, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, "LOS object");
}
} else {
obj = get_los_section_memory (size + sizeof (LOSObject));
+1 -2
View File
@@ -378,8 +378,7 @@ ms_get_empty_block (void)
*/
int alloc_num = MS_BLOCK_ALLOC_NUM;
for (;;) {
p = sgen_alloc_os_memory_aligned (MS_BLOCK_SIZE * alloc_num, MS_BLOCK_SIZE, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE,
alloc_num == 1 ? "major heap section" : NULL);
p = sgen_alloc_os_memory_aligned (MS_BLOCK_SIZE * alloc_num, MS_BLOCK_SIZE, SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE, "major heap section");
if (p)
break;
alloc_num >>= 1;
+2 -2
View File
@@ -305,7 +305,7 @@ sgen_alloc_os_memory (size_t size, SgenAllocFlags flags, const char *assert_desc
g_assert (!(flags & ~(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE)));
ptr = mono_valloc (0, size, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE));
ptr = mono_valloc (0, size, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE), assert_description);
sgen_assert_memory_alloc (ptr, size, assert_description);
if (ptr) {
SGEN_ATOMIC_ADD_P (total_alloc, size);
@@ -323,7 +323,7 @@ sgen_alloc_os_memory_aligned (size_t size, mword alignment, SgenAllocFlags flags
g_assert (!(flags & ~(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE)));
ptr = mono_valloc_aligned (size, alignment, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE));
ptr = mono_valloc_aligned (size, alignment, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE), assert_description);
sgen_assert_memory_alloc (ptr, size, assert_description);
if (ptr) {
SGEN_ATOMIC_ADD_P (total_alloc, size);
+18 -63
View File
@@ -25,10 +25,9 @@
#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;
+1 -1
View 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;
+88
View File
@@ -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
+34
View File
@@ -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
+1 -1
View 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);
}
+111 -69
View 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,44 @@ 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, ...)
{
char *msg;
va_list args;
va_start (args, format);
if (vasprintf (&msg, format, args) < 0)
return;
va_end (args);
if (acfg->logfile)
fprintf (acfg->logfile, "%s", msg);
else
printf ("%s", msg);
free (msg);
}
static void
aot_printerrf (MonoAotCompile *acfg, const gchar *format, ...)
{
char *msg;
va_list args;
va_start (args, format);
if (vasprintf (&msg, format, args) < 0)
return;
va_end (args);
if (acfg->logfile)
fprintf (acfg->logfile, "%s", msg);
else
fprintf (stderr, "%s", msg);
free (msg);
}
/* Wrappers around the image writer functions */
static inline void
@@ -3113,7 +3153,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 +3969,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 +4019,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 +5373,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 +5472,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 +6391,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 +7056,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 +7136,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 +7164,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 +8412,7 @@ emit_dwarf_info (MonoAotCompile *acfg)
#endif
}
static void
static gboolean
collect_methods (MonoAotCompile *acfg)
{
int mindex, i;
@@ -8395,9 +8426,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 +8492,7 @@ collect_methods (MonoAotCompile *acfg)
if (acfg->aot_opts.full_aot)
add_wrappers (acfg);
return TRUE;
}
static void
@@ -8573,9 +8605,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 +8620,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 +8630,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 +8648,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 +8670,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 +8684,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 +8698,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 +8803,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 +8819,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 +8859,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 +8871,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 +8882,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 +8929,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 +8983,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 +8998,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 +9018,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 +9042,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 +9079,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 +9167,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 +9177,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 +9201,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 +9217,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);
+278 -115
View File
@@ -55,12 +55,17 @@
#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;
}
@@ -496,7 +497,7 @@ decode_klass_ref (MonoAotModule *module, guint8 *buf, guint8 **endbuf)
g_assert (serial == 0);
} else {
/* Anonymous */
MonoGenericParam *par = (MonoGenericParam*)mono_image_alloc0 (module->assembly->image, sizeof (MonoGenericParamFull));
MonoGenericParam *par = (MonoGenericParam*)mono_image_alloc0 (module->assembly->image, sizeof (MonoGenericParamFull), "aot-runtime-generic-param");
par->num = num;
par->serial = serial;
// FIXME:
@@ -1272,132 +1273,281 @@ 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)
*l = g_slist_prepend (*l, ass);
}
#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);
}
for (i = 0; i < s->len; ++i) {
if (!isalnum (s->str [i]) && s->str [i] != '-')
s->str [i] = '_';
}
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;
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;
}
}
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;
}
}
g_free (tmp);
enable_aot_cache = TRUE;
in_process = TRUE;
}
/*
* load_aot_module_from_cache:
* aot_cache_load_module:
*
* Experimental code to AOT compile loaded assemblies on demand.
*
* 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 ();
home = g_get_home_dir ();
enabled = FALSE;
if (config->apps) {
MonoDomain *domain = mono_domain_get ();
MonoAssembly *entry_assembly = domain->entry_assembly;
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);
for (l = config->apps; l; l = l->next) {
char *n = l->data;
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);
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_AOT, "AOT: not found.");
aot_options = g_strdup_printf ("outfile=%s", fname);
if (!strcmp (assembly->aname.name, "mscorlib") && !mono_defaults.corlib)
/* Can't AOT this during startup */
return NULL;
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 ++;
res = g_spawn_command_line_sync (cmd, &out, &err, &exit_status, NULL);
/* Check for previous failure */
failure_fname = g_strdup_printf ("%s.failure", fname);
failure_file = fopen (failure_fname, "r");
g_free (failure_fname);
if (!failure_file) {
mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: assembly '%s' previously failed to compile '%s' ('%s')... ", assembly->image->name, failure_fname);
return NULL;
} else {
fclose (failure_file);
}
#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 {
mono_trace (G_LOG_LEVEL_MESSAGE, MONO_TRACE_AOT, "AOT: compiling assembly '%s'... ", assembly->image->name);
/*
* 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)
{
@@ -1589,6 +1739,10 @@ load_aot_module (MonoAssembly *assembly, gpointer user_data)
if (mono_security_cas_enabled ())
return;
if (enable_aot_cache && !strcmp (assembly->aname.name, "mscorlib") && !mono_defaults.corlib && !mono_aot_only)
/* Loaded later from mono_aot_get_method () */
return;
mono_aot_lock ();
if (static_aot_modules)
info = g_hash_table_lookup (static_aot_modules, assembly->aname.name);
@@ -1596,16 +1750,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 +1807,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 +2028,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 +2098,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
@@ -2361,7 +2515,7 @@ alloc0_jit_info_data (MonoDomain *domain, int size, gboolean async_context)
res = mono_domain_alloc0_lock_free (domain, size);
InterlockedExchangeAdd (&async_jit_info_size, size);
} else {
res = mono_domain_alloc0 (domain, size);
res = mono_domain_alloc0 (domain, size, "jit-info-data");
}
return res;
}
@@ -2537,6 +2691,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 +2851,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;
}
@@ -3056,7 +3210,7 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
case MONO_PATCH_INFO_SWITCH:
ji->data.table = mono_mempool_alloc0 (mp, sizeof (MonoJumpInfoBBTable));
ji->data.table->table_size = decode_value (p, &p);
table = mono_domain_alloc (mono_domain_get (), sizeof (gpointer) * ji->data.table->table_size);
table = mono_domain_alloc (mono_domain_get (), sizeof (gpointer) * ji->data.table->table_size, "aot-jump-table");
ji->data.table->table = (MonoBasicBlock**)table;
for (i = 0; i < ji->data.table->table_size; i++)
table [i] = (gpointer)(gssize)decode_value (p, &p);
@@ -3064,7 +3218,7 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
case MONO_PATCH_INFO_R4: {
guint32 val;
ji->data.target = mono_domain_alloc0 (mono_domain_get (), sizeof (float));
ji->data.target = mono_domain_alloc0 (mono_domain_get (), sizeof (float), "aot-float");
val = decode_value (p, &p);
*(float*)ji->data.target = *(float*)&val;
break;
@@ -3073,7 +3227,7 @@ decode_patch (MonoAotModule *aot_module, MonoMemPool *mp, MonoJumpInfo *ji, guin
guint32 val [2];
guint64 v;
ji->data.target = mono_domain_alloc0 (mono_domain_get (), sizeof (double));
ji->data.target = mono_domain_alloc0 (mono_domain_get (), sizeof (double), "aot-double");
val [0] = decode_value (p, &p);
val [1] = decode_value (p, &p);
@@ -3324,7 +3478,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 +3597,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 +3793,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) {
load_aot_module (klass->image->assembly, NULL);
amodule = klass->image->aot_module;
}
mscorlib_aot_loaded = TRUE;
}
if (!amodule)
return NULL;
@@ -4149,7 +4312,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 */
@@ -4670,7 +4833,7 @@ mono_aot_get_lazy_fetch_trampoline (guint32 slot)
*/
if (!addr)
addr = load_function (amodule, "rgctx_fetch_trampoline_general");
info = mono_domain_alloc0 (mono_get_root_domain (), sizeof (gpointer) * 2);
info = mono_domain_alloc0 (mono_get_root_domain (), sizeof (gpointer) * 2, "aot-lazy-fetch-tramp");
info [0] = GUINT_TO_POINTER (slot);
info [1] = mono_create_specific_trampoline (GUINT_TO_POINTER (slot), MONO_TRAMPOLINE_RGCTX_LAZY_FETCH, mono_get_root_domain (), NULL);
code = mono_aot_get_static_rgctx_trampoline (info, addr);
@@ -4702,7 +4865,7 @@ mono_aot_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem
}
/* Save the entries into an array */
buf = mono_domain_alloc (domain, (real_count + 1) * 2 * sizeof (gpointer));
buf = mono_domain_alloc (domain, (real_count + 1) * 2 * sizeof (gpointer), "aot-imt-entries-array");
index = 0;
for (i = 0; i < count; ++i) {
MonoIMTCheckItem *item = imt_entries [i];
@@ -4714,7 +4877,7 @@ mono_aot_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem
buf [(index * 2)] = item->key;
if (item->has_target_code) {
gpointer *p = mono_domain_alloc (domain, sizeof (gpointer));
gpointer *p = mono_domain_alloc (domain, sizeof (gpointer), "aot-imt-entry");
*p = item->value.target_code;
buf [(index * 2) + 1] = p;
} else {
@@ -4770,7 +4933,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);
}
}
+1 -1
View 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;
}
+5 -5
View 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);
+1 -1
View 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;
+6 -6
View File
@@ -4550,7 +4550,7 @@ handle_delegate_ctor (MonoCompile *cfg, MonoClass *klass, MonoInst *target, Mono
domain_jit_info (domain)->method_code_hash = g_hash_table_new (NULL, NULL);
code_slot = g_hash_table_lookup (domain_jit_info (domain)->method_code_hash, method);
if (!code_slot) {
code_slot = mono_domain_alloc0 (domain, sizeof (gpointer));
code_slot = mono_domain_alloc0 (domain, sizeof (gpointer), "delegate-code-slot");
g_hash_table_insert (domain_jit_info (domain)->method_code_hash, method, code_slot);
}
mono_domain_unlock (domain);
@@ -7669,7 +7669,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
#endif
/* FIXME: we should really allocate this only late in the compilation process */
f = mono_domain_alloc (cfg->domain, sizeof (float));
f = mono_domain_alloc (cfg->domain, sizeof (float), "jit-ldc-float");
CHECK_OPSIZE (5);
CHECK_STACK_OVF (1);
@@ -7706,7 +7706,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
#endif
/* FIXME: we should really allocate this only late in the compilation process */
d = mono_domain_alloc (cfg->domain, sizeof (double));
d = mono_domain_alloc (cfg->domain, sizeof (double), "jit-ldc-double");
CHECK_OPSIZE (9);
CHECK_STACK_OVF (1);
@@ -9755,7 +9755,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (cfg->compile_aot)
EMIT_NEW_AOTCONST (cfg, args [2], MONO_PATCH_INFO_CASTCLASS_CACHE, NULL);
else
EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer)));
EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer), "jit-castclass-cache"));
/*The wrapper doesn't inline well so the bloat of inlining doesn't pay off.*/
@@ -9819,7 +9819,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (cfg->compile_aot)
EMIT_NEW_AOTCONST (cfg, args [2], MONO_PATCH_INFO_CASTCLASS_CACHE, NULL);
else
EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer)));
EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer), "jit-isinst-cache"));
*sp++ = mono_emit_method_call (cfg, mono_isinst, args, NULL);
ip += 5;
@@ -9891,7 +9891,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
if (cfg->compile_aot)
EMIT_NEW_AOTCONST (cfg, args [2], MONO_PATCH_INFO_CASTCLASS_CACHE, NULL);
else
EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer)));
EMIT_NEW_PCONST (cfg, args [2], mono_domain_alloc0 (cfg->domain, sizeof (gpointer), "jit-castclass-cache"));
/* The wrapper doesn't inline well so the bloat of inlining doesn't pay off. */
*sp++ = emit_castclass_with_cache (cfg, klass, args, &bblock);
+2 -2
View File
@@ -1256,8 +1256,8 @@ mono_arch_init (void)
/* amd64_alu_membase_imm_size (code, X86_CMP, AMD64_R11, 0, 0, 4); */
single_step_fault_size = 4;
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), flags);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), flags);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), flags, "sdb");
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), flags, "sdb");
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
mono_aot_register_jit_icall ("mono_amd64_throw_exception", mono_amd64_throw_exception);
+2 -2
View File
@@ -907,8 +907,8 @@ mono_arch_init (void)
#else
{
#endif
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
}
+14 -4
View File
@@ -1971,13 +1971,13 @@ mono_setup_altstack (MonoJitTlsData *tls)
if (mono_mprotect (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE)) {
/* mprotect can fail for the main thread stack */
gpointer gaddr = mono_valloc (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON|MONO_MMAP_FIXED);
gpointer gaddr = mono_valloc (tls->stack_ovf_guard_base, tls->stack_ovf_guard_size, MONO_MMAP_NONE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON|MONO_MMAP_FIXED, "altstack-guard");
g_assert (gaddr == tls->stack_ovf_guard_base);
tls->stack_ovf_valloced = TRUE;
}
/* Setup an alternate signal stack */
tls->signal_stack = mono_valloc (0, MONO_ARCH_SIGNAL_STACK_SIZE, MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON);
tls->signal_stack = mono_valloc (0, MONO_ARCH_SIGNAL_STACK_SIZE, MONO_MMAP_READ|MONO_MMAP_WRITE|MONO_MMAP_PRIVATE|MONO_MMAP_ANON, "alt-stack");
tls->signal_stack_size = MONO_ARCH_SIGNAL_STACK_SIZE;
g_assert (tls->signal_stack);
@@ -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;
}
+1 -1
View File
@@ -2370,7 +2370,7 @@ create_map (MonoCompile *cfg)
encoded_size = endbuf - buf;
alloc_size = sizeof (GCEncodedMap) + ALIGN_TO (encoded_size, map->callsite_entry_size) + (map->callsite_entry_size * map->ncallsites) + bitmaps_size;
emap = mono_domain_alloc0 (cfg->domain, alloc_size);
emap = mono_domain_alloc0 (cfg->domain, alloc_size, "gc-map");
//emap->ref_slots = map->ref_slots;
/* Encoded fixed fields */
+10 -10
View File
@@ -158,7 +158,7 @@ set_info_templates (MonoImage *image, MonoRuntimeGenericContextTemplate *templat
/* FIXME: quadratic! */
while (length < type_argc) {
template->method_templates = g_slist_append_image (image, template->method_templates, NULL);
template->method_templates = g_slist_append_image (image, template->method_templates, NULL, "gsharing-method-templates");
length++;
}
@@ -353,7 +353,7 @@ alloc_template (MonoClass *class)
num_allocted++;
num_bytes += size;
return mono_image_alloc0 (class->image, size);
return mono_image_alloc0 (class->image, size, "gsharing-alloc-template");
}
static MonoRuntimeGenericContextInfoTemplate*
@@ -374,7 +374,7 @@ alloc_oti (MonoImage *image)
num_allocted++;
num_bytes += size;
return mono_image_alloc0 (image, size);
return mono_image_alloc0 (image, size, "gsharing-alloc-oti");
}
#define MONO_RGCTX_SLOT_USED_MARKER ((gpointer)&mono_defaults.object_class->byval_arg)
@@ -577,7 +577,7 @@ inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *co
MonoDomain *domain = mono_domain_get ();
int i;
res = mono_domain_alloc0 (domain, sizeof (MonoGSharedVtMethodInfo));
res = mono_domain_alloc0 (domain, sizeof (MonoGSharedVtMethodInfo), "gsharedvt-method-info");
/*
res->nlocals = info->nlocals;
res->locals_types = g_new0 (MonoType*, info->nlocals);
@@ -585,7 +585,7 @@ inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *co
res->locals_types [i] = mono_class_inflate_generic_type (info->locals_types [i], context);
*/
res->num_entries = oinfo->num_entries;
res->entries = mono_domain_alloc0 (domain, sizeof (MonoRuntimeGenericContextInfoTemplate) * oinfo->num_entries);
res->entries = mono_domain_alloc0 (domain, sizeof (MonoRuntimeGenericContextInfoTemplate) * oinfo->num_entries, "gsharedvt-entries");
for (i = 0; i < oinfo->num_entries; ++i) {
MonoRuntimeGenericContextInfoTemplate *otemplate = &oinfo->entries [i];
MonoRuntimeGenericContextInfoTemplate *template = &res->entries [i];
@@ -605,7 +605,7 @@ inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *co
MonoJumpInfoGSharedVtCall *res;
MonoDomain *domain = mono_domain_get ();
res = mono_domain_alloc0 (domain, sizeof (MonoJumpInfoGSharedVtCall));
res = mono_domain_alloc0 (domain, sizeof (MonoJumpInfoGSharedVtCall), "gshared-vtcall");
/* Keep the original signature */
res->sig = info->sig;
@@ -938,7 +938,7 @@ class_type_info (MonoDomain *domain, MonoClass *class, MonoRgctxInfoType info_ty
}
case MONO_RGCTX_INFO_CAST_CACHE: {
/*First slot is the cache itself, the second the vtable.*/
gpointer **cache_data = mono_domain_alloc0 (domain, sizeof (gpointer) * 2);
gpointer **cache_data = mono_domain_alloc0 (domain, sizeof (gpointer) * 2, "gshared-cast-cache");
cache_data [1] = (gpointer)class;
return cache_data;
}
@@ -1187,7 +1187,7 @@ mini_get_gsharedvt_wrapper (gboolean gsharedvt_in, gpointer addr, MonoMethodSign
num_trampolines ++;
/* Cache it */
tramp_info = mono_domain_alloc0 (domain, sizeof (GSharedVtTrampInfo));
tramp_info = mono_domain_alloc0 (domain, sizeof (GSharedVtTrampInfo), "gsharedvt-wrapper");
memcpy (tramp_info, &tinfo, sizeof (GSharedVtTrampInfo));
mono_domain_lock (domain);
@@ -1263,7 +1263,7 @@ instantiate_info (MonoDomain *domain, MonoRuntimeGenericContextInfoTemplate *oti
return mono_compile_method (mono_marshal_get_remoting_invoke_with_check (data));
#endif
case MONO_RGCTX_INFO_METHOD_DELEGATE_CODE:
return mono_domain_alloc0 (domain, sizeof (gpointer));
return mono_domain_alloc0 (domain, sizeof (gpointer), "gshared-delegate-code");
case MONO_RGCTX_INFO_CLASS_FIELD:
return data;
case MONO_RGCTX_INFO_FIELD_OFFSET: {
@@ -1799,7 +1799,7 @@ alloc_rgctx_array (MonoDomain *domain, int n, gboolean is_mrgctx)
static int mrgctx_bytes_alloced = 0;
int size = mono_class_rgctx_get_array_size (n, is_mrgctx) * sizeof (gpointer);
gpointer array = mono_domain_alloc0 (domain, size);
gpointer array = mono_domain_alloc0 (domain, size, "gshared-array");
if (!inited) {
mono_counters_register ("RGCTX num arrays alloced", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &rgctx_num_alloced);
+2 -2
View File
@@ -709,8 +709,8 @@ mono_arch_init (void)
{
mono_mutex_init_recursive (&mini_arch_mutex);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
}
+2 -2
View File
@@ -622,8 +622,8 @@ mono_arch_init (void)
mono_mutex_init_recursive (&mini_arch_mutex);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
mono_aot_register_jit_icall ("mono_ppc_throw_exception", mono_ppc_throw_exception);
+2 -2
View File
@@ -1262,8 +1262,8 @@ mono_arch_init (void)
mono_mutex_init_recursive (&mini_arch_mutex);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ, "sdb");
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ, "sdb");
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
code = (guint8 *) &breakpointCode;
+5 -5
View File
@@ -116,7 +116,7 @@ mono_create_static_rgctx_trampoline (MonoMethod *m, gpointer addr)
mono_domain_lock (domain);
/* Duplicates inserted while we didn't hold the lock are OK */
info = mono_domain_alloc (domain, sizeof (RgctxTrampInfo));
info = mono_domain_alloc (domain, sizeof (RgctxTrampInfo), "rgctx-tramp-info");
info->m = m;
info->addr = addr;
g_hash_table_insert (domain_jit_info (domain)->static_rgctx_trampoline_hash, info, res);
@@ -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), "delegate-tramp-info");
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);
@@ -1444,7 +1444,7 @@ mono_create_jump_trampoline (MonoDomain *domain, MonoMethod *method, gboolean ad
code = mono_create_specific_trampoline (method, MONO_TRAMPOLINE_JUMP, mono_domain_get (), &code_size);
g_assert (code_size);
ji = mono_domain_alloc0 (domain, MONO_SIZEOF_JIT_INFO);
ji = mono_domain_alloc0 (domain, MONO_SIZEOF_JIT_INFO, "jit-info");
ji->code_start = code;
ji->code_size = code_size;
ji->d.method = method;
@@ -1507,7 +1507,7 @@ mono_create_jit_trampoline_from_token (MonoImage *image, guint32 token)
MonoDomain *domain = mono_domain_get ();
guint8 *buf, *start;
buf = start = mono_domain_alloc0 (domain, 2 * sizeof (gpointer));
buf = start = mono_domain_alloc0 (domain, 2 * sizeof (gpointer), "tramp-from-token");
*(gpointer*)(gpointer)buf = image;
buf += sizeof (gpointer);
@@ -1547,7 +1547,7 @@ mono_create_delegate_trampoline_info (MonoDomain *domain, MonoClass *klass, Mono
tramp_info->invoke_impl = mono_create_specific_trampoline (tramp_info, MONO_TRAMPOLINE_DELEGATE, domain, &code_size);
g_assert (code_size);
dpair = mono_domain_alloc0 (domain, sizeof (MonoClassMethodPair));
dpair = mono_domain_alloc0 (domain, sizeof (MonoClassMethodPair), "class-method-pair");
memcpy (dpair, &pair, sizeof (MonoClassMethodPair));
/* store trampoline address */
+2 -2
View File
@@ -760,8 +760,8 @@ mono_arch_init (void)
{
mono_mutex_init_recursive (&mini_arch_mutex);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ, "sdb");
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ|MONO_MMAP_32BIT, "sdb");
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
mono_aot_register_jit_icall ("mono_x86_throw_exception", mono_x86_throw_exception);
+21 -21
View File
@@ -3402,7 +3402,7 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
domain_jit_info (domain)->method_code_hash = g_hash_table_new (NULL, NULL);
code_slot = g_hash_table_lookup (domain_jit_info (domain)->method_code_hash, patch_info->data.method);
if (!code_slot) {
code_slot = mono_domain_alloc0 (domain, sizeof (gpointer));
code_slot = mono_domain_alloc0 (domain, sizeof (gpointer), "code-slot");
g_hash_table_insert (domain_jit_info (domain)->method_code_hash, patch_info->data.method, code_slot);
}
mono_domain_unlock (domain);
@@ -3421,7 +3421,7 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
jump_table = mono_code_manager_reserve (mono_dynamic_code_hash_lookup (domain, method)->code_mp, sizeof (gpointer) * patch_info->data.table->table_size);
} else {
if (mono_aot_only) {
jump_table = mono_domain_alloc (domain, sizeof (gpointer) * patch_info->data.table->table_size);
jump_table = mono_domain_alloc (domain, sizeof (gpointer) * patch_info->data.table->table_size, "jump-table");
} else {
jump_table = mono_domain_code_reserve (domain, sizeof (gpointer) * patch_info->data.table->table_size);
}
@@ -3680,7 +3680,7 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
break;
}
case MONO_PATCH_INFO_CASTCLASS_CACHE: {
target = mono_domain_alloc0 (domain, sizeof (gpointer));
target = mono_domain_alloc0 (domain, sizeof (gpointer), "castclass-cache");
break;
}
case MONO_PATCH_INFO_JIT_TLS_ID: {
@@ -3898,7 +3898,7 @@ mono_postprocess_patches (MonoCompile *cfg)
mono_domain_lock (domain);
jlist = g_hash_table_lookup (domain_jit_info (domain)->jump_target_hash, patch_info->data.method);
if (!jlist) {
jlist = mono_domain_alloc0 (domain, sizeof (MonoJumpList));
jlist = mono_domain_alloc0 (domain, sizeof (MonoJumpList), "jump-list");
g_hash_table_insert (domain_jit_info (domain)->jump_target_hash, patch_info->data.method, jlist);
}
jlist->list = g_slist_prepend (jlist->list, ip);
@@ -4307,7 +4307,7 @@ create_jit_info_for_trampoline (MonoMethod *wrapper, MonoTrampInfo *info)
uw_info = mono_unwind_ops_encode (info->unwind_ops, &info_len);
}
jinfo = mono_domain_alloc0 (domain, MONO_SIZEOF_JIT_INFO);
jinfo = mono_domain_alloc0 (domain, MONO_SIZEOF_JIT_INFO, "jit-info");
jinfo->d.method = wrapper;
jinfo->code_start = info->code;
jinfo->code_size = info->code_size;
@@ -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) {
@@ -4388,7 +4391,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
} else {
jinfo = mono_domain_alloc0 (cfg->domain, MONO_SIZEOF_JIT_INFO +
(num_clauses * sizeof (MonoJitExceptionInfo)) +
generic_info_size + holes_size + arch_eh_info_size + cas_size);
generic_info_size + holes_size + arch_eh_info_size + cas_size, "jit-info");
}
jinfo->d.method = cfg->method_to_register;
@@ -4413,7 +4416,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
if (cfg->method->dynamic)
gi->generic_sharing_context = g_new0 (MonoGenericSharingContext, 1);
else
gi->generic_sharing_context = mono_domain_alloc0 (cfg->domain, sizeof (MonoGenericSharingContext));
gi->generic_sharing_context = mono_domain_alloc0 (cfg->domain, sizeof (MonoGenericSharingContext), "gsharing-context");
mini_init_gsctx (cfg->method->dynamic ? NULL : cfg->domain, NULL, cfg->gsctx_context, gi->generic_sharing_context);
if ((method_to_compile->flags & METHOD_ATTRIBUTE_STATIC) ||
@@ -4445,7 +4448,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
if (cfg->method->dynamic)
gi->locations = g_malloc0 (gi->nlocs * sizeof (MonoDwarfLocListEntry));
else
gi->locations = mono_domain_alloc0 (cfg->domain, gi->nlocs * sizeof (MonoDwarfLocListEntry));
gi->locations = mono_domain_alloc0 (cfg->domain, gi->nlocs * sizeof (MonoDwarfLocListEntry), "dwarf-loc-list-entry");
i = 0;
for (l = loclist; l; l = l->next) {
memcpy (&(gi->locations [i]), l->data, sizeof (MonoDwarfLocListEntry));
@@ -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;
@@ -4693,7 +4693,7 @@ get_gsharedvt_type (MonoType *t)
mono_image_unlock (image);
if (res)
return res;
copy = mono_image_alloc0 (image, sizeof (MonoGenericParamFull));
copy = mono_image_alloc0 (image, sizeof (MonoGenericParamFull), "gsharedvt-generic-param");
memcpy (copy, par, sizeof (MonoGenericParamFull));
} else {
copy = g_memdup (par, sizeof (MonoGenericParamFull));
@@ -4874,7 +4874,7 @@ mini_init_gsctx (MonoDomain *domain, MonoMemPool *mp, MonoGenericContext *contex
if (context && context->class_inst) {
inst = context->class_inst;
if (domain)
gsctx->var_is_vt = mono_domain_alloc0 (domain, sizeof (gboolean) * inst->type_argc);
gsctx->var_is_vt = mono_domain_alloc0 (domain, sizeof (gboolean) * inst->type_argc, "gsharing-context-var-is-vt");
else if (mp)
gsctx->var_is_vt = mono_mempool_alloc0 (mp, sizeof (gboolean) * inst->type_argc);
else
@@ -4890,7 +4890,7 @@ mini_init_gsctx (MonoDomain *domain, MonoMemPool *mp, MonoGenericContext *contex
if (context && context->method_inst) {
inst = context->method_inst;
if (domain)
gsctx->mvar_is_vt = mono_domain_alloc0 (domain, sizeof (gboolean) * inst->type_argc);
gsctx->mvar_is_vt = mono_domain_alloc0 (domain, sizeof (gboolean) * inst->type_argc, "gsharing-context-mvar-is-vt");
else if (mp)
gsctx->mvar_is_vt = mono_mempool_alloc0 (mp, sizeof (gboolean) * inst->type_argc);
else
@@ -7103,7 +7103,7 @@ mini_create_ftnptr (MonoDomain *domain, gpointer addr)
desc [1] = NULL;
# elif defined(__ppc64__) || defined(__powerpc64__)
desc = mono_domain_alloc0 (domain, 3 * sizeof (gpointer));
desc = mono_domain_alloc0 (domain, 3 * sizeof (gpointer), "ftnptr-desc");
desc [0] = addr;
desc [1] = NULL;
+2 -1
View File
@@ -123,7 +123,7 @@
#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,
+2 -2
View 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);
+7 -1
View 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 =
Loaded 100 of 123 files, more files were not shown because too many files have changed in this diff. Show more