From 9eb6a84285c1597d723be13924a7ad2991cf717f Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 7 Aug 2023 15:00:38 -0700 Subject: 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 --- source/slang/slang-serialize-container.cpp | 41 +++--------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) (limited to 'source/slang/slang-serialize-container.cpp') 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& _getCandidateExtensionList( } else if (Val* val = dynamicCast(nodeBase)) { - valUses[val] = List(); - } - } - } - // 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); } } } -- cgit v1.2.3