[loggers] Guard object/code move events using mutexes.
authormlippautz <mlippautz@chromium.org>
Mon, 14 Sep 2015 12:06:43 +0000 (05:06 -0700)
committerCommit bot <commit-bot@chromium.org>
Mon, 14 Sep 2015 12:06:51 +0000 (12:06 +0000)
Parallel compaction, i.e., concurrently moving of objects (and code) requires
proper synchronization in the logger.

R=hpayer@chromium.org
BUG=chromium:524425
LOG=N

Review URL: https://codereview.chromium.org/1338253002

Cr-Commit-Position: refs/heads/master@{#30714}

src/heap-profiler.cc
src/heap-profiler.h
src/log.cc

index 6dc18f3..ebf3d56 100644 (file)
@@ -135,6 +135,7 @@ SnapshotObjectId HeapProfiler::GetSnapshotObjectId(Handle<Object> obj) {
 
 
 void HeapProfiler::ObjectMoveEvent(Address from, Address to, int size) {
+  base::LockGuard<base::Mutex> guard(&profiler_mutex_);
   bool known_object = ids_->MoveObject(from, to, size);
   if (!known_object && !allocation_tracker_.is_empty()) {
     allocation_tracker_->address_to_trace()->MoveObject(from, to, size);
index 80516be..20fd2c7 100644 (file)
@@ -76,6 +76,7 @@ class HeapProfiler {
   List<v8::HeapProfiler::WrapperInfoCallback> wrapper_callbacks_;
   base::SmartPointer<AllocationTracker> allocation_tracker_;
   bool is_tracking_object_moves_;
+  base::Mutex profiler_mutex_;
 };
 
 } }  // namespace v8::internal
index 0e932cf..0209f95 100644 (file)
@@ -501,6 +501,7 @@ class JitLogger : public CodeEventLogger {
                                  int length);
 
   JitCodeEventHandler code_event_handler_;
+  base::Mutex logger_mutex_;
 };
 
 
@@ -530,6 +531,7 @@ void JitLogger::LogRecordedBuffer(Code* code,
 
 
 void JitLogger::CodeMoveEvent(Address from, Address to) {
+  base::LockGuard<base::Mutex> guard(&logger_mutex_);
   Code* from_code = Code::cast(HeapObject::FromAddress(from));
 
   JitCodeEvent event;