Binary translation is the process of converting binary code from one ISA to another ISA without the presence of source code. In dynamic binary translation (DBT), translation is done at run-time, and optimization algorithms are applied on the translated code at the same time. DBT is especially useful in solving the problem of legacy code, code migration and building a virtual computing environment. It has become a hot spot in recent research. Because all the translation and optimization are done at run-time, it has a high demand on the efficiency of the system.The work of this thesis includes three major parts: run-time profiling, hot code recognition and optimization, and the management of code cache according to the profile information.Profile involves collecting run-time information of the system. Traditionally, the object to be profiled in a binary translation system is basic block, but it requires a lot of work, and the information it collected is relatively isolated. In this thesis, we proposed an efficient path-based profiling method.Hot code recognition is the process of finding the highly frequently executed blocks by using the profiling information. Then the hot blocks are merged into superblocks, which contain single entry but multiple exits. This will save the system a lot of cost on context switch, and also provide great opportunity for intermediate level optimization.Code cache management focuses on the eviction of obsolete blocks. Because blocks may be different in length, fragmentation will be caused by inappropriate eviction. This thesis proposed a multi-level cache to solve the problem by using profiling information. |