diff options
| author | Yong He <yonghe@outlook.com> | 2023-08-07 15:00:38 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-07 15:00:38 -0700 |
| commit | 9eb6a84285c1597d723be13924a7ad2991cf717f (patch) | |
| tree | ad4358fb9dcbbd4b561670d02671859a217ad14a /source/slang/slang-serialize-container.cpp | |
| parent | 9ef9cc00d98d1775f0ad86efd246ca1605b3b3e4 (diff) | |
Fix `Val` deduplication bug. (#3050)
* Fix `Val` deduplication bug.
* Fix
* Concat stdlib files into a single module.
* Remove unnecessary logic in `resolve`.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-serialize-container.cpp')
| -rw-r--r-- | source/slang/slang-serialize-container.cpp | 41 |
1 files changed, 3 insertions, 38 deletions
diff --git a/source/slang/slang-serialize-container.cpp b/source/slang/slang-serialize-container.cpp index 293535b02..8105d32fb 100644 --- a/source/slang/slang-serialize-container.cpp +++ b/source/slang/slang-serialize-container.cpp @@ -566,44 +566,9 @@ static List<ExtensionDecl*>& _getCandidateExtensionList( } else if (Val* val = dynamicCast<Val>(nodeBase)) { - valUses[val] = List<Val**>(); - } - } - } - // Go through fixup locations and deduplicate Vals. - // This is needed because we currently the same Val can be serialized multiple times - // in different modules. If we have a type defined in Module A and used in Module B, - // then both serialized Module A and Module B will contain a Type Val object that refers to A. - // When we load B, we should resolve those type references to the existing Type val instead. - // This step can be avoided if we can run deduplication while deserializing, which - // requires a different way of handling Val objects. - for (auto fixup : reader.getFixUps()) - { - if (fixup.kind == PostSerializationFixUpKind::ValPtr) - { - auto list = valUses.tryGetValue(*(Val**)fixup.addressToModify); - if (list) - list->add((Val**)fixup.addressToModify); - } - } - SLANG_AST_BUILDER_RAII(astBuilder); - for (auto& valUseList : valUses) - { - auto val = valUseList.key; - auto desc = val->getDesc(); - astBuilder->m_cachedNodes.tryGetValueOrAdd(desc, val); - } - for (auto& valUseList : valUses) - { - auto val = valUseList.key; - auto newVal = val->resolve(); - if (val != newVal) - { - astBuilder->m_cachedNodes[val->getDesc()] = newVal; - for (auto use : valUseList.value) - { - if (*use != newVal) - *use = newVal; + val->_setUnique(); + auto desc = val->getDesc(); + astBuilder->m_cachedNodes.tryGetValueOrAdd(desc, val); } } } |
