Patent ID: 7770163

Claim:
A computer-implemented method for synchronizing a plurality of clones of a software method to be executed by at least one thread while the software method is compiled, the software method having references to each of a plurality of global profiling control variables and to each of a plurality of global profiling data variables, the computer-implemented method comprising: cloning, by a processor, the software method to generate a first software method clone; creating, by a processor, at least one transition between equivalent program points in the software method and the first software method clone; inserting, by a processor, a lock object into one of the software method and the first software method clone; changing, by a processor, code that controls the at least one transition between the equivalent program points in the software method and the first software method clone, wherein a non-profiling clone comprises the one of the software method and the first software method clone into which the lock object was inserted, and a profiling clone comprises the other one of the software method and the first software method clone; causing creation, by a processor, of a plurality of thread-specific local profiling control variables based on the plurality of global profiling control variables, so that each thread expected to execute the software method has a plurality of thread-specific local profiling control variables, each such thread-specific local profiling control variable being based on a corresponding global profiling control variable; performing, by a processor, a first synchronization operation at one of an entry point of the non-profiling clone and a point after the entry point of the non-profiling clone so as to initialize the thread-local storage prior to using the thread-local storage, wherein, when executed at runtime, the first synchronization operation acquires exclusive access to the plurality of global profiling control variables, initializes each of the plurality of thread-specific local profiling control variables, and then releases exclusive access; and executing, by a processor, the profiling clone using thread-local storage.