[compiler-rt] r178855 - Remove InternalAlloc/InternalFree calls from StopTheWorld. Patch by Sergey Matveev.
Alexey Samsonov
samsonov at google.com
Fri Apr 5 00:41:21 PDT 2013
Author: samsonov
Date: Fri Apr 5 02:41:21 2013
New Revision: 178855
URL: http://llvm.org/viewvc/llvm-project?rev=178855&view=rev
Log:
Remove InternalAlloc/InternalFree calls from StopTheWorld. Patch by Sergey Matveev.
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=178855&r1=178854&r2=178855&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Fri Apr 5 02:41:21 2013
@@ -651,8 +651,9 @@ int internal_sigaltstack(const struct si
ThreadLister::ThreadLister(int pid)
: pid_(pid),
descriptor_(-1),
+ buffer_(4096),
error_(true),
- entry_((linux_dirent *)buffer_),
+ entry_((struct linux_dirent *)buffer_.data()),
bytes_read_(0) {
char task_directory_path[80];
internal_snprintf(task_directory_path, sizeof(task_directory_path),
@@ -700,8 +701,8 @@ bool ThreadLister::GetDirectoryEntries()
CHECK_GE(descriptor_, 0);
CHECK_NE(error_, true);
bytes_read_ = internal_getdents(descriptor_,
- (struct linux_dirent *)buffer_,
- sizeof(buffer_));
+ (struct linux_dirent *)buffer_.data(),
+ buffer_.size());
if (bytes_read_ < 0) {
Report("Can't read directory entries from /proc/%d/task.\n", pid_);
error_ = true;
@@ -709,7 +710,7 @@ bool ThreadLister::GetDirectoryEntries()
} else if (bytes_read_ == 0) {
return false;
}
- entry_ = (struct linux_dirent *)buffer_;
+ entry_ = (struct linux_dirent *)buffer_.data();
return true;
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h?rev=178855&r1=178854&r2=178855&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h Fri Apr 5 02:41:21 2013
@@ -13,6 +13,7 @@
#ifndef SANITIZER_LINUX_H
#define SANITIZER_LINUX_H
+#include "sanitizer_common.h"
#include "sanitizer_internal_defs.h"
struct sigaltstack;
@@ -43,7 +44,7 @@ class ThreadLister {
int pid_;
int descriptor_;
- char buffer_[4096];
+ InternalScopedBuffer<char> buffer_;
bool error_;
struct linux_dirent* entry_;
int bytes_read_;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc?rev=178855&r1=178854&r2=178855&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux.cc Fri Apr 5 02:41:21 2013
@@ -148,27 +148,24 @@ void ThreadSuspender::KillAllThreads() {
}
bool ThreadSuspender::SuspendAllThreads() {
- void *mem = InternalAlloc(sizeof(ThreadLister));
- ThreadLister *thread_lister = new(mem) ThreadLister(pid_);
+ ThreadLister thread_lister(pid_);
bool added_threads;
do {
// Run through the directory entries once.
added_threads = false;
- pid_t tid = thread_lister->GetNextTID();
+ pid_t tid = thread_lister.GetNextTID();
while (tid >= 0) {
if (SuspendThread(tid))
added_threads = true;
- tid = thread_lister->GetNextTID();
+ tid = thread_lister.GetNextTID();
}
- if (thread_lister->error()) {
+ if (thread_lister.error()) {
// Detach threads and fail.
ResumeAllThreads();
- InternalFree(mem);
return false;
}
- thread_lister->Reset();
+ thread_lister.Reset();
} while (added_threads);
- InternalFree(mem);
return true;
}
More information about the llvm-commits
mailing list