A method, apparatus and computer instructions for hardware assist for
autonomically patching code. The present invention provides hardware
microcode to a new type of metadata to selectively identify instructions
to be patched for specific performance optimization functions. The
present invention also provides a new flag in the machine status register
(MSR) to enable or disable a performance monitoring application or
process to perform code-patching functions. If the code patching function
is enabled, the application or process may patch code at run time by
associating the metadata with the selected instructions. The metadata
includes pointers pointing to the patch code block code. The program code
may be patched autonomically without modifying original code.