Conversation
|
@benpye, |
|
|
||
| for (int i = 0; i < argCount; i++) | ||
| { | ||
| if(i == 0 && hasThis && unbox) |
There was a problem hiding this comment.
Would it be better to just check if (i == 0 && unbox) and then assert that hasThis is true?
| /// </summary> | ||
| /// <param name="unboxingStubNode">The unboxing node to be output</param> | ||
| /// <param name="methodImplementations">The buffer in which to write out the C++ code</param> | ||
| private void OutputUnboxNode(UnboxingStubNode unboxingStubNode) |
There was a problem hiding this comment.
Nit: We call these things unboxing stubs - OutputUnboxingStubNode or OutputUnboxingStub would be better name.
There was a problem hiding this comment.
Would it be possible to just allocate a normal CppMethodCodeNode for these, where _methodCode is this code and _dependencies points to the CppMethodCodeNode of the target?
It would fix the TODO here:
It feels odd to allocate the UnboxingStubNode (which represents a machine code helper) and then try to patch things up later.
There was a problem hiding this comment.
The unboxing stubs define their own mangled name. We could derive CppMethodCodeNode, providing the unboxing names. Would have to swap GetCppMethodName for method.GetMangledName in several places I think, or at least redefine GetCppMethodName to use the getter on the method.
EDIT:
We also run into trouble in getting the right forward declarations this way, we rely on the MethodDesc being accurate. Is there a suitable MethodDesc type allowing the name to be redefined? I guess then we could avoid an unboxing specific node.
|
Will address the two comments.
Seems RyuJIT takes a vastly different path to resolve. The following is still true: |
| System.Diagnostics.Debug.Assert(hasThis); | ||
|
|
||
| var thisType = method.OwningType; | ||
| if (thisType.IsValueType) |
There was a problem hiding this comment.
I think that this should be assert instead as well - unboxing stubs are only valid for value types.
|
@benpye Do you plan to do more changes for this? I think this change is improvement as is - I would be happy to merge it. The cleanup around the unboxing stub node define can be done separately. |
|
@jkotas Happy to merge this as is, as you say, already an improvement. Have addressed your comments and squashed. Can work on cleaning up and what is going on with the enum case. |
|
Thanks! |
This change set adds limited unboxing support for the C++ backend. Calling interface methods on boxed value types is functional, as is calling methods such as
Convert.ToInt32with a boxed value type. Enums (as in #2884) still fails, I need to look at what is going on withFindInterfaceMethodImplementationTarget.@jkotas
Working examples: