Issue 4610 - std.bigint not working on OSX
Summary: std.bigint not working on OSX
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Windows
: P2 blocker
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2010-08-09 21:37 UTC by Don
Modified: 2010-08-10 13:34 UTC (History)
2 users (show)

See Also:


Attachments
Test case for osx (5.41 KB, text/plain)
2010-08-10 00:20 UTC, Don
Details
Disassembly of osxbug (15.16 KB, application/octet-stream)
2010-08-10 02:32 UTC, Jacob Carlborg
Details

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2010-08-09 21:37:28 UTC
The Phobos unit tests are reported to fail.
Seems to be a problem with the asm routines.
Comment 1 Don 2010-08-10 00:20:12 UTC
Created attachment 709 [details]
Test case for osx

It's impossible for me to fix this without help, as I don't have access to OSX.
If you have access to OSX, please compile the attachment with 
$ dmd osxbug
$ osxbug
It should print:
13131325 56161622 8A8A8A94
Please report the output on OSX. Please also provide a disassembly of osxbug.obj, if possible.
Comment 2 Jacob Carlborg 2010-08-10 02:32:44 UTC
Created attachment 710 [details]
Disassembly of osxbug
Comment 3 Jacob Carlborg 2010-08-10 02:33:54 UTC
It prints "13131325 56161622 8A8A8A94" using both Mac OS X 10.5 and 10.6 with dmd v2.047
Comment 4 Don 2010-08-10 03:00:38 UTC
Thanks! Looks like the compiler is not respecting 'naked'.
It's inserting some kind of garbage at the top of the function!

    asm {
        naked;
        
        push ESI;
        push EDI;
        push EBX;
        push EBP;

_D6osxbug25__T15multibyteMulAddVa43Z15multibyteMulAddFAkxAkkkZk:
		call	  L12D    // ????
L12D:		pop	ECX         // ????
		mov	-010h[EBP],ECX  // WHAT ON EARTH WILL THIS DO???
		push	ESI
		push	EDI
		push	EBX
		push	EBP
Comment 5 Walter Bright 2010-08-10 12:23:19 UTC
The call/pop sequence is how the base address for static data is computed. Why it's there for naked functions, I don't know yet.
Comment 6 Walter Bright 2010-08-10 13:34:03 UTC
http://www.dsource.org/projects/dmd/changeset/612