Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions source/slang/slang-fossil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ Fossil::AnyValPtr getRootValue(void const* data, Size size)

} // namespace Fossil

Fossil::AnyValRef Fossil::ValRef<FossilizedContainerObjBase>::getElement(
Index index) const
Fossil::AnyValRef Fossil::ValRef<FossilizedContainerObjBase>::getElement(Index index) const
{
SLANG_ASSERT(index >= 0);
SLANG_ASSERT(index < getElementCount());
Expand All @@ -92,8 +91,7 @@ Fossil::AnyValRef Fossil::ValRef<FossilizedContainerObjBase>::getElement(
return Fossil::AnyValRef(elementPtr, elementLayout);
}

FossilizedRecordElementLayout* FossilizedRecordLayout::getField(
Index index) const
FossilizedRecordElementLayout* FossilizedRecordLayout::getField(Index index) const
{
SLANG_ASSERT(index >= 0);
SLANG_ASSERT(index < fieldCount);
Expand All @@ -102,8 +100,7 @@ FossilizedRecordElementLayout* FossilizedRecordLayout::getField(
return fieldsPtr + index;
}

Fossil::AnyValRef Fossil::ValRef<FossilizedRecordVal>::getField(
Index index) const
Fossil::AnyValRef Fossil::ValRef<FossilizedRecordVal>::getField(Index index) const
{
SLANG_ASSERT(index >= 0);
SLANG_ASSERT(index < getFieldCount());
Expand Down
25 changes: 10 additions & 15 deletions source/slang/slang-fossil.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ struct FossilizedPtr : RelativePtr32<T>

using Layout = FossilizedPtrLikeLayout;

SLANG_FORCE_INLINE static bool isMatchingKind(FossilizedValKind kind) { return kind == FossilizedValKind::Ptr; }
SLANG_FORCE_INLINE static bool isMatchingKind(FossilizedValKind kind)
{
return kind == FossilizedValKind::Ptr;
}
};

static_assert(sizeof(FossilizedPtr<void>) == sizeof(uint32_t));
Expand Down Expand Up @@ -493,30 +496,22 @@ SLANG_FORCE_INLINE int compare(FossilizedString const& lhs, UnownedStringSlice c
return compare(lhs.get(), rhs);
}

SLANG_FORCE_INLINE bool operator==(
FossilizedString const& left,
UnownedStringSlice const& right)
SLANG_FORCE_INLINE bool operator==(FossilizedString const& left, UnownedStringSlice const& right)
{
return left.get() == right;
}

SLANG_FORCE_INLINE bool operator!=(
FossilizedString const& left,
UnownedStringSlice const& right)
SLANG_FORCE_INLINE bool operator!=(FossilizedString const& left, UnownedStringSlice const& right)
{
return left.get() != right;
}

SLANG_FORCE_INLINE bool operator==(
FossilizedStringObj const& left,
UnownedStringSlice const& right)
SLANG_FORCE_INLINE bool operator==(FossilizedStringObj const& left, UnownedStringSlice const& right)
{
return left.get() == right;
}

SLANG_FORCE_INLINE bool operator!=(
FossilizedStringObj const& left,
UnownedStringSlice const& right)
SLANG_FORCE_INLINE bool operator!=(FossilizedStringObj const& left, UnownedStringSlice const& right)
{
return left.get() != right;
}
Expand Down Expand Up @@ -1099,8 +1094,8 @@ struct ValRef<FossilizedPtr<T>> : ValRefBase<FossilizedPtr<T>>
template<typename T>
SLANG_FORCE_INLINE ValPtr<T> cast(AnyValPtr valPtr)
{
// if (!valPtr)
// return ValPtr<T>();
// if (!valPtr)
// return ValPtr<T>();
return ValPtr<T>(
static_cast<T*>(valPtr.getDataPtr()),
(typename T::Layout*)(valPtr.getLayout()));
Expand Down
13 changes: 5 additions & 8 deletions source/slang/slang-serialize-ast.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// slang-serialize-ast.cpp
#include "slang-serialize-ast.h"

#include "core/slang-performance-profiler.h"
#include "slang-ast-dispatch.h"
#include "slang-check.h"
#include "slang-compiler.h"
Expand All @@ -10,8 +11,6 @@
#include "slang-serialize-fossil.h"
#include "slang-serialize-riff.h"

#include "core/slang-performance-profiler.h"

//
#include "slang-serialize-ast.cpp.fiddle"

Expand Down Expand Up @@ -540,7 +539,7 @@ struct ASTSerialWriteContext : SourceLocSerialContext
ModuleDecl* _module = nullptr;
SerialSourceLocWriter* _sourceLocWriter = nullptr;

public:
public:
//
// For the most part, this type just implements the methods
// of the `IASTSerializerImpl` interface, and then has some
Expand All @@ -556,8 +555,7 @@ struct ASTSerialWriteContext : SourceLocSerialContext
ContainerDeclDirectMemberDecls& value);
SerialSourceLocWriter* getSourceLocWriter() { return _sourceLocWriter; }

private:

private:
void _writeImportedModule(ASTSerializer const& serializer, ModuleDecl* moduleDecl);
void _writeImportedDecl(
ASTSerializer const& serializer,
Expand Down Expand Up @@ -687,7 +685,7 @@ struct ASTSerialReadContext : public SourceLocSerialContext, public RefObject
Count _deserializedTopLevelDeclCount = 0;
#endif

public:
public:
//
// Much like the `ASTSerialWriter`, for the most part this
// type just implements the `IASTSerializer` interface,
Expand All @@ -704,8 +702,7 @@ struct ASTSerialReadContext : public SourceLocSerialContext, public RefObject
ContainerDeclDirectMemberDecls& value);
SerialSourceLocReader* getSourceLocReader() { return _sourceLocReader; }

private:

private:
ModuleDecl* _readImportedModule(ASTSerializer const& serializer);
NodeBase* _readImportedDecl(ASTSerializer const& serializer);

Expand Down
13 changes: 9 additions & 4 deletions source/slang/slang-serialize-fossil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "slang-serialize-fossil.h"

#include "../core/slang-blob.h"

#include "core/slang-performance-profiler.h"

namespace Slang
Expand Down Expand Up @@ -324,7 +323,10 @@ void SerialWriter::handleUniquePtr(void*& value, SerializerCallback callback, vo
handleSharedPtr(value, callback, context);
}

void SerialWriter::handleDeferredObjectContents(void* valuePtr, SerializerCallback callback, void* context)
void SerialWriter::handleDeferredObjectContents(
void* valuePtr,
SerializerCallback callback,
void* context)
{
// Because we are already deferring writing of the *entirety* of
// an object's members as part of how `handleSharedPtr()` works,
Expand Down Expand Up @@ -1367,7 +1369,10 @@ void SerialReader::handleSharedPtr(void*& value, SerializerCallback callback, vo
value = objectInfo->resurrectedObjectPtr;
}

void SerialReader::handleDeferredObjectContents(void* valuePtr, SerializerCallback callback, void* context)
void SerialReader::handleDeferredObjectContents(
void* valuePtr,
SerializerCallback callback,
void* context)
{
// Unlike the case in `SerialWriter::handleDeferredObjectContents()`,
// we very much *do* want to delay invoking the callback until later.
Expand Down Expand Up @@ -1577,7 +1582,7 @@ void SerialReader::_pushContainerState(
auto containerDataPtr = containerObjPtr.getDataPtr();
auto containerLayout = containerObjPtr.getLayout();

auto elementCount = (uint32_t) containerObjPtr->getElementCount();
auto elementCount = (uint32_t)containerObjPtr->getElementCount();

FossilizedValLayout const* elementLayout = containerLayout->elementLayout;
auto elementStride = containerLayout->elementStride;
Expand Down
20 changes: 6 additions & 14 deletions source/slang/slang-serialize-fossil.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ namespace Fossil
#define SLANG_SERIALIZE_FOSSIL_ENABLE_VALIDATION_CHECKS 1

#if SLANG_SERIALIZE_FOSSIL_ENABLE_VALIDATION_CHECKS
#define SLANG_SERIALIZE_FOSSIL_VALIDATE(CONDITION) \
do \
{ \
if (!(CONDITION)) \
#define SLANG_SERIALIZE_FOSSIL_VALIDATE(CONDITION) \
do \
{ \
if (!(CONDITION)) \
SLANG_UNEXPECTED("invalid format encountered in serialized data"); \
} while (0)
#else
#define SLANG_SERIALIZE_FOSSIL_VALIDATE(CONDITION) \
SLANG_ASSERT(CONDITION)
#define SLANG_SERIALIZE_FOSSIL_VALIDATE(CONDITION) SLANG_ASSERT(CONDITION)
#endif

// A commonly-occuring kind of validation check when reading
Expand Down Expand Up @@ -87,7 +86,6 @@ SLANG_FORCE_INLINE ValPtr<T> expectPossiblyNullValOfType(AnyValPtr valPtr)
struct SerialWriter
{
public:

SerialWriter(ChunkBuilder* chunk);
SerialWriter(BlobBuilder& blobBuilder);

Expand Down Expand Up @@ -635,11 +633,7 @@ struct SerialWriter
void handleSharedPtr(void*& value, SerializerCallback callback, void* context);
void handleUniquePtr(void*& value, SerializerCallback callback, void* context);

void handleDeferredObjectContents(
void* valuePtr,
SerializerCallback callback,
void* context)
;
void handleDeferredObjectContents(void* valuePtr, SerializerCallback callback, void* context);
};

/// Serializer implementation for reading objects from a fossil-format blob.
Expand Down Expand Up @@ -744,7 +738,6 @@ struct SerialReader
SLANG_FORCE_INLINE State& getState() { return _state; }

public:

//
// The serialization protocol allows the back-end
// implementation to define a `Scope` type that will
Expand All @@ -766,7 +759,6 @@ struct SerialReader
};

private:

//
// Like other serializer implementations for reading, we track objects
// that are in the process of being read in, to avoid possible
Expand Down
3 changes: 1 addition & 2 deletions source/slang/slang-serialize-ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "core/slang-blob-builder.h"
#include "core/slang-common.h"
#include "core/slang-dictionary.h"
#include "core/slang-performance-profiler.h"
#include "slang-ir-insts-stable-names.h"
#include "slang-ir-insts.h"
#include "slang-ir-validate.h"
Expand All @@ -14,8 +15,6 @@
#include "slang-tag-version.h"
#include "slang.h"

#include "core/slang-performance-profiler.h"

//
#include "slang-serialize-ir.cpp.fiddle"

Expand Down
5 changes: 1 addition & 4 deletions source/slang/slang-serialize-riff.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,7 @@ struct RIFFSerialWriter
void handleSharedPtr(void*& value, SerializerCallback callback, void* context);
void handleUniquePtr(void*& value, SerializerCallback callback, void* context);

void handleDeferredObjectContents(
void* valuePtr,
SerializerCallback callback,
void* context);
void handleDeferredObjectContents(void* valuePtr, SerializerCallback callback, void* context);
};

/// Serializer implementation for reading from a tree of RIFF chunks.
Expand Down
47 changes: 23 additions & 24 deletions source/slang/slang-serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -783,34 +783,33 @@ struct ScopedSerializerOptional
};


#define SLANG_SCOPED_SERIALIZER_ARRAY(SERIALIZER) \
::Slang::ScopedSerializerArray<std::remove_reference_t<decltype(SERIALIZER)>> SLANG_CONCAT(_scopedSerializerArray, __LINE__)(SERIALIZER)
#define SLANG_SCOPED_SERIALIZER_ARRAY(SERIALIZER) \
::Slang::ScopedSerializerArray<std::remove_reference_t<decltype(SERIALIZER)>> SLANG_CONCAT( \
_scopedSerializerArray, \
__LINE__)(SERIALIZER)

#define SLANG_SCOPED_SERIALIZER_DICTIONARY(SERIALIZER) \
#define SLANG_SCOPED_SERIALIZER_DICTIONARY(SERIALIZER) \
::Slang::ScopedSerializerDictionary<std::remove_reference_t<decltype(SERIALIZER)>> \
SLANG_CONCAT( \
_scopedSerializerDictionary, \
__LINE__)( \
SERIALIZER)
SLANG_CONCAT(_scopedSerializerDictionary, __LINE__)(SERIALIZER)

#define SLANG_SCOPED_SERIALIZER_OPTIONAL(SERIALIZER) \
#define SLANG_SCOPED_SERIALIZER_OPTIONAL(SERIALIZER) \
::Slang::ScopedSerializerOptional<std::remove_reference_t<decltype(SERIALIZER)>> SLANG_CONCAT( \
_scopedSerializerOptional, \
_scopedSerializerOptional, \
__LINE__)(SERIALIZER)

#define SLANG_SCOPED_SERIALIZER_STRUCT(SERIALIZER) \
#define SLANG_SCOPED_SERIALIZER_STRUCT(SERIALIZER) \
::Slang::ScopedSerializerStruct<std::remove_reference_t<decltype(SERIALIZER)>> SLANG_CONCAT( \
_scopedSerializerStruct, \
_scopedSerializerStruct, \
__LINE__)(SERIALIZER)

#define SLANG_SCOPED_SERIALIZER_VARIANT(SERIALIZER) \
#define SLANG_SCOPED_SERIALIZER_VARIANT(SERIALIZER) \
::Slang::ScopedSerializerVariant<std::remove_reference_t<decltype(SERIALIZER)>> SLANG_CONCAT( \
_scopedSerializerVariant, \
_scopedSerializerVariant, \
__LINE__)(SERIALIZER)

#define SLANG_SCOPED_SERIALIZER_TUPLE(SERIALIZER) \
#define SLANG_SCOPED_SERIALIZER_TUPLE(SERIALIZER) \
::Slang::ScopedSerializerTuple<std::remove_reference_t<decltype(SERIALIZER)>> SLANG_CONCAT( \
_scopedSerializerTuple, \
_scopedSerializerTuple, \
__LINE__)(SERIALIZER)

//
Expand Down Expand Up @@ -1046,9 +1045,9 @@ template<typename S, typename T>
SLANG_FORCE_INLINE void deferSerializeObjectContents(S const& serializer, T* value)
{
serializer->handleDeferredObjectContents(
value,
_serializeObjectContentsCallback<S, T>,
serializer.getContext());
value,
_serializeObjectContentsCallback<S, T>,
serializer.getContext());
}

template<typename S, typename T>
Expand All @@ -1073,18 +1072,18 @@ template<typename S, typename T>
SLANG_FORCE_INLINE void serializeSharedPtr(S const& serializer, T*& value)
{
serializer->handleSharedPtr(
*(void**)&value,
_serializeObjectCallback<S, T>,
serializer.getContext());
*(void**)&value,
_serializeObjectCallback<S, T>,
serializer.getContext());
}

template<typename S, typename T>
SLANG_FORCE_INLINE void serializeUniquePtr(S const& serializer, T*& value)
{
serializer->handleUniquePtr(
*(void**)&value,
_serializeObjectCallback<S, T>,
serializer.getContext());
*(void**)&value,
_serializeObjectCallback<S, T>,
serializer.getContext());
}

template<typename S, typename T>
Expand Down
Loading