Uh oh!
There was an error while loading. Please reload this page.
[wasm] PInvokeTableGenerator: Fixup symbol names with invalid chars - #60814
[wasm] PInvokeTableGenerator: Fixup symbol names with invalid chars#60814radical wants to merge 5 commits into
Conversation
ghost
commented
Oct 24, 2021
Tagging subscribers to 'arch-wasm': @lewing Issue Detailsnull
|
lambdageek
left a comment
There was a problem hiding this comment.
Maybe we should use an allow-list instead of a deny list. there's a lot of stuff you can technically put in an IL method name, as far as I can tell from ECMA-335.
| public string FileWrites { get; private set; } = string.Empty; | ||
| private static char[] s_charsToReplace = new[] { '.', '-', }; | ||
| private static char[] s_charsToReplace = new[] { '.', '-', ',', '|', '<', '>' }; |
There was a problem hiding this comment.
I'm not a fan of this.
For one thing it's incomplete - for nested classes we also need to replace '/' when it's in a class name. For another thing, C# allows many unicode characters in an identifier (https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/identifier-names). And IL metadata actually doesn't seem to have any restrictions on identifiers - it's just sequences of bytes. I think we should do something like: convert the name to utf8; look at the bytes; for any bytes not in [0-9A-Za-z] replace them by "" or underscore and the byte hex code (ie F☃ will become "F_E2_98_83" https://www.compart.com/en/unicode/U+2603)
| private static string SymbolNameForMethod(MethodInfo method) | ||
| { | ||
| string module_symbol = method.DeclaringType!.Module!.Assembly!.GetName()!.Name!; | ||
| string class_name = method.DeclaringType.Name; |
There was a problem hiding this comment.
Should we check method.DeclaringType.IsNested and include the enclosing types' names?
| string class_name = method.DeclaringType.Name; | ||
| string method_name = method.Name; | ||
| string entry_name = $"wasm_native_to_interp_{module_symbol}_{class_name}_{method_name}"; | ||
| string entry_name = $"wasm_native_to_interp_{SymbolNameForMethod(method)}"; |
There was a problem hiding this comment.
If we're compiling for !aot, we should check if the method UnmanagedCallersOnlyAttribute has an EntryPoint and emit the wasm_native_to_interp callback with the supplied name.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
lambdageek
commented
Oct 27, 2021
The interpreter runs of the new test are unhappy for some reason. unclear why |
ghost
commented
Nov 26, 2021
Draft Pull Request was automatically closed for inactivity. Please let us know if you'd like to reopen it. |
Includes: - Better error logging, and handling - Add @(NativeFileReference) to up-to-date check items for VS - Add `WasmBuild.sln` - Better fix up of symbol names for pinvokes, and callbacks, based on @lambdageek's suggestion in #60814 (comment)Fixes#60862
Fixes#60800