One embodiment of the present invention provides a system that facilitates
prefetching memory pages for a computer program. The system operates by
analyzing the computer program within a compiler to identify memory pages
accessed within a portion of the computer program. Next, the system
creates a map of these memory pages accessed by the computer program,
wherein the map is indexed by a program counter for the computer program.
A given program counter value indexes memory pages within this map that
are likely to be accessed during subsequent execution of the computer
program. The system examines the map during execution of the computer
program, and if the current program counter for the computer program
indexes memory pages in the map, the system touches the memory pages,
thereby causing the system to prefetch the memory pages.