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
14 changes: 6 additions & 8 deletions src/wasm-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ class HeapType {
// should also be passed by value.
uintptr_t id;

static constexpr int TypeBits = 3;
static constexpr int TypeBits = 2;
static constexpr int UsedBits = TypeBits + 1;
static constexpr int SharedMask = 1 << TypeBits;

public:
// Bits 0-2 are used by the Type representation, so need to be left free.
// Bit 3 determines whether the basic heap type is shared (1) or unshared (0).
// Bits 0-1 are used by the Type representation, so need to be left free.
// Bit 2 determines whether the basic heap type is shared (1) or unshared (0).
enum BasicHeapType : uint32_t {
ext = 1 << UsedBits,
func = 2 << UsedBits,
Expand Down Expand Up @@ -278,7 +278,7 @@ class Type {
// bit 0 set. When that bit is masked off, they are pointers to the underlying
// vectors of types. Otherwise, the type is a reference type, and is
// represented as a heap type with bit 1 set iff the reference type is
// nullable and bit 2 set iff the reference type is exact.
// nullable.
//
// Since `Type` is really just a single integer, it should be passed by value.
// This is a uintptr_t rather than a TypeID (uint64_t) to save memory on
Expand All @@ -287,7 +287,6 @@ class Type {

static constexpr int TupleMask = 1 << 0;
static constexpr int NullMask = 1 << 1;
static constexpr int ExactMask = 1 << 2;

public:
enum BasicType : uint32_t {
Expand Down Expand Up @@ -320,8 +319,7 @@ class Type {
// Signature, Struct or Array via implicit conversion to HeapType.
Type(HeapType heapType, Nullability nullable)
: Type(heapType.getID() | (nullable == Nullable ? NullMask : 0)) {
assert(heapType.isBasic() ||
!(heapType.getID() & (TupleMask | NullMask | ExactMask)));
assert(heapType.isBasic() || !(heapType.getID() & (TupleMask | NullMask)));
}

// Predicates
Expand Down Expand Up @@ -372,7 +370,7 @@ class Type {
bool isNonNullable() const { return isRef() && !(id & NullMask); }
HeapType getHeapType() const {
assert(isRef());
return HeapType(id & ~(NullMask | ExactMask));
return HeapType(id & ~NullMask);
}

bool isFunction() const { return isRef() && getHeapType().isFunction(); }
Expand Down
22 changes: 11 additions & 11 deletions test/example/c-api-kitchen-sink.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ BinaryenTypeAuto: -1
BinaryenPackedTypeNotPacked: 0
BinaryenPackedTypeInt8: 1
BinaryenPackedTypeInt16: 2
BinaryenHeapTypeExt: 16
BinaryenHeapTypeFunc: 32
BinaryenHeapTypeAny: 64
BinaryenHeapTypeEq: 80
BinaryenHeapTypeI31: 96
BinaryenHeapTypeStruct: 112
BinaryenHeapTypeArray: 128
BinaryenHeapTypeString: 160
BinaryenHeapTypeNone: 176
BinaryenHeapTypeNoext: 192
BinaryenHeapTypeNofunc: 208
BinaryenHeapTypeExt: 8
BinaryenHeapTypeFunc: 16
BinaryenHeapTypeAny: 32
BinaryenHeapTypeEq: 40
BinaryenHeapTypeI31: 48
BinaryenHeapTypeStruct: 56
BinaryenHeapTypeArray: 64
BinaryenHeapTypeString: 80
BinaryenHeapTypeNone: 88
BinaryenHeapTypeNoext: 96
BinaryenHeapTypeNofunc: 104
BinaryenFeatureMVP: 0
BinaryenFeatureAtomics: 1
BinaryenFeatureBulkMemory: 16
Expand Down