| 3376 | } |
| 3377 | |
| 3378 | Program_impl::Program_impl(JitCache_impl& cache, std::string source, |
| 3379 | jitify::detail::vector<std::string> headers, |
| 3380 | jitify::detail::vector<std::string> options, |
| 3381 | file_callback_type file_callback) |
| 3382 | : _cache(cache) { |
| 3383 | // Compute hash of source, headers and options |
| 3384 | std::string options_string = reflection::reflect_list(options); |
| 3385 | using detail::hash_combine; |
| 3386 | using detail::hash_larson64; |
| 3387 | _hash = hash_combine(hash_larson64(source.c_str()), |
| 3388 | hash_larson64(options_string.c_str())); |
| 3389 | for (size_t i = 0; i < headers.size(); ++i) { |
| 3390 | _hash = hash_combine(_hash, hash_larson64(headers[i].c_str())); |
| 3391 | } |
| 3392 | _hash = hash_combine(_hash, (uint64_t)file_callback); |
| 3393 | // Add pre-include built-in JIT-safe headers |
| 3394 | for (int i = 0; i < detail::preinclude_jitsafe_headers_count; ++i) { |
| 3395 | const char* hdr_name = detail::preinclude_jitsafe_header_names[i]; |
| 3396 | const std::string& hdr_source = |
| 3397 | detail::get_jitsafe_headers_map().at(hdr_name); |
| 3398 | headers.push_back(std::string(hdr_name) + "\n" + hdr_source); |
| 3399 | } |
| 3400 | // Merge options from parent |
| 3401 | options.insert(options.end(), _cache._options.begin(), _cache._options.end()); |
| 3402 | // Load sources |
| 3403 | #if JITIFY_THREAD_SAFE |
| 3404 | std::lock_guard<std::mutex> lock(cache._program_cache_mutex); |
| 3405 | #endif |
| 3406 | if (!cache._program_config_cache.contains(_hash)) { |
| 3407 | _config = &cache._program_config_cache.insert(_hash); |
| 3408 | this->load_sources(source, headers, options, file_callback); |
| 3409 | } else { |
| 3410 | _config = &cache._program_config_cache.get(_hash); |
| 3411 | } |
| 3412 | } |
| 3413 | |
| 3414 | inline void Program_impl::load_sources(std::string source, |
| 3415 | std::vector<std::string> headers, |
nothing calls this directly
no test coverage detected