One embodiment of the present invention provides a system that facilitates
efficient join operations between a head thread and a speculative thread
during speculative program execution, wherein the head thread executes
program instructions and the speculative thread executes program
instructions in advance of the head thread. The system operates by
executing a primary version of a program using the head thread, and by
executing a speculative version of the program using the speculative
thread. When the head thread reaches a point in the program where the
speculative thread began executing, the system performs a join operation
between the head thread and the speculative thread. This join operation
causes the speculative thread to act as a new head thread by switching
from executing the speculative version of the program to executing the
primary version of the program. To facilitate this switching operation,
the system performs a lookup to determine where the new head thread is to
commence executing within the primary version of the program based upon
where the speculative thread is currently executing within the
speculative version of the program.