diff options
| author | gingerBill <bill@gingerbill.org> | 2025-02-20 14:10:45 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2025-02-20 14:10:45 +0000 |
| commit | 5489a889832ac05e5edca7355b4601c1a82c2d27 (patch) | |
| tree | d78b2b7852ff003d5f7c40c8a91c5332776f695c /src/llvm_backend.cpp | |
| parent | c25ac939d4bd86d51c383e96232da1d241c6a504 (diff) | |
Change `typeid` definition to be based around the canonical type hash
`typeid` used to be a fancy index with extra metadata stored on it. Now it is direct hash of the type.
This is safe to do in practice since any possible collisions are checked at compile time AND the chances of having a 1% collision are around 1 in 600K (see the Birthday Paradox).
Therefore accessing a `^Type_Info` is now a hash table lookup with linear probing. The table is twice the size than necessary so prevent too much probing due to an overly dense hash table.
Diffstat (limited to 'src/llvm_backend.cpp')
| -rw-r--r-- | src/llvm_backend.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 908117501..4ebcf7578 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -3154,9 +3154,10 @@ gb_internal bool lb_generate_code(lbGenerator *gen) { lbModule *m = default_module; { // Add type info data - GB_ASSERT_MSG(info->minimum_dependency_type_info_index_map.count == info->type_info_types.count, "%tu vs %tu", info->minimum_dependency_type_info_index_map.count, info->type_info_types.count); + // GB_ASSERT_MSG(info->minimum_dependency_type_info_index_map.count == info->type_info_types.count, "%tu vs %tu", info->minimum_dependency_type_info_index_map.count, info->type_info_types.count); - isize max_type_info_count = info->minimum_dependency_type_info_index_map.count+1; + // isize max_type_info_count = info->minimum_dependency_type_info_index_map.count+1; + isize max_type_info_count = info->type_info_types_hash_map.count; Type *t = alloc_type_array(t_type_info_ptr, max_type_info_count); // IMPORTANT NOTE(bill): As LLVM does not have a union type, an array of unions cannot be initialized |