Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Add IL scanner phase - #3503

Merged
MichalStrehovsky merged 14 commits into
dotnet:masterfrom
MichalStrehovsky:scanner
May 15, 2017
Merged

MichalStrehovsky merged 14 commits into
dotnet:masterfrom
MichalStrehovsky:scanner

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Sending this out to give people a chance to give early feedback.

This adds an initial (empty) implementation of an IL scanner that will scan method bodies, starting from the provided compilation roots, and expand the dependency graph based on scanning the IL, to determine the set of methods (and types, and other interesting artifacts) that will be compiled.

This nicely plugs into the existing architecture where the scanner looks almost just like another codegen backend - we have a separate NodeFactory for it, a separate builder class, and a separate compilation class. The actual IL parsing reuses the importer written for CppCodegen and ILVerifier.

The results of the scanning phase will flow into the metadata generator and potentially other parts of the system.

Having the compilation builder create the scanner builder is a bit
weird, but scanners will potentially need to be customized for various
backends and it seems better than making the user exposed to selecting
name mangling schemes.
@MichalStrehovsky MichalStrehovsky changed the title [WIP] Add IL scanner phase Add IL scanner phase May 13, 2017
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

Dropping the WIP tag. I still see a couple diffs when comparing to RyuJIT, but at least some of them are caused by #3608 that I'll need to go fix. Let's review this.

@davidwrighton @nattress @jkotas?

private DependencyAnalyzerBase<NodeFactory> CreateDependencyGraph(NodeFactory factory)
{
// Choose which dependency graph implementation to use based on the amount of logging requested.
switch (_dependencyTrackingLevel)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicated from CompilationBuilder. Refactor to a static helper that takes _dependencyTrackingLevel as an argument?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, fixed.

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

@kouvel @AntonLapounov @sergiy-k The Ubuntu Debug assertion might be unrelated. There's very little code in this pull request that actually runs (pretty much only the small refactorings to RyuJit*.cs and CppCodegen*.cs are live code). I don't want to ask dotnet-bot to retests this just yet in case there's some artifacts that could be salvaged.

Running test src/Simple/BasicThreading BasicThreading
FinalizeTest passed
Unhandled Exception: System.Diagnostics.Debug+DebugAssertException: 

   at BasicThreading!<BaseAddress>+0x549e86
   at BasicThreading!<BaseAddress>+0x540dd0
   at BasicThreading!<BaseAddress>+0x533752
   at System.Threading.WaitSubsystem.WaitableObject.get_IsSignaled()
   at System.Threading.WaitSubsystem.WaitableObject.SignalAutoResetEvent()
   at System.Threading.WaitSubsystem.WaitableObject.SignalEvent()
   at BasicThreading!<BaseAddress>+0x5b5fab
   at System.Threading.EventWaitHandle.SetCore(IntPtr handle)
   at System.Threading.EventWaitHandle.Set()
   at System.Threading.Lock.ReleaseContended()
   at System.Threading.Lock.ReleaseCore()
   at System.Threading.Lock.Release()
   at BasicThreading!<BaseAddress>+0x54676b
   at BasicThreading!<BaseAddress>+0x555d28
   at BasicThreading!<BaseAddress>+0x57972f
   at BasicThreading!<BaseAddress>+0x55da4d
   at BasicThreading!<BaseAddress>+0x550c74
   at ThreadStaticsTestWithTasks.<>c.<Run>b__2_0(Object param)
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
   at BasicThreading!<BaseAddress>+0x722e3e
   at System.Threading.ExecutionContext.Run(Threading.ExecutionContext executionContext, Threading.ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Threading.Tasks.Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at BasicThreading!<BaseAddress>+0x74f32d
src/Simple/BasicThreading/BasicThreading.sh: line 2: 26030 Aborted                 (core dumped) $1/$2
fail

@davidwrighton

Copy link
Copy Markdown
Member

Looks good. I dislike that we can only have one variant of the ilscanner per binary due to the partial class implementation sharing, and we may wish to have more implementations of this thing in the future, but that's not an issue which I'd like to see you fix at this time. (Its fixable with no/negligible perf loss by going enthusiastic with generics and constraints, but I'm not sure I want to propose that.)

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

I dislike that we can only have one variant of the ilscanner per binary due to the partial class implementation sharing

Yes, I spent a couple hours trying to find a scheme where we could share the importer differently, but ended up kicking CppCodegen out of this assembly instead (#3468) - because as you noted, we had a need to have the importer in both, and I didn't want us to pay the perf penalty.

We might be able to come up with a scheme where we make the scanner itself shareable (because most parts of the scanner-specific importer are boring).

@kouvel

kouvel commented May 15, 2017

Copy link
Copy Markdown
Contributor

The Ubuntu Debug assertion might be unrelated. There's very little code in this pull request that actually runs (pretty much only the small refactorings to RyuJit*.cs and CppCodegen*.cs are live code). I don't want to ask dotnet-bot to retests this just yet in case there's some artifacts that could be salvaged.

I don't see a link to a dump in the build output, and I couldn't find a dump on dumpling corresponding to this failure based on the build time. There's probably not much else in the build output that would be useful. Would need to try to repro this or figure it out from the stack trace.

@MichalStrehovsky
MichalStrehovsky merged commit 85d38d5 into dotnet:master May 15, 2017
@MichalStrehovsky
MichalStrehovsky deleted the scanner branch May 15, 2017 21:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants