Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix internal error caused by the missing ldind/stind pickler combinator for inline IL #5528

Closed

Conversation

zpodlovics
Copy link

@zpodlovics zpodlovics commented Aug 17, 2018

This is a fix for #5527

Right now the ldind / stind keyword is known and handled (https://github.com/Microsoft/visualfsharp/blob/master/src/absil/illex.fsl#L145) here (https://github.com/Microsoft/visualfsharp/blob/master/src/absil/ilascii.fs#L196)
and here (https://github.com/Microsoft/visualfsharp/blob/master/src/absil/illex.fsl#L63) and here, but not yet possible to emit the corresponding bytecode because of the missing TAST pickler combinators (https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/TastPickle.fs#L1157) How the TAST (Pickler) versioning supposed to work? Is it OK to extend it with new functionality and tags? Please forgive me if I made some mistakes, this is my first pull request for F#.

Please note: I intentionally did not propose any new functionality for NativePtr in this pull request, so no surface area change are required.

Please note: Right now every access (including ldobj/stobj) assume aligned access in F#, which is perfectly fine on x86 and unaligned access is also inexpressible in C#. However this should be addressed in the future, because other architectures for example ARM does have a problem with unaligned access [1] (I have a quick and dirty inline IL prototype, and will be introduced later after cleanup)

[1] "An operation that performs an unaligned access can abort on any memory access that it makes, and can abort on more than one access. This means that an unaligned access that occurs across a page boundary can generate an abort on either side of the boundary."

@zpodlovics zpodlovics changed the title Fix internal error caused by the missing ldind/stind picker combinator for inline IL [WIP] Fix internal error caused by the missing ldind/stind picker combinator for inline IL Aug 17, 2018
@cartermp cartermp requested a review from dsyme August 17, 2018 16:00
@zpodlovics zpodlovics changed the title [WIP] Fix internal error caused by the missing ldind/stind picker combinator for inline IL [WIP] Fix internal error caused by the missing ldind/stind pickler combinator for inline IL Aug 17, 2018
@TIHan
Copy link
Member

TIHan commented Aug 18, 2018

I don't see a reason why we shouldn't include this. I imagine we would do something with it for the NativePtr API at some point.

@zpodlovics
Copy link
Author

Thank you! Well, the other alternative is to write the same thing in C# or pure IL (ilproj). The inline IL is probably the best feature to "improve" the low level stuff in F# (but still takes really-really long time until the upstream include these features): (#409 (comment))

eg.: there is no unaligned load/store concept in F# and not even in C#, therefore there is no way to express it, so there will be always cases where we have to use low level stuff to introduce new functionality or even concepts: non-volatile memory will probably also require low level stuff in the near future (https://github.com/dotnet/coreclr/issues/916#issuecomment-366562117)

Eventually it will land in NativePtr but I would rather not propose any API right now before I "dogfooding" my ideas in a larger project and also without checking other developers use-case scenarios.

@TIHan
Copy link
Member

TIHan commented Aug 19, 2018

Inline IL was meant for FSharp.Core internals, not for public use; though you can use it publicly.

If anything, we should look for ways to extend/change NativePtr API if it makes sense and if that requires additional inline IL changes, then that seems reasonable.

@zpodlovics
Copy link
Author

Unfortunately I did not found the original usenet message about this only this: (https://stackoverflow.com/questions/15968054/what-is-the-syntax-seen-in-f-standard-library-implementation):

"Embedded IL in F# codes. Is this feature officially supported

Not really. The 99.9% purpose of this feature is for operations defined in FSharp.Core.dll (called fslib.dll in 1.9.2.9 and before).

Historically it has been useful to allow end-users to embed IL in order to access .NET IL functionality not accessible by F# library or language constructs using their own embedded IL. The need for this is becoming much more rare, indeed almost non-existent, now that the F# library has matured a bit more. We expect this to continue to be the case. It's even possible that we will make this a library-only feature in the "product" version of F#, though we have not yet made a final decision in this regard."

@cartermp
Copy link
Contributor

@zpodlovics is this still WIP? I think we'd like to see some tests if possible, but we'll refrain from reviewing until it's ready.

@KevinRansom
Copy link
Member

@zpodlovics , @cartermp .

I am closing this PR as an orphan PR, it hasn't been updated in nearly two years, the last comment was 16 months ago. Please Feel free to reactivate this PR, if you are ready to continue work on it.

Thank you for this contribution

Kevin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants