Skip to content

Commit

Permalink
compiler-services renam
Browse files Browse the repository at this point in the history
  • Loading branch information
bfarmer67 committed Dec 14, 2024
1 parent 8b00f42 commit 1ca53c6
Show file tree
Hide file tree
Showing 26 changed files with 56 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/Hyperbee.Expressions/AsyncBlockExpression.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq.Expressions;
using Hyperbee.Expressions.Transformation;
using Hyperbee.Expressions.CompilerServices;

namespace Hyperbee.Expressions;

Expand Down
2 changes: 1 addition & 1 deletion src/Hyperbee.Expressions/AwaitExpression.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics;
using System.Linq.Expressions;
using Hyperbee.Expressions.Transformation;
using Hyperbee.Expressions.CompilerServices;

namespace Hyperbee.Expressions;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;

namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

internal delegate TAwaiter AwaitBinderGetAwaiterDelegate<TAwaitable, out TAwaiter>( ref TAwaitable awaitable, bool configureAwait );
internal delegate TResult AwaitBinderGetResultDelegate<TAwaiter, out TResult>( ref TAwaiter awaiter );
Expand Down Expand Up @@ -155,4 +155,9 @@ internal TResult GetResult<TAwaiter, TResult>( ref TAwaiter awaiter )

return result;
}

public override string ToString()
{
return ".Binder";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Reflection.Emit;
using System.Runtime.CompilerServices;

namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

internal static class AwaitBinderFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using static System.Linq.Expressions.Expression;

namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

internal static class JumpTableBuilder
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

internal class LoweringException : Exception
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using Hyperbee.Expressions.Transformation.Transitions;
using Hyperbee.Expressions.CompilerServices.Transitions;
using Hyperbee.Expressions.Visitors;

namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

internal class LoweringVisitor : ExpressionVisitor
{
Expand Down Expand Up @@ -418,7 +418,7 @@ protected Expression VisitAwaitExtension( AwaitExpression node )
sourceState.StateId
);

var resumeLabel = Expression.Label( $"{joinState.NodeLabel.Name}_RESUME" );
var resumeLabel = Expression.Label( $"{sourceState.NodeLabel.Name}_RESUME" );

var awaitTransition = new AwaitTransition
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;

namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

public delegate bool MethodMatchDelegate( Type[] parameterTypes, int? argCount = null );

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using Hyperbee.Expressions.Transformation.Transitions;
using Hyperbee.Expressions.CompilerServices.Transitions;

namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

internal sealed class StateContext
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Runtime.CompilerServices;
using static System.Linq.Expressions.Expression;

namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

public interface IVoidResult; // Marker interface for void Task results
public delegate void MoveNextDelegate<in T>( T stateMachine ) where T : IAsyncStateMachine;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

using System.Linq.Expressions;

namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

internal sealed class StateMachineContext
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Diagnostics;
using System.Linq.Expressions;
using Hyperbee.Expressions.Transformation.Transitions;
using Hyperbee.Expressions.CompilerServices.Transitions;
using static System.Linq.Expressions.Expression;

namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

[DebuggerDisplay( "State = {NodeLabel?.Name,nq}, ScopeId = {ScopeId}, GroupId = {GroupId}, StateOrder = {StateOrder}, Transition = {Transition?.GetType().Name,nq}" )]
internal sealed class StateNode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using Hyperbee.Expressions.Transformation.Transitions;
using Hyperbee.Expressions.CompilerServices.Transitions;

namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

internal sealed class StateOptimizer
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Linq.Expressions;

namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

internal sealed class StateResult
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using static System.Linq.Expressions.Expression;

namespace Hyperbee.Expressions.Transformation.Transitions;
namespace Hyperbee.Expressions.CompilerServices.Transitions;

internal class AwaitTransition : Transition
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using static System.Linq.Expressions.Expression;

namespace Hyperbee.Expressions.Transformation.Transitions;
namespace Hyperbee.Expressions.CompilerServices.Transitions;

internal class ConditionalTransition : Transition
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using static System.Linq.Expressions.Expression;

namespace Hyperbee.Expressions.Transformation.Transitions;
namespace Hyperbee.Expressions.CompilerServices.Transitions;

internal class FinalTransition : Transition
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Linq.Expressions;

namespace Hyperbee.Expressions.Transformation.Transitions;
namespace Hyperbee.Expressions.CompilerServices.Transitions;

internal class GotoTransition : Transition
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Linq.Expressions;

namespace Hyperbee.Expressions.Transformation.Transitions;
namespace Hyperbee.Expressions.CompilerServices.Transitions;

internal class LoopTransition : Transition
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using static System.Linq.Expressions.Expression;

namespace Hyperbee.Expressions.Transformation.Transitions;
namespace Hyperbee.Expressions.CompilerServices.Transitions;

internal class SwitchTransition : Transition
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Linq.Expressions;
using static System.Linq.Expressions.Expression;

namespace Hyperbee.Expressions.Transformation.Transitions;
namespace Hyperbee.Expressions.CompilerServices.Transitions;

[DebuggerDisplay( "Transition = {GetType().Name,nq}" )]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using static System.Linq.Expressions.Expression;

namespace Hyperbee.Expressions.Transformation.Transitions;
namespace Hyperbee.Expressions.CompilerServices.Transitions;

internal class TryCatchTransition : Transition
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Runtime.CompilerServices;
using static System.Linq.Expressions.Expression;

namespace Hyperbee.Expressions.Transformation;
namespace Hyperbee.Expressions.CompilerServices;

internal sealed class VariableResolver : ExpressionVisitor
{
Expand Down
19 changes: 14 additions & 5 deletions test/Hyperbee.Expressions.Benchmark/AsyncBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,10 @@ public void Setup()
_preRunFastCompiled = _lambda.CompileFast();
_preRunNextCompiled = _nextlambda.Compile();

_coldRunCompiled = _lambda.Compile();
_coldRunFastCompiled = _lambda.CompileFast();
_coldRunNextCompiled = _nextlambda.Compile();

//_preRunFastNextCompiled = _nextlambda.CompileFast();
//_coldRunNextFastCompiled = _nextlambda.CompileFast();

Warmup( _preRunCompiled, _preRunFastCompiled, _preRunNextCompiled );

return;

// Helpers
Expand All @@ -96,6 +92,19 @@ void Warmup( params Func<Task<int>>[] funcs )
}
}

[IterationSetup( Targets = [
nameof(Hyperbee_AsyncBlock_FirstExecute),
nameof(Hyperbee_AsyncBlock_FirstFastExecute),
nameof(DotNext_AsyncLambda_FirstExecute)
] ) ]
public void IterationSetup()
{
_coldRunCompiled = _lambda.Compile();
_coldRunFastCompiled = _lambda.CompileFast();
_coldRunNextCompiled = _nextlambda.Compile();
//_coldRunNextFastCompiled = _nextlambda.CompileFast();
}

// Compile

[BenchmarkCategory( "Compile" )]
Expand Down
14 changes: 8 additions & 6 deletions test/Hyperbee.Expressions.Tests/BlockAsyncBasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public async Task BlockAsync_ShouldAwaitMultipleTasks_WithDifferentResults( Comp
// Arrange
var block = BlockAsync(
Await( AsyncHelper.Completer(
Constant( completer ),
Constant( 1 )
) ),
Constant( completer ),
Constant( 1 )
) ),
Await( AsyncHelper.Completer(
Constant( completer ),
Constant( 2 )
) )
Constant( completer ),
Constant( 2 )
) )
);

var lambda = Lambda<Func<Task<int>>>( block );
Expand All @@ -114,6 +114,7 @@ public async Task BlockAsync_ShouldThrowException_WithFaultedTask()
var block = BlockAsync(
Await( Constant( Task.FromException<int>( new InvalidOperationException( "Test Exception" ) ) ) )
);

var lambda = Lambda<Func<Task<int>>>( block );
var compiledLambda = lambda.Compile();

Expand Down Expand Up @@ -153,6 +154,7 @@ public async Task BlockAsync_ShouldAwaitNestedBlockAsync_WithNestedTasks( Comple
Await( AsyncHelper.Completer( Constant( completer ), Constant( 1 ) ) ),
Await( innerBlock )
);

var lambda = Lambda<Func<Task<int>>>( block );
var compiledLambda = lambda.Compile( compiler );

Expand Down
2 changes: 1 addition & 1 deletion test/Hyperbee.Expressions.Tests/Compiler/CompilerTests2.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using Hyperbee.Expressions.Tests.TestSupport;
using Hyperbee.Expressions.Transformation;
using Hyperbee.Expressions.CompilerServices;
using static System.Linq.Expressions.Expression;
using static Hyperbee.Expressions.ExpressionExtensions;

Expand Down

0 comments on commit 1ca53c6

Please sign in to comment.