process_breakpoint() will process breakpoint, stepping, and method
exit/entry events all at the same time when checking a sequence point.
So, if there is is a breakpoint and a stepping event at the same time,
the debugger agent will suspend the current thread twice, which means
you have to click the step button in the debugger client twice on that
line. Considering only one of these events at a time seems to fix
the issue without breaking any current unit tests or showing any other
noticeable issues in testing.
* Fix bug #60843 and add test:
If an enum was nested inside a generic class, using it as an argument to a custom attribute would cause a runtime error in the custom attribute decoder. Update the decoder to forward this special case through the normal primitive loading path.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=60843
* Update based on PR feedback
* Don't use caller info attributes since FullAOT does not have them
* Revert "Don't use caller info attributes since FullAOT does not have them"
This reverts commit 316afb686363ef0e46c15d5858bbc1b85ffd5264.
* Fix embarassing bug in test case
* Update outdated test category name
* Disable bug 60843 test in interpreter
In commit 8ba48b5a41
mono_string_new was adjusted to only assert for
out of memory rather than all errors to preserve
previous behavior for invalid strings. This
change preserves behavior for mono_string_new_wrapper.
This commit allows customization of WCF service creation via the Factory attribute in an .svc file:
`<%@ ServiceHost Language="C#" Service="CustomService" Factory="CustomServiceHostFactory" %>`
All the patch does is uncomment a few lines that were already there and fix a small error. I am not sure why these lines were commented. Possibly the code is not sufficiently robust or it was just never given another look. But this works for me and it seems better than no support at all. For example, a custom ServiceHostFactory appears to be the only way to create a WCF service in a managed host which customizes EndpointDispatcher.AddressFilter and EndpointDispatcher.ContractFilter. This in turn is useful for proxied WCF services.
See also http://mono.1490590.n4.nabble.com/Mono-WCF-ServiceHost-Factory-option-td4251992.html (from 2012; never posted on the mailing list for some reason).
The previous code was handling only objects residing in 2 32bit card protected address spaces. This means card table scanning for objects larger than 4GB was potentially broken, while card scanning of objects larger than 8GB was completely broken.
Fixes https://github.com/mono/mono/issues/7537
[threads] Delay abort via handler block guard when in abort protected block.
`mono_install_handler_block_guard` is called when we want to signal an async
abort to another thread. In case the other thread is executing native code
while in a `finally` block, the handler block guard sets a byte in the finally
block that used to trigger a self abort (`mono_thread_self_abort`).
This PR renames `mono_thread_self_abort` to
`ves_icall_thread_finish_async_abort`. It also changes the code from
immediately executing a synchronous abort, to checking whether we are in an
abort protected block (most commonly - whether we were called from a cctor) and
in that case merely toggling the "async interrupt"
MonoInternalThread:thread_state bit. If we're not in an abort-protected block,
trigger a self interrupt (which will turn into an abort exception in the
icall wrapper of `ves_icall_thread_finish_async_abort`).
Fixes#7588
The latest `WebCompletionSource<T>` changes (PR #7358) exposed and
intensified the side-effects of a race condition between `WebOperation`
and `ServicePointScheduler`.
* WebCompletionSource<T> now contains new `CurrentResult` and `CurrentStatus`
properties, which allow completion status to be checked in a non-blocking way.
* WebOperation.CompleteResponseRead() has been renamed into Finish() and
contains the continuation that was previouly known as FinishReading().
Calling this new Finish() method will now complete the `finishedTask`
completion, which has a new accessor called `Finished`.
* The ServicePointScheduler's main-loop is still woken up by completion of
`WebOperation.Finished.Task`, but we use the new `CurrentResult` property
to check state in a non-blocking way. This ensures the the clean-up and
bookkeeping work that's necessary after `WebCompletion.Finish()` always
happens prior to starting new connections.
* [w32file] remove unused mono_w32file_get_times ()
* [w32file-unix] replace SECMULT with TICKS_PER_SECOND
* [w32file-unix] use CONVERT_BASE in more places
* [w32file-unix] factor setfiletime
* [w32file-unix] use utimes if available in order to set subsecond information on access and write time
* [FileTest] add regression test for github issue 7646
* [w32file-unix] reduce compiler warnings
* [w32file-unix] 1000ns = 1us and 1us = 10ticks
* [w32file-unix] add LL suffix to constant in order to prevent overflowing on 32bit systems
* [loader] Don't load framework Facade assemblies that are older than expected.
If there is an older framework Facade assembly in the search order before the
one that we want, don't load it.
"older" here means just compare the major components of the version.
Fixes https://github.com/mono/mono/issues/7624
Even though it's found during configure when targetting 10.7, it's not "really" available before versions 10.12 and it would crash with "lazy symbol binding failed".
When mono is used as a submodule then .git will be a file instead of a
directory. Adjusted the version.h generation code to support that.
Also newer git version started to use `(HEAD detached at <git sha>)`
in `git branch` output instead of `(detached from <git sha>)`,
fixed the regex to support that pattern too.
* [Tailcall] Cleanup is_supported_tail_call to only check virtual_, not opcode == CALLVIRT.
* [Tailcall] Generate tailcall address earlier to honor NT ABI.
Let R11 through tailcall.
Assert alignment when patching.
* [Tailcall] Factor out two copies of SysV varargs handling to a helper function and remove for NT.
Tailcall needs a third instance, and it likely gets in the way of NT tailcall, where it is not needed.
* [Tailcall] Teach amd64_patch how to patch jmp rip+32 and jmp [rip + 32]
very similar to call rip+32 and call [rip + 32]. This might be useful.
* [Tailcall] Fix varargs handling of tailcalls.
* Remove new asserts and just leave comments.
* [Tailcall] No need to free RAX on non-reg calls.
send an internal VM_DISPOSE command to shut down the debugger thread
properly. This prevents runtime hangs that occur during profile
events after the debugger shuts down.
* Fix bounds manipulation in Control.DrawToBitmap and dispose objects properly.
* Add test for DrawToBitmap and fix one more bug in the implementation.
Fixes#7620
On macOS the stopwatch's elapsed time was regularly getting skewed by 200-800ms. On average, yielding decreases the number of GCs by only 25%, while the elapsed time error is always less than 15ms.
Fixes#6999
When a thread has a handler block guard installed (a `finally` block
that checks the exvar to see if it should issue abort the thread because
another thread called Abort on it), ves_icall_thread_finish_async_abort
is called. It must clear the handler block guard for the current thread
in case the abort landed while we're in an abort protected block (a
cctor, most commonly). In that case we must resume the interruption
when we leave all the abort protected blocks, not just at the end of an
intermitent catch clause.
mono_install_handler_block_guard is called when we want to signal an async
abort to another thread. In case the other thread is executing native code
while in a `finally` block, the handler block guard sets a byte in the finally
block that used to trigger a self abort (`mono_thread_self_abort`).
This PR renames `mono_thread_self_abort` to
`ves_icall_thread_finish_async_abort`. It also changes the code from
immediately executing a synchronous abort, to checking whether we are in an
abort protected block (most commonly - whether we were called from a cctor) and
in that case merely toggling the "async interrupt"
MonoInternalThread:thread_state bit. If we're not in an abort-protected block,
trigger a self interrupt (which will turn into an abort exception in the
icall wrapper of `ves_icall_thread_finish_async_abort`).
* Revert "[Tailcall] Quick fix for building F#. Do not tailcall any method with a vtable_arg. (#7609)"
This reverts commit 8ceead93e3.
* [Tailcall] Correct fix for regression from change b4ee86154f.
Regression test not yet available.
* extra brace
* [jit] Incorrect code under mono --trace.
* [Tailcall] call_opcode == CEE_CALLVIRT does not matter for tailcall_membase, only virtual_ does.
* [Tailcall] Add FIXME for tail. not followed by ret. Correct behavior is to raise an exception, not fail an assert.
* [Tailcall] Add disabled debug code to break when compile a tailcall and/or execute a tailcall.
* [Tailcall] Add disabled debug code to try to tailcall any call followed by a ret.
This might be reasonable in the future, as well as a little data flow
analysis skipping nops and branches, as csc w/o -optimize outputs.
* [Tailcall] Add more tailcall tests, i.e. that would
have caught recent regression.
* [Tailcall] Replace #if 0 with MONO_DEBUG=tailcall_break_compile,tailcall_break_run,tailcall_try_all,tailcall_log,
tailcall_all. Consider MONO_TAILCALL_DEBUG instead.
* Revert "[Tailcall] Replace #if 0 with MONO_DEBUG=tailcall_break_compile,tailcall_break_run,tailcall_try_all,tailcall_log,"
This reverts commit 796d9490f672625189dfac47ff24b05f3fb65cbe.
* [Tailcall] Replace #if 0 with ifdefs:
define DEBUG_TAILCALL_BREAK_COMPILE breakpoint in method-to-ir
define DEBUG_TAILCALL_BREAK_RUN 1 codegen outputs breakpoint
define DEBUG_TAILCALL_TRY_ALL 1 consider any call followed by ret, can expand later
define DEBUG_TAILCALL 1 low volume logging under -v instead of -v -v
* [Tailcall] Dial back tailcalls on ARM32, where there is no
volatile non-parameter register in the ABI, in which to pass
an extra parameter. (Why not just pass as a regular first/last parameter?)
* [Tailcall] Dial back untested architectures MIPS S390x PowerPC SPARC.
* [Tailcall] Copy tailcall-generic-cast-il.il to tailcall-generic-cast-nocrash-il.il and tailcall-generic-cast-conservestack-il.il
All platforms should be able to run it without crash,
but only some can run it and conserve stack.
* [Tailcall] Finish splitting tailcall-generic-cast into nocrash and conservestack variations.
All platforms can run nocrash, only some conservestack.
* Change the logic for closing ToolStrip drop-downs to work for more complex nesting.
* Implement SetOwner/GetParent(with_owner=true) behavior for X11 and Carbon backends.
Fixes the logic for closing ToolStripDropDowns for the following cases:
* ComboBox embedded in ToolStripDropDown as seen in KeePass when the window is resized to be small enough for the toolbar to overflow.
* ToolStripDropDown containing controls that open other ToolStripDropDowns and the user clicks on the top-level ToolStripDropDown. The child ToolStripDropDown, and only that child, should be closed in that case.
* Update AnchorLayoutEvents to match Windows behavior, make Bug82762 test platform independent.
* Cache affected layout control and property across SuspendLayout/ResumeLayout.
* Extend AnchorLayoutEvents test.
* Update for little nuances in the layout code.
* Unify flow layout for ToolStrips and FlowLayoutPanel by using the IArrangedContainer and IArrangedElement abstractions.
* Implement basic table layout support for ToolStrips.
* Clean up handling of FlowLayoutSettings.
* Fixes for default values of LayoutSettings in tool strips.
* Remove more of the duct tape holding the ToolStrip layouts together and replace it with calls into the LayoutEngine. Fix other small bugs that prevented ToolStrip overflows from being displayed correctly. Tested with KeePass.
* Fix indentation.
* Address code style issues.
* Remove unnecessary override.
* Fix indentation.
* Bump API snapshot submodule
* Fix error in vcxproj filter causing load error in Visual Studio.
* Fixes issue #7596 on Windows x64.
Passing value types in Windows x64 not fitting into register will be passed
by reference (ArgValuetypeAddrInIReg or ArgValuetypeAddrOnStack )
using a local variable allocated in caller’s frame.
Current implementation sized and marshaled the native struct correctly when
using pinvoke, but it sized the final local passed as reference to the native method
using the managed stack size instead of the native. This caused the final copy
into the local to overwrite other locals on stack if managed and native struct stack
sizes differed.
The fix is to flag the local variable used as stack parameter with its pinvoke state.
This makes sure the stack allocation size will be correct when using value types
passed on the stacks in pinvokes.
When running other unit tests with sequence points I hit a similar issue with
empty structs as return parameters (using [StructLayout (LayoutKind.Sequential, Size = 0)].
This commit includes a fix to ignore the return value if it’s an empty struct on Windows x64.
* [sgen] Use current nursery size when computing allowance
The allowance is the minimum heap growth that we allow between two majors (which is 4 * nursery_size). We need to use the current nursery size instead of the 4MB default, in order to facilitate low memory uses.
* [sgen] Account for soft heap limit in allowance calculation
This is relevant in cases where the nursery size and soft heap limit are comparable in size.
* [profiler] Fix wrong docs for mono_profiler_set_call_instrumentation_filter_callback ().
* [mini] Don't inline methods if they're going to be instrumented for coverage.
This handles coverage instrumentation in a similar fashion to call
instrumentation.
Fixes#6186.
* [mini] Add MonoError to mini_get_shared_method_full and replace bucket of booleans with a flags enum.
* [mini] Eliminate mini_get_shared_method in favor of the variant that takes a MonoError.
* [mini] Rename GetSharedMethodFlags members to follow our coding conventions.
* [mini] Remove reduntant arguments in get_shared_inst.
* [mini] Inline partial in mini_get_shared_method_full.
* [mini] In mini_get_shared_method_full, rename gsharedvt to use_gsharedvt_inst and move it's value to depend on all_vt.
* [mini] Eliminate SHARE_MODE_ALL_VALUETYPES as its semantically equivalent to SHARE_MODE_GSHAREDVT.
* Fix platform-specific build issues
These changes allow some of the Mono code used by the debugger to build
on a few additional platforms. Specifically, this includes platforms:
* That don't have access to the full Win32 API
* That don't have access to the full Posix API
* That don't support IPv6
* Wrap `access` and `_access` in `g_access`
* Convert indentation to tabs
* Wrap `mktemp` and `_mktemp` in `g_mktemp`
* Wrap `open` and `_open` in `g_open`
* Wrap `write` and `_write` in `g_write`
* Fix indentation
* Use proper asserts
* Add a configure check for `access`
* Remove the use of HAVE_XBOXONE_WINAPI_SUPPORT
* Replace the previous definition of `g_open`
I missed that it was here in my earlier commit, and ended up redefining
it.
* Use `g_error` instead of `g_assert(0)`
* [Tailcall] Quick fix for building F#.
Do not tailcall any thing with a vtable_arg.
This does often work, but not in F#, along with unbox in the call target.
The problem is being further reduced and debugged, but this will serve for now.
Regression is from change b4ee86154f.
* [Tailcall] Temporarily disable tests that depend on tailcall.
* [Coop] ves_icall_System_Threading_Thread_GetDomainID convert to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_ConstructInternalThread to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_Thread_internal to coop/handle.
* [Coop] Convert mono_threads_get_max_stack_size ves_icall_System_Threading_Thread_SystemMaxStackSize/typo SystemMaxStackStize to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_Suspend to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_Sleep_internal to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_SpinWait_nop to coop/handle.
* [Coop] Convert threadpool.c to handles -- no pointers, just MonoError.
* [Coop] Convert ves_icall_System_Threading_InternalThread_Thread_free_internal to coop/handle.
* [Coop] Convert mmap to coop/handle -- where there aren't pointers, just unused errors.
* [Coop] Rename some error to ioerror or win32error.
* [Coop] Convert ves_icall_System_Threading_Thread_current_lcid to coop/handle -- no pointers.
* [Coop] Convert mono_mmap_open_file, mono_mmap_open_handle to coop/handle.
* [Coop] Convert ves_icall_System_Threading_Thread_Yield to coop/handle (no pointers).
* [Coop] Layer ves_icall_System_Threading_Thread_ConstructInternalThread over new mono_thread_construct_internal.
* Ignore out of memory.
* Favor mono_error_set_generic_error over small factories (loss of breakpoint?).
* Restore accidentally lost barrier.
* [Coop] Mostly undo commit d7bdbcc9a2e76913861b69ff106f0bf9573e7ea6
Convert ves_icall_System_Threading_Thread_Sleep_internal to coop/handle.
for now.
It duplicates mono_thread_execute_interruption to mono_thread_execute_interruption_handle
which we want to ensure does not last long.
This should be achieved better by pull
https://github.com/mono/mono/pull/6639
which removes all but one pointer user and leaves
that pointer user layered over handle instead of duplicating.
* [Coop] Fix Windows build.
* [Tailcall][Windows] Add missing error parameter.
* [Tailcall] Cleanup is_supported_tail_call to use language-base short circuit.
* [Tailcall] Move more of the logic into is_supported_tail_call.
* [Tailcall] Be sure not to use TAILCALL_MEM_BASE if not supported.
i.e. not if virtual_, besides CALLVIRT -- they are not quite the same.
* [Facades] Make System.Net.Http.Rtc.dll a net_4_x only facade
It doesn't make sense on mobile (see https://github.com/mono/mono/pull/7541#issuecomment-372434424) but we'd like to keep it in net_4_x to match Desktop .NET
* Bump API snapshot submodule
We implemented them in the facades until now but in .NET 4.7.1
they were promoted into the regular class libraries.
Use PLATFORM_DEBUG_FLAGS for IL-less assemblies
Also replace some files with corefx that were identical.
* Fix the test for OnCreateControl.
* Do not create child controls until the parent is created.
* Fix showing menus after CreateControl behavior change.
* Make all top-level controls call SetTopLevel.
* Fix TopLevelControl property to actually return top-level controls, not just Forms.
* [threads] Fix race between abort socket syscall and thread shutdown
The race happens when we call mono_thread_info_abort_socket_sycall_for_close on
a thread that's about to shut down.
We lookup the MonoThreadInfo for that thread outside the
mono_thread_info_suspend_lock, and then use it to send the signal once we've
taken the lock.
In between those two actions, the other thread already finished
unregister_thread and pthreads may already have destroyed its TLS keys and
otherwise started to dismantle the thread.
The fix is to do a second mono_thread_info_lookup once we have the lock and
only signal the other thread if it still around.
Fixes https://github.com/mono/mono/issues/6998
* [threads] Simplify mono_thread_info_abort_socket_syscall_for_close
Call mono_thread_info_lookup while holding the thread info suspend lock.
We no longer need to check for STATE_DETACHED because removing MonoThreadInfo on
detach is done while holding the suspend lock.
* [metadata] split IL generation code into seperate compilation units.
* [metadata] move ENABLE_ILGEN definition to configure
* [metadata] split IL generation code into seperate compilation units.
By adding callbacks for IL generating runtime code, we can link in code
later into the runtime that does such for configurations which do not
need IL generation initially. This is the case if you configure the
runtime with `--enable-minimal=jit,interpreter`.
In such configuration, the build will produce an additional library,
called `libmono-ilgen`.
An embedded can choose to link this library to the final binary and
initialize IL generation with the following three, newly added, API
calls:
* `void mono_marshal_ilgen_init (void)`
* `void mono_method_builder_ilgen_init (void)`
* `void mono_sgen_mono_ilgen_init (void)`
This change is mostly moving code around, but there are minor changes
like introducing the enum `MarshalTypeCheckPositions`, so we avoid
copy/paste constants accross compilation units.
* [windows] add IL gen files to windows build and set ENABLE_ILGEN
* [fixup!] fix windows build
* [fixup!] resolve merge conflicts with class getter commits
* marshal.c: b8da973620
* sgen-mono.c: 8ba4947f7a
at some point I gave up to resolve merge conflicts and worked through
errors/warnings by compiling with
> `CFLAGS=-DENABLE_CHECKED_BUILD_PRIVATE_TYPES=1`
so the result is likely a bit different
* redo lost changes from 57f3f34e60
* redo lost changes from 52514effbf
* [fixup!] fix array marshal
* [method-builder] use eglib types
review comment by Ludovic,
https://github.com/mono/mono/pull/7375#discussion_r171876337
* [marshal] remove stelem strings from header
review comment by Rodrigo,
https://github.com/mono/mono/pull/7375#discussion_r171921029
* gboolean g_is_usermode_native_debugger_present (void).
i.e. Win32 IsDebuggerPresent which is just call mov mov ret.
Other slower methods on other systems if possible and unintrusive (OSX).
This is very useful as in:
if (g_is_usermode_native_debugger_present ()) G_BREAKPOINT
"native" meaning "not managed"
"usermode" meaning "not kernel"
Both other kinds exist and are detected differently.
* Move new debugging utility from glib to mono/utils.
* Redo it with CoreCLR as basis. https://github.com/dotnet/coreclr/blob/master/src/pal/src/init/pal.cpp
* Link to a specific stable revision, not master.
https://raw.githubusercontent.com/dotnet/coreclr/f1c9dac3e2db2397e01cd2da3e8aaa4f81a80013/src/pal/src/init/pal.cpp
* Use a clearer form of boolean normalization.
* Update Visual Studio project files.
* Fix include path, remove unnecessary boolean canonicalization, spell out words, swap int/boolean.
* Header got missed in the move from glib.
It'd fail with the following errors since e6de24c2d1:
```
MCS [net_4_x-darwin] net_4_x_System.Data.OracleClient_test.dll
Test/System.Data.OracleClient.jvm/MonoTests.System.Data.Utils/ADONetTesterClass.cs(337,71): error CS0012: The type `System.Xml.Serialization.IXmlSerializable' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
...
MCS [net_4_x-darwin] net_4_x_System.Json.Microsoft_test.dll
Test/System.Json/JsonValueTest.cs(23,12): error CS0012: The type `System.Dynamic.IDynamicMetaObjectProvider' is defined in an assembly that is not referenced. Consider adding a reference to assembly `System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
...
MCS [net_4_x-darwin] DummyAssembly.dll
error CS0518: The predefined type `System.Object' is not defined or imported
error CS0518: The predefined type `System.ValueType' is not defined or imported
```
* [ci] Add compiling class lib tests to mcs job
* Avoid recalculating Document on TextBox controls without handles. Properly dispose graphic contexts.
* Make sure all CreateGraphics calls are wrapped in using block.
* Avoid a couple more no-op calls in RichTextBox.
* Fix default values and the StartPage property in PrintPreviewControl.
* Do not cache resized bitmaps in PrintPreviewControl if the source data are scalable metafiles.
* [interp] Use jit's dead basic block detection
Using generating_code doesn't cover all cases since it doesn't do basic block liveness calculation.
* [interp] Throw instructions clear the stack
* [interp] Add stack check at return
There would be a compilation error in the XA build as follow:
```
obj/Release/bundles/armeabi-v7a/temp.c: In function 'install_aot_modules':
obj/Release/bundles/armeabi-v7a/temp.c:49:25: error: 'MONO_AOT_MODE_NORMAL' undeclared (first use in this function)
mono_jit_set_aot_mode (MONO_AOT_MODE_NORMAL);
^
obj/Release/bundles/armeabi-v7a/temp.c:49:25: note: each undeclared identifier is reported only once for each function it appears in
```
* [Tailcall] Fix the F# code; let rec functiona ()= printfn "%d" 1; functionb ()
and functionb ()= functiona ()
let ()= functiona ()
The test case and the fix are from https://bugzilla.xamarin.com/show_bug.cgi?id=25224.
Just bringing in change ca0dd5c0bb:
commit ca0dd5c0bb
Author: Zoltan Varga <[email protected]>
Date: Thu Dec 11 15:37:29 2014 -0500
[jit] Enable tail calls from gshared code. Fixes#25224.
Previously it was reverted due to performance regression, which has been fixed.
The problem was that use vs. patch of jmps was using inflated vs. non-inflated code.
Fixed here: https://github.com/mono/mono/commit/fe95e4b34b00caa8073dfa3b4473a43182abcbbb
The IL is:
.method public static !!a functiona<a>() cil managed
{
.
.
.
IL_001d: tail.
IL_001f: call !!0 '1'::functionb<!!0>()
IL_0024: ret
}
.method public static !!a functionb<a>() cil managed
{
IL_0000: tail.
IL_0002: call !!0 '1'::functiona<!!0>()
IL_0007: ret
}
* [Tailcall] Add tail.callvirt support to AMD64 JIT. Not yet
any other architecture (arm, x86, etc.) or scenario (AOT, LLVM,
interpreter, etc.)
This is based on F# that stack overflows to report failure:
type A() =
member this.f2 (a) = if a > 0 then this.f1(a - 1)
else 1
member this.f1 (a) = if a > 0 then this.f2(a - 1)
else 2
let a = A()
printfn "%d" (a.f1(1000 * 1000 * 10))
and in turn C#, self checking instead of stack overflowing:
using System;
using System.Runtime.CompilerServices;
using static System.Runtime.CompilerServices.MethodImplOptions;
unsafe class A
{
static int check (long stack1, long stack2)
{
return (stack1 == stack2) ? 0 : 1;
}
[MethodImpl (NoInlining)]
public virtual int f1 (int counter, long initial_stack, long current_stack)
{
int local;
if (counter > 0)
return f2 (counter - 1, initial_stack, (long)&local);
return check ((long)&local, current_stack);
}
[MethodImpl (NoInlining)]
public virtual int f2 (int counter, long initial_stack, long current_stack)
{
int local;
if (counter > 0)
return f1 (counter - 1, initial_stack, (long)&local);
return check ((long)&local, current_stack);
}
[MethodImpl (NoInlining)]
public static void Main ()
{
int stack;
Environment.Exit (new A().f1 (100, (long)&stack, 0));
}
}
And then IL, inserting tail prefixes and cleaning up a little:
.assembly extern mscorlib { }
.assembly b { }
.class A
{
.method static int32 check(int64 stack1, int64 stack2)
{
ldarg.0
ldarg.1
beq.s IL_0006
ldc.i4.1
ret
IL_0006:
ldc.i4.0
ret
}
.method newslot virtual instance int32 f1 (int32 counter, int64 initial_stack, int64 current_stack) noinlining
{
.locals init (int32 V_0)
ldarg.1
ldc.i4.0
ble.s IL_0013
ldarg.0
ldarg.1
ldc.i4.1
sub
ldarg.2
ldloca.s V_0
conv.u
conv.u8
tail. callvirt instance int32 A::f2 (int32, int64, int64)
ret
IL_0013:
ldloca.s V_0
conv.u
conv.u8
ldarg.3
tail. call int32 A::check (int64, int64)
ret
}
.method newslot virtual instance int32 f2 (int32 counter, int64 initial_stack, int64 current_stack) noinlining
{
.locals init (int32 V_0)
ldarg.1
ldc.i4.0
ble.s IL_0013
ldarg.0
ldarg.1
ldc.i4.1
sub
ldarg.2
ldloca.s V_0
conv.u
conv.u8
tail. callvirt instance int32 A::f1 (int32, int64, int64)
ret
IL_0013:
ldloca.s V_0
conv.u
conv.u8
ldarg.3
tail. call int32 A::check (int64, int64)
ret
}
.method static int32 Main () noinlining
{
.entrypoint
.locals init (int32 V_0)
newobj instance void A::.ctor()
ldc.i4 0x100
ldloca.s V_0
conv.u
conv.u8
ldc.i4.0
conv.i8
tail. callvirt instance int32 A::f1 (int32, int64, int64)
ret
}
.method instance void .ctor ()
{
ldarg.0
tail. call instance void [mscorlib]System.Object::.ctor ()
ret
}
}
* Allow comments anywhere in .md line, not just the start.
* [Tailcall] Avoid changing ins->sreg1 in OP_TAILCALL_MEMBASE.
This was likely based on OP_CALL_REG which has more reason to do
it but still not a good example.
* [Tailcall] Rollback x86/arm/ppc/llvm until changes are actually
complete/working.
* [Tailcall] Fix code formating: default at end, open brace at right on
previous line.
* [Tailcall] Consolidate comments out of tailcall-virt.cs and tailcall-virt.fs and into tailcall-virt.il.
Make IL less unreadable with whitespace.
Disable instead of enable tailcall-virt test.
* [Tailcall] Combine assert and default that it made unreachable and make assert more informative.
* [Tailcall] Remove a newline.
* [Tailcall] Add additional verbose output.
Add 3 tests that would seem focused on this change and would
seem to be fixed -- all three pass on desktop, all three fail
on previous mono, two are fixed now -- one needs more debugging --
generic value types.
Problem is probably:
is_supported_tail_call:
if (fsig->hasthis && cmethod->klass->valuetype)
/* this might point to the current method's stack */
supported_tail_call = FALSE;
* [Tailcall] Allow tail.callvirt on AMD64 AOT now, having tested it.
* [Tailcall] LLVM support for tail.callvirt/OP_TAILCALL_MEMBASE, now having tested it.
* [Tailcall] Disable new tests for interpreter as I had intended.
* [Tailcall] Consolide interpreter disabling of tailcall tests.
Address https://github.com/mono/mono/issues/7093 in kind of an adhoc way.
The correct fix is to make
```
((IEnumerable<U>) (new T[] {...})).GetEnumerator()
```
return an `IEnumerator<U>` (like .NET does) instead of `IEnumerator<T>`
and to stop marking IEnumerator as an array special interface.
fetching Microsoft.NET.Build.Extensions nuget from `cli-deps` to
`dotnet-core`. Both of these should have the same nugets but sometimes
seem to be off by one.
To pick up:
commit 345755cb49ee1979df280399f03178aae0b4029a
Author: Alex Rønne Petersen <[email protected]>
Date: Tue Mar 6 13:40:16 2018 +0100
Add build support for RISC-V. (#6)
Use `MonoClass` getters in the rest of the code in `mono/metadata/`
1. Add `mono_class_contextbound_bit_offset()` which returns the bit offset of `MonoClass:contextbound` which is needed by `remoting.c`
2. Add `mono_class_create_array_fill_type` which is used by sgen to write over unused nursery fragments.
3. Alllow `metadata-cross-helpers.c` to access `MonoClass` fields directly. Rationale: it needs to compute field offsets.
4. Everything else shouldn't have any functional changes.
https://github.com/mono/mono/issues/6925
---
* [metadata] Fix warnings in class-accessors.c
Fix warnings about missing prototypes for class-abi-details.h functions.
* [cominterop] Use MonoClass getters in cominterop.c
* [loader] Use MonoClass getters in loader.c
* [runtime] Use MonoClass getters in icall.c
* [metadata] Add mono_class_contextbound_bit_offset() accessor
Compute the bit offset of MonoClass:countextbound
* [remoting] Use MonoClass getters for remoting.c
* [boehm] Use MonoClass getters in boehm-gc.c
* [callspec] Use MonoClass getters in callspec.c
* [sre] Use MonoClass getters in dynamic-image.c
* [w32] Use MonoClass getters in w32process.c
* [debug] Use MonoClass getters in mono-debug.c
* [runtime] Use MonoClass getters in method-builder.c
* [runtime] Use MonoClass getters in security-manager.c
* [coop] Use MonoClass getters in handle.c
* [reflection] Use MonoClass getters in reflection.c
* [sgen] Add mono_class_create_array_fill_type
Used by sgen to fill nursery fragments before a collection
* [sgen] Use MonoClass getters in sgen-mono.c and the GC bridges
* [verify] Use MonoClass getters in the verifier
* [sre] Use MonoClass getters in SRE
* [custom_attr] Use MonoClass getters in custom-attrs.c
* [metadata] Use MonoClass getters in gc.c
* [security-core-clr] Use MonoClass getters in security-core-clr.c
* [metadata] Use MonoClass getters in metadata.c
* [metadata] Allow metadata-cross-helpers to access MonoClass fields
* [coop handle] Use MonoClass getter in mono_handle_unbox_unsafe
attribute(deprecated(message)) was introduced in gcc 4.5.
attribute(deprecated) was introduced in gcc 4.0?
pragma GCC diagnostic 4.2?
https://github.com/mono/mono/issues/7408
* Update many of the unit tests to pass on Windows.
* Update the TextBox default colors.
* Update ToolStripManager.RevertMerge error handling.
* Update menu item cloning to pass unit tests.
* Update PreviewKeyDownEventArgs.KeyValue behavior.
* Update return value of AccessibleObject.State.
* Update TextBoxBase.IsInputKey to treat backspace as input key.
* Update constructors of BindingCompleteEventArgs to properly set the Cancel property.
* Fix and cache ToolStrip[Item] default font.
* Run fixed layout unit tests.
* Silence the warnings and debug prints in unit tests.
* Update the default colors for ComboBox to match the TextBox.
* Remove superfluous debug prints that are already checked by Assert anyway.
* Make sure HandleCreated event is called for MDI children.
* Do not return zombie handles from CreateWindow, it causes invalid window handles to be sent to X11 functions and lot of noise in the unit test output.
* Do not return zombie handles from CreateWindow, it causes invalid window handles to be sent to X11 functions.
[System.Windows.Forms] Layout fixes
This is accumulation of layout related fixes from https://github.com/filipnavara/mac-playground. Some of the patches were rewritten, small bugs were fixed and it passes the unit tests now.
All the changes are listed in the commits, but the main ones are listed here:
- Rewritten TableLayout, which handles many quirks and unifies the code for GetPreferredSize and the actual layout.
- Fixed FlowLayoutPanel.GetPreferredSize to respect flow breaks.
- Many of the GetPreferredSize implementations fixed to return sensible values. For container controls with default layout the implementation is moved to DefaultLayout and shared.
- Implemented cache for GetPreferredSize that greatly improves the performance for complex layouts.
- Cleaned up implementations of SetBounds, SetBoundsCore and UpdateBounds that improve the performance by reducing the number of re-computations of the same values.
- Moved the calculation of dist_right and dist_bottom for anchor layouts to DefaultLayout.InitLayout.
The Linux build currently just displays "tarball" since we don't
have the .git directory when building the Linux packages.
This allows us to pass environment variables that contain the
branch+commit to the build for generating version.h so we can
show the more detailed info like on OSX.
Same as in https://github.com/mono/mono/pull/6033 to fix the following error on the FullAOT armel/armhf builds:
```
Ran out of trampolines of type 0 in '/home/builder/jenkins/workspace/test-mono-mainline-fullaot/label/debian-9-armhf/mcs/class/lib/testing_aot_full/mscorlib.dll' (limit 9000)
```
Now explicit bounds are only updated in SetBoundsCore, no more all the updating and restoring with UpdateBounds calls.
Rely on the WM_WINDOWSPOSCHANGED message to be sent from XplatUI.SetWindowPos to call UpdateBounds. This avoids an explicit call to XplatUI.GetWindowPos and UpdateBounds in SetBoundsCore.
Fix events triggered in incorrect order when Control.Controls.Remove is called.
Update Dispose behavior with events and exceptions to match the reference implementation more closely.
Rework the layout engines to use AutoSizeInternal property since TextBoxBase has its own AutoSize that should not be respected by layout engines.
Rework automatic sizing behavior of TextBoxBase to return correct values.
Rework TableLayout completely to use same code for layout and calculation of preferred size.
Co-authored-by: Jiri Volejnik <[email protected]>
The Label control has special sizing behaviour that predates the introduction of layout engines in .NET Framework 2.0. In earlier versions of the framework it used to auto-size itself. Now it does it only if it's contained in the default layout engine, otherwise it lets the layout engine do its magic.
* [mcs tests] fix runtime arguments passing to test harness
This fixes a regression introduced by
https://github.com/mono/mono/pull/5484/files#diff-d4a99dd2b7df29f027dae0b3eec6c8e6R193
The change it subtle: Variables are moved into another one, but one
variable got changed from `TEST_RUNTIME_FLAGS` to `RUNTIME_FLAGS`, which
causes the harness not picking up `--interpreter` if set.
* [interp] disable System.Threading.ThreadTest.Test_Interrupt
* [sre-save] Emit a warning if overwriting a MonoClass token with unequal value
It's not clear to me how we could ever have a class without a type_token set
even with a TypeBuilder.
* [sre-save] Use MonoClass getters in sre-save.c
* [sre-save] Change g_warning to g_error in mono_image_fill_export_table
We think this case should not happen.
* [sdks] Move common targets
* [sdks] Have RELEASE be empty when CONFIGURATION != 'release'
* [sdks] Create common runtime compilation template
* [sdks] Use runtime template for Android
* [sdks] Use runtime template for iOS
* Use VSCMD_ARG_TGT_ARCH env in mkbundle on Windows when trying to autodetect target architecture.
Using mkbundle on Windows with VS toolchain, mkbundle will detect target
architecture (x86/x64) by looking at the architecture of executing .NET runtime.
This could lead to some surprises when run from a VS development command propmt setup
to target x86 or x64 but running a mono binary using opposite architecture.
To mitigate this issue mkbundle will look now at the VSCMD_ARG_TGT_ARCH
set in VS development command prompts and use target architecture based
on this env variable. If not defined, current behavior will be used, picking the target
architecture based on executed .NET runtime architecture.
* Updated mkbundle documentation.
* [corlib] Remove IVT for S.R.I.RuntimeInformation facade
The types live in corlib now so we don't need the IVT anymore.
Also removed leftover SR.cs file.
* Bump API snapshot submodule
The original version of this code overwrote the same string over and over
again. Because of the order of operations, when looking for siblings of
Test.dll, we would probe for Test.dll.mdb, then Test.pdb, then Test.pdb.config
(note the last one - should be Test.dll.config).
New version of the code uses fresh strings for each sibling.
Fixes https://github.com/mono/mono/issues/7262
* [sdks] Add armv7s device build.
* [sdks] Disable dtrace on the cross compiler builds.
* [sdks] Avoid building mono-dtrace.h for the cross compilers, its not needed anymore.
* [sdks] Add a configure-mono target.
* [sdks] Put back the call to CheckXcodeDir.
* [sdks] Enable ccache if possible.
* [sdks] Generalize iosDeviceTemplate so it can build the tvos runtime as well. Add tvos device build.
- This is independent of optimization, which is seemingly what we want.
- This does not have bug under optimization that `error` has, that
currently breaks FullAOT builds.
This is an alternative to https://github.com/mono/mono/pull/7353.
Use ifdef GNUC || clang to indicate we know clang is compatible,
and not just depend on clang defining GNUC and being very compatible.
See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84628.
* [runtime] Export mono_runtime_get_aotid () for use in the profiler.
* [profiler] Add nanoseconds startup time to file header.
Fixes#6178.
* [profiler] Add a TYPE_AOT_ID event containing the current runtime's AOT ID, if available.
Fixes#6181.
* [profiler] Add Mvid to image load events.
Fixes#6180.
* [profiler] Add generation field to heap object events.
Fixes#6174.
* [profiler] Remove TYPE_SAMPLE_UBIN and some more dead ELF code.
We had a few stubs that threw not implemented exceptions in Dispose()
which causes the finalizer thread to abort.
Since those classes throw in the constructor already there's no way
to create a valid object and we can remove the throw in Dispose().
Fixes https://github.com/mono/mono/issues/7338
This new helper class uses `TaskCompletionSource<>` internally, but instead
of using TrySetException(), it sets a result containing an `ExceptionDispatchInfo`.
The problem with using TrySetException() is that it wraps the exception
object in an `AggregateException`, that would be unobserved if the caller
throws the original exception.
* [System]: Enable some System.Net.Requests tests from CoreFX.
* tests.make: add `$(XTEST_HARNESS_PATH)` to `TEST_MONO_PATH`,
so we can find xunit.assert.
* corefx/SR.cs: add `System.Net.Requests` resources from corefx.
* HttpWebRequest: See below for detailed summary.
* Match parameter names of overridden base class members.
* Fixed order of some argument / state checks to match the
tested behavior.
* Most async methods now throw exceptions instead of returning
faulted tasks when called with incorrect arguments.
* HttpWebResponse.ContentType: use `string.empty` as default.
* WebConnectionStream.FlushAsync: override to return a finished task.
* HttpWebRequestTest.AllowReadStreamBuffering: removed this test.
* test-helpers/RemoteExecutorConsoleApp: silently ignore compiler-
generated helper methods.
Enabled tests from CoreFX:
--------------------------
Added the following tests from external/corefx/src/System.Net.Requests/tests:
* AuthorizationTest, FileWebRequestTest, GlobalProxySelectionTest,
HttpRequestCachePolicyTest, HttpWebRequestTest, HttpWebResponseHeaderTest,
HttpWebResponseTest, LoggingTest, RequestStreamTest, WebRequestTest
Not working yet:
* AuthenticationManagerTest, FtpWebRequestTest
We are currently using
../../../external/corefx/src/System.Net.Requests/tests/*.cs:AuthenticationManagerTest.cs,FtpWebRequestTest.cs
Summary of HttpWebRequest changes:
----------------------------------
* Host - we are now using the implementation from corefx.
* DefaultMaxResponseHeadersLength (unused) - fix default value.
* AllowReadStreamBuffering (unused) - allow this property to
be read/written.
* ContinueTimeout - likewise.
* DefaultCachePolicy (unused) - allow this property to be
read/written and set default value.
* DefaultMaximumErrorResponseLength (unused) - likewise.
* Connection - use implementation from corefx.
* Method - use implementation from corefx, which has additional
error checks.
* MaximumResponseHeadersLength - use implementation from corefx,
adding error checks.
* ReadWriteTimeout - likewise.
* ProtocolVersion - include parameter name in ArgumentException.
* TransferEncoding - use implementation from corefx.
* BeginGetRequestStream / GetRequestStreamAsync / GetRequestStream:
throw exceptions when called with incorrect arguments rather than
returning faulted tasks.
* Disable the corefx tests for the moment.
* Bump API snapshot submodule
* Update tests.make
* [acceptance-tests] Revert part of 1216780e83.
This didn't work as well as I'd hoped.
* [libgc] Export GC_start_blocking () and GC_end_blocking ().
* [libgc] Allow GC_start_blocking ()/GC_end_blocking () to be called unbalanced.
This makes things a bit easier in Mono.
* [libgc] Implement GC_start_blocking ()/GC_end_blocking () for Windows.
* [utils/event] Export the MonoOSEvent APIs for use in the profiler.
* [runtime] Implement thread info flags and get rid of tools threads.
The concept of a tools thread was originally a good solution to the problem of
some internal threads needing to be exempt from stop-the-world. Since they were
introduced, however, we've added more code in the profiler's internal threads
which require certain properties that don't hold true for tools threads. In
particular, we call into some APIs in the metadata layer that, while not
needing the managed heap, do need a domain to be set under certain conditions
(see #6188).
To avoid further complicating the semantics of tools thread by trying to set a
domain for them in a way that doesn't break things horribly, we'll instead do
away with the concept entirely. We already had mono_gc_set_skip_thread () to
flag a thread as being exempt from stop-the-world, which we used in thread pool
threads. This means we already have the infrastructure that is necessary for a
thread to be fully attached to the runtime as a managed thread while still
being exempt from stop-the-world.
So, we do the following:
1. Introduce a set of flags that can be set on a MonoThreadInfo at arbitrary
points (although not in async context). These can indicate that the thread
doesn't want to participate in stop-the-world, doesn't want to receive
sampling signals, etc.
2. Change the thread iteration macros to allow skipping threads with specific
flags set and use this where appropriate (e.g. SGen stop-the-world code).
3. Get rid of mono_gc_set_skip_thread () and make runtime code use the new
mono_thread_info_set_flags () instead.
4. Switch all internal profiler threads to using mono_thread_attach () and
mono_thread_detach (). Use mono_thread_info_set_flags () to disable
stop-the-world and sampling signals for these threads immediately after they
start.
With these changes, internal profiler threads are now fully attached threads
and can call any APIs in the runtime as long as they don't touch the managed
heap.
* [libgc] Add a note about how GC_start_blocking ()/GC_end_blocking () differ from upstream.
* [runtime] Use getters in IS_MONOTYPE()
* [metadata] Add m_class_offsetof_fieldName accessors
These look like:
```c
intptr_t
m_class_offsetof_someField (void) {
return MONO_STRUCT_OFFSET (MonoClass, someField);
}
```
When Mono is compiled with the definition of MonoClass
hidden (--enable-checked-build=private_types),
only the function prototypes are available via
mono/metadata/class-abi-details.h
When Mono is compiled without the checked build flag,
the functions are inlined into that header.
* [metadata] Add accessor function mono_class_set_nonblittable
This is needed by mono_marshal_load_type_info ()
* [marshal] Use m_class_get_ getters to access MonoClass fields
* OpenBSD hasn't have /dev/srandom anymore. See:
https://mastodon.social/@_xhr_/99389358375291806
* Crichton hasn't touched Mono since 2004, per logs. I
doubt they're who to consult about this issue anymore, if
someone somehow does.
* Always enable explicit null checks for AIX
AIX has a "null page" that allows reads (but not W|X) to occur on
*0; allegedly legacy crap for old stupid C programs that poorly
managed string handling. Because of this, we can't catch SIGSEGVs
to give out NREs with - we have to do null checks ourselves. As
such, turn this debug option on all the time; it's seemingly what
other managed runtimes have done, at least according to with what
one contact says.
* Make explicit null checking definable by architecture headers
Turns out other OSes do this too; so best to keep it generic.
To the poor souls on HP-UX and IRIX, good luck!
* Make arch-specific explicit null checks a backend option instead
Don't put ifdefs into JIT code except in that init_backend func;
also make ifdef name consistent with the debug flag name
* Rework the Win32 drag and drop bridge not to depend on Hwnd object.
* Avoid using Hwnd.GetBorderWidth directly.
* Unify GetParent calls to make same sense out of them. They should either consider form owners or not, which wasn't consistent across the XplatUI backends and uses.
Reimplement Control.FromChildHandle using XplatUI instead of relying on Hwnd class.
* Update GetParent parameters.
* Remove direct accesses to Hwnd objects from Control.
* Don't create the Hwnd object in the XplatUIWin32 backend.
* Split handling of Hwnd.GetNextStackedFormLocation for MDI windows into MdiClient to remove dependency on Hwnd objects.
We were previously passing to EH the address to the context that is being set up by the suspend mechanism. This context could get modified while we unwind, confusing EH (could raise `cfa_reg != -1` assertion)
This commit significantly reduces the race window and should mostly avoid crashes (if we get the wrong context we should just fail to invoke clauses from managed)
Don't assert when comparing if an "array special interface" is assignable from
an array.
The code assumed that the special interface is some sort of generic instance
like ``IList`1<string>``, but it could be a generic type definition
``IList`1``.
There is a case where we would be obligated to return TRUE:
If someone used reflection to get the generic param of ``IList`1`` and then made an
array:
```
var i = typeof (IList<>);
var iparam = i.GetTypeInfo().GenericTypeParameters [0]; // returns gparam T
var a = iparam.MakeArrayType (); // T[]
Console.WriteLine (i.IsAssignableFrom (a));
```
But that case is handled by the `MONO_CLASS_IMPLEMENTED_INTERFACE` check,
earlier in mono_class_is_assignable_from.
So we can return FALSE here.
Fixes https://github.com/mono/mono/issues/7095
* [metadata] Fix m_classdef_get_next_class_cache getter to be byref
Apparently the way this field is used is to internally chain cached classes, so
we need its address.
* [metadata] Use MonoClass getters in image.c
* [metadata] Allow debug-helpers to access MonoClass fields directly.
* [metadata] Use MonoClass getters in mono-error.c
* [sgen] Use MonoClass getters in sgen-debug.c
* [sgen] Use MonoClass getters in sgen-client-mono.h
* [metadta] Use MonoClass getters in appdomain.c
* [metadata] Use MonoClass getters in exceptions.c
The mkbundle VS toolchain build has never supported zlib and the -z argument.
Commit adds zlib.lib or zlibstaticlib (depending on use of --static) to the
linker command line when using -z argument.
NOTE, user still needs to make sure zlib.h, zconf.h, zlib.lib or zlibstatic.lib
is visible to cl.exe and link.exe when running mkbundle using VS toolchain.
* [metadata] Create transient ginst during parsing.
Allocate the instantiation types transiently so that they can be freed if
we're going to ultimately discard this MonoGenericInst candidate.
* [metadata] Store GenericParamInfo for anonymous generic params in a cache in MonoImage
The issue is that mono_metadata_parse_generic_param can be called from
mono_metadata_parse_method_signature_full without a MonoGenericContainer which
means we will image_alloc0 temporary MonoGenericParamInfo every time.
This happens, for example in method_from_methodspec in loader.c when we
parse a generic instantiation without having a generic container on hand.
* [metadata] Use MonoGenericParamFull for all generic params
We used to allocate a smaller MonoGenericParam for anonymous generic
parameters. Instead always allocate a MonoGenericParamFull now (which has the
extra MonoGenericParamInfo fields).
As a result, update call sites that checked whether mono_generic_param_info
returned non-NULL to check gparam->owner->is_anonymous instead.
As a fesult of that, update mono_metadata_load_generic_params to create
non-anonymous parameters right away if we know the class or method that will
eventually own them.
* [metadata] Remove anon gparam MonoClass caches from MonoImage
Now that all generic parameters are MonoGenericParamFull and have a pklass
field, cache the class corresponding to a generic param in the struct itself
instead of an external cache.
* [metadata] Remove gshared constraint gparam caches from MonoImage
Now that every gparam is a MonoGenericParamFull, we can always cache the
MonoClass for a gparam in MonoGenericParamFull:pklass.
* [wasm] Enable LTO in release builds. Change packaging to include both debug and release builds.
* [wasm/sgen] Make it possible to disable debug helpers and do so under wasm. Saves 2% on a release build.
* [Tailcall] Add 11 tests. They all run w/o exception or stack overflow, on all platforms.
They are self-checking and report if they were tail called.
All 11 pass on Windows .NET.
2 pass with Mono on Windows or Mac.
CoreCLR not tested as it is a difficult/unknown command line environment.
Mono has problems with at least:
virtual
non-managed pointers
generics
calli
managed references even if not to current frame
Tests originally written in C# and then run through ildasm and perl.
See https://github.com/jaykrell/mono/commits/tailcalltest2.gen.
* [Tailcall] Interpreter fails all tailcall tests.
SvcHttpHandler is supposed to be thread-safe so it shouldn't use plain
Dictionary without additional locking.
The problem is apparent when running test app from issue #7134 with
hyperfastcgi as the following exception sometimes surfaces:
```
[System.NullReferenceException]: Object reference not set to an instance of an object
at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x00111] in .../mono/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:441
at System.Collections.Generic.Dictionary`2[TKey,TValue].set_Item (TKey key, TValue value) [0x00000] in .../mono/external/corefx/src/Common/src/CoreLib/System/Collections/Generic/Dictionary.cs:223
at System.ServiceModel.Channels.SvcHttpHandler.ProcessRequest (System.Web.HttpContext context) [0x00048] in .../mono/mcs/class/System.ServiceModel/System.ServiceModel.Channels/SvcHttpHandler.cs:82
at System.Web.HttpApplication+<Pipeline>d__225.MoveNext () [0x008fd] in .../mono/mcs/class/System.Web/System.Web/HttpApplication.cs:1338
at System.Web.HttpApplication.Tick () [0x00000] in .../mono/mcs/class/System.Web/System.Web/HttpApplication.cs:927
```
* Add test for bug 18941
* Expand and update bug 18941 test because there are more problems with our handling of empty structs
* Remove array offset calculation from test because it uses unmanaged sizes. Fix calculation of struct sizes used in marshal struct layout (fixes SizeOf(TestOffsets))
* Correct Marshal.SizeOf implementation to use mono_marshal_type_size instead of returning native sizes
* Remove commented out code
* [sre] Remove S.R.E.FieldBuilder:table_idx field
The field was used in two ways:
1. as the temporary token returned by MemberInfo.MetadataToken
property
2. as a way for sre-save to record the field index in the dynamic assembly.
For (1) we now use the value returned by
ModuleBuilder.GetToken(MemberInfo) (ie a pseudotoken).
For (2) we lookup the field index in the dynamic assembly hash that maps
MonoClassField pointers to indices.
* [sre] Assign consecutive tokens to all fields in a class.
Ensure that a token and a Module are enough to uniquely identify every
MonoClassField.
Because of how metadata is represented in Mono, the fields defined in a
class must have consecutive tokens (because the MonoClass:field.first
and and MonoClass:field.count are used to index into the
MonoClass:fields array).
When the class is created we bump the "next available field token" value
in the ModuleBuilder. Any FieldBuilder objects that are still alive
after the type is created will use RuntimeResolve() to map from their
pseudotoken to the real token.
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=33208
* [sre] Change S.R.E.ModuleBuilder.get_next_table_index to take a count
Allow us to reserve more than one consecutive token.
(For now all the callers just have count == 1)
* [sre] Access S.R.E.ModuleBuilder:table_indexes from typebuilder_setup_fields
Use the ModuleBuidler:table_indexes array for assigning tokens to fields
when a TypeBuilder is constructing a type. Also register those tokens
with the runtime so that ResolveMember calls work.
* [test] System.Reflection.Emit.ModuleBuilder field tokens in a module should be distinct
Regression test for https://bugzilla.xamarin.com/show_bug.cgi?id=33208
* [runtime] Relax assertions in mono_class_{get,set}_first_field_idx
Removed the !klass->image->dynamic check. Classes created by SRE are
of kind MONO_CLASS_DEF and have a first field index.
* Fix issues due to API changes.
* Bump mscorlib version
https://github.com/mono/mono/issues/7200
Three styles:
1. LIBS="$LIBS -lfoo" -- common and probably works
2. LIBS+="-lfoo" -- was here and does not work
3. LIBS+=" -lfoo" -- should work
%p-formatted numbers already include '0x'
Fixes this output when dumping threads:
"Threadpool worker" tid=0x0x7000105cc000 this=0x0x10bc18508 , thread handle : 0x7fbb9e6c6c90, state : not waiting
to become:
"Threadpool worker" tid=0x7000105cc000 this=0x10bc18508 , thread handle : 0x7fbb9e6c6c90, state : not waiting
* [configure] Remove sgen_copying. It's dead.
* [configure] Add sgen_gc_bridge and sgen_split_nursery to the configure flags.
* [configure] Remove more dead configure flags.
* [configure] Par is now just a feature of conc, remove that too
* [sgen] Fix enable minimal for concurrent configuration.
* [sgen] Fix enable minimal for the split nursery.
* [sgen] Use the new enable minimal to compile the bridge code out.
* [wasm] Switch to the new enable minimal flagd and add mono-opt.js build. The new flags save 300k out of 2.8m.
* Fix *setup_async_callback and add *resume_sighandler_ctx on PPC
mono_arch_setup_async_callback didn't work on systems that use
function pointers. For consistency with other backends with
exception support, also add mono_arch_setup_resume_sighandler_ctx,
which we can use to support mono_arch_setup_async_callback, like
those other backends.
Also enable async callbacks on AIX, then enable
*resume_sighandler_ctx on PPC Linux (untested) and AIX. With this,
I can now ^C in the REPL with AIX and have it work; whereas before
it bombed out, with or without async callbacks enabled or disabled.
* Don't configure func descriptors twice, set args reg with user data
* No sense configuring configuring function descriptors if
the restore sigcontext call already set them up. (If Mac
OS supports is verified and added to the ifdef maze, it'd
be safe to remove this whole ifdef, and let the call in
`exceptions-ppc` handle it all, as all supported OSes
would have that call...)
* Set user_data in an arguments register, like what amd64
and z do.
These don't seem to cause any regressions, like the first patch.
* Remove unnecessary case for PPC
* mono_ppc_set_func_into_sigctx is unused now, remove it
* Everyone has MONO_ARCH_HAVE_SETUP_RESUME_FROM_SIGNAL_HANDLER_CTX on PPC now
* Everyone has MONO_ARCH_HAVE_SIGCTX_TO_MONOCTX on PPC too
mono_threads_is_safepoints_enabled is used to check if cooperative suspend safepoints are enabled, while mono_threads_is_blocking_transition_enabled is used to check if GC safe/unsafe transition are enabled.
* [mini] Change mono_arch_is_inst_imm () to receive the non-imm and imm opcode.
* [mini] Provide a stub for mono_arch_exceptions_init ().
* [mini] No need to define MONO_ARCH_FPSTACK_SIZE on platforms that don't use it.
* [mini] Remove some dead defines from backend headers.
* [mini] Remove the unused dummy_store opcode.
* [mini] Handle dummy init instructions in all backends.
* [mini] Implement live range instructions in all backends.
* [mini] Allocate trampolines from the domain code manager where appropriate.
* [wasm] Add server.py for those that want to experiment with streaming compilation.
* [wasm] Implement System.Threading.Timer.
Timer implementation is done in a somewhat convoluted way.
First, we change Timer to not depend on a scheduler thread.
What we do is call for the runtime to schedule a timed callback to be executed.
Next step, the runtime. We add enough plumbing to get this call to JS.
Finally, in JS we either call setTimeout or schedule it to be run on the next tick.
Oh, wait, timeouts are ignored on non-web environments? Yes, right now its only use case
is offline testing, so ain't no time to wait for all this timeouting.
* [aot] Add hybrid aot tests.
* [jit] Disable partial sharing during JITting, its only been tested in full aot mode, and doesn't seem to work with JITted methods. Fixes https://github.com/mono/mono/issues/7085.
Context: https://github.com/xamarin/xamarin-android/pull/1078
xamarin-android uses `mono-api-html` and `mono-api-info` in order to
perform API comparisons; see e.g. 4e459045.
A recent problem has arisen regarding "inter-API-level diffs": there
are many API changes which we consider to be acceptable, and thus
would like to ignore. Unfortunately, `mono-api-html` doesn't support
ignoring many of these constructs, e.g. base class changes:
<h3>Type Changed: Android.Preferences.CheckBoxPreference</h3>
Modified base type: <span class='removed removed-inline removed-breaking-inline'>Android.Preferences.Preference</span> <span class='added '>Android.Preferences.TwoStatePreference</span>
and property type changes:
<h3>Type Changed: Android.Views.InputEvent</h3>
<p>Modified properties:</p>
<pre>
<div data-is-breaking> public <span class='added added-breaking-inline'>abstract</span> int DeviceId { get; }
</div><div data-is-breaking> public <span class='added added-breaking-inline'>abstract</span> InputSourceType Source { get; }
Overhaul the `mono-api-html` "ignore" infrastructure:
* Introduce ignore "scoping". Previously, the ignore options would
only match the *member* text against any provided regular
expression. Thus, `mono-api-html -r ToString` would ignore *all*
members containing `ToString`. Furthermore, there was no way to
restrict the ignore to a particular type. Expand the regex
semantics so that the declaring type is used as a "prefix" for the
to-be-matched text. For example, if a class `Example` is removed,
`mono-api-html` will now match the following value against any
`-r` regular expressions:
Example: Removed type
* Add a `mono-api-html -v` option, to control output verbosity.
When specified, `mono-api-html` will print out available `-r`/etc.
option values:
$ mono-api-html expected.xml new.xml -v
Possible -a value: Android.Resource: Added fields: public static const int AccessibilityEventTypes;
Possible -r value: Android.Preferences.CheckBoxPreference: Modified base type: 'Android.Preferences.Preference' to 'Android.Preferences.TwoStatePreference'
Possible -r value: Android.Views.InputEvent: Modified properties: public int DeviceId { get; }
Possible -n value: Android.Views.UnavailableException: Added type
...
Additionally, allow `mono-api-html` to take a
`Mono.Options.ResponseFileSource`, which allows `@response-files` to
be used as command-line options.
Althought it was previously defined in a public API header, the macro was not
usable for the last several years since it was implemented in terms of
the MonoClass definition which was not visible in the public API.
There is a subtle semantic change here: mono_type_is_generic_parameter will
return FALSE if it's given a byref type parameter, the previous definition of
the macro would return TRUE. (E.g. if you had "class F<T>" then
IS_INTERFACE("T&") used to return TRUE but will now return FALSE. )
Also
- Move mono_class_set_failure definition to class-accessors.c
- Move a few functions that set up specific MonoClass fields to class-init.c:
- mono_class_setup_has_finalizer
- mono_class_setup_nested_types
- mono_class_setup_supertypes
Some terminals like vt220 don't have a format string for setting foreground
or background colors. In that case, the set*color members of the
TermInfoDriver are set to null and trying to set the background color throws.
Signed-off-by: Kai Ruhnau <[email protected]>
* [profiler] Document addition of MONO_ROOT_SOURCE_EPHEMERON.
* [profiler] Remove dead ELF traversal code.
This was buggy and hasn't been enabled for a long time.
The code uses reflection to access all the fields in the RuntimeFeatures
class. When running the linker we strip out these fields since
they're `const` and the test fails because it can't find the expected values.
Since the linker always removes all constant fields we can't simply
"use" the field in the test and instead we just bail out when encountering this case.
Also used Dictionary instead of tuples for the test since it renders
better in the nunit output.
Fixes https://github.com/mono/mono/issues/7145
* Assorted fixes for AIX and i
* Fix a bug I introduced when changing the MonoArray vector
type; array lengths wouldn't match up to what they
actually were on AIX/i.
* Use a custom mkdtemp implementation on Unices without
mkdtemp - and ones that do but don't necessarily have it,
like i 7.1, which lacks mkdtemp in its libc. We can't
determine this at runtime, so AIX will have to suffer
with i.
* Enhance PowerPC hwcap on AIX to detect features like
Linux does.
* Don't use clock_getres on AIX, because i 7.1 doesn't have
that syscall - it's in libc, but it'll bomb out with a
SIGILL; the way unimplemented opcodes are handled on i.
* Don't use PROT_NONE for hazard pointer alloc when on AIX
AIX and i 7.2 are OK with doing this, but i 7.1 is not and will
SIGSEGV because we violate access privleges; not even mprotect will
change this. As such, change to r/w protection for AIX/i.
* Fix Environment.OSVersion on AIX/i
Before, it would report "Unix 1.0.0.0" due to the fact AIX only
puts the minor version number where other Unices would put the
whole version in uname. Set up an ifdef for AIX and deal with this
semantic difference with a sprintf.
* Disable mffgpr on AIX
Reports of it not working on i 7.1 on POWER7; tester reports
disabling this in hwcap makes it run. This requires further
investigation.
* Fix threadpool errno delivering bogus values with _THREAD_SAFE
We didn't set this, and we need it so that errno is thread-local on
AIX/i. Oops!
* Make suggested changed to AIX branch
* use sizeof (utsname) for sanity's sake
* use a variable for hazard table protection
* match defines for CPPFLAGS -> libmono_cflags
In certain cases of having concurrent WCF requests
HttpReplyChannel.TryReceiveRequest can return true with the context
being null ("at closing phase").
This patch prevents crashing the whole application with a
NullReferenceException as reported in issue #7134.
Whether this is just covering the issue over or a real fix is yet to be
determined.
Fixes https://github.com/mono/mono/issues/7134
Assume a class implementing multiple generic I`1 interfaces. If a virtual call invocation is trying to resolve the correct interface using object O implementing I`1 also , the interface is resolved using a set of rules (not fully implemented in Mono), but a requirement is that the chosen interface is "variant-compatible" with object O, that is its generic parameters are set to the same types.
This last requirement is relaxed as an implementation-specific detail when I`1 is IEnumerator`1, in which case e.g. a virtual call on a class implementing IEnumerator<byte> can happen with an object of type IEnumerator<sbyte> by way of sharing IEnumerator`1 as a generic interface they define. Here, clearly the interfaces are not "variant-compatible", and this is allowed.
Resolution of classes implementing IEnumerator should still attempt to select a compatible interface using the standard rules before attempting to apply this special rule.
This is unnecessary and doesn't really make sense semantically in general as
some targets might define a different arch_target depending on bitness, while
still using the same arch/ subdir.
* Change first parameter of mono_nullable_box from guint8* to gpointer to avoid casts.
* [Coop] Provide object creation functions that return handles
and related. Existing functions are left unchanged
instead of layering over new to allay performance concerns.
Note that there are several variations new_object:
alloc vs. non-alloc
fast vs. regular -- fast does not handle finalization or weak fields and is external only
specific vs. non-specific -- specific is "vtable" and "non-specific" is "class"
"_handle" implies "_checked" if we can get away with it, as conversion continues
mono_gc_alloc_handle_array
mono_gc_alloc_handle_mature
mono_gc_alloc_handle_obj
mono_gc_alloc_handle_pinned_obj
mono_gc_alloc_handle_string
mono_gc_alloc_handle_vector
mono_gc_register_object_with_weak_fields(MonoObjectHandle) (raw "obj" vs. handle "object")
mono_gc_wbarrier_object_copy_handle
mono_nullable_box_handle
mono_object_clone_handle
mono_object_new_by_vtable "_by_vtable" instead of "_specific", and implies handle
mono_object_new_handle "_by_class" implied
mono_object_new_handle_mature "_by_class" implied
mono_object_new_pinned_handle "_by_class" implied
mono_object_register_finalizer_handle
mono_value_box_handle
* Combine mono_object_new_fast and mono_object_new_fast_checked.
Suppose we wanted to use coop handles to implement the following icall:
[MethodImpl (InternalCall)]
extern void GetGenericValueImpl<T> (int idx, T out value);
The question is: how should we pass the argument "value" to the C code?
If it was a reference type like "string" , we would use a coop handle:
void ves_icall_GetGenericValueImpl_string (gint32 idx, MonoStringHandleOut value, MonoError *error);
But if it was a valuetype, we would instead pin the memory with an interior
handle and pass the raw address:
void ves_icall_GetGenericValueImpl_int32 (gint32 idx, gint32 *value, MonoError *error);
But we don't have two different implementation on the C side - there's just one
icall - we have to choose a single mechanism.
So the mechanism we choose is to treat all the args like valuetypes - pin the
memory in the wrapper and pass a raw pointer to the C side.
The other troubling possibility is if someone writes:
[MethodImpl (InternalCall)]
extern void BadInternalCall<T> (Something s, T bad);
Now we really don't have any options. So we just assert that noone ever writes
such a call.
On interp we can't async abort since we cannot unwind from an ip in the interp, so the interpreter does explicit checks as part of branch instructions.
Note this can lead to increased stack usage when compiling with -O0.
* [offsets-tool] Add an '--output' argument to specify the output file directly instead of generating it from the target triple.
* [sdks] Add targets for the watch cross compiler.
* [mkbundle] Automatically bundle config files and machine.config files for the simple/cross compiler scenario, fixes one of the missing issues for #6230
When using the interp_wrapper to enter interp from native we don't need to save the lmf since it doesn't make sense to unwind to native. Also make sure we have the interp context set up if we weren't attached at interp transition time.
While Mono does copy the values of arrays back when they are marshaled
to unmanaged code, .NET does not seem to be doing this, and manifests
as the Syscall.poll invocation in Mono.Posix with .NET Core does not update
the values in the provided array.
The following example should print "Got 1 and 1" with the following command:
```
echo foo | dotnet run
```
But instead prints 0 and 1 on .NET Core, but the correct result with Mono.
This patch is going here for the sake of the Mono.Posix.NetCore package that
we publish.
Sample:
```
using System;
using System.Runtime.InteropServices;
class X {
private struct _pollfd {
public int fd;
public short events;
public short revents;
}
[DllImport("libc")]
static extern int poll ([In,Out]_pollfd[] ufds, uint nfds, int timeout);
static void Main ()
{
var p2 = new _pollfd [1] { new _pollfd () { fd = 0, events = 1 } };
var m = poll (p2, 1, -1);
Console.WriteLine ("Got: {0} and {1}", n, pollmap [0].revents);
Console.ReadLine ();
}
}
```
* [runtime] Unboxing of nullable enums should throw for boxed ints. Fixes gh #6666.
For some reason, one can't unbox the underlying type of an enum into a nullable.
This is counter intuitive to the unboxing rules of enums, but it's what dotnet does.
* [interp] Unboxing of nullable enmus should throw for boxed ints
fixes https://github.com/mono/mono/issues/6666 for the interpreter
Ensure that the callback to mono_domain_foreach_safe can actually do stuff with the domain argument like running code.
This new function make it possible to do so safely, unlikely the previous one.
This ensures that the process exit callback has a shot of correctly executing on domains racily being unloaded.
The ProcessExit event is fired before the threadpool is shutdown, so we can leverage that to run them
with a timeout.
The timeout is 3 seconds per appdomain. It could be improved by making that global to all domains if that
ever becomes an issue.
MonoError is simplified for MME by having the error message eagerly created, which simplifies things A LOT.
Managed Exception creation is simplified by only setting Message, as it's done by other runtimes.
* [mini] Fix mini_emit_memory_copy_internal with ref types and remove workaround from mono_method_to_ir
* [mini] Remove unused argument and rename function to better reflect its use.
* [utils] Fix swapped member and signature fields in error message.
* [runtime] Simplify MME by only setting the message field since ClassName/MemberName don't need to be set.
* [runtime] Add mono_error_set_method_missing to exceptions.c and collapse setting MME to a single function.
This implements the cleanup discussed in the PR.
* [runtime] Cleanup MonoError for BadImageFormatException.
Move mono_error_set_bad_image & mono_error_set_bad_image_name to exception.c.
Rename mono_error_set_bad_image_name to mono_error_set_bad_image_by_name.
Introduce mono_corlib_exception_new_with_args to be used when creating exception objects.
It's easier to consume than mono_exception_from_name_two_strings_checked as it takes string arguments as char*.
Fix usage of mono_error_set_bad_image_by_name to never dup the supplied image name as the callee does it.
Fix some empty error messages.
Finally, reduce the cruft in mono_error_prepare_exception by using the new exception creation function from above.
* [runtime] Cleanup MonoError of FileNotFoundException.
Move it to use the generic first_argument and make it a simple error - IE, get_message doesn't format anything.
* [runtime] Rework MonoError for MissingFieldException.
* Fix build issues
* [runtime] Ensure memory is freed using new MonoError set functions.
When unboxing nullable we call Nullable.Unbox which returns the valuetype, but CEE_UNBOX needs to return an address to it. Therefore we store the result in a local in the frame so we can get its address.
* [mini] Fix mini_emit_memory_copy_internal with ref types and remove workaround from mono_method_to_ir
* [mini] Remove unused argument and rename function to better reflect its use.
* Fix gshared support for default interface methods by always passing an mrgctx to them.
This is needed because these methods can be part of more than one inheritance hierarchy or
be present more than once in the same inheritance hierarchy so its not possible to
assign rgxtx slots to their gshared entries that would work in all cases.
* [jit] Add a mini_method_is_default_method () helper function.
Fix a regression introduced in the new web stack - when connecting
to a DNS host name that resolves to multiple IP addresses, we need
to probe them all.
On iOS, "localhost" will resolve to both "::1" and "127.0.0.1".
* [runtime] Make icall tables loadable.
Move the icall table code into a separate icall-table.c file, which is either linked into libmono or compiled into a
separate libmono-icall-table.a archive which can be linked into an app, and installed by calling mono_icall_table_init ().
* Change ClCompile to ClInclude for new .h file.
We must not push one vararg at a time since the alignment of the argument is not the same as the alignment of a value type in interp (which is always 8)
Detect conflicts caused by diamond inheritance during vtable construction, and throw an exception when a conflicting
methods is called.
Disable generic sharing for default interface methods, it doesn't work yet, probably
because these methods are called on classes, but the gshared information is associated with the interface.
Enable dim-diamondshape.exe test.
Setting ReadTimeout in WebResponseStream.ctor throws System.Net.Sockets.SocketException : Invalid arguments on iOS.
Set it in WebConnection.InitConnection() immediately after establishing a connection, before we read/write anything.
* [jit] Simplify some gshared code by calling mini_method_get_rgctx () in more places, make mono_method_lookup_rgctx () static. NFC.
* [jit] Get rid of the 'method' argument to emit_get_rgctx (), it should always be equal to cfg->method. NFC.
.. process. Version from:
https://github.com/dotnet/cli/blob/501e11d928c21608999c934f0a7078570b688c6c/build/DependencyVersions.props
```
<MicrosoftNETSdkPackageVersion>2.1.0-preview1-62414-02</MicrosoftNETSdkPackageVersion>
<MicrosoftNETBuildExtensionsPackageVersion>$(MicrosoftNETSdkPackageVersion)</MicrosoftNETBuildExtensionsPackageVersion>
```
Also, update the list in the runtime and deniedAssembliesList.txt
installed for use by msbuild.
.. assemblies.
This is specifically required for handling .net assemblies in
`Microsoft.NET.Build.Extensions` nuget which don't work on mono. These
assemblies are bundled with msbuild and we want to be able to deny these
at runtime.
* [configure.ac] Add --enable-checked-build=private_types option
The idea is that when private_types is turned on, we will hide the definitions
of various structs in Mono and only allow access via getter/setter
methods.
If private_types is off, those same getters would be static inline functions
and also the struct definition would be visible (to allow for incremental
conversion of existing code).
* [metadata] Move _MonoClass definition to class-private-definition.h
* [metadata] Define a getter for every MonoClass field
in a checked build, the getters are just declared in class-internals.h and
defined in class-accessors.h
in a non-checked build, the getters are static inline functions in class-internals.h
For a field foo of type FooType define
FooType m_class_get_foo (MonoClass *klass) { return klass->foo; }
The exceptions are fields that are embedded structs, e.g. MonoType byval_arg,
for those we return a pointer to the field instead of a copy:
MonoType * m_class_get_byval_arg (MonoClass *klass) { return &klass->byval_arg; }
* [metadata] Rename MonoClass boolean getters to use is/has names
instead of the string m_class_get_fieldname pattern
- m_class_is_inited
- m_class_is_size_inited
- m_class_is_valuetype
- m_class_is_enumtype
- m_class_is_blittable
- m_class_is_unicode
- m_class_was_typebuilder
- m_class_is_ghcimpl
- m_class_has_finalize
- m_class_is_delegate
- m_class_is_gc_descr_inited
- m_class_has_cctor
- m_class_has_references
- m_class_has_static_refs
- m_class_has_no_special_static_fields
- m_class_is_com_object
- m_class_is_interfaces_inited
- m_class_is_simd_type
- m_class_is_has_finalize_inited
- m_class_is_fields_inited
- m_class_has_failure
* [metadata] (class-internals.h) Use m_class_get_ getters
* [metadata] (class-inlines.h) Use m_class_get_ getters
* [metadata] (class-accessors.c) Use m_class_get_ getters; setters not done
The setters are not converted.
Ultimately, I think that will sort itself out - a few of them are only used
from SRE and from MonoClass construction - we will eventually provide setters
for just two places and hide them elsewhere.
When doing a vararg call we push on the vtstack the current call signature followed by the params. The child_frame will have a pointer to this memory on the parents vt_stack from where it can linearly access the varargs using the same ArgIterator logic.
Use `git blame -C10 mono/metadata/class-init.c` to see attribution for most of the old code.
This PR comprises:
* [metadata] Move (some) MonoClass construction to class-init.c
So far moved MonoClassDef, MonoClassGtd and MonoClassGenericInst construction
functions.
The idea is to eventually isolate functions that needs write/setter access to
MonoClass fields in a separate translation unit and make MonoClass opaque and
only accessible via getters everywhere else.
* [metadata] Move pointer MonoClass creation to class-init.c
* Mark mono_ptr_class_get as external only, runtime should use
mono_class_create_ptr.
* [msvc] Add mono/metadata/class-init.c (and .h) to the .targets file
* [metadata] Rename mono_generic_class_get_class
to mono_class_create_generic_inst
* [metadata] Move array class creation to class-init.c
* Mark mono_array_class_get external only, runtime should use
mono_class_create_array
* Mark mono_bounded_array_class_get external only, runtime should use
mono_class_create_bounded_array
* [metadata] Move generic param creation to class-init.c
* Also move mono_class_setup_vtable_general, mono_class_init_sizes, mono_class_setup_methods
* [metadata] Move mono_class_setup_basic_field_info to class-init.c
* [metadata] Move mono_class_setup_fields to class-init.c
* [metadata] Rename mono_class_from_generic_parameter_internal
to mono_class_create_generic_parameter
* [metadata] Move mono_class_layout_fields to class-init.c
* [metadata] Move mono_class_setup_{properties,events} to class-init.h
* [metadata] Move mono_class_setup_interfaces to class-init.c
* Also move mono_class_setup_mono_type
* [metadata] Move mono_class_setup_parent to class-init.c
* [metadata] remove some extern statistics
* [runtime] Add a 'frame_addr' field to MonoStackFrameInfo, which is equal to either interp_frame or ctx->sp.
Use this field to compare frames with each other or with stack addresses instead of setting ctx->sp to
the interp frame address, which breaks mixed mode, since mixed mode assumes ctx->sp is the real
sp of the last native interpreter frame.
* [ci] Reenable mixed mode tests.
* [System]: WebResponseStream now correctly reads the chunk trailer when using gzip/deflate.
This should actually fix bug #59779.
* Add missing ConfigureAwait(false)
* Get autotools scripts for Mono and Boehm to recognize i
PASE is most similar to AIX, and perhaps I assume other commercial
Unices, as well as PowerPC Linux, so grab variables from them as
needed.
With this, we get glib failing to build due to missing mkdtemp.
* Use better cpp definition to grab more of what we want
* Fix random and 64-bit file offset support
* Set TARGET on IBM i on POWER
* Add hack to gfile-unix.c to work around flawed AIX header
From comment:
/* HACK: the preprocessor will not give us mkdtemp no matter
what and Mono (for good reason) does
"-Werror-implicit-function-declaration" so we error out;
instead declare mkdtemp here; the linker will find mkdtemp
anwyays. libuv has had similar issues, but they just ignore
the compiler warning instead of failing on it.
See: github.com/libuv/libuv/pull/740 */
* Work around missing definition on AIX/PASE
* Fix conflicting definition from due too AIX headers
* Initial work to get JIT working on AIX
* uncertain about NIP; is IAR the right register? need review from
PPC asm people
* needs calling convention work; AIX does NOT use ELF
* Fix lack of casting on sigcontext macros, fix errnos for AIX
* AIX doesn't distinguish between ENOTEMPTY and EEXIST without a
define. Handle this case with a conditional cpp directive..
* When ctx is a void pointer, dereferencing as a struct will fail.
Handle this case with a cast.
* Handle regular AIX as well as PASE
* Implement stack boundaries check for AIX, volume info func
* vol info should be like other Unix, just needs to bridge ifdef
* highly uncertain for the bounds checking, needs further review
* Fix typo in mono/utils/mono-threads-aix.c
* In boehm-gc.c, don't use pthread_getattr_np on AIX even if available
It's not available on IBM i, and even if available, toolchains for AIX
may "helpfully" swap out system headers with variants that remove
functions like pthread_getattr_np.
* Don't use "-export-dynamic" on non-GNU ld
IBM ld considers "-e" to be a flag for setting the entry point.
Detect non-GNU ld, and offer equivalents when possible.
The makefile in mini had to be changed as a result due to
hardcoded flags.
* Use pthread-stop-world.c on AIX
Remove an ifdef that gated this off to AIX. It seems the old AIX
specific files shouldn't be used, and that the changelog for libgc
says pthread should work fine on AIX instead; yet it was blocked.
Restore this, as it compiles and seems to let mono-boehm link fine.
* AIX workarounds for some of support dir
* fstab on AIX is there, but defines a struct more like other
platforms' checklist struct.
* AIX, like macOS and some BSDs, doesn't define some serial types.
* psignal is another victim of GNU; even then it isn't in PASE
headers anyways
* More support workarounds for AIX headers
* Replacement function body for syslog2 on vsyslog-less platforms
AIX lacks vsyslog; detect in autoconf and act appropriately.
* Final support hacks for AIX
* Fix problematic stack management on AIX
this gets us past ifdefs, after much handwringing
* get the right end of the stack; r1/stack pointer is on the wrong
end and ustk is just plain broken
* AIX doesn't seem to like the semantics of the mmap call valloc
does here; either we're allocating into an area we shouldn't be
or we're not passing the right flags. Until then, learn to live
without the stack guard?
* Disable Boehm GC on AIX
Focus on getting SGen working, and avoid legacy debugging nonsense
* Remove AIX ifdef-undef and replace with s/hz/uhz
* Don't use sigaltstack on AIX due to bugginess with guard sections
The valloc call on AIX has issues after issuing mprotect; don't do
do it. I believe it fails because we aren't issuing the right
flags on AIX, or because we're allocating inside of an already
allocated area.
* Perform a 64-bit build on AIX
We still crash at the same place, but probably for the best that
we switch to 64-bit. (Maybe we could make it configurable?)
* Fix func descriptor ifdef, add initial (likely wrong) defs for AIX
* AIX doesn't define __powerpc64__ or __ppc64__ when compiling as
64-bit. Use an alternate ifdef, and shuffle around that ifdef
anyways, as it could lead to wrong results on other platforms
too.
* AIX likely needs special definitions, especially on 32-bit. The
calling convention is closest to PPC64BE Linux, but not exactly.
* Fix stack size on AIX
Ruby dealt with this before: https://github.com/ruby/ruby/commit/a2594be783c727c6034308f5294333752c3845bb
* Set up initial PPC hwcap for AIX, fix ftnptr ifdefs, tweak AIX defs
* Fix hwcap to use better values on PPC AIX
Still needs more adjustment though
* Fix alignment issue on AIX, tweak mini-ppc values just a bit more
* On AIX, doubles are always aligned by 4 if they're in structs.
Since we need to have them aligned by 8 on 64-bit, this is bad,
so change the type on AIX.
* We can use this definition on AIX
Now we can bootstrap Mono!
* Shuffle MonoArray ifdef per suggestion of @vargaz
* Fix System.Decimal division on big endian systems
Before, we got non-sensical overflow on things like
`(Decimal)Int32.MaxValue / 1000`; now they get the same value,
comparing this POWER6 running AIX to my server's output running
OpenBSD/amd64.
* Fix dynamically linked build of Mono on AIX
nm wasn't seeing 64-bit symbools as it defaults to 32-bit mode,
also never try to use GNU nm
* Fix PPC64 define in mono-config
Interestingly, there was an AIX define already present, and that
definition is present in AIX's passed includes, so continue to use
it.
* Don't use __thread even if detected on AIX
tl;dr: The assembler gets angry with __thread and minimal-toc, and
changing options to replace minimal-toc causes linker issues; this
TLS option isn't important anyways if we have pthread instead,
like before when we were using Perzl's old GCC without __thread.
* Get lib.a(lib.o) type archives working with P/Invoke for AIX
AIX libraries are very, very strange compared to other Unices.
I'm not entirely sure if this is correct or optimal; it may need
to special case further. For now, it's enough to get gacutil
up and running.
Some resources I found useful for this charade:
<http://stromberg.dnsalias.org/~dstromberg/AIX-shared-libs.html>
Also set libc and libintl to their proper values.
* Scheduling priority hack for i
PASE doesn't accept anything other than SCHED_OTHER, and the funcs
for getting min/max don't work either. AIX suffers, but only a
little bit.
* Final polish on request
Remove Boehm changes if we don't use Boehm, tweak some defines,
remove some externs, tweak autoconf file
* Be aware of ERESTART, on OSes that use it
Instead of EINTR/EAGAIN, AIX uses ERESTART. Handle this, so things
like xsp are less chatty when performing async IO.
The `label` environment variable is set by Jenkins based on the
chroot/node configuration a given job is using.
This crept into the CI scripts while it should have been a
separate concern and caused all sorts of issues when we bumped
from e.g. debian-8-* to debian-9-* in some jobs.
Instead we should consistently use the CI_TAGS env var which we
control exclusively.
* [sdks] Fix build for llvm
* [sdks] Have .stamp-%-configure always depend on .stamp-%-toolchain
* [sdks] Dependencies on directories should always be order-only
This commit implements checking whether the compiler used to build mono supports
the recently added switches to generate code designed to mitigate the effects of
the Spectre/Meltdown bugs of the modern CPUs (https://meltdownattack.com/).
As of this commit the options are implemented for GCC 8.x, 7.3 and backported to
some older versions of gcc 7.x (e.g. in Ubuntu). The options tested for, and
used, here are:
-mindirect-branch (https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/x86-Options.html#index--mindirect-branch)
-mfunction-return (https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/x86-Options.html#index--mfunction-return)
Checks and usage of the above flags is hidden behind the
`--with-spectre-mitigation` configure option, defaulting to `no`.
Two additional options are implemented to specify the kind of thunk to implement
by each of the flags above:
--with-spectre-indirect-branch-choice=keep,thunk,inline,extern
Convert indirect branches to the specified kind of thunk (defaults to inline)
--with-spectre-function-return-choice=keep,thunk,inline,extern
Convert function return instructions to the specified kind of
thunk (defaults to inline)
The CoreFX version has a few error checks which are not in the
referencesource, switching to CoreFX allows us to enable their tests.
Use Path.GetRandomFileName() and Path.GetTempFileName() in tests.
We are now using nested streams to take care of buffering, chunked encoding and automatic decompression.
GZip / Deflate decompression have been moved inside `WebResponseStream`, the `HttpWebResponse` now always returns a `WebResponseStream` (and not a `GZipStream`) because we have to do extra book-keeping after reading the entire content.
Returns TRUE if the method flags indicate that it's not expected to have a
body because it is abstract, a PInvoke, an internal call or a
runtime method.
* Print combined stdout and stderr in console output.
* Print the RNG seed used for a test run on startup and in the test report.
* Set the individual test timeout back to 6 hours.
* Use the nodefaults profiler option.
* Allow configuration through environment variables:
- MONO_PROFILER_STRESS_OPTIONS: Specify a set of profiler options to use
instead of the randomly generated ones.
- MONO_PROFILER_STRESS_REGEX: Specify a regular expression to filter which
tests should be run.
- MONO_PROFILER_STRESS_SEED: Specify the RNG seed. Useful for reproducing full
test runs at a later point.
- MONO_PROFILER_STRESS_TIMEOUT: Specify a different individual test timeout
from the default.
it has the right logic to avoid this:
```
ld: -undefined and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
```
i.e. setting `-no-undefined`. However, this requires that we link
against `libmonosgen` on those platforms.
We've been using a certain pattern for the Windows .msi for a long
time but the build output used a different name which we simply
manually renamed before publishing.
Since we want to automate as much as possible we can change the
build to produce the correct name right away.
For mono_thread_get_undeniable_exception to work, it needs to unwind the stack and find the first managed frame. This is only possible if we push an interp LMF with a frame for the interp to native transition.
During interp frame unwinding, we were initializing the sp field (to the corresponding interpreter frame) starting with the parent frames of the first interpreter frame.
Debugger maintains it's own list of loaded classes. The unload/filter
logic does not handle composite types like arrays and generic instances.
Expose and reuse the logic from metadata that properly detects any
usage of an image within a type.
This prevents the cache from containing MonoClass values which have
already been freed by the metadata cleaning code.
* Minimal fix to Authenticode infrastructure to understand PE32+.
A number of other problems are noticed in the code but commented only.
This fixes https://bugzilla.xamarin.com/show_bug.cgi?id=56071
* Induce many array out of bounds accesses, and some other error paths.
* Tweaks.
* tweak
* Move braces, move addition, document constants and use them.
* whitespace
* fix comment
* remove diff-minimizing hacks
* cosmetic
* move braces and assume zero-initialization; adjust comment.
* improving Makefile but still a ways to go
* fix C# indent
* Change from C++ to C, and cleanup Makefile.
* update clean target in Makefile
* cleanup Makefile and C#
* remove test code that people don't like and it wasn't very useful
wordsmithing and new good information in comments
* Fix indentation
When an exception is thrown from jitted code, the EH mechanism correctly sets the interp resume data to the right interp frame that should catch the exception, but it resumes to the interpreter by force, setting the MonoContext. This context has invalid data (for example the SP points to a InterpFrame and it is not the real sp at interp exit)
This bug was exposed by inlining changes from d3763c6c1e
* Move machine handling of performance counters from native
to managed -- just slightly less native code therefore.
* PR feedback: Rename ValidMachine to IsValidMachine.
Use string::operator== instead of .Length/[].
Change InstanceExistsInternal to return bool/MonoBoolean directly instead of int.
Remove question mark on FIXME comment for more reliable grep.
Remove redundant zeroing of a pointer.
Also add two more variants
* mono_error_assert_msg_ok (err, msg) to print "msg, due to <err>" on failure
* mono_error_assertf_ok (err, fmt, args...) to print
"<formatted args>, due to <err>" on failure.
Avoid inlining some functions with high stack frame locals usage (ex functions that use MonoLMFExt which is a big structure).
No performance cost was observed on microbenchmarks, while stack usage decreased by over 3 times on amd64 and over 4 times on arm.
Give it 2.5 seconds.
https://jenkins.mono-project.com/job/test-mono-pull-request-amd64/10727/parsed_console/log.html
Tests run: 120, Passed: 119, Errors: 0, Failures: 1, Inconclusive: 0
Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
Elapsed time: 00:00:32.8320000
Errors and Failures:
EndBuildWaitsForSubmissionCompletion (MonoTests.Microsoft.Build.Execution.BuildSubmissionTest.EndBuildWaitsForSubmissionCompletion)
#5
Expected: less than or equal to 00:00:02
But was: 00:00:02.0757916
at MonoTests.Microsoft.Build.Execution.BuildSubmissionTest.EndBuildWaitsForSubmissionCompletion () [0x00126] in /mnt/jenkins/workspace/test-mono-pull-request-amd64/mcs/class/Microsoft.Build/Test/Microsoft.Build.Execution/BuildSubmissionTest.cs:105
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /mnt/jenkins/workspace/test-mono-pull-request-amd64/mcs/class/corlib/System.Reflection/MonoMethod.cs:305
Split mono_method_get_header_checked into internal and external forms. (#6609)
External form is mono_method_get_header_checked, the preexisting name.
Internal form is mono_method_get_header_internal.
External must initialize the MonoError for compatibility, internal can/should assume it is already initialized per the new pattern.
* g_assert should be an expression not a statement; provide g_assertf f is format like printf
- g_assert should be an expression, not a statement
ANSI C assert gets this correct, and I corrected
widely used NT ASSERT circa 2001 with no ill effects
Note that ANSI C assert is void, g_assert here is boolean.
- provide g_assertf
f is for format, like printf -- too terse?
Where you might previously say:
if (!(expr))
g_error(...); // like printf
now:
g_assertf(expr, ...)
Manual tests provided -- how to provide a test whose success is failure to compile?
Correct existing eglib/test to build and pass, but don't enable in build.
Enabling it is a line in toplevel configure.ac to add eglib/test/Makefile
after eglib/Makefile.
* Fix comment in test code.
* format with s instead of hs
* review
* [WASM] Fix System.Core issues and disable broken tests.
* [wasm] Fix cookie computation heap overflow. Use a local to make it thread safe.
* [wasm] Disable System tests that don't work under WASM. Change the wasm profile to disable BSD sockets.
* [wasm] Address reviewer feedback.
* [wasm] Disable test that requires multiple threads.
* [wasm] Add package target to wasm.
* [wasm] Modify the runner to exit(1) if the test suite fails.
* [wasm] Add CI configuration for WebAssembly.
* [wasm] Fix issues found over review.
* [runtime] Export mono_class_get_checked () for use in profilers.
* [runtime] Expand mono_method_get_header_summary () to collect more info.
It now collects all the trivially-accessible header data that doesn't require
chasing down other metadata.
* [profiler] Use mono_method_get_header_summary () in the coverage code.
We only need code start and size information, not all the data that is present
in the header. By switching to this function, we avoid all the side effects
that come with resolving local variables and exception clauses (which can even
result in loading assemblies in the worst case).
* [profiler] Write out all uncovered classes/methods in a loaded image.
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=60225
This required a bit of refactoring and some workarounds for various special
cases. This also fixes some race conditions with respect to how data was
inserted into the lock-free hash tables and queues.
In c7d8d247c3 I unified how we're
passing -arch in CFLAGS to "-arch=XXX" since the original change
in 63a49e9eb8 mixed the formats.
Turns out the correct syntax is "-arch XXX" instead and it broke
the ccache build in bockbuild because it complained about the
unknown format.
Also add LDFLAGS in the amd64 case to match what we have in bockbuild.
When we had a jit info table for aot images loaded in the domain, we would queue jit infos for freeing at domain unload time. This means leaking during entire application life.
Add comment for jit info freeing when having multiple tables.
Fixes#60986.
This cute hack allow us to cut the budget of perf irrelevant blocks[1] while massively boosting those that are perf relevant[2].
It has a ton of missing features, like it doesn't detect nested loops, it doesn't take hints from inlined methods and it doesn't compute EH info.
Beyond that, inlining budget is all but horrible, so there's ton of room for improvement here.
Results are promising.
A marginal improvements in benchmarks like Roslyn (2% user) while as much as 30% in micro benchmarks where the now bigger methods are in loop bodies.
Code size with Roslyn changed from 5433242 to 5501751, IE extra 68.5k, or 1.2% more.
[1] those ending in throw or in a catch handler
[2] Loops
we return the address of the StackOverflowException object in
`restore_soft_guard_pages`, so it ends up in the architecture specific
result register (e.g. %rax) where the exception handler expects it.
fixes https://bugzilla.xamarin.com/show_bug.cgi?id=60862
* [test-runner] Record test duration in NUnit xml
This allows us to keep track of the time on Jenkins.
Also fix issue where we were recording .Seconds of a TimeSpan instead of .TotalSeconds.
* [tests] Bump timeouts in process-stress-?.exe runtime tests
We're seeing these fail sometimes on Linux Azure VMs, let's try
if bumping the timeouts helps.
* [class] Add Obsolete message to ICSharpCode.SharpZipLib.dll
Users should use the nuget package instead, we'll remove the assembly in Mono 6.0
Don't install it into the 4.7.1 reference assembly directory anymore.
* Bump API snapshot submodule
* [runtime] Allow access to protected default interface methods from classes which implement the interface.
* [interp] Add some automatic conversations between virtual and non-virtual calls that .net has. Fixes dim-valuetype.il.
* [bcl] Sort the MethodImpl table in PEAPI.
* [runtime] Enable dim-methodimpl.exe test.
* [runtime] Fix vtable construction tracing.
* [interp] Fix null checks on the receiver when converting virtual calls to non-virtual.
Rationale:
1. it asks for double faulting scenarios we can't do anything about
it anyway, exception just unmap yet another page
2. `mprotect(2)` behaves weirdly (at least on macOS) if you try to
change permissions for subsequent pages with different permissions.
With the previous code it happened that the requested memory range
would go from somewhere in the stack guard and overlap into the
regular, unprotected stack and end up with unpredictable behaviour.
We could be more careful about it, but it would complicate things
even more.
no longer needed. It remains only for register_icall.
Remove casts from void* to HANDLE, as HANDLE always and forever
will also be void*.
Add comments explaining the valid use of INVALID_HANDLE_VALUE (-1).
With CreateFileMapping, for the file handle, it means to
use physical memory / pagefile.
Previously, we tried to keep the intern status of a string consistent across domains. Meaning
that if you interned "FOO" in domain 0, it would return true for String.IsInterned in domain 1.
This behavior exists in the CLR because the string table is shared between domain as string are
what they call agile objects - those that can exit in multiple domains at the same time.
Mono appdomain isolation doesn't work that way and there's not visible advantage of keeping that property.
The reason for this change is to potentially reduce the amount of interned strings and, more importantly,
reduce the amount of domain lookups, which are quite expensive and unsafe.
This should speed up interning queries.
Follow up to https://github.com/mono/mono/pull/6431, we should
capture the exception that is passed to the methods.
Copied the SetResult() method that referencesource uses.
* [mini] factor out interp into a library
It enables us to ship the interpreter as an add-on to the runtime.
Embedder can statically link it into their application on demand.
Usage:
configure mono without the interpreter, such as:
```
$ ./autogen.sh --enable-minimal=interpreter ...
$ make; make install
```
run your favorite program with the interpreter and see it fail:
```
$ ./mono/mini/mono-sgen --interpreter ./mono/mini/basic.exe
Mono IL interpreter support is missing
```
despite `--enable-minimal=interpreter`, we can still build the interp
module:
```
% make -C mono/mini libmono-ee-interp-static.la
CC interp/libmono_ee_interp_static_la-interp.lo
CC interp/libmono_ee_interp_static_la-mintops.lo
CC interp/libmono_ee_interp_static_la-transform.lo
CCLD libmono-ee-interp-static.la
```
`libmono-ee-interp-static.a` can be statically linked into the target
application.
* [fixup] include libmono-ee-interp reference in runtime unit-tests
* [runtime] Mark mono_class_get and mono_class_get_full external only.
Runtime should use mono_class_get_checked and
mono_class_get_and_inflate_typespec_checked, respectively.
* [runtime] Mark mono_ldtoken external only
Runtime should use mono_ldtoken_checked
* [metadata] Mark mono_type_create_from_typespec external only
Runtime should use mono_type_create_from_typespec_checked
* [runtime] Remove mono_class_inflate_generic_method_full.
Mark mono_class_inflate_generic_method external only.
Runtime should use mono_class_inflate_generic_method_full_checked.
* [runtime] Mark mono_get_inflated_method external only
This function is obsolete. It should have no callers.
* [metadata] Mark mono_field_from_token external only
Runtime should use mono_field_from_token_checked
* [runtime] Add MonoError arg to mono_class_get_inflated_method
* [metadata] Mark mono_metadata_parse_method_signature external only
Runtime should use mono_metadata_parse_method_signature_full
* [metadata] Mark mono_metadata_interfaces_from_typedef as external only.
Runtime should use mono_metadata_interfaces_from_typedef_full
* [mini] Add MonoError arg to mono_class_get_method_generic
Also move its declaration from metadata/class-internals.h to mini/mini.h
since it's defined and used in mini/
* [class] Assert that mono_class_get_inflated_method never returns NULL
https://github.com/mono/mono/pull/5599 fixed a race condition during shutdown
when runtime threads have come parts of their way through detach, but still
depend on runtime resources, like GC memory. The fix added runtime threads
to the joinable thread list just before they vanished from mono_thread_manage
radar making sure shutdown waited upon the thread before cleaning up.
The above fix slightly changed the behavior of the finalizer thread since it
waits on joinable threads and will now potential block on threads still
executing code (that involves runtime resources). There’s was an assumption
around the threads on the joinable thread list that they should be very close
to complete when added, so join calls coming from the finalizer thread should
almost never block and if it does, the code that remains to execute should not
involve runtime operations risking deadlock situations. Adding the thread to
the list earlier than previously done expose the shutdown to some potential
theoretical problems.
To mitigate the risk and still solve the race condition this commit adds a
mechanism to keep track of active runtime threads until they park on joinable
thread list. The pending counter will be waited upon by the shutdown
thread, just before it does its regular wait on all joinable threads
(after finalizer thread has stopped) to make sure all runtime threads have
been added to the joinable thread list before waiting upon them. Threads are
added to the joinable thread as late as possible, exactly how it’s been done
in the past by sgen_client_thread_detach_with_lock. Shutdown thread will wait
on runtime threads to appear on the list for a short time and if timeout (pending
runtime thread count not reaching 0 before timeout), it will just print a warning
and continue shutdown.
Getting into a wait state during shutdown due to runtime threads not yet added to
joinable threads list should be very rare (hitting previous race condition that was rare),
triggering the timeout should be even more rare, and if that ever happens, we are exposed
to shutdown race condition as we have had in the past, but now we at least get a warning in
the log making it simpler to analyze further.
This commit also fixes a problem with the debugger thread hitting the same race condition as above.
The shutdown thread stopping the debugger thread didn't completely wait for it to stop using runtime
resources before continue shutdown sequence. This triggers the same race condition as when shutting
down regular runtime threads. This commit makes sure stop_debugger_thread waits on the debugger thread
handle to become signaled (happens at the very end of thread lifetime) before continuing the shutdown
logic.
2017-12-14 10:52:51 +01:00
1694 changed files with 65209 additions and 41169 deletions
If you are new to contributing to Mono, please try to do your best at conforming to our coding guidelines http://www.mono-project.com/community/contributing/coding-guidelines/ but don't worry if you get something wrong. One of the project members will help you to get things landed.
Does your pull request fix any of the existing issues? Please use the following format: Fixes #issue-number
AC_ARG_ENABLE(ninja,[ --enable-ninja Enable using ninja where available], enable_ninja=$enableval)
AC_CHECK_PROG(HAVE_NINJA, ninja, yes, no)
AM_CONDITIONAL(NINJA, test x$enable_ninja = xyes -a x$HAVE_NINJA != xno)
AC_ARG_ENABLE(werror, [ --enable-werror Pass -Werror to the C compiler], werror_flag=$enableval, werror_flag=no)
if test x$werror_flag = xyes; then
@@ -864,7 +885,6 @@ if test "x$with_xen_opt" = "xyes" -a "x$mono_cv_clang" = "xno"; then
CFLAGS="$CFLAGS -mno-tls-direct-seg-refs"
AC_MSG_CHECKING(for -mno-tls-direct-seg-refs option to gcc)
AC_TRY_COMPILE([], [
return 0;
], [
AC_MSG_RESULT(yes)
# Pass it to libgc as well
@@ -980,6 +1000,52 @@ AC_ARG_WITH(wasm, [ --with-wasm=yes,no If you w
AC_ARG_WITH(runtime_preset, [ --with-runtime_preset=net_4_x,all,aot,hybridaot,fullaot,bitcode,unreal Which default profile to build (defaults to net_4_x)], [], [with_runtime_preset=net_4_x])
AC_ARG_WITH(spectre-mitigation, [ --with-spectre-mitigation=yes,no If you want to build the runtime with compiler flags that enable Spectre mitigation (defaults to no)], [], [with_spectre_mitigation=default])
AC_ARG_WITH(spectre-indirect-branch-choice, [ --with-spectre-indirect-branch-choice=keep,thunk,inline,extern Convert indirect branches to the specified kind of thunk (defaults to inline)], [], [with_spectre_indirect_branch_choice=inline])
AC_ARG_WITH(spectre-function-return-choice, [ --with-spectre-function-return-choice=keep,thunk,inline,extern Convert function return instructions to the specified kind of thunk (defaults to inline)], [], [with_spectre_function_return_choice=inline])
dnl
dnl Spectre compiler mitigation flag checks
dnl
if test "x$with_spectre_mitigation" = "xyes"; then
AC_MSG_NOTICE([Compiler Spectre mitigation support checks])
for feature in `echo "$enable_minimal" | sed -e "s/,/ /g"`; do
eval "mono_feature_disable_$feature='yes'"
@@ -1356,6 +1422,12 @@ fi
AM_CONDITIONAL(DISABLE_INTERPRETER, test x$mono_feature_disable_interpreter = xyes)
if test "x$mono_feature_disable_interpreter" != "xyes" -o "x$mono_feature_disable_jit" != "xyes"; then
AC_DEFINE(ENABLE_ILGEN, 1, [Some VES is available at runtime])
fi
AM_CONDITIONAL(ENABLE_ILGEN, test x$mono_feature_disable_interpreter != xyes -o x$mono_feature_disable_jit != xyes)
if test "x$mono_feature_disable_simd" = "xyes"; then
AC_DEFINE(DISABLE_SIMD, 1, [Disable SIMD intrinsics related optimizations.])
AC_MSG_NOTICE([Disabled SIMD support])
@@ -1411,29 +1483,25 @@ if test "x$mono_feature_disable_mdb" = "xyes"; then
AC_MSG_NOTICE([Disabled support for .mdb symbol files.])
fi
if test "x$mono_feature_disable_sgen_remset" = "xyes"; then
AC_DEFINE(DISABLE_SGEN_REMSET, 1, [Disable wbarrier=remset support in SGEN.])
AC_MSG_NOTICE([Disabled wbarrier=remset support in SGEN.])
if test "x$mono_feature_disable_sgen_marksweep_conc" = "xyes"; then
AC_DEFINE(DISABLE_SGEN_MAJOR_MARKSWEEP_CONC, 1, [Disable concurrent gc support in SGEN.])
AC_MSG_NOTICE([Disabled concurrent gc support in SGEN.])
fi
if test "x$mono_feature_disable_sgen_marksweep_par" = "xyes"; then
AC_DEFINE(DISABLE_SGEN_MAJOR_MARKSWEEP_PAR, 1, [Disable major=marksweep-par support in SGEN.])
AC_MSG_NOTICE([Disabled major=marksweep-par support in SGEN.])
if test "x$mono_feature_disable_sgen_split_nursery" = "xyes"; then
AC_DEFINE(DISABLE_SGEN_SPLIT_NURSERY, 1, [Disable minor=split support in SGEN.])
AC_MSG_NOTICE([Disabled minor=split support in SGEN.])
fi
if test "x$mono_feature_disable_sgen_marksweep_fixed" = "xyes"; then
AC_DEFINE(DISABLE_SGEN_MAJOR_MARKSWEEP_FIXED, 1, [Disable major=marksweep-fixed support in SGEN.])
AC_MSG_NOTICE([Disabled major=marksweep-fixed support in SGEN.])
if test "x$mono_feature_disable_sgen_gc_bridge" = "xyes"; then
AC_DEFINE(DISABLE_SGEN_GC_BRIDGE, 1, [Disable gc bridge support in SGEN.])
AC_MSG_NOTICE([Disabled gc bridge support in SGEN.])
fi
if test "x$mono_feature_disable_sgen_marksweep_fixed_par" = "xyes"; then
AC_DEFINE(DISABLE_SGEN_MAJOR_MARKSWEEP_FIXED_PAR, 1, [Disable major=marksweep-fixed-par support in SGEN.])
AC_MSG_NOTICE([Disabled major=marksweep-fixed-par support in SGEN.])
fi
if test "x$mono_feature_disable_sgen_copying" = "xyes"; then
AC_DEFINE(DISABLE_SGEN_MAJOR_COPYING, 1, [Disable major=copying support in SGEN.])
AC_MSG_NOTICE([Disabled major=copying support in SGEN.])
if test "x$mono_feature_disable_sgen_debug_helpers" = "xyes"; then
AC_DEFINE(DISABLE_SGEN_DEBUG_HELPERS, 1, [Disable debug helpers in SGEN.])
AC_MSG_NOTICE([Disabled debug helpers in SGEN.])
fi
AC_ARG_ENABLE(executables, [ --disable-executables disable the build of the runtime executables], enable_executables=$enableval, enable_executables=yes)
@@ -1592,6 +1660,33 @@ if test x$platform_android = xyes; then
AC_ARG_ENABLE(icall-symbol-map,[ --enable-icall-symbol-map Generate tables which map icall functions to their C symbols], icall_symbol_map=$enableval, icall_symbol_map=no)
if test "x$icall_symbol_map" = "xyes"; then
@@ -4083,6 +4226,8 @@ if test "x$icall_tables" = "xno"; then
AC_ARG_ENABLE(checked_build, [ --enable-checked-build=LIST To enable checked build (expensive asserts), configure with a comma-separated LIST of checked build modules and then include that same list in the environment variable MONO_CHECK_MODE at runtime. Recognized checked build modules: all, gc, metadata, thread],[
AC_ARG_ENABLE(checked_build, [ --enable-checked-build=LIST To enable checked build (expensive asserts), configure with a comma-separated LIST of checked build modules and then include that same list in the environment variable MONO_CHECK_MODE at runtime. Recognized checked build modules: all, gc, metadata, thread, private_types],[
Loaded 100 of 1694 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.