This repository has been archived by the owner on Nov 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 318
ILEmit backend for DependencyInjeciton #630
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f89905c
Add ILEmit backend
pakrym ebeda60
More things
pakrym 4b02a45
Some optimizations and method size detection experiment
pakrym 88343a9
Cross compile and disabled tests
pakrym dbc1ad5
Test more for RELEASE
pakrym 75681af
Better name
pakrym 1665d80
Cross complile to app2.0 and add more tests
pakrym 294ca9d
Undo perf multi targeting
pakrym 2381852
PR comments
pakrym bec355c
More PR Comments
pakrym File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace Microsoft.Extensions.DependencyInjection.ServiceLookup | ||
{ | ||
internal enum CallSiteKind | ||
{ | ||
Factory, | ||
|
||
Constructor, | ||
|
||
Constant, | ||
|
||
IEnumerable, | ||
|
||
ServiceProvider, | ||
|
||
Scope, | ||
|
||
Transient, | ||
|
||
CreateInstance, | ||
|
||
ServiceScopeFactory, | ||
|
||
Singleton | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,6 @@ public ConstantCallSite(Type serviceType, object defaultValue) | |
|
||
public Type ServiceType => DefaultValue.GetType(); | ||
public Type ImplementationType => DefaultValue.GetType(); | ||
public CallSiteKind Kind { get; } = CallSiteKind.Constant; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. public CallSiteKind Kind => CallSiteKind.Constant; Why do you want a backing field? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So JIT can do it's JITty stuff |
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/DI/ServiceLookup/Expressions/ExpressionsServiceProviderEngine.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.Extensions.DependencyInjection.ServiceLookup | ||
{ | ||
internal class ExpressionsServiceProviderEngine : ServiceProviderEngine | ||
{ | ||
private readonly ExpressionResolverBuilder _expressionResolverBuilder; | ||
public ExpressionsServiceProviderEngine(IEnumerable<ServiceDescriptor> serviceDescriptors, IServiceProviderEngineCallback callback) : base(serviceDescriptors, callback) | ||
{ | ||
_expressionResolverBuilder = new ExpressionResolverBuilder(RuntimeResolver, this, Root); | ||
} | ||
|
||
protected override Func<ServiceProviderEngineScope, object> RealizeService(IServiceCallSite callSite) | ||
{ | ||
var realizedService = _expressionResolverBuilder.Build(callSite); | ||
RealizedServices[callSite.ServiceType] = realizedService; | ||
return realizedService; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,7 @@ public FactoryCallSite(Type serviceType, Func<IServiceProvider, object> factory) | |
|
||
public Type ServiceType { get; } | ||
public Type ImplementationType => null; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Remove space |
||
public CallSiteKind Kind { get; } = CallSiteKind.Factory; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/DI/ServiceLookup/ILEmit/ILEmitCallSiteAnalysisResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.Extensions.DependencyInjection.ServiceLookup | ||
{ | ||
internal readonly struct ILEmitCallSiteAnalysisResult | ||
{ | ||
public ILEmitCallSiteAnalysisResult(int size) : this() | ||
{ | ||
Size = size; | ||
} | ||
|
||
public ILEmitCallSiteAnalysisResult(int size, bool hasScope) | ||
{ | ||
Size = size; | ||
HasScope = hasScope; | ||
} | ||
|
||
public readonly int Size; | ||
|
||
public readonly bool HasScope; | ||
|
||
public ILEmitCallSiteAnalysisResult Add(in ILEmitCallSiteAnalysisResult other) => | ||
new ILEmitCallSiteAnalysisResult(Size + other.Size, HasScope | other.HasScope); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PranavPoints++