[PATCH] D32189: Implement StopTheWorld for Darwin

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 18 16:06:34 PDT 2017


kubamracek added inline comments.


================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_mac.cc:74-78
+  for (unsigned int i = 0; i < num_threads; ++i) {
+    if (threads[i] == mach_thread_self() ||
+        suspended_threads_list.ContainsThread(threads[i])) {
+      continue;
+    }
----------------
Do you expect any performance issues from this O(n^2) behavior?  What is the maximum reasonable thread count?  Why do we even need to check for `ContainsThread`?  Do you expect that `threads` contains duplicates?


================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_mac.cc:87-89
+    if (threads[i] == mach_thread_self()) {
+      continue;
+    }
----------------
Can we iterate over `suspended_thread_list` instead and skip the check for `mach_thread_self`?


================
Comment at: lib/sanitizer_common/sanitizer_stoptheworld_mac.cc:96-97
 void StopTheWorld(StopTheWorldCallback callback, void *argument) {
-  CHECK(0 && "unimplemented");
+  struct RunThreadArgs arg = { callback, argument };
+  pthread_t run_thread = (pthread_t) internal_start_thread(RunThread, &arg);
+  internal_join_thread(run_thread);
----------------
clang-format please


https://reviews.llvm.org/D32189





More information about the llvm-commits mailing list