[PATCH] LLD: Implement our own future and use that for FileArchive::preload().

Shankar Kalpathi Easwaran shankarke at gmail.com
Tue Mar 3 08:53:46 PST 2015


================
Comment at: include/lld/Core/Parallel.h:77
@@ +76,3 @@
+/// https://gcc.gnu.org/ml/gcc-patches/2014-05/msg01389.html
+template<typename T> class Future {
+public:
----------------
there is only one usage of Future with lld::File, Why do we want to make this a template ?

================
Comment at: lib/ReaderWriter/FileArchive.cpp:63-69
@@ -62,8 +62,9 @@
     {
       std::lock_guard<std::mutex> lock(_mutex);
       auto it = _preloaded.find(memberStart);
       if (it != _preloaded.end()) {
-        std::future<const File *> &future = it->second;
-        return future.get();
+        std::unique_ptr<Future<const File *>> &p = it->second;
+        Future<const File *> *future = p.get();
+        return future->get();
       }
     }
----------------
The _preloaded map could get resized here ? Can we resize the map in advance since we know how many members are in the archive ?

================
Comment at: lib/ReaderWriter/FileArchive.cpp:261-262
@@ -263,4 +260,4 @@
   std::unique_ptr<Archive> _archive;
   mutable MemberMap _symbolMemberMap;
   mutable InstantiatedSet _membersInstantiated;
   atom_collection_vector<DefinedAtom> _definedAtoms;
----------------
looks like/most of the members are mutable, I think this needs to be made non-const.

================
Comment at: lib/ReaderWriter/FileArchive.cpp:269
@@ -271,4 +268,3 @@
   mutable std::vector<std::unique_ptr<MemoryBuffer>> _memberBuffers;
-  mutable std::map<const char *, std::future<const File *>> _preloaded;
-  mutable std::vector<std::unique_ptr<std::promise<const File *>>> _promises;
+  mutable std::map<const char *, std::unique_ptr<Future<const File *>>> _preloaded;
   mutable std::mutex _mutex;
----------------
llvm::DenseMap ?

http://reviews.llvm.org/D8025

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






More information about the llvm-commits mailing list