| 1495 | } |
| 1496 | |
| 1497 | bool LlvmCodeGen::SetFunctionPointers(CodeGenCache* cache, |
| 1498 | const CodeGenCacheKey* cache_key) { |
| 1499 | // Get pointers to all codegen'd functions. |
| 1500 | for (auto& entry : fns_to_jit_compile_) { |
| 1501 | const llvm::StringRef& function_name = entry.first; |
| 1502 | |
| 1503 | LlvmFunctionWithFnPtrTargets& fn_with_targets = entry.second; |
| 1504 | llvm::Function* function = fn_with_targets.first; |
| 1505 | std::vector<CodegenFnPtrBase*>& jitted_fn_ptrs = fn_with_targets.second; |
| 1506 | |
| 1507 | void* jitted_function = nullptr; |
| 1508 | if (cache != nullptr) { |
| 1509 | DCHECK(cache_key != nullptr); |
| 1510 | // engine_cache_cached_ is used to keep the life of the object cache |
| 1511 | // in case the object cache is evicted in the global cache. |
| 1512 | DCHECK(engine_cache_cached_ != nullptr); |
| 1513 | // Using the function getFunctionAddress() with a non-existent function name would |
| 1514 | // hit an assertion during the test, could be a bug in llvm 5, need to review after |
| 1515 | // upgrade llvm. But because we already checked the names hashcode for key collision |
| 1516 | // cases, we expect all the functions should be in the cached execution engine. |
| 1517 | jitted_function = |
| 1518 | reinterpret_cast<void*>(execution_engine()->getFunctionAddress(function_name)); |
| 1519 | if (jitted_function == nullptr) { |
| 1520 | LOG(WARNING) << "Failed to get a jitted function from cache: " |
| 1521 | << function_name.data() |
| 1522 | << " key hash_code=" << cache_key->hash_code(); |
| 1523 | cache->IncHitOrMissCount(/*hit*/ false); |
| 1524 | return false; |
| 1525 | } |
| 1526 | } else { |
| 1527 | DCHECK(cache_key == nullptr); |
| 1528 | jitted_function = execution_engine()->getPointerToFunction(function); |
| 1529 | DCHECK(jitted_function != nullptr) << "Failed to jit " << function_name.data(); |
| 1530 | } |
| 1531 | |
| 1532 | DCHECK(jitted_function != nullptr); |
| 1533 | for (CodegenFnPtrBase* jitted_fn_ptr : jitted_fn_ptrs) { |
| 1534 | jitted_fn_ptr->store(jitted_function); |
| 1535 | } |
| 1536 | } |
| 1537 | |
| 1538 | return true; |
| 1539 | } |
| 1540 | |
| 1541 | void LlvmCodeGen::DestroyModule() { |
| 1542 | // Clear all references to LLVM objects owned by the module. |
nothing calls this directly
no test coverage detected