Compare commits

...
79 Commits
Author SHA1 Message Date
Geoff Norton 3b5c655c05 Fix the build on windows 2010-10-05 15:59:29 -04:00
Michael Hutchinson 3b6f5c3308 [io-layer] Cope with pids > 16 bits
Fixes an issue in Process where "pseudo-handles" for processes with
pids > 16 bits would overflow and start getting treated as normal
handles. This would frequently segfault MonoDevelop on MacOS.
2010-10-05 13:38:52 -04:00
Geoff Norton 579a0ca72b Its possible that we're calling Process_free_internal on a pseudo-handle.
When we are not using SHM we use psuedo handles to return processes from pids,
however we dont guard against pseudo-handles in CloseProcess, which could lead to
calling unref on a fake handle.
2010-10-05 13:02:07 -04:00
Marek Habersack 577dfd5d78 [asp.net] Fix for bug #643298. A typo prevented the EnableViewStateMac from being recognized in the Page directive. 2010-10-05 08:04:46 +02:00
Miguel de Icaza 57dae7a311 Retval is not a reserved keyword, fixes 643345 2010-10-03 12:31:14 -04:00
Zoltan Varga a21c08a924 Check the debugger_thread_exited condition in a loop to guard against spurious wakeups. Fixes #642780. 2010-10-01 23:53:09 +02:00
Zoltan Varga e763cd5010 Fix code buffer reallocation check for OP_SWITCH on arm. 2010-10-01 16:27:51 +02:00
Zoltan Varga 964d3433d8 Fix a deadlock introduced by 5c2e3bf7 by using a separate low level lock to procect access to the file_share_hash hash table. Fixes #642985. 2010-10-01 10:03:27 +02:00
Gonzalo Paniagua Javier 89f92560a1 Invoke the callback in separate threads
The callbacks need to be invoked in different threads to avoid clogging
	the IO pool.

	Fixes bug #639656.
2010-09-30 01:41:22 -04:00
Marek Safar b1752875e8 [642437] Nested types have to check type arguments only and not full class 2010-09-29 09:06:09 -06:00
Alan McGovern 2a308efd0a [System.ServiceModel] Fix a few potential exceptions in background threads
Pass the listener as it's own async state so that we avoid potential null derefs in the callback. Also wrap the BeginAccept and EndAccept calls in their own try/catches in case they throw an exception.
2010-09-29 08:46:52 -06:00
Jérémie Laval bff2b8d6c4 [ReaderWriterLockSlim] Fix state corruption and race in a special interleaving.
Fix possible state corruption in the case where Upgradeable wasn't reactivating its read bit after a downgrade and set events accordingly. Fix possible race where a write process wannabe could step in the middle of Upgradeable actually upgrading to write mode.

Conflicts:

	mcs/class/System.Core/System.Threading/ReaderWriterLockSlim.cs
2010-09-29 15:45:21 +01:00
Marek Habersack 9f2d34d689 [asp.net] Remove lock recursion in Cache.ExpireItems 2010-09-28 22:36:04 +02:00
Atsushi Eno 37edaa18f7 TCP channel listener: remove extra complication (threads) in the previous change. 2010-09-28 10:57:39 -06:00
Atsushi Eno 77d12442c4 Rework TCP listening model, and fix AcceptTcpClient() to not drop timed out requests that actually steals next requests in the air. 2010-09-28 10:57:38 -06:00
Jérémie Laval 3ad4bb8e3d Turn Is*LockHeld properties into thread-specific values in ReaderWriterLockSlim. Add corresponding unit tests. 2010-09-28 13:24:25 +01:00
Marek Habersack 67c7faf279 [asp.net] Get rid of a possible (although unlikely) race condition when acquiring locks
The patch removes a small race condition where a boolean flag is set after acquiring a lock to
indicate to code executing in the finally {} block that it should release the lock. The boolean
variable is now removed and the lock is released unconditionally. It carries a potential to
throw an exception when the lock is not held, but it's better than to fail to release it and
lead the application to a deadlock.
2010-09-28 13:32:15 +02:00
Jackson Harper 7757931e8e On 64bit this is turning into a 16 byte struct, this works around the issue. 2010-09-24 00:26:29 -04:00
Andrew Jorgensen 5a55034e93 move DynamicData to mvc because it depends on Extensions 2010-09-23 14:18:16 -06:00
Gonzalo Paniagua Javier bab18ab6d2 epoll_ctl takes an int, not IntPtr
Ditto.
2010-09-23 15:02:32 -04:00
Gonzalo Paniagua Javier 4c601b8522 EpollEvent size adjustment
EpollEvent has to be one uint32 plus one int64, i.e. 12 bytes long.
	Manos libres now.
2010-09-22 18:15:57 -04:00
Jérémie Laval 36e827b0be Also set readerDoneEvent when exiting an upgradeable lock and reader condition is correct.
It could cause a deadlock when a writer tested the rwlock value before RwRead was removed and another Upgradeable operation happened at the same time.
2010-09-22 11:10:56 +01:00
Marek Safar e137468dc6 [640722] Consider delegate parameters when checking member hiding 2010-09-21 10:22:11 -06:00
Marek Safar aa92238b98 [640709] Don't reuse method parameters for base proxy, they can be hoisted 2010-09-21 10:21:46 -06:00
Marek Safar 093a537205 [640699] Reduced compound expressions need explicit conversion too. 2010-09-21 10:09:36 -06:00
Andrew Jorgensen fe1653eae0 put the x11 devel package back in buildrequires and a couple other spec fixes 2010-09-20 17:25:14 -06:00
Rodrigo Kumpera 58f029f2d1 Report the broken type name instead of assembly's. 2010-09-20 14:54:25 -03:00
Rodrigo Kumpera f16036819a Use List<Exception> instead of ArrayList to make things prettier. 2010-09-20 14:44:56 -03:00
Rodrigo Kumpera 784d21f5fd Fix AssemblyBuilder::GetTypes () with unfinished types.
* AssemblyBuilder.cs (GetTypes): Raise ReflectionTypeLoadException
	if any type was not finished.

	* AssemblyBuilderTest.cs: Add test for GetTypes () and incomplete
	TypeBuilders'.

	Fixes #640288
2010-09-20 14:36:41 -03:00
Andrew Jorgensen c101a18be3 errant file 2010-09-17 12:20:56 -06:00
Marek Safar f038e86294 [639603] Don't emit statements as expressions when they don't support it. 2010-09-17 12:09:26 -06:00
Gonzalo Paniagua Javier ef47ac3d22 Revert my last patch
Not only it didn't fix anything but it broke a test.
2010-09-17 09:48:59 -06:00
Atsushi Eno 95617646ba Add working .svc handler in 4.0 web.config. 2010-09-17 09:47:46 -06:00
Atsushi Eno 652ff412d2 (merge master 3a7d8b3) Avoid crash for use of deprecated InstallTrackingHandler in Snow Leopard. 2010-09-17 12:42:08 +09:00
Andrew Jorgensen 8ca77a27fa More .spec reorgs 2010-09-16 17:12:57 -06:00
Gonzalo Paniagua Javier 3b8eeb54d3 Fix typo. It has been there for 4 years.
Why on earth this wasn't found earlier? $20 reward to whoever gives a
	plausible explanation.
2010-09-16 15:10:58 -04:00
Marek Safar 6e23108f39 [639407] Clean up more static stuff to fix repl instances. 2010-09-16 12:06:42 -06:00
Miguel de Icaza 052fd53f21 Revert 2010-09-15 17:18:41 -04:00
Rodrigo Kumpera 164ba0d204 Fix a sgen shutdown crash.
* threads.c (mono_thread_suspend_all_other_threads): wait_data
	must not be malloc'd since it holds managed pointers. Alloc
	it on stack since the struct is about 512/1024 bytes long.

	* threads.c (mono_thread_manage): Ditto.

	* threads.c (mono_threads_request_thread_dump): Ditto.
2010-09-15 17:39:44 -03:00
Marek Safar 8853b1acb3 [637935] Fixed 3.5 version of msbuild dlls to reference 3.5 version of the engine
MONO_PATH does not work for subsequent dlls, so have to workaround it by
using full path for dlls in 3.5 profile which does not have it's own
mscorlib
2010-09-15 13:07:21 -06:00
Miguel de Icaza d2bc3285b1 Make the thread-id field be of the proper size on 64 bit machines.
This error was found by Gonzalo when he was looking at another problem
when thread IDs overflowed ints.

Currently we use gpointers in the io-layer for the threadid, but we were
only exposing the value as an int32.   The good news is that the code is
not really used right now, but could cause problems in the future as we
extend Process.
2010-09-15 14:28:58 -04:00
Ankit Jain 019cca88ce [xbuild] Fix references to Microsoft.Build.* assemblies for 3.5 . 2010-09-15 12:15:10 -06:00
Andrew Jorgensen b2ac405dbb mono-configuration-crypto is a 4.0 assembly, not 2.0 2010-09-15 10:39:11 -06:00
Rodrigo Kumpera 24ef405181 Fix monotouch bootstrap.
* Type.cs (GetTypeCodeImpl): If the type is a TypeBuilder
	call into specific code.

	* TypeBuilder.cs (GetTypeCodeInternal): New method that
	handles enums correctly.

	This change is required because calling into the runtime
	with incomplete TypeBuilders cause the runtime to crash.
2010-09-15 12:26:12 -04:00
Geoff Norton e2aecacc87 Fix the embedded mono on OSX code to support a symlinked mono into the framework.
The embedding code looks at the executable name, and builds the embedding profile
from that, however the default install has a /usr/bin/mono symlink pointing to
/Library/Frameworks/Mono.framework.  We now resolve the symlink before allowing
the embedding code to proceed.
2010-09-15 12:25:57 -04:00
Marek Safar d6038fc397 [639403] Fixes the endless recursion with hacked EOF 2010-09-15 09:07:12 -06:00
Gonzalo Paniagua Javier 0d7b33cbc9 GetProcessById now works on the Mac too
Ditto.
	This should fix MD problems when SHM is disabled.
2010-09-14 18:25:36 -04:00
Marek Safar f40fc6829d Initialize all core types 2010-09-14 16:15:39 -06:00
Gonzalo Paniagua Javier eb12be05d9 From master 2010-09-14 16:00:04 -04:00
Jérémie Laval f68a0cd137 Allow recursive Write + n * Read lock pattern for ReaderWriterLockSlim and add corresponding unit test 2010-09-14 16:00:04 -04:00
Jérémie Laval 815ec755b4 Generalize ThreadLockState to include recursive count informations and update them accordingly in the different Enter/Exit methods 2010-09-14 16:00:04 -04:00
Jérémie Laval f751095363 Split ReaderWriterLockSlim helper classes into their own files 2010-09-14 16:00:04 -04:00
Marek Safar 30f3260cc1 Finish predefined attributes instance access to allow compile time dynamic support in repl.
Fixes 639010
2010-09-14 11:27:01 -06:00
Geoff Norton 50a2d76b29 Fix a typo in my last commit 2010-09-13 19:59:19 -04:00
Geoff Norton 006d9f248d The tid is passed around internally as a unsigned value.
We were having a crash on OSX due to thread->tid not equalling the
passed tid due to a signedness issue.
2010-09-13 18:43:36 -04:00
Geoff Norton f16e13ead3 Mono 2.8 has a few more usages of the old type 2010-09-13 18:38:09 -04:00
Zoltan Varga 904b7563aa Bump minor version to 2 to be compatible with the runtime. 2010-09-13 15:32:28 -06:00
Geoff Norton 05378ccef9 Fix the build when compiling without shared handle support entirely
The wapi init functions call this even when shared is compiled out,
lets just return FALSE to get into the right codepaths.
2010-09-13 14:46:11 -04:00
Geoff Norton 911929eed1 Rename major -> major_collector and drop unguarded usage of ucontext_t.
Android defines a variable called "major" in its headers, lets rename
major -> major_collector to work around the conflict.

Not every architecture/platform has ucontext_t, so lets not strongly
type our contexts to that and let the macros do their job.
2010-09-13 14:45:55 -04:00
Zoltan Varga ae557e488d Avoid freeing the allocated monitors on shutdown, it seems to cause crashes
when running with SGEN, since SGEN writes to those arrays in:

==29095==    at 0x6844E5: add_or_remove_disappearing_link (sgen-gc.c:4143)
==29095==    by 0x6845F8: mono_gc_register_disappearing_link (sgen-gc.c:4167)
==29095==    by 0x67DE35: clear_domain_process_object (sgen-gc.c:1384)
==29095==    by 0x67DEA3: clear_domain_process_major_object_callback (sgen-gc.c:1400)
==29095==    by 0x6DE2DC: major_iterate_objects (sgen-marksweep.c:692)
==29095==    by 0x67E00B: mono_gc_clear_domain (sgen-gc.c:1459)
2010-09-10 16:58:05 -06:00
Geoff Norton d88e223dd4 Forward port this change for MonoVS 2010-09-10 14:55:45 -06:00
Geoff Norton 1867fd1486 fix typo
svn path=/branches/mono-2-6/mono/; revision=148851
2010-09-10 14:55:43 -06:00
Geoff Norton 1f42b9026c 2009-12-14 Geoff Norton <[email protected]>
* debugger-agent.c: The end_runtime_invoke guard isn't working
        on AMD64 as __builtin_frame_address (1) returns NULL.  Disable the
        behaviour by default, and make it runtime configurable.

svn path=/branches/mono-2-6/mono/; revision=148421
2010-09-10 14:55:41 -06:00
Miguel de Icaza 4b649e0805 [Fix] Correct fix for the g_shell_parse_argv bug
Simplifies the code a little bit by eliminating the in_quote variable,
but also fixes the rules to follow the requirements from the
"Shell Command Language" specification on the Unix03 site:

http://opengroup.org/onlinepubs/007908775/xcu/chap2.html#tag_001_002

In particular, the interpretation of the backslash inside double quotes
is limited to a handful of characters.   Notice that this differs from
the glib implementation which is not correct either.
2010-09-10 01:04:15 -04:00
Miguel de Icaza 2ce8ebda5f [Fix] Allow escape characters inside quoted text, and do not let nested quote reset the quoting state
This should fix #637680
2010-09-09 19:48:41 -04:00
Andrew Jorgensen 3b7c1f8741 Various cleanup and addition 2010-09-09 09:57:59 -06:00
Zoltan Varga faa1dd5646 Add a few more remaps. 2010-09-07 15:50:00 -06:00
Zoltan Varga 21b9ee9deb Remap g_strdupv too. 2010-09-07 15:49:59 -06:00
Marek Habersack db99cebd57 [asp.net] Fix for bug #636709. ClientID must be reset when ID is assigned. 2010-09-07 23:21:26 +02:00
Marek Habersack a8c3708337 [asp.net] Fix for bug #636475. A typo caused ads not to be matched in ChooseAd
The second loop over the ads hashtable must not reject an app if the keyword filter is empty.
2010-09-07 22:11:41 +02:00
Gonzalo Paniagua Javier b40cb0cc14 Add wsdl help generator to the 4.0 files
Ditto.

	Fixes bug #636841.
2010-09-07 14:32:44 -04:00
Gonzalo Paniagua Javier 5640b0a889 Remove Content-Length header when not needed
If we are redirecting to a GET from a POST, the Content-Length header
	might have stale data and it will be sent. Some servers, instead of
	ignoring it, keep waiting for the data to be sent (for a GET!).

	Fixes bug #636219.
2010-09-01 16:07:04 -06:00
Gonzalo Paniagua Javier 693cbe7207 Use the request itself as the key for the cache.
We were usign teh URL, but that might not be unique among several
	requests that need to be authenticated using NTLM. This led to
	different requests sharing the same authentication session which fails
	miserably.

	Bug #631315 fixed.
2010-09-01 16:07:03 -06:00
Gonzalo Paniagua Javier 93d6cc3bf9 Avoid sending data in the challenge phase of NTLM
If there's a POST/PUT request that gets a NTLM 401, we save the data
	and don't send it again until after the challenge phase. Ie, instead of
	sending all the data 3 times, we only send it at most twice.
2010-09-01 16:07:02 -06:00
Ankit Jain 0474947f86 [xbuild] Update man page to add "/tv:" option.
Add option to specify toolsversion from the command line,
to the man page.
2010-09-01 15:34:14 -06:00
Ankit Jain 0013378bfa [xbuild] Unsubscribe events on ConsoleLogger.Shutdown ()
Reported by Lluis Sanchez.
2010-09-01 15:34:03 -06:00
Geoff Norton 0e5aff05c4 Fix build of mono-basic on ppc64
OP_BREAK can take up to 40 bytes on ppc64
2010-09-01 12:15:25 -06:00
Jonathan Pryor 38a79cb7b8 [mdoc-update] Only check for duplicate elements, not duplicate nodes.
The duplicate-element checking algorithm wasn't restricted to just elements;
consequently, an 'invalid token' exception was generated from XPath because we
were trying to call XmlNode.SelectNodes("#text"), and '#' isn't valid.  Oops.

Fixes building gendarme from mono-tools.
2010-09-01 09:12:12 -06:00
Andrew Jorgensen fc767570a8 Version 2.8 2010-08-31 16:38:26 -06:00
88 changed files with 3146 additions and 728 deletions

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@ AC_CANONICAL_SYSTEM
m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(mono,2.8.1)
AM_INIT_AUTOMAKE(mono,2.8)
AM_MAINTAINER_MODE
API_VER=2.0
File diff suppressed because it is too large. Load diff
+2
View File
@@ -4,9 +4,11 @@ monodir = $(sysconfdir)/mono/4.0
EXTRA_DIST = machine.config \
web.config \
DefaultWsdlHelpGenerator.aspx \
settings.map
mono_DATA = machine.config \
web.config \
DefaultWsdlHelpGenerator.aspx \
settings.map
+1
View File
@@ -76,6 +76,7 @@
<!--
<add path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="False"/>
-->
<add verb="*" path="*.svc" type="System.ServiceModel.Channels.SvcHttpHandlerFactory, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add path="*.rules" verb="*" type="System.Web.HttpForbiddenHandler" validate="True"/>
<!--
<add path="*.xoml" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="False"/>
+3
View File
@@ -50,6 +50,7 @@
#define g_hash_table_new_full monoeg_g_hash_table_new_full
#define g_hash_table_remove monoeg_g_hash_table_remove
#define g_hash_table_size monoeg_g_hash_table_size
#define g_hash_table_print_stats monoeg_g_hash_table_print_stats
#define g_int_equal monoeg_g_int_equal
#define g_int_hash monoeg_g_int_hash
#define g_list_alloc monoeg_g_list_alloc
@@ -99,6 +100,7 @@
#define g_pattern_spec_new monoeg_g_pattern_spec_new
#define g_print monoeg_g_print
#define g_printf monoeg_g_printf
#define g_printerr monoeg_g_printerr
#define g_propagate_error monoeg_g_propagate_error
#define g_ptr_array_add monoeg_g_ptr_array_add
#define g_ptr_array_foreach monoeg_g_ptr_array_foreach
@@ -166,6 +168,7 @@
#define g_strerror monoeg_g_strerror
#define g_strescape monoeg_g_strescape
#define g_strfreev monoeg_g_strfreev
#define g_strdupv monoeg_g_strdupv
#define g_string_append monoeg_g_string_append
#define g_string_append_c monoeg_g_string_append_c
#define g_string_append_len monoeg_g_string_append_len
+17 -9
View File
@@ -33,7 +33,6 @@ split_cmdline (const gchar *cmdline, GPtrArray *array, GError **error)
{
gchar *ptr;
gchar c;
gboolean in_quote = FALSE;
gboolean escaped = FALSE;
gchar quote_char = '\0';
GString *str;
@@ -42,18 +41,28 @@ split_cmdline (const gchar *cmdline, GPtrArray *array, GError **error)
ptr = (gchar *) cmdline;
while ((c = *ptr++) != '\0') {
if (escaped) {
escaped = FALSE;
if (!g_ascii_isspace (c))
/*
* \CHAR is only special inside a double quote if CHAR is
* one of: $`"\ and newline
*/
if (quote_char == '\"'){
if (!(c == '$' || c == '`' || c == '"' || c == '\\'))
g_string_append_c (str, '\\');
g_string_append_c (str, c);
} else if (in_quote) {
} else {
if (!g_ascii_isspace (c))
g_string_append_c (str, c);
}
escaped = FALSE;
} else if (quote_char) {
if (c == quote_char) {
in_quote = FALSE;
quote_char = '\0';
g_ptr_array_add (array, g_string_free (str, FALSE));
str = g_string_new ("");
} else {
} else if (c == '\\'){
escaped = TRUE;
} else
g_string_append_c (str, c);
}
} else if (g_ascii_isspace (c)) {
if (str->len > 0) {
g_ptr_array_add (array, g_string_free (str, FALSE));
@@ -62,7 +71,6 @@ split_cmdline (const gchar *cmdline, GPtrArray *array, GError **error)
} else if (c == '\\') {
escaped = TRUE;
} else if (c == '\'' || c == '"') {
in_quote = TRUE;
quote_char = c;
} else {
g_string_append_c (str, c);
@@ -76,7 +84,7 @@ split_cmdline (const gchar *cmdline, GPtrArray *array, GError **error)
return -1;
}
if (in_quote) {
if (quote_char) {
if (error)
*error = g_error_new (G_LOG_DOMAIN, 0, "Unfinished quote.");
g_string_free (str, TRUE);
+34
View File
@@ -226,6 +226,39 @@ test_shell_argv3 ()
return OK;
}
// This was the 2.8 showstopper error
RESULT
test_shell_argv4 ()
{
GError *error;
gint argc;
gchar **argv;
gboolean ret;
char *str = "'/usr/bin/gnome-terminal' -e \"bash -c 'read -p \\\"Press any key to continue...\\\" -n1;'\"";
argv = NULL;
argc = 0;
error = NULL;
ret = g_shell_parse_argv (str, &argc, &argv, &error);
if (!ret)
return FAILED ("1. It should return TRUE");
if (argc != 3)
return FAILED ("2. argc was %d", argc);
if (argv == NULL)
return FAILED ("3. argv[0] was NULL");
if (error != NULL)
return FAILED ("4. error was set");
if (strcmp (argv [0], "/usr/bin/gnome-terminal"))
return FAILED ("5. Expected /usr/bin/gnome-terminal got %s", argv [0]);
if (strcmp (argv [1], "-e"))
return FAILED ("6. Expected -e, got: %s", argv [1]);
if (strcmp (argv [2], "bash -c 'read -p \"Press any key to continue...\" -n1;'"))
return FAILED ("7. Got unexpected result: %s\n", argv [2]);
return OK;
}
RESULT
test_quote ()
{
@@ -244,6 +277,7 @@ static Test shell_tests [] = {
{"g_shell_parse_argv1", test_shell_argv1},
{"g_shell_parse_argv2", test_shell_argv2},
{"g_shell_parse_argv3", test_shell_argv3},
{"g_shell_parse_argv4", test_shell_argv4},
{"g_shell_quote", test_quote},
{NULL, NULL}
};
+9
View File
@@ -23,6 +23,15 @@ Set or override project properties
.B \//logger:<logger>
Custom logger to log build events
.TP
.B \//toolsversion:version , /tv:version
Specify the toolset version to use.
Eg. /tv:4.0
This would cause 4.0 version of the Microsoft.Common.targets (among others) to be used. This overrides
the value specified in a project file.
Valid values: 2.0, 3.0, 3.5 and 4.0
.TP
.B \//verbosity:<level>
Logger verbosity level : quiet, minimal, normal, detailed, diagnostic
.TP
@@ -50,7 +50,11 @@ namespace System.Windows.Forms.CarbonInternal {
private static DragTrackingDelegate DragTrackingHandler = new DragTrackingDelegate (TrackingCallback);
static Dnd () {
InstallTrackingHandler (DragTrackingHandler, IntPtr.Zero, IntPtr.Zero);
try {
InstallTrackingHandler (DragTrackingHandler, IntPtr.Zero, IntPtr.Zero);
} catch (EntryPointNotFoundException) {
// it is deprecated in 10.6 and does not exist anymore.
}
}
internal Dnd () {
+4 -8
View File
@@ -4,15 +4,11 @@ include ../../build/rules.make
LIBRARY = Microsoft.Build.Engine.dll
ifeq (1.0, $(FRAMEWORK_VERSION))
LIBRARY_NAME = dummy-Microsoft.Build.Engine.dll
NO_INSTALL = yes
NO_TEST = yes
NO_SIGN_ASSEMBLY = yes
endif
BUILD_FRAMEWORK = Microsoft.Build.Framework.dll
ifeq (3.5, $(FRAMEWORK_VERSION))
NAME_SUFFIX = .v3.5
BUILD_FRAMEWORK := $(topdir)/class/lib/$(PROFILE)/$(BUILD_FRAMEWORK)
else
ifeq (4.0, $(FRAMEWORK_VERSION))
NAME_SUFFIX = .v4.0
@@ -24,11 +20,11 @@ LIB_MCS_FLAGS = \
/r:System.dll \
/r:System.Core.dll \
/r:System.Xml.dll \
/r:Microsoft.Build.Framework.dll \
/r:$(BUILD_FRAMEWORK) \
/r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll
TEST_MCS_FLAGS = \
/r:Microsoft.Build.Framework.dll \
/r:$(BUILD_FRAMEWORK) \
/r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll
EXTRA_DISTFILES = \
@@ -55,6 +55,7 @@ namespace Microsoft.Build.BuildEngine {
ConsoleColor errorColor, warningColor, eventColor, messageColor, highMessageColor;
ColorSetter colorSet;
ColorResetter colorReset;
IEventSource eventSource;
bool no_message_color, use_colors;
bool noItemAndPropertyList;
@@ -202,6 +203,8 @@ namespace Microsoft.Build.BuildEngine {
public virtual void Initialize (IEventSource eventSource)
{
this.eventSource = eventSource;
eventSource.BuildStarted += new BuildStartedEventHandler (BuildStartedHandler);
eventSource.BuildFinished += new BuildFinishedEventHandler (BuildFinishedHandler);
eventSource.ProjectStarted += new ProjectStartedEventHandler (ProjectStartedHandler);
@@ -574,6 +577,20 @@ namespace Microsoft.Build.BuildEngine {
public virtual void Shutdown ()
{
if (eventSource == null)
return;
eventSource.BuildStarted -= BuildStartedHandler;
eventSource.BuildFinished -= BuildFinishedHandler;
eventSource.ProjectStarted -= ProjectStartedHandler;
eventSource.ProjectFinished -= ProjectFinishedHandler;
eventSource.TargetStarted -= TargetStartedHandler;
eventSource.TargetFinished -= TargetFinishedHandler;
eventSource.TaskStarted -= TaskStartedHandler;
eventSource.TaskFinished -= TaskFinishedHandler;
eventSource.MessageRaised -= MessageHandler;
eventSource.WarningRaised -= WarningHandler;
eventSource.ErrorRaised -= ErrorHandler;
}
static bool InEmacs = Environment.GetEnvironmentVariable ("EMACS") == "t";
+8 -14
View File
@@ -3,17 +3,13 @@ SUBDIRS =
include ../../build/rules.make
LIBRARY = Microsoft.Build.Tasks.dll
ifeq (1.0, $(FRAMEWORK_VERSION))
LIBRARY_NAME = dummy-Microsoft.Build.Tasks.dll
NO_INSTALL = yes
NO_TEST = yes
NO_SIGN_ASSEMBLY = yes
else
BUILD_FRAMEWORK = Microsoft.Build.Framework.dll
BUILD_ENGINE = Microsoft.Build.Engine.dll
ifeq (3.5, $(FRAMEWORK_VERSION))
NAME_SUFFIX = .v3.5
BUILD_FRAMEWORK := $(topdir)/class/lib/$(PROFILE)/$(BUILD_FRAMEWORK)
BUILD_ENGINE := $(topdir)/class/lib/$(PROFILE)/$(BUILD_ENGINE)
else
ifeq (4.0, $(FRAMEWORK_VERSION))
NAME_SUFFIX = .v4.0
@@ -22,8 +18,6 @@ endif
LIBRARY_NAME = Microsoft.Build.Tasks$(NAME_SUFFIX).dll
endif
LIB_MCS_FLAGS = \
/r:$(corlib) \
/r:System.dll \
@@ -31,12 +25,12 @@ LIB_MCS_FLAGS = \
/r:System.Xml.dll \
/r:System.Windows.Forms.dll \
/r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll \
/r:Microsoft.Build.Framework.dll \
/r:Microsoft.Build.Engine.dll
/r:$(BUILD_FRAMEWORK) \
/r:$(BUILD_ENGINE)
TEST_MCS_FLAGS = \
/r:Microsoft.Build.Engine.dll \
/r:Microsoft.Build.Framework.dll \
/r:$(BUILD_ENGINE) \
/r:$(BUILD_FRAMEWORK) \
/r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll
EXTRA_DISTFILES = \
+4 -8
View File
@@ -3,15 +3,11 @@ SUBDIRS =
include ../../build/rules.make
LIBRARY = Microsoft.Build.Utilities.dll
ifeq (1.0, $(FRAMEWORK_VERSION))
LIBRARY_NAME = dummy-Microsoft.Build.Utilities.dll
NO_INSTALL = yes
NO_TEST = yes
NO_SIGN_ASSEMBLY = yes
endif
BUILD_FRAMEWORK = Microsoft.Build.Framework.dll
ifeq (3.5, $(FRAMEWORK_VERSION))
LIBRARY_NAME = Microsoft.Build.Utilities.v3.5.dll
BUILD_FRAMEWORK := $(topdir)/class/lib/$(PROFILE)/$(BUILD_FRAMEWORK)
else
ifeq (4.0, $(FRAMEWORK_VERSION))
LIBRARY_NAME = Microsoft.Build.Utilities.v4.0.dll
@@ -21,9 +17,9 @@ endif
LIB_MCS_FLAGS = \
/r:$(corlib) \
/r:System.dll \
/r:Microsoft.Build.Framework.dll
/r:$(BUILD_FRAMEWORK)
TEST_MCS_FLAGS = /r:Microsoft.Build.Framework.dll
TEST_MCS_FLAGS = /r:$(BUILD_FRAMEWORK)
export TESTING_MONO=a
XBUILD_DIR=../../tools/xbuild
@@ -158,20 +158,6 @@ namespace Microsoft.CSharp.RuntimeBinder
IgnorePrivateMembers = false
};
var core_types = Compiler.TypeManager.InitCoreTypes ();
importer.Initialize ();
// I don't think dynamically loaded assemblies can be used as dynamic
// expression without static type to be loaded first
// AppDomain.CurrentDomain.AssemblyLoad += (sender, e) => { throw new NotImplementedException (); };
// Import all currently loaded assemblies
var ns = Compiler.GlobalRootNamespace.Instance;
foreach (System.Reflection.Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) {
ns.AddAssemblyReference (a);
importer.ImportAssembly (a, ns);
}
var reporter = new Compiler.Report (ErrorPrinter.Instance) {
WarningLevel = 0
};
@@ -180,8 +166,29 @@ namespace Microsoft.CSharp.RuntimeBinder
IsRuntimeBinder = true
};
Compiler.TypeManager.InitCoreTypes (cc, core_types);
Compiler.TypeManager.InitOptionalCoreTypes (cc);
IList<Compiler.PredefinedTypeSpec> core_types = null;
// HACK: To avoid re-initializing static TypeManager types, like string_type
if (!Compiler.RootContext.EvalMode) {
core_types = Compiler.TypeManager.InitCoreTypes ();
}
importer.Initialize ();
// I don't think dynamically loaded assemblies can be used as dynamic
// expression without static type to be loaded first
// AppDomain.CurrentDomain.AssemblyLoad += (sender, e) => { throw new NotImplementedException (); };
// Import all currently loaded assemblies
var ns = cc.GlobalRootNamespace;
foreach (System.Reflection.Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) {
ns.AddAssemblyReference (a);
importer.ImportAssembly (a, ns);
}
if (!Compiler.RootContext.EvalMode) {
Compiler.TypeManager.InitCoreTypes (cc, core_types);
Compiler.TypeManager.InitOptionalCoreTypes (cc);
}
dc = new DynamicContext (cc);
}
@@ -265,7 +265,7 @@ namespace Mono.Debugger.Soft
* with newer runtimes, and vice versa.
*/
public const int MAJOR_VERSION = 2;
public const int MINOR_VERSION = 1;
public const int MINOR_VERSION = 2;
enum WPSuspendPolicy {
NONE = 0,
@@ -1165,10 +1165,18 @@ namespace Mono.Unix.Native {
EPOLL_CTL_MOD = 3,
}
[StructLayout (LayoutKind.Sequential, Pack = 1)]
[StructLayout (LayoutKind.Explicit, Size=12, Pack=1)]
public struct EpollEvent {
[FieldOffset (0)]
public EpollEvents events;
public IntPtr fd;
[FieldOffset (4)]
public int fd;
[FieldOffset (4)]
public IntPtr ptr;
[FieldOffset (4)]
public uint u32;
[FieldOffset (4)]
public ulong u64;
}
#endregion
@@ -2669,7 +2677,7 @@ namespace Mono.Unix.Native {
return sys_epoll_create1 (flags);
}
public static int epoll_ctl (int epfd, EpollOp op, IntPtr fd, EpollEvents events)
public static int epoll_ctl (int epfd, EpollOp op, int fd, EpollEvents events)
{
EpollEvent ee = new EpollEvent ();
ee.events = events;
@@ -2693,7 +2701,7 @@ namespace Mono.Unix.Native {
private static extern int sys_epoll_create1 (EpollFlags flags);
[DllImport (LIBC, SetLastError=true, EntryPoint="epoll_ctl")]
private static extern int sys_epoll_ctl (int epfd, EpollOp op, IntPtr fd, ref EpollEvent ee);
private static extern int sys_epoll_ctl (int epfd, EpollOp op, int fd, ref EpollEvent ee);
[DllImport (LIBC, SetLastError=true, EntryPoint="epoll_wait")]
private static extern int sys_epoll_wait (int epfd, EpollEvent [] ee, int maxevents, int timeout);
@@ -85,6 +85,8 @@ System.Threading/LockRecursionException.cs
System.Threading/LockRecursionPolicy.cs
System.Threading/ReaderWriterLockSlim.cs
../corlib/System.Threading/AtomicBoolean.cs
System.Threading/ThreadLockState.cs
System.Threading/ReaderWriterLockSlimExtensions.cs
Microsoft.Win32.SafeHandles/SafePipeHandle.cs
System.IO.Pipes/AnonymousPipeClientStream.cs
System.IO.Pipes/AnonymousPipeServerStream.cs
@@ -35,43 +35,6 @@ using System.Threading;
namespace System.Threading {
[Flags]
internal enum ThreadLockState
{
None = 0,
Read = 1,
Write = 2,
Upgradable = 4,
UpgradedRead = 5,
UpgradedWrite = 6
}
internal static class ReaderWriterLockSlimExtensions
{
internal static bool Has (this ThreadLockState state, ThreadLockState value)
{
return (state & value) > 0;
}
#if !NET_4_0 && !NET_4_0_BOOTSTRAP
internal static bool Wait (this ManualResetEvent self, int timeout)
{
return self.WaitOne (timeout);
}
internal static bool IsSet (this ManualResetEvent self)
{
return self.WaitOne (0);
}
#else
internal static bool IsSet (this ManualResetEventSlim self)
{
return self.IsSet;
}
#endif
}
[HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true, ExternalThreading = true)]
public class ReaderWriterLockSlim : IDisposable
@@ -104,8 +67,11 @@ namespace System.Threading {
int numReadWaiters, numUpgradeWaiters, numWriteWaiters;
bool disposed;
static int idPool = int.MinValue;
readonly int id = Interlocked.Increment (ref idPool);
[ThreadStatic]
static IDictionary<ReaderWriterLockSlim, ThreadLockState> currentThreadState;
static IDictionary<int, ThreadLockState> currentThreadState;
public ReaderWriterLockSlim () : this (LockRecursionPolicy.NoRecursion)
{
@@ -123,23 +89,30 @@ namespace System.Threading {
public bool TryEnterReadLock (int millisecondsTimeout)
{
if (CheckState (millisecondsTimeout, ThreadLockState.Read))
ThreadLockState ctstate = CurrentThreadState;
if (CheckState (millisecondsTimeout, LockState.Read)) {
ctstate.ReaderRecursiveCount++;
return true;
}
// This is downgrading from upgradable, no need for check since
// we already have a sort-of read lock that's going to disappear
// after user calls ExitUpgradeableReadLock.
// Same idea when recursion is allowed and a write thread wants to
// go for a Read too.
if (CurrentThreadState.Has (ThreadLockState.Upgradable)
if (CurrentLockState.Has (LockState.Upgradable)
|| recursionPolicy == LockRecursionPolicy.SupportsRecursion) {
Interlocked.Add (ref rwlock, RwRead);
CurrentThreadState = CurrentThreadState ^ ThreadLockState.Read;
ctstate.LockState ^= LockState.Read;
ctstate.ReaderRecursiveCount++;
return true;
}
Stopwatch sw = Stopwatch.StartNew ();
Interlocked.Increment (ref numReadWaiters);
int val = 0;
while (millisecondsTimeout == -1 || sw.ElapsedMilliseconds < millisecondsTimeout) {
if ((rwlock & 0x7) > 0) {
@@ -147,11 +120,20 @@ namespace System.Threading {
continue;
}
if ((Interlocked.Add (ref rwlock, RwRead) & 0x7) == 0) {
CurrentThreadState = CurrentThreadState ^ ThreadLockState.Read;
Interlocked.Decrement (ref numReadWaiters);
if (readerDoneEvent.IsSet ())
/* Optimistically try to add ourselves to the reader value
* if the adding was too late and another writer came in between
* we revert the operation.
*/
if (((val = Interlocked.Add (ref rwlock, RwRead)) & 0x7) == 0) {
/* If we are the first reader, reset the event to let other threads
* sleep correctly if they try to acquire write lock
*/
if (val >> RwReadBit == 1)
readerDoneEvent.Reset ();
ctstate.LockState ^= LockState.Read;
ctstate.ReaderRecursiveCount++;
Interlocked.Decrement (ref numReadWaiters);
return true;
}
@@ -171,10 +153,13 @@ namespace System.Threading {
public void ExitReadLock ()
{
if (!CurrentThreadState.Has (ThreadLockState.Read))
ThreadLockState ctstate = CurrentThreadState;
if (!ctstate.LockState.Has (LockState.Read))
throw new SynchronizationLockException ("The current thread has not entered the lock in read mode");
CurrentThreadState = ThreadLockState.None;
ctstate.LockState ^= LockState.Read;
ctstate.ReaderRecursiveCount--;
if (Interlocked.Add (ref rwlock, -RwRead) >> RwReadBit == 0)
readerDoneEvent.Set ();
}
@@ -186,39 +171,54 @@ namespace System.Threading {
public bool TryEnterWriteLock (int millisecondsTimeout)
{
bool isUpgradable = CurrentThreadState.Has (ThreadLockState.Upgradable);
if (CheckState (millisecondsTimeout, isUpgradable ? ThreadLockState.UpgradedWrite : ThreadLockState.Write))
ThreadLockState ctstate = CurrentThreadState;
if (CheckState (millisecondsTimeout, LockState.Write)) {
ctstate.WriterRecursiveCount++;
return true;
}
Stopwatch sw = Stopwatch.StartNew ();
Interlocked.Increment (ref numWriteWaiters);
bool isUpgradable = ctstate.LockState.Has (LockState.Upgradable);
// If the code goes there that means we had a read lock beforehand
/* If the code goes there that means we had a read lock beforehand
* that need to be suppressed, we also take the opportunity to register
* our interest in the write lock to avoid other write wannabe process
* coming in the middle
*/
if (isUpgradable && rwlock >= RwRead)
Interlocked.Add (ref rwlock, -RwRead);
if (Interlocked.Add (ref rwlock, RwWaitUpgrade - RwRead) >> RwReadBit == 0)
readerDoneEvent.Set ();
int stateCheck = isUpgradable ? RwWaitUpgrade : RwWait;
int appendValue = RwWait | (isUpgradable ? RwWaitUpgrade : 0);
while (millisecondsTimeout < 0 || sw.ElapsedMilliseconds < millisecondsTimeout) {
int state = rwlock;
if (state <= stateCheck) {
if (Interlocked.CompareExchange (ref rwlock, RwWrite, state) == state) {
CurrentThreadState = isUpgradable ? ThreadLockState.UpgradedWrite : ThreadLockState.Write;
writerDoneEvent.Reset ();
ctstate.LockState ^= LockState.Write;
ctstate.WriterRecursiveCount++;
Interlocked.Decrement (ref numWriteWaiters);
if (writerDoneEvent.IsSet ())
writerDoneEvent.Reset ();
return true;
}
state = rwlock;
}
while ((state & RwWait) == 0 && Interlocked.CompareExchange (ref rwlock, state | appendValue, state) == state)
state = rwlock;
// We register our interest in taking the Write lock (if upgradeable it's already done)
if (!isUpgradable)
while ((state & RwWait) == 0 && Interlocked.CompareExchange (ref rwlock, state | RwWait, state) == state)
state = rwlock;
while (rwlock > stateCheck && (millisecondsTimeout < 0 || sw.ElapsedMilliseconds < millisecondsTimeout))
readerDoneEvent.Wait (ComputeTimeout (millisecondsTimeout, sw));
// Before falling to sleep
while (rwlock > stateCheck && (millisecondsTimeout < 0 || sw.ElapsedMilliseconds < millisecondsTimeout)) {
if ((rwlock & RwWrite) != 0)
writerDoneEvent.Wait (ComputeTimeout (millisecondsTimeout, sw));
else if ((rwlock >> RwReadBit) > 0)
readerDoneEvent.Wait (ComputeTimeout (millisecondsTimeout, sw));
}
}
Interlocked.Decrement (ref numWriteWaiters);
@@ -232,12 +232,19 @@ namespace System.Threading {
public void ExitWriteLock ()
{
if (!CurrentThreadState.Has (ThreadLockState.Write))
ThreadLockState ctstate = CurrentThreadState;
if (!ctstate.LockState.Has (LockState.Write))
throw new SynchronizationLockException ("The current thread has not entered the lock in write mode");
CurrentThreadState = CurrentThreadState ^ ThreadLockState.Write;
Interlocked.Add (ref rwlock, -RwWrite);
bool isUpgradable = ctstate.LockState.Has (LockState.Upgradable);
ctstate.LockState ^= LockState.Write;
ctstate.WriterRecursiveCount--;
int value = Interlocked.Add (ref rwlock, isUpgradable ? RwRead - RwWrite : -RwWrite);
writerDoneEvent.Set ();
if (isUpgradable && value >> RwReadBit == 1)
readerDoneEvent.Reset ();
}
public void EnterUpgradeableReadLock ()
@@ -251,10 +258,14 @@ namespace System.Threading {
//
public bool TryEnterUpgradeableReadLock (int millisecondsTimeout)
{
if (CheckState (millisecondsTimeout, ThreadLockState.Upgradable))
return true;
ThreadLockState ctstate = CurrentThreadState;
if (CurrentThreadState.Has (ThreadLockState.Read))
if (CheckState (millisecondsTimeout, LockState.Upgradable)) {
ctstate.UpgradeableRecursiveCount++;
return true;
}
if (ctstate.LockState.Has (LockState.Read))
throw new LockRecursionException ("The current thread has already entered read mode");
Stopwatch sw = Stopwatch.StartNew ();
@@ -272,8 +283,10 @@ namespace System.Threading {
upgradableEvent.Reset ();
if (TryEnterReadLock (ComputeTimeout (millisecondsTimeout, sw))) {
CurrentThreadState = ThreadLockState.Upgradable;
ctstate.LockState = LockState.Upgradable;
Interlocked.Decrement (ref numUpgradeWaiters);
ctstate.ReaderRecursiveCount--;
ctstate.UpgradeableRecursiveCount++;
return true;
}
@@ -292,14 +305,18 @@ namespace System.Threading {
public void ExitUpgradeableReadLock ()
{
if (!CurrentThreadState.Has (ThreadLockState.Upgradable | ThreadLockState.Read))
ThreadLockState ctstate = CurrentThreadState;
if (!ctstate.LockState.Has (LockState.Upgradable | LockState.Read))
throw new SynchronizationLockException ("The current thread has not entered the lock in upgradable mode");
upgradableTaken.Value = false;
upgradableEvent.Set ();
CurrentThreadState = CurrentThreadState ^ ThreadLockState.Upgradable;
Interlocked.Add (ref rwlock, -RwRead);
ctstate.LockState ^= LockState.Upgradable;
ctstate.UpgradeableRecursiveCount--;
if (Interlocked.Add (ref rwlock, -RwRead) >> RwReadBit == 0)
readerDoneEvent.Set ();
}
public void Dispose ()
@@ -309,43 +326,43 @@ namespace System.Threading {
public bool IsReadLockHeld {
get {
return rwlock >= RwRead;
return rwlock >= RwRead && CurrentThreadState.LockState.Has (LockState.Read);
}
}
public bool IsWriteLockHeld {
get {
return (rwlock & RwWrite) > 0;
return (rwlock & RwWrite) > 0 && CurrentThreadState.LockState.Has (LockState.Write);
}
}
public bool IsUpgradeableReadLockHeld {
get {
return upgradableTaken.Value;
return upgradableTaken.Value && CurrentThreadState.LockState.Has (LockState.Upgradable);
}
}
public int CurrentReadCount {
get {
return (rwlock >> RwReadBit) - (IsUpgradeableReadLockHeld ? 1 : 0);
return (rwlock >> RwReadBit) - (upgradableTaken.Value ? 1 : 0);
}
}
public int RecursiveReadCount {
get {
return IsReadLockHeld ? IsUpgradeableReadLockHeld ? 0 : 1 : 0;
return CurrentThreadState.ReaderRecursiveCount;
}
}
public int RecursiveUpgradeCount {
get {
return IsUpgradeableReadLockHeld ? 1 : 0;
return CurrentThreadState.UpgradeableRecursiveCount;
}
}
public int RecursiveWriteCount {
get {
return IsWriteLockHeld ? 1 : 0;
return CurrentThreadState.WriterRecursiveCount;
}
}
@@ -372,28 +389,30 @@ namespace System.Threading {
return recursionPolicy;
}
}
ThreadLockState CurrentThreadState {
LockState CurrentLockState {
get {
// TODO: provide a IEqualityComparer thingie to have better hashes
if (currentThreadState == null)
currentThreadState = new Dictionary<ReaderWriterLockSlim, ThreadLockState> ();
ThreadLockState state;
if (!currentThreadState.TryGetValue (this, out state))
currentThreadState[this] = state = ThreadLockState.None;
return state;
return CurrentThreadState.LockState;
}
set {
if (currentThreadState == null)
currentThreadState = new Dictionary<ReaderWriterLockSlim, ThreadLockState> ();
currentThreadState[this] = value;
CurrentThreadState.LockState = value;
}
}
bool CheckState (int millisecondsTimeout, ThreadLockState validState)
ThreadLockState CurrentThreadState {
get {
if (currentThreadState == null)
currentThreadState = new Dictionary<int, ThreadLockState> ();
ThreadLockState state;
if (!currentThreadState.TryGetValue (id, out state))
currentThreadState[id] = state = new ThreadLockState ();
return state;
}
}
bool CheckState (int millisecondsTimeout, LockState validState)
{
if (disposed)
throw new ObjectDisposedException ("ReaderWriterLockSlim");
@@ -402,15 +421,15 @@ namespace System.Threading {
throw new ArgumentOutOfRangeException ("millisecondsTimeout");
// Detect and prevent recursion
ThreadLockState ctstate = CurrentThreadState;
LockState ctstate = CurrentLockState;
if (recursionPolicy == LockRecursionPolicy.NoRecursion)
if ((ctstate != ThreadLockState.None && ctstate != ThreadLockState.Upgradable)
|| (ctstate == ThreadLockState.Upgradable && validState == ThreadLockState.Upgradable))
if ((ctstate != LockState.None && ctstate != LockState.Upgradable)
|| (ctstate == LockState.Upgradable && validState == LockState.Upgradable))
throw new LockRecursionException ("The current thread has already a lock and recursion isn't supported");
// If we already had right lock state, just return
if (ctstate == validState)
if (ctstate.Has (validState))
return true;
CheckRecursionAuthorization (ctstate, validState);
@@ -418,10 +437,10 @@ namespace System.Threading {
return false;
}
static void CheckRecursionAuthorization (ThreadLockState ctstate, ThreadLockState desiredState)
static void CheckRecursionAuthorization (LockState ctstate, LockState desiredState)
{
// In read mode you can just enter Read recursively
if (ctstate == ThreadLockState.Read)
if (ctstate == LockState.Read)
throw new LockRecursionException ();
}
@@ -0,0 +1,57 @@
//
// ReaderWriterLockSlimExtensions.cs
//
// Author:
// Jérémie "Garuma" Laval <[email protected]>
//
// Copyright (c) 2010 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Threading
{
internal static class ReaderWriterLockSlimExtensions
{
internal static bool Has (this LockState state, LockState value)
{
return (state & value) > 0;
}
#if !NET_4_0 && !NET_4_0_BOOTSTRAP
internal static bool Wait (this ManualResetEvent self, int timeout)
{
return self.WaitOne (timeout);
}
internal static bool IsSet (this ManualResetEvent self)
{
return self.WaitOne (0);
}
#else
internal static bool IsSet (this ManualResetEventSlim self)
{
return self.IsSet;
}
#endif
}
}
@@ -0,0 +1,51 @@
//
// ThreadLockState.cs
//
// Author:
// Jérémie "Garuma" Laval <[email protected]>
//
// Copyright (c) 2010 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Threading
{
[Flags]
internal enum LockState
{
None = 0,
Read = 1,
Write = 2,
Upgradable = 4,
UpgradedRead = Upgradable | Read,
UpgradedWrite = Upgradable | Write
}
internal class ThreadLockState
{
public LockState LockState;
public int ReaderRecursiveCount;
public int WriterRecursiveCount;
public int UpgradeableRecursiveCount;
}
}
@@ -452,6 +452,28 @@ namespace MonoTests.System.Threading
Assert.IsTrue (v.TryEnterWriteLock (100), "#3");
}
[Test]
public void RecursiveWritePlusReadLockTest ()
{
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
Assert.IsTrue (v.TryEnterWriteLock (100), "#1");
Assert.AreEqual (1, v.RecursiveWriteCount, "1b");
Assert.AreEqual (0, v.RecursiveReadCount, "1c");
Assert.IsTrue (v.TryEnterReadLock (100), "#2");
Assert.AreEqual (1, v.RecursiveWriteCount, "2b");
Assert.AreEqual (1, v.RecursiveReadCount, "2c");
Assert.IsTrue (v.TryEnterReadLock (100), "#3");
Assert.AreEqual (1, v.RecursiveWriteCount, "3b");
Assert.AreEqual (2, v.RecursiveReadCount, "3c");
v.ExitReadLock ();
Assert.AreEqual (1, v.RecursiveWriteCount, "4b");
Assert.AreEqual (1, v.RecursiveReadCount, "4c");
}
[Test]
public void RecursiveUpgradeableReadLockTest ()
{
@@ -461,5 +483,92 @@ namespace MonoTests.System.Threading
Assert.IsTrue (v.TryEnterUpgradeableReadLock (100), "#2");
Assert.IsTrue (v.TryEnterUpgradeableReadLock (100), "#3");
}
[Test]
public void RecursiveReadPropertiesTest ()
{
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
v.EnterReadLock ();
v.EnterReadLock ();
Assert.AreEqual (true, v.IsReadLockHeld, "#1a");
Assert.AreEqual (1, v.CurrentReadCount, "#2a");
Assert.AreEqual (2, v.RecursiveReadCount, "#3a");
bool rLock = true;
int cReadCount = -1, rReadCount = -1;
Thread t = new Thread ((_) => {
rLock = v.IsReadLockHeld;
cReadCount = v.CurrentReadCount;
rReadCount = v.RecursiveReadCount;
});
t.Start ();
t.Join ();
Assert.AreEqual (false, rLock, "#1b");
Assert.AreEqual (1, cReadCount, "#2b");
Assert.AreEqual (0, rReadCount, "#3b");
}
[Test]
public void RecursiveUpgradePropertiesTest ()
{
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
v.EnterUpgradeableReadLock ();
v.EnterUpgradeableReadLock ();
Assert.AreEqual (true, v.IsUpgradeableReadLockHeld, "#1a");
Assert.AreEqual (false, v.IsReadLockHeld, "#11a");
Assert.AreEqual (0, v.CurrentReadCount, "#2a");
Assert.AreEqual (2, v.RecursiveUpgradeCount, "#3a");
bool upLock = false, rLock = false;
int rCount = -1, rUCount = -1;
Thread t = new Thread ((_) => {
upLock = v.IsUpgradeableReadLockHeld;
rLock = v.IsReadLockHeld;
rCount = v.CurrentReadCount;
rUCount = v.RecursiveUpgradeCount;
});
t.Start ();
t.Join ();
Assert.AreEqual (false, upLock, "#1b");
Assert.AreEqual (false, rLock, "#11b");
Assert.AreEqual (0, rCount, "#2b");
Assert.AreEqual (0, rUCount, "#3b");
}
[Test]
public void RecursiveWritePropertiesTest ()
{
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
v.EnterWriteLock ();
v.EnterWriteLock ();
Assert.AreEqual (true, v.IsWriteLockHeld, "#1a");
Assert.AreEqual (2, v.RecursiveWriteCount, "#3a");
bool wLock = false;
int rWrite = -1;
Thread t = new Thread ((_) => {
wLock = v.IsWriteLockHeld;
rWrite = v.RecursiveWriteCount;
});
t.Start ();
t.Join ();
Assert.AreEqual (false, wLock, "#1b");
Assert.AreEqual (0, rWrite, "#3b");
}
}
}
@@ -66,6 +66,8 @@ System.Security.Cryptography/SHA512CryptoServiceProvider.cs
System.Threading/LockRecursionException.cs
System.Threading/LockRecursionPolicy.cs
System.Threading/ReaderWriterLockSlim.cs
System.Threading/ThreadLockState.cs
System.Threading/ReaderWriterLockSlimExtensions.cs
System.Linq.Expressions/Extensions.cs
System.Linq.Expressions/ExpressionTransformer.cs
@@ -3,9 +3,30 @@
//
// Author:
// Marcos Cobena ([email protected])
// Atsushi Enomoto ([email protected])
//
// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
// Copyright 2009-2010 Novell, Inc (http://www.novell.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
@@ -46,8 +67,9 @@ namespace System.ServiceModel.Channels
info = new TcpChannelInfo (source, MessageEncoder, quotas);
}
List<ManualResetEvent> accept_handles = new List<ManualResetEvent> ();
List<TChannel> accepted_channels = new List<TChannel> ();
SynchronizedCollection<ManualResetEvent> accept_handles = new SynchronizedCollection<ManualResetEvent> ();
Queue<TcpClient> accepted_clients = new Queue<TcpClient> ();
SynchronizedCollection<TChannel> accepted_channels = new SynchronizedCollection<TChannel> ();
protected override TChannel OnAcceptChannel (TimeSpan timeout)
{
@@ -89,32 +111,28 @@ namespace System.ServiceModel.Channels
{
DateTime start = DateTime.Now;
TcpClient client = null;
if (tcp_listener.Pending ()) {
client = tcp_listener.AcceptTcpClient ();
} else {
TcpClient client = accepted_clients.Count == 0 ? null : accepted_clients.Dequeue ();
if (client == null) {
var wait = new ManualResetEvent (false);
tcp_listener.BeginAcceptTcpClient (delegate (IAsyncResult result) {
client = tcp_listener.EndAcceptTcpClient (result);
wait.Set ();
accept_handles.Remove (wait);
}, null);
if (State == CommunicationState.Closing)
return null;
accept_handles.Add (wait);
wait.WaitOne (timeout);
if (!wait.WaitOne (timeout)) {
accept_handles.Remove (wait);
return null;
}
accept_handles.Remove (wait);
// recurse with new timeout, or return null if it's either being closed or timed out.
timeout -= (DateTime.Now - start);
return State == CommunicationState.Opened && timeout > TimeSpan.Zero ? AcceptTcpClient (timeout) : null;
}
// This may be optional though ...
if (client != null) {
foreach (var ch in accepted_channels) {
var dch = ch as TcpDuplexSessionChannel;
if (dch == null || dch.TcpClient == null && !dch.TcpClient.Connected)
continue;
if (((IPEndPoint) dch.TcpClient.Client.RemoteEndPoint).Equals (client.Client.RemoteEndPoint))
// ... then it should be handled in another BeginTryReceive/EndTryReceive loop in ChannelDispatcher.
return AcceptTcpClient (timeout - (DateTime.Now - start));
}
// There might be bettwe way to exclude those TCP clients though ...
foreach (var ch in accepted_channels) {
var dch = ch as TcpDuplexSessionChannel;
if (dch == null || dch.TcpClient == null && !dch.TcpClient.Connected)
continue;
if (((IPEndPoint) dch.TcpClient.Client.RemoteEndPoint).Equals (client.Client.RemoteEndPoint))
// ... then it should be handled in another BeginTryReceive/EndTryReceive loop in ChannelDispatcher.
return AcceptTcpClient (timeout - (DateTime.Now - start));
}
return client;
@@ -132,25 +150,25 @@ namespace System.ServiceModel.Channels
{
if (State == CommunicationState.Closed)
return;
ProcessClose ();
ProcessClose (TimeSpan.Zero);
}
protected override void OnClose (TimeSpan timeout)
{
if (State == CommunicationState.Closed)
return;
ProcessClose ();
ProcessClose (timeout);
}
void ProcessClose ()
void ProcessClose (TimeSpan timeout)
{
if (tcp_listener == null)
throw new InvalidOperationException ("Current state is " + State);
lock (accept_handles) {
foreach (var wait in accept_handles)
wait.Set ();
}
//tcp_listener.Client.Close (Math.Max (50, (int) timeout.TotalMilliseconds));
tcp_listener.Stop ();
var l = new List<ManualResetEvent> (accept_handles);
foreach (var wait in l) // those handles will disappear from accepted_handles
wait.Set ();
tcp_listener = null;
}
@@ -164,6 +182,31 @@ namespace System.ServiceModel.Channels
int explicitPort = Uri.Port;
tcp_listener = new TcpListener (entry.AddressList [0], explicitPort <= 0 ? TcpTransportBindingElement.DefaultPort : explicitPort);
tcp_listener.Start ();
tcp_listener.BeginAcceptTcpClient (TcpListenerAcceptedClient, tcp_listener);
}
void TcpListenerAcceptedClient (IAsyncResult result)
{
var listener = (TcpListener) result.AsyncState;
try {
var client = listener.EndAcceptTcpClient (result);
if (client != null) {
accepted_clients.Enqueue (client);
if (accept_handles.Count > 0)
accept_handles [0].Set ();
}
} catch {
/* If an accept fails, just ignore it. Maybe the remote peer disconnected already */
} finally {
if (State == CommunicationState.Opened) {
try {
listener.BeginAcceptTcpClient (TcpListenerAcceptedClient, listener);
} catch {
/* If this fails, we must have disposed the listener */
}
}
}
}
}
}
@@ -42,6 +42,21 @@ namespace System.Web.Caching
{
public static readonly DateTime NoAbsoluteExpiration = DateTime.MaxValue;
public static readonly TimeSpan NoSlidingExpiration = TimeSpan.Zero;
// cacheLock will be released in the code below without checking whether it was
// actually acquired. The API doesn't offer a reliable way to check whether the lock
// is being held by the current thread and since Mono does't implement CER
// (Constrained Execution Regions -
// http://msdn.microsoft.com/en-us/library/ms228973.aspx) currently, we have no
// reliable way of recording the information that the lock has been successfully
// acquired.
// It can happen that a Thread.Abort occurs while acquiring the lock and the lock
// isn't actually held. In this case the attempt to release a lock will throw an
// exception. It's better than a race of setting a boolean flag after acquiring the
// lock and then relying upon it here to release it - that may cause a deadlock
// should we fail to release the lock which was successfully acquired but
// Thread.Abort happened right after that during the stloc instruction to set the
// boolean flag. Once CERs are supported we can use the boolean flag reliably.
ReaderWriterLockSlim cacheLock;
Dictionary <string, CacheItem> cache;
CacheItemPriorityQueue timedItems;
@@ -153,19 +168,17 @@ namespace System.Web.Caching
{
if (key == null)
throw new ArgumentNullException ("key");
bool locked = false;
try {
cacheLock.EnterWriteLock ();
locked = true;
CacheItem it = GetCacheItem (key);
if (it != null)
return it.Value;
Insert (key, value, dependencies, absoluteExpiration, slidingExpiration, priority, onRemoveCallback, null, false);
} finally {
if (locked)
cacheLock.ExitWriteLock ();
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
return null;
@@ -173,10 +186,8 @@ namespace System.Web.Caching
public object Get (string key)
{
bool locked = false;
try {
cacheLock.EnterUpgradeableReadLock ();
locked = true;
CacheItem it = GetCacheItem (key);
if (it == null)
return null;
@@ -187,6 +198,7 @@ namespace System.Web.Caching
if (!NeedsUpdate (it, CacheItemUpdateReason.DependencyChanged, false))
Remove (it.Key, CacheItemRemovedReason.DependencyChanged, false, true);
} finally {
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
@@ -212,6 +224,7 @@ namespace System.Web.Caching
if (!NeedsUpdate (it, CacheItemUpdateReason.Expired, false))
Remove (key, CacheItemRemovedReason.Expired, false, true);
} finally {
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
@@ -221,9 +234,8 @@ namespace System.Web.Caching
return it.Value;
} finally {
if (locked) {
cacheLock.ExitUpgradeableReadLock ();
}
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitUpgradeableReadLock ();
}
}
@@ -282,20 +294,17 @@ namespace System.Web.Caching
internal void SetItemTimeout (string key, DateTime absoluteExpiration, TimeSpan slidingExpiration, bool doLock)
{
CacheItem ci = null;
bool locked = false;
CacheItem ci = null;
try {
if (doLock) {
if (doLock)
cacheLock.EnterWriteLock ();
locked = true;
}
ci = GetCacheItem (key);
if (ci != null)
SetItemTimeout (ci, absoluteExpiration, slidingExpiration, ci.OnRemoveCallback, null, key, false);
} finally {
if (locked) {
if (doLock) {
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
}
@@ -317,12 +326,9 @@ namespace System.Web.Caching
ci.OnRemoveCallback = onRemoveCallback;
ci.OnUpdateCallback = onUpdateCallback;
bool locked = false;
try {
if (doLock) {
if (doLock)
cacheLock.EnterWriteLock ();
locked = true;
}
if (ci.Timer != null) {
ci.Timer.Dispose ();
@@ -336,7 +342,8 @@ namespace System.Web.Caching
if (!disableExpiration && ci.AbsoluteExpiration != NoAbsoluteExpiration)
EnqueueTimedItem (ci);
} finally {
if (locked) {
if (doLock) {
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
}
@@ -376,16 +383,14 @@ namespace System.Web.Caching
object Remove (string key, CacheItemRemovedReason reason, bool doLock, bool invokeCallback)
{
CacheItem it = null;
bool locked = false;
try {
if (doLock) {
if (doLock)
cacheLock.EnterWriteLock ();
locked = true;
}
it = RemoveCacheItem (key);
} finally {
if (locked) {
if (doLock) {
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
}
@@ -424,10 +429,8 @@ namespace System.Web.Caching
internal void InvokePrivateCallbacks ()
{
CacheItemRemovedReason reason = CacheItemRemovedReason.Removed;
bool locked = false;
try {
cacheLock.EnterReadLock ();
locked = true;
foreach (string key in cache.Keys) {
CacheItem item = GetCacheItem (key);
if (item.Disabled)
@@ -442,25 +445,21 @@ namespace System.Web.Caching
}
}
} finally {
if (locked) {
cacheLock.ExitReadLock ();
}
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitReadLock ();
}
}
public IDictionaryEnumerator GetEnumerator ()
{
ArrayList list = new ArrayList ();
bool locked = false;
try {
cacheLock.EnterReadLock ();
locked = true;
foreach (CacheItem it in cache.Values)
list.Add (it);
} finally {
if (locked) {
cacheLock.ExitReadLock ();
}
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitReadLock ();
}
return new CacheItemEnumerator (list);
@@ -478,13 +477,9 @@ namespace System.Web.Caching
bool NeedsUpdate (CacheItem item, CacheItemUpdateReason reason, bool needLock)
{
bool locked = false;
try {
if (needLock) {
if (needLock)
cacheLock.EnterWriteLock ();
locked = true;
}
if (item == null || item.OnUpdateCallback == null)
return false;
@@ -525,8 +520,10 @@ namespace System.Web.Caching
} catch (Exception) {
return false;
} finally {
if (locked)
if (needLock) {
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
}
}
@@ -534,11 +531,9 @@ namespace System.Web.Caching
{
DateTime now = DateTime.Now;
CacheItem item = timedItems.Peek ();
bool locked = false;
try {
cacheLock.EnterWriteLock ();
locked = true;
while (item != null) {
if (!item.Disabled && item.ExpiresAt > now.Ticks)
@@ -549,13 +544,13 @@ namespace System.Web.Caching
}
item = timedItems.Dequeue ();
if (!NeedsUpdate (item, CacheItemUpdateReason.Expired, true))
if (!NeedsUpdate (item, CacheItemUpdateReason.Expired, false))
Remove (item.Key, CacheItemRemovedReason.Expired, false, true);
item = timedItems.Peek ();
}
} finally {
if (locked)
cacheLock.ExitWriteLock ();
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
if (item != null) {
@@ -574,10 +569,8 @@ namespace System.Web.Caching
internal void CheckDependencies ()
{
IList list;
bool locked = false;
try {
cacheLock.EnterWriteLock ();
locked = true;
list = new List <CacheItem> ();
foreach (CacheItem it in cache.Values)
list.Add (it);
@@ -587,18 +580,15 @@ namespace System.Web.Caching
Remove (it.Key, CacheItemRemovedReason.DependencyChanged, false, true);
}
} finally {
if (locked) {
cacheLock.ExitWriteLock ();
}
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
}
internal DateTime GetKeyLastChange (string key)
{
bool locked = false;
try {
cacheLock.EnterReadLock ();
locked = true;
CacheItem it = GetCacheItem (key);
if (it == null)
@@ -606,9 +596,8 @@ namespace System.Web.Caching
return it.LastChange;
} finally {
if (locked) {
cacheLock.ExitReadLock ();
}
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitReadLock ();
}
}
@@ -41,6 +41,8 @@ namespace System.Web.Caching
CacheItem[] heap;
int heapSize = 0;
int heapCount = 0;
// See comment for the cacheLock field at top of System.Web.Caching/Cache.cs
ReaderWriterLockSlim queueLock;
public int Count {
@@ -94,20 +96,18 @@ namespace System.Web.Caching
if (item == null)
return;
bool locked = false;
CacheItem[] heap;
try {
queueLock.EnterWriteLock ();
locked = true;
heap = GetHeapWithGrow ();
heap [heapCount++] = item;
BubbleUp (heap);
AddSequenceEntry (item, EDSequenceEntryType.Enqueue);
} finally {
if (locked)
queueLock.ExitWriteLock ();
// See comment at the top of the file, above queueLock declaration
queueLock.ExitWriteLock ();
}
}
@@ -115,12 +115,10 @@ namespace System.Web.Caching
{
CacheItem ret = null;
CacheItem[] heap;
bool locked = false;
int index;
try {
queueLock.EnterWriteLock ();
locked = true;
heap = GetHeapWithShrink ();
if (heap == null || heapCount == 0)
return null;
@@ -136,19 +134,17 @@ namespace System.Web.Caching
AddSequenceEntry (ret, EDSequenceEntryType.Dequeue);
return ret;
} finally {
if (locked)
queueLock.ExitWriteLock ();
// See comment at the top of the file, above queueLock declaration
queueLock.ExitWriteLock ();
}
}
public CacheItem Peek ()
{
bool locked = false;
CacheItem ret;
try {
queueLock.EnterReadLock ();
locked = true;
if (heap == null || heapCount == 0)
return null;
@@ -157,8 +153,8 @@ namespace System.Web.Caching
return ret;
} finally {
if (locked)
queueLock.ExitReadLock ();
// See comment at the top of the file, above queueLock declaration
queueLock.ExitReadLock ();
}
}
@@ -94,6 +94,7 @@ namespace System.Web.Compilation
// This is here _only_ for the purpose of unit tests!
internal static bool suppressDebugModeMessages;
// See comment for the cacheLock field at top of System.Web.Caching/Cache.cs
#if SYSTEMCORE_DEP
static ReaderWriterLockSlim buildCacheLock;
#else
@@ -817,14 +818,12 @@ namespace System.Web.Compilation
// to the assembly builder and, in effect, no assembly is produced but there are STILL types that need
// to be added to the cache.
Assembly compiledAssembly = results != null ? results.CompiledAssembly : null;
bool locked = false;
try {
#if SYSTEMCORE_DEP
buildCacheLock.EnterWriteLock ();
#else
buildCacheLock.AcquireWriterLock (-1);
#endif
locked = true;
if (compiledAssembly != null)
referencedAssemblies.Add (compiledAssembly);
@@ -835,13 +834,11 @@ namespace System.Web.Compilation
StoreInCache (bp, compiledAssembly, results);
}
} finally {
if (locked) {
#if SYSTEMCORE_DEP
buildCacheLock.ExitWriteLock ();
buildCacheLock.ExitWriteLock ();
#else
buildCacheLock.ReleaseWriterLock ();
buildCacheLock.ReleaseWriterLock ();
#endif
}
}
}
@@ -883,24 +880,19 @@ namespace System.Web.Compilation
#endif
static BuildManagerCacheItem GetCachedItem (string vp)
{
bool locked = false;
try {
#if SYSTEMCORE_DEP
buildCacheLock.EnterReadLock ();
#else
buildCacheLock.AcquireReaderLock (-1);
#endif
locked = true;
return GetCachedItemNoLock (vp);
} finally {
if (locked) {
#if SYSTEMCORE_DEP
buildCacheLock.ExitReadLock ();
buildCacheLock.ExitReadLock ();
#else
buildCacheLock.ReleaseReaderLock ();
buildCacheLock.ReleaseReaderLock ();
#endif
}
}
}
@@ -1290,27 +1282,22 @@ namespace System.Web.Compilation
else
return;
bool locked = false;
try {
#if SYSTEMCORE_DEP
buildCacheLock.EnterWriteLock ();
#else
buildCacheLock.AcquireWriterLock (-1);
#endif
locked = true;
if (HasCachedItemNoLock (virtualPath)) {
buildCache [virtualPath] = null;
OnEntryRemoved (virtualPath);
}
} finally {
if (locked) {
#if SYSTEMCORE_DEP
buildCacheLock.ExitWriteLock ();
buildCacheLock.ExitWriteLock ();
#else
buildCacheLock.ReleaseWriterLock ();
buildCacheLock.ReleaseWriterLock ();
#endif
}
}
}
@@ -67,6 +67,8 @@ namespace System.Web.Configuration {
static readonly char[] pathTrimChars = { '/' };
static readonly object suppressAppReloadLock = new object ();
static readonly object saveLocationsCacheLock = new object ();
// See comment for the cacheLock field at top of System.Web.Caching/Cache.cs
static readonly ReaderWriterLockSlim sectionCacheLock;
#if !TARGET_J2EE
@@ -225,14 +227,11 @@ namespace System.Web.Configuration {
static void ConfigurationSaveHandler (_Configuration sender, ConfigurationSaveEventArgs args)
{
bool locked = false;
try {
sectionCacheLock.EnterWriteLock ();
locked = true;
sectionCache.Clear ();
} finally {
if (locked)
sectionCacheLock.ExitWriteLock ();
sectionCacheLock.ExitWriteLock ();
}
lock (suppressAppReloadLock) {
@@ -442,7 +441,6 @@ namespace System.Web.Configuration {
int cacheKey;
bool pathPresent = !String.IsNullOrEmpty (path);
string locationPath = null;
bool locked = false;
if (pathPresent)
locationPath = "location_" + path;
@@ -453,7 +451,6 @@ namespace System.Web.Configuration {
try {
sectionCacheLock.EnterReadLock ();
locked = true;
object o;
if (pathPresent) {
@@ -469,8 +466,7 @@ namespace System.Web.Configuration {
if (sectionCache.TryGetValue (baseCacheKey, out o))
return o;
} finally {
if (locked)
sectionCacheLock.ExitReadLock ();
sectionCacheLock.ExitReadLock ();
}
string cachePath = null;
@@ -687,27 +683,21 @@ namespace System.Web.Configuration {
static void AddSectionToCache (int key, object section)
{
object cachedSection;
bool locked = false;
try {
sectionCacheLock.EnterUpgradeableReadLock ();
locked = true;
if (sectionCache.TryGetValue (key, out cachedSection) && cachedSection != null)
return;
bool innerLocked = false;
try {
sectionCacheLock.EnterWriteLock ();
innerLocked = true;
sectionCache.Add (key, section);
} finally {
if (innerLocked)
sectionCacheLock.ExitWriteLock ();
sectionCacheLock.ExitWriteLock ();
}
} finally {
if (locked)
sectionCacheLock.ExitUpgradeableReadLock ();
sectionCacheLock.ExitUpgradeableReadLock ();
}
}
@@ -143,7 +143,7 @@ namespace System.Web.UI.WebControls
int r = new Random ().Next (total_imp);
foreach (Hashtable a in ads) {
if (keywordFilterEmpty && KeywordFilter != (string) a ["Keyword"])
if (!keywordFilterEmpty && KeywordFilter != (string) a ["Keyword"])
continue;
cur_imp += a ["Impressions"] != null ? int.Parse ((string) a ["Impressions"]) : 1;
@@ -821,6 +821,8 @@ namespace System.Web.UI
uniqueID = null;
#if NET_4_0
ClearCachedClientID ();
#else
clientID = null;
#endif
if (!HasControls ())
return;
@@ -432,7 +432,7 @@ namespace System.Web.UI
enable_event_validation = GetBool (atts, "EnableEventValidation", enable_event_validation);
maintainScrollPositionOnPostBack = GetBool (atts, "MaintainScrollPositionOnPostBack", maintainScrollPositionOnPostBack);
if (atts.Contains ("EnableViewState")) {
if (atts.Contains ("EnableViewStateMac")) {
enableViewStateMac = GetBool (atts, "EnableViewStateMac", enableViewStateMac);
enableViewStateMacSet = true;
}
+2 -2
View File
@@ -134,10 +134,10 @@ namespace Mono.Http
return null;
lock (cache) {
NtlmSession ds = (NtlmSession) cache [request.RequestUri];
NtlmSession ds = (NtlmSession) cache [request];
if (ds == null) {
ds = new NtlmSession ();
cache.Add (request.RequestUri, ds);
cache.Add (request, ds);
}
return ds.Authenticate (header, webRequest, credentials);
@@ -201,10 +201,15 @@ namespace System.Net.Sockets
}
if (callback != null)
callback (this);
ThreadPool.QueueUserWorkItem (CB, null);
Buffer = null;
}
void CB (object unused)
{
callback (this);
}
SocketAsyncCall GetDelegate (Worker worker, SocketOperation op)
{
switch (op) {
+44 -19
View File
@@ -96,14 +96,20 @@ namespace System.Net
bool getResponseCalled;
Exception saved_exc;
object locker = new object ();
bool is_ntlm_auth;
bool finished_reading;
internal WebConnection WebConnection;
DecompressionMethods auto_decomp;
int maxResponseHeadersLength;
static int defaultMaxResponseHeadersLength;
int readWriteTimeout = 300000; // ms
enum NtlmAuthState {
None,
Challenge,
Response
}
NtlmAuthState ntlm_auth_state;
// Constructors
static HttpWebRequest ()
{
@@ -160,10 +166,6 @@ namespace System.Net
// Properties
internal bool UsesNtlmAuthentication {
get { return is_ntlm_auth; }
}
public string Accept {
get { return webHeaders ["Accept"]; }
set {
@@ -960,10 +962,17 @@ namespace System.Net
webHeaders.RemoveAndAdd ("Transfer-Encoding", "chunked");
webHeaders.RemoveInternal ("Content-Length");
} else if (contentLength != -1) {
if (contentLength > 0)
continue100 = true;
webHeaders.SetInternal ("Content-Length", contentLength.ToString ());
if (ntlm_auth_state != NtlmAuthState.Challenge) {
if (contentLength > 0)
continue100 = true;
webHeaders.SetInternal ("Content-Length", contentLength.ToString ());
} else {
webHeaders.SetInternal ("Content-Length", "0");
}
webHeaders.RemoveInternal ("Transfer-Encoding");
} else {
webHeaders.RemoveInternal ("Content-Length");
}
if (actualVersion == HttpVersion.Version11 && continue100 &&
@@ -1107,9 +1116,11 @@ namespace System.Net
if (bodyBuffer != null) {
// The body has been written and buffered. The request "user"
// won't write it again, so we must do it.
writeStream.Write (bodyBuffer, 0, bodyBufferLength);
bodyBuffer = null;
writeStream.Close ();
if (ntlm_auth_state != NtlmAuthState.Challenge) {
writeStream.Write (bodyBuffer, 0, bodyBufferLength);
bodyBuffer = null;
writeStream.Close ();
}
} else if (method != "HEAD" && method != "GET" && method != "MKCOL" && method != "CONNECT" &&
method != "TRACE") {
if (getResponseCalled && !writeStream.RequestWritten)
@@ -1185,6 +1196,7 @@ namespace System.Net
}
}
r.Reset ();
finished_reading = false;
haveResponse = false;
webResponse.ReadAll ();
webResponse = null;
@@ -1237,7 +1249,7 @@ namespace System.Net
try {
redirected = CheckFinalStatus (r);
if (!redirected) {
if (is_ntlm_auth && authCompleted && webResponse != null
if (ntlm_auth_state != NtlmAuthState.None && authCompleted && webResponse != null
&& (int)webResponse.StatusCode < 400) {
WebConnectionStream wce = webResponse.GetResponseStream () as WebConnectionStream;
if (wce != null) {
@@ -1256,7 +1268,7 @@ namespace System.Net
r.DoCallback ();
} else {
if (webResponse != null) {
if (is_ntlm_auth) {
if (ntlm_auth_state != NtlmAuthState.None) {
HandleNtlmAuth (r);
return;
}
@@ -1316,18 +1328,21 @@ namespace System.Net
return false;
webHeaders [(isProxy) ? "Proxy-Authorization" : "Authorization"] = auth.Message;
authCompleted = auth.Complete;
is_ntlm_auth = (auth.Module.AuthenticationType == "NTLM");
bool is_ntlm = (auth.Module.AuthenticationType == "NTLM");
if (is_ntlm)
ntlm_auth_state = (NtlmAuthState)((int) ntlm_auth_state + 1);
return true;
}
// Returns true if redirected
bool CheckFinalStatus (WebAsyncResult result)
{
if (result.GotException)
if (result.GotException) {
bodyBuffer = null;
throw result.Exception;
}
Exception throwMe = result.Exception;
bodyBuffer = null;
HttpWebResponse resp = result.Response;
WebExceptionStatus protoError = WebExceptionStatus.ProtocolError;
@@ -1339,10 +1354,17 @@ namespace System.Net
if (!usedPreAuth && CheckAuthorization (webResponse, code)) {
// Keep the written body, so it can be rewritten in the retry
if (InternalAllowBuffering) {
bodyBuffer = writeStream.WriteBuffer;
bodyBufferLength = writeStream.WriteBufferLength;
// NTLM: This is to avoid sending data in the 'challenge' request
// We save it in the first request (first 401), don't send anything
// in the challenge request and send it in the response request along
// with the buffers kept form the first request.
if (ntlm_auth_state != NtlmAuthState.Response) {
bodyBuffer = writeStream.WriteBuffer;
bodyBufferLength = writeStream.WriteBufferLength;
}
return true;
} else if (method != "PUT" && method != "POST") {
bodyBuffer = null;
return true;
}
@@ -1350,6 +1372,7 @@ namespace System.Net
writeStream = null;
webResponse.Close ();
webResponse = null;
bodyBuffer = null;
throw new WebException ("This request requires buffering " +
"of data for authentication or " +
@@ -1357,6 +1380,7 @@ namespace System.Net
}
}
bodyBuffer = null;
if ((int) code >= 400) {
string err = String.Format ("The remote server returned an error: ({0}) {1}.",
(int) code, webResponse.StatusDescription);
@@ -1373,6 +1397,7 @@ namespace System.Net
}
}
bodyBuffer = null;
if (throwMe == null) {
bool b = false;
int c = (int) code;
@@ -139,9 +139,14 @@ namespace System.Net
{
if (!callbackDone && cb != null) {
callbackDone = true;
cb (this);
ThreadPool.QueueUserWorkItem (CB, null);
}
}
void CB (object unused)
{
cb (this);
}
internal void WaitUntilComplete ()
{
@@ -1046,6 +1046,8 @@ namespace System.Net
socket = null;
}
if (ntlm_authenticated)
ResetNtlm ();
busy = false;
Data = new WebConnectionData ();
if (sendNext)
@@ -39,6 +39,7 @@ using System.Runtime.Serialization;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography;
@@ -825,6 +826,19 @@ namespace System.Reflection.Emit
}
}
if (res != null) {
List<Exception> exceptions = null;
foreach (var type in res) {
if (type is TypeBuilder) {
if (exceptions == null)
exceptions = new List <Exception> ();
exceptions.Add (new TypeLoadException (string.Format ("Type '{0}' is not finished", type.FullName)));
}
}
if (exceptions != null)
throw new ReflectionTypeLoadException (new Type [exceptions.Count], exceptions.ToArray ());
}
return res == null ? Type.EmptyTypes : res;
}
@@ -1897,6 +1897,20 @@ namespace System.Reflection.Emit
return res;
}
internal TypeCode GetTypeCodeInternal () {
if (parent == pmodule.assemblyb.corlib_enum_type) {
for (int i = 0; i < num_fields; ++i) {
FieldBuilder f = fields [i];
if (!f.IsStatic)
return Type.GetTypeCode (f.FieldType);
}
throw new InvalidOperationException ("Enum basetype field not defined");
} else {
return Type.GetTypeCodeInternal (this);
}
}
void _TypeBuilder.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
{
throw new NotImplementedException ();
+2
View File
@@ -686,6 +686,8 @@ namespace System {
Type type = this;
if (type is MonoType)
return GetTypeCodeInternal (type);
if (type is TypeBuilder)
return ((TypeBuilder)type).GetTypeCodeInternal ();
type = type.UnderlyingSystemType;
@@ -1776,6 +1776,32 @@ public class AssemblyBuilderTest
ab.GetCustomAttributes (true);
}
[Test]
public void GetTypesWithUnfinishedTypeBuilder ()
{
AssemblyBuilder ab = genAssembly ();
ModuleBuilder mb = ab.DefineDynamicModule("tester", "tester.dll", false);
mb.DefineType ("K").CreateType ();
var tb = mb.DefineType ("T");
try {
ab.GetTypes ();
Assert.Fail ("#1");
} catch (ReflectionTypeLoadException ex) {
Assert.AreEqual (1, ex.Types.Length, "#2");
Assert.AreEqual (1, ex.LoaderExceptions.Length, "#3");
Assert.IsNull (ex.Types [0], "#4");
Assert.IsTrue (ex.LoaderExceptions [0] is TypeLoadException, "#5");
}
tb.CreateType ();
var types = ab.GetTypes ();
Assert.AreEqual (2, types.Length, "#5");
foreach (var t in types)
Assert.IsFalse (t is TypeBuilder, "#6_" + t.Name);
}
private static void AssertAssemblyName (string tempDir, AssemblyName assemblyName, string abName, string fullName)
{
AppDomain currentDomain = AppDomain.CurrentDomain;
+1 -1
View File
@@ -305,7 +305,7 @@ namespace Mono.ILASM {
%token K_OUT
%token K_OPT
// %token K_LCID
%token K_RETVAL
//%token K_RETVAL
%token K_STATIC
%token K_PUBLIC
%token K_PRIVATE
+1 -1
View File
@@ -143,7 +143,7 @@ namespace Mono.ILASM {
keywords ["opt"] = new ILToken (Token.K_OPT, "opt");
// Not a keyword according to ilasm 1.1
// keywords ["lcid"] = new ILToken (Token.K_LCID, "lcid");
keywords ["retval"] = new ILToken (Token.K_RETVAL, "retval");
//keywords ["retval"] = new ILToken (Token.K_RETVAL, "retval");
keywords ["static"] = new ILToken (Token.K_STATIC, "static");
keywords ["public"] = new ILToken (Token.K_PUBLIC, "public");
keywords ["private"] = new ILToken (Token.K_PRIVATE, "private");
+3
View File
@@ -654,6 +654,9 @@ namespace Mono.CSharp {
// Otherwise, if the selected operator is a predefined operator
//
Binary b = source as Binary;
if (b == null && source is ReducedExpression)
b = ((ReducedExpression) source).OriginalExpression as Binary;
if (b != null) {
//
// 2a. the operator is a shift operator
+9 -16
View File
@@ -308,7 +308,7 @@ namespace Mono.CSharp {
public bool HasSecurityAttribute {
get {
PredefinedAttribute pa = PredefinedAttributes.Get.Security;
PredefinedAttribute pa = context.Compiler.PredefinedAttributes.Security;
return pa.IsDefined && TypeSpec.IsBaseClass (type, pa.Type, false);
}
}
@@ -337,7 +337,7 @@ namespace Mono.CSharp {
void ApplyModuleCharSet (ResolveContext rc)
{
if (Type != PredefinedAttributes.Get.DllImport)
if (Type != context.Compiler.PredefinedAttributes.DllImport)
return;
if (!RootContext.ToplevelTypes.HasDefaultCharSet)
@@ -522,7 +522,7 @@ namespace Mono.CSharp {
public string GetValidTargets ()
{
StringBuilder sb = new StringBuilder ();
AttributeTargets targets = Type.GetAttributeUsage (PredefinedAttributes.Get.AttributeUsage).ValidOn;
AttributeTargets targets = Type.GetAttributeUsage (context.Compiler.PredefinedAttributes.AttributeUsage).ValidOn;
if ((targets & AttributeTargets.Assembly) != 0)
sb.Append ("assembly, ");
@@ -993,7 +993,7 @@ namespace Mono.CSharp {
public bool IsInternalMethodImplAttribute {
get {
if (Type != PredefinedAttributes.Get.MethodImpl)
if (Type != context.Compiler.PredefinedAttributes.MethodImpl)
return false;
MethodImplOptions options;
@@ -1048,7 +1048,9 @@ namespace Mono.CSharp {
if (ctor == null)
return;
AttributeUsageAttribute usage_attr = Type.GetAttributeUsage (PredefinedAttributes.Get.AttributeUsage);
var predefined = context.Compiler.PredefinedAttributes;
AttributeUsageAttribute usage_attr = Type.GetAttributeUsage (predefined.AttributeUsage);
if ((usage_attr.ValidOn & Target) == 0) {
Report.Error (592, Location, "The attribute `{0}' is not valid on this declaration type. " +
"It is valid on `{1}' declarations only",
@@ -1056,8 +1058,6 @@ namespace Mono.CSharp {
return;
}
var predefined = PredefinedAttributes.Get;
AttributeEncoder encoder = new AttributeEncoder (false);
if (PosArguments != null) {
@@ -1560,7 +1560,7 @@ namespace Mono.CSharp {
public static void VerifyModulesClsCompliance (CompilerContext ctx)
{
Module[] modules = GlobalRootNamespace.Instance.Modules;
Module[] modules = ctx.GlobalRootNamespace.Modules;
if (modules == null)
return;
@@ -1659,9 +1659,7 @@ namespace Mono.CSharp {
public readonly PredefinedAttribute StructLayout;
public readonly PredefinedAttribute FieldOffset;
public static PredefinedAttributes Get = new PredefinedAttributes ();
private PredefinedAttributes ()
public PredefinedAttributes ()
{
ParamArray = new PredefinedAttribute ("System", "ParamArrayAttribute");
Out = new PredefinedAttribute ("System.Runtime.InteropServices", "OutAttribute");
@@ -1713,11 +1711,6 @@ namespace Mono.CSharp {
((PredefinedAttribute) fi.GetValue (this)).Initialize (ctx, true);
}
}
public static void Reset ()
{
Get = new PredefinedAttributes ();
}
}
public class PredefinedAttribute
+19 -26
View File
@@ -667,7 +667,7 @@ namespace Mono.CSharp {
if (OptAttributes == null)
return false;
return OptAttributes.Contains (PredefinedAttributes.Get.ComImport);
return OptAttributes.Contains (Compiler.PredefinedAttributes.ComImport);
}
}
@@ -781,7 +781,7 @@ namespace Mono.CSharp {
if (OptAttributes == null)
return null;
Attribute a = OptAttributes.Search (PredefinedAttributes.Get.CoClass);
Attribute a = OptAttributes.Search (Compiler.PredefinedAttributes.CoClass);
if (a == null)
return null;
@@ -998,7 +998,7 @@ namespace Mono.CSharp {
int type_size = Kind == MemberKind.Struct && first_nonstatic_field == null ? 1 : 0;
if (IsTopLevel) {
if (GlobalRootNamespace.Instance.IsNamespace (Name)) {
if (Compiler.GlobalRootNamespace.IsNamespace (Name)) {
Report.Error (519, Location, "`{0}' clashes with a predefined namespace", Name);
return false;
}
@@ -1053,14 +1053,12 @@ namespace Mono.CSharp {
if (proxy_method == null) {
string name = CompilerGeneratedClass.MakeName (method.Name, null, "BaseCallProxy", hoisted_base_call_proxies.Count);
var base_parameters = method.Parameters.FixedParameters as Parameter[];
if (base_parameters == null) {
base_parameters = new Parameter[method.Parameters.Count];
for (int i = 0; i < base_parameters.Length; ++i) {
var base_param = method.Parameters.FixedParameters[i];
base_parameters[i] = new Parameter (new TypeExpression (method.Parameters.Types[i], Location),
base_param.Name, base_param.ModFlags, null, Location);
}
var base_parameters = new Parameter[method.Parameters.Count];
for (int i = 0; i < base_parameters.Length; ++i) {
var base_param = method.Parameters.FixedParameters[i];
base_parameters[i] = new Parameter (new TypeExpression (method.Parameters.Types[i], Location),
base_param.Name, base_param.ModFlags, null, Location);
base_parameters[i].Resolve (this, i);
}
var cloned_params = ParametersCompiled.CreateFullyResolved (base_parameters, method.Parameters.Types);
@@ -1612,7 +1610,7 @@ namespace Mono.CSharp {
if (!seen_normal_indexers)
return;
PredefinedAttribute pa = PredefinedAttributes.Get.DefaultMember;
PredefinedAttribute pa = Compiler.PredefinedAttributes.DefaultMember;
if (pa.Constructor == null &&
!pa.ResolveConstructor (Location, TypeManager.string_type))
return;
@@ -1751,7 +1749,7 @@ namespace Mono.CSharp {
}
if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
PredefinedAttributes.Get.CompilerGenerated.EmitAttribute (TypeBuilder);
Compiler.PredefinedAttributes.CompilerGenerated.EmitAttribute (TypeBuilder);
base.Emit ();
}
@@ -2399,11 +2397,11 @@ namespace Mono.CSharp {
base.Emit ();
if ((ModFlags & Modifiers.METHOD_EXTENSION) != 0)
PredefinedAttributes.Get.Extension.EmitAttribute (TypeBuilder);
Compiler.PredefinedAttributes.Extension.EmitAttribute (TypeBuilder);
var trans_flags = TypeManager.HasDynamicTypeUsed (base_type);
if (trans_flags != null) {
var pa = PredefinedAttributes.Get.DynamicTransform;
var pa = Compiler.PredefinedAttributes.DynamicTransform;
if (pa.Constructor != null || pa.ResolveConstructor (Location, ArrayContainer.MakeType (TypeManager.bool_type))) {
TypeBuilder.SetCustomAttribute (new CustomAttributeBuilder (pa.Constructor, new object[] { trans_flags }));
}
@@ -2475,7 +2473,7 @@ namespace Mono.CSharp {
if (OptAttributes == null)
return null;
Attribute[] attrs = OptAttributes.SearchMulti (PredefinedAttributes.Get.Conditional);
Attribute[] attrs = OptAttributes.SearchMulti (Compiler.PredefinedAttributes.Conditional);
if (attrs == null)
return null;
@@ -2634,14 +2632,9 @@ namespace Mono.CSharp {
while (mt.IsPointer)
mt = TypeManager.GetElementType (mt);
if (mt.MemberDefinition == this) {
for (var p = Parent; p != null; p = p.Parent) {
if (p.Kind == MemberKind.Class) {
has_unmanaged_check_done = true;
return false;
}
}
continue;
if (mt.IsGenericOrParentIsGeneric || mt.IsGenericParameter) {
has_unmanaged_check_done = true;
return false;
}
if (TypeManager.IsUnmanagedType (mt))
@@ -2884,13 +2877,13 @@ namespace Mono.CSharp {
ObsoleteAttribute oa = base_member.GetAttributeObsolete ();
if (oa != null) {
if (OptAttributes == null || !OptAttributes.Contains (PredefinedAttributes.Get.Obsolete)) {
if (OptAttributes == null || !OptAttributes.Contains (Compiler.PredefinedAttributes.Obsolete)) {
Report.SymbolRelatedToPreviousError (base_member);
Report.Warning (672, 1, Location, "Member `{0}' overrides obsolete member `{1}'. Add the Obsolete attribute to `{0}'",
GetSignatureForError (), TypeManager.GetFullNameSignature (base_member));
}
} else {
if (OptAttributes != null && OptAttributes.Contains (PredefinedAttributes.Get.Obsolete)) {
if (OptAttributes != null && OptAttributes.Contains (Compiler.PredefinedAttributes.Obsolete)) {
Report.SymbolRelatedToPreviousError (base_member);
Report.Warning (809, 1, Location, "Obsolete member `{0}' overrides non-obsolete member `{1}'",
GetSignatureForError (), TypeManager.GetFullNameSignature (base_member));
+13 -12
View File
@@ -38,6 +38,7 @@ namespace Mono.CSharp {
public class CodeGen {
static AppDomain current_domain;
// Breaks dynamic and repl
public static AssemblyClass Assembly;
static CodeGen ()
@@ -107,7 +108,7 @@ namespace Mono.CSharp {
if (an.KeyPair != null) {
// If we are going to strong name our assembly make
// sure all its refs are strong named
foreach (Assembly a in GlobalRootNamespace.Instance.Assemblies) {
foreach (Assembly a in ctx.GlobalRootNamespace.Assemblies) {
AssemblyName ref_name = a.GetName ();
byte [] b = ref_name.GetPublicKeyToken ();
if (b == null || b.Length == 0) {
@@ -1012,7 +1013,7 @@ namespace Mono.CSharp {
Arguments named = new Arguments (1);
named.Add (new NamedArgument ("SkipVerification", loc, new BoolLiteral (true, loc)));
GlobalAttribute g = new GlobalAttribute (new NamespaceEntry (null, null, null), "assembly",
GlobalAttribute g = new GlobalAttribute (new NamespaceEntry (Compiler, null, null, null), "assembly",
new MemberAccess (system_security_permissions, "SecurityPermissionAttribute"),
new Arguments[] { pos, named }, loc, false);
g.AttachTo (this, this);
@@ -1030,13 +1031,13 @@ namespace Mono.CSharp {
if (!OptAttributes.CheckTargets())
return;
ClsCompliantAttribute = ResolveAttribute (PredefinedAttributes.Get.CLSCompliant);
ClsCompliantAttribute = ResolveAttribute (Compiler.PredefinedAttributes.CLSCompliant);
if (ClsCompliantAttribute != null) {
is_cls_compliant = ClsCompliantAttribute.GetClsCompliantAttributeValue ();
}
Attribute a = ResolveAttribute (PredefinedAttributes.Get.RuntimeCompatibility);
Attribute a = ResolveAttribute (Compiler.PredefinedAttributes.RuntimeCompatibility);
if (a != null) {
var val = a.GetPropertyValue ("WrapNonExceptionThrows") as BoolConstant;
if (val != null)
@@ -1281,7 +1282,7 @@ namespace Mono.CSharp {
try {
var fi = typeof (AssemblyBuilder).GetField ("culture", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
fi.SetValue (CodeGen.Assembly.Builder, value == "neutral" ? "" : value);
fi.SetValue (Builder, value == "neutral" ? "" : value);
} catch {
Report.RuntimeMissingSupport (a.Location, "AssemblyCultureAttribute setting");
}
@@ -1302,7 +1303,7 @@ namespace Mono.CSharp {
try {
var fi = typeof (AssemblyBuilder).GetField ("version", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
fi.SetValue (CodeGen.Assembly.Builder, vinfo);
fi.SetValue (Builder, vinfo);
} catch {
Report.RuntimeMissingSupport (a.Location, "AssemblyVersionAttribute setting");
}
@@ -1319,7 +1320,7 @@ namespace Mono.CSharp {
try {
var fi = typeof (AssemblyBuilder).GetField ("algid", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
fi.SetValue (CodeGen.Assembly.Builder, alg);
fi.SetValue (Builder, alg);
} catch {
Report.RuntimeMissingSupport (a.Location, "AssemblyAlgorithmIdAttribute setting");
}
@@ -1335,12 +1336,12 @@ namespace Mono.CSharp {
flags |= ((uint) cdata[pos + 3]) << 24;
// Ignore set PublicKey flag if assembly is not strongnamed
if ((flags & (uint) AssemblyNameFlags.PublicKey) != 0 && (CodeGen.Assembly.Builder.GetName ().KeyPair == null))
if ((flags & (uint) AssemblyNameFlags.PublicKey) != 0 && (Builder.GetName ().KeyPair == null))
flags &= ~(uint)AssemblyNameFlags.PublicKey;
try {
var fi = typeof (AssemblyBuilder).GetField ("flags", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
fi.SetValue (CodeGen.Assembly.Builder, flags);
fi.SetValue (Builder, flags);
} catch {
Report.RuntimeMissingSupport (a.Location, "AssemblyFlagsAttribute setting");
}
@@ -1409,13 +1410,13 @@ namespace Mono.CSharp {
base.Emit (tc);
if (has_extension_method)
PredefinedAttributes.Get.Extension.EmitAttribute (Builder);
Compiler.PredefinedAttributes.Extension.EmitAttribute (Builder);
// FIXME: Does this belong inside SRE.AssemblyBuilder instead?
PredefinedAttribute pa = PredefinedAttributes.Get.RuntimeCompatibility;
PredefinedAttribute pa = tc.Compiler.PredefinedAttributes.RuntimeCompatibility;
if (pa.IsDefined && (OptAttributes == null || !OptAttributes.Contains (pa))) {
var ci = TypeManager.GetPredefinedConstructor (pa.Type, Location.Null, TypeSpec.EmptyTypes);
PropertyInfo [] pis = new PropertyInfo [1];
pis [0] = TypeManager.GetPredefinedProperty (pa.Type,
"WrapNonExceptionThrows", Location.Null, TypeManager.bool_type).MetaInfo;
object [] pargs = new object [1];
+6 -6
View File
@@ -86,7 +86,7 @@ namespace Mono.CSharp {
{
var c = ((ConstSpec) spec).Value as Constant;
if (c.Type == TypeManager.decimal_type) {
FieldBuilder.SetCustomAttribute (CreateDecimalConstantAttribute (c));
FieldBuilder.SetCustomAttribute (CreateDecimalConstantAttribute (c, Compiler.PredefinedAttributes));
} else {
FieldBuilder.SetConstant (c.GetTypedValue ());
}
@@ -94,11 +94,11 @@ namespace Mono.CSharp {
base.Emit ();
}
public static CustomAttributeBuilder CreateDecimalConstantAttribute (Constant c)
public static CustomAttributeBuilder CreateDecimalConstantAttribute (Constant c, PredefinedAttributes pa)
{
PredefinedAttribute pa = PredefinedAttributes.Get.DecimalConstant;
if (pa.Constructor == null &&
!pa.ResolveConstructor (c.Location, TypeManager.byte_type, TypeManager.byte_type,
PredefinedAttribute attr = pa.DecimalConstant;
if (attr.Constructor == null &&
!attr.ResolveConstructor (c.Location, TypeManager.byte_type, TypeManager.byte_type,
TypeManager.uint32_type, TypeManager.uint32_type, TypeManager.uint32_type))
return null;
@@ -110,7 +110,7 @@ namespace Mono.CSharp {
(uint) bits [2], (uint) bits [1], (uint) bits [0]
};
return new CustomAttributeBuilder (pa.Constructor, args);
return new CustomAttributeBuilder (attr.Constructor, args);
}
public static void Error_InvalidConstantType (TypeSpec t, Location loc, Report Report)
+17 -4
View File
@@ -552,11 +552,22 @@ namespace Mono.CSharp
{
readonly Report report;
readonly ReflectionMetaImporter meta_importer;
readonly PredefinedAttributes attributes;
readonly GlobalRootNamespace root;
public CompilerContext (ReflectionMetaImporter metaImporter, Report report)
{
this.meta_importer = metaImporter;
this.report = report;
this.attributes = new PredefinedAttributes ();
this.root = new GlobalRootNamespace ();
}
public GlobalRootNamespace GlobalRootNamespace {
get {
return root;
}
}
public bool IsRuntimeBinder { get; set; }
@@ -567,15 +578,17 @@ namespace Mono.CSharp
}
}
public PredefinedAttributes PredefinedAttributes {
get {
return attributes;
}
}
public Report Report {
get {
return report;
}
}
//public PredefinedAttributes PredefinedAttributes {
// get { throw new NotImplementedException (); }
//}
}
//
+3 -3
View File
@@ -474,7 +474,7 @@ namespace_declaration
Report.Error(1671, name.Location, "A namespace declaration cannot have modifiers or attributes");
}
current_namespace = new NamespaceEntry (
current_namespace = new NamespaceEntry (compiler,
current_namespace, file, name.GetName ());
current_class = current_namespace.SlaveDeclSpace;
current_container = current_class.PartialContainer;
@@ -5980,7 +5980,7 @@ opt_query_continuation
interactive_parsing
: EVAL_STATEMENT_PARSER EOF
| EVAL_USING_DECLARATIONS_UNIT_PARSER using_directives
| EVAL_USING_DECLARATIONS_UNIT_PARSER using_directives opt_COMPLETE_COMPLETION
| EVAL_STATEMENT_PARSER {
Evaluator.LoadAliases (current_namespace);
@@ -6346,7 +6346,7 @@ public CSharpParser (SeekableStreamReader reader, CompilationUnit file, Compiler
this.file = file;
this.compiler = ctx;
current_namespace = new NamespaceEntry (null, file, null);
current_namespace = new NamespaceEntry (ctx, null, file, null);
current_class = current_namespace.SlaveDeclSpace;
current_container = current_class.PartialContainer; // == RootContest.ToplevelTypes
oob_stack.Clear ();
+5 -5
View File
@@ -509,7 +509,7 @@ namespace Mono.CSharp {
if (OptAttributes == null)
return null;
Attribute obsolete_attr = OptAttributes.Search (PredefinedAttributes.Get.Obsolete);
Attribute obsolete_attr = OptAttributes.Search (Compiler.PredefinedAttributes.Obsolete);
if (obsolete_attr == null)
return null;
@@ -706,7 +706,7 @@ namespace Mono.CSharp {
caching_flags &= ~Flags.HasCompliantAttribute_Undetected;
if (OptAttributes != null) {
Attribute cls_attribute = OptAttributes.Search (PredefinedAttributes.Get.CLSCompliant);
Attribute cls_attribute = OptAttributes.Search (Compiler.PredefinedAttributes.CLSCompliant);
if (cls_attribute != null) {
caching_flags |= Flags.HasClsCompliantAttribute;
if (cls_attribute.GetClsCompliantAttributeValue ())
@@ -750,7 +750,7 @@ namespace Mono.CSharp {
{
if (HasClsCompliantAttribute) {
if (CodeGen.Assembly.ClsCompliantAttribute == null) {
Attribute a = OptAttributes.Search (PredefinedAttributes.Get.CLSCompliant);
Attribute a = OptAttributes.Search (Compiler.PredefinedAttributes.CLSCompliant);
if ((caching_flags & Flags.ClsCompliantAttributeFalse) != 0) {
Report.Warning (3021, 2, a.Location,
"`{0}' does not need a CLSCompliant attribute because the assembly is not marked as CLS-compliant",
@@ -764,7 +764,7 @@ namespace Mono.CSharp {
}
if (!IsExposedFromAssembly ()) {
Attribute a = OptAttributes.Search (PredefinedAttributes.Get.CLSCompliant);
Attribute a = OptAttributes.Search (Compiler.PredefinedAttributes.CLSCompliant);
Report.Warning (3019, 2, a.Location, "CLS compliance checking will not be performed on `{0}' because it is not visible from outside this assembly", GetSignatureForError ());
return false;
}
@@ -780,7 +780,7 @@ namespace Mono.CSharp {
}
if (Parent.Parent != null && !Parent.IsClsComplianceRequired ()) {
Attribute a = OptAttributes.Search (PredefinedAttributes.Get.CLSCompliant);
Attribute a = OptAttributes.Search (Compiler.PredefinedAttributes.CLSCompliant);
Report.Warning (3018, 1, a.Location, "`{0}' cannot be marked as CLS-compliant because it is a member of non CLS-compliant type `{1}'",
GetSignatureForError (), Parent.GetSignatureForError ());
return false;
+25 -11
View File
@@ -22,10 +22,10 @@ namespace Mono.CSharp {
//
// Delegate container implementation
//
public class Delegate : TypeContainer
public class Delegate : TypeContainer, IParametersMember
{
FullNamedExpression ReturnType;
public readonly ParametersCompiled Parameters;
readonly ParametersCompiled parameters;
Constructor Constructor;
Method InvokeBuilder;
@@ -59,10 +59,24 @@ namespace Mono.CSharp {
ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod_flags,
IsTopLevel ? Modifiers.INTERNAL :
Modifiers.PRIVATE, name.Location, Report);
Parameters = param_list;
parameters = param_list;
spec = new TypeSpec (Kind, null, this, null, ModFlags | Modifiers.SEALED);
}
#region Properties
public TypeSpec MemberType {
get {
return ReturnType.Type;
}
}
public AParametersCollection Parameters {
get {
return parameters;
}
}
#endregion
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Target == AttributeTargets.ReturnValue) {
@@ -105,7 +119,7 @@ namespace Mono.CSharp {
// First, call the `out of band' special method for
// defining recursively any types we need:
//
var p = Parameters;
var p = parameters;
if (!p.Resolve (this))
return false;
@@ -217,7 +231,7 @@ namespace Mono.CSharp {
int param = 0;
for (int i = 0; i < Parameters.FixedParameters.Length; ++i) {
Parameter p = Parameters [i];
Parameter p = parameters [i];
if ((p.ModFlags & Parameter.Modifier.ISBYREF) == 0)
continue;
@@ -246,7 +260,7 @@ namespace Mono.CSharp {
public override void DefineConstants ()
{
if (!Parameters.IsEmpty) {
Parameters.ResolveDefaultValues (this);
parameters.ResolveDefaultValues (this);
}
}
@@ -254,11 +268,11 @@ namespace Mono.CSharp {
{
if (ReturnType.Type == InternalType.Dynamic) {
return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
PredefinedAttributes.Get.Dynamic.EmitAttribute (return_attributes.Builder);
Compiler.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
} else {
var trans_flags = TypeManager.HasDynamicTypeUsed (ReturnType.Type);
if (trans_flags != null) {
var pa = PredefinedAttributes.Get.DynamicTransform;
var pa = Compiler.PredefinedAttributes.DynamicTransform;
if (pa.Constructor != null || pa.ResolveConstructor (Location, ArrayContainer.MakeType (TypeManager.bool_type))) {
return_attributes = new ReturnParameter (this, InvokeBuilder.MethodBuilder, Location);
return_attributes.Builder.SetCustomAttribute (
@@ -267,13 +281,13 @@ namespace Mono.CSharp {
}
}
Parameters.ApplyAttributes (InvokeBuilder.MethodBuilder);
parameters.ApplyAttributes (this, InvokeBuilder.MethodBuilder);
Constructor.ConstructorBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
InvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
if (BeginInvokeBuilder != null) {
BeginInvokeBuilder.ParameterInfo.ApplyAttributes (BeginInvokeBuilder.MethodBuilder);
BeginInvokeBuilder.ParameterInfo.ApplyAttributes (this, BeginInvokeBuilder.MethodBuilder);
BeginInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
EndInvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
@@ -314,7 +328,7 @@ namespace Mono.CSharp {
return false;
}
Parameters.VerifyClsCompliance (this);
parameters.VerifyClsCompliance (this);
if (!ReturnType.Type.IsCLSCompliant ()) {
Report.Warning (3002, 1, Location, "Return type of `{0}' is not CLS-compliant",
+1 -1
View File
@@ -616,7 +616,7 @@ namespace Mono.CSharp {
xref.SetAttribute ("cref", "N:" + ns.GetSignatureForError ());
return; // a namespace
}
if (GlobalRootNamespace.Instance.IsNamespace (name)) {
if (mc.Compiler.GlobalRootNamespace.IsNamespace (name)) {
xref.SetAttribute ("cref", "N:" + name);
return; // a namespace
}
+6 -8
View File
@@ -413,9 +413,9 @@ namespace Mono.CSharp
// Extern aliased refs require special handling
if (alias == null)
GlobalRootNamespace.Instance.AddAssemblyReference (a);
ctx.GlobalRootNamespace.AddAssemblyReference (a);
else
GlobalRootNamespace.Instance.DefineRootNamespace (alias, a, ctx);
ctx.GlobalRootNamespace.DefineRootNamespace (alias, a, ctx);
} catch (BadImageFormatException f) {
// .NET 2.0 throws this if we try to load a module without an assembly manifest ...
@@ -455,7 +455,7 @@ namespace Mono.CSharp
}
}
GlobalRootNamespace.Instance.AddModuleReference (m);
ctx.GlobalRootNamespace.AddModuleReference (m);
} catch (BadImageFormatException f) {
Error9 ("module", f.FileName, f.FusionLog);
@@ -487,7 +487,7 @@ namespace Mono.CSharp
foreach (var entry in external_aliases)
LoadAssembly (entry.Value, entry.Key, false);
GlobalRootNamespace.Instance.ComputeNamespaces (ctx);
ctx.GlobalRootNamespace.ComputeNamespaces (ctx);
}
static string [] LoadArgs (string file)
@@ -1695,7 +1695,7 @@ namespace Mono.CSharp
set_method.Invoke (CodeGen.Assembly.Builder, BindingFlags.Default, null, new object[]{true}, null);
}
GlobalRootNamespace.Instance.AddModuleReference (RootContext.ToplevelTypes.Builder);
ctx.GlobalRootNamespace.AddModuleReference (RootContext.ToplevelTypes.Builder);
//
// Load assemblies required
@@ -1778,7 +1778,7 @@ namespace Mono.CSharp
if (timestamps)
ShowTime ("Closing types");
RootContext.CloseTypes ();
RootContext.CloseTypes (ctx);
PEFileKinds k = PEFileKinds.ConsoleApplication;
@@ -2031,13 +2031,11 @@ namespace Mono.CSharp
RootContext.Reset (full_flag);
TypeManager.Reset ();
PredefinedAttributes.Reset ();
ArrayContainer.Reset ();
ReferenceContainer.Reset ();
PointerContainer.Reset ();
Parameter.Reset ();
GlobalRootNamespace.Reset ();
Unary.Reset ();
Binary.Reset ();
ConstantFold.Reset ();
+12 -2
View File
@@ -1873,6 +1873,16 @@ namespace Mono.CSharp {
this.loc = orig_expr.Location;
}
#region Properties
public Expression OriginalExpression {
get {
return orig_expr;
}
}
#endregion
//
// Creates fully resolved expression switcher
//
@@ -2224,10 +2234,10 @@ namespace Mono.CSharp {
}
if (Arity == 0 && Name == "dynamic" && RootContext.Version > LanguageVersion.V_3) {
if (!PredefinedAttributes.Get.Dynamic.IsDefined) {
if (!ec.Compiler.PredefinedAttributes.Dynamic.IsDefined) {
ec.Compiler.Report.Error (1980, Location,
"Dynamic keyword requires `{0}' to be defined. Are you missing System.Core.dll assembly reference?",
PredefinedAttributes.Get.Dynamic.GetSignatureForError ());
ec.Compiler.PredefinedAttributes.Dynamic.GetSignatureForError ());
}
return new DynamicTypeExpr (loc);
+7 -45
View File
@@ -129,10 +129,11 @@ namespace Mono.CSharp {
CompilerCallableEntryPoint.Reset ();
RootContext.ToplevelTypes = new ModuleCompiled (ctx, true);
/*var ctypes = */TypeManager.InitCoreTypes ();
var ctypes = TypeManager.InitCoreTypes ();
ctx.MetaImporter.Initialize ();
driver.LoadReferences ();
TypeManager.InitCoreTypes (ctx, ctypes);
TypeManager.InitOptionalCoreTypes (ctx);
RootContext.EvalMode = true;
@@ -152,27 +153,8 @@ namespace Mono.CSharp {
CompilerCallableEntryPoint.PartialReset ();
RootContext.PartialReset ();
// Workaround for API limitation where full message printer cannot be passed
ReportPrinter printer;
if (MessageOutput == Console.Out || MessageOutput == Console.Error){
var console_reporter = new ConsoleReportPrinter (MessageOutput);
console_reporter.Fatal = driver.fatal_errors;
printer = console_reporter;
} else
printer = new StreamReportPrinter (MessageOutput);
ctx = new CompilerContext (new ReflectionMetaImporter (), new Report (printer));
RootContext.ToplevelTypes = new ModuleCompiled (ctx, true);
ctx.MetaImporter.Initialize ();
//
// PartialReset should not reset the core types, this is very redundant.
//
// if (!TypeManager.InitCoreTypes (ctx, null))
// throw new Exception ("Failed to InitCoreTypes");
// TypeManager.InitOptionalCoreTypes (ctx);
Location.AddFile (null, "{interactive}");
Location.Initialize ();
@@ -744,7 +726,7 @@ namespace Mono.CSharp {
return null;
}
RootContext.CloseTypes ();
RootContext.CloseTypes (ctx);
if (Environment.GetEnvironmentVariable ("SAVE") != null)
CodeGen.Save (current_debug_name, false, Report);
@@ -897,7 +879,7 @@ namespace Mono.CSharp {
{
lock (evaluator_lock){
driver.LoadAssembly (file, false);
GlobalRootNamespace.Instance.ComputeNamespaces (ctx);
ctx.GlobalRootNamespace.ComputeNamespaces (ctx);
}
}
@@ -909,7 +891,7 @@ namespace Mono.CSharp {
lock (evaluator_lock){
// GlobalRootNamespace.Instance.AddAssemblyReference (a);
// GlobalRootNamespace.Instance.ComputeNamespaces (ctx);
ctx.MetaImporter.ImportAssembly (a, GlobalRootNamespace.Instance);
ctx.MetaImporter.ImportAssembly (a, ctx.GlobalRootNamespace);
}
}
@@ -1204,32 +1186,12 @@ namespace Mono.CSharp {
}
// This means its really a statement.
if (clone.Type == TypeManager.void_type){
source = source.Resolve (ec);
target = null;
type = TypeManager.void_type;
eclass = ExprClass.Value;
return this;
if (clone.Type == TypeManager.void_type || clone is DynamicInvocation || clone is Assign) {
return clone;
}
return base.DoResolve (ec);
}
public override void Emit (EmitContext ec)
{
if (target == null)
source.Emit (ec);
else
base.Emit (ec);
}
public override void EmitStatement (EmitContext ec)
{
if (target == null)
source.Emit (ec);
else
base.EmitStatement (ec);
}
}
public class Undo {
+1 -1
View File
@@ -7174,7 +7174,7 @@ namespace Mono.CSharp {
public override FullNamedExpression ResolveAsTypeStep (IMemberContext ec, bool silent)
{
if (alias == GlobalAlias) {
expr = GlobalRootNamespace.Instance;
expr = ec.Compiler.GlobalRootNamespace;
return base.ResolveAsTypeStep (ec, silent);
}
+6 -6
View File
@@ -208,11 +208,11 @@ namespace Mono.CSharp
public override void Emit ()
{
if (member_type == InternalType.Dynamic) {
PredefinedAttributes.Get.Dynamic.EmitAttribute (FieldBuilder);
Compiler.PredefinedAttributes.Dynamic.EmitAttribute (FieldBuilder);
} else {
var trans_flags = TypeManager.HasDynamicTypeUsed (member_type);
if (trans_flags != null) {
var pa = PredefinedAttributes.Get.DynamicTransform;
var pa = Compiler.PredefinedAttributes.DynamicTransform;
if (pa.Constructor != null || pa.ResolveConstructor (Location, ArrayContainer.MakeType (TypeManager.bool_type, 1))) {
FieldBuilder.SetCustomAttribute (new CustomAttributeBuilder (pa.Constructor, new object[] { trans_flags }));
}
@@ -220,7 +220,7 @@ namespace Mono.CSharp
}
if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
PredefinedAttributes.Get.CompilerGenerated.EmitAttribute (FieldBuilder);
Compiler.PredefinedAttributes.CompilerGenerated.EmitAttribute (FieldBuilder);
if (OptAttributes != null) {
OptAttributes.Emit ();
@@ -436,7 +436,7 @@ namespace Mono.CSharp
buffer_size *= type_size;
EmitFieldSize (buffer_size);
PredefinedAttributes.Get.UnsafeValueType.EmitAttribute (fixed_buffer_type);
Compiler.PredefinedAttributes.UnsafeValueType.EmitAttribute (fixed_buffer_type);
base.Emit ();
}
@@ -446,7 +446,7 @@ namespace Mono.CSharp
CustomAttributeBuilder cab;
PredefinedAttribute pa;
pa = PredefinedAttributes.Get.StructLayout;
pa = Compiler.PredefinedAttributes.StructLayout;
if (pa.Constructor == null &&
!pa.ResolveConstructor (Location, TypeManager.short_type))
return;
@@ -468,7 +468,7 @@ namespace Mono.CSharp
if ((ModFlags & Modifiers.PRIVATE) != 0)
return;
pa = PredefinedAttributes.Get.FixedBuffer;
pa = Compiler.PredefinedAttributes.FixedBuffer;
if (pa.Constructor == null &&
!pa.ResolveConstructor (Location, TypeManager.type_type, TypeManager.int32_type))
return;
+3 -5
View File
@@ -566,13 +566,11 @@ namespace Mono.CSharp
} else {
kind = MemberKind.Class;
if (type == typeof (object)) {
#if NET_4_0
var pa = PredefinedAttributes.Get.Dynamic.Type;
if (pa != null && type.IsDefined (typeof (DynamicAttribute), false))
return InternalType.Dynamic;
#endif
if (type == typeof (object) && type.IsDefined (typeof (DynamicAttribute), false)) {
return InternalType.Dynamic;
}
#endif
if ((ma & TypeAttributes.Sealed) != 0) {
mod |= Modifiers.SEALED;
+22 -6
View File
@@ -510,10 +510,18 @@ namespace Mono.CSharp {
}
//
// Is the member of the correct type ?
// Destructors are ignored as they cannot be overridden by user
// Is the member of same type ?
//
if ((entry.Kind & ~MemberKind.Destructor & mkind & MemberKind.MaskType) == 0) {
if ((entry.Kind & MemberKind.Destructor) == 0 && (member_param == null || !(entry is IParametersMember))) {
// Destructors are ignored as they cannot be overridden by user
if ((entry.Kind & MemberKind.Destructor) != 0)
continue;
// Only different arity methods hide
if (mkind != MemberKind.Method && member.MemberName.Arity != entry.Arity)
continue;
if ((member_param == null || !(entry is IParametersMember))) {
bestCandidate = entry;
return null;
}
@@ -535,13 +543,21 @@ namespace Mono.CSharp {
continue;
var pm = entry as IParametersMember;
if (pm == null)
continue;
AParametersCollection entry_parameters;
if (pm == null) {
if (entry.Kind != MemberKind.Delegate)
continue;
// TODO: I don't have DelegateSpec
entry_parameters = Delegate.GetParameters (member.Compiler, (TypeSpec) entry);
} else {
entry_parameters = pm.Parameters;
}
if (entry.IsAccessor != member is AbstractPropertyEventMethod)
continue;
if (!TypeSpecComparer.Override.IsEqual (pm.Parameters, member_param))
if (!TypeSpecComparer.Override.IsEqual (entry_parameters, member_param))
continue;
}
+17 -15
View File
@@ -580,17 +580,17 @@ namespace Mono.CSharp {
public override void Emit ()
{
if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
PredefinedAttributes.Get.CompilerGenerated.EmitAttribute (MethodBuilder);
Compiler.PredefinedAttributes.CompilerGenerated.EmitAttribute (MethodBuilder);
if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
PredefinedAttributes.Get.DebuggerHidden.EmitAttribute (MethodBuilder);
Compiler.PredefinedAttributes.DebuggerHidden.EmitAttribute (MethodBuilder);
if (ReturnType == InternalType.Dynamic) {
return_attributes = new ReturnParameter (this, MethodBuilder, Location);
PredefinedAttributes.Get.Dynamic.EmitAttribute (return_attributes.Builder);
Compiler.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
} else {
var trans_flags = TypeManager.HasDynamicTypeUsed (ReturnType);
if (trans_flags != null) {
var pa = PredefinedAttributes.Get.DynamicTransform;
var pa = Compiler.PredefinedAttributes.DynamicTransform;
if (pa.Constructor != null || pa.ResolveConstructor (Location, ArrayContainer.MakeType (TypeManager.bool_type))) {
return_attributes = new ReturnParameter (this, MethodBuilder, Location);
return_attributes.Builder.SetCustomAttribute (
@@ -674,7 +674,7 @@ namespace Mono.CSharp {
if (OptAttributes == null)
return null;
Attribute[] attrs = OptAttributes.SearchMulti (PredefinedAttributes.Get.Conditional);
Attribute[] attrs = OptAttributes.SearchMulti (Compiler.PredefinedAttributes.Conditional);
if (attrs == null)
return null;
@@ -1030,7 +1030,7 @@ namespace Mono.CSharp {
Report.Error (1109, Location, "`{0}': Extension methods cannot be defined in a nested class",
GetSignatureForError ());
PredefinedAttribute pa = PredefinedAttributes.Get.Extension;
PredefinedAttribute pa = Compiler.PredefinedAttributes.Extension;
if (!pa.IsDefined) {
Report.Error (1110, Location,
"`{0}': Extension methods cannot be declared without a reference to System.Core.dll assembly. Add the assembly reference or remove `this' modifer from the first parameter",
@@ -1120,7 +1120,7 @@ namespace Mono.CSharp {
base.Emit ();
if ((ModFlags & Modifiers.METHOD_EXTENSION) != 0)
PredefinedAttributes.Get.Extension.EmitAttribute (MethodBuilder);
Compiler.PredefinedAttributes.Extension.EmitAttribute (MethodBuilder);
} catch {
Console.WriteLine ("Internal compiler error at {0}: exception caught while emitting {1}",
Location, MethodBuilder);
@@ -1451,7 +1451,7 @@ namespace Mono.CSharp {
}
if ((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0)
PredefinedAttributes.Get.DebuggerHidden.EmitAttribute (ConstructorBuilder);
Compiler.PredefinedAttributes.DebuggerHidden.EmitAttribute (ConstructorBuilder);
if (OptAttributes != null)
OptAttributes.Emit ();
@@ -1488,7 +1488,7 @@ namespace Mono.CSharp {
}
}
parameters.ApplyAttributes (ConstructorBuilder);
parameters.ApplyAttributes (this, ConstructorBuilder);
SourceMethod source = SourceMethod.Create (Parent, ConstructorBuilder, block);
@@ -1861,13 +1861,15 @@ namespace Mono.CSharp {
if (GenericMethod != null)
GenericMethod.EmitAttributes ();
method.ParameterInfo.ApplyAttributes (MethodBuilder);
var mc = (IMemberContext) method;
method.ParameterInfo.ApplyAttributes (mc, MethodBuilder);
SourceMethod source = SourceMethod.Create (parent, MethodBuilder, method.Block);
ToplevelBlock block = method.Block;
if (block != null) {
BlockContext bc = new BlockContext ((IMemberContext) method, block, method.ReturnType);
BlockContext bc = new BlockContext (mc, block, method.ReturnType);
if (block.Resolve (null, bc, method.ParameterInfo, method)) {
EmitContext ec = method.CreateEmitContext (MethodBuilder.GetILGenerator ());
if (!ec.HasReturnLabel && bc.HasReturnLabel) {
@@ -2097,17 +2099,17 @@ namespace Mono.CSharp {
method_data.Emit (parent);
if ((ModFlags & Modifiers.COMPILER_GENERATED) != 0 && !Parent.IsCompilerGenerated)
PredefinedAttributes.Get.CompilerGenerated.EmitAttribute (method_data.MethodBuilder);
Compiler.PredefinedAttributes.CompilerGenerated.EmitAttribute (method_data.MethodBuilder);
if (((ModFlags & Modifiers.DEBUGGER_HIDDEN) != 0))
PredefinedAttributes.Get.DebuggerHidden.EmitAttribute (method_data.MethodBuilder);
Compiler.PredefinedAttributes.DebuggerHidden.EmitAttribute (method_data.MethodBuilder);
if (ReturnType == InternalType.Dynamic) {
return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location);
PredefinedAttributes.Get.Dynamic.EmitAttribute (return_attributes.Builder);
Compiler.PredefinedAttributes.Dynamic.EmitAttribute (return_attributes.Builder);
} else {
var trans_flags = TypeManager.HasDynamicTypeUsed (ReturnType);
if (trans_flags != null) {
var pa = PredefinedAttributes.Get.DynamicTransform;
var pa = Compiler.PredefinedAttributes.DynamicTransform;
if (pa.Constructor != null || pa.ResolveConstructor (Location, ArrayContainer.MakeType (TypeManager.bool_type))) {
return_attributes = new ReturnParameter (this, method_data.MethodBuilder, Location);
return_attributes.Builder.SetCustomAttribute (
+20 -22
View File
@@ -83,24 +83,18 @@ namespace Mono.CSharp {
}
}
// TODO: It should go to AssemblyClass or AssemblySpec
public class GlobalRootNamespace : RootNamespace {
Module [] modules;
Dictionary<string, RootNamespace> root_namespaces;
public static GlobalRootNamespace Instance = new GlobalRootNamespace ();
GlobalRootNamespace ()
public GlobalRootNamespace ()
: base ("global")
{
root_namespaces = new Dictionary<string, RootNamespace> ();
root_namespaces.Add (alias_name, this);
}
public static void Reset ()
{
Instance = new GlobalRootNamespace ();
}
public Assembly [] Assemblies {
get { return referenced_assemblies; }
}
@@ -694,9 +688,9 @@ namespace Mono.CSharp {
this.Location = loc;
}
public virtual FullNamedExpression Resolve (IMemberContext rc)
public virtual FullNamedExpression Resolve (IMemberContext rc, bool local)
{
FullNamedExpression fne = GlobalRootNamespace.Instance.GetRootNamespace (Alias);
FullNamedExpression fne = rc.Compiler.GlobalRootNamespace.GetRootNamespace (Alias);
if (fne == null) {
rc.Compiler.Report.Error (430, Location,
"The extern alias `{0}' was not specified in -reference option",
@@ -723,12 +717,12 @@ namespace Mono.CSharp {
this.value = name;
}
public override FullNamedExpression Resolve (IMemberContext rc)
public override FullNamedExpression Resolve (IMemberContext rc, bool local)
{
if (resolved != null || value == null)
return resolved;
if (rc == null)
if (local)
return null;
resolved = value.GetTypeExpression ().ResolveAsTypeStep (rc, false);
@@ -764,6 +758,7 @@ namespace Mono.CSharp {
public readonly DeclSpace SlaveDeclSpace;
static readonly Namespace [] empty_namespaces = new Namespace [0];
Namespace [] namespace_using_table;
CompilerContext ctx;
static List<NamespaceEntry> entries = new List<NamespaceEntry> ();
@@ -772,8 +767,10 @@ namespace Mono.CSharp {
entries = new List<NamespaceEntry> ();
}
public NamespaceEntry (NamespaceEntry parent, CompilationUnit file, string name)
// TODO: ctx should be a module
public NamespaceEntry (CompilerContext ctx, NamespaceEntry parent, CompilationUnit file, string name)
{
this.ctx = ctx;
this.parent = parent;
this.file = file;
entries.Add (this);
@@ -781,14 +778,15 @@ namespace Mono.CSharp {
if (parent != null)
ns = parent.NS.GetNamespace (name, true);
else if (name != null)
ns = GlobalRootNamespace.Instance.GetNamespace (name, true);
ns = Compiler.GlobalRootNamespace.GetNamespace (name, true);
else
ns = GlobalRootNamespace.Instance;
ns = Compiler.GlobalRootNamespace;
SlaveDeclSpace = new RootDeclSpace (this);
}
private NamespaceEntry (NamespaceEntry parent, CompilationUnit file, Namespace ns, bool slave)
private NamespaceEntry (CompilerContext ctx, NamespaceEntry parent, CompilationUnit file, Namespace ns, bool slave)
{
this.ctx = ctx;
this.parent = parent;
this.file = file;
this.IsImplicit = true;
@@ -871,7 +869,7 @@ namespace Mono.CSharp {
NamespaceEntry Doppelganger {
get {
if (!IsImplicit && doppelganger == null) {
doppelganger = new NamespaceEntry (ImplicitParent, file, ns, true);
doppelganger = new NamespaceEntry (ctx, ImplicitParent, file, ns, true);
doppelganger.using_aliases = using_aliases;
}
return doppelganger;
@@ -893,7 +891,7 @@ namespace Mono.CSharp {
if (implicit_parent == null) {
implicit_parent = (parent.NS == ns.Parent)
? parent
: new NamespaceEntry (parent, file, ns.Parent, false);
: new NamespaceEntry (ctx, parent, file, ns.Parent, false);
}
return implicit_parent;
}
@@ -1064,7 +1062,7 @@ namespace Mono.CSharp {
foreach (UsingAliasEntry ue in n.using_aliases) {
if (ue.Alias == name)
return ue.Resolve (Doppelganger);
return ue.Resolve (Doppelganger ?? this, Doppelganger == null);
}
}
@@ -1097,7 +1095,7 @@ namespace Mono.CSharp {
}
}
return ue.Resolve (Doppelganger);
return ue.Resolve (Doppelganger ?? this, Doppelganger == null);
}
}
}
@@ -1251,7 +1249,7 @@ namespace Mono.CSharp {
{
if (using_aliases != null) {
foreach (UsingAliasEntry ue in using_aliases)
ue.Resolve (Doppelganger);
ue.Resolve (Doppelganger, Doppelganger == null);
}
if (using_clauses != null) {
@@ -1283,7 +1281,7 @@ namespace Mono.CSharp {
#region IMemberContext Members
public CompilerContext Compiler {
get { return RootContext.ToplevelTypes.Compiler; }
get { return ctx; }
}
public TypeSpec CurrentType {
+16 -15
View File
@@ -180,10 +180,10 @@ namespace Mono.CSharp {
return parameter_type;
}
public override void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index)
public override void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index, PredefinedAttributes pa)
{
base.ApplyAttributes (mb, cb, index);
PredefinedAttributes.Get.ParamArray.EmitAttribute (builder);
base.ApplyAttributes (mb, cb, index, pa);
pa.ParamArray.EmitAttribute (builder);
}
}
@@ -195,7 +195,7 @@ namespace Mono.CSharp {
parameter_type = InternalType.Arglist;
}
public override void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index)
public override void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index, PredefinedAttributes pa)
{
// Nothing to do
}
@@ -293,7 +293,7 @@ namespace Mono.CSharp {
return;
}
if (a.Type == PredefinedAttributes.Get.Out && (ModFlags & Modifier.REF) == Modifier.REF &&
if (a.Type == pa.Out && (ModFlags & Modifier.REF) == Modifier.REF &&
!OptAttributes.Contains (pa.In)) {
a.Report.Error (662, a.Location,
"Cannot specify only `Out' attribute on a ref parameter. Use both `In' and `Out' attributes or neither");
@@ -408,7 +408,7 @@ namespace Mono.CSharp {
if (attributes == null)
return;
var pa = attributes.Search (PredefinedAttributes.Get.OptionalParameter);
var pa = attributes.Search (rc.Compiler.PredefinedAttributes.OptionalParameter);
if (pa == null)
return;
@@ -418,7 +418,7 @@ namespace Mono.CSharp {
attributes.Attrs.Remove (pa);
TypeSpec expr_type = null;
pa = attributes.Search (PredefinedAttributes.Get.DefaultParameterValue);
pa = attributes.Search (rc.Compiler.PredefinedAttributes.DefaultParameterValue);
if (pa != null) {
attributes.Attrs.Remove (pa);
default_expr = pa.GetParameterDefaultValue (out expr_type);
@@ -564,7 +564,7 @@ namespace Mono.CSharp {
"Argument type `{0}' is not CLS-compliant", GetSignatureForError ());
}
public virtual void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index)
public virtual void ApplyAttributes (MethodBuilder mb, ConstructorBuilder cb, int index, PredefinedAttributes pa)
{
if (mb == null)
builder = cb.DefineParameter (index, Attributes, Name);
@@ -582,7 +582,7 @@ namespace Mono.CSharp {
Constant c = default_expr as Constant;
if (c != null) {
if (default_expr.Type == TypeManager.decimal_type) {
builder.SetCustomAttribute (Const.CreateDecimalConstantAttribute (c));
builder.SetCustomAttribute (Const.CreateDecimalConstantAttribute (c, pa));
} else {
builder.SetConstant (c.GetTypedValue ());
}
@@ -590,14 +590,14 @@ namespace Mono.CSharp {
}
if (parameter_type == InternalType.Dynamic) {
PredefinedAttributes.Get.Dynamic.EmitAttribute (builder);
pa.Dynamic.EmitAttribute (builder);
} else {
var trans_flags = TypeManager.HasDynamicTypeUsed (parameter_type);
if (trans_flags != null) {
var pa = PredefinedAttributes.Get.DynamicTransform;
if (pa.Constructor != null || pa.ResolveConstructor (Location, ArrayContainer.MakeType (TypeManager.bool_type))) {
var dt = pa.DynamicTransform;
if (dt.Constructor != null || dt.ResolveConstructor (Location, ArrayContainer.MakeType (TypeManager.bool_type))) {
builder.SetCustomAttribute (
new CustomAttributeBuilder (pa.Constructor, new object [] { trans_flags }));
new CustomAttributeBuilder (dt.Constructor, new object [] { trans_flags }));
}
}
}
@@ -1179,16 +1179,17 @@ namespace Mono.CSharp {
// Define each type attribute (in/out/ref) and
// the argument names.
public void ApplyAttributes (MethodBase builder)
public void ApplyAttributes (IMemberContext mc, MethodBase builder)
{
if (Count == 0)
return;
MethodBuilder mb = builder as MethodBuilder;
ConstructorBuilder cb = builder as ConstructorBuilder;
var pa = mc.Compiler.PredefinedAttributes;
for (int i = 0; i < Count; i++) {
this [i].ApplyAttributes (mb, cb, i + 1);
this [i].ApplyAttributes (mb, cb, i + 1, pa);
}
}
+4 -4
View File
@@ -655,11 +655,11 @@ namespace Mono.CSharp
OptAttributes.Emit ();
if (member_type == InternalType.Dynamic) {
PredefinedAttributes.Get.Dynamic.EmitAttribute (PropertyBuilder);
Compiler.PredefinedAttributes.Dynamic.EmitAttribute (PropertyBuilder);
} else {
var trans_flags = TypeManager.HasDynamicTypeUsed (member_type);
if (trans_flags != null) {
var pa = PredefinedAttributes.Get.DynamicTransform;
var pa = Compiler.PredefinedAttributes.DynamicTransform;
if (pa.Constructor != null || pa.ResolveConstructor (Location, ArrayContainer.MakeType (TypeManager.bool_type))) {
PropertyBuilder.SetCustomAttribute (
new CustomAttributeBuilder (pa.Constructor, new object[] { trans_flags }));
@@ -1112,7 +1112,7 @@ namespace Mono.CSharp
return null;
MethodBuilder mb = method_data.MethodBuilder;
ParameterInfo.ApplyAttributes (mb);
ParameterInfo.ApplyAttributes (this, mb);
Spec = new MethodSpec (MemberKind.Method, parent.PartialContainer.Definition, this, ReturnType, mb, ParameterInfo, method.ModFlags);
Spec.IsAccessor = true;
@@ -1442,7 +1442,7 @@ namespace Mono.CSharp
return false;
if (OptAttributes != null) {
Attribute indexer_attr = OptAttributes.Search (PredefinedAttributes.Get.IndexerName);
Attribute indexer_attr = OptAttributes.Search (Compiler.PredefinedAttributes.IndexerName);
if (indexer_attr != null) {
var compiling = indexer_attr.Type.MemberDefinition as TypeContainer;
if (compiling != null)
+3 -2
View File
@@ -272,7 +272,7 @@ namespace Mono.CSharp {
// methods, fields, etc) we need to "Define" them before we
// can save the Assembly
// </remarks>
static public void CloseTypes ()
static public void CloseTypes (CompilerContext ctx)
{
HackCorlibEnums ();
@@ -288,8 +288,9 @@ namespace Mono.CSharp {
// If we have a <PrivateImplementationDetails> class, close it
//
if (helper_classes != null){
var cg = ctx.PredefinedAttributes.CompilerGenerated;
foreach (TypeBuilder type_builder in helper_classes) {
PredefinedAttributes.Get.CompilerGenerated.EmitAttribute (type_builder);
cg.EmitAttribute (type_builder);
type_builder.CreateType ();
}
}
+1 -1
View File
@@ -217,7 +217,7 @@ namespace Mono.CSharp
if (!OptAttributes.CheckTargets ())
return;
Attribute a = ResolveAttribute (PredefinedAttributes.Get.DefaultCharset);
Attribute a = ResolveAttribute (Compiler.PredefinedAttributes.DefaultCharset);
if (a != null) {
has_default_charset = true;
DefaultCharSet = a.GetCharSetValue ();
+3 -2
View File
@@ -4742,8 +4742,9 @@ namespace Mono.CSharp {
if (General != null) {
if (CodeGen.Assembly.WrapNonExceptionThrows) {
foreach (Catch c in Specific){
if (c.CatchType == TypeManager.exception_type && PredefinedAttributes.Get.RuntimeCompatibility.IsDefined) {
ec.Report.Warning (1058, 1, c.loc, "A previous catch clause already catches all exceptions. All non-exceptions thrown will be wrapped in a `System.Runtime.CompilerServices.RuntimeWrappedException'");
if (c.CatchType == TypeManager.exception_type && ec.Compiler.PredefinedAttributes.RuntimeCompatibility.IsDefined) {
ec.Report.Warning (1058, 1, c.loc,
"A previous catch clause already catches all exceptions. All non-exceptions thrown will be wrapped in a `System.Runtime.CompilerServices.RuntimeWrappedException'");
}
}
}
+5 -5
View File
@@ -226,7 +226,7 @@ namespace Mono.CSharp {
public static TypeSpec CoreLookupType (CompilerContext ctx, string ns_name, string name, int arity, MemberKind kind, bool required)
{
Namespace ns = GlobalRootNamespace.Instance.GetNamespace (ns_name, true);
Namespace ns = ctx.GlobalRootNamespace.GetNamespace (ns_name, true);
var te = ns.LookupType (ctx, name, arity, !required, Location.Null);
var ts = te == null ? null : te.Type;
@@ -355,7 +355,7 @@ namespace Mono.CSharp {
continue;
if (!RootContext.StdLib) {
var ns = GlobalRootNamespace.Instance.GetNamespace (p.Namespace, false);
var ns = ctx.GlobalRootNamespace.GetNamespace (p.Namespace, false);
ns.ReplaceTypeWithPredefined (found, p);
var tc = found.MemberDefinition as TypeContainer;
@@ -364,8 +364,8 @@ namespace Mono.CSharp {
}
}
PredefinedAttributes.Get.ParamArray.Initialize (ctx, false);
PredefinedAttributes.Get.Out.Initialize (ctx, false);
ctx.PredefinedAttributes.ParamArray.Initialize (ctx, false);
ctx.PredefinedAttributes.Out.Initialize (ctx, false);
if (InternalType.Dynamic.GetMetaInfo () == null) {
InternalType.Dynamic.SetMetaInfo (object_type.GetMetaInfo ());
@@ -390,7 +390,7 @@ namespace Mono.CSharp {
// Initialize InternalsVisibleTo as the very first optional type. Otherwise we would populate
// types cache with incorrect accessiblity when any of optional types is internal.
//
PredefinedAttributes.Get.Initialize (ctx);
ctx.PredefinedAttributes.Initialize (ctx);
runtime_argument_handle_type = CoreLookupType (ctx, "System", "RuntimeArgumentHandle", MemberKind.Struct, false);
asynccallback_type = CoreLookupType (ctx, "System", "AsyncCallback", MemberKind.Delegate, false);
@@ -1973,15 +1973,12 @@ class MDocUpdater : MDocCommand
break;
}
default: {
bool dup = false;
foreach (XmlElement n in e.SelectNodes (child.Name))
if (n.OuterXml == child.OuterXml) {
dup = true;
break;
}
if (!dup) {
bool add = true;
if (child.NodeType == XmlNodeType.Element &&
e.SelectNodes (child.Name).Cast<XmlElement>().Any (n => n.OuterXml == child.OuterXml))
add = false;
if (add)
CopyNode (child, e);
}
break;
}
}
+6 -1
View File
@@ -3,9 +3,14 @@ SUBDIRS =
include ../../build/rules.make
HAS_NUNIT_TEST = yes
BUILD_FRAMEWORK = Microsoft.Build.Framework.dll
BUILD_ENGINE = Microsoft.Build.Engine.dll
ifeq (3.5, $(FRAMEWORK_VERSION))
NAME_SUFFIX = .v3.5
ASSEMBLY_VERSION = 3.5.0.0
BUILD_FRAMEWORK := $(topdir)/class/lib/$(PROFILE)/$(BUILD_FRAMEWORK)
BUILD_ENGINE := $(topdir)/class/lib/$(PROFILE)/$(BUILD_ENGINE)
else
ifeq (4.0, $(FRAMEWORK_VERSION))
NAME_SUFFIX = .v4.0
@@ -13,7 +18,7 @@ ASSEMBLY_VERSION = 4.0.0.0
endif
endif
LOCAL_MCS_FLAGS = -r:Microsoft.Build.Framework.dll -r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll -r:Microsoft.Build.Engine.dll
LOCAL_MCS_FLAGS = -r:$(BUILD_FRAMEWORK) -r:Microsoft.Build.Utilities$(NAME_SUFFIX).dll -r:$(BUILD_ENGINE)
PROGRAM = $(topdir)/class/lib/$(PROFILE)/xbuild.exe
include ../../build/executable.make
+83 -44
View File
@@ -7,21 +7,19 @@
%define sgen no
%endif
%if %llvm == yes
%define enable_llvm --enable-loadedllvm
%endif
Name: mono-core
License: LGPL v2.1 only
Group: Development/Languages/Mono
Summary: A .NET Runtime Environment
Url: http://www.mono-project.com
Version: @VERSION@
Release: 30
Release: 0
Source0: mono-%{version}.tar.bz2
BuildRequires: bison
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: pkgconfig
BuildRequires: xorg-x11-libX11-devel
BuildRequires: zlib-devel
%ifnarch ia64
BuildRequires: valgrind-devel
@@ -51,6 +49,9 @@ Conflicts: f-spot < 0.4
Conflicts: helix-banshee < 1.0
Conflicts: mono-addins < 0.3.1
Recommends: libgdiplus0 >= 2.6
%if %llvm == yes
Recommends: libmono-llvm0 = %{version}-%{release}
%endif
Provides: mono(Commons.Xml.Relaxng) = 1.0.5000.0
Provides: mono(CustomMarshalers) = 1.0.5000.0
Provides: mono(I18N) = 1.0.5000.0
@@ -67,6 +68,7 @@ Provides: mono(System.Security) = 1.0.5000.0
Provides: mono(System.Xml) = 1.0.5000.0
Provides: mono(mscorlib) = 1.0.5000.0
%define _use_internal_dependency_generator 0
%define __find_provides env sh -c 'filelist=($(cat)) && { printf "%s\\n" "${filelist[@]}" | /usr/lib/rpm/find-provides && printf "%s\\n" "${filelist[@]}" | prefix=%{buildroot}%{_prefix} %{buildroot}%{_bindir}/mono-find-provides ; } | sort | uniq'
%define __find_requires env sh -c 'filelist=($(cat)) && { printf "%s\\n" "${filelist[@]}" | /usr/lib/rpm/find-requires && printf "%s\\n" "${filelist[@]}" | prefix=%{buildroot}%{_prefix} %{buildroot}%{_bindir}/mono-find-requires ; } | sort | uniq'
@@ -91,9 +93,15 @@ export CFLAGS=" $RPM_OPT_FLAGS -fno-strict-aliasing"
export PATH=/opt/novell/llvm-mono/bin:$PATH
%endif
%configure \
--with-ikvm=yes \
--with-sgen=%{sgen} \
%{?enable_llvm} \
%if %llvm == yes
--enable-loadedllvm \
--disable-system-aot \
%endif
%ifnarch %ix86 x86_64
--disable-system-aot \
%endif
--with-ikvm=yes \
--with-moonlight=no
make # We are not -jN safe! %{?jobs:-j%jobs}
@@ -118,9 +126,10 @@ rm -f %buildroot%_prefix/lib/mono/*/culevel.exe*
rm -f %buildroot%_prefix/lib/mono/2.0/cilc.exe*
# brp-compress doesn't search _mandir
# so we cheat it
ln -s . %buildroot%_prefix/usr
ln -s . %buildroot%_prefix%_prefix
RPM_BUILD_ROOT=%buildroot%_prefix /usr/lib/rpm/brp-compress
rm %buildroot%_prefix/usr
rm %buildroot%_prefix%_prefix
%fdupes %buildroot%_prefix
%find_lang mcs
%clean
@@ -144,6 +153,8 @@ rm -rf %buildroot
%dir %_sysconfdir/mono
%dir %_sysconfdir/mono/2.0
%dir %_sysconfdir/mono/4.0
%_bindir/al
%_bindir/al2
%_bindir/certmgr
%_bindir/chktrust
%_bindir/csharp
@@ -199,6 +210,7 @@ rm -rf %buildroot
%_prefix/lib/mono/2.0/System.Xml.Linq.dll
%_prefix/lib/mono/2.0/System.Xml.dll
%_prefix/lib/mono/2.0/System.dll
%_prefix/lib/mono/2.0/al.exe*
%_prefix/lib/mono/2.0/cscompmgd.dll
%_prefix/lib/mono/2.0/csharp.exe*
%_prefix/lib/mono/2.0/gacutil.exe*
@@ -230,6 +242,7 @@ rm -rf %buildroot
%_prefix/lib/mono/4.0/System.Xml.Linq.dll
%_prefix/lib/mono/4.0/System.Xml.dll
%_prefix/lib/mono/4.0/System.dll
%_prefix/lib/mono/4.0/al.exe*
%_prefix/lib/mono/4.0/certmgr.exe*
%_prefix/lib/mono/4.0/chktrust.exe*
%_prefix/lib/mono/4.0/cscompmgd.dll
@@ -299,6 +312,7 @@ A Library for embedding Mono in your Application.
License: LGPL v2.1 only
Summary: Development files for libmono
Group: Development/Languages/Mono
Requires: mono-core == %version-%release
%description -n libmono-2_0-devel
The Mono Project is an open development initiative that is working to
@@ -343,6 +357,7 @@ A Library for embedding Mono in your Application (sgen version).
License: LGPL v2.1 only
Summary: Development files for libmonosgen
Group: Development/Languages/Mono
Requires: mono-core == %version-%release
%description -n libmonosgen-2_0-devel
The Mono Project is an open development initiative that is working to
@@ -428,7 +443,6 @@ Obsoletes: mono-novell-directory
Provides: mono-directory
Provides: mono-ms-enterprise
Provides: mono-novell-directory
Provides: mono(Mono.Data) = 1.0.5000.0
Provides: mono(Mono.Data.Tds) = 1.0.5000.0
Provides: mono(Novell.Directory.Ldap) = 1.0.5000.0
Provides: mono(System.Data) = 1.0.5000.0
@@ -453,19 +467,19 @@ Database connectivity for Mono.
%_prefix/lib/mono/2.0/Novell.Directory.Ldap.dll
%_prefix/lib/mono/2.0/System.Data.DataSetExtensions.dll
%_prefix/lib/mono/2.0/System.Data.Linq.dll
%_prefix/lib/mono/2.0/System.Data.Services.dll
%_prefix/lib/mono/2.0/System.Data.dll
%_prefix/lib/mono/2.0/System.DirectoryServices.dll
%_prefix/lib/mono/2.0/System.EnterpriseServices.dll
%_prefix/lib/mono/2.0/System.Runtime.Serialization.dll
%_prefix/lib/mono/2.0/System.Transactions.dll
%_prefix/lib/mono/4.0/Mono.Data.Tds.dll
%_prefix/lib/mono/4.0/Novell.Directory.Ldap.dll
%_prefix/lib/mono/4.0/System.Data.DataSetExtensions.dll
%_prefix/lib/mono/4.0/System.Data.Linq.dll
%_prefix/lib/mono/4.0/System.Data.Services.dll
%_prefix/lib/mono/4.0/System.Data.dll
%_prefix/lib/mono/4.0/System.DirectoryServices.dll
%_prefix/lib/mono/4.0/System.EnterpriseServices.dll
%_prefix/lib/mono/4.0/System.Runtime.Serialization.dll
%_prefix/lib/mono/4.0/System.Transactions.dll
%_prefix/lib/mono/4.0/sqlmetal.exe*
%_prefix/lib/mono/4.0/sqlsharp.exe*
@@ -474,9 +488,9 @@ Database connectivity for Mono.
%_prefix/lib/mono/gac/System.Data
%_prefix/lib/mono/gac/System.Data.DataSetExtensions
%_prefix/lib/mono/gac/System.Data.Linq
%_prefix/lib/mono/gac/System.Data.Services
%_prefix/lib/mono/gac/System.DirectoryServices
%_prefix/lib/mono/gac/System.EnterpriseServices
%_prefix/lib/mono/gac/System.Runtime.Serialization
%_prefix/lib/mono/gac/System.Transactions
%package -n mono-winforms
@@ -646,31 +660,28 @@ Mono implementation of WCF, Windows Communication Foundation
%defattr(-, root, root)
%_bindir/svcutil
%_libdir/pkgconfig/wcf.pc
%_prefix/lib/mono/2.0/System.Data.Services.dll
%_prefix/lib/mono/2.0/System.IdentityModel.Selectors.dll
%_prefix/lib/mono/2.0/System.IdentityModel.dll
%_prefix/lib/mono/2.0/System.Runtime.Serialization.dll
%_prefix/lib/mono/2.0/System.ServiceModel.Web.dll
%_prefix/lib/mono/2.0/System.ServiceModel.dll
%_prefix/lib/mono/4.0/System.Data.Services.dll
%_prefix/lib/mono/4.0/System.IdentityModel.Selectors.dll
%_prefix/lib/mono/4.0/System.IdentityModel.dll
%_prefix/lib/mono/4.0/System.Runtime.DurableInstancing.dll
%_prefix/lib/mono/4.0/System.Runtime.Serialization.dll
%_prefix/lib/mono/4.0/System.ServiceModel.Discovery.dll
%_prefix/lib/mono/4.0/System.ServiceModel.Routing.dll
%_prefix/lib/mono/4.0/System.ServiceModel.Web.dll
%_prefix/lib/mono/4.0/System.ServiceModel.dll
%_prefix/lib/mono/4.0/System.Web.ApplicationServices.dll
%_prefix/lib/mono/4.0/svcutil.exe*
%_prefix/lib/mono/gac/System.Data.Services.Client
%_prefix/lib/mono/gac/System.Data.Services
%_prefix/lib/mono/gac/System.IdentityModel
%_prefix/lib/mono/gac/System.IdentityModel.Selectors
%_prefix/lib/mono/gac/System.Runtime.DurableInstancing
%_prefix/lib/mono/gac/System.Runtime.Serialization
%_prefix/lib/mono/gac/System.ServiceModel
%_prefix/lib/mono/gac/System.ServiceModel.Discovery
%_prefix/lib/mono/gac/System.ServiceModel.Routing
%_prefix/lib/mono/gac/System.ServiceModel.Web
%_prefix/lib/mono/gac/System.Web.ApplicationServices
%package -n mono-winfxcore
License: MIT License (or similar) ; Ms-Pl
@@ -691,6 +702,7 @@ Mono implementation of core WinFX APIs
%defattr(-, root, root)
%_prefix/lib/mono/2.0/WindowsBase.dll*
%_prefix/lib/mono/4.0/WindowsBase.dll*
%_prefix/lib/mono/gac/System.Data.Services.Client
%_prefix/lib/mono/gac/WindowsBase
%package -n mono-web
@@ -724,6 +736,7 @@ Mono implementation of ASP.NET, Remoting and Web Services.
%config %_sysconfdir/mono/2.0/Browsers
%config %_sysconfdir/mono/2.0/DefaultWsdlHelpGenerator.aspx
%config %_sysconfdir/mono/2.0/web.config
%config %_sysconfdir/mono/4.0/DefaultWsdlHelpGenerator.aspx
%config %_sysconfdir/mono/4.0/web.config
%config %_sysconfdir/mono/browscap.ini
%config %_sysconfdir/mono/mconfig/config.xml
@@ -735,10 +748,6 @@ Mono implementation of ASP.NET, Remoting and Web Services.
%_bindir/wsdl2
%_bindir/xsd
%_libdir/pkgconfig/mono.web.pc
%_libdir/pkgconfig/system.web.extensions.design_1.0.pc
%_libdir/pkgconfig/system.web.extensions_1.0.pc
%_libdir/pkgconfig/system.web.mvc.pc
%_libdir/pkgconfig/system.web.mvc2.pc
%_mandir/man1/disco.1%ext_man
%_mandir/man1/mconfig.1%ext_man
%_mandir/man1/soapsuds.1%ext_man
@@ -750,16 +759,11 @@ Mono implementation of ASP.NET, Remoting and Web Services.
%_prefix/lib/mono/2.0/System.Runtime.Remoting.dll
%_prefix/lib/mono/2.0/System.Runtime.Serialization.Formatters.Soap.dll
%_prefix/lib/mono/2.0/System.Web.Abstractions.dll
%_prefix/lib/mono/2.0/System.Web.DynamicData.dll
%_prefix/lib/mono/2.0/System.Web.Extensions.Design.dll
%_prefix/lib/mono/2.0/System.Web.Extensions.dll
%_prefix/lib/mono/2.0/System.Web.Mvc.dll
%_prefix/lib/mono/2.0/System.Web.Routing.dll
%_prefix/lib/mono/2.0/System.Web.Services.dll
%_prefix/lib/mono/2.0/System.Web.dll
%_prefix/lib/mono/2.0/wsdl.exe*
%_prefix/lib/mono/2.0/xsd.exe*
%_prefix/lib/mono/3.5/System.Web.Extensions.Design.dll
%_prefix/lib/mono/4.0/Mono.Http.dll
%_prefix/lib/mono/4.0/Mono.Web.dll
%_prefix/lib/mono/4.0/System.ComponentModel.Composition.dll
@@ -767,9 +771,7 @@ Mono implementation of ASP.NET, Remoting and Web Services.
%_prefix/lib/mono/4.0/System.Runtime.Remoting.dll
%_prefix/lib/mono/4.0/System.Runtime.Serialization.Formatters.Soap.dll
%_prefix/lib/mono/4.0/System.Web.Abstractions.dll
%_prefix/lib/mono/4.0/System.Web.DynamicData.dll
%_prefix/lib/mono/4.0/System.Web.Extensions.Design.dll
%_prefix/lib/mono/4.0/System.Web.Extensions.dll
%_prefix/lib/mono/4.0/System.Web.ApplicationServices.dll
%_prefix/lib/mono/4.0/System.Web.Routing.dll
%_prefix/lib/mono/4.0/System.Web.Services.dll
%_prefix/lib/mono/4.0/System.Web.dll
@@ -778,9 +780,6 @@ Mono implementation of ASP.NET, Remoting and Web Services.
%_prefix/lib/mono/4.0/soapsuds.exe*
%_prefix/lib/mono/4.0/wsdl.exe*
%_prefix/lib/mono/4.0/xsd.exe*
%_prefix/lib/mono/compat-2.0/System.Web.Extensions.Design.dll
%_prefix/lib/mono/compat-2.0/System.Web.Extensions.dll
%_prefix/lib/mono/compat-2.0/System.Web.Mvc.dll
%_prefix/lib/mono/gac/Mono.Http
%_prefix/lib/mono/gac/Mono.Web
%_prefix/lib/mono/gac/System.ComponentModel.Composition
@@ -789,12 +788,46 @@ Mono implementation of ASP.NET, Remoting and Web Services.
%_prefix/lib/mono/gac/System.Runtime.Serialization.Formatters.Soap
%_prefix/lib/mono/gac/System.Web
%_prefix/lib/mono/gac/System.Web.Abstractions
%_prefix/lib/mono/gac/System.Web.ApplicationServices
%_prefix/lib/mono/gac/System.Web.Routing
%_prefix/lib/mono/gac/System.Web.Services
%package -n mono-mvc
License: MIT License (or similar) ; Ms-Pl
Summary: Mono implementation of ASP.NET MVC
Group: Development/Languages/Mono
Requires: mono-core == %version-%release
%description -n mono-mvc
The Mono Project is an open development initiative that is working to
develop an open source, Unix version of the .NET development platform.
Its objective is to enable Unix developers to build and deploy
cross-platform .NET applications. The project will implement various
technologies that have been submitted to the ECMA for standardization.
Mono implementation of ASP.NET MVC.
%files -n mono-mvc
%defattr(-, root, root)
%_libdir/pkgconfig/system.web.extensions.design_1.0.pc
%_libdir/pkgconfig/system.web.extensions_1.0.pc
%_libdir/pkgconfig/system.web.mvc.pc
%_libdir/pkgconfig/system.web.mvc2.pc
%_prefix/lib/mono/2.0/System.Web.DynamicData.dll
%_prefix/lib/mono/2.0/System.Web.Extensions.Design.dll
%_prefix/lib/mono/2.0/System.Web.Extensions.dll
%_prefix/lib/mono/2.0/System.Web.Mvc.dll
%_prefix/lib/mono/3.5/System.Web.Extensions.Design.dll
%_prefix/lib/mono/4.0/System.Web.DynamicData.dll
%_prefix/lib/mono/4.0/System.Web.Extensions.Design.dll
%_prefix/lib/mono/4.0/System.Web.Extensions.dll
%_prefix/lib/mono/compat-2.0/System.Web.Extensions.Design.dll
%_prefix/lib/mono/compat-2.0/System.Web.Extensions.dll
%_prefix/lib/mono/compat-2.0/System.Web.Mvc.dll
%_prefix/lib/mono/gac/System.Web.DynamicData
%_prefix/lib/mono/gac/System.Web.Extensions
%_prefix/lib/mono/gac/System.Web.Extensions.Design
%_prefix/lib/mono/gac/System.Web.Mvc
%_prefix/lib/mono/gac/System.Web.Routing
%_prefix/lib/mono/gac/System.Web.Services
%package -n mono-data-oracle
License: LGPL v2.1 only
@@ -926,8 +959,6 @@ Mono development tools.
%files -n mono-devel
%defattr(-, root, root)
%_bindir/al
%_bindir/al2
%_bindir/caspol
%_bindir/ccrewrite
%_bindir/cert2spc
@@ -1018,7 +1049,6 @@ Mono development tools.
%_prefix/lib/mono/2.0/Microsoft.VisualBasic.targets
%_prefix/lib/mono/2.0/Mono.Debugger.Soft.dll
%_prefix/lib/mono/2.0/PEAPI.dll
%_prefix/lib/mono/2.0/al.exe*
%_prefix/lib/mono/2.0/genxs.exe*
%_prefix/lib/mono/2.0/ilasm.exe*
%_prefix/lib/mono/2.0/mkbundle.exe*
@@ -1051,7 +1081,6 @@ Mono development tools.
%_prefix/lib/mono/4.0/Microsoft.VisualBasic.targets
%_prefix/lib/mono/4.0/Mono.CodeContracts.dll
%_prefix/lib/mono/4.0/PEAPI.dll
%_prefix/lib/mono/4.0/al.exe*
%_prefix/lib/mono/4.0/caspol.exe*
%_prefix/lib/mono/4.0/ccrewrite.exe*
%_prefix/lib/mono/4.0/cert2spc.exe*
@@ -1097,7 +1126,9 @@ Mono development tools.
License: LGPL v2.1 only
Summary: Monodoc - Documentation tools for C# code
Group: Development/Tools/Other
Requires: mono-core == %version-%release
Obsoletes: monodoc
Provides: monodoc
# Added to uncompress and compare documentation used by build-compare
Requires: unzip
@@ -1140,15 +1171,21 @@ Monodoc-core contains documentation tools for C#.
License: LGPL v2.1 only
Summary: Install everything built from the mono source tree
Group: Development/Languages/Mono
Requires: bytefx-data-mysql = %version-%release
Requires: ibm-data-db2 = %version-%release
Requires: mono-core = %version-%release
Requires: ibm-data-db2 = %version-%release
Requires: libmono-2_0-1 = %version-%release
Requires: libmono-2_0-devel = %version-%release
%if %llvm == yes
Requires: libmono-llvm0 = %version-%release
%endif
%if %sgen == yes
Requires: libmonosgen-2_0-0 = %version-%release
Requires: libmonosgen-2_0-devel = %version-%release
%endif
Requires: mono-data = %version-%release
Requires: mono-data-firebird = %version-%release
Requires: mono-data-oracle = %version-%release
Requires: mono-data-postgresql = %version-%release
Requires: mono-data-sqlite = %version-%release
Requires: mono-data-sybase = %version-%release
Requires: mono-devel = %version-%release
Requires: mono-extras = %version-%release
Requires: mono-locale-extras = %version-%release
@@ -1156,6 +1193,8 @@ Requires: mono-nunit = %version-%release
Requires: mono-wcf = %version-%release
Requires: mono-web = %version-%release
Requires: mono-winforms = %version-%release
Requires: mono-winfxcore = %version-%release
Requires: monodoc-core = %version-%release
%description -n mono-complete
The Mono Project is an open development initiative that is working to
+17 -4
View File
@@ -124,6 +124,10 @@ struct _WapiFileShareLayout *_wapi_fileshare_layout = NULL;
* 4MB array.
*/
static GHashTable *file_share_hash;
static CRITICAL_SECTION file_share_hash_mutex;
#define file_share_hash_lock() EnterCriticalSection (&file_share_hash_mutex)
#define file_share_hash_unlock() LeaveCriticalSection (&file_share_hash_mutex)
guint32 _wapi_fd_reserve;
@@ -220,8 +224,10 @@ static void handle_cleanup (void)
_wapi_shm_detach (WAPI_SHM_DATA);
_wapi_shm_detach (WAPI_SHM_FILESHARE);
if (file_share_hash)
if (file_share_hash) {
g_hash_table_destroy (file_share_hash);
DeleteCriticalSection (&file_share_hash_mutex);
}
for (i = 0; i < _WAPI_PRIVATE_MAX_SLOTS; ++i)
g_free (_wapi_private_handles [i]);
@@ -1643,9 +1649,9 @@ void
_wapi_free_share_info (_WapiFileShare *share_info)
{
if (!_wapi_shm_enabled ()) {
_wapi_handle_lock_shared_handles ();
file_share_hash_lock ();
g_hash_table_remove (file_share_hash, share_info);
_wapi_handle_unlock_shared_handles ();
file_share_hash_unlock ();
} else {
memset (share_info, '\0', sizeof(struct _WapiFileShare));
}
@@ -1697,11 +1703,16 @@ gboolean _wapi_handle_get_or_set_share (dev_t device, ino_t inode,
* info. This is needed even if SHM is disabled, to track sharing inside
* the current process.
*/
if (!file_share_hash)
if (!file_share_hash) {
file_share_hash = g_hash_table_new_full (wapi_share_info_hash, wapi_share_info_equal, NULL, g_free);
InitializeCriticalSection (&file_share_hash_mutex);
}
tmp.device = device;
tmp.inode = inode;
file_share_hash_lock ();
file_share = g_hash_table_lookup (file_share_hash, &tmp);
if (file_share) {
*old_sharemode = file_share->sharemode;
@@ -1723,6 +1734,8 @@ gboolean _wapi_handle_get_or_set_share (dev_t device, ino_t inode,
g_hash_table_insert (file_share_hash, file_share, file_share);
}
file_share_hash_unlock ();
} else {
/* If a linear scan gets too slow we'll have to fit a hash
* table onto the shared mem backing store
+1 -5
View File
@@ -17,12 +17,8 @@
#define _WAPI_PROCESS_CURRENT (gpointer)0xFFFFFFFF
/* This marks a system process that we don't have a handle on */
/* FIXME: cope with pids > 16bit */
#if defined(__HAIKU__)
/* FIXME: cope with pids > 31bit? */
#define _WAPI_PROCESS_UNHANDLED_PID_MASK 0x7FFFFFFF
#else
#define _WAPI_PROCESS_UNHANDLED_PID_MASK 0x7FFF
#endif
#define _WAPI_PROCESS_UNHANDLED (-1 & ~_WAPI_PROCESS_UNHANDLED_PID_MASK)
extern gpointer _wapi_process_duplicate (void);
+12 -2
View File
@@ -1690,10 +1690,20 @@ static gboolean process_open_compare (gpointer handle, gpointer user_data)
}
}
gboolean CloseProcess(gpointer handle)
{
if ((GPOINTER_TO_UINT (handle) & _WAPI_PROCESS_UNHANDLED) == _WAPI_PROCESS_UNHANDLED) {
/* This is a pseudo handle */
return(TRUE);
}
return CloseHandle (handle);
}
gpointer OpenProcess (guint32 req_access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED, guint32 pid)
{
/* Find the process handle that corresponds to pid */
gpointer handle;
gpointer handle = NULL;
mono_once (&process_current_once, process_set_current);
@@ -1705,7 +1715,7 @@ gpointer OpenProcess (guint32 req_access G_GNUC_UNUSED, gboolean inherit G_GNUC_
process_open_compare,
GUINT_TO_POINTER (pid), NULL, TRUE);
if (handle == 0) {
#if defined(__OpenBSD__)
#if defined(PLATFORM_MACOSX) || defined(__OpenBSD__)
if ((kill(pid, 0) == 0) || (errno == EPERM)) {
#elif defined(__HAIKU__)
team_info teamInfo;
+1
View File
@@ -190,6 +190,7 @@ extern gpointer GetCurrentProcess (void);
extern guint32 GetProcessId (gpointer handle);
extern guint32 GetCurrentProcessId (void);
extern gboolean EnumProcesses (guint32 *pids, guint32 len, guint32 *needed);
extern gboolean CloseProcess (gpointer handle);
extern gpointer OpenProcess (guint32 access, gboolean inherit, guint32 pid);
extern gboolean GetExitCodeProcess (gpointer process, guint32 *code);
extern gboolean GetProcessTimes (gpointer process, WapiFileTime *create_time,
+6
View File
@@ -151,6 +151,12 @@ _wapi_shm_detach (_wapi_shm_t type)
g_free (wapi_storage [type]);
}
gboolean
_wapi_shm_enabled (void)
{
return FALSE;
}
#else
/*
* Use POSIX shared memory if possible, it is simpler, and it has the advantage that
+8 -2
View File
@@ -29,6 +29,7 @@
#include <mono/metadata/mono-config.h>
#include <mono/utils/mono-digest.h>
#include <mono/utils/mono-logger-internal.h>
#include <mono/utils/mono-path.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/coree.h>
@@ -589,7 +590,7 @@ void
mono_set_rootdir (void)
{
#if defined(HOST_WIN32) || (defined(PLATFORM_MACOSX) && !defined(TARGET_ARM))
gchar *bindir, *installdir, *root, *name, *config;
gchar *bindir, *installdir, *root, *name, *resolvedname, *config;
#ifdef HOST_WIN32
name = mono_get_module_file_name ((HMODULE) &__ImageBase);
@@ -612,10 +613,14 @@ mono_set_rootdir (void)
fallback ();
return;
}
name = mono_path_resolve_symlinks (name);
}
#endif
bindir = g_path_get_dirname (name);
resolvedname = mono_path_resolve_symlinks (name);
bindir = g_path_get_dirname (resolvedname);
installdir = g_path_get_dirname (bindir);
root = g_build_path (G_DIR_SEPARATOR_S, installdir, "lib", NULL);
@@ -634,6 +639,7 @@ mono_set_rootdir (void)
g_free (installdir);
g_free (bindir);
g_free (name);
g_free (resolvedname);
#elif defined(DISABLE_MONO_AUTODETECTION)
fallback ();
#else
+2
View File
@@ -129,10 +129,12 @@ mono_monitor_cleanup (void)
/*DeleteCriticalSection (&monitor_mutex);*/
/* FIXME: This seems to cause crashes with SGEN
for (marray = monitor_allocated; marray; marray = next) {
next = marray->next;
g_free (marray);
}
*/
}
/*
+4
View File
@@ -65,7 +65,11 @@ void ves_icall_System_Diagnostics_Process_Process_free_internal (MonoObject *thi
g_message ("%s: Closing process %p, handle %p", __func__, this, process);
#endif
#if TARGET_WIN32
CloseHandle (process);
#else
CloseProcess (process);
#endif
}
#define STASH_SYS_ASS(this) \
+1 -1
View File
@@ -108,7 +108,7 @@ typedef void (*MonoProfileAssemblyResult) (MonoProfiler *prof, MonoAssembly *ass
typedef void (*MonoProfileMethodInline) (MonoProfiler *prof, MonoMethod *parent, MonoMethod *child, int *ok);
typedef void (*MonoProfileThreadFunc) (MonoProfiler *prof, intptr_t tid);
typedef void (*MonoProfileThreadFunc) (MonoProfiler *prof, uintptr_t tid);
typedef void (*MonoProfileAllocFunc) (MonoProfiler *prof, MonoObject *obj, MonoClass *klass);
typedef void (*MonoProfileStatFunc) (MonoProfiler *prof, mono_byte *ip, void *context);
typedef void (*MonoProfileStatCallChainFunc) (MonoProfiler *prof, int call_chain_depth, mono_byte **ip, void *context);
+3 -3
View File
@@ -187,7 +187,7 @@ card_table_clear (void)
{
/*XXX we could do this in 2 ways. using mincore or iterating over all sections/los objects */
if (use_cardtable) {
major.iterate_live_block_ranges (clear_cards);
major_collector.iterate_live_block_ranges (clear_cards);
los_iterate_live_block_ranges (clear_cards);
}
}
@@ -197,13 +197,13 @@ scan_from_card_tables (void *start_nursery, void *end_nursery, GrayQueue *queue)
if (use_cardtable) {
#ifdef SGEN_HAVE_OVERLAPPING_CARDS
/*First we copy*/
major.iterate_live_block_ranges (move_cards_to_shadow_table);
major_collector.iterate_live_block_ranges (move_cards_to_shadow_table);
los_iterate_live_block_ranges (move_cards_to_shadow_table);
/*Then we clear*/
card_table_clear ();
#endif
major.scan_card_table (queue);
major_collector.scan_card_table (queue);
los_scan_card_table (queue);
}
}
+82 -83
View File
@@ -774,7 +774,7 @@ static int mark_ephemerons_in_range (CopyOrMarkObjectFunc copy_func, char *start
static void clear_unreachable_ephemerons (CopyOrMarkObjectFunc copy_func, char *start, char *end, GrayQueue *queue);
static void null_ephemerons_for_domain (MonoDomain *domain);
SgenMajorCollector major;
SgenMajorCollector major_collector;
#include "sgen-protocol.c"
#include "sgen-pinning.c"
@@ -1221,7 +1221,7 @@ mono_gc_scan_for_specific_ref (MonoObject *key)
mono_sgen_scan_area_with_callback (nursery_section->data, nursery_section->end_data,
(IterateObjectCallbackFunc)scan_object_for_specific_ref_callback, key);
major.iterate_objects (TRUE, TRUE, (IterateObjectCallbackFunc)scan_object_for_specific_ref_callback, key);
major_collector.iterate_objects (TRUE, TRUE, (IterateObjectCallbackFunc)scan_object_for_specific_ref_callback, key);
for (bigobj = los_object_list; bigobj; bigobj = bigobj->next)
scan_object_for_specific_ref (bigobj->data, key);
@@ -1362,7 +1362,7 @@ check_for_xdomain_refs (void)
mono_sgen_scan_area_with_callback (nursery_section->data, nursery_section->end_data,
(IterateObjectCallbackFunc)scan_object_for_xdomain_refs, NULL);
major.iterate_objects (TRUE, TRUE, (IterateObjectCallbackFunc)scan_object_for_xdomain_refs, NULL);
major_collector.iterate_objects (TRUE, TRUE, (IterateObjectCallbackFunc)scan_object_for_xdomain_refs, NULL);
for (bigobj = los_object_list; bigobj; bigobj = bigobj->next)
scan_object_for_xdomain_refs (bigobj->data, bigobj->size, NULL);
@@ -1402,14 +1402,14 @@ static void
clear_domain_free_major_non_pinned_object_callback (char *obj, size_t size, MonoDomain *domain)
{
if (need_remove_object_for_domain (obj, domain))
major.free_non_pinned_object (obj, size);
major_collector.free_non_pinned_object (obj, size);
}
static void
clear_domain_free_major_pinned_object_callback (char *obj, size_t size, MonoDomain *domain)
{
if (need_remove_object_for_domain (obj, domain))
major.free_pinned_object (obj, size);
major_collector.free_pinned_object (obj, size);
}
/*
@@ -1454,7 +1454,7 @@ mono_gc_clear_domain (MonoDomain * domain)
objects with major-mark&sweep), but we might need to
dereference a pointer from an object to another object if
the first object is a proxy. */
major.iterate_objects (TRUE, TRUE, (IterateObjectCallbackFunc)clear_domain_process_major_object_callback, domain);
major_collector.iterate_objects (TRUE, TRUE, (IterateObjectCallbackFunc)clear_domain_process_major_object_callback, domain);
for (bigobj = los_object_list; bigobj; bigobj = bigobj->next)
clear_domain_process_object (bigobj->data, domain);
@@ -1475,8 +1475,8 @@ mono_gc_clear_domain (MonoDomain * domain)
prev = bigobj;
bigobj = bigobj->next;
}
major.iterate_objects (TRUE, FALSE, (IterateObjectCallbackFunc)clear_domain_free_major_non_pinned_object_callback, domain);
major.iterate_objects (FALSE, TRUE, (IterateObjectCallbackFunc)clear_domain_free_major_pinned_object_callback, domain);
major_collector.iterate_objects (TRUE, FALSE, (IterateObjectCallbackFunc)clear_domain_free_major_non_pinned_object_callback, domain);
major_collector.iterate_objects (FALSE, TRUE, (IterateObjectCallbackFunc)clear_domain_free_major_pinned_object_callback, domain);
UNLOCK_GC;
}
@@ -1545,7 +1545,7 @@ mono_sgen_add_to_global_remset (gpointer ptr)
g_assert (!ptr_in_nursery (ptr) && ptr_in_nursery (*(gpointer*)ptr));
lock = (current_collection_generation == GENERATION_OLD && major.is_parallel);
lock = (current_collection_generation == GENERATION_OLD && major_collector.is_parallel);
if (lock)
LOCK_GLOBAL_REMSET;
@@ -1602,10 +1602,10 @@ drain_gray_stack (GrayQueue *queue)
if (!obj)
break;
DEBUG (9, fprintf (gc_debug_file, "Precise gray object scan %p (%s)\n", obj, safe_name (obj)));
major.minor_scan_object (obj, queue);
major_collector.minor_scan_object (obj, queue);
}
} else {
if (major.is_parallel && queue == &workers_distribute_gray_queue)
if (major_collector.is_parallel && queue == &workers_distribute_gray_queue)
return;
for (;;) {
@@ -1613,7 +1613,7 @@ drain_gray_stack (GrayQueue *queue)
if (!obj)
break;
DEBUG (9, fprintf (gc_debug_file, "Precise gray object scan %p (%s)\n", obj, safe_name (obj)));
major.major_scan_object (obj, queue);
major_collector.major_scan_object (obj, queue);
}
}
}
@@ -2049,9 +2049,9 @@ alloc_nursery (void)
g_assert (nursery_size == DEFAULT_NURSERY_SIZE);
alloc_size = nursery_size;
#ifdef SGEN_ALIGN_NURSERY
data = major.alloc_heap (alloc_size, alloc_size, DEFAULT_NURSERY_BITS);
data = major_collector.alloc_heap (alloc_size, alloc_size, DEFAULT_NURSERY_BITS);
#else
data = major.alloc_heap (alloc_size, 0, DEFAULT_NURSERY_BITS);
data = major_collector.alloc_heap (alloc_size, 0, DEFAULT_NURSERY_BITS);
#endif
nursery_start = data;
nursery_real_end = nursery_start + nursery_size;
@@ -2171,7 +2171,7 @@ finish_gray_stack (char *start_addr, char *end_addr, int generation, GrayQueue *
TV_DECLARE (btv);
int fin_ready;
int ephemeron_rounds = 0;
CopyOrMarkObjectFunc copy_func = current_collection_generation == GENERATION_NURSERY ? major.copy_object : major.copy_or_mark_object;
CopyOrMarkObjectFunc copy_func = current_collection_generation == GENERATION_NURSERY ? major_collector.copy_object : major_collector.copy_or_mark_object;
/*
* We copied all the reachable objects. Now it's the time to copy
@@ -2269,7 +2269,7 @@ check_scan_starts (void)
if (!do_scan_starts_check)
return;
mono_sgen_check_section_scan_starts (nursery_section);
major.check_scan_starts ();
major_collector.check_scan_starts ();
}
static int last_num_pinned = 0;
@@ -2449,7 +2449,7 @@ dump_heap (const char *type, int num, const char *reason)
mono_sgen_dump_section (nursery_section, "nursery");
major.dump_heap (heap_dump_file);
major_collector.dump_heap (heap_dump_file);
fprintf (heap_dump_file, "<los>\n");
for (bigobj = los_object_list; bigobj; bigobj = bigobj->next)
@@ -2465,7 +2465,7 @@ mono_sgen_register_moved_object (void *obj, void *destination)
g_assert (mono_profiler_events & MONO_PROFILE_GC_MOVES);
/* FIXME: handle this for parallel collector */
g_assert (!major.is_parallel);
g_assert (!major_collector.is_parallel);
if (moved_objects_idx == MOVED_OBJECTS_NUM) {
mono_profiler_gc_moves (moved_objects, moved_objects_idx);
@@ -2556,7 +2556,7 @@ static gboolean
need_major_collection (void)
{
mword los_alloced = los_memory_usage - MIN (last_los_memory_usage, los_memory_usage);
return minor_collection_sections_alloced * major.section_size + los_alloced > minor_collection_allowance;
return minor_collection_sections_alloced * major_collector.section_size + los_alloced > minor_collection_allowance;
}
/*
@@ -2603,7 +2603,7 @@ collect_nursery (size_t requested_size)
nursery_section->next_data = nursery_next;
major.start_nursery_collection ();
major_collector.start_nursery_collection ();
gray_object_queue_init (&gray_queue, mono_sgen_get_unmanaged_allocator ());
@@ -2649,8 +2649,8 @@ collect_nursery (size_t requested_size)
TV_GETTIME (atv);
time_minor_scan_pinned += TV_ELAPSED_MS (btv, atv);
/* registered roots, this includes static fields */
scan_from_registered_roots (major.copy_object, nursery_start, nursery_next, ROOT_TYPE_NORMAL, &gray_queue);
scan_from_registered_roots (major.copy_object, nursery_start, nursery_next, ROOT_TYPE_WBARRIER, &gray_queue);
scan_from_registered_roots (major_collector.copy_object, nursery_start, nursery_next, ROOT_TYPE_NORMAL, &gray_queue);
scan_from_registered_roots (major_collector.copy_object, nursery_start, nursery_next, ROOT_TYPE_WBARRIER, &gray_queue);
TV_GETTIME (btv);
time_minor_scan_registered_roots += TV_ELAPSED_MS (atv, btv);
/* thread data */
@@ -2675,7 +2675,7 @@ collect_nursery (size_t requested_size)
if (consistency_check_at_minor_collection)
check_major_refs ();
major.finish_nursery_collection ();
major_collector.finish_nursery_collection ();
TV_GETTIME (all_btv);
mono_stats.minor_gc_time_usecs += TV_ELAPSED (all_atv, all_btv);
@@ -2716,7 +2716,7 @@ major_do_collection (const char *reason)
*/
char *heap_start = NULL;
char *heap_end = (char*)-1;
int old_num_major_sections = major.get_num_major_sections ();
int old_num_major_sections = major_collector.get_num_major_sections ();
int num_major_sections, num_major_sections_saved, save_target, allowance_target;
mword los_memory_saved, los_memory_alloced, old_los_memory_usage;
@@ -2733,7 +2733,7 @@ major_do_collection (const char *reason)
binary_protocol_collection (GENERATION_OLD);
check_scan_starts ();
gray_object_queue_init (&gray_queue, mono_sgen_get_unmanaged_allocator ());
if (major.is_parallel)
if (major_collector.is_parallel)
gray_object_queue_init (&workers_distribute_gray_queue, mono_sgen_get_unmanaged_allocator ());
degraded_mode = 0;
@@ -2785,7 +2785,7 @@ major_do_collection (const char *reason)
DEBUG (6, fprintf (gc_debug_file, "Pinning from sections\n"));
/* first pass for the sections */
mono_sgen_find_section_pin_queue_start_end (nursery_section);
major.find_pin_queue_start_ends (WORKERS_DISTRIBUTE_GRAY_QUEUE);
major_collector.find_pin_queue_start_ends (WORKERS_DISTRIBUTE_GRAY_QUEUE);
/* identify possible pointers to the insize of large objects */
DEBUG (6, fprintf (gc_debug_file, "Pinning from large objects\n"));
for (bigobj = los_object_list; bigobj; bigobj = bigobj->next) {
@@ -2801,14 +2801,14 @@ major_do_collection (const char *reason)
}
/* second pass for the sections */
mono_sgen_pin_objects_in_section (nursery_section, WORKERS_DISTRIBUTE_GRAY_QUEUE);
major.pin_objects (WORKERS_DISTRIBUTE_GRAY_QUEUE);
major_collector.pin_objects (WORKERS_DISTRIBUTE_GRAY_QUEUE);
TV_GETTIME (btv);
time_major_pinning += TV_ELAPSED_MS (atv, btv);
DEBUG (2, fprintf (gc_debug_file, "Finding pinned pointers: %d in %d usecs\n", next_pin_slot, TV_ELAPSED (atv, btv)));
DEBUG (4, fprintf (gc_debug_file, "Start scan with %d pinned objects\n", next_pin_slot));
major.init_to_space ();
major_collector.init_to_space ();
workers_start_all_workers (1);
@@ -2816,8 +2816,8 @@ major_do_collection (const char *reason)
time_major_scan_pinned += TV_ELAPSED_MS (btv, atv);
/* registered roots, this includes static fields */
scan_from_registered_roots (major.copy_or_mark_object, heap_start, heap_end, ROOT_TYPE_NORMAL, WORKERS_DISTRIBUTE_GRAY_QUEUE);
scan_from_registered_roots (major.copy_or_mark_object, heap_start, heap_end, ROOT_TYPE_WBARRIER, WORKERS_DISTRIBUTE_GRAY_QUEUE);
scan_from_registered_roots (major_collector.copy_or_mark_object, heap_start, heap_end, ROOT_TYPE_NORMAL, WORKERS_DISTRIBUTE_GRAY_QUEUE);
scan_from_registered_roots (major_collector.copy_or_mark_object, heap_start, heap_end, ROOT_TYPE_WBARRIER, WORKERS_DISTRIBUTE_GRAY_QUEUE);
TV_GETTIME (btv);
time_major_scan_registered_roots += TV_ELAPSED_MS (atv, btv);
@@ -2832,8 +2832,8 @@ major_do_collection (const char *reason)
time_major_scan_alloc_pinned += TV_ELAPSED_MS (atv, btv);
/* scan the list of objects ready for finalization */
scan_finalizer_entries (major.copy_or_mark_object, fin_ready_list, WORKERS_DISTRIBUTE_GRAY_QUEUE);
scan_finalizer_entries (major.copy_or_mark_object, critical_fin_list, WORKERS_DISTRIBUTE_GRAY_QUEUE);
scan_finalizer_entries (major_collector.copy_or_mark_object, fin_ready_list, WORKERS_DISTRIBUTE_GRAY_QUEUE);
scan_finalizer_entries (major_collector.copy_or_mark_object, critical_fin_list, WORKERS_DISTRIBUTE_GRAY_QUEUE);
TV_GETTIME (atv);
time_major_scan_finalized += TV_ELAPSED_MS (btv, atv);
DEBUG (2, fprintf (gc_debug_file, "Root scan: %d usecs\n", TV_ELAPSED (btv, atv)));
@@ -2841,7 +2841,7 @@ major_do_collection (const char *reason)
TV_GETTIME (btv);
time_major_scan_big_objects += TV_ELAPSED_MS (atv, btv);
if (major.is_parallel) {
if (major_collector.is_parallel) {
while (!gray_object_queue_is_empty (WORKERS_DISTRIBUTE_GRAY_QUEUE)) {
workers_distribute_gray_queue_sections ();
usleep (2000);
@@ -2850,7 +2850,7 @@ major_do_collection (const char *reason)
workers_change_num_working (-1);
workers_join ();
if (major.is_parallel)
if (major_collector.is_parallel)
g_assert (gray_object_queue_is_empty (&gray_queue));
/* all the objects in the heap */
@@ -2887,7 +2887,7 @@ major_do_collection (const char *reason)
TV_GETTIME (atv);
time_major_los_sweep += TV_ELAPSED_MS (btv, atv);
major.sweep ();
major_collector.sweep ();
TV_GETTIME (btv);
time_major_sweep += TV_ELAPSED_MS (atv, btv);
@@ -2917,12 +2917,12 @@ major_do_collection (const char *reason)
g_assert (gray_object_queue_is_empty (&gray_queue));
num_major_sections = major.get_num_major_sections ();
num_major_sections = major_collector.get_num_major_sections ();
num_major_sections_saved = MAX (old_num_major_sections - num_major_sections, 0);
los_memory_saved = MAX (old_los_memory_usage - los_memory_usage, 1);
save_target = ((num_major_sections * major.section_size) + los_memory_saved) / 2;
save_target = ((num_major_sections * major_collector.section_size) + los_memory_saved) / 2;
/*
* We aim to allow the allocation of as many sections as is
* necessary to reclaim save_target sections in the next
@@ -2938,14 +2938,14 @@ major_do_collection (const char *reason)
*
* hence:
*/
allowance_target = (mword)((double)save_target * (double)(minor_collection_sections_alloced * major.section_size + los_memory_alloced) / (double)(num_major_sections_saved * major.section_size + los_memory_saved));
allowance_target = (mword)((double)save_target * (double)(minor_collection_sections_alloced * major_collector.section_size + los_memory_alloced) / (double)(num_major_sections_saved * major_collector.section_size + los_memory_saved));
minor_collection_allowance = MAX (MIN (allowance_target, num_major_sections * major.section_size + los_memory_usage), MIN_MINOR_COLLECTION_ALLOWANCE);
minor_collection_allowance = MAX (MIN (allowance_target, num_major_sections * major_collector.section_size + los_memory_usage), MIN_MINOR_COLLECTION_ALLOWANCE);
minor_collection_sections_alloced = 0;
last_los_memory_usage = los_memory_usage;
major.finish_major_collection ();
major_collector.finish_major_collection ();
check_scan_starts ();
@@ -3017,7 +3017,7 @@ report_internal_mem_usage (void)
printf ("Internal memory usage:\n");
mono_sgen_report_internal_mem_usage ();
printf ("Pinned memory usage:\n");
major.report_pinned_memory_usage ();
major_collector.report_pinned_memory_usage ();
}
/*
@@ -3163,7 +3163,7 @@ alloc_degraded (MonoVTable *vtable, size_t size)
}
degraded_mode += size;
return major.alloc_degraded (vtable, size);
return major_collector.alloc_degraded (vtable, size);
}
/*
@@ -3503,7 +3503,7 @@ mono_gc_alloc_pinned_obj (MonoVTable *vtable, size_t size)
p = alloc_large_inner (vtable, size);
} else {
DEBUG (9, g_assert (vtable->klass->inited));
p = major.alloc_small_pinned_obj (size, vtable->klass->has_references);
p = major_collector.alloc_small_pinned_obj (size, vtable->klass->has_references);
}
DEBUG (6, fprintf (gc_debug_file, "Allocated pinned object %p, vtable: %p (%s), size: %zd\n", p, vtable, vtable->klass->name, size));
binary_protocol_alloc_pinned (p, vtable, size);
@@ -3600,7 +3600,7 @@ finalize_in_range (CopyOrMarkObjectFunc copy_func, char *start, char *end, int g
for (i = 0; i < finalizable_hash_size; ++i) {
prev = NULL;
for (entry = finalizable_hash [i]; entry;) {
if ((char*)entry->object >= start && (char*)entry->object < end && !major.is_object_live (entry->object)) {
if ((char*)entry->object >= start && (char*)entry->object < end && !major_collector.is_object_live (entry->object)) {
gboolean is_fin_ready = object_is_fin_ready (entry->object);
char *copy = entry->object;
copy_func ((void**)&copy, queue);
@@ -3667,7 +3667,7 @@ object_is_reachable (char *object, char *start, char *end)
/*This happens for non nursery objects during minor collections. We just treat all objects as alive.*/
if (object < start || object >= end)
return TRUE;
return !object_is_fin_ready (object) || major.is_object_live (object);
return !object_is_fin_ready (object) || major_collector.is_object_live (object);
}
/* LOCKING: requires that the GC lock is held */
@@ -3844,7 +3844,7 @@ null_link_in_range (CopyOrMarkObjectFunc copy_func, char *start, char *end, int
prev = NULL;
for (entry = disappearing_link_hash [i]; entry;) {
char *object = DISLINK_OBJECT (entry);
if (object >= start && object < end && !major.is_object_live (object)) {
if (object >= start && object < end && !major_collector.is_object_live (object)) {
gboolean track = DISLINK_TRACK (entry);
if (!track && object_is_fin_ready (object)) {
void **p = entry->link;
@@ -4577,12 +4577,11 @@ suspend_handler (int sig, siginfo_t *siginfo, void *context)
int old_errno = errno;
gpointer regs [ARCH_NUM_REGS];
gpointer stack_start;
ucontext_t *ctx = (ucontext_t*)context;
id = pthread_self ();
info = mono_sgen_thread_info_lookup (id);
info->stopped_domain = mono_domain_get ();
info->stopped_ip = (gpointer) ARCH_SIGCTX_IP (ctx);
info->stopped_ip = (gpointer) ARCH_SIGCTX_IP (context);
stop_count = global_stop_count;
/* duplicate signal */
if (0 && info->stop_count == stop_count) {
@@ -4593,13 +4592,13 @@ suspend_handler (int sig, siginfo_t *siginfo, void *context)
/* update the remset info in the thread data structure */
info->remset = remembered_set;
#endif
stack_start = (char*) ARCH_SIGCTX_SP (ctx) - REDZONE_SIZE;
stack_start = (char*) ARCH_SIGCTX_SP (context) - REDZONE_SIZE;
/* If stack_start is not within the limits, then don't set it
in info and we will be restarted. */
if (stack_start >= info->stack_start_limit && info->stack_start <= info->stack_end) {
info->stack_start = stack_start;
ARCH_COPY_SIGCTX_REGS (regs, ctx);
ARCH_COPY_SIGCTX_REGS (regs, context);
info->stopped_regs = regs;
} else {
g_assert (!info->stack_start);
@@ -4607,7 +4606,7 @@ suspend_handler (int sig, siginfo_t *siginfo, void *context)
/* Notify the JIT */
if (gc_callbacks.thread_suspend_func)
gc_callbacks.thread_suspend_func (info->runtime_data, ctx);
gc_callbacks.thread_suspend_func (info->runtime_data, context);
DEBUG (4, fprintf (gc_debug_file, "Posting suspend_ack_semaphore for suspend from %p %p\n", info, (gpointer)ARCH_GET_THREAD ()));
/* notify the waiting thread */
@@ -4736,9 +4735,9 @@ mono_gc_scan_object (void *obj)
{
g_assert_not_reached ();
if (current_collection_generation == GENERATION_NURSERY)
major.copy_object (&obj, &gray_queue);
major_collector.copy_object (&obj, &gray_queue);
else
major.copy_or_mark_object (&obj, &gray_queue);
major_collector.copy_or_mark_object (&obj, &gray_queue);
return obj;
}
@@ -4827,7 +4826,7 @@ handle_remset (mword *p, void *start_nursery, void *end_nursery, gboolean global
//__builtin_prefetch (ptr);
if (((void*)ptr < start_nursery || (void*)ptr >= end_nursery)) {
gpointer old = *ptr;
major.copy_object (ptr, queue);
major_collector.copy_object (ptr, queue);
DEBUG (9, fprintf (gc_debug_file, "Overwrote remset at %p with %p\n", ptr, *ptr));
if (old)
binary_protocol_ptr_update (ptr, old, *ptr, (gpointer)LOAD_VTABLE (*ptr), safe_object_get_size (*ptr));
@@ -4849,7 +4848,7 @@ handle_remset (mword *p, void *start_nursery, void *end_nursery, gboolean global
return p + 2;
count = p [1];
while (count-- > 0) {
major.copy_object (ptr, queue);
major_collector.copy_object (ptr, queue);
DEBUG (9, fprintf (gc_debug_file, "Overwrote remset at %p with %p (count: %d)\n", ptr, *ptr, (int)count));
if (!global && *ptr >= start_nursery && *ptr < end_nursery)
mono_sgen_add_to_global_remset (ptr);
@@ -4860,7 +4859,7 @@ handle_remset (mword *p, void *start_nursery, void *end_nursery, gboolean global
ptr = (void**)(*p & ~REMSET_TYPE_MASK);
if (((void*)ptr >= start_nursery && (void*)ptr < end_nursery))
return p + 1;
major.minor_scan_object ((char*)ptr, queue);
major_collector.minor_scan_object ((char*)ptr, queue);
return p + 1;
case REMSET_VTYPE: {
ptr = (void**)(*p & ~REMSET_TYPE_MASK);
@@ -4869,7 +4868,7 @@ handle_remset (mword *p, void *start_nursery, void *end_nursery, gboolean global
desc = p [1];
count = p [2];
while (count-- > 0)
ptr = (void**) major.minor_scan_vtype ((char*)ptr, desc, start_nursery, end_nursery, queue);
ptr = (void**) major_collector.minor_scan_vtype ((char*)ptr, desc, start_nursery, end_nursery, queue);
return p + 3;
}
default:
@@ -5559,7 +5558,7 @@ find_object_for_ptr (char *ptr)
* be called from gdb, so we don't care.
*/
found_obj = NULL;
major.iterate_objects (TRUE, TRUE, (IterateObjectCallbackFunc)find_object_for_ptr_callback, ptr);
major_collector.iterate_objects (TRUE, TRUE, (IterateObjectCallbackFunc)find_object_for_ptr_callback, ptr);
return found_obj;
}
@@ -5778,9 +5777,9 @@ describe_ptr (char *ptr)
if (ptr_in_nursery (ptr)) {
printf ("Pointer inside nursery.\n");
} else {
if (major.ptr_is_in_non_pinned_space (ptr)) {
if (major_collector.ptr_is_in_non_pinned_space (ptr)) {
printf ("Pointer inside oldspace.\n");
} else if (major.obj_is_from_pinned_alloc (ptr)) {
} else if (major_collector.obj_is_from_pinned_alloc (ptr)) {
printf ("Pointer is inside a pinned chunk.\n");
} else {
printf ("Pointer unknown.\n");
@@ -5985,7 +5984,7 @@ check_consistency (void)
DEBUG (1, fprintf (gc_debug_file, "Begin heap consistency check...\n"));
// Check that oldspace->newspace pointers are registered with the collector
major.iterate_objects (TRUE, TRUE, (IterateObjectCallbackFunc)check_consistency_callback, NULL);
major_collector.iterate_objects (TRUE, TRUE, (IterateObjectCallbackFunc)check_consistency_callback, NULL);
for (bigobj = los_object_list; bigobj; bigobj = bigobj->next)
check_consistency_callback (bigobj->data, bigobj->size, NULL);
@@ -6017,7 +6016,7 @@ check_major_refs (void)
{
LOSObject *bigobj;
major.iterate_objects (TRUE, TRUE, (IterateObjectCallbackFunc)check_major_refs_callback, NULL);
major_collector.iterate_objects (TRUE, TRUE, (IterateObjectCallbackFunc)check_major_refs_callback, NULL);
for (bigobj = los_object_list; bigobj; bigobj = bigobj->next)
check_major_refs_callback (bigobj->data, bigobj->size, NULL);
@@ -6087,7 +6086,7 @@ mono_gc_get_used_size (void)
LOCK_GC;
tot = los_memory_usage;
tot += nursery_section->next_data - nursery_section->data;
tot += major.get_used_size ();
tot += major_collector.get_used_size ();
/* FIXME: account for pinned objects */
UNLOCK_GC;
return tot;
@@ -6298,7 +6297,7 @@ mono_gc_base_init (void)
{
char *env;
char **opts, **ptr;
char *major_collector = NULL;
char *major_collector_opt = NULL;
struct sigaction sinfo;
LOCK_INIT (gc_mutex);
@@ -6319,7 +6318,7 @@ mono_gc_base_init (void)
char *opt = *ptr;
if (g_str_has_prefix (opt, "major=")) {
opt = strchr (opt, '=') + 1;
major_collector = g_strdup (opt);
major_collector_opt = g_strdup (opt);
}
}
} else {
@@ -6339,25 +6338,25 @@ mono_gc_base_init (void)
mono_sgen_register_fixed_internal_mem_type (INTERNAL_MEM_STORE_REMSET, sizeof (GenericStoreRememberedSet));
mono_sgen_register_fixed_internal_mem_type (INTERNAL_MEM_EPHEMERON_LINK, sizeof (EphemeronLinkNode));
if (!major_collector || !strcmp (major_collector, "marksweep")) {
mono_sgen_marksweep_init (&major);
} else if (!major_collector || !strcmp (major_collector, "marksweep-fixed")) {
mono_sgen_marksweep_fixed_init (&major);
} else if (!major_collector || !strcmp (major_collector, "marksweep-par")) {
mono_sgen_marksweep_par_init (&major);
if (!major_collector_opt || !strcmp (major_collector_opt, "marksweep")) {
mono_sgen_marksweep_init (&major_collector);
} else if (!major_collector_opt || !strcmp (major_collector_opt, "marksweep-fixed")) {
mono_sgen_marksweep_fixed_init (&major_collector);
} else if (!major_collector_opt || !strcmp (major_collector_opt, "marksweep-par")) {
mono_sgen_marksweep_par_init (&major_collector);
workers_init (mono_cpu_count ());
} else if (!major_collector || !strcmp (major_collector, "marksweep-fixed-par")) {
mono_sgen_marksweep_fixed_par_init (&major);
} else if (!major_collector_opt || !strcmp (major_collector_opt, "marksweep-fixed-par")) {
mono_sgen_marksweep_fixed_par_init (&major_collector);
workers_init (mono_cpu_count ());
} else if (!strcmp (major_collector, "copying")) {
mono_sgen_copying_init (&major);
} else if (!strcmp (major_collector_opt, "copying")) {
mono_sgen_copying_init (&major_collector);
} else {
fprintf (stderr, "Unknown major collector `%s'.\n", major_collector);
fprintf (stderr, "Unknown major collector `%s'.\n", major_collector_opt);
exit (1);
}
#ifdef SGEN_HAVE_CARDTABLE
use_cardtable = major.supports_cardtable;
use_cardtable = major_collector.supports_cardtable;
#else
use_cardtable = FALSE;
#endif
@@ -6373,7 +6372,7 @@ mono_gc_base_init (void)
use_cardtable = FALSE;
} else if (strcmp (opt, "cardtable") == 0) {
if (!use_cardtable) {
if (major.supports_cardtable)
if (major_collector.supports_cardtable)
fprintf (stderr, "The cardtable write barrier is not supported on this platform.\n");
else
fprintf (stderr, "The major collector does not support the cardtable write barrier.\n");
@@ -6405,21 +6404,21 @@ mono_gc_base_init (void)
continue;
}
#endif
if (!(major.handle_gc_param && major.handle_gc_param (opt))) {
if (!(major_collector.handle_gc_param && major_collector.handle_gc_param (opt))) {
fprintf (stderr, "MONO_GC_PARAMS must be a comma-delimited list of one or more of the following:\n");
fprintf (stderr, " nursery-size=N (where N is an integer, possibly with a k, m or a g suffix)\n");
fprintf (stderr, " major=COLLECTOR (where COLLECTOR is `marksweep', `marksweep-par' or `copying')\n");
fprintf (stderr, " wbarrier=WBARRIER (where WBARRIER is `remset' or `cardtable')\n");
if (major.print_gc_param_usage)
major.print_gc_param_usage ();
if (major_collector.print_gc_param_usage)
major_collector.print_gc_param_usage ();
exit (1);
}
}
g_strfreev (opts);
}
if (major_collector)
g_free (major_collector);
if (major_collector_opt)
g_free (major_collector_opt);
nursery_size = DEFAULT_NURSERY_SIZE;
minor_collection_allowance = MIN_MINOR_COLLECTION_ALLOWANCE;
+3 -3
View File
@@ -506,14 +506,14 @@ los_scan_card_table (GrayQueue *queue)
elem = (char*)mono_array_addr_with_size ((MonoArray*)obj->data, size, index);
if (klass->element_class->valuetype) {
while (elem < card_end) {
major.minor_scan_vtype (elem, desc, nursery_start, nursery_next, queue);
major_collector.minor_scan_vtype (elem, desc, nursery_start, nursery_next, queue);
elem += size;
}
} else {
while (elem < card_end) {
gpointer new, old = *(gpointer*)elem;
if (old) {
major.copy_object ((void**)elem, queue);
major_collector.copy_object ((void**)elem, queue);
new = *(gpointer*)elem;
if (G_UNLIKELY (ptr_in_nursery (new)))
mono_sgen_add_to_global_remset (elem);
@@ -524,7 +524,7 @@ los_scan_card_table (GrayQueue *queue)
}
} else {
if (sgen_card_table_region_begin_scanning ((mword)obj->data, (mword)obj->size))
major.minor_scan_object (obj->data, queue);
major_collector.minor_scan_object (obj->data, queue);
}
}
}
+7 -7
View File
@@ -40,7 +40,7 @@ static int workers_num_working;
static GrayQueue workers_distribute_gray_queue;
#define WORKERS_DISTRIBUTE_GRAY_QUEUE (major.is_parallel ? &workers_distribute_gray_queue : &gray_queue)
#define WORKERS_DISTRIBUTE_GRAY_QUEUE (major_collector.is_parallel ? &workers_distribute_gray_queue : &gray_queue)
/*
* Must be a power of 2. It seems that larger values don't help much.
@@ -148,7 +148,7 @@ workers_change_num_working (int delta)
{
int old, new;
if (!major.is_parallel)
if (!major_collector.is_parallel)
return -1;
do {
@@ -209,7 +209,7 @@ workers_thread_func (void *data_untyped)
static void
workers_distribute_gray_queue_sections (void)
{
if (!major.is_parallel)
if (!major_collector.is_parallel)
return;
workers_gray_queue_share_redirect (&workers_distribute_gray_queue);
@@ -220,7 +220,7 @@ workers_init (int num_workers)
{
int i;
if (!major.is_parallel)
if (!major_collector.is_parallel)
return;
//g_print ("initing %d workers\n", num_workers);
@@ -274,7 +274,7 @@ workers_start_all_workers (int num_additional_workers)
{
int i;
if (!major.is_parallel)
if (!major_collector.is_parallel)
return;
g_assert (workers_num_working == 0);
@@ -289,7 +289,7 @@ workers_join (void)
{
int i;
if (!major.is_parallel)
if (!major_collector.is_parallel)
return;
//g_print ("joining\n");
@@ -313,7 +313,7 @@ mono_sgen_is_worker_thread (pthread_t thread)
{
int i;
if (!major.is_parallel)
if (!major_collector.is_parallel)
return FALSE;
for (i = 0; i < workers_num; ++i) {
+16 -8
View File
@@ -2981,8 +2981,10 @@ mono_threads_is_shutting_down (void)
void mono_thread_manage (void)
{
struct wait_data *wait=g_new0 (struct wait_data, 1);
struct wait_data wait_data;
struct wait_data *wait = &wait_data;
memset (wait, 0, sizeof (struct wait_data));
/* join each thread that's still running */
THREAD_DEBUG (g_message ("%s: Joining each running thread...", __func__));
@@ -2990,7 +2992,6 @@ void mono_thread_manage (void)
if(threads==NULL) {
THREAD_DEBUG (g_message("%s: No threads", __func__));
mono_threads_unlock ();
g_free (wait);
return;
}
mono_threads_unlock ();
@@ -3007,6 +3008,8 @@ void mono_thread_manage (void)
ResetEvent (background_change_event);
wait->num=0;
/*We must zero all InternalThread pointers to avoid making the GC unhappy.*/
memset (wait->threads, 0, MAXIMUM_WAIT_OBJECTS * SIZEOF_VOID_P);
mono_g_hash_table_foreach (threads, build_wait_tids, wait);
mono_threads_unlock ();
if(wait->num>0) {
@@ -3033,6 +3036,8 @@ void mono_thread_manage (void)
mono_threads_lock ();
wait->num = 0;
/*We must zero all InternalThread pointers to avoid making the GC unhappy.*/
memset (wait->threads, 0, MAXIMUM_WAIT_OBJECTS * SIZEOF_VOID_P);
mono_g_hash_table_foreach_remove (threads, remove_and_abort_threads, wait);
mono_threads_unlock ();
@@ -3052,8 +3057,6 @@ void mono_thread_manage (void)
#ifndef HOST_WIN32
sched_yield ();
#endif
g_free (wait);
}
static void terminate_thread (gpointer key, gpointer value, gpointer user)
@@ -3114,13 +3117,15 @@ collect_threads_for_suspend (gpointer key, gpointer value, gpointer user_data)
*/
void mono_thread_suspend_all_other_threads (void)
{
struct wait_data *wait = g_new0 (struct wait_data, 1);
struct wait_data wait_data;
struct wait_data *wait = &wait_data;
int i;
gsize self = GetCurrentThreadId ();
gpointer *events;
guint32 eventidx = 0;
gboolean starting, finished;
memset (wait, 0, sizeof (struct wait_data));
/*
* The other threads could be in an arbitrary state at this point, i.e.
* they could be starting up, shutting down etc. This means that there could be
@@ -3147,6 +3152,8 @@ void mono_thread_suspend_all_other_threads (void)
* threads while threads_mutex is held.
*/
wait->num = 0;
/*We must zero all InternalThread pointers to avoid making the GC unhappy.*/
memset (wait->threads, 0, MAXIMUM_WAIT_OBJECTS * SIZEOF_VOID_P);
mono_threads_lock ();
mono_g_hash_table_foreach (threads, collect_threads_for_suspend, wait);
mono_threads_unlock ();
@@ -3243,8 +3250,6 @@ void mono_thread_suspend_all_other_threads (void)
g_free (events);
}
g_free (wait);
}
static void
@@ -3273,9 +3278,12 @@ collect_threads (gpointer key, gpointer value, gpointer user_data)
void
mono_threads_request_thread_dump (void)
{
struct wait_data *wait = g_new0 (struct wait_data, 1);
struct wait_data wait_data;
struct wait_data *wait = &wait_data;
int i;
memset (wait, 0, sizeof (struct wait_data));
/*
* Make a copy of the hashtable since we can't do anything with
* threads while threads_mutex is held.
+6
View File
@@ -2797,6 +2797,12 @@ Wed Jan 13 15:54:53 CET 2010 Paolo Molaro <[email protected]>
* tramp-amd64.c (mono_arch_nullify_class_init_trampoline): Fix the LLVM support
by merging the LLVM and !MAP_32BIT cases.
2009-12-14 Geoff Norton <[email protected]>
* debugger-agent.c: The end_runtime_invoke guard isn't working on
AMD64 as __builtin_frame_address (1) returns NULL. Disable the
behaviour by default, and make it runtime configurable.
2009-12-13 Jonathan Chambers <[email protected]>
* debugger-agent.c (mono_debugger_agent_thread_interrupt): Handle a NULL
+1 -1
View File
@@ -48,7 +48,7 @@
memory_barrier: len:4
nop: len:4
relaxed_nop: len:4
break: len:4
break: len:40
seq_point: len:48
jmp: len:96
call: dest:a clob:c len:36
+14 -7
View File
@@ -103,6 +103,7 @@ typedef struct {
GSList *onthrow;
int timeout;
char *launch;
gboolean embedding;
} AgentConfig;
typedef struct
@@ -232,7 +233,7 @@ typedef struct {
#define HEADER_LENGTH 11
#define MAJOR_VERSION 2
#define MINOR_VERSION 1
#define MINOR_VERSION 2
typedef enum {
CMD_SET_VM = 1,
@@ -534,6 +535,8 @@ static HANDLE debugger_thread_handle;
static int log_level;
static gboolean embedding;
static FILE *log_file;
/* Classes whose class load event has been sent */
@@ -582,9 +585,9 @@ static void runtime_initialized (MonoProfiler *prof);
static void runtime_shutdown (MonoProfiler *prof);
static void thread_startup (MonoProfiler *prof, intptr_t tid);
static void thread_startup (MonoProfiler *prof, uintptr_t tid);
static void thread_end (MonoProfiler *prof, intptr_t tid);
static void thread_end (MonoProfiler *prof, uintptr_t tid);
static void appdomain_load (MonoProfiler *prof, MonoDomain *domain, int result);
@@ -727,6 +730,8 @@ mono_debugger_agent_parse_options (char *options)
agent_config.timeout = atoi (arg + 8);
} else if (strncmp (arg, "launch=", 7) == 0) {
agent_config.launch = g_strdup (arg + 7);
} else if (strncmp (arg, "embedding=", 10) == 0) {
agent_config.embedding = atoi (arg + 10) == 1;
} else {
print_usage ();
exit (1);
@@ -794,6 +799,8 @@ mono_debugger_agent_init (void)
log_level = agent_config.log_level;
embedding = agent_config.embedding;
if (agent_config.log_file) {
log_file = fopen (agent_config.log_file, "w+");
if (!log_file) {
@@ -899,7 +906,7 @@ mono_debugger_agent_cleanup (void)
//WaitForSingleObject (debugger_thread_handle, INFINITE);
if (GetCurrentThreadId () != debugger_thread_id) {
mono_mutex_lock (&debugger_thread_exited_mutex);
if (!debugger_thread_exited) {
while (!debugger_thread_exited) {
#ifdef HOST_WIN32
if (WAIT_TIMEOUT == WaitForSingleObject(debugger_thread_exited_cond, 0)) {
mono_mutex_unlock (&debugger_thread_exited_mutex);
@@ -2833,7 +2840,7 @@ runtime_shutdown (MonoProfiler *prof)
}
static void
thread_startup (MonoProfiler *prof, intptr_t tid)
thread_startup (MonoProfiler *prof, uintptr_t tid)
{
MonoInternalThread *thread = mono_thread_internal_current ();
MonoInternalThread *old_thread;
@@ -2895,7 +2902,7 @@ thread_startup (MonoProfiler *prof, intptr_t tid)
}
static void
thread_end (MonoProfiler *prof, intptr_t tid)
thread_end (MonoProfiler *prof, uintptr_t tid)
{
MonoInternalThread *thread;
DebuggerTlsData *tls = NULL;
@@ -3000,7 +3007,7 @@ end_runtime_invoke (MonoProfiler *prof, MonoMethod *method)
gpointer stackptr = __builtin_frame_address (1);
#endif
if (ss_req == NULL || stackptr != ss_invoke_addr || ss_req->thread != mono_thread_internal_current ())
if (!embedding || ss_req == NULL || stackptr != ss_invoke_addr || ss_req->thread != mono_thread_internal_current ())
return;
/*
+1 -1
View File
@@ -3792,7 +3792,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
*/
mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_SWITCH, ins->inst_p0);
max_len += 4 * GPOINTER_TO_INT (ins->klass);
if (offset > (cfg->code_size - max_len - 16)) {
if (offset + max_len > (cfg->code_size - 16)) {
cfg->code_size += max_len;
cfg->code_size *= 2;
cfg->native_code = g_realloc (cfg->native_code, cfg->code_size);
+1 -1
View File
@@ -244,7 +244,7 @@ $(scripts_4_0): $(SCRIPT_IN) Makefile
mv -f $@.tmp $@
$(scripts_mono_configuration_crypto): mono-configuration-crypto.in
$(REWRITE2) -e "s,@exe_name@,mono-configuration-crypto,g" $(srcdir)/mono-configuration-crypto.in > $@.tmp
$(REWRITE4) -e "s,@exe_name@,mono-configuration-crypto,g" $(srcdir)/mono-configuration-crypto.in > $@.tmp
mv -f $@.tmp $@
$(MDOC_SUBCOMMANDS): Makefile