assembly - Dynamic recompilation on the same architecture -


i know dynamic recompilation can used translate instructions 1 architecture during execution. can used optimize program on same architecture? if write poorly optimized assembly language program, can use dynamic recompiler make run faster native speeds?

it's impossible create code runs faster native speed, fastest code possible still runs @ native speed only. :)

if mean "faster original code", yes, it's possible create tool such purpose, quite difficult make practical , successful.

reasoning:

with native-compiled languages c++, compiling original source compiler has many strong hints original intent of programmer, , optimizer can more aggressive, not blindly translating char char machine code, producing code holds language definition (ie. omitting whole function call, when result not used, , there's no side effect of function execution).

once try optimize native machine code only, wouldn't have additional context. new optimized code must mimic original code in every aspect, down side effects , memory modifications.

at point down minor optimizations, register reallocation, instruction reordering, few instruction replacement faster alternative, etc.

a modern x86 cpu doing lot of on it's own during execution, x86 original cisc-like instruction set not implemented directly on chip, gets translated internal risc-like micro-instructions, registers being aliased, , being reordered, executed in parallel when possible, branch predictions speculative fetch-ahead, etc... modern x86 cpu machine in machine, it's doing half of possible in approach itself.

the other half difficult compute program anyway, tool designed in way save internal x86 optimization hassle, making machine code more target platform friendly, gaining marginal additional performance.


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -