Patent ID: 8621444

Claim:
A method of simulating an instruction set architecture (ISA) with an instruction set simulator (ISS), comprising: generating decoder source code for an original input application, prior to a simulation time, by decoding each instruction of a plurality of instructions in the original input application, wherein the decoding comprises: identifying a plurality of unique instruction patterns in the original input application; selecting an appropriate template from a plurality of templates for each unique instruction pattern of the plurality of unique instruction patterns, wherein each template of the plurality of templates is configured to implement a functionality of an instruction contained within an instruction class, the instruction class describing a set of instructions of the instruction set architecture having a common behavior; generating a customized template for each instruction of the plurality of instructions by extracting values from each instruction and assigning the extracted values to parameters within the template; instantiating the customized template; and appending the customized template and corresponding instantiation code into the decoder source code; compiling the decoder source code including optimizing the decoder source code through partial evaluation to generate an optimized decoder having optimized decoded instructions of the original input application; executing the optimized decoder to simulate the original input application, comprising: loading, at a simulation time, the optimized decoded instructions of the original input application into instruction memory; fetching, at a run time, an instruction binary of the optimized decoded instruction from instruction memory; determining, at the runtime, whether the fetched instruction binary has been modified since a time of decoding; if the fetched instruction binary has been modified since a time of decoding: decoding, at the runtime, the modified instruction to generate a redecoded instruction by selecting one of an optimized decoded template or a decoding mechanism comprising function pointers; and executing one of the decoded instruction or the redecoded instruction.