Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3133c5f
working on failures
dadhi May 6, 2025
028b813
nice
dadhi May 6, 2025
130af98
add DevMode to speedup bt.bat and b.bat and dev builds
dadhi May 6, 2025
6945b5a
nicier test output
dadhi May 6, 2025
5f86416
counting the interpretations
dadhi May 6, 2025
096744a
trying to understand why #468 and #472 were not tracked by interprete…
dadhi May 6, 2025
663f2c3
@wip ArithmeticResult #472
dadhi May 6, 2025
24b5d0f
boxing with boxing #472
dadhi May 6, 2025
5497420
faster debug
dadhi May 6, 2025
874e8ab
trying unboxed thingy
dadhi May 7, 2025
39de1e0
fix bool and char comparison
dadhi May 7, 2025
f815ff1
fixiki
dadhi May 7, 2025
165a105
alternative interpretator for better type control and hopefully @perf
dadhi May 7, 2025
8b44fcf
fixing stuff
dadhi May 7, 2025
5d5b59f
Comparing basic interpretation without boxing all-in-one and new one …
dadhi May 7, 2025
7dea3d0
more diagnostics
dadhi May 8, 2025
960ffd6
more diagnostics
dadhi May 8, 2025
84b0719
better diag messages
dadhi May 8, 2025
f8bdece
cleanup and @perf up
dadhi May 8, 2025
6404050
more special for int
dadhi May 8, 2025
9239040
cleanup
dadhi May 8, 2025
f37d445
name rename
dadhi May 8, 2025
6a13aae
avoid boxing
dadhi May 9, 2025
80a02de
removing ConstantRefExpression but keeping ConstantRef to create the …
dadhi May 10, 2025
0680331
fixing the type of ValueConstantExpression arg from object to T
dadhi May 10, 2025
8a82c89
avoid exceptions in interpreter #472
dadhi May 11, 2025
a2bb16a
fixing single and double convert to decimal
dadhi May 11, 2025
c8bedec
#473 works with interpreter but not with compiler, now we have a prob…
dadhi May 11, 2025
4c1bcc0
proper use of CompilerFlags.DisableInterpreter
dadhi May 11, 2025
8ff4b74
fix ci
dadhi May 11, 2025
5a15c51
fixed: #473
dadhi May 11, 2025
489b3f7
adding tests and removing last excpetion in interpreter
dadhi May 11, 2025
f525daa
optimize EmitDefault
dadhi May 12, 2025
3560338
optimize the pooling of the type arrays for the DynamiMethod creation
dadhi May 12, 2025
7c30e9b
optimize things a bit more
dadhi May 12, 2025
ba43325
cleanup and new bm results
dadhi May 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 31 additions & 32 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,46 @@ name: Publish

on:
push:
tags:
- 'v*.*.*'
tags:
- "v*.*.*"

jobs:
build:

runs-on: ubuntu-latest
env:
DOTNET_NOLOGO: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true

steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
- name: Build
run: dotnet build -c:Release

- name: Make Internal
shell: pwsh
run: ./BuildScripts/MakeInternal.ps1

- name: Pack with dotnet
run: |
arrTag=(${GITHUB_REF//\// })
VERSION="${arrTag[2]}"
VERSION="${VERSION//v}"
echo "$VERSION"
dotnet pack --no-build --output artifacts -p:Version=$VERSION -p:ContinuousIntegrationBuild=True ./nuspecs/FastExpressionCompiler.src.nuspec
dotnet pack --no-build --output artifacts -p:Version=$VERSION -p:ContinuousIntegrationBuild=True ./nuspecs/FastExpressionCompiler.LightExpression.src.nuspec
dotnet pack --no-build --output artifacts -p:Version=$VERSION -p:ContinuousIntegrationBuild=True ./nuspecs/FastExpressionCompiler.Internal.src.nuspec
dotnet pack --no-build --output artifacts -p:Version=$VERSION -p:ContinuousIntegrationBuild=True ./nuspecs/FastExpressionCompiler.LightExpression.Internal.src.nuspec

- uses: actions/upload-artifact@v4
with:
name: Packages
path: ./artifacts
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json

- name: Build
run: dotnet build -c:Release

- name: Make Internal
shell: pwsh
run: ./BuildScripts/MakeInternal.ps1

- name: Pack with dotnet
run: |
arrTag=(${GITHUB_REF//\// })
VERSION="${arrTag[2]}"
VERSION="${VERSION//v}"
echo "$VERSION"

dotnet pack --no-build --output artifacts -p:Version=$VERSION -p:ContinuousIntegrationBuild=True ./nuspecs/FastExpressionCompiler.src.nuspec
dotnet pack --no-build --output artifacts -p:Version=$VERSION -p:ContinuousIntegrationBuild=True ./nuspecs/FastExpressionCompiler.LightExpression.src.nuspec
dotnet pack --no-build --output artifacts -p:Version=$VERSION -p:ContinuousIntegrationBuild=True ./nuspecs/FastExpressionCompiler.Internal.src.nuspec
dotnet pack --no-build --output artifacts -p:Version=$VERSION -p:ContinuousIntegrationBuild=True ./nuspecs/FastExpressionCompiler.LightExpression.Internal.src.nuspec

- uses: actions/upload-artifact@v4
with:
name: Packages
path: ./artifacts

# - name: Push with dotnet
# run: dotnet nuget push artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
5 changes: 4 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@

<NeutralLanguage>en-US</NeutralLanguage>
<LangVersion>latest</LangVersion>
<LatestSupportedNet>net9.0</LatestSupportedNet>

<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>

<NoWarn>IDE0251;IDE0079;IDE0047;NETSDK1212</NoWarn>

<!-- When set, reducec number of the TargetPlatforms to speedup a local Dev -->
<DevMode>false</DevMode>

</PropertyGroup>

<ItemGroup>
Expand Down
12 changes: 9 additions & 3 deletions b.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
@echo off

echo:
echo:## Starting BUILD...
echo:
dotnet build -p:DevMode=true -v:m -c:Release
if %ERRORLEVEL% neq 0 goto :error

echo:
echo:## Starting: TESTS...
echo:## Starting TESTS...
echo:

dotnet run -c:Release -f:net9.0 --project test/FastExpressionCompiler.TestsRunner/FastExpressionCompiler.TestsRunner.csproj
dotnet run --no-build -p:DevMode=true -f:net9.0 -c:Release --project test/FastExpressionCompiler.TestsRunner/FastExpressionCompiler.TestsRunner.csproj
if %ERRORLEVEL% neq 0 goto :error

dotnet run -c:Release --project test/FastExpressionCompiler.TestsRunner.Net472
dotnet run --no-build -p:DevMode=true -c:Release --project test/FastExpressionCompiler.TestsRunner.Net472
if %ERRORLEVEL% neq 0 goto :error

echo:
Expand Down
2 changes: 1 addition & 1 deletion bt.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
echo:
echo:## Running TESTS on the Latest Supported .NET...
echo:
dotnet run -c:Release -f:net9.0 --project test/FastExpressionCompiler.TestsRunner/FastExpressionCompiler.TestsRunner.csproj
dotnet run -p:DevMode=true -f:net9.0 -c:Release --project test/FastExpressionCompiler.TestsRunner/FastExpressionCompiler.TestsRunner.csproj
if %ERRORLEVEL% neq 0 goto :error

echo:
Expand Down
32 changes: 12 additions & 20 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,11 @@ setlocal EnableDelayedExpansion

echo: # BUILDING AND RUNNING THE TESTS IN RELEASE MODE
echo:
echo:

set "FrameworkParam=-f:net9.0"
set "LatestSupportedNetProp=-p:LatestSupportedNet=net9.0"
if [%1] NEQ [] (
set "FrameworkParam=-f:%1"
set "LatestSupportedNetProp=-p:LatestSupportedNet=%1"
)
echo:FrameworkParam == '%FrameworkParam%', LatestSupportedNetProp == '%LatestSupportedNetProp%'

echo:
echo:## Starting: RESTORE and BUILD...
echo:

dotnet clean -v:m %LatestSupportedNetProp%
dotnet build -v:m %LatestSupportedNetProp% -c:Release
dotnet clean -v:m
dotnet build -v:m -c:Release
if %ERRORLEVEL% neq 0 goto :error

echo:
Expand All @@ -27,19 +16,22 @@ echo:## Finished: RESTORE and BUILD
echo:
echo:## Starting: TESTS...
echo:
echo: running on .NET 9.0 (Latest)
echo:
dotnet run --no-build net9.0 %FrameworkParam% -c:Release --project test/FastExpressionCompiler.TestsRunner
echo:running on .NET 9.0 (Latest)
dotnet run --no-build -f:net9.0 -c:Release --project test/FastExpressionCompiler.TestsRunner
if %ERRORLEVEL% neq 0 goto :error

echo: running on .NET 8.0 (LTS)
echo:
dotnet run --no-build net8.0 %FrameworkParam% -c:Release --project test/FastExpressionCompiler.TestsRunner
echo:running on .NET 8.0 (LTS)
dotnet run --no-build -f:net8.0 -c:Release --project test/FastExpressionCompiler.TestsRunner
if %ERRORLEVEL% neq 0 goto :error

echo: running on .NET 6.0 (LTS)
echo:
dotnet run --no-build net6.0 %FrameworkParam% -c:Release --project test/FastExpressionCompiler.TestsRunner
echo:running on .NET 6.0 (Previous LTS)
dotnet run --no-build -f:net6.0 -c:Release --project test/FastExpressionCompiler.TestsRunner
if %ERRORLEVEL% neq 0 goto :error

echo:
echo:running on .NET 4.7.2
dotnet run --no-build -c:Release --project test/FastExpressionCompiler.TestsRunner.Net472
if %ERRORLEVEL% neq 0 goto :error
echo:
Expand Down
28 changes: 15 additions & 13 deletions build_debug.bat
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
@echo off
setlocal EnableDelayedExpansion

echo: # BUILDING AND RUNNNG THE TESTS IN DEBUG MODE
echo: # BUILDING AND RUNNING THE TESTS IN DEBUG MODE
echo:
echo:

set "FrameworkParam=-f:net9.0"
set "LatestSupportedNetProp=-p:LatestSupportedNet=net9.0"
if [%1] NEQ [] (
set "FrameworkParam=-f:%1"
set "LatestSupportedNetProp=-p:LatestSupportedNet=%1"
)
echo:FrameworkParam == '%FrameworkParam%', LatestSupportedNetProp == '%LatestSupportedNetProp%'

echo:
echo:## Starting: RESTORE and BUILD...
echo:

dotnet build %LatestSupportedNetProp% -c:Debug
dotnet build -c:Debug
if %ERRORLEVEL% neq 0 goto :error

echo:
Expand All @@ -26,10 +16,22 @@ echo:## Finished: RESTORE and BUILD
echo:
echo:## Starting: TESTS...
echo:
echo:running on .NET 9.0 (Latest)
dotnet run --no-build -f:net9.0 -c:Debug --project test/FastExpressionCompiler.TestsRunner
if %ERRORLEVEL% neq 0 goto :error

dotnet run --no-build %LatestSupportedNetProp% %FrameworkParam% -c:Debug --project test/FastExpressionCompiler.TestsRunner
echo:
echo:running on .NET 8.0 (LTS)
dotnet run --no-build -f:net8.0 -c:Debug --project test/FastExpressionCompiler.TestsRunner
if %ERRORLEVEL% neq 0 goto :error

echo:
echo:running on .NET 6.0 (Previous LTS)
dotnet run --no-build -f:net6.0 -c:Debug --project test/FastExpressionCompiler.TestsRunner
if %ERRORLEVEL% neq 0 goto :error

echo:
echo:running on .NET 4.7.2
dotnet run --no-build -c:Debug --project test/FastExpressionCompiler.TestsRunner.Net472
if %ERRORLEVEL% neq 0 goto :error
echo:
Expand Down
6 changes: 6 additions & 0 deletions running
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
on .NET 9.0 (Latest)
on .NET 8.0 (LTS)
on .NET 6.0 (Previous LTS)
on .NET 4.7.2
on .NET 9.0 (Latest)
on .NET 8.0 (LTS)
55 changes: 19 additions & 36 deletions src/FastExpressionCompiler.LightExpression/Expression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,25 @@ private static ParameterExpression TryToMakeKnownTypeParameter(Type type, string
public static readonly ConstantExpression OneConstant = new IntConstantExpression(1);
public static readonly ConstantExpression MinusOneConstant = new IntConstantExpression(-1);

public static ConstantRefExpression<T> ConstantRef<T>(T value) => new ConstantRefExpression<T>(value);
/// <summary>Holds the value that you can change lately</summary>
public sealed class ValueRef<T>
{
/// <summary>Reflection access to the value FieldInfo</summary>
public static readonly FieldInfo ValueField = typeof(ValueRef<T>).GetField(nameof(Value), BindingFlags.Public | BindingFlags.Instance);
/// <summary>The adjustable value</summary>
public T Value;
/// <summary>Construct with the initial value</summary>
public ValueRef(T value) => Value = value;
}

public static ConstantRefExpression ConstantRef(object value, Type type) => new ConstantRefExpression(value, type);
/// <summary>Simplifies the constant which is always hold in Closure and which Value can be modified after the compilation</summary>
public static Expression ConstantRef<T>(T value, out ValueRef<T> valueRef)
{
valueRef = new ValueRef<T>(value);

// todo: @perf try the intrinsic?
return new InstanceFieldExpression(new ValueConstantExpression<ValueRef<T>>(valueRef), ValueRef<T>.ValueField);
}

/// <summary>Avoids the boxing for all (two) bool values</summary>
public static ConstantExpression Constant(bool value) => value ? TrueConstant : FalseConstant;
Expand Down Expand Up @@ -3827,10 +3843,6 @@ public abstract class ConstantExpression : Expression
public sealed override ExpressionType NodeType => ExpressionType.Constant;
public abstract object Value { get; }

///<summary>Constant with this field defined will be always put in Closure as a Constant instance and not its value,
/// and will always be accessed by its mutable Field directly, without putting its value into the local variable</summary>
public virtual FieldInfo RefField => null;

#if SUPPORTS_VISITOR
[RequiresUnreferencedCode(Trimming.Message)]
protected internal override Expression Accept(ExpressionVisitor visitor) => visitor.VisitConstant(this);
Expand Down Expand Up @@ -3869,36 +3881,7 @@ public sealed class ValueConstantExpression<T> : ConstantExpression
// Note: the Value is specifically an object despite possibility of strongly typed T, because this way it will be a single boxing.
// Otherwise even using the typed `T _value`, it will be boxed multiple times through its `object Value` accessor.
public override object Value { get; }
internal ValueConstantExpression(object value) => Value = value;
}

/// <summary>A special case of Constant entirely stored in Closure,
/// so that its ValueRef can be updated and the all its Value usage sites will be updated as well, #466.</summary>
public sealed class ConstantRefExpression<T> : ConstantExpression
{
public override Type Type => typeof(T);
public override object Value => ValueRef;
private static readonly FieldInfo ValueRefField = typeof(ConstantRefExpression<T>).GetField(nameof(ValueRef));
public override FieldInfo RefField => ValueRefField;
public T ValueRef;
internal ConstantRefExpression(T value) => ValueRef = value;
}

/// <summary>
/// Note: There is no RefConstantExpression which relies on `Value.GetType()`, because the Value may change (by design), so the Type, which may produce unexpected results.
/// </summary>
public sealed class ConstantRefExpression : ConstantExpression
{
public override Type Type { get; }
public override object Value => ValueRef;
public object ValueRef;
private static readonly FieldInfo ValueRefField = typeof(ConstantRefExpression).GetField(nameof(ValueRef));
public override FieldInfo RefField => ValueRefField;
internal ConstantRefExpression(object value, Type type)
{
Type = type ?? typeof(object); // The type always should be set
ValueRef = value;
}
internal ValueConstantExpression(T value) => Value = value;
}

public sealed class TypedValueConstantExpression : ConstantExpression
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks Condition=" '$(LatestSupportedNet)' == 'net7.0' ">net472;netstandard2.0;netstandard2.1;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(LatestSupportedNet)' == 'net8.0' ">net472;netstandard2.0;netstandard2.1;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(LatestSupportedNet)' == 'net9.0' ">net472;netstandard2.0;netstandard2.1;net6.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks Condition="'$(DevMode)' != 'true'">net472;netstandard2.0;netstandard2.1;net6.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks Condition="'$(DevMode)' == 'true'">net472;net9.0</TargetFrameworks>

<VersionPrefix>5.2.0</VersionPrefix>
<VersionSuffix>preview-02</VersionSuffix>
<VersionSuffix>preview-03</VersionSuffix>

<Product>FastExpressionCompiler.LightExpression</Product>

Expand All @@ -16,7 +15,8 @@
<PackageReleaseNotes><![CDATA[
## v5.2.0

- add: Expose TestTools and FastExpressionCompiler.ILDecoder to enable testing and diagnostic in the consumer projects
- feat: #472 Interpreter to reduce the IL emitted by the Logical, Comparison, Arithmetics expressions, by calculating them during compile time and using the calculation result in IL
- feat: Expose TestTools and FastExpressionCompiler.ILDecoder to enable testing and diagnostic in the consumer code


## v5.1.1. Bug-fix release
Expand Down
Loading