Skip to content

Commit

Permalink
use AtomicMap
Browse files Browse the repository at this point in the history
Summary: This is a behavior-preserving change.

Reviewed By: thezhangwei

Differential Revision: D50439281

fbshipit-source-id: abb09c2ab58829e20477f062fe8c0e4676497381
  • Loading branch information
Nikolai Tillmann authored and facebook-github-bot committed Oct 24, 2023
1 parent e26c481 commit 3f30b75
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions opt/outliner/MethodSplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ ConcurrentSet<DexMethod*> split_splittable_closures(
const ConcurrentMap<DexType*, std::vector<SplittableClosure>>&
splittable_closures,
const std::string& name_infix,
ConcurrentMap<std::string, size_t>* uniquifiers,
AtomicMap<std::string, size_t>* uniquifiers,
Stats* stats,
std::unordered_map<DexClasses*, std::unique_ptr<DexState>>* dex_states,
ConcurrentSet<DexMethod*>* concurrent_added_methods,
Expand Down Expand Up @@ -342,8 +342,7 @@ ConcurrentSet<DexMethod*> split_splittable_closures(
auto method = splittable_closure->method_closures->method;
std::string id =
method->get_class()->str() + "." + method->get_name()->str();
size_t index{0};
uniquifiers->update(id, [&index](auto, auto& v, bool) { index = v++; });
size_t index = uniquifiers->fetch_add(id, 1);
auto new_method =
split_method(*splittable_closure, name_infix, index, dex_state.get());
if (!new_method) {
Expand Down Expand Up @@ -425,7 +424,7 @@ void split_methods_in_stores(
scope, [&](DexMethod* method, IRCode&) { methods.insert(method); });

size_t iteration{0};
ConcurrentMap<std::string, size_t> uniquifiers;
AtomicMap<std::string, size_t> uniquifiers;
while (!methods.empty() && iteration < config.max_iteration) {
TRACE(MS, 2, "=== iteration[%zu]", iteration);
Timer t("iteration " + std::to_string(iteration++));
Expand Down

0 comments on commit 3f30b75

Please sign in to comment.