diff options
author | Thomas Lively <tlively@google.com> | 2024-07-12 16:48:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-12 13:48:06 -0700 |
commit | eda6530a187add28f06d9ab84d78b21b5001a6df (patch) | |
tree | b731f8dc5a32a1b8e969f47f82f497909a236c71 /src/literal.h | |
parent | 0e0e08db6280dec4f4fcce2dff3ba07445c45b8a (diff) | |
download | binaryen-eda6530a187add28f06d9ab84d78b21b5001a6df.tar.gz binaryen-eda6530a187add28f06d9ab84d78b21b5001a6df.tar.bz2 binaryen-eda6530a187add28f06d9ab84d78b21b5001a6df.zip |
[threads] ref.i31_shared (#6735)
Implement `ref.i31_shared` the new instruction for creating references
to shared i31s. Implement binary and text parsing and emitting as well
as interpretation. Copy the upstream spec test for i31 and modify it so
that all the heap types are shared. Comment out some parts that we do
not yet support.
Diffstat (limited to 'src/literal.h')
-rw-r--r-- | src/literal.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/literal.h b/src/literal.h index 1268448fb..45f76f247 100644 --- a/src/literal.h +++ b/src/literal.h @@ -243,8 +243,8 @@ public: static Literal makeFunc(Name func, HeapType type) { return Literal(func, type); } - static Literal makeI31(int32_t value) { - auto lit = Literal(Type(HeapType::i31, NonNullable)); + static Literal makeI31(int32_t value, Shareability share) { + auto lit = Literal(Type(HeapTypes::i31.getBasic(share), NonNullable)); lit.i32 = value | 0x80000000; return lit; } @@ -281,7 +281,7 @@ public: return i32; } int32_t geti31(bool signed_ = true) const { - assert(type.getHeapType() == HeapType::i31); + assert(type.getHeapType().getBasic(Unshared) == HeapType::i31); // Cast to unsigned for the left shift to avoid undefined behavior. return signed_ ? int32_t((uint32_t(i32) << 1)) >> 1 : (i32 & 0x7fffffff); } |