summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2020-09-18 13:35:45 -0400
committerGitHub <noreply@github.com>2020-09-18 13:35:45 -0400
commit21339e802d77981bbc64cc21cc1315cc41932f35 (patch)
treefbf9105fa191f951dc01f2315c026a9fdde644b7 /source/core
parent9a6eec6192a373d8c14073f63f68e160d762ee50 (diff)
Serialization fixes based on review of #1547 (#1551)
* 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. * Add flags to control what is output in SerialContainer. Turn off AST output for obfuscated code. Lazily create astClasses when doing write container serialization. * Typo fix for Clang/Linux. * Fixes that came out of review * TranslationUnit -> Module * TargetModule -> TargetComponent * PAYLOAD_MIN_ALIGNMENT -> kPayloadMinAlignment
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-riff.cpp4
-rw-r--r--source/core/slang-riff.h5
2 files changed, 3 insertions, 6 deletions
diff --git a/source/core/slang-riff.cpp b/source/core/slang-riff.cpp
index 2162c40be..d64cd89c7 100644
--- a/source/core/slang-riff.cpp
+++ b/source/core/slang-riff.cpp
@@ -864,7 +864,7 @@ void RiffContainer::setPayload(Data* data, const void* payload, size_t size)
data->m_ownership = Ownership::Arena;
data->m_size = size;
- data->m_payload = m_arena.allocateAligned(size, PAYLOAD_MIN_ALIGNMENT);
+ data->m_payload = m_arena.allocateAligned(size, kPayloadMinAlignment);
if (payload)
{
@@ -941,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.allocateAligned(payloadSize, PAYLOAD_MIN_ALIGNMENT);
+ void* dst = m_arena.allocateAligned(payloadSize, kPayloadMinAlignment);
dataChunk->getPayload(dst);
// Remove other datas
diff --git a/source/core/slang-riff.h b/source/core/slang-riff.h
index 43c5e285d..5a753b6d6 100644
--- a/source/core/slang-riff.h
+++ b/source/core/slang-riff.h
@@ -177,14 +177,11 @@ need to be recalculated, before serialization.
class RiffContainer
{
public:
- enum
- {
// This alignment is only made for arena based allocations.
// For external blocks it's client code to have appropriate alignment.
// This is needed because when reading a RiffContainer, all allocation is arena based, and
// if the payload contains 8 byte aligned data, the overall payload needs to be 8 byte aligned.
- PAYLOAD_MIN_ALIGNMENT = 8,
- };
+ static const size_t kPayloadMinAlignment = 8;
enum class Ownership
{