In my change from the summer I added provisions to the type layout
check to support printing the differences as an aid for investigation
of this class of failures; I however put the diff display after the
assertion so that it actually doesn't get hit as the assertion tears
down the process. This change fixes the ordering and should let us
review the particular mismatch that occurs in the arm64 runs
(https://github.com/dotnet/runtime/issues/60036).
Thanks
Tomas
P.S. The change includes the instrumentation to unblock the
GenericsTest test that hits this issue to let me analyze the diff.
* [tests] Re-enable test
* [interp] Fix unboxing during CALLI
On interp we were storing function pointers as a simple InterpMethod. The problem is that, when loading an InterpMethod with a ldvirtftn opcode, the resulting method might need to have its this pointer unboxed, so this information needs to be embedded into the function pointer. We achieve this by tagging the InterpMethod whether we need to perform unboxing as part of calling it.
* Updated channel passed to ci_setup in the performance-setup.sh file.
* Removed spaces from assignments so they are seen as actual variabls, and tested locally.
- Improve assembly name acquisition in dotnet-pgo
- Use assembly name from AssemblyLoad event, and do not attempt to figure it out from the Module load event
- Collect MemoryRegionInfo for all method regions, not just the first.
- Add a concept to check a guid associated with the associated dll files to avoid data tearing
- Improve parsing of instantiated method signatures when reading an R2R file
- Handle the subtly different format which is use for type signatures in the InstantiationMethodSignature portion of an R2R file
* [mono][wasm] Add beginnings of support for WASI.
* Use mono_process_current_pid () instead of getpid ().
* Remove MONO_STRICT_IO_EMULATION option.
* Fix the build when eventpipe is disabled.
* Use HOST_BROWSER instead of HOST_WASM to protect emscripten only code.
Non-browser WS server used for ConnectAsync_Cancel_ThrowsCancellationException doesn't support "delay20sec", only "delay10sec". This basically reverts the change in this line from #58199 for non-browser platforms.
Contributes to #58355
* Unsafe pointers replaced with managed pointers
* Duplicate code replaced with static local
* Spannified internals
* Spannified compare
* Spannified div/rem operations
* Minus two array allocations for each bitwise operation
* Removed redundant locals
* Code review feedback (code style)
* Code review feedback
* LeadingZeroes replaced with BitOperations
* stackalloc in Divide without remainder
* Reduced memory allocation for bitwise operations
* Managed pointer replaced with Span
* Removed namespace imports
* Removed delegate type
* Reduced memory allocation in the end of each bitwise operation
* Code review feedback
* Removed redundant array allocation
* Trivial division moved to stack alloc
* Reduced memory allocation for divide operator
* Reduced memory allocation for shift operations
* Array pooling for Square operation
* Fixed bound check for bitwise operations
* Multiply now uses array pooling
* Removed namespace import
* Reduced memory allocation for Add
* Removed swap of arguments
* Reduced memory allocations for multiply operator
* Reduced memory allocations for modulo operator
* Temporarily spannify ActualLength method
* Spannify FastReducer
* Spannify initial parts of GCD alg
* Simple GCD test for debugging
* Simple test for debugging
* Removed debug code
* Spannified GCD algorithm
* Removed arg passing by ref
* Complete migration of gcd to span
* Removed memory allocation for trivial case of GCD
* Reorganize utility code
* Removed redundant parameter
* Reduced memory alloc for trivial case of Pow alg
* Use span for trivial modulus pow case
* Use span for trivial cases of pow modulus
* Fixed buffer cleanup
* Reduced memory allocation of ModPow operations
* BitsBuffer replaced with span
* Reorganize utility methods
* Reduced visibility scope
* Removed temporary code for bits cleanup
* Fill leading bits with zeroes
* Unify order of parameters
* Unify order of parameters
* Unify order of parameters
* Reuse the same local var
* Removed whtespace
* Code review feedback
* Avoid misleading with Span.CopyTo
* Clarify purpose of slicing
Co-authored-by: Günther Foidl <[email protected]>
* Replace mentioning of uint[] in comments
* Fixed code formatting issues
* Share StackAllocThreshold const
* Ignore const threshold values in Release config
* Literal field cannot be discovered with TypeInfo.GetDeclaredField
* Removed invalid assertion
* Removed invalid assertion
* Removed invalid assertion
* Code review feedback
* Fixed header
* Fixed overflow of result buffer
* Reduced ctor visibility
* Eliminated bounds check
* Returned optimization using Math.DivRem
* Added braces to be consistent with other branches
* Fixed location of the comment
* Combine slice and conversion as the single line
* Combine slice and conversion as the single line
* Merge with parsing optimizations
* Reduced checks
* Removed redundant global const
* Replaced magic consts with their named equivalents
* Removed useless asserts
* Manual merge with #53984 PR
* Review feedback (use const for stackalloc)
* Review feedback
* Unsafe code replaced with span indexer where possible
* Removed unused local
* Review feedback
Co-authored-by: Günther Foidl <[email protected]>
* Add support for cloning loops with `<=` conditions
Loop cloning currently only handles loops using `<` limit comparison,
e.g., in loops like `for (i = c; i < n; i++)`. This change allows
for loop cloning for loops using `<=`. This happens frequently in the BenchF
benchmarks (which maybe had their origin long ago in 1-based array Fortran code?),
and some in the BenchI benchmarks. In real world code, it happens
in Visual Basic code.
There are perf wins and losses, with the usual existing issues for loop cloning.
For one case, BenchI.XPosMatrix, I see a loss due to various things, including:
1. Unfortunate register allocation and/or missing copy prop, leading to lots of
unnecessary copies.
2. Hitting jcc erratum
3. CSE leads to un-contained array length load in array bounds check
Even so, there is one fewer bounds check than the baseline. We could remove one more,
but a limitation in recognizing multi-dimensional jagged array components prevents loop
cloning from recognizing a legal-to-remove bounds check (https://github.com/dotnet/runtime/issues/54074).
* Handle aborting from loop cloning for statically false conditions
This change activated existing unused code that statically determined
a loop choice condition was false, leading to aborting the loop
cloning (and at runtime to an almost certain exception). (The test
case was `for (i = 1; i <= a.Length; i++) { a[i] = 1; }`)
If any choice condition is false, we shouldn't also check if all conditions
are true (that value is unreliable in this case).
There are no SPMI asm diffs from this change.
* Check BackgroundService.ExecuteTask for null
In some scenarios, derived classes might not have called base.StartAsync, and ExecuteTask will still be null. Ensure we don't fail in those cases.
Fix#60131
* Set call return type in fgMorphIntoHelperCall
It was just forgotten.
* Introduce IntegralRange::ForNode
* Use Range::ForNode in assertion propagation
Couple good diffs from the handling of GT_CALL.
* Fix IntegralRange::ForCastInput
The comments are right, the code is wrong...
Fortunately, the bug was a pessimizing one, not a correctness issue.
* Use IntegralRange in fgOptimizeCast
And reap the benefits.
We assume that we can use half the free list space in gen 0 for new allocation. If that is too optimistic, we may allocate into decommitted memory and crash in the allocator. That is because there is a race condition between the allocating thread and the decommitting thread - we decided to avoid that by making sure we would never decommit memory that we may allocate in gen 0.
There are two reasons why assuming we can use half the free list space for new allocations may be too optimistic:
- if we allocate large objects in gen 0, we may not have free spaces of the necessary size available.
- when background GC goes into background_ephemeral_sweep, it deletes and rebuilds the free list for gen 0. A thread trying to allocate during that time may see a completely empty free list.
Currently the total code bytes shown for the base/diff is misleading
when SPMI is used because SPMI generates only .dasm files for method
contexts with diffs. This change:
* Adds -baseMetricsSummary and -diffMetricsSummary to SPMI, which
specifies a file path to output metrics. Currently that's just the
number of failing/succeeding compiles, and the total number of code
bytes, but the hope is to use this for other metrics as well.
* Adds --override-total-base-metric and --override-total-diff-metric to
jit-analyze, to support overriding the computed total base and total
diff metric, since they are misleading when .dasm files are only
created for differences
* Supports this from the superpmi.py wrapper script for asmdiffs when no
explicit metric is provided: in this case, the script will get the
metrics from SPMI and pass them to jit-analyze to override the
computed totals.
The net result is that the displayed results from jit-analyze after SPMI
runs are less misleading and should be more comparable to similar PMI
runs.
Parker Bibus pinged me earlier today to report a bug caused by my
test cleanup - using generatelayoutonly without previously
building the managed tests ends up failing the build due to
unrestored packages. This was due to the fact that I overlooked
that CopyDependenciesToCoreRoot needs the support projects to be
restored; in usual scenarios, they usually got restored as part
of another build step like managed test build so that I didn't hit
that in my local and lab testing.
Thanks
Tomas
* Creating a test case for PR https://github.com/dotnet/runtime/pull/59773
But I'm not using Uint8Array to set the content on memory allocated using malloc as @lewing suggested in the same PR.
* add lines in the eof
* Change the function that allocate memory.
* adding comment as suggested by @kg
* Accepting @lewing suggestion
* Make GenTreeField a unary op
There is no reason for it to be a GTK_SPECIAL op, a concept that
is needed only for nodes with special operand iteration semantics.
There is a quirk in this change, in gtCloneExpr, it is needed to
make this commit a zero-diff one (which it is).
* Remove the quirk
The old implementation of cloning for fields had
an interesting hidden pessimization in it: it set
GTF_GLOB_REF unnecessarily on the cloned tree, even
if the original tree did not have the flag.
This was because "gtNewFldRef", when passed "nullptr"
for the "FldObj", added the aforementioned GTF_GLOB_REF
to the node, presuming it was a static field access.
But we do not need to do that, and this commits removes
the quirk, getting some good diffs in the process.
* Remove dead code
- Delete unused GTF_NOP_DEATH.
- Delete dead code handling GT_INDEX_ADDR as a
GTK_SPECIAL node, it has always been GTK_BINOP.
- Remove the unused Compiler* parameter from GenTreeQmark's constructor.
- Remove the unused Compiler* parameter from LIR::Use::ReplaceWith,
ever so slightly improving its performance.
There are a handful of expected diffs with this change,
they are due to proper costing for INDEX_ADDR causing
fgMorphArgs to make slightly different decisions.
* Use more strong typing in GenTreeQmark
* Call the base constructor
MSVC apparently does not detect this :(.
* Merge src/tests/run.proj into src/tests/build.proj
In my previous change I modified the test-related scripts to always
use build.proj as the "front-end", the run.proj became something
like a targets file just used internally by build.proj. As both
MSBuild scripts are rather short and the boundary between test
building and running is rather blurred, I propose merging their
contents into the build.proj script and removing the run.proj
script to simplify developer navigation around the multitude of
test-related scripts.
Based on PR feedback I separated out those parts of the build
script that deal with emission of the XUnit wrappers to a separate
targets file "xunit-wrappers.targets". The expectation is that this
file can be removed once we refactor the XUnit wrapper logic
to more dynamic test grouping.
Thanks
Tomas
* Remove XML metadata per Santi's PR feedback
* Separate out xunit wrapper emitter into a new script
* Move the target CreateAllWrappers to xunit-wrappers.targers per Santi's PR feedback
* Support fast tailcalls in R2R
Partially addresses #5857
* Support ARM64
* Run jit-format
* Fix non-R2R ARM build
* Fix recursive-call-to-loop optimization with non-standard args
* Implement new delay load helper for fast tailcalls
* Minor changes and fix build break
* Switch to a define for tailcall register
* Fix x86
* Implement DefType.IsUnsafeValueType
* Emit rex.jmp for tailcall jumps on x64
* Refactor non standard args + refix recursive tailcall opt
* Set nonStandardArgKind for stack args also
* Regenerate JIT interface
* Improve recursion-to-loop decision about which args need to be reassigned
* Use INS_tail_i_jmp for func token indir
* More efficient arm64 VSD fast tailcalls, fix some bad merging
Also fix logic since we removed tailcall register. For ARM64 that means
we now use the single temp reg that is available for R2R/VSD calls, and
in LSRA we ensure this goes into a volatile register.
* Take R2R indirection into account for tail call profitability
On x64 an R2R indirected direct call normally disassembles the call site
to determine the indirection cell, so it is more expensive to do tail
calls in this scenario as the indirection cell needs to be passed in a
register. Take this into account: if there is no tail. prefix, do normal
calls, and otherwise use tail calls.
* Disallow tailcalls via JIT helper in R2R builds
* Revert "Take R2R indirection into account for tail call profitability"
This reverts commit 863ad4d344bcdacebb00c8c921c7345fd63c7d7b.
Let's not divert on the behavior here. It is not clear that having a
smaller call site is better than tail calling albeit with a larger call
site.
* Add SPMI support, clean up mcPackets enum
* Take necessary conditions into account in canTailCall
Do not do implicit tailcalls when
* The caller is the entry point
* The caller is marked NoInline
* The callee requires security object
Add an option, statically determined at compile time,
to generate loop cloning loop choice conditions into one block
per condition instead of using bitwise `and` operators that
execute all non-dependent conditions in a single block. Set the
condition to use the one-block-per-condition mode.
This leads to code size reduction in the generated condition code,
generally performance improvements in the microbenchmarks,
as well as making it easier to understand.