Compiler aided selective lock assignment for improving the performance of software transactional memory