mirror of
https://github.com/odin-lang/Odin.git
synced 2026-07-12 19:00:28 +00:00
Commented the workaround with links to issues, and put it behind a build flag.
This commit is contained in:
@@ -520,8 +520,17 @@ gb_internal u64 type_hash_canonical_type(Type *type) {
|
||||
type_writer_make_hasher(&w, &w.hash_ctx);
|
||||
write_type_to_canonical_string(&w, type);
|
||||
u64 hash = typeid_hash_context_fini(&w.hash_ctx);
|
||||
hash &= 0x7fffffffffffffffull;
|
||||
hash = hash ? hash : 1;
|
||||
if (build_context.webkit_switch_workaround) {
|
||||
// Clear the top bit so every `typeid` is in [1, 2^63). A `switch` over a
|
||||
// typeid (e.g. a type switch over `any` in core:fmt) then has a case-value
|
||||
// span < 2^63. WebKit's B3/OMG wasm JIT computes a switch's value range as
|
||||
// a signed i64 (max - min); a span >= 2^63 overflows and makes it build a
|
||||
// pathologically-sized jump table, OOM-crashing the tab.
|
||||
// WebKit bug: https://bugs.webkit.org/show_bug.cgi?id=317022
|
||||
// Odin issue/PR: https://github.com/odin-lang/Odin/issues/6810
|
||||
hash &= 0x7fffffffffffffffull;
|
||||
hash = hash ? hash : 1;
|
||||
}
|
||||
|
||||
type->canonical_hash.store(hash, std::memory_order_relaxed);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user