mono.git
7 years ago[profiler] Process requests in enter/leave callbacks regardless of call depth.
Alex Rønne Petersen [Wed, 3 Aug 2016 11:58:03 +0000 (13:58 +0200)]
[profiler] Process requests in enter/leave callbacks regardless of call depth.

Heapshots have nothing to do with call depth, so they should be processed in
any case.

Also flush the local buffer in all enter/leave callbacks if needed.

7 years ago[profiler] Periodically flush all thread-local buffers.
Alex Rønne Petersen [Thu, 21 Jul 2016 09:24:05 +0000 (11:24 +0200)]
[profiler] Periodically flush all thread-local buffers.

This ensures that even for low-activity threads, it won't take ages before the
events from it arrive. We do this flush every 1sec (as with sampling of perf
counters).

7 years ago[profiler] Implement global flush points for thread-local buffers.
Alex Rønne Petersen [Wed, 20 Jul 2016 16:21:53 +0000 (18:21 +0200)]
[profiler] Implement global flush points for thread-local buffers.

The problem is this: Given an allocation of object O on address A1 in thread T1
and a subsequent GC move of O from A1 to A2 in T2, if T2's event buffer is
flushed before T1's buffer, the reader of the log file will a seemingly
nonexistent object being moved, and then see the actual allocation of that
object later. This makes it extremely difficult to keep track of the managed
heap.

The way we solve this is by flushing all thread-local buffers when the GC stops
the world. This way, we know that all prior allocations in the program have
been committed to the log file before any moves that are about to follow as
part of the collection. Similarly, we flush the GC thread's buffer before
restarting the world to ensure that all moves are committed before allocations
that may happen later (which could use some of the addresses freed up for use
due to the moves).

This is reasonably easy now that we have a global LLS of threads which are
attached to the profiler. However, we have to use some kind of lock to ensure
that buffers aren't being written to while we're trying to flush them, or that
a suspended thread was in the middle of modifying its buffer. For this, we use
a reader/writer spin lock of sorts, somewhat similar to the lock used by the
SGen binary protocol. When threads are modifying their own buffer (whether it
be writing to it or flushing it), they take the reader lock. This means that
many different threads can be operating on their own buffers without any lock
contention (which would kinda defeat the purpose of the thread-local buffers).
Now, when a thread -- such as the thread that initiated a GC -- wants to access
the buffers of other threads, it takes the writer lock. In doing so, all other
threads are prevented from modifying their own buffers. This gives the thread
holding the writer lock an opportunity to flush the buffers of other threads.

7 years ago[utils/threads] Export mono_thread_info_yield () for use in the profiler.
Alex Rønne Petersen [Wed, 20 Jul 2016 13:48:01 +0000 (15:48 +0200)]
[utils/threads] Export mono_thread_info_yield () for use in the profiler.

7 years ago[profiler] Remove LogBuffer.locked and related debugging code.
Alex Rønne Petersen [Wed, 20 Jul 2016 01:39:47 +0000 (03:39 +0200)]
[profiler] Remove LogBuffer.locked and related debugging code.

This hasn't been needed for a long time.

7 years ago[profiler] Rewrite TLS code.
Alex Rønne Petersen [Tue, 19 Jul 2016 10:35:01 +0000 (12:35 +0200)]
[profiler] Rewrite TLS code.

* Actual thread-local state is now stored in a MonoProfilerThread struct which
  is stored in a single TLS slot per thread. This avoids storing things like
  call_depth in LogBuffer. The current LogBuffer of a thread is also stored in
  the MonoProfilerThread.
* All MonoProfilerThread structs are stored in a global linked list set. This
  LLS is used to manually clean up the thread-local state of threads that, for
  whatever reason, don't have the thread_end () callback invoked.
* Lifetime management of thread-local buffers is now much more straightforward.
* The thread-local list of referenced methods is now only allocated if needed.
* Fixed a MethodInfo memory leak in handle_writer_queue_entry ().
* Fixed some class load events that could be lost in the writer thread when
  fetching the full name of a method.
* TLS slots are now actually freed on shutdown.

7 years ago[profiler] Implement process_id () for Windows.
Alex Rønne Petersen [Tue, 19 Jul 2016 04:13:59 +0000 (06:13 +0200)]
[profiler] Implement process_id () for Windows.

7 years ago[utils/lls] Export the linked list set API for use in the profiler.
Alex Rønne Petersen [Tue, 19 Jul 2016 02:57:57 +0000 (04:57 +0200)]
[utils/lls] Export the linked list set API for use in the profiler.

Also exported a couple of hazard pointer functions used by the LLS macros.

7 years ago[utils/lls] Use mono_thread_hazardous_queue_free () instead of mono_thread_hazardous_...
Alex Rønne Petersen [Tue, 19 Jul 2016 02:52:55 +0000 (04:52 +0200)]
[utils/lls] Use mono_thread_hazardous_queue_free () instead of mono_thread_hazardous_try_free ().

We cannot use the latter as we do not know whether the free function is safe to call.

7 years ago[utils/lls] Rename get_hazardous_pointer_with_mask () to mono_lls_get_hazardous_point...
Alex Rønne Petersen [Tue, 19 Jul 2016 02:51:03 +0000 (04:51 +0200)]
[utils/lls] Rename get_hazardous_pointer_with_mask () to mono_lls_get_hazardous_pointer_with_mask ().

7 years ago[utils/hp] Rename get_hazardous_pointer () to mono_get_hazardous_pointer ().
Alex Rønne Petersen [Tue, 19 Jul 2016 02:50:44 +0000 (04:50 +0200)]
[utils/hp] Rename get_hazardous_pointer () to mono_get_hazardous_pointer ().

7 years ago[utils/hp] Remove HazardFreeLocking and HazardFreeContext enums.
Alex Rønne Petersen [Tue, 19 Jul 2016 02:43:21 +0000 (04:43 +0200)]
[utils/hp] Remove HazardFreeLocking and HazardFreeContext enums.

These are no longer useful in the new hazard free API.

7 years ago[profiler] Only forward declare structs that need it.
Alex Rønne Petersen [Tue, 19 Jul 2016 02:18:50 +0000 (04:18 +0200)]
[profiler] Only forward declare structs that need it.

7 years agoRevert "[runtime] Fix pedump by using the normal embedding APIs instead of in…" ...
Zoltan Varga [Mon, 29 Aug 2016 22:01:18 +0000 (00:01 +0200)]
Revert "[runtime] Fix pedump by using the normal embedding APIs instead of in…" (#3479)

7 years agoMerge pull request #3478 from vargaz/fix-pedump
Rodrigo Kumpera [Mon, 29 Aug 2016 21:51:30 +0000 (17:51 -0400)]
Merge pull request #3478 from vargaz/fix-pedump

[runtime] Fix pedump by using the normal embedding APIs instead of in…

7 years ago[runtime] Fix pedump by using the normal embedding APIs instead of initializing parts...
Zoltan Varga [Mon, 29 Aug 2016 20:37:22 +0000 (22:37 +0200)]
[runtime] Fix pedump by using the normal embedding APIs instead of initializing parts of the runtime. Fixes #43786.

7 years agoMerge pull request #3422 from xmcclure/tarjan-doublefan
monojenkins [Mon, 29 Aug 2016 20:30:06 +0000 (22:30 +0200)]
Merge pull request #3422 from xmcclure/tarjan-doublefan

Make GC bridge perform well in the "double fan" scenario

The GC bridge currently performs VERY poorly when the object graph has a "double fan" shape. If M Java objects point to 1 C# object which points to N Java objects, the graph exported to Monodroid will currently drop the C# object node and replace it with (M\*N) edges. It is easy to write code where (M\*N) grows ludicrously big.

In testing on device, this patch solves that problem while leaving other cases unaffected. In testing on device, I found:
* All performance tests except double fan: No discernible performance difference after patch
* Double fan test with M=N=1000: Before the patch this took between three and seven seconds. After the patch this took between 0.2 and 0.3 seconds.
* Double fan test with M=N=4000: Before the patch this took anywhere from one to two minutes. After the patch, this took about 1.2 seconds.
* Double fan test with M=N=6000: Before the patch, this took so long I was not able to get it to ever complete. After the patch, this took about 1.3 seconds.
* Double fan test with M=N=20000: I did not attempt this test pre-patch. After the patch, it took about 5.6 seconds.

The commit messages describe the changes in some detail but the short version is:
* Add a mechanism for exporting non-bridged SCCs to the bridge client
* Turn that mechanism on whenever the product fanin*fanout grows too large
* Make the merge cache more aggressive

To function, this patch requires a corresponding change to monodroid. See https://github.com/xamarin/xamarin-android/pull/154

7 years ago[Facades] Remove private facade
Marek Safar [Mon, 29 Aug 2016 19:40:50 +0000 (21:40 +0200)]
[Facades] Remove private facade

7 years agoMerge pull request #3463 from david-mitchell/al-platform-switch
Marek Safar [Mon, 29 Aug 2016 19:31:33 +0000 (21:31 +0200)]
Merge pull request #3463 from david-mitchell/al-platform-switch

Add missing switch and functionality to al.

7 years agoGC bridge: Fix non-buildable assert ()s added in previous commits
Andi McClure [Mon, 29 Aug 2016 18:34:22 +0000 (14:34 -0400)]
GC bridge: Fix non-buildable assert ()s added in previous commits

7 years agoMerge pull request #3468 from alexrp/hwcap-improvements
Alex Rønne Petersen [Mon, 29 Aug 2016 18:26:46 +0000 (20:26 +0200)]
Merge pull request #3468 from alexrp/hwcap-improvements

[utils/hwcap] Clean up and improve the hwcap code.

7 years agoGC bridge: Move bridge-require-precise-merge to MONO_GC_PARAMS
Andi McClure [Mon, 29 Aug 2016 17:48:48 +0000 (13:48 -0400)]
GC bridge: Move bridge-require-precise-merge to MONO_GC_PARAMS

This was previously in MONO_GC_DEBUG, but we do not use this for
production-viable flags.

7 years ago[corlib] Improve CanceledContinuationExecuteSynchronouslyTest test
Marek Safar [Mon, 29 Aug 2016 16:39:14 +0000 (18:39 +0200)]
[corlib] Improve CanceledContinuationExecuteSynchronouslyTest test

7 years agoAdd missing switch and functionality to al.
David Mitchell [Fri, 26 Aug 2016 23:24:32 +0000 (16:24 -0700)]
Add missing switch and functionality to al.

When running msbuild on mono against an architecture-specific
project that also defines satellite assemblies, the /platform
switch will be passed to al.exe. Mono's implementation of al.exe
does not support this switch, which results in a failed build.

This commit adds the /platform switch, which also required
changing the implementation from System.Reflection to
IKVM.Reflection because Mono's implementation of AssemblyBuilder
does not support the necessary options.

While testing this change, I also noticed a few attributes that
the MS version of al.exe will copy from "template" assemblies,
so I added support for those, as well.

7 years ago[mcs] Add reference to parent storey when current value type async storey needs fabri...
Marek Safar [Mon, 29 Aug 2016 16:01:39 +0000 (18:01 +0200)]
[mcs] Add reference to parent storey when current value type async storey needs fabricated this access. Fixes #40860

7 years ago[llvm] Fix the arm cross compiler build when using llvm 3.9.
Zoltan Varga [Mon, 29 Aug 2016 14:49:05 +0000 (16:49 +0200)]
[llvm] Fix the arm cross compiler build when using llvm 3.9.

7 years agoMerge pull request #3453 from ntherning/cleanup-AssemblyTest-temp-file-handling
Marek Safar [Mon, 29 Aug 2016 14:46:04 +0000 (16:46 +0200)]
Merge pull request #3453 from ntherning/cleanup-AssemblyTest-temp-file-handling

Cleanup temp file handling in AssemblyTest

7 years agoCleanup temp file handling in AssemblyTest
Niklas Therning [Thu, 25 Aug 2016 15:33:14 +0000 (17:33 +0200)]
Cleanup temp file handling in AssemblyTest

SetUp() already sets up a temp folder for the test methods and TearDown()
handles cleaning up and taking into account that on Windows, loaded assemblies
cannot be deleted. However, some of the tests created temp files outside of
this folder and had their own cleanup code which didn't expect temp files to
be undeletable on Windows.

This patch removes any custom temp file creation/cleanup from individual test
methods. It also slightly changes the way SetUp() created the temp folder for
each test, now the paths will be shallower.

7 years ago[utils/hwcap] Clean up and improve the hwcap code.
Alex Rønne Petersen [Thu, 28 Jul 2016 15:26:49 +0000 (17:26 +0200)]
[utils/hwcap] Clean up and improve the hwcap code.

* Get rid of the arch-specific headers.
* Do verbose printing in one place.
* Simplify the cross compilation case to avoid repetition.
* Define all variables with a macro in a single header.
* Print detected hwcap info via g_print () so it's visible on mobile.
* Expose plain bool variables in the s390x implementation.

7 years ago[runtime] Bundle support, implement missing stream processing (#3423)
Miguel de Icaza [Sun, 28 Aug 2016 01:51:53 +0000 (21:51 -0400)]
[runtime] Bundle support, implement missing stream processing (#3423)

7 years ago[corlib] Fix Marshal test to not rely on Assert.Less
Alexander Köplinger [Sat, 27 Aug 2016 19:24:10 +0000 (21:24 +0200)]
[corlib] Fix Marshal test to not rely on Assert.Less

It doesn't work on nunitlite e.g. on XA:

```
src/corlib/Test/System.Runtime.InteropServices/MarshalTest.cs(268,11): error CS0117: `NUnit.Framework.Assert' does not contain a definition for `Less'
```

7 years ago[runtime] ves_icall_AssemblyBuilder_InternalAddModule is dead code (#3461)
Aleksey Kliger (λgeek) [Fri, 26 Aug 2016 21:46:11 +0000 (17:46 -0400)]
[runtime] ves_icall_AssemblyBuilder_InternalAddModule is dead code (#3461)

There is no System.Refleciton.Emit.AssemblyBuilder::InternalAddModule method

7 years agoMerge pull request #3451 from BrzVlad/fix-armel-emulation
Vlad Brezae [Fri, 26 Aug 2016 20:57:29 +0000 (23:57 +0300)]
Merge pull request #3451 from BrzVlad/fix-armel-emulation

[arm] Fix armel no fp

7 years agoMerge pull request #3460 from akoeplinger/remove-net_4_5-ifdef
Alexander Köplinger [Fri, 26 Aug 2016 19:21:55 +0000 (21:21 +0200)]
Merge pull request #3460 from akoeplinger/remove-net_4_5-ifdef

[mcs] Remove NET_4_5 ifdef from the source files

7 years agoMerge pull request #3459 from akoeplinger/fix-parameter-names
Alexander Köplinger [Fri, 26 Aug 2016 19:18:07 +0000 (21:18 +0200)]
Merge pull request #3459 from akoeplinger/fix-parameter-names

[bcl] Fix method parameter names to match .NET

7 years agoMerge pull request #3457 from akoeplinger/fix-gethrforexception
Alexander Köplinger [Fri, 26 Aug 2016 18:58:59 +0000 (20:58 +0200)]
Merge pull request #3457 from akoeplinger/fix-gethrforexception

[corlib] Return e.HResult instead of PlatformNotSupportedException/-1 for Marshal.GetHRForException

7 years agoPR feedback: Add a runtime switch for the aggressive SCC merging
Andi McClure [Fri, 26 Aug 2016 18:13:44 +0000 (14:13 -0400)]
PR feedback: Add a runtime switch for the aggressive SCC merging

Previously every time we add a new runtime setting for the bridge
processor we have added a new callback for it. Because this is getting
unweildy, and also because some of these settings might have been
broken by recent init order changes, I created a new set_config
callback and merged the existing set_dump_prefix and enable_processing
with it.

7 years agoPR feedback: Corrections to aggressive merge cache
Andi McClure [Fri, 26 Aug 2016 19:00:37 +0000 (15:00 -0400)]
PR feedback: Corrections to aggressive merge cache

hash_perturb was being mixed in in the wrong place. Fix that, also
make the hash function take some input from high bits on 64-bit
systems, also make the types around the hash more reasonable.

7 years ago[sre] Remove TypeBuilder::create_internal_class () icall, it doesn't seem to be neede...
Zoltan Varga [Fri, 26 Aug 2016 17:56:12 +0000 (19:56 +0200)]
[sre] Remove TypeBuilder::create_internal_class () icall, it doesn't seem to be needed. (#3458)

7 years ago[bcl] Fix method parameter names to match .NET
Alexander Köplinger [Fri, 26 Aug 2016 13:33:35 +0000 (15:33 +0200)]
[bcl] Fix method parameter names to match .NET

The names were fixed only for the subset of methods that are included in netstandard,
and in cases where netstandard differs from Desktop .NET we match with .NET.

7 years agoFix tarball build
Alexander Köplinger [Fri, 26 Aug 2016 15:31:12 +0000 (17:31 +0200)]
Fix tarball build

emitnunit.pl was removed in d3129a762419ea579de7e35a36b3471e35e5a75c

7 years ago[corlib] Return e.HResult instead of PlatformNotSupportedException/-1 for Marshal...
Alexander Köplinger [Fri, 26 Aug 2016 10:22:10 +0000 (12:22 +0200)]
[corlib] Return e.HResult instead of PlatformNotSupportedException/-1 for Marshal.GetHRForException

Follow what coreclr/corefx does now: https://github.com/dotnet/coreclr/pull/6929.

7 years ago[runtime] Remove most of the contents of MonoDynamicGenericClass, the… (#3441)
Zoltan Varga [Fri, 26 Aug 2016 10:32:05 +0000 (12:32 +0200)]
[runtime] Remove most of the contents of MonoDynamicGenericClass, the… (#3441)

* [runtime] Remove most of the contents of MonoDynamicGenericClass, the elements of the 'fields' array are not used anywhere, making all the other fields unneccesary too.

* [runtime] Remove the MonoDynamicGenericClass structure, merge it into MonoGenericClass. Add some comments.

7 years ago[jit] Add an assert to the native types code to make sure we are using the matching...
Zoltan Varga [Fri, 26 Aug 2016 10:02:54 +0000 (12:02 +0200)]
[jit] Add an assert to the native types code to make sure we are using the matching managed assembly.

7 years ago[llvmonly] Initialize native-to-managed wrappers when they are loaded instead of...
Zoltan Varga [Thu, 25 Aug 2016 20:18:45 +0000 (22:18 +0200)]
[llvmonly] Initialize native-to-managed wrappers when they are loaded instead of on the first call, since the call might be made on a thread not attached to the runtime. Fixes #43357.

7 years ago[jit] Fix an assertion on amd64 when using fixed size buffers and pinvoke. Fixes...
Zoltan Varga [Thu, 25 Aug 2016 18:35:08 +0000 (20:35 +0200)]
[jit] Fix an assertion on amd64 when using fixed size buffers and pinvoke. Fixes #33571.

7 years ago[corcompare] Show extension argument changes. Make parameter name difference breaking...
Marek Safar [Thu, 25 Aug 2016 16:27:45 +0000 (18:27 +0200)]
[corcompare] Show extension argument changes. Make parameter name difference breaking change.

7 years ago[mcs] Don't crash when as operand cannot be resolved. Fixes #43718
Marek Safar [Thu, 25 Aug 2016 15:55:54 +0000 (17:55 +0200)]
[mcs] Don't crash when as operand cannot be resolved. Fixes #43718

7 years ago[mcs] Correctly detect catch resume point marker in scope of resume points. Fixes...
Marek Safar [Thu, 25 Aug 2016 15:23:27 +0000 (17:23 +0200)]
[mcs] Correctly detect catch resume point marker in scope of resume points. Fixes #43636

7 years agoMerge pull request #3447 from ludovic-henry/iolayer-extract-threading
Ludovic Henry [Thu, 25 Aug 2016 13:55:15 +0000 (15:55 +0200)]
Merge pull request #3447 from ludovic-henry/iolayer-extract-threading

[threads] Get thread handle from MonoThreadInfo when attaching

7 years ago[jit] Don't lower store_r4 and load_r4 on armel with no fp
Vlad Brezae [Thu, 25 Aug 2016 10:45:38 +0000 (10:45 +0000)]
[jit] Don't lower store_r4 and load_r4 on armel with no fp

When having a float variable in memory, we should always access its contents through the fload_r4/fstore_r4 funcs, which do the conversion between float and double and different memsize vs var size. It is common case, to have a temp float, have its address loaded with ldaddr and later do a load_r4_membase on that address to access the contents. If alias analyis lowers this load_r4_membase to an op_fmove directly on the register pair, this would in turn be decomposed into 2 simple int op_moves on soft float, which is wrong if these op_moves are converted to memory accesses.

7 years agoMerge pull request #3449 from lateralusX/jlorenss/win-add-missing-source-file
João Matos [Thu, 25 Aug 2016 10:39:54 +0000 (11:39 +0100)]
Merge pull request #3449 from lateralusX/jlorenss/win-add-missing-source-file

Add missing source file, sgen-os-coop.c, to libmonoruntime Visual Studio project.

7 years ago[arm] Fix opcode emulation on armel with no fp
Vlad Brezae [Thu, 25 Aug 2016 10:15:16 +0000 (10:15 +0000)]
[arm] Fix opcode emulation on armel with no fp

Even though we register emulations for these opcodes, the native function doesn't not map to the opcode logic, being used instead as part of the opcode decomposition along with other instructions. Make sure we don't try to emulate these opcodes through the general emulation pass.

7 years agoAdd missing source file, sgen-os-coop.c, to libmonoruntime Visual Studio project.
lateralusX [Thu, 25 Aug 2016 09:14:33 +0000 (11:14 +0200)]
Add missing source file, sgen-os-coop.c, to libmonoruntime Visual Studio project.

Add missing source file, sgen-os-coop.c to project.

Add source files and headers into correct filters (Header/Source Files).

Eliminated Visual Studio linker warning LNK4221 for libmonoruntime project generated
by empty source files under certain configurations, boehm-gc.c, lock-tracer.c,
null-gc.c and sgen-os-coop.c

7 years agoMerge pull request #3437 from ntherning/fix-DirectoryNotFoundException-thrown-in...
Alexander Köplinger [Wed, 24 Aug 2016 21:38:29 +0000 (23:38 +0200)]
Merge pull request #3437 from ntherning/fix-DirectoryNotFoundException-thrown-in-FileInfoTest.MoveTo_DestFileName_DirectoryDoesNotExist-on-windows

FileInfo.MoveTo() throws DirectoryNotFoundException rather than FileNotFoundException on Windows when target doesn't exist

7 years agoPR feedback: Formatting, comments, asserts
Andi McClure [Wed, 24 Aug 2016 19:33:00 +0000 (15:33 -0400)]
PR feedback: Formatting, comments, asserts

7 years ago[threads] Get thread handle from MonoThreadInfo when attaching
Ludovic Henry [Thu, 14 Jul 2016 16:36:54 +0000 (18:36 +0200)]
[threads] Get thread handle from MonoThreadInfo when attaching

7 years agoMerge pull request #3439 from ludovic-henry/iolayer-extract-threading
Ludovic Henry [Wed, 24 Aug 2016 18:54:04 +0000 (20:54 +0200)]
Merge pull request #3439 from ludovic-henry/iolayer-extract-threading

[mono-threads] Create Win32 handle when attaching the thread

7 years agoMerge pull request #3444 from akoeplinger/fix-netstandard-extensions
Alexander Köplinger [Wed, 24 Aug 2016 18:05:08 +0000 (20:05 +0200)]
Merge pull request #3444 from akoeplinger/fix-netstandard-extensions

[Facades] Implement methods for *Extensions types that are available on the extended type

7 years ago[mini] Wrap error output for NUnit xml in CDATA section
Alexander Köplinger [Wed, 24 Aug 2016 16:35:57 +0000 (18:35 +0200)]
[mini] Wrap error output for NUnit xml in CDATA section

Makes sure that characters like <> (which appear in stack traces) don't confuse the XML parser.

7 years ago[monosymbolicate] Add pdb detection
Marek Safar [Wed, 24 Aug 2016 15:05:04 +0000 (17:05 +0200)]
[monosymbolicate] Add pdb detection

7 years ago[mono-threads-windows] Allocate ThreadStartInfo on the stack
Ludovic Henry [Tue, 23 Aug 2016 17:13:23 +0000 (19:13 +0200)]
[mono-threads-windows] Allocate ThreadStartInfo on the stack

7 years ago[mono-threads] Create Win32 handle when attaching the thread
Ludovic Henry [Wed, 13 Jul 2016 15:19:36 +0000 (17:19 +0200)]
[mono-threads] Create Win32 handle when attaching the thread

This guarantee that a MonoThreadInfo always has a handle.

7 years ago[w32handle] Remove unused assertions
Ludovic Henry [Wed, 24 Aug 2016 13:45:08 +0000 (15:45 +0200)]
[w32handle] Remove unused assertions

7 years ago[w32handle] Initialize them earlier
Ludovic Henry [Wed, 24 Aug 2016 10:09:08 +0000 (12:09 +0200)]
[w32handle] Initialize them earlier

If we happen to have the debugger or the log profiler enabled, we would run into a use before initialization case for the w32handle. The debugger or profiler would call `mono_gc_base_init` which would attach the current thread, and that would crash in `mono_w32handle_new` at w32handle.c:437 with `scan_mutex` being an invalid value (EINVAL).

7 years agoMerge pull request #3445 from rolfbjarne/cecil-update
Marek Safar [Wed, 24 Aug 2016 14:11:50 +0000 (16:11 +0200)]
Merge pull request #3445 from rolfbjarne/cecil-update

[tuner/linker] Update code to fix build errors after cecil update.

7 years agoRevert "[corcompare] Reflects cecil breaking changes"
Marek Safar [Wed, 24 Aug 2016 14:08:25 +0000 (16:08 +0200)]
Revert "[corcompare] Reflects cecil breaking changes"

This reverts commit b0ec389b68300278163dc31949ad747e0e206cca.

7 years ago[tuner/linker] Update code to fix warnings after cecil update.
Rolf Bjarne Kvinge [Wed, 24 Aug 2016 13:56:43 +0000 (15:56 +0200)]
[tuner/linker] Update code to fix warnings after cecil update.

7 years ago[corcompare] Reflects cecil breaking changes
Marek Safar [Wed, 24 Aug 2016 13:16:17 +0000 (15:16 +0200)]
[corcompare] Reflects cecil breaking changes

7 years agoFileInfo.MoveTo() throws DirectoryNotFoundException rather than
Niklas Therning [Tue, 23 Aug 2016 14:19:11 +0000 (16:19 +0200)]
FileInfo.MoveTo() throws DirectoryNotFoundException rather than
FileNotFoundException on Mono on Windows and on .NET when target doesn't exist

FileInfoTest.MoveTo_DestFileName_DirectoryDoesNotExist() expects
FileNotFoundException to be thrown but on Windows a DirectoryNotFoundException
is thrown instead.

This patch changes MoveFile() in mono/io-layer/io.c to set the last error to
ERROR_PATH_NOT_FOUND rather than ERROR_FILE_NOT_FOUND when the destination
path doesn't exist. This results in a DirectoryNotFoundException being thrown
in managed code rather than FileNotFoundException. This is the behaviour
observed in .NET.

Also updated FileInfoTest.MoveTo_DestFileName_DirectoryDoesNotExist() to check
for DirectoryNotFoundException rather than FileNotFoundException.

7 years agoMerge pull request #3443 from ntherning/do-not-pass-FILE_FLAG_OVERLAPPED-to-CreateFile
Niklas Therning [Wed, 24 Aug 2016 13:02:04 +0000 (15:02 +0200)]
Merge pull request #3443 from ntherning/do-not-pass-FILE_FLAG_OVERLAPPED-to-CreateFile

Don't pass FILE_FLAG_OVERLAPPED to CreateFile()

7 years ago[Facades] Add argument null validation for extension methods
Alexander Köplinger [Wed, 24 Aug 2016 12:50:21 +0000 (14:50 +0200)]
[Facades] Add argument null validation for extension methods

7 years ago[Facades] Implement methods for *Extensions types that are available on the extended...
Alexander Köplinger [Wed, 24 Aug 2016 11:51:20 +0000 (13:51 +0200)]
[Facades] Implement methods for *Extensions types that are available on the extended type

The methods are already available in our implementations of those types so we can just forward the calls
to the "real" types instead of throwing NotImplementedException.

I audited all code in mcs/class/Facades and the only places where we still throw NotImplementedException
are ones where we really need to add a custom implementation.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=43695

7 years ago[Facades] Make sure "this" is added to the type extensions
Alexander Köplinger [Wed, 24 Aug 2016 11:44:55 +0000 (13:44 +0200)]
[Facades] Make sure "this" is added to the type extensions

It was missing on a few methods.

7 years ago[Facades] Throw PlatformNotSupportedException instead of NotImplementedException...
Alexander Köplinger [Wed, 24 Aug 2016 11:43:29 +0000 (13:43 +0200)]
[Facades] Throw PlatformNotSupportedException instead of NotImplementedException for ServiceController on mobile

It's unlikely the ServiceController APIs will be supported on mobile since they don't really make sense there,
they were initially designed for controlling Windows Services.

7 years agoMerge pull request #3436 from ntherning/fix-alt-dir-separator-not-replaced-in-Path...
Marek Safar [Wed, 24 Aug 2016 11:17:24 +0000 (13:17 +0200)]
Merge pull request #3436 from ntherning/fix-alt-dir-separator-not-replaced-in-Path.CleanPath

Path.CleanPath() does not always replace AltDirectorySeparatorChar

7 years ago[linker] Mark declaring types of nested types resolved from xml descriptors. Fixes...
Rolf Bjarne Kvinge [Wed, 24 Aug 2016 10:12:48 +0000 (12:12 +0200)]
[linker] Mark declaring types of nested types resolved from xml descriptors. Fixes #43658. (#3434)

If the declaring type of a nested type marked by an xml descriptor
is not otherwise marked, the members of the nested type will not
be preserved, because the linker will not process the nested type
(since the parent type isn't marked, MarkStep:InitializeAssembly
will skip it, and thus skip akk its nested types as well).

https://bugzilla.xamarin.com/show_bug.cgi?id=43658

7 years agoPath.CleanPath() does not always replace AltDirectorySeparatorChar
Niklas Therning [Tue, 23 Aug 2016 13:54:09 +0000 (15:54 +0200)]
Path.CleanPath() does not always replace AltDirectorySeparatorChar

If sub == 0, i.e. there are no repeated separators, this method just returns
the input string. On Windows, where DirectorySeparatorChar (\) is different
from AltDirectorySeparatorChar (/), this means that the call

    Path.GetDirectoryName ("foo/bar/dingus")

won't return "foo\bar" as .NET would but rather returns "foo/bar".

This patch makes sure the '/' -> '\' conversion is run when
AltDirectorySeparatorChar characters have been seen in the input string, even
if sub == 0.

PathTest.GetDirectoryName() triggered this bug.

7 years agoDon't pass FILE_FLAG_OVERLAPPED to CreateFile()
Niklas Therning [Wed, 24 Aug 2016 08:49:23 +0000 (10:49 +0200)]
Don't pass FILE_FLAG_OVERLAPPED to CreateFile()

When a FileStream is opened with the FileOptions.Asynchronous flag set the
code in file-io.c will pass FILE_FLAG_OVERLAPPED to the CreateFile() function.
On Windows this means the file will be in asynchronous mode and when
ReadFile()/WriteFile() are called an OVERLAPPED struct has to be passed. Mono
doesn't do this which means that when reading/writing asynchronous FileStreams
Windows returns an ERROR_INVALID_PARAMETER and an exception is raised in
managed code.

This patch simply removes the code which passes the FILE_FLAG_OVERLAPPED to
CreateFile(). This will work since asynchronous I/O is handled in managed code
anyway, using threads. On the OS level the I/O is still synchronous. The patch
won't affect other platforms since the implementation of
ReadFile()/WriteFile()/etc in mono/io-layer/, which is used on non-Windows, is
always synchronous and ignores the FILE_FLAG_OVERLAPPED.

This bug was triggered by the
MonoTests.System.IO.BinaryWriterTest.AsynchronousModeWrites test.

7 years ago[bcl] More netstandard api matching
Marek Safar [Tue, 23 Aug 2016 22:26:23 +0000 (00:26 +0200)]
[bcl] More netstandard api matching

7 years agoMerge pull request #3430 from akoeplinger/simplify-mini-nunit
Alexander Köplinger [Tue, 23 Aug 2016 19:02:54 +0000 (21:02 +0200)]
Merge pull request #3430 from akoeplinger/simplify-mini-nunit

[mini] Replace emitnunit.pl with simpler Makefile-based xml generation

7 years agoMerge pull request #3431 from mhutch/fix-targetframeworkattribute
Alexander Köplinger [Tue, 23 Aug 2016 17:20:31 +0000 (19:20 +0200)]
Merge pull request #3431 from mhutch/fix-targetframeworkattribute

[xbuild] Fix incremental build of TargetFrameworkAttribute

7 years agoMerge pull request #3435 from ntherning/fix-DirectoryInfoTest-assumes-current-dir...
Niklas Therning [Tue, 23 Aug 2016 14:46:27 +0000 (16:46 +0200)]
Merge pull request #3435 from ntherning/fix-DirectoryInfoTest-assumes-current-dir-is-c-on-windows

Fix for DirectoryInfoTest assuming current dir is C:\ on Windows

7 years agoFix for DirectoryInfoTest assuming current dir is C:\ on Windows
Niklas Therning [Tue, 23 Aug 2016 13:44:54 +0000 (15:44 +0200)]
Fix for DirectoryInfoTest assuming current dir is C:\ on Windows

This test assumes that `new DirectoryInfo (@"c:").Name == "C:\"` when run on
Windows but the actual value depends on the current directory. If current dir
is C:\temp the Name property will return "temp". Similar problem in the
FullName() and Parent() tests.

This patch sets the current directory to C:\ explicitly before running the
failing tests on Windows. The current dir is reset in TearDown().

7 years ago[mini] Replace emitnunit.pl with simpler Makefile-based xml generation
Alexander Köplinger [Thu, 11 Aug 2016 15:52:20 +0000 (17:52 +0200)]
[mini] Replace emitnunit.pl with simpler Makefile-based xml generation

In an effort to cut down on the number of different scripts we have that try to output NUnit xml.

It also fixes a bug in emitnunit.pl where it would not output anything when one of the tests crashes
the process, because then the final "Overall results: tests: 22425, 100% pass, opt combinations: 25"
line isn't printed and emitnunit.pl just exits. This happens on Alpine.

7 years ago[mcs] Remove NET_4_5 ifdef from the source files
Alexander Köplinger [Tue, 23 Aug 2016 13:15:51 +0000 (15:15 +0200)]
[mcs] Remove NET_4_5 ifdef from the source files

It is always set in all profiles that we support so we can remove it.

7 years ago[jit] Avoid strengh reducing divisions when using llvm, llvm can do it by itself.
Zoltan Varga [Tue, 23 Aug 2016 13:09:21 +0000 (15:09 +0200)]
[jit] Avoid strengh reducing divisions when using llvm, llvm can do it by itself.

7 years agoMerge pull request #3426 from ntherning/fix-handle-leak-in-DirectoryInfo.EnumerateFil...
Niklas Therning [Tue, 23 Aug 2016 11:55:25 +0000 (13:55 +0200)]
Merge pull request #3426 from ntherning/fix-handle-leak-in-DirectoryInfo.EnumerateFileSystemInfos-on-windows

Fixes a handle leak in DirectoryInfo.EnumerateFileSystemInfos()

7 years agoMerge pull request #3433 from ntherning/fix-DoubleTest.Parse-assumes-en-US
Niklas Therning [Tue, 23 Aug 2016 10:22:50 +0000 (12:22 +0200)]
Merge pull request #3433 from ntherning/fix-DoubleTest.Parse-assumes-en-US

Don't assume "3 5" is unparseable in the current culture in DoubleTest.Parse()

7 years agoDon't assume "3 5" is unparseable in the current culture in DoubleTest.Parse()
Niklas Therning [Tue, 23 Aug 2016 09:32:41 +0000 (11:32 +0200)]
Don't assume "3 5" is unparseable in the current culture in DoubleTest.Parse()

DoubleTest.Parse() expects "3 5" to be unparseable in the current culture and
expects an exception to be thrown. In sv-SE however "3 5" parses to 35 and
this test fails.

This patch sets the current culture to en-US when the DoubleTest.Parse() test
is run.

7 years agoFixes a handle leak in DirectoryInfo.EnumerateFileSystemInfos()
Niklas Therning [Mon, 22 Aug 2016 14:54:03 +0000 (16:54 +0200)]
Fixes a handle leak in DirectoryInfo.EnumerateFileSystemInfos()

When running DirectoryInfo.EnumerateFileSystemInfos() on an empty directory
MonoIO.FindFirst() will return null and the method returns without closing the
handle which is opened by FindFirst(). This patch makes sure the finally block
which closes the handle is run even when FindFirst() returns null.

Also added a call to FindClose() and some more cleanup in the native
implementation of MonoIO.FindFirst() when an allocation fails.

This bug caused an exception in DirectyoryInfoTest.TearDown() and several
other TearDown() methods in the MonoTests.System.IO tests on Windows due to
RemoveDirectory() failing on an empty directory which still had an open handle
associated with it.

7 years agoMerge pull request #3103 from marek-safar/rs-Threading
Marek Safar [Tue, 23 Aug 2016 07:17:43 +0000 (09:17 +0200)]
Merge pull request #3103 from marek-safar/rs-Threading

[corlib] EventWaitHandle from referencesource

7 years ago[xbuild] Fix incremental build of TargetFrameworkAttribute
Mikayla Hutchinson [Tue, 23 Aug 2016 02:52:31 +0000 (22:52 -0400)]
[xbuild] Fix incremental build of TargetFrameworkAttribute

The targets depended on a feature that doesn't exist in
xbuild (https://bugzilla.xamarin.com/show_bug.cgi?id=43645)
and as a consequence would fail to add the generated file to
the build when the GenerateTargetFrameworkMonikerAttribute
target was up to date.

7 years agoMerge pull request #3429 from akoeplinger/fix-signaturedescription
Alexander Köplinger [Tue, 23 Aug 2016 00:35:44 +0000 (02:35 +0200)]
Merge pull request #3429 from akoeplinger/fix-signaturedescription

[corlib] Add new values for RSAPKCS1SHA(256/384/512)SignatureDescription to CryptoConfig and fix SignatureDescriptionTest in FullAOT

7 years agoMerge pull request #3381 from krytarowski/netbsd-support-20
Alexander Köplinger [Mon, 22 Aug 2016 23:24:39 +0000 (01:24 +0200)]
Merge pull request #3381 from krytarowski/netbsd-support-20

Resurrect NetBSD support in mono-perfcounters.c

7 years ago[corlib] EventWaitHandle from referencesource
Marek Safar [Fri, 3 Jun 2016 13:18:42 +0000 (15:18 +0200)]
[corlib] EventWaitHandle from referencesource

7 years ago[arm64] Bump instruction sizes for atomic ops to match the emmited code
Vlad Brezae [Mon, 22 Aug 2016 21:06:23 +0000 (14:06 -0700)]
[arm64] Bump instruction sizes for atomic ops to match the emmited code

7 years ago[corlib] Add new values for RSAPKCS1SHA(256/384/512)SignatureDescription to CryptoCon...
Alexander Köplinger [Mon, 22 Aug 2016 18:04:57 +0000 (20:04 +0200)]
[corlib] Add new values for RSAPKCS1SHA(256/384/512)SignatureDescription to CryptoConfig and fix SignatureDescriptionTest in FullAOT

With the .NET 4.6.2 merge in https://github.com/mono/mono/commit/b6a30059db8319348ebb454cc303633dfabd6a29#diff-799d44d25450b5b84906cbe7095708a0L86
the RSAPKCS1SignatureDescription class switched from using SHA1CryptoServiceProvider as the DigestAlgorithm to SHA1Cng.

This uncovered an issue when running SignatureDescriptionTest in FullAOT, as we were missing an entry for SHA1Cng
in CryptoConfig.fullaot.cs and so we didn't find the algorithm.

Additionally, 4.6.2 added new variants of the SignatureDescription class using SHA256, SHA384 and 512 which
had to be added alongside the corresponding digest/signature URLs defined by https://msdn.microsoft.com/en-us/library/windows/desktop/dd979768(v=vs.85).aspx

Note that on mobile/FullAOT we're falling back to the *Managed variants of the SHA algorithms as the *Cng/*CryptoServiceProvider variants
aren't exposed there (except for SHA1CryptoServiceProvider since it was in the framework from the beginning) so we need to special case these in the tests.

7 years ago[s390x] Fix compilation of sre-save.c
Aleksey Kliger [Mon, 22 Aug 2016 18:07:59 +0000 (14:07 -0400)]
[s390x] Fix compilation of sre-save.c

7 years ago[corlib] Simplify monotouch_*_corlib.dll.sources
Alexander Köplinger [Mon, 22 Aug 2016 17:15:50 +0000 (19:15 +0200)]
[corlib] Simplify monotouch_*_corlib.dll.sources

They were all using the same .cs source files so just including the generic monotouch .sources
makes it easier to reason about and reduces the risk of forgetting to update one of the lists.