blob: 8fb4cea3606f0ecc41cfd0a2be81e2c0133556a0 [file]
// Generated by src/wasm/idl/generate.py from shared_layout.py. Do not edit.
//
// The shared memory words librive and web/rive_shared_lane.mjs both
// read, as wasm32 byte offsets.
#ifndef _RIVE_WASM_SHARED_LAYOUT_GEN_HPP_
#define _RIVE_WASM_SHARED_LAYOUT_GEN_HPP_
#include <cstdint>
namespace rive
{
namespace shared_layout
{
// What a block holds, its first word.
constexpr uint32_t kKindRegion = 0;
constexpr uint32_t kKindRing = 1;
constexpr uint32_t kKindSnapshot = 2;
constexpr uint32_t kKindSignal = 3;
constexpr uint32_t kKindBlob = 4;
// Every block starts with these words.
constexpr uint32_t kHeaderKind = 0;
constexpr uint32_t kHeaderLock = 4;
constexpr uint32_t kHeaderCapacity = 8;
constexpr uint32_t kHeaderClosed = 12;
constexpr uint32_t kHeaderSize = 16;
// A region after its header.
constexpr uint32_t kRegionPoisoned = 16;
constexpr uint32_t kRegionData = 32;
// A ring after its header; signals are registry ids.
constexpr uint32_t kRingHead = 16;
constexpr uint32_t kRingUsed = 20;
constexpr uint32_t kRingDataSignal = 24;
constexpr uint32_t kRingSpaceSignal = 28;
constexpr uint32_t kRingData = 32;
// A snapshot after its header: copies of capacity bytes each, a version per
// copy that is odd while a publish writes it.
constexpr uint32_t kSnapshotLatest = 16;
constexpr uint32_t kSnapshotSeq = 24;
constexpr uint32_t kSnapshotSeqHigh = 28;
constexpr uint32_t kSnapshotVersions = 32;
constexpr uint32_t kSnapshotSizes = 40;
constexpr uint32_t kSnapshotData = 48;
constexpr uint32_t kSnapshotCopies = 2;
// A ring record's length word or a snapshot copy's size. With the holds bit
// set, the bytes end in the shared ids the value holds and then their count.
constexpr uint32_t kRecordHolds = 0x80000000;
// A signal after its header; watchers point at wake words.
constexpr uint32_t kSignalWatcherCount = 16;
constexpr uint32_t kSignalWatcherCapacity = 20;
constexpr uint32_t kSignalSeq = 24;
constexpr uint32_t kSignalSeqHigh = 28;
constexpr uint32_t kSignalWatchers = 32;
// A blob after its header: bytes fixed once made.
constexpr uint32_t kBlobData = 16;
// The futex word a watcher parks on.
constexpr uint32_t kWakeWordWord = 0;
// The registry, at SharedRegistry::table().
constexpr uint32_t kTableLock = 0;
constexpr uint32_t kTableCount = 4;
constexpr uint32_t kTableFreeHead = 8;
constexpr uint32_t kTableFreeTail = 12;
constexpr uint32_t kTableLanes = 16;
constexpr uint32_t kTableTokens = 144;
constexpr uint32_t kTableChunks = 148;
// A registry slot. Its state packs the generation in the low bits, a live bit,
// then the pins librive holds.
constexpr uint32_t kSlotState = 0;
constexpr uint32_t kSlotBlock = 4;
constexpr uint32_t kSlotOwner = 16;
constexpr uint32_t kSlotOwnerHigh = 20;
constexpr uint32_t kSlotSize = 24;
constexpr uint32_t kSlotLive = 4096;
constexpr uint32_t kSlotPin = 8192;
// Slots come in chunks that never move once made.
constexpr uint32_t kChunkShift = 10;
constexpr uint32_t kChunkSlots = 1024;
constexpr uint32_t kChunkCount = 512;
// An id: the top bit, its slot, the generation's low bits.
constexpr uint32_t kIdBit = 0x80000000;
constexpr uint32_t kIdSlotShift = 12;
constexpr uint32_t kIdGenerationMask = 4095;
// Lanes without librive.
constexpr uint32_t kLaneCount = 32;
constexpr uint32_t kLaneIdle = 1;
constexpr uint32_t kLaneFirstToken = 2;
// The most bytes a shared object holds, and the most objects one script keeps
// at once, so no file fills the registry.
constexpr uint32_t kSharedMaxBytes = 0x10000000;
constexpr uint32_t kSharedMaxObjects = 0x10000;
// What ring_write answers.
constexpr uint32_t kRingWriteFull = 0;
constexpr uint32_t kRingWriteWritten = 1;
constexpr uint32_t kRingWriteNeverFits = 2;
// What a create answers instead of an id.
constexpr uint32_t kCreateRefused = 0;
constexpr uint32_t kCreateFull = 1;
constexpr uint32_t kCreateBadSize = 2;
constexpr uint32_t kCreateNoMemory = 3;
constexpr uint32_t kCreateTooMany = 4;
// What region_lock answers.
constexpr uint32_t kRegionLockGone = 0;
constexpr uint32_t kRegionLockAcquired = 1;
constexpr uint32_t kRegionLockNested = 2;
constexpr uint32_t kRegionLockTimedOut = 3;
// Words of the counter an NRDP page shares with its worklet thread, so it can
// free what the thread held when it ends it.
constexpr uint32_t kHoldBlocks = 0;
constexpr uint32_t kHoldStarting = 1;
constexpr uint32_t kHoldToken = 2;
constexpr uint32_t kHoldLock = 3;
constexpr uint32_t kHoldWords = 4;
} // namespace shared_layout
} // namespace rive
#endif