-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.4: Ported zstd v1.5.0, performance improvements
- Loading branch information
Showing
76 changed files
with
4,026 additions
and
1,480 deletions.
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
Binary file not shown.
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,77 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#if !NETCOREAPP3_0_OR_GREATER | ||
|
||
using InlineIL; | ||
using static InlineIL.IL.Emit; | ||
|
||
namespace System.Runtime.CompilerServices | ||
{ | ||
public static unsafe class Unsafe | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static T As<T>(object o) | ||
where T : struct | ||
{ | ||
Ldarg(nameof(o)); | ||
return IL.Return<T>(); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static ref TTo As<TFrom, TTo>(ref TFrom source) | ||
{ | ||
Ldarg(nameof(source)); | ||
return ref IL.ReturnRef<TTo>(); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static int SizeOf<T>() | ||
{ | ||
Sizeof(typeof(T)); | ||
return IL.Return<int>(); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static ref T Add<T>(ref T source, int elementOffset) | ||
{ | ||
Ldarg(nameof(source)); | ||
Ldarg(nameof(elementOffset)); | ||
Sizeof(typeof(T)); | ||
Conv_I(); | ||
Mul(); | ||
IL.Emit.Add(); | ||
return ref IL.ReturnRef<T>(); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static void SkipInit<T>(out T value) | ||
{ | ||
Ret(); | ||
throw IL.Unreachable(); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static ref T AsRef<T>(void* source) | ||
{ | ||
// For .NET Core the roundtrip via a local is no longer needed | ||
#if NETCOREAPP | ||
IL.Push(source); | ||
return ref IL.ReturnRef<T>(); | ||
#else | ||
// Roundtrip via a local to avoid type mismatch on return that the JIT inliner chokes on. | ||
IL.DeclareLocals( | ||
false, | ||
new LocalVar("local", typeof(int).MakeByRefType()) | ||
); | ||
|
||
IL.Push(source); | ||
Stloc("local"); | ||
Ldloc("local"); | ||
return ref IL.ReturnRef<T>(); | ||
#endif | ||
} | ||
} | ||
} | ||
|
||
#endif |
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,54 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#if !NETCOREAPP3_0_OR_GREATER | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
namespace System.Runtime.Intrinsics | ||
{ | ||
public static class Vector128 | ||
{ | ||
internal const int Size = 16; | ||
|
||
public static unsafe Vector128<byte> Create(byte value) | ||
{ | ||
byte* pResult = stackalloc byte[16] | ||
{ | ||
value, | ||
value, | ||
value, | ||
value, | ||
value, | ||
value, | ||
value, | ||
value, | ||
value, | ||
value, | ||
value, | ||
value, | ||
value, | ||
value, | ||
value, | ||
value, | ||
}; | ||
|
||
return Unsafe.AsRef<Vector128<byte>>(pResult); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public static Vector128<U> As<T, U>(this Vector128<T> vector) | ||
where T : struct | ||
where U : struct => | ||
Unsafe.As<Vector128<T>, Vector128<U>>(ref vector); | ||
|
||
public static T GetElement<T>(this Vector128<T> vector, int index) | ||
where T : struct | ||
{ | ||
ref T e0 = ref Unsafe.As<Vector128<T>, T>(ref vector); | ||
return Unsafe.Add(ref e0, index); | ||
} | ||
} | ||
} | ||
|
||
#endif |
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,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
#if !NETCOREAPP3_0_OR_GREATER | ||
|
||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace System.Runtime.Intrinsics | ||
{ | ||
[StructLayout(LayoutKind.Sequential, Size = Vector128.Size)] | ||
public readonly struct Vector128<T> : IEquatable<Vector128<T>> | ||
where T : struct | ||
{ | ||
private readonly ulong _00; | ||
private readonly ulong _01; | ||
|
||
public static int Count => Vector128.Size / Unsafe.SizeOf<T>(); | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public bool Equals(Vector128<T> other) | ||
{ | ||
for (int i = 0; i < Count; i++) | ||
{ | ||
if (!((IEquatable<T>)(this.GetElement(i))).Equals(other.GetElement(i))) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.