[Mono-dev] [PATCH] Marshaling structs on Winx64

Bill Holmes billholmes54 at gmail.com
Wed Jun 4 18:25:22 EDT 2008

The attached code is some of the fixes needed for marshaling structs on Winx64.

In mini-amd64 two things have been fixed.
1)  Structs containing floats are passed in the integer registers, not
the float registers.
2)  Only structs that are 1,2,4,or 8 bytes will be copied into a
register.  All others are pushed at the beginning of the stack
(depending on your point of reference) and the address of that stack
location is stored in the argument register.

I still am struggling to figure out how to fix the case where the
struct will not fit into the register because of the criteria listed
above.  What needs to happen is that the struct is copied onto the
stack and the address of that location is stored in an argument
register.  Any suggestion of how to do this or something that I should
be reading would be appreciated.

I have also attached a new set of unit tests that represents the code
I am using to debug some of these issues.  I have disabled the
Test_In_Args_Value_On_Stack_ADDR_In_RCX portion of the test because of
the problem mentioned above.  More tests are needed for return values
as well as calling managed code from native.  I will be adding theses

I have encountered another problem that I have decided to ignore for
the time being.  Originally the C# portion of my tests contained char
types instead of byte types.  This worked fine when run under .net.
However mono assumes 2 bytes for the char.  Is this just another
Winx64 bug that needs addressed?

As always suggestions are not only welcome but encouraged.  I am
defiantly a fish out of water in this code.

OK to commit?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winx64_struct_08_06_04.diff
Type: application/octet-stream
Size: 1730 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080604/dc803ee9/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winx64_struct_tests_08_06_04.diff
Type: application/octet-stream
Size: 13112 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080604/dc803ee9/attachment-0003.obj 

More information about the Mono-devel-list mailing list