C Programming Optimized Code, RAMifications

Publié le: 13 mars 2009
sur la chaîne: Executive Quest
8,059
22

Let's take a look at what happens to our function when we compile it with compiler optimizations enabled. What is optimized code? What is function in-lining? See how the gcc compiler strips off the CDECL calling convention wrappers (stack push call and ret instruction overhead) and embeds our functions code directly into main() when we enable the gcc optimize for size flag, -Os.

This is just one of the many, many optimizing steps a compiler might do. We can also tell it to unroll loops, or treat the stack differently. See "man gcc" for options. But let's not enable too many of these optimizations, or risk ricing up our code.

Optimized code can run a little bit faster or take up a little bit less memory. However, the compiler flags we choose can make significant changes to the final assembly language output. This may not be a problem for some, but in the future we might want to know about this in case we decide to do some non-standard self-modifying code experiments.

Resources:
http://www.iso-9899.info/wiki/Main_Page
http://www.cs.princeton.edu/~benjasik...
http://www.phiral.net/linuxasmone.htm
http://en.wikibooks.org/wiki/Category...
http://en.wikipedia.org/wiki/X86_call...


Sur cette page du site, vous pouvez voir la vidéo en ligne C Programming Optimized Code, RAMifications durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Executive Quest 13 mars 2009, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 8,059 fois et il a aimé 22 téléspectateurs. Bon visionnage!