source: icGREP/icgrep-devel/icgrep/grep_engine.cpp @ 5817

Last change on this file since 5817 was 5817, checked in by cameron, 15 months ago

Toolchain restructuring; creating a total order for memoizer lessThan

File size: 20.1 KB
Line 
1/*
2 *  Copyright (c) 2017 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#include "grep_engine.h"
8#include "grep_interface.h"
9#include <llvm/IR/Module.h>
10#include <boost/filesystem.hpp>
11#include <UCD/resolve_properties.h>
12#include <kernels/charclasses.h>
13#include <kernels/cc_kernel.h>
14#include <kernels/grep_kernel.h>
15#include <kernels/linebreak_kernel.h>
16#include <kernels/streams_merge.h>
17#include <kernels/source_kernel.h>
18#include <kernels/s2p_kernel.h>
19#include <kernels/scanmatchgen.h>
20#include <kernels/streamset.h>
21#include <kernels/until_n.h>
22#include <kernels/kernel_builder.h>
23#include <pablo/pablo_kernel.h>
24#include <re/re_cc.h>
25#include <re/casing.h>
26#include <re/exclude_CC.h>
27#include <re/re_toolchain.h>
28#include <toolchain/toolchain.h>
29#include <re/re_name_resolve.h>
30#include <re/re_collect_unicodesets.h>
31#include <re/re_multiplex.h>
32#include <re/grapheme_clusters.h>
33#include <re/printer_re.h>
34#include <toolchain/toolchain.h>
35#include <toolchain/cpudriver.h>
36#include <iostream>
37#include <cc/multiplex_CCs.h>
38#include <llvm/Support/raw_ostream.h>
39#include <util/aligned_allocator.h>
40#include <sys/stat.h>
41#include <fcntl.h>
42#include <errno.h>
43#include <llvm/ADT/STLExtras.h> // for make_unique
44#include <llvm/Support/CommandLine.h>
45#include <llvm/Support/Debug.h>
46#include <sched.h>
47
48using namespace parabix;
49using namespace llvm;
50using namespace cc;
51
52static cl::opt<int> Threads("t", cl::desc("Total number of threads."), cl::init(2));
53
54namespace grep {
55
56// Grep Engine construction and initialization.
57
58GrepEngine::GrepEngine() :
59    mGrepDriver(nullptr),
60    mNextFileToGrep(0),
61    mNextFileToPrint(0),
62    grepMatchFound(false),
63    mMoveMatchesToEOL(true),
64    mEngineThread(pthread_self()) {}
65
66GrepEngine::~GrepEngine() {
67    delete mGrepDriver;
68}
69
70QuietModeEngine::QuietModeEngine() : GrepEngine() {
71    mMoveMatchesToEOL = false;
72}
73
74MatchOnlyEngine::MatchOnlyEngine(bool showFilesWithoutMatch) :
75    GrepEngine(), mRequiredCount(showFilesWithoutMatch) {
76    mFileSuffix = NullFlag ? std::string("\0", 1) : "\n";
77    mMoveMatchesToEOL = false;
78}
79
80CountOnlyEngine::CountOnlyEngine() : GrepEngine() {
81    mFileSuffix = ":";
82}
83
84EmitMatchesEngine::EmitMatchesEngine() : GrepEngine() {
85    mFileSuffix = InitialTabFlag ? "\t:" : ":";
86    if (LineRegexpFlag) mMoveMatchesToEOL = false;
87}
88
89void GrepEngine::initFileResult(std::vector<std::string> & filenames) {
90    const unsigned n = filenames.size();
91    mResultStrs.resize(n);
92    mFileStatus.resize(n, FileStatus::Pending);
93    inputFiles = filenames;
94}
95
96// Code Generation
97//
98// All engines share a common pipeline to compute a stream of Matches from a given input Bytestream.
99
100std::pair<StreamSetBuffer *, StreamSetBuffer *> GrepEngine::grepPipeline(std::vector<re::RE *> & REs, StreamSetBuffer * ByteStream) {
101    auto & idb = mGrepDriver->getBuilder();
102    const unsigned segmentSize = codegen::SegmentSize;
103    const unsigned bufferSegments = codegen::BufferSegments * codegen::ThreadNum;
104    const unsigned encodingBits = 8;
105
106    StreamSetBuffer * BasisBits = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(encodingBits, 1), segmentSize * bufferSegments);
107    kernel::Kernel * s2pk = mGrepDriver->addKernelInstance<kernel::S2PKernel>(idb);
108    mGrepDriver->makeKernelCall(s2pk, {ByteStream}, {BasisBits});
109
110    StreamSetBuffer * LineFeedStream = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
111    kernel::Kernel * linefeedK = mGrepDriver->addKernelInstance<kernel::LineFeedKernelBuilder>(idb, encodingBits);
112    mGrepDriver->makeKernelCall(linefeedK, {BasisBits}, {LineFeedStream});
113
114    StreamSetBuffer * LineBreakStream = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
115    StreamSetBuffer * CRLFStream = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
116    kernel::Kernel * linebreakK = mGrepDriver->addKernelInstance<kernel::LineBreakKernelBuilder>(idb, encodingBits);
117    mGrepDriver->makeKernelCall(linebreakK, {BasisBits, LineFeedStream}, {LineBreakStream, CRLFStream});
118
119    kernel::Kernel * requiredStreamsK = mGrepDriver->addKernelInstance<kernel::RequiredStreams_UTF8>(idb);
120    StreamSetBuffer * RequiredStreams = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(3, 1), segmentSize * bufferSegments);
121    mGrepDriver->makeKernelCall(requiredStreamsK, {BasisBits}, {RequiredStreams});
122
123    const auto n = REs.size();
124    std::vector<std::vector<re::CC *>> charclasses(n);
125    std::vector<StreamSetBuffer *> MatchResultsBufs(n);
126
127    for(unsigned i = 0; i < n; ++i) {
128        REs[i] = resolveModesAndExternalSymbols(REs[i]);
129        REs[i] = excludeUnicodeLineBreak(REs[i]);
130//#define USE_MULTIPLEX_CC
131#ifdef USE_MULTIPLEX_CC
132        REs[i] = regular_expression_passes(REs[i]);
133        const std::vector<const re::CC *> UnicodeSets = re::collectUnicodeSets(REs[i]);
134        if (UnicodeSets.size() <= 1) {
135            StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
136            kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, REs[i]);
137            mGrepDriver->makeKernelCall(icgrepK, {BasisBits, LineBreakStream, CRLFStream, RequiredStreams}, {MatchResults});
138            MatchResultsBufs[i] = MatchResults;
139        }
140        else {
141            mpx = make_unique<MultiplexedAlphabet>("mpx", UnicodeSets);
142            REs[i] = transformCCs(mpx.get(), REs[i]);
143            std::vector<re::CC *> mpx_basis = mpx->getMultiplexedCCs();
144            auto numOfCharacterClasses = mpx_basis.size();
145            StreamSetBuffer * CharClasses = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(numOfCharacterClasses), segmentSize * bufferSegments);
146            kernel::Kernel * ccK = mGrepDriver->addKernelInstance<kernel::CharClassesKernel>(idb, std::move(mpx_basis));
147            mGrepDriver->makeKernelCall(ccK, {BasisBits}, {CharClasses});
148            StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
149            kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, REs[i], std::vector<cc::Alphabet *>{mpx.get()});
150            mGrepDriver->makeKernelCall(icgrepK, {BasisBits, LineBreakStream, CRLFStream, RequiredStreams, CharClasses}, {MatchResults});
151            MatchResultsBufs[i] = MatchResults;
152        }
153#else
154        REs[i] = regular_expression_passes(REs[i]);
155        StreamSetBuffer * MatchResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
156        kernel::Kernel * icgrepK = mGrepDriver->addKernelInstance<kernel::ICGrepKernel>(idb, REs[i]);
157        mGrepDriver->makeKernelCall(icgrepK, {BasisBits, LineBreakStream, CRLFStream, RequiredStreams}, {MatchResults});
158        MatchResultsBufs[i] = MatchResults;
159#endif
160    }
161    StreamSetBuffer * MergedResults = MatchResultsBufs[0];
162    if (REs.size() > 1) {
163        MergedResults = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
164        kernel::Kernel * streamsMergeK = mGrepDriver->addKernelInstance<kernel::StreamsMerge>(idb, 1, REs.size());
165        mGrepDriver->makeKernelCall(streamsMergeK, MatchResultsBufs, {MergedResults});
166    }
167    StreamSetBuffer * Matches = MergedResults;
168
169    if (mMoveMatchesToEOL) {
170        StreamSetBuffer * OriginalMatches = Matches;
171        kernel::Kernel * matchedLinesK = mGrepDriver->addKernelInstance<kernel::MatchedLinesKernel>(idb);
172        Matches = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
173        mGrepDriver->makeKernelCall(matchedLinesK, {OriginalMatches, LineBreakStream}, {Matches});
174    }
175
176    if (InvertMatchFlag) {
177        kernel::Kernel * invertK = mGrepDriver->addKernelInstance<kernel::InvertMatchesKernel>(idb);
178        StreamSetBuffer * OriginalMatches = Matches;
179        Matches = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
180        mGrepDriver->makeKernelCall(invertK, {OriginalMatches, LineBreakStream}, {Matches});
181    }
182    if (MaxCountFlag > 0) {
183        kernel::Kernel * untilK = mGrepDriver->addKernelInstance<kernel::UntilNkernel>(idb);
184        untilK->setInitialArguments({idb->getSize(MaxCountFlag)});
185        StreamSetBuffer * AllMatches = Matches;
186        Matches = mGrepDriver->addBuffer<CircularBuffer>(idb, idb->getStreamSetTy(1, 1), segmentSize * bufferSegments);
187        mGrepDriver->makeKernelCall(untilK, {AllMatches}, {Matches});
188    }
189    return std::pair<StreamSetBuffer *, StreamSetBuffer *>(LineBreakStream, Matches);
190}
191
192// The QuietMode, MatchOnly and CountOnly engines share a common code generation main function,
193// which returns a count of the matches found (possibly subject to a MaxCount).
194//
195
196void GrepEngine::grepCodeGen(std::vector<re::RE *> REs) {
197
198    assert (mGrepDriver == nullptr);
199    mGrepDriver = new ParabixDriver("engine");
200    auto & idb = mGrepDriver->getBuilder();
201    Module * M = idb->getModule();
202
203    const auto segmentSize = codegen::SegmentSize;
204    const auto bufferSegments = codegen::BufferSegments * codegen::ThreadNum;
205
206    const unsigned encodingBits = 8;
207
208    Function * mainFunc = cast<Function>(M->getOrInsertFunction("Main", idb->getInt64Ty(), idb->getInt32Ty(), nullptr));
209    mainFunc->setCallingConv(CallingConv::C);
210    idb->SetInsertPoint(BasicBlock::Create(M->getContext(), "entry", mainFunc, 0));
211    auto args = mainFunc->arg_begin();
212
213    Value * const fileDescriptor = &*(args++);
214    fileDescriptor->setName("fileDescriptor");
215
216    StreamSetBuffer * ByteStream = mGrepDriver->addBuffer<SourceBuffer>(idb, idb->getStreamSetTy(1, encodingBits));
217    kernel::Kernel * sourceK = mGrepDriver->addKernelInstance<kernel::FDSourceKernel>(idb, segmentSize * bufferSegments);
218    sourceK->setInitialArguments({fileDescriptor});
219    mGrepDriver->makeKernelCall(sourceK, {}, {ByteStream});
220
221    StreamSetBuffer * LineBreakStream;
222    StreamSetBuffer * Matches;
223    std::tie(LineBreakStream, Matches) = grepPipeline(REs, ByteStream);
224
225    kernel::Kernel * matchCountK = mGrepDriver->addKernelInstance<kernel::PopcountKernel>(idb);
226    mGrepDriver->makeKernelCall(matchCountK, {Matches}, {});
227    mGrepDriver->generatePipelineIR();
228    idb->setKernel(matchCountK);
229    Value * matchedLineCount = idb->getAccumulator("countResult");
230    matchedLineCount = idb->CreateZExt(matchedLineCount, idb->getInt64Ty());
231    mGrepDriver->deallocateBuffers();
232    idb->CreateRet(matchedLineCount);
233    mGrepDriver->finalizeObject();
234}
235
236//
237// The EmitMatches engine uses an EmitMatchesAccumulator object to concatenate together
238// matched lines.
239
240class EmitMatch : public MatchAccumulator {
241    friend class EmitMatchesEngine;
242public:
243    EmitMatch(std::string linePrefix, std::ostringstream & strm) : mLinePrefix(linePrefix), mLineCount(0), mTerminated(true), mResultStr(strm) {}
244    void accumulate_match(const size_t lineNum, char * line_start, char * line_end) override;
245    void finalize_match(char * buffer_end) override;
246protected:
247    std::string mLinePrefix;
248    size_t mLineCount;
249    bool mTerminated;
250    std::ostringstream & mResultStr;
251};
252
253//
254//  Default Report Match:  lines are emitted with whatever line terminators are found in the
255//  input.  However, if the final line is not terminated, a new line is appended.
256//
257void EmitMatch::accumulate_match (const size_t lineNum, char * line_start, char * line_end) {
258    if (WithFilenameFlag) {
259        mResultStr << mLinePrefix;
260    }
261    if (LineNumberFlag) {
262        // Internally line numbers are counted from 0.  For display, adjust
263        // the line number so that lines are numbered from 1.
264        if (InitialTabFlag) {
265            mResultStr << lineNum+1 << "\t:";
266        }
267        else {
268            mResultStr << lineNum+1 << ":";
269        }
270    }
271    size_t bytes = line_end - line_start + 1;
272    mResultStr.write(line_start, bytes);
273    mLineCount++;
274    unsigned last_byte = *line_end;
275    mTerminated = (last_byte >= 0x0A) && (last_byte <= 0x0D);
276    if (LLVM_UNLIKELY(!mTerminated)) {
277        if (last_byte == 0x85) {  //  Possible NEL terminator.
278            mTerminated = (bytes >= 2) && (static_cast<unsigned>(line_end[-1]) == 0xC2);
279        }
280        else {
281            // Possible LS or PS terminators.
282            mTerminated = (bytes >= 3) && (static_cast<unsigned>(line_end[-2]) == 0xE2)
283                                       && (static_cast<unsigned>(line_end[-1]) == 0x80)
284                                       && ((last_byte == 0xA8) || (last_byte == 0xA9));
285        }
286    }
287}
288
289void EmitMatch::finalize_match(char * buffer_end) {
290    if (!mTerminated) mResultStr << "\n";
291}
292
293void EmitMatchesEngine::grepCodeGen(std::vector<re::RE *> REs) {
294    assert (mGrepDriver == nullptr);
295    mGrepDriver = new ParabixDriver("engine");
296    auto & idb = mGrepDriver->getBuilder();
297    Module * M = idb->getModule();
298
299    const auto segmentSize = codegen::SegmentSize;
300    const auto bufferSegments = codegen::BufferSegments * codegen::ThreadNum;
301    const unsigned encodingBits = 8;
302
303    Function * mainFunc = cast<Function>(M->getOrInsertFunction("Main", idb->getInt64Ty(), idb->getInt32Ty(), idb->getIntAddrTy(), nullptr));
304    mainFunc->setCallingConv(CallingConv::C);
305    idb->SetInsertPoint(BasicBlock::Create(M->getContext(), "entry", mainFunc, 0));
306    auto args = mainFunc->arg_begin();
307
308    Value * const fileDescriptor = &*(args++);
309    fileDescriptor->setName("fileDescriptor");
310    Value * match_accumulator = &*(args++);
311    match_accumulator->setName("match_accumulator");
312
313    StreamSetBuffer * ByteStream = mGrepDriver->addBuffer<SourceBuffer>(idb, idb->getStreamSetTy(1, encodingBits));
314    kernel::Kernel * sourceK = mGrepDriver->addKernelInstance<kernel::FDSourceKernel>(idb, segmentSize * bufferSegments);
315    sourceK->setInitialArguments({fileDescriptor});
316    mGrepDriver->makeKernelCall(sourceK, {}, {ByteStream});
317
318    StreamSetBuffer * LineBreakStream;
319    StreamSetBuffer * Matches;
320    std::tie(LineBreakStream, Matches) = grepPipeline(REs, ByteStream);
321
322    kernel::Kernel * scanMatchK = mGrepDriver->addKernelInstance<kernel::ScanMatchKernel>(idb);
323    scanMatchK->setInitialArguments({match_accumulator});
324    mGrepDriver->makeKernelCall(scanMatchK, {Matches, LineBreakStream, ByteStream}, {});
325    mGrepDriver->LinkFunction(*scanMatchK, "accumulate_match_wrapper", &accumulate_match_wrapper);
326    mGrepDriver->LinkFunction(*scanMatchK, "finalize_match_wrapper", &finalize_match_wrapper);
327
328    mGrepDriver->generatePipelineIR();
329    mGrepDriver->deallocateBuffers();
330    idb->CreateRet(idb->getInt64(0));
331    mGrepDriver->finalizeObject();
332}
333
334
335//
336//  The doGrep methods apply a GrepEngine to a single file, processing the results
337//  differently based on the engine type.
338
339uint64_t GrepEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) {
340    typedef uint64_t (*GrepFunctionType)(int32_t fileDescriptor);
341    auto f = reinterpret_cast<GrepFunctionType>(mGrepDriver->getMain());
342
343    int32_t fileDescriptor = openFile(fileName, mResultStrs[fileIdx]);
344    if (fileDescriptor == -1) return 0;
345
346    uint64_t grepResult = f(fileDescriptor);
347    close(fileDescriptor);
348    return grepResult;
349}
350
351uint64_t CountOnlyEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) {
352    uint64_t grepResult = GrepEngine::doGrep(fileName, fileIdx);
353    if (WithFilenameFlag) mResultStrs[fileIdx] << linePrefix(fileName);
354    mResultStrs[fileIdx] << grepResult << "\n";
355    return grepResult;
356}
357
358std::string GrepEngine::linePrefix(std::string fileName) {
359    if (fileName == "-") {
360        return LabelFlag + mFileSuffix;
361    }
362    else {
363        return fileName + mFileSuffix;
364    }
365}
366
367uint64_t MatchOnlyEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) {
368    uint64_t grepResult = GrepEngine::doGrep(fileName, fileIdx);
369    if (grepResult == mRequiredCount) {
370       mResultStrs[fileIdx] << linePrefix(fileName);
371    }
372    return grepResult;
373}
374
375uint64_t EmitMatchesEngine::doGrep(const std::string & fileName, const uint32_t fileIdx) {
376    typedef uint64_t (*GrepFunctionType)(int32_t fileDescriptor, intptr_t accum_addr);
377    auto f = reinterpret_cast<GrepFunctionType>(mGrepDriver->getMain());
378
379    int32_t fileDescriptor = openFile(fileName, mResultStrs[fileIdx]);
380    if (fileDescriptor == -1) return 0;
381    EmitMatch accum(linePrefix(fileName), mResultStrs[fileIdx]);
382    f(fileDescriptor, reinterpret_cast<intptr_t>(&accum));
383    close(fileDescriptor);
384    if (accum.mLineCount > 0) grepMatchFound = true;
385    return accum.mLineCount;
386}
387
388// Open a file and return its file desciptor.
389int32_t GrepEngine::openFile(const std::string & fileName, std::ostringstream & msgstrm) {
390    if (fileName == "-") {
391        return STDIN_FILENO;
392    }
393    else {
394        struct stat sb;
395        int32_t fileDescriptor = open(fileName.c_str(), O_RDONLY);
396        if (LLVM_UNLIKELY(fileDescriptor == -1)) {
397            if (!NoMessagesFlag) {
398                if (errno == EACCES) {
399                    msgstrm << "icgrep: " << fileName << ": Permission denied.\n";
400                }
401                else if (errno == ENOENT) {
402                    msgstrm << "icgrep: " << fileName << ": No such file.\n";
403                }
404                else {
405                    msgstrm << "icgrep: " << fileName << ": Failed.\n";
406                }
407            }
408            return fileDescriptor;
409        }
410        if (stat(fileName.c_str(), &sb) == 0 && S_ISDIR(sb.st_mode)) {
411            if (!NoMessagesFlag) {
412                msgstrm << "icgrep: " << fileName << ": Is a directory.\n";
413            }
414            close(fileDescriptor);
415            return -1;
416        }
417        return fileDescriptor;
418    }
419}
420
421// The process of searching a group of files may use a sequential or a task
422// parallel approach.
423
424void * DoGrepThreadFunction(void *args) {
425    return reinterpret_cast<GrepEngine *>(args)->DoGrepThreadMethod();
426}
427
428bool GrepEngine::searchAllFiles() {
429    const unsigned numOfThreads = std::min(static_cast<unsigned>(Threads), static_cast<unsigned>(inputFiles.size())); 
430    std::vector<pthread_t> threads(numOfThreads);
431
432    for(unsigned long i = 1; i < numOfThreads; ++i) {
433        const int rc = pthread_create(&threads[i], nullptr, DoGrepThreadFunction, (void *)this);
434        if (rc) {
435            llvm::report_fatal_error("Failed to create thread: code " + std::to_string(rc));
436        }
437    }
438    // Main thread also does the work;
439
440    DoGrepThreadMethod();
441    for(unsigned i = 1; i < numOfThreads; ++i) {
442        void * status = nullptr;
443        const int rc = pthread_join(threads[i], &status);
444        if (rc) {
445            llvm::report_fatal_error("Failed to join thread: code " + std::to_string(rc));
446        }
447    }
448    return grepMatchFound;
449}
450
451
452// DoGrep thread function.
453void * GrepEngine::DoGrepThreadMethod() {
454
455    unsigned fileIdx = mNextFileToGrep++;
456    while (fileIdx < inputFiles.size()) {
457        const auto grepResult = doGrep(inputFiles[fileIdx], fileIdx);
458        mFileStatus[fileIdx] = FileStatus::GrepComplete;
459        if (grepResult > 0) {
460            grepMatchFound = true;
461        }
462        if (QuietMode && grepMatchFound) {
463            if (pthread_self() != mEngineThread) {
464                pthread_exit(nullptr);
465            }
466            return nullptr;
467        }
468        fileIdx = mNextFileToGrep++;
469    }
470
471    unsigned printIdx = mNextFileToPrint++;
472    while (printIdx < inputFiles.size()) {
473        const bool readyToPrint = ((printIdx == 0) || (mFileStatus[printIdx - 1] == FileStatus::PrintComplete)) && (mFileStatus[printIdx] == FileStatus::GrepComplete);
474        if (readyToPrint) {
475            const auto output = mResultStrs[printIdx].str();
476            if (!output.empty()) {
477                llvm::outs() << output;
478            }
479            mFileStatus[printIdx] = FileStatus::PrintComplete;
480            printIdx = mNextFileToPrint++;
481        } else {
482            mGrepDriver->performIncrementalCacheCleanupStep();
483        }
484        sched_yield();
485    }
486
487    if (pthread_self() != mEngineThread) {
488        pthread_exit(nullptr);
489    } else {
490        // Always perform one final cache cleanup step.
491        mGrepDriver->performIncrementalCacheCleanupStep();
492    }
493    return nullptr;
494}
495
496}
Note: See TracBrowser for help on using the repository browser.