This invention discloses a
Java code
layout optimization method that does not interrupt application services. The method includes: acquiring front-end
bottleneck data of the application; when it is determined that code
layout optimization is needed based on the front-end
bottleneck data, collecting the
dynamic control flow graph of the application service; calculating a new code
layout based on the
dynamic control flow graph; generating new code according to the new code layout; correcting
relocation information in all code, that is, redirecting function calls and data references pointing to the old code to the new code. During the correction process, memory barriers and cache maintenance instructions are used to ensure the
atomicity and consistency of the modification operations, so as to achieve uninterrupted application services; only reclaiming the memory space used by the old code that is no longer executed to store the new code generated in the next optimization, retaining the
function code still on the
call stack, so that most of the memory space can be reclaimed without interrupting application services. This method effectively alleviates the processor front-end
bottleneck of
Java applications and improves application performance.