Repetitive synchronization in program code is optimized through lock
coarsening that is performed subject to a number of constraints. Using a
forward pass over the program code followed by a backward pass, region
extent bits may be determined that identify the points in the program
where object locking can be coarsened. The program code may then be
modified to realize coarsened locking regions determined based on the
region extent bits. Alternatively, previously determined value numbers
may provide much of the information collected by the two passes. In such
a case, a single pass over the program code may locate features that
limit lock coarsening opportunities. A set of synchronization operations
that can be removed may then be determined and used when modifying the
program code to coarsen locking regions.