You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we provide an Implementation of Unsafe class and ref structs, this will a big boost into the right direction and makes low level system programming much more type safe and easier.
The most important functions, in the order:
public static int SizeOf<T>()
public static ref TTo As<TFrom, TTo>(ref TFrom source)
public static void* AsPointer<T>(ref T value)
If the above methods are implemented correctly, the following methods should work "automatically", because they depend on the above methods:
public static ref T AsRef<T>(void* source)
public static void Write<T>(void* destination, T value)
public static T Read<T>(void* source)
It could be necessary to provide the ByReference<T> Type.
Please keep in mind that SizeOf() should NOT rely on metadata lookup for each call, it will be horrible slow. As I know, Mosa is duplicating for every generic call the code - so compiler should know the size of T at compile time. And if the methods are correctly implemented as Intrinsics, they could be inlined within the calling method, wich means, that nearly every Call to the above methods is done in very less (maybe only a single) instruction, especially the ref struct methods.
After all the above stuff is working, the following features will work without any additional Compiler support:
removing unsafe-pointers and replace them via ref structs
If we provide an Implementation of Unsafe class and ref structs, this will a big boost into the right direction and makes low level system programming much more type safe and easier.
The most important functions, in the order:
If the above methods are implemented correctly, the following methods should work "automatically", because they depend on the above methods:
It could be necessary to provide the
ByReference<T>
Type.Please keep in mind that SizeOf() should NOT rely on metadata lookup for each call, it will be horrible slow. As I know, Mosa is duplicating for every generic call the code - so compiler should know the size of T at compile time. And if the methods are correctly implemented as Intrinsics, they could be inlined within the calling method, wich means, that nearly every Call to the above methods is done in very less (maybe only a single) instruction, especially the ref struct methods.
After all the above stuff is working, the following features will work without any additional Compiler support:
Here's a small reference implementation incl. a test scenario at the end of the file:
https://github.com/abanu-org/abanu/blob/fd6a45042722596198763b9b63c6b92484d73dc2/src/Abanu.Lib/BitReader.cs
It would be nice if this feature could get a reasonable priority.
The text was updated successfully, but these errors were encountered: