From b9cddcb9c718f986ee5e4f7c6189ee2ebea4ace1 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Thu, 17 Sep 2020 16:47:57 -0400 Subject: Share debug information between AST and IR (#1547) * Test if blob is returned. * Rename serialize files so can be grouped. * StringRepresentationCache -> SerialStringTable * Split out SerialStringTable from slang-serialize-ir * First pass at reorganizing serialization/containers. Remain some issues about debug info. * Fix bug in calculating sourceloc. * Improve calcFixSourceLoc * Make allocations for payload RiffContainer align to at least 8 bytes. This is important for read, if the payload can contain 8 byte aligned data. Note this has no effect on Riff file format alignment rules. * Improve comments around RiffContainer and alignment. * Remove SerialStringTable, can just use StringSlicePool instead. * Typo fix for Clang/Linux. Co-authored-by: Tim Foley --- source/core/slang-riff.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'source/core/slang-riff.cpp') diff --git a/source/core/slang-riff.cpp b/source/core/slang-riff.cpp index 9fc23fbc8..2162c40be 100644 --- a/source/core/slang-riff.cpp +++ b/source/core/slang-riff.cpp @@ -313,6 +313,11 @@ struct DumpVisitor : public RiffContainer::Visitor return SLANG_OK; } +/* static */SlangResult RiffUtil::write(RiffContainer* container, Stream* stream) +{ + return write(container->getRoot(), true, stream); +} + /* static */SlangResult RiffUtil::read(Stream* stream, RiffContainer& outContainer) { typedef RiffContainer::ScopeChunk ScopeChunk; @@ -561,6 +566,20 @@ void RiffContainer::ListChunk::findContained(FourCC type, List& out) } } +RiffContainer::ListChunk* RiffContainer::ListChunk::findContainedList(FourCC type) +{ + Chunk* chunk = m_containedChunks; + while (chunk) + { + if (chunk->m_fourCC == type && chunk->m_kind == Chunk::Kind::List) + { + return static_cast(chunk); + } + chunk = chunk->m_next; + } + return nullptr; +} + RiffContainer::Data* RiffContainer::ListChunk::findContainedData(FourCC type) const { Chunk* found = findContained(type); @@ -841,11 +860,11 @@ void RiffContainer::setPayload(Data* data, const void* payload, size_t size) // Add current chunks data m_dataChunk->m_payloadSize += size; - + data->m_ownership = Ownership::Arena; data->m_size = size; - data->m_payload = m_arena.allocate(size); + data->m_payload = m_arena.allocateAligned(size, PAYLOAD_MIN_ALIGNMENT); if (payload) { @@ -922,7 +941,7 @@ RiffContainer::Data* RiffContainer::makeSingleData(DataChunk* dataChunk) // Okay lets combine all into one block const size_t payloadSize = dataChunk->calcPayloadSize(); - void* dst = m_arena.allocate(payloadSize); + void* dst = m_arena.allocateAligned(payloadSize, PAYLOAD_MIN_ALIGNMENT); dataChunk->getPayload(dst); // Remove other datas -- cgit v1.2.3