Partial Cross-Compilation and Mixed Execution for Accelerating Dynamic Binary Translation

Yuhao Gu, Zhongchun Zheng, Nong Xiao, Yutong Lu, Xianwei ZhangarXiv 2025 · DOI

Abstract

Dynamic Binary Translation (DBT) is a cornerstone of modern cross-architecture computing, enabling legacy software to run on diverse hardware like ARM and RISC-V. However, the performance penalty of instruction-by-instruction translation often limits its utility. This paper presents a novel hybrid execution framework, referred to as TECH, that bridges the gap between slow emulation and difficult-to-achieve full native porting. By selectively cross-compiling platform-independent source code while emulating only non-portable segments, the proposed system achieves significant performance gains, reaching up to 13x speedup over standard DBT.

Introduction

The computing industry is currently undergoing a major architectural shift. While x86 has long dominated the desktop and server markets, ARM and RISC-V are rapidly gaining ground due to their energy efficiency and performance. This transition relies heavily on Dynamic Binary Translation (DBT) technologies—such as Apple’s Rosetta 2—to ensure software compatibility. Despite their necessity, DBT systems are notoriously inefficient, often running programs at a fraction of their native speed because they must translate guest instructions into host instructions at runtime.

The traditional alternative is full cross-compilation, which involves rebuilding the entire application for the target architecture. However, this is frequently an "all-or-nothing" proposition. Many programs contain ISA-specific code, such as inline assembly or platform-dependent macros, that prevents successful cross-compilation. If even a small portion of the code fails to compile for the new architecture, the developer is forced back into the slow lane of full emulation. This paper addresses this "middle ground" by proposing a system that runs portable code natively while emulating only the strictly necessary parts.

The Hybrid Execution Framework

The core of the proposed solution is a coordinated compilation and emulation workflow designed to maximize native execution.

The hybrid execution model compared to traditional DBT and native execution.

The process begins at compile-time with a hybrid build. The system analyzes the source code to identify "eligible" functions—those that are ISA-agnostic and can be safely cross-compiled to the host architecture (e.g., from x86 to ARM). For functions that contain non-portable elements, the system retains the original guest code but inserts "bridging stubs." These stubs act as entry points that allow the runtime environment to transition between emulated and native execution modes.

At runtime, the system employs a mixed execution strategy. The emulator (typically QEMU) manages the execution of guest code. When the control flow reaches a stub, the system performs a complex "Calling Conversion." This process translates function arguments between different Application Binary Interfaces (ABIs), ensuring that data is correctly passed from the emulated environment to the native host function. Once the native function completes, the system transitions back to the emulator to continue guest execution.

Optimizing the Guest-Host Boundary

To minimize the overhead associated with switching between emulated and native modes, the researchers introduced several key optimizations:

  • Global Reference Table (GRT): This table pre-stores constant data and pointers, avoiding the need for redundant data construction during cross-boundary calls.
  • Fast Calling Path (FCP): This optimization allows offloaded native functions to call one another directly. By bypassing the emulator for internal native calls, the system significantly reduces the frequency of expensive context switches.
  • Partial Function Outlining (PFO): This technique handles functions that are mostly portable but contain isolated "problematic" instructions (e.g., a single variadic call or a specific assembly instruction). PFO splits these functions, allowing the bulk of the logic to run natively while keeping only the non-portable snippet within the emulator.

Evaluation and Results

The prototype system was evaluated across several standard benchmarks, including the LLVM Test Suite and NAS Parallel Benchmarks (NPB). The tests focused on emulating x86-64 on AArch64 and vice versa.

Relative speedup of the hybrid system (TECH) across various benchmarks compared to native execution and standard QEMU.

The results demonstrate substantial performance improvements. On the AArch64 host, the system achieved a geometric mean speedup of 3.03x over standard QEMU, with some benchmarks reaching as high as 13.03x. When emulating ARM on an x86-64 host, the peak speedup reached an impressive 18.91x. Furthermore, the system showed additive benefits when applied to shared libraries. For instance, accelerating both libpng and zlib for imagemagick resulted in a 3.96x overall performance boost without requiring modifications to the application's primary source code.

Discussion and Limitations

A critical insight from this research is that cross-compilation does not need to be exhaustive to be highly effective. By accepting a "hybrid" state, developers can capture the majority of native performance benefits even when a portion of the codebase remains unportable. The authors also noted that source-level offloading is superior to binary-level attempts because it preserves type information, allowing for safer and more automated ABI conversions.

However, the system is not without limitations. It currently requires access to source code for the functions being offloaded, meaning it cannot yet optimize closed-source binaries without prior preparation. Additionally, the researchers identified a "short function" trap: if a function is too small, the overhead of the guest-to-host transition can outweigh the performance gains of native execution. This suggests that a sophisticated cost model is necessary to automatically determine which functions are truly worth offloading.

Conclusion

This hybrid execution framework represents a significant step forward in cross-architecture performance. By breaking the "all-or-nothing" paradigm of cross-compilation, it offers a practical path toward native-like speeds for legacy software on modern hardware. Future work will focus on developing adaptive offloading strategies and deeper co-optimizations between the compiler and the emulator to further refine this promising technology.

Summary updated

BibTeX
@misc{gu2025partial,
  author = {Yuhao Gu and Zhongchun Zheng and Nong Xiao and Yutong Lu and Xianwei Zhang},
  title = {{Partial Cross-Compilation and Mixed Execution for Accelerating Dynamic Binary Translation}},
  year = {2025},
  eprint = {2512.00487},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2512.00487},
}
Figure