@@ -299,17 +299,17 @@ class SerialBackgroundQueue {
299299 std::mutex mutex;
300300
301301public:
302- void queueWork (std::function<void ()> work, bool reap ) {
302+ void queueWork (std::function<void ()> work) {
303303 mutex.lock ();
304- if (running && ( queue.empty () || reap )) {
304+ if (running && queue.empty ()) {
305305 mutex.unlock ();
306306 running->join ();
307307 mutex.lock ();
308308 delete running;
309309 running = nullptr ;
310310 }
311311
312- if (!reap ) {
312+ if (work ) {
313313 queue.emplace_back (std::move (work));
314314 if (!running)
315315 running = new std::thread ([&]() {
@@ -332,11 +332,6 @@ class SerialBackgroundQueue {
332332 }
333333};
334334
335- #ifndef NDEBUG
336- #include < iomanip>
337- #include < iostream>
338- #endif
339-
340335// Most input files have been mapped but not yet paged in.
341336// This code forces the page-ins on multiple threads so
342337// the process is not stalled waiting on disk buffer i/o.
@@ -374,22 +369,18 @@ void multiThreadedPageInBackground(DeferredFiles &deferred) {
374369#ifndef NDEBUG
375370 auto dt = high_resolution_clock::now () - t0;
376371 if (Process::GetEnv (" LLD_MULTI_THREAD_PAGE" ))
377- std::cerr << " multiThreadedPageIn " << totalBytes << " /"
378- << numDeferedFilesTouched << " /" << deferred.size () << " /"
379- << std::setprecision (4 )
380- << duration_cast<milliseconds>(dt).count () / 1000 . << " \n " ;
372+ llvm::dbgs () << " multiThreadedPageIn " << totalBytes << " /"
373+ << numDeferedFilesTouched << " /" << deferred.size () << " /"
374+ << duration_cast<milliseconds>(dt).count () / 1000 . << " \n " ;
381375#endif
382376}
383377
384- static void multiThreadedPageIn (const DeferredFiles &deferred,
385- bool reap = false ) {
378+ static void multiThreadedPageIn (const DeferredFiles &deferred) {
386379 static SerialBackgroundQueue pageInQueue;
387- pageInQueue.queueWork (
388- [=]() {
389- DeferredFiles files = deferred;
390- multiThreadedPageInBackground (files);
391- },
392- reap);
380+ pageInQueue.queueWork ([=]() {
381+ DeferredFiles files = deferred;
382+ multiThreadedPageInBackground (files);
383+ });
393384}
394385
395386static InputFile *processFile (std::optional<MemoryBufferRef> buffer,
@@ -491,7 +482,7 @@ static InputFile *processFile(std::optional<MemoryBufferRef> buffer,
491482 }
492483
493484 if (archiveContents)
494- archiveContents->emplace_back ( path, isLazy, *mb);
485+ archiveContents->push_back ({ path, isLazy, *mb} );
495486 if (!hasObjCSection (*mb))
496487 continue ;
497488 if (Error e = file->fetch (c, " -ObjC" ))
@@ -568,7 +559,7 @@ static void deferFile(StringRef path, bool isLazy, DeferredFiles &deferred) {
568559 if (!buffer)
569560 return ;
570561 if (config->readThreads )
571- deferred.emplace_back ( path, isLazy, *buffer);
562+ deferred.push_back ({ path, isLazy, *buffer} );
572563 else
573564 processFile (buffer, nullptr , path, LoadType::CommandLine, isLazy);
574565}
0 commit comments