-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Eliminate the use of MarshalAs for bools #237
Comments
Oddly enough, using |
While working on these, it dawned on me that emitting As far as I can think, the marshaler only touches the fields of a struct for marshaling purposes when that struct is passed (directly or indirectly) by value or it's passed as a C# byref. After the work on the above issues is completed, the latter situation won't ever happen in Biohazrd-generated code. The by-value case can, but only for structs which are not implicitly passed by reference. The rules vary between ABIs, but generally structs passed by value are only "truly" passed by value (from an ABI perspective not a programming language perspective) when they can fit within registers. Generally speaking this only happens if the struct is relatively small. If the struct is relatively small the performance hit of having the marshaler clone and manipulate the struct is also relatively small. It's obviously still not ideal, but maybe the API clarity is worth it over using One thing we could do is write a transformation which looks through all parameter/return types and checks if they're by-value and if they directly or indirectly reference a record which contains fields which use bools and opt-in to |
Right now we use
MarshalAs
forbool
where possible andNativeBoolean
where not.We should instead prefer using trampolines where possible and
NativeBoolean
where not.The text was updated successfully, but these errors were encountered: