The way DefaultThreadCurrentCulture is to be implemented is that its current value
will always be used by a thread that didn't set a value for its culture.
This means we can't cache DefaultThreadCurrentCulture value as it's allowed to
change and threads must always show the latest value.
the problem of changing the culture when a new value is set in the current thread
is that is doesn't work well with CultureInfo.DefaultThreadCurrentCulture.
This fixes bug #667329.
The problem was that ManagedThreadId was created from a per-appdomain
counter, but stored in a per-thread storage, so if two threads could
end up with the same ManagedThreadId if a second appdomain executed
on the second thread first.
* mono-threads.c: An implementation of low level thread management that
fits what sgen needs. It uses hazard pointers to manage the thread list
since we can't protect it with the GC lock as this would cause boehm to
deadlock. This requires us to move small_id one layer down.
* Thread.cs:
* object-internals.h:
* threads.c: Small id is now stored on MonoThreadInfo so it can be
used by lower layers of the runtime such as sgen.
* sgen-major-copying.c:
* sgen-os-mach.c:
* sgen-os-posix.c:
* sgen-gc.h:
* sgen-gc.c: Replace sgen's thread management code with
the new one.
* boehm-gc.c: Hookup the new thread management code. Boehm's
own management code is not been replaced as I'm too much of
a coward to mess with it.
* hazard-pointer.c: Adjust to the new location of small_id.
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.
* 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.
* 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.
* 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
* 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
* 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
* 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