OSDN Git Service

Add a fence to ensure other threads see the correct data.
authorNicolas Geoffray <ngeoffray@google.com>
Mon, 4 Jan 2016 16:06:51 +0000 (16:06 +0000)
committerNicolas Geoffray <ngeoffray@google.com>
Mon, 4 Jan 2016 16:27:17 +0000 (16:27 +0000)
Other threads may see the ProfilingInfo pointer in the ArtMethod,
but the data they have for it is bogus due to a prior load in their
cache.

bug:26221227
Change-Id: I1fa8f088a3144df39d07a986ed57d6fc20edba18

runtime/jit/jit_code_cache.cc

index 08eac0e..c260ca4 100644 (file)
@@ -668,6 +668,11 @@ ProfilingInfo* JitCodeCache::AddProfilingInfoInternal(Thread* self,
     return nullptr;
   }
   info = new (data) ProfilingInfo(method, entries);
+
+  // Make sure other threads see the data in the profiling info object before the
+  // store in the ArtMethod's ProfilingInfo pointer.
+  QuasiAtomic::ThreadFenceRelease();
+
   method->SetProfilingInfo(info);
   profiling_infos_.push_back(info);
   return info;