Skip to content

Commit 0859078

Browse files
committed
Fifth review followups.
1 parent 0af2bde commit 0859078

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

lld/MachO/Driver.cpp

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -299,17 +299,17 @@ class SerialBackgroundQueue {
299299
std::mutex mutex;
300300

301301
public:
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,19 @@ 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;
387380
pageInQueue.queueWork(
388381
[=]() {
389382
DeferredFiles files = deferred;
390383
multiThreadedPageInBackground(files);
391-
},
392-
reap);
384+
});
393385
}
394386

395387
static InputFile *processFile(std::optional<MemoryBufferRef> buffer,
@@ -491,7 +483,7 @@ static InputFile *processFile(std::optional<MemoryBufferRef> buffer,
491483
}
492484

493485
if (archiveContents)
494-
archiveContents->emplace_back(path, isLazy, *mb);
486+
archiveContents->push_back({path, isLazy, *mb});
495487
if (!hasObjCSection(*mb))
496488
continue;
497489
if (Error e = file->fetch(c, "-ObjC"))
@@ -568,7 +560,7 @@ static void deferFile(StringRef path, bool isLazy, DeferredFiles &deferred) {
568560
if (!buffer)
569561
return;
570562
if (config->readThreads)
571-
deferred.emplace_back(path, isLazy, *buffer);
563+
deferred.push_back({path, isLazy, *buffer});
572564
else
573565
processFile(buffer, nullptr, path, LoadType::CommandLine, isLazy);
574566
}

0 commit comments

Comments
 (0)