| 276 | } |
| 277 | |
| 278 | void BfCodeGenThread::RunLoop() |
| 279 | { |
| 280 | String threadName = StrFormat("CodeGen/Worker %d", mThreadIdx); |
| 281 | BpSetThreadName(threadName.c_str()); |
| 282 | BfpThread_SetName(NULL, threadName.c_str(), NULL); |
| 283 | |
| 284 | while (!mShuttingDown) |
| 285 | { |
| 286 | BfCodeGenRequest* request = NULL; |
| 287 | { |
| 288 | AutoCrit autoCrit(mCodeGen->mPendingRequestCritSect); |
| 289 | if (!mCodeGen->mPendingRequests.IsEmpty()) |
| 290 | { |
| 291 | request = mCodeGen->mPendingRequests[0]; |
| 292 | mCodeGen->mPendingRequests.RemoveAt(0); |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | if (request == NULL) |
| 297 | { |
| 298 | mCodeGen->mRequestEvent.WaitFor(20); |
| 299 | continue; |
| 300 | } |
| 301 | |
| 302 | auto cacheDir = GetFileDir(request->mOutFileName); |
| 303 | auto cacheFileName = GetFileName(request->mOutFileName); |
| 304 | |
| 305 | StringT<256> objFileName = request->mOutFileName + BF_OBJ_EXT; |
| 306 | |
| 307 | bool hasCacheMatch = false; |
| 308 | BfCodeGenDirectoryData* dirCache = NULL; |
| 309 | |
| 310 | Val128 hash; |
| 311 | Val128 orderedHash; |
| 312 | |
| 313 | BfLogX(2, "BfCodeGen handle %s\n", request->mOutFileName.c_str()); |
| 314 | |
| 315 | bool isLibWrite = (request->mOptions.mOptLevel == BfOptLevel_OgPlus) && (request->mOptions.mWriteToLib) && (!request->mOptions.mIsHotCompile); |
| 316 | |
| 317 | #ifndef CODEGEN_DISABLE_CACHE |
| 318 | { |
| 319 | AutoCrit autoCrit(mCodeGen->mCacheCritSect); |
| 320 | dirCache = mCodeGen->GetDirCache(cacheDir); |
| 321 | |
| 322 | //For testing only! |
| 323 | /*{ |
| 324 | FileStream fileStr; |
| 325 | fileStr.Open(request->mOutFileName + ".bfir", "wb"); |
| 326 | fileStr.Write(request->mData.mVals, request->mData.mSize); |
| 327 | }*/ |
| 328 | |
| 329 | HashContext hashCtx; |
| 330 | hashCtx.Mixin(request->mOptions.mHash); |
| 331 | hashCtx.Mixin(request->mData.mVals, request->mData.mSize); |
| 332 | hash = hashCtx.Finish128(); |
| 333 | |
| 334 | hasCacheMatch = dirCache->CheckCache(cacheFileName, hash, &orderedHash, isLibWrite); |
| 335 |
no test coverage detected