A method and system for creating and injecting code into a running program
that identifies a hot data stream, and prefetching data elements in the
stream so they are available when needed by the processor. The injected
code identifies the first few elements in a hot data stream (i.e. the
prefix), and prefetches the balance of the elements in the stream (i.e.,
the suffix). Since the hot data stream identification code and prefetch
code is injected at run time, pointer related time-dependencies inherent
in earlier prefetch systems are eliminated. A global deterministic finite
state machine (DFSM) is used to help create conceptual logic used to
generate the code injected into the program for prefix detection.