RyuJIT: Don't emit null checks for constant strings by EgorBo · Pull Request #37245 · dotnet/runtime (original) (raw)

It's rotted a bit.

Currently mono desktop runtime packs don't include libhostfxr.* and libhostpolicy* libs needed for corehost in self contained mode.

Co-authored-by: Alexander Köplinger alex.koeplinger@outlook.com

Co-authored-by: Stephen Toub stoub@microsoft.com

Co-authored-by: Thomas Levesque thomaslevesque@users.noreply.github.com

Co-authored-by: lateralusX lateralusX@users.noreply.github.com

Add a general options API to the runtime, based on the flags API in Google V8:

https://chromium.googlesource.com/v8/v8.git/+/refs/heads/master/src/flags/

Supported features:

This is designed to replace the many option parsing functions in the runtime, MONO_DEBUG, the many mono_set_... functions etc.

Co-authored-by: vargaz vargaz@users.noreply.github.com Co-authored-by: Zoltan Varga vargaz@gmail.com

This reverts commit 51f6b8bd3a2a38c432b1cd1f7c465c256f5f699c.

After some recent shuffles of tests location, running the coreclr tests with runincontext option stopped working. This change fixes it by fixing the script path in the run.py.

Co-authored-by: Ryan Lucia ryan@luciaonline.net

Co-authored-by: Ryan Lucia ryan@luciaonline.net

Co-authored-by: Jan Kotas jkotas@microsoft.com

Expressions like ~(BBF_KEEP_BBJ_ALWAYS) were being evaluated as 32 bit signed quantities, leading to mask value 00000000_7FFFFFFFF instead of the desired FFFFFFFF_7FFFFFFFF, causing inadvertent clearing of flags with higher value.

SPMI diffs showed the only flag loss that impacted codegen was BBF_HAS_CALL, which feeds into the CSE heuristics. So no known correctness issue, but it is certainly possible to also lose BBF_DOMINATED_BY_EXCEPTIONAL_ENTRY or BBF_HAS_SUPPRESSGC_CALL and that may be more serious.

These tests are not compatible with running using the runincontext tool.

Because the PKCS#12/PFX import is now done with managed code, the PKCS12 shim was dead code.

  1. If we're inheriting a fraction of the profile weight of a profiled block, mark the inheriting block as profiled. This prevents methods like optSetBlockWeights or optMarkLoopBlocks from coming along later and setting the weights to something else. Since the full inheritance method has similar logic, make it delegate to the fractional one, with a scale of 100 (no scaling).

  2. If we switch from Tier0 to FullOpt, make sure to clear the BBINSTR flag, else we'll put probes into optimized code.

  3. Dump edge weights in the dot graph, if we have them.

  4. Only dump the flow graph twice per phase.

This baselines the remaining test failures with GH issues to track for further investigation.

Co-authored-by: Carlos Sanchez Lopez carlossanlop@users.noreply.github.com

We don't want most analyzers running over our test code currently (some rules could be enabled with varying degrees of effort), but we do want the xunit analyzers running, and they haven't been. Fix that by creating a new ruleset specific to library tests, and switching over to use it when building library test projects.

Co-authored-by: Jan Kotas jkotas@microsoft.com

We also no longer appear to need the NETCORE or DISABLE_REMOTING defines in msbuild, so remove them

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Viktor Hofer viktor.hofer@microsoft.com Co-authored-by: Jeremy Koritzinsky jekoritz@microsoft.com Co-authored-by: Marek Safar marek.safar@gmail.com

Change post-detach-1.cs to also have versions that call reverse pinvokes from foreign threads that were not attached to mono.

The foreign threads should not prevent GC and should not prevent Mono from shutting down using mono_manage_internal.

If a thread is started from native code, and it interacts with the runtime (by calling a thunk that invokes a managed method), the runtime will attach the thread - it will create a MonoInternalThread and add it to the list of threads hash (in threads.c).

If the thread returns from the managed call, it will still be recorded by the runtime, but as long as it is not running managed code anymore, it will prevent shutdown. The problem is when we try to suspend the thread in order to abort it, mono_thread_state_init_from_handle will see a NULL domain (because mono_threads_detach_coop_internal will restore it to NULL when a managed method returns back to native code). (On systems using POSIX signals to suspend, the same check is in mono_thread_state_init_from_sigctx). As a result, mono_threads_suspend_begin_async_suspend (or suspend_signal_handler on POSIX) will set suspend_can_continue to FALSE, and mono_thread_info_safe_suspend_and_run will not run the suspend callback.

As a result, when mono_manage_internal calls abort_threads, it will add the thread handle to the wait list, but it will not actually request the thread to abort. As a result, after abort_threads returns, the subsequent call to wait_for_tids will block until the native thread terminates (at which point the TLS destructor will notify the thread handle and wait_for_tids will unblock).

This commit changes the behavior of abort_threads to ignore threads that do not run async_suspend_critical and not to add them to the wait list. As a result, if a native thread calls into managed and then returns to native code, the runtime will not wait for it.

Give a hint to embedders to aid debugging

It's used to keep track of whether the thread will eventually throw a TAE (and thus that we need to wait for it).

The issue is that under full coop suspend, we treat threads in GC Safe (BLOCKING) state as if they're suspended and always execute async_abort_critical. So the field has nothing to do with whether the thread was suscessfully suspended, but rather whether it will (eventually) be aborted.

If the foreign external thread doesn't have any managed methods on its callstack, but it once called a native-to-managed wrapper, it will be left by mono_threads_detach_coop in GC Safe (BLOCKING) state. But under full coop, GC Safe state is considered suspended, so mono_thread_info_safe_suspend_and_run will run async_abort_critical for the thread.

But the thread may never call into Mono again, in which case it will never safepoint and aknowledge the abort interruption. So set thread_will_abort to FALSE in this case, so that mono_thread_manage_internal won't try to wait for it.


Related to an issue first identified in https://github.com/mono/mono/pull/18517


This supersedes mono/mono#18656

Co-authored-by: lambdageek lambdageek@users.noreply.github.com

Co-authored-by: Stephen Toub stoub@microsoft.com

Co-authored-by: Stephen Toub stoub@microsoft.com

AsyncIteratorMethodBuilder was only doing its clean-up for completion (e.g. zeroing out the state machine and context, removing the object from a debugger-incited tracking table) if the last call to the iterator was part of asynchronous completion; if the last MoveNextAsync completed synchronously, the used code path could miss that cleanup work.

The comment on the test documents the desired precedence order.

Moved some of the existing tests which validate the behavior of the two settings together into a new separate test class.

The Vector128 type is being left in a Blazor WASM application because Utf8Utility.GetPointerToFirstInvalidByte is always creating one, even though it isn't used.

I refactored the code such that the bit mask is no longer created on platforms it is not used, since it is only being used by Arm64.

The hosted pool runs into no disk space issues.

The logic in fgInlinePrependStatements that zero-initializes locals doesn't kick in for jit temps introduced when small stackallocs are optimized. So if we inline a method with a small stackalloc into a loop, the memory for the stackalloc doesn't get properly re-zeroed on each iteration.

Fix by disallowing such inlines by adding an extra check: the call site must not be in a loop.

Closes #43391.

The outerloop run has OSX checked test runs for CG2 and CG2 composite modes. Currently both would use a log upload artifact with the same name (coreclr__TestRunLogs_R2R_CG2_OSX_x64_checked_outerloop). Disambiguate the two with a different LogNamePrefix for composite runs.

The crossgen2 comparison runs are failing to create the baseline crossgen'd framework because the live libraries zip's internal path has changed. .net5 has been replaced with .net6. The build should have failed when we tried to copy from the wrong folder but the error got eaten and we ended up with a malformed framework folder. Adjust the inline yml scripts so if they fail, it will fail that containing build task.

First draft of Dynamic Pgo proposal.

Add --csvmap switch to Crossgen2 which causes it to generate node summary CSV files that are parsable by tests. The intent is to use this for size on disk perf tests so just the node type statistics and individual node map are implemented in CSV files. We can add section and relocs easily if we think they'll be useful in future.

If the runtime gets a single step or breakpoint signal while it is already running native code for a P/Invoke, it will be in GC Safe mode. Switch back to GC Unsafe to run the debugger engine steps.

Addresses https://github.com/mono/mono/issues/20490

Co-authored-by: lambdageek lambdageek@users.noreply.github.com

Co-authored-by: Mitchell Hwang mitchell.hwang@microsoft.com

Co-authored-by: Ankit Jain radical@gmail.com

Co-authored-by: Ankit Jain radical@gmail.com

Co-authored-by: Ankit Jain radical@gmail.com

Co-authored-by: Ankit Jain radical@gmail.com

Fixing stale version badges in docs

From the issue description: Improper cache-control in generated badges caused browsers caching svg badges for a year. It is, therefore, recommend to modify related README.md content by simple find & replace from: _version_badge.svg to _version_badge.svg?no-cache This will trigger github to compute and use different/new Camo proxy URL.

Fix #3822

Co-authored-by: Stephen Toub stoub@microsoft.com

Co-authored-by: Stephen Toub stoub@microsoft.com

Turns it on everywhere except Windows.

This reverts commit 0744e1e432e12c5bddd4ce8c208660e31d96f12a.

This reverts commit 60e511b0bfb1836476a5fcf05ff3450d32c3d907.

This reverts commit e760beb2fcd1a5fcfd22ddf47eb6939a7094562d.

For changes to the ilasm or ildasm source code, trigger the ilasm round-trip pipeline.

There could, of course, be other changes that could affect ilasm/ildasm, but this at least catches the primary ones.

This will not use cmake on windows, it just fixes the conditionals so the windows build doesn't fail if cmake is enabled by default.

This change enables warnings for implicit fallthrough in switch cases and fixes all the cases where the warning was reported. It also fixes some places where the fall through was incorrect. Fortunately, these places were not causing functional issues.

We don't actually pin the byte array, so it must be copied or it can be overwritten once we run a GC on the LOH.

Fixes https://github.com/dotnet/runtime/issues/43402

Tested manually that it fixes the issue using the associated repro. This isn't really something that lends itself to a test, so that's the best I can do.

The semaphore file that is used as the input for deciding whether to rebuild tasks.proj wasn't properly taking the mobile task projects into account. This resulted in e.g. WasmAppBuilder not being built if you built for desktop before, resulting in a build error.

We now use the conditioned project references as an input instead of globbing through all nested projects.

Co-authored-by: Viktor Hofer viktor.hofer@microsoft.com

Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Packaging , Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk , Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk , Microsoft.DotNet.CodeAnalysis , Microsoft.DotNet.GenAPI , Microsoft.DotNet.GenFacades , Microsoft.DotNet.XUnitExtensions , Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.VersionTools.Tasks , Microsoft.DotNet.XUnitConsoleRunner , Microsoft.DotNet.ApiCompat From Version 6.0.0-beta.20514.1 -> To Version 6.0.0-beta.20515.7

Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Xunit From Version 1.0.0-prerelease.20516.1 -> To Version 1.0.0-prerelease.20519.2

Microsoft.NET.ILLink.Tasks From Version 6.0.0-alpha.1.20516.1 -> To Version 6.0.0-alpha.1.20520.1

Microsoft.NET.ILLink.Tasks From Version 6.0.0-alpha.1.20516.1 -> To Version 6.0.0-alpha.1.20520.2

Microsoft.DotNet.Build.Tasks.Feed , Microsoft.DotNet.Build.Tasks.Packaging , Microsoft.DotNet.Build.Tasks.SharedFramework.Sdk , Microsoft.DotNet.Build.Tasks.TargetFramework.Sdk , Microsoft.DotNet.CodeAnalysis , Microsoft.DotNet.GenAPI , Microsoft.DotNet.GenFacades , Microsoft.DotNet.XUnitExtensions , Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Helix.Sdk , Microsoft.DotNet.RemoteExecutor , Microsoft.DotNet.VersionTools.Tasks , Microsoft.DotNet.XUnitConsoleRunner , Microsoft.DotNet.ApiCompat From Version 6.0.0-beta.20514.1 -> To Version 6.0.0-beta.20516.5

runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.win-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.win-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.osx.10.12-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.osx.10.12-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.linux-x64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk , runtime.linux-arm64.Microsoft.NETCore.Runtime.Mono.LLVM.Tools , runtime.linux-arm64.Microsoft.NETCore.Runtime.Mono.LLVM.Sdk From Version 9.0.1-alpha.1.20512.1 -> To Version 9.0.1-alpha.1.20519.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

Co-authored-by: Jan Vorlicek janvorli@microsoft.com

Co-authored-by: Jan Vorlicek janvorli@microsoft.com

In preparation to bring mono samples to dotnet/samples, files that are most likely to change will be packaged into a nuget package to be downloaded and consumed on the dotnet/samples end rather than mirroring changes.

This PR expands the process that created the NuGet package for Microsoft.NETCore.BrowserDebugHost.Transport to build a NuGet package for the Android sample.

Co-authored-by: Mitchell Hwang mitchell.hwang@microsoft.com

The on-device version of https://github.com/dotnet/runtime/pull/37585

Co-authored-by: Premek Vysoky premek.vysoky@microsoft.com Co-authored-by: Santiago Fernandez Madero safern@microsoft.com

Commit descriptions:

Corresponding PR to update SOS: https://github.com/dotnet/diagnostics/pull/1274 Fixes https://github.com/dotnet/runtime/issues/32020

At some point some Debug.Asserts/Fails were replaced by this NetEventSource.Fail helper, which both Debug.Fails and fires an EventSource event. But asserts in our code base are intended for things that should never happen, and we needn't be emitting events for them (if we did want to emit events for them, we'd need to tackle the other ~20,000 Debug.Assert/Fails in the codebase.

I've deleted NetEventSource.Fail, and fixed up the call sites. Some were simply replaced by Debug.Assert/Fail. Some were deleted entirely, when from code inspection it looked like they could actually be hit, but were guarded by a check for the event source being enabled and thus were unlikely to have been triggered in our previous testing. Etc.

Build fails with libjitinterface_armel.so and libclrjit_unix_armel_x64.so was not found after #41126.

Signed-off-by: Timur t.mustafin@partner.samsung.com

Fix last issues preventing the Pri0 tests from passing under crossgen2 for arm and x86

Also enable testing targetting x86 and arm

Avoid emitting LLVM intrinsics which are not not enabled since it would cause llc to fail.

Switch back to the old command-line parser for Crossgen2 to improve performance of parsing arguments.

For some reason, Task.Delay(TimeSpan, ...) and CancellationTokenSource.CancelAfter(TimeSpan) cut off the max allowed timeout at int.MaxValue milliseconds, whereas Timer's TimeSpan support (which is used under the covers) goes all the way to UInt32.MaxValue - 2. This changes Task/CancellationTokenSource to match, effectively doubling the allowed length of the timeouts.

Co-authored-by: Jan Kotas jkotas@microsoft.com

This script label and code was removed in a previous change even though it is still required. Bring it back.

Change #42848 altered comments to print numbers in comments in little-endian format, but went too far and changed two places that print out numbers outside of comments that are later parsed by ilasm in round-trip testing.

Fixes #43672

Fixes https://github.com/dotnet/runtime/issues/35674.

Co-authored-by: Aleksey Kliger (λgeek) akliger@gmail.com

Co-authored-by: Aleksey Kliger (λgeek) akliger@gmail.com

Co-authored-by: Sunguoyun sunguoyun@loongson.cn

There are some environments (checked CoreCLR, no tiered compilation) where the current timeout is insufficient. Increasing the timeout so the tests don't fail in these environments.

Fix #43389

Backport from dotnet/runtimelab:NativeAOT

Signature mismatches cause errors on some platforms like wasm.

The rewriter defined two extra opcodes, CEE_COUNT and CEE_SWITCH_ARG, but does not define them in the k_rgnStackPushes array. This can cause out-of-bounds reads when computing the value of maxstack.

CLion creates a directory named ".idea" as a sibling to the top-level CMakeLists.txt that describes the project; with src/mono, git clean -dXf will delete src/mono/.idea because ".idea/" is an ignored pattern in .gitignore.

One workaround is to create an out-of-tree CMakeLists.txt that contains nothing but add_directory(relative/path/to/src/mono), but this changes the value of CMAKE_SOURCE_DIR to something other than what our CMake build files expect.

wasm sample to use publish.

In my refactoring of NegotiateStream to use async/await, I broke its handling of EOF, with it throwing an exception instead of returning 0. This fixes it to correctly handle EOF.

[master] Update dependencies from mono/linker

Co-authored-by: Stephen Toub stoub@microsoft.com

Co-authored-by: Stephen Toub stoub@microsoft.com

Fix #33259

Co-authored-by: Stephen Toub stoub@microsoft.com

Co-authored-by: Stephen Toub stoub@microsoft.com

See the Justification for each of the added suppressions.

Also annotate GetMethodBody as potentially dangerous with trimming. Trimming can change IL of a method (can remove branches, remove local variables, change some isntructions, ...) - as such accessing the actual body of a method is potentially dangerous.

Co-authored-by: Nikolay-parhimovich <>

JSON configuration files must have an object as the root element. Previously, the exception message produced by Microsoft.Extensions.Configuration.Json.JsonConfigurationFileParser when a non-object root element was parsed was Error: Unsupported JSON token 'TOKEN_TYPE' was found. This error message was vague and caused confusion. This commit updates the error message to specifically mention that the root element must be an object.

Fix dotnet/extensions#3543.

Co-authored-by: Stephen Toub stoub@microsoft.com

Building full AOT using CI scripts won't work when VS2019 IDE is present (not falling back to VS2019 build tools).

This happens due to a typo in setup-vs-msvcbuild-env.bat. Since CI doesn't install VS IDE, but using buildtools (where clan bin path is added to PATH) problem only shows up on local development environment using VS2019 IDE.

Co-authored-by: lateralusX lateralusX@users.noreply.github.com

Co-authored-by: HuyLuong huy.luong@orientsoftware.com

When the destination IP on the packet doesn't match any WireGuard peer (such as if the peer is disconnected while the app is running), the sender may get an ENOKEY errno.

This is mentioned in Section 3 "Send/Receive" of https://www.wireguard.com/papers/wireguard.pdf

Fixes https://github.com/mono/mono/issues/20503

Co-authored-by: lambdageek lambdageek@users.noreply.github.com

Co-authored-by: Stephen Toub stoub@microsoft.com

Co-authored-by: Stephen Toub stoub@microsoft.com

Co-authored-by: Marie Píchová 11718369+ManickaP@users.noreply.github.com

Co-authored-by: Angelo Breuer 46497296+angelobreuer@users.noreply.github.com Co-authored-by: Marie Píchová 11718369+ManickaP@users.noreply.github.com

The samples are often used for debugging runtime problems by modifying the code to reproduce issues. The code analyzers and warnings-as-errors add a papercut before a modified sample can run.

allow MONO_CONFIG and MONO_ENV_OPTIONS to be set from the outside

We send assembly loaded events to the proxy based off events from the debugger engine. And we check that it isn't an assembly that was already loaded. This check has a bug in computing the assembly name, from the filename, which caused these events to be sent even for already loaded assemblies.

The upstream instrumentation runners don't use runOnMainSync() in the onStart() method, update our runner to do the same and add a bit more logging.

Also fixed a small typo in configure.cmake that I happened to notice.

[master] Update dependencies from dotnet/arcade Microsoft/vstest dotnet/llvm-project dotnet/runtime-assets mono/linker

Fix #42686 by doing a graceful close in case if the abortive connect(AF_UNSPEC) call fails on Linux, and improve couple of related tests:

Removes the exception handling at CLRPrivBinderCoreCLR::BindAssemblyByName so that the inner exceptioncan be set when the default AssemblyLoadContext.Resolving handler throws

L.A.Noire splash screen calls it to check if the game has opened its window, and stays forever visible if this is not implemented.

Co-authored-by: rbernon rbernon@users.noreply.github.com

This change:

  1. Simplified if checks.
  2. Use expression property syntax.
  3. Used using declaration.
  4. Inlined out declaration.
  5. Removed unwated unsafe modifier.
  6. Removed redundant casting.

Add AddressFamily-specific name resolution and cancellation support for Windows. Resolves #939

Use VerifierCorElementType instead of SignatureCorElementType to specify the element type of the target field

In (non-palsuite) product code, _wcslwr is only used within PAL inside _wcslwr_unsafe() method, which is exposed as _wcslwr_s for PAL consumers. PR inlines the usage of _wcslwr in _wcslwr_unsafe and fixes up PAL tests.

Before this change, an InterpFrame contained 3 regions of data : args + locals, valuetype stack, execution stack. Each entry on the execution stack was a stackval structure. The space for valuetypes, was allocated separately, since they have various sizes. When pushing a valuetype on the stack, we allocated first the space for it on the vtstack and then pushed the address of the region on the execution stack. This change merges the execution stack with the valuetype stack, meaning we push now variable sized data on the execution stack. In order to keep track of the current stack location, whenever we push a type on stack, during transform phase, we also keep track of the offset where this value will reside on stack, as well as the size it occupies. All callsites need to be informed how much they need to pop the stack for the arguments. While called code can access this space normally (the args are special locals belonging to the frame and are accessed directly as such), external code needs a new mechanism to detect each argument for a given frame. This is achieved with the lazily initialized arg_offsets array on an InterpMethod. The method doesn't need to be compiled for this array to be correctly initialized.

Why :

Co-authored-by: BrzVlad BrzVlad@users.noreply.github.com

This reverts commit 3a4298cf15379678c4d437a6554a1453706cc3b3.

Propagate GTF_CALL if needed in GT_LIST. Use gtNewListNode. Ignore test for Mono

Co-authored-by: Eirik Tsarpalis eirik.tsarpalis@gmail.com

Co-authored-by: Eirik Tsarpalis eirik.tsarpalis@gmail.com

Rips out all of the APM code that was previously used to implement this and replaces it with {Value}Task-based async/await implementations.

Intrinsify BitOperations.PopCount for constant input

Fold "(X op C1) op C2" to "X op (C1 op C2)"

The return type validation was rejecting cases when the method being overriden had canon type in its generic arguments. This change fixes the problem by using parent method type instantiation for constructing the SigTypeContext in such case. It also adds a regression test.