1. A method of global scope basic-block reordering, comprising: profiling an application having a source code decomposable into a plurality of basic-blocks, wherein the profiling yields a global basic-block sequence; generating a hierarchical locality model according to the global basic-block sequence, wherein the hierarchical locality model represents the plurality of basic blocks and affinities of each basic block of the plurality of basic blocks to one or more other basic blocks of the plurality of basic blocks, and wherein an affinity between a pair of basic blocks represents the smallest number of calls of basic blocks needed to traverse between basic blocks of the pair during execution; and generating a target code according to the hierarchical locality model.