[PATCH] Speculatively instantiate archive members

Rui Ueyama ruiu at google.com
Mon Jan 19 08:47:30 PST 2015


Denis,

Thank you for reviewing! This code was submitted in r226336 and the final
code doesn't have the issues that you pointed out, I believe.

On Mon, Jan 19, 2015 at 5:17 AM, Denis Protivensky <
dprotivensky at accesssoftek.com> wrote:

> 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/
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150119/20b56b22/attachment.html>


More information about the llvm-commits mailing list