Optimizing of explicit temporary storage
Mark Mitchell
mark@codesourcery.com
Tue Oct 12 09:37:00 GMT 2004
Florian Weimer wrote:
>* Mark Mitchell:
>
>
>
>>I don't think any compiler has ever attempted to turn:
>>
>> free (malloc (16));
>>
>>into a no-op, which would be a simpler case.
>>
>>
>
>There are scheme compilers that turn heap allocation into stack
>allocation if they can prove that the object does not escape.
>Java code would benefit from this optimization, too.
>
>
Yes, but that's rather a different situation due to the nature of Scheme.
In C, even given just:
(void) malloc(16);
it would be surprising to most programmers to optimize away the call
because malloc *does* have side-effects on real systems. For example,
on UNIX, it is likely to call sbrk, which result in observable changes
in the process state.
--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com
More information about the Gcc
mailing list