Commit Graph
161 Commits
Author SHA1 Message Date
Paolo Molaro b795fe8f87 Implemented fast version of ThreadLocal<T>.
This patchset implements a fast version of ThreadLocal<T> by reusing the code from
the implementation of the ThreadStatic attribute. The tls slots are cleaned up
on Dispose (or Finalize) instead of during appdomain shutdown.
Since C# doesn't allow us to define an icall that returns a T& or a T* type, a JIT
hack is used: every load field address instruction for the tlsdata field in
ThreadLocal<T> is intercepted and trasformed into a tls access by using the tls_offset
field from the same ThreadLocal<T> instance. So, while the C# code looks like
it accesses and changes an instance field, under the hood it will access the tls
storage.
The end result is that this is 5-6 times faster than the previous code, 10-15%
faster than using Thread.GetData () (when used with references).
This implementation also fixes a number of issues with disposing and with
per-thread initializers throwing an exception.
2011-03-01 16:43:48 +01:00
Rodrigo Kumpera fee645b660 Make maxStackSize behavior compatible with MS.
* Thread.cs (.ctor): Check if maxStackSize is negative
	and raise and AOORE. Silently use a saner minimum size
	of 128k as mono can't really run with much less than that.
2011-02-11 14:56:58 +01:00
Gonzalo Paniagua Javier d84abdc22a Move some code into their own methods. 2011-02-09 18:09:03 -05:00
Gonzalo Paniagua Javier df5d05c37f Attempt 1 2011-02-09 12:04:56 -05:00
Geoff Norton 83e999b7d7 Add pfx to the mobile profile 2011-01-25 01:51:17 -05:00
Marek Safar d84d7c7eb9 Remove no longer used BOOTSTRAP conditionals 2010-12-29 12:41:12 +00:00
Rodrigo Kumpera 9d15836e9e Fix corlib regression 2010-11-27 03:20:29 -02:00
Rodrigo Kumpera 0a609bf3de Move culture handling to Thread from InternalThread.
* Thread.cs: Move culture data from InternalThread to Thread
	and thus completely avoid the whole caching and serialization
	nightmare. Even thou this is a cleanup it should speed up
	multi-appdomain setups.

	* threads.c: Remove culture caching machinery.

	* icall-def.h: Ditto.

	Fixes #318750 as a byproduct.
2010-11-27 02:56:37 -02:00
Zoltan Varga 150aa825d5 Fix the previous change. 2010-11-09 20:00:23 +01:00
Zoltan Varga 8e0d6b1111 Speed up Thread.ManagedThreadId. 2010-11-09 19:53:05 +01:00
Jérémie Laval 0856ee3930 Add Yield method to Thread (4.0 profile).
Yield is an internal call that simply calls wapi SwitchToThread function.
On !Windows system, this functions use POSIX sched_yield function.
2010-07-29 11:49:55 +02:00
Jb Evain ba09e4ba86 use MOONLIGHT symbol
svn path=/trunk/mcs/; revision=153658
2010-03-16 12:11:37 +00:00
Marek Safar 3086e99d75 Warnings cleanup
svn path=/trunk/mcs/; revision=146142
2009-11-13 14:52:59 +00:00
Miguel de Icaza 7f825c2dbe More NET_2_0 removal
svn path=/trunk/mcs/; revision=145236
2009-11-03 01:08:45 +00:00
Miguel de Icaza 5e63701d4b 2009-11-02 Miguel de Icaza <[email protected]>
* Jumbo patch to drop support for pre-NET_2_0 code:

        Remove ONLY_1_1 code
        Remove NET_1_0 only code
        Remove NET_2_0 defines assuming the value is true.


svn path=/trunk/mcs/; revision=145230
2009-11-02 23:22:40 +00:00
Sebastien Pouliot ccffcae90d 2009-11-02 Sebastien Pouliot <[email protected]>
* Thread.cs (set_CurrentUICulture): Delay setting in_currentculture
	to true until after the null check and the return statement.


svn path=/trunk/mcs/; revision=145214
2009-11-02 20:05:35 +00:00
Sebastien Pouliot b6a5bb1207 In System.Threading:
2009-10-25  Sebastien Pouliot  <[email protected]>

	* Thread.cs: Fix validations for Join and Sleep overloads

In Test/System.Threading:
2009-10-25  Sebastien Pouliot  <[email protected]>

	* ThreadTest.cs: Add test cases for Current[UI]Culture (not 
	working), Name, Join, Sleep and SpinWait


svn path=/trunk/mcs/; revision=144824
2009-10-25 16:41:18 +00:00
Jb Evain d40cd894df 2009-10-20 Jb Evain <[email protected]>
* Thread.cs: change type of the current_appcontext field to object
	to avoid triggering static constructors unless explicitely required.


svn path=/trunk/mcs/; revision=144431
2009-10-20 09:03:19 +00:00
Geoff Norton 88026a47b4 fix MONOTOUCH on trunk
svn path=/trunk/mcs/; revision=144133
2009-10-14 18:49:14 +00:00
Sebastien Pouliot c85fce7f73 2009-10-07 Sebastien Pouliot <[email protected]>
* Thread.cs: Remove LocalDataStoreSlot-related methods from
	Moonlight build


svn path=/trunk/mcs/; revision=143629
2009-10-07 12:31:16 +00:00
Mark Probst 1d313a8230 2009-09-30 Mark Probst <[email protected]>
* Thread.cs: Remove serialized culture icall stuff from
	InternalThread.  Implement it by using the cross-domain byte array
	transfer icalls.

	* Environment.cs: Corlib version bump.

svn path=/trunk/mcs/; revision=143040
2009-09-30 16:09:56 +00:00
Rolf Bjarne Kvinge 2994492806 2009-09-29 Rolf Bjarne Kvinge <[email protected]>
* Thread.cs: StartSafe: ignore ThreadAbortExceptions.

svn path=/trunk/mcs/; revision=142847
2009-09-29 10:59:54 +00:00
Mark Probst 1c5ff76d6c 2009-09-26 Mark Probst <[email protected]>
* Thread.cs: Serialize the principal so as not to make it cross
	appdomains.  Two new internal calls for copying byte arrays
	between domains.

2009-09-26  Mark Probst  <[email protected]>

	* Environment.cs: Corlib version bump.

svn path=/trunk/mcs/; revision=142671
2009-09-26 11:20:02 +00:00
Mark Probst 0473dde9f7 2009-09-25 Mark Probst <[email protected]>
* Thread.cs: The Thread class is split up into Thread and
	InternalThread now.  We have exactly one InternalThread per
	thread, and at most one Thread per appdomain per thread.  Most
	data is stored in InternalThread.  All InternalThread objects live
	in the root domain.

	* Environment.cs: Corlib version bump.

svn path=/trunk/mcs/; revision=142661
2009-09-25 21:48:40 +00:00
Sebastien Pouliot f07228a460 2009-09-23 Sebastien Pouliot <[email protected]>
* ExecutionContext.cs: Don't use SecurityContext and don't expose
	AsyncFlowControl for NET_2_1
	* ThreadAbortException.cs: Remove ExceptionState from NET_2_1
	* Thread.cs: Don't expose ApartmentState and remove Suspend and
	Resume methods for NET_2_1
	* ThreadPool.cs: Remove GetAvailableThreads and Unsafe* methods
	for NET_2_1


svn path=/trunk/mcs/; revision=142481
2009-09-23 12:58:58 +00:00
Sebastien Pouliot a0818feb95 2009-09-22 Sebastien Pouliot <[email protected]>
* Thread.cs: Remove [Get|Set]CompressedStack for NET_2_1


svn path=/trunk/mcs/; revision=142401
2009-09-22 13:40:55 +00:00
Sebastien Pouliot 5d0ed14755 In System.Threading:
2009-09-21  Sebastien Pouliot  <[email protected]>

	* Thread.cs: Remove CurrentPrincipal property for NET_2_1
	* ExecutionContext.cs: Remove Run method for NET_2_1

In System.Security:
2009-09-21  Sebastien Pouliot  <[email protected]>

	* SecurityContext.cs: Don't use WindowsIdentity under NET_2_1

In System:
2009-09-21  Sebastien Pouliot  <[email protected]>

	* AppDomain.cs: Remove use of IPrincipal, Evidence and 
	PermissionSet types for NET_2_1

In .:
2009-09-21  Sebastien Pouliot  <[email protected]>

	* net_2_1_bootstrap_corlib.dll.sources, net_2_1_raw_corlib.dll.sources:
	Remove most of System.Security.Policy and System.Security.Principal
	and more of System.Security.Permissions from NET_2_1 build

In System.Security.Policy:
2009-09-21  Sebastien Pouliot  <[email protected]>

	* PolicyLevel_2_1.cs: Remove use of PolicyStatement


svn path=/trunk/mcs/; revision=142324
2009-09-21 11:54:24 +00:00
Zoltan Varga f1fd210aab 2009-08-03 Zoltan Varga <[email protected]>
* Thread.cs: Always call Thread_free_internal from the finalizer, since
	it frees other things besides the handle. Fixes #527576.

svn path=/trunk/mcs/; revision=139281
2009-08-03 13:28:59 +00:00
Jb Evain 6fe38f5790 2009-07-20 Jb Evain <[email protected]>
* Thread.cs: use the moonlight specific thread start
	hack for the net_2_1 profile exclusively.


svn path=/trunk/mcs/; revision=138225
2009-07-20 16:03:23 +00:00
Bill Holmes 48cfa18d07 2009-06-22 Bill Holmes <[email protected]>
* object-internals.h : Adding interrupt_on_stop field.

	* threads.c (mono_thread_request_interruption) : On Windows exit the
	  thread if interrupt_on_stop is set.

	* socket-io.c (ves_icall_System_Net_Sockets_Socket_Accept_internal) :
	  Removing old interrupt logic and setting the interrupt_on_stop for the
	  thread when calling accept.

	* socket-io.c (ves_icall_System_Net_Sockets_Socket_Receive_internal) :
	  setting the interrupt_on_stop for the thread when calling accept.

	* Thread.cs : Adding interrupt_on_stop field.

	Contributed under MIT/X11 license.


svn path=/trunk/mcs/; revision=136628
2009-06-22 17:41:26 +00:00
Rolf Bjarne Kvinge 003f517773 2009-06-10 Rolf Bjarne Kvinge <[email protected]>
* Thread.cs: MoonlightUnhandledException: ensure there's no way to
	reach native code with a managed exception.

svn path=/trunk/mcs/; revision=135897
2009-06-10 22:17:32 +00:00
Sebastien Pouliot bd19dacb39 2009-06-10 Sebastien Pouliot <[email protected]>
* Thread.cs: Refactor calling Moonlight's OnUnhandledException to 
	make sur the delegate it not called from a [SecuritySafeCritical]
	caller.
	* ThreadPool.cs: Reuse the above code for QueueUserWorkItem. 
	Original patch from Alan McGovern


svn path=/trunk/mcs/; revision=135866
2009-06-10 17:17:55 +00:00
Mark Probst 5bb6e7f1dc 2009-05-26 Mark Probst <[email protected]>
* Thread.cs: Don't set the execution context when creating a
        thread because the _ec member is thread static and we set the
        wrong one.  It's now set by the runtime.  We just provide the
        correct one.

        * Environment.cs: Bump corlib version.

svn path=/trunk/mcs/; revision=134773
2009-05-26 16:06:58 +00:00
Mark Probst 322f82badc 2009-04-21 Mark Probst <[email protected]>
* Thread.cs: Make the execution context field thread-static to
        avoid it being shared between app domains.

2009-04-21  Mark Probst  <[email protected]>

        * Environment.cs: Bump corlib version.

svn path=/trunk/mcs/; revision=132308
2009-04-21 18:39:48 +00:00
Rolf Bjarne Kvinge 42a3e10016 2009-04-20 Rolf Bjarne Kvinge <[email protected]>
* Thread.cs: For 2.1 ensure exceptions in threads are handled using the
	UnhandledException event mechanism in System.Windows.Application instead
	of crashing the application.


svn path=/trunk/mcs/; revision=132166
2009-04-20 12:57:02 +00:00
Mark Probst 7466b0e42e 2009-04-18 Mark Probst <[email protected]>
* NumberFormatter.cs: Keep the current thread's number formatter
        as a ThreadStatic member.

2009-04-18  Mark Probst  <[email protected]>

        * Thread.cs: Don't keep the current number formatter here
        because it's shared between app domains.

svn path=/trunk/mcs/; revision=132067
2009-04-17 23:32:33 +00:00
Mark Probst 88270f8ee7 Proper app domain separation regarding thread abort exception state.
2009-04-18  Mark Probst  <[email protected]>

        * Thread.cs: Make the abort exception state a GC handle, to
        properly separate AppDomains.  Add internal method for getting the
        state object.

        * ThreadAbortException.cs: Get the abort exception state via the
        method in Thread.

2009-04-18  Mark Probst  <[email protected]>

        * Environment.cs: Bump corlib version.

svn path=/trunk/mcs/; revision=132063
2009-04-17 23:01:02 +00:00
Paolo Molaro 6a71988302 Tue Sep 16 21:02:59 CEST 2008 Paolo Molaro <[email protected]>
* Thread.cs: fixed SpinWait() implementation (bug #423582).


svn path=/trunk/mcs/; revision=113209
2008-09-16 19:05:54 +00:00
Marek Safar 159314e044 Warnings cleanup
svn path=/trunk/mcs/; revision=111730
2008-08-27 18:28:16 +00:00
Marek Safar cc9c53a109 Warnings cleanup
svn path=/trunk/mcs/; revision=111713
2008-08-27 15:40:13 +00:00
Kornél Pál 2d861bf887 * Thread.cs: Implement BeginThreadAffinity and EndThreadAffinity as no-op because managed and native threads are currently bound together.
svn path=/trunk/mcs/; revision=106145
2008-06-18 18:15:24 +00:00
Zoltan Varga e492e68db8 2008-06-14 Zoltan Varga <[email protected]>
* Thread.cs: Sync layout with unmanaged side.

svn path=/trunk/mcs/; revision=105811
2008-06-13 22:45:17 +00:00
Zoltan Varga 2eacc0fdf5 2008-04-11 Zoltan Varga <[email protected]>
* Thread.cs: Make in_currentculture non-static. Fixes #378892.

svn path=/trunk/mcs/; revision=100464
2008-04-11 18:50:22 +00:00
Dick Porter 68eaed43c0 2008-04-07 Dick Porter <[email protected]>
* Thread.cs: Fix throwing of exceptions when manipulating
	ApartmentState.  Fixes part of bug 324338.



svn path=/trunk/mcs/; revision=100010
2008-04-07 11:12:10 +00:00
Eyal Alalouf 41501f96be Improve ToString perf of primitive types.
svn path=/trunk/mcs/; revision=99502
2008-04-01 11:37:11 +00:00
Massimiliano Mantione 7633bb9b56 Thread.cs: Renamed "unused6" because it will be used to hold the "mono_thread_manage" callback.
svn path=/trunk/mcs/; revision=99029
2008-03-26 13:12:22 +00:00
Paolo Molaro 5e0ee89e62 Fri Feb 22 11:23:53 CET 2008 Paolo Molaro <[email protected]>
* Thread.cs: implemented Begin/EndCriticalRegion.


svn path=/trunk/mcs/; revision=96410
2008-02-22 09:39:36 +00:00
Zoltan Varga 37ab41a282 2008-01-06 Zoltan Varga <[email protected]>
* Thread.cs (set_CurrentCulture): If the culture is read-only, cache the result
	of serializing it.
	(set_CurrentUICulture): Ditto.

svn path=/trunk/mcs/; revision=92335
2008-01-06 11:05:05 +00:00
Zoltan Varga a278bd3b4d 2008-01-03 Zoltan Varga <[email protected]>
* Thread.cs (set_CurrentCulture): Avoid the serialization overhead if
	the new culture is equal to the old one.

svn path=/trunk/mcs/; revision=92201
2008-01-03 19:05:50 +00:00
Zoltan Varga f42cbf51d2 2007-12-27 Zoltan Varga <[email protected]>
* Thread.cs: Change the type of synch_cs to an IntPtr to be in synch with the
	unmanaged definition.

svn path=/trunk/mcs/; revision=91908
2007-12-26 22:43:39 +00:00