Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NativeAOT-LLVM: Nativeaot merge and add instrinsic for EETypePtr<> #610

Merged
merged 306 commits into from
Jan 31, 2021

Conversation

yowl
Copy link
Contributor

@yowl yowl commented Jan 31, 2021

This PR merges in NativeAOT and address the change from #577 , making EETypePtr an intrinsic. Also adds a stub for Thread.UnsafeStart(object parameter)

dotnet-maestro bot and others added 30 commits January 13, 2021 14:38
Microsoft.NET.ILLink.Tasks
 From Version 6.0.0-alpha.1.21061.5 -> To Version 6.0.0-alpha.1.21063.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
I've analyzed all of nativeaot SDK libraries for trimming. Except for things that are already known in dotnet/runtime, we don't have warnings anymore after this.

(For future reference - to analyze trim safety of a library, one just need to compile the library in the `--multifile` mode and enable `--scanreflection`. This makes sure all code in the library is looked at.)
Just an unnecessary allocation.  The AsnEncodedData ctor makes a copy regardless of whether the input is a span or an array, so may as well avoid allocating another array on top of that.
RyuJIT can do an extra optimization here.
…ts dotnet/llvm-project dotnet/icu (#46853)

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

Follow up change missing in #46323

Fixes #46908
…692)

* Adding support for ReciprocalEstimate and ReciprocalSqrtEstimate

* Adding basic documentation comments to the new Math.ReciprocalEstimate functions

* Increasing the epsilon for estimated functions to account for ARM64 only doing a single Newton-Raphson iteration
* Set official build value to false

* Add pr trigger

* Remove PR
* Enable host tests on OSX

* initialize Ssl shim on demand

* fix OpenSsl.Tests

* partial modifier

* fixed Cryptography.Algorithms

* first to dlopen libssl wins
… code (#44987)

* [wasm][debugger] Move DevToolsQueue to a separate file

* Move Inspector to separate file, mv Support.cs=>DebuggerTest.cs

* [wasm][debugger][tests] Some improvements to DevToolsQueue

- `Pump` -> `TryPump`
- use a ConcurrentQueue instead of a List, for tracking the pending
requests.

DevToolsClient:
- use DevToolsQueue, and remove the redundant code.
- Wake up the runloop when a new send task gets added

* [wasm][debugger] Check Proxy's client_initiated_close early

- this allows the proxy to shutdown quicker, and not have to wait for
the other tasks to get scheduled.

- Fixes the issue of chrome processes left around.

* [wasm][debugger][tests] Inspector - handle event being received before a waiter

.. gets added.

This handles the case where `NotifyOf` gets invoked before a
corresponding `WaitFor` gets called.

* [wasm][debugger][tests] Refactor test harness to support simpler test code

Problem:

- Currently, test methods must call `insp.Ready(..)` with a
callback. And `Ready` takes care of the init, and shutdown for
the proxy, and browser.

- But this means that we have to repeat that boiler plate code in all
the test methods. And the stack traces are deeply nested.

- Instead, we want to have the *test method* contain only the test
specific code.

Solution:

- we want to do that by using xunit's `IAsyncLifetime`, with
methods:
	- `InitializeAsync` - setup proxy+browser here
	- `DisposeAsync` - shutdown

- This would mean that when the *test method* runs, it already has
everything set up, so the code can be just specific to the actual test.

Implementation:

- Improve DevToolsClient's RunLoop, to support this
	- Tries to handle shutdown/close requests explicitly, and not throw
	errors in such cases

	- Adds a `RunLoopStopped` event, which gets invoked with the reason due
	to which it stopped. Eg - Exception getting thrown, cancellation,
	shutdown request etc.

	- With `insp.Ready(..)`, the whole setup (launch proxy, browser,
	run test code) happens from the same *test method*. But here we
	are doing it at separate times, from different methods, and it's
	all async.
		- IOW, there are multiple places where failure can
		happen, and we need to explicitly propogate that, and
		fail the appropriate listeners/tasks/etc
		-> causing the test to correctly fail.

Note: This does not change *any* actual test code! The `Ready` method is
adjusted to use the new init/shutdown bits.
Subsequent commits will make the test changes.

* [wasm][debugger][tests] Port some tests to the simpler test harness bits

We add a `SingleSessionTestBase` class, which implements
`IAsyncLifetime` to init/shutdown the proxy+browser outside the test
methods.

And port `HarnessTests`, and `SteppingTests` to that.

Added a few more tests to `HarnessTests`, to check for common cases like
test methods throwing exceptions, or timing out, or commands failing
etc.
	- This is needed because with the older `insp.Ready` API, the
	whole thing was called from the test method, so failures would
	correctly fail the test.

	- But now we do these things in separate steps, so failing the
	test requires a bit more work in the harness.

Note: I didn't port all the tests in one go, to make the review a bit
simpler. A subsequent PR can move rest of the tests over, and do some
cleanup that it would afford.

* [wasm][debugger][tests] Fix race in ExceptionThrownInJSOutOfBand test

Fix the race where the `Runtime.exceptionThrown` message can be received
before the test calls `WaitFor`, causing it to get missed.

* [wasm][debugger] Formatting fixes on the changes

* Remove unncessary AssertHelpers.ThrowsAsync

Suggested by @lewing !

* [wasm][debugger][tests] Fix a race when sending messages

DevToolsClient.Send adds to `pending_ops`, which can happen while the
list is being modified in `RunLoop`.

Fix: Since, we need to modify it outside `RunLoop` only when a new send
task is available, we can let `RunLoop` itself add it to the list. And use
a taskCompletionSource to wake up the loop.
Same problem as dotnet#552 in properties. Found by accident, but should have done the due dilligence in dotnet#552.
…ple (#45910)

* Enable AOT Profiler

* Add a `browser-profile` sample

* Clean up Makefile add AotInterp mode to MonoAotMode

* move the shared make logic to wasm.mk

Co-authored-by: Steve Pfister <steveisok@users.noreply.github.com>
Co-authored-by: Ankit Jain <radical@gmail.com>
* Rewrite ARM64 IJW bootstrap thunk.

* Fix alignment.
Phase 1 of replacing existing infrastructure around handling of pgo data with more flexible schema based approach.

The schema based approach allows the JIT to define the form of data needed for instrumentation.
- The schema associates 4 32bit integers with each data collection point (ILOffset, InstrumentationKind, Count, and Other)
  - Rich meaning is attached to InstrumentationKind, and Count
    - InstrumentationKind defines the size and layout of individual instrumentation data items
    - Count allows a single schema item to be repeated
  - ILOffset and Other are not processed in any specific way by the infrastructure

Changes part of this phase
- PgoManager holds arbitrary amount of pgo data instead of a slab
  - Aware of collectible assemblies
  - Match with pgo data utilizes hash of IL body in addition to IL size information for greater accuracy in match
- JIT no longer uses block count apis, and instead uses schema based apis
  - JIT now explicitly defines the shape of data collected for both basic block and type probes
  - The rest of the system handles that without deep knowledge of what those formats are
- Text file format for pgo data updated
- Existing IBC infrastructure adjusted to speak in terms of schema concept
- Uncompressed and binary encoded implementation of Pgo schema handling
- Update SuperPMI to handle new apis

Future Changes for static Pgo
- Move Pgo type handle histogram processing into JIT
- Extract Pgo data from process using Event infrastructure
- Triggers for controlling Pgo data extraction
- Instrumented Pgo processing as part of dotnet-pgo tool
- Pgo data flow in crossgen2
* extend the __LINKEDIT. section to cover the single-exe metadata.

* codesign test
…3.3 (#46937)

[master] Update dependencies from mono/linker
* Ignore data breakpoint during GC
* Simplify disabling DebuggerDataBreakpoint during GC
* Fix destroy pinned handle
* Fix CordbModule::IsMappedLayout  assert to allow using VS with debug/checked runtime builds

Co-authored-by: Chuck Ries <chuckr@microsoft.com>
…10113.1 (#46929)

[master] Update dependencies from dotnet/xharness
Normally, any JIT-EE GUID change would be accompanied by
a change in the JIT source code, so a JIT build would be
kicked off. But in some cases, such as a change in the
SuperPMI data format to cause an incompatible format, with
a manual change of the GUID to compensate, should also
kick off a JIT build so asmdiff baselines have a JIT
with an appropriate GUID.
* Add more sleeps after flush

* remove sleeps and add retry loop

* Fix build
* Prefer ucontext.h over sys/ucontext.h

* Cleanup redundant _XOPEN_SOURCE definitions

* Remove unused makefile from PAL tests
* Fix fragmenetation counter to not return NaN

* add regression test
davidwrighton and others added 28 commits January 25, 2021 18:21
* Debugging Crossgen2 documentation and such
- Also new --print-repro-instructions command line switch to crossgen2 as requested by the JIT team
Create a number of smaller files with cohesive sets of methods.
…cceptWebSocketAsync (#47402)

* Fix #46123 - make `subProtocol` nullable when dealing with WebSockets in HttpListener.

* Update ref for System.Net.HttpListener
* Fix for issue 46529
Move check for side-effect and don't push the cast for shifts of 32 to 63
Added test Runtime_46239.cs

* clang format
<!--
Thank you for your Pull Request!

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
-->

Co-authored-by: vargaz <vargaz@users.noreply.github.com>
When `libgdiplus` is installed via macports, `System.TypeInitializationException` exception is thrown.
This is because macports installs the library in `/opt/local/lib`.

```sh
$ port install libgdiplus
$ port contents libgdiplus
Port libgdiplus contains:
  /opt/local/lib/libgdiplus.0.dylib
  /opt/local/lib/libgdiplus.a
  /opt/local/lib/libgdiplus.dylib
  /opt/local/lib/pkgconfig/libgdiplus.pc
  /opt/local/share/doc/libgdiplus/AUTHORS
  /opt/local/share/doc/libgdiplus/COPYING
  /opt/local/share/doc/libgdiplus/ChangeLog
  /opt/local/share/doc/libgdiplus/LICENSE
  /opt/local/share/doc/libgdiplus/NEWS
  /opt/local/share/doc/libgdiplus/README.md
  /opt/local/share/doc/libgdiplus/TODO
```

PR adds `/opt/local/lib/libgdiplus.dylib` as a well-known probing path.
* [wasm] Handle Top-Level style entry point mangling too

This adds a check for '<Main>$' in addition to 'Main' when
looking for the async entry point.

Fixes #47404
* Performance tuning Xoshiro pseudo random number generators. Move PRNG state from the heap onto the stack before performong PRNG generation and mxing operations.

* Declare PRNG state method variables on single line (code review feedback nit).
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Use a separate thread for tiered compilation background work

- Makes it easier to manage how much time is spend for performing background work like rejitting and allows yielding more frequently with just Sleep without incurring thread pool overhead, which is useful in CPU-limited cases
- A min/max range is determined for how long background work will be done before yielding the thread. The max is the same as before, 50 ms. For now the min is `processor count` ms (capped to the max), such that in CPU-limited cases the thread would yield more frequently in order to not monopolize too much of the limited CPU resources for background work, and in cases with a larger number of processors where the background work is typically less intrusive to foreground work it would yield less frequently.
- At the same time, progress should be made on background work such that steady-state perf would be reached in reasonable time. Yielding too frequently can slow down the background work too much. The sleep duration is measured to identify oversubscribed situations to yield less frequently and make faster progress on the background work.
- Due to less time spent rejitting in some CPU-limited cases, steady-state performance may be reached a bit later in favor of fewer spikes along the way
- When the portable thread pool is enabled, a side effect of using a managed worker thread for tiering background work was that several GC-heavy microbenchmarks regressed. Tiering was the only thing using the thread pool in those tests and stack-walking the managed thread was slower due to the presence of GC refs. It's not too concerning, the benchmarks are just measuring something different from before, but in any case this change also resolves that issue. Fixes dotnet/runtime#44211.
Force the reflection-only code paths that don't Reflection.Emit.
* Support cross-architecture compilation in ILC
* Fix paths for CMake and build.sh
* Fix slashes in #include's path
* Replace 'git restore' with 'git checkout'
* Use 'exit /b 1' consistently in build.cmd
…tnet#594)

This required beefing up the illink-based one a little:

* Attempt to instantiate generic things. This matches the behavior of the old scanner that was able to make `typeof(SomeType<>).MakeGenericType(otherType).GetMethod("Foo")` work for reference-type `otherType`. This is a heuristic. `MakeGenericType` just needs to warn as being unsafe.
* Recognize `Enum.GetValues` and `Marshal.SizeOf`. As a bonus, this hooks into the flow analysis infra, so we can potentially figure out more use cases. As another bonus, there's now a warning.
* Detect when Type.GetType resolved things through a forwarder and add the forwarder metadata.


Lost features:
* We no longer do the optimization for `typeof(T) == typeof(Foo)` that was trying to avoid seeing `Foo` as constructed (with a fully populated vtable). This can be added later; I'm leaving the compiler infra inplace.
* Ability to run the scanner to only scan for interop pattern.
These were ifdeffed out for UAPAOT in the past. The rest of the UAPAOT ifdefs seem to be dealing with with the pregenerated serialization code that .NET Native creates and are not relevant for NativeAOT.
…NativeAOT-LLVM

# Conflicts:
#	eng/Subsets.props
#	src/coreclr/CMakeLists.txt
#	src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj
#	src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj
#	src/libraries/Native/Unix/System.Globalization.Native/CMakeLists.txt
EETypePtr as intrinsic
UnsafeStart(object parameter) placeholder
@jkotas jkotas merged commit b28a312 into dotnet:feature/NativeAOT-LLVM Jan 31, 2021
@yowl yowl deleted the nativeaot-merge branch January 31, 2021 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.