Index: vm/em/src/NValueProfileCollector.cpp =================================================================== --- vm/em/src/NValueProfileCollector.cpp (revision 627113) +++ vm/em/src/NValueProfileCollector.cpp (working copy) @@ -171,7 +171,9 @@ VPData* instProfile, ValueT curr_value) { uint8* updating_ptr = methProfile->getUpdatingStatePtr(); - if (updateStrategy == UPDATE_FLAGGED_ALL) { + if (updateStrategy == UPDATE_LOCKED) { + methProfile->lockProfile(); + } else if (updateStrategy == UPDATE_FLAGGED_ALL) { // Checking a flag and modifying it atomically must be faster than // locking because it skips simultaneous updates. Faster but sacrifices // profile precision. @@ -186,7 +188,7 @@ // We increment the counter safely only with UPDATE_FLAGGED_ALL (*num_times_profiled)++; } else { - if (updateStrategy == UPDATE_LOCKED) { + if (updateStrategy == UPDATE_LOCKED_INSERT) { methProfile->lockProfile(); }else if (updateStrategy == UPDATE_FLAGGED_INSERT) { if (port_atomic_cas8(updating_ptr, 1, 0) != 0) { @@ -199,14 +201,16 @@ *num_times_profiled = 1; insert(steady_part, clear_part, curr_value, *num_times_profiled); *last_value = curr_value; - if (updateStrategy == UPDATE_LOCKED) { + if (updateStrategy == UPDATE_LOCKED_INSERT) { methProfile->unlockProfile(); }else if (updateStrategy == UPDATE_FLAGGED_INSERT) { *updating_ptr = 0; } } UNSAFE_REGION_END - if (updateStrategy == UPDATE_FLAGGED_ALL) { + if (updateStrategy == UPDATE_LOCKED) { + methProfile->unlockProfile(); + } else if (updateStrategy == UPDATE_FLAGGED_ALL) { *updating_ptr = 0; } } Index: vm/em/src/DrlEMImpl.cpp =================================================================== --- vm/em/src/DrlEMImpl.cpp (revision 627113) +++ vm/em/src/DrlEMImpl.cpp (working copy) @@ -655,6 +655,8 @@ updateStrategy = UPDATE_FLAGGED_INSERT; }else if (strategy == "UNSAFE") { updateStrategy = UPDATE_UNSAFE; + }else if (strategy == "LOCKED_INSERT") { + updateStrategy = UPDATE_LOCKED_INSERT; }else if (strategy != "LOCKED") { LECHO(10, "EM: unsupported value profiler updateStrategy"); return NULL; Index: vm/em/src/NValueProfileCollector.h =================================================================== --- vm/em/src/NValueProfileCollector.h (revision 627113) +++ vm/em/src/NValueProfileCollector.h (working copy) @@ -44,10 +44,14 @@ enum ProfileUpdateStrategy { + // Lock when modifying the TNV table, even trivial counter increments. + // This mode is only one that guarantees accurate profiling + UPDATE_LOCKED, + // Lock when restructuring the TNV table (inserting). Trivial counter // increments might not be locked (in current implementation they are not // locked for FirstN table management only) - UPDATE_LOCKED, + UPDATE_LOCKED_INSERT, // When a new value is added to TNV all simultaneous updates to the table // are skipped Index: vm/jitrino/config/em64t/server.emconf =================================================================== --- vm/jitrino/config/em64t/server.emconf (revision 627115) +++ vm/jitrino/config/em64t/server.emconf (working copy) @@ -43,7 +43,7 @@ VALUE_PROF.profilerType=VALUE_PROFILER VALUE_PROF.vpalgo=TNV_FIRST_N -VALUE_PROF.updateStrategy=LOCKED +VALUE_PROF.updateStrategy=LOCKED_INSERT VALUE_PROF.vpSteadySize=4 SD1_OPT.genProfile=EDGE_PROF,VALUE_PROF SD2_OPT.useProfile=EDGE_PROF,VALUE_PROF Index: vm/jitrino/config/ia32/server_aggressive.emconf =================================================================== --- vm/jitrino/config/ia32/server_aggressive.emconf (revision 627115) +++ vm/jitrino/config/ia32/server_aggressive.emconf (working copy) @@ -34,6 +34,7 @@ VALUE_PROF.profilerType=VALUE_PROFILER VALUE_PROF.vpalgo=TNV_FIRST_N +VALUE_PROF.updateStrategy=LOCKED VALUE_PROF.vpSteadySize=4 SD1_OPT.genProfile=EDGE_PROF,VALUE_PROF SD2_OPT.useProfile=EDGE_PROF,VALUE_PROF Index: vm/jitrino/config/ia32/server.emconf =================================================================== --- vm/jitrino/config/ia32/server.emconf (revision 627115) +++ vm/jitrino/config/ia32/server.emconf (working copy) @@ -43,7 +43,7 @@ VALUE_PROF.profilerType=VALUE_PROFILER VALUE_PROF.vpalgo=TNV_FIRST_N -VALUE_PROF.updateStrategy=LOCKED +VALUE_PROF.updateStrategy=LOCKED_INSERT VALUE_PROF.vpSteadySize=4 SD1_OPT.genProfile=EDGE_PROF,VALUE_PROF SD2_OPT.useProfile=EDGE_PROF,VALUE_PROF