[PATCH] Speculatively instantiate archive members

Denis Protivensky dprotivensky at accesssoftek.com
Mon Jan 19 05:17:14 PST 2015


My in-place comment doesn't submit for some reason, so I put it here:

lib/ReaderWriter/FileArchive.cpp:105

  _promises[index].set_value(nullptr);

Here is also a concurrency issue.

_promises[index] returns a reference to the promise object stored in the vector. If before making set_value() the vector's memory is moved because of reallocation in the other thread (new element inserted), the returned reference will again be invalid as it was in the previous version of the code when capturing promise by reference.

One of the solutions is to avoid vector reallocations. So we need either to reserve some sufficient element count beforehand, or to change vector to deque, for example.


================
Comment at: lib/ReaderWriter/FileArchive.cpp:105
@@ +104,3 @@
+      if (instantiateMember(ci, result)) {
+        _promises[index].set_value(nullptr);
+        return;
----------------
Here is also a concurrency issue.

_promises[index] returns a reference to the promise object stored in the vector. If before making set_value() the vector's memory is moved because of reallocation in the other thread (new element inserted), the returned reference will again be invalid as it was in the previous version of the code when capturing promise by reference.

One of the solutions is to avoid vector reallocations. So we need either to reserve some sufficient element count beforehand, or to change vector to deque, for example.

http://reviews.llvm.org/D7015

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list