How do I choose the correct primative?
TheFlyingFiddle
kurtyan at student.chalmers.se
Sun Jan 5 00:23:43 PST 2014
On Sunday, 5 January 2014 at 06:31:38 UTC, Jake Thomas wrote:
> And got 86,421 lines of assembly!! I expected a load
> instruction to load whatever was at loadMe's location into r0
> (the return register) and not much else. Maybe 10 lines - tops
> - due to compiler fluffiness. I got about 8,641 times that -
> over 3 more orders of magnatude. What is going on here?
Well the compiler pulls in at minimum the entire D runtime if i'm
not mistaken which make the standard .exe about 350kb.
Things like Object.factory also pulls in it's fair share due to
not being able to remove classes. So we get alot of fluff in
small programs.
The module layout of the standard library is also a problem,
there is a lot of interconnections between the different modules
in Phobos. (will hopefully be better when the modules are broken
down into submodules)
I tested your test program on windows x64 and got the following
result:
mov ebp,esp
sub rsp,10h
mov eax,dword ptr [rbp-8]
lea rsp,[rbp]
pop rbp
ret
//This does a 32 bit load into the eax register (return register)
from the //stack.
mov eax,dword ptr [rbp-8]
//I also ran this to see if there was any difference
int main()
{
int loadMe = 10;
return loadMe;
}
--Resulting main functtion
mov ebp,esp
sub rsp,10h
mov eax,0Ah
mov dword ptr [rbp-8],eax
lea rsp,[rbp]
pop rbp
ret
//Loads 10 the value to be returned and
//Then stores that value on the stack.
//While this is not rly necessary i ran
//the code in debug mode so it does not
//remove most useless instructions.
mov eax,0Ah
mov dword ptr [rbp-8],eax
//In optimized mode it is gone
push rbp
mov rbp,rsp
mov eax,0Ah
pop rbp
ret
So it looks like dmd does 32-bit loads at least on windows x64.
More information about the Digitalmars-d-learn
mailing list