Re: are static operations optimized?
Re: are static operations optimized?
- Subject: Re: are static operations optimized?
- From: Jeremy Pereira <email@hidden>
- Date: Tue, 27 Jan 2009 16:53:27 +0000
On 27 Jan 2009, at 16:32, David Harper wrote:
Hello,
Though perhaps it is irrelevant to fuss about O(1) operations, I was
wondering if anyone with some familiarity with the objective-C
compiler could say whether static operations are actually calculated
at runtime or parsed & pre-calculated for optimization purposes.
When I say static operations I refer to those without variables.
For example, if I had a method with the following return statement:
return (128 - 6);
I created the following function in a .m file in Xcode:
int foo()
{
return (128 - 6);
}
I then used Xcode's show assembly code context menu option to show the
compilation. Here it is:
_foo:
LFB662:
LM1:
pushl ëp
LCFI0:
LM2:
movl $122, êx
LM3:
movl %esp, ëp
LCFI1:
LM4:
leave
ret
That was from the default release build. It's clear that constant
expressions are precalculated.
would this be compiled as "return 122" ? Would pre-calculating such
things save a relevant amount of clock cycles if such a statement
were evaluated, say, 100,000 times per second?
Just curious. I apologize if this is the incorrect list for such a
question.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden