Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Do not merge] run CI #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions src/binaryen-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ BinaryenLiteral toBinaryenLiteral(Literal x) {
case HeapType::any:
case HeapType::eq:
case HeapType::func:
case HeapType::cont:
case HeapType::struct_:
case HeapType::array:
case HeapType::exn:
Expand All @@ -98,6 +99,7 @@ BinaryenLiteral toBinaryenLiteral(Literal x) {
case HeapType::none:
case HeapType::noext:
case HeapType::nofunc:
case HeapType::nocont:
case HeapType::noexn:
// Null.
return ret;
Expand Down Expand Up @@ -141,6 +143,7 @@ Literal fromBinaryenLiteral(BinaryenLiteral x) {
WASM_UNREACHABLE("TODO: extern literals");
case HeapType::eq:
case HeapType::func:
case HeapType::cont:
case HeapType::struct_:
case HeapType::array:
case HeapType::exn:
Expand All @@ -153,6 +156,7 @@ Literal fromBinaryenLiteral(BinaryenLiteral x) {
case HeapType::none:
case HeapType::noext:
case HeapType::nofunc:
case HeapType::nocont:
case HeapType::noexn:
assert(type.isNullable());
return Literal::makeNull(heapType);
Expand Down
7 changes: 7 additions & 0 deletions src/tools/fuzzing/fuzzing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2525,6 +2525,9 @@ Expression* TranslateToFuzzReader::makeBasicRef(Type type) {
case HeapType::func: {
return makeRefFuncConst(type);
}
case HeapType::cont: {
WASM_UNREACHABLE("not implemented");
}
case HeapType::any: {
// Choose a subtype we can materialize a constant for. We cannot
// materialize non-nullable refs to func or i31 in global contexts.
Expand Down Expand Up @@ -2652,6 +2655,7 @@ Expression* TranslateToFuzzReader::makeBasicRef(Type type) {
case HeapType::none:
case HeapType::noext:
case HeapType::nofunc:
case HeapType::nocont:
case HeapType::noexn: {
auto null = builder.makeRefNull(heapType);
if (!type.isNullable()) {
Expand Down Expand Up @@ -4076,6 +4080,8 @@ HeapType TranslateToFuzzReader::getSubType(HeapType type) {
return pick(FeatureOptions<HeapType>()
.add(FeatureSet::ReferenceTypes, HeapType::func)
.add(FeatureSet::GC, HeapType::nofunc));
case HeapType::cont:
return pick(HeapType::cont, HeapType::nocont);
case HeapType::ext:
return pick(FeatureOptions<HeapType>()
.add(FeatureSet::ReferenceTypes, HeapType::ext)
Expand Down Expand Up @@ -4116,6 +4122,7 @@ HeapType TranslateToFuzzReader::getSubType(HeapType type) {
case HeapType::none:
case HeapType::noext:
case HeapType::nofunc:
case HeapType::nocont:
case HeapType::noexn:
break;
}
Expand Down
6 changes: 6 additions & 0 deletions src/tools/fuzzing/heap-types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ struct HeapTypeGeneratorImpl {
switch (type.getBasic()) {
case HeapType::func:
return pickSubFunc();
case HeapType::cont:
WASM_UNREACHABLE("not implemented");
case HeapType::any:
return pickSubAny();
case HeapType::eq:
Expand All @@ -399,6 +401,7 @@ struct HeapTypeGeneratorImpl {
case HeapType::none:
case HeapType::noext:
case HeapType::nofunc:
case HeapType::nocont:
case HeapType::noexn:
return type;
}
Expand Down Expand Up @@ -442,6 +445,7 @@ struct HeapTypeGeneratorImpl {
case HeapType::ext:
case HeapType::func:
case HeapType::exn:
case HeapType::cont:
case HeapType::any:
break;
case HeapType::eq:
Expand Down Expand Up @@ -470,6 +474,8 @@ struct HeapTypeGeneratorImpl {
return pickSubAny();
case HeapType::nofunc:
return pickSubFunc();
case HeapType::nocont:
WASM_UNREACHABLE("not implemented");
case HeapType::noext:
candidates.push_back(HeapType::ext);
break;
Expand Down
4 changes: 4 additions & 0 deletions src/wasm-binary.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ enum EncodedType {
eqref = -0x13, // 0x6d
nonnullable = -0x1c, // 0x64
nullable = -0x1d, // 0x63
contref = -0x18, // 0x68
nullcontref = -0x0b, // 0x75
// exception handling
exnref = -0x17, // 0x69
nullexnref = -0xc, // 0x74
Expand Down Expand Up @@ -403,6 +405,8 @@ enum EncodedHeapType {
eq = -0x13, // 0x6d
exn = -0x17, // 0x69
noexn = -0xc, // 0x74
cont = -0x18, // 0x68
nocont = -0x0b, // 0x75
i31 = -0x14, // 0x6c
struct_ = -0x15, // 0x6b
array = -0x16, // 0x6a
Expand Down
6 changes: 6 additions & 0 deletions src/wasm-type.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ class HeapType {
enum BasicHeapType : uint32_t {
ext,
func,
cont,
any,
eq,
i31,
Expand All @@ -334,6 +335,7 @@ class HeapType {
none,
noext,
nofunc,
nocont,
noexn,
};
static constexpr BasicHeapType _last_basic_type = noexn;
Expand Down Expand Up @@ -367,6 +369,10 @@ class HeapType {
bool isFunction() const;
bool isData() const;
bool isSignature() const;
// Indicates whether the given type was defined to be of the form
// `(cont $ft)`. Returns false for `cont`, the top type of the continuation
// type hierarchy (and all other types). In other words, this is analogous to
// `isSignature`, but for continuation types.
bool isContinuation() const;
bool isStruct() const;
bool isArray() const;
Expand Down
6 changes: 6 additions & 0 deletions src/wasm/literal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ Literal::Literal(const Literal& other) : type(other.type) {
case HeapType::noext:
case HeapType::nofunc:
case HeapType::noexn:
case HeapType::nocont:
WASM_UNREACHABLE("null literals should already have been handled");
case HeapType::any:
case HeapType::eq:
case HeapType::func:
case HeapType::cont:
case HeapType::struct_:
case HeapType::array:
case HeapType::exn:
Expand Down Expand Up @@ -622,6 +624,9 @@ std::ostream& operator<<(std::ostream& o, Literal literal) {
case HeapType::noexn:
o << "nullexnref";
break;
case HeapType::nocont:
o << "nullcontref";
break;
case HeapType::ext:
o << "externref";
break;
Expand All @@ -631,6 +636,7 @@ std::ostream& operator<<(std::ostream& o, Literal literal) {
case HeapType::any:
case HeapType::eq:
case HeapType::func:
case HeapType::cont:
case HeapType::struct_:
case HeapType::array:
WASM_UNREACHABLE("invalid type");
Expand Down
24 changes: 24 additions & 0 deletions src/wasm/wasm-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,9 @@ void WasmBinaryWriter::writeType(Type type) {
case HeapType::func:
o << S32LEB(BinaryConsts::EncodedType::funcref);
return;
case HeapType::cont:
o << S32LEB(BinaryConsts::EncodedType::contref);
return;
case HeapType::eq:
o << S32LEB(BinaryConsts::EncodedType::eqref);
return;
Expand Down Expand Up @@ -1539,6 +1542,9 @@ void WasmBinaryWriter::writeType(Type type) {
case HeapType::noexn:
o << S32LEB(BinaryConsts::EncodedType::nullexnref);
return;
case HeapType::nocont:
o << S32LEB(BinaryConsts::EncodedType::nullcontref);
return;
}
}
if (type.isNullable()) {
Expand Down Expand Up @@ -1612,6 +1618,9 @@ void WasmBinaryWriter::writeHeapType(HeapType type) {
case HeapType::func:
ret = BinaryConsts::EncodedHeapType::func;
break;
case HeapType::cont:
ret = BinaryConsts::EncodedHeapType::cont;
break;
case HeapType::any:
ret = BinaryConsts::EncodedHeapType::any;
break;
Expand Down Expand Up @@ -1654,6 +1663,9 @@ void WasmBinaryWriter::writeHeapType(HeapType type) {
case HeapType::noexn:
ret = BinaryConsts::EncodedHeapType::noexn;
break;
case HeapType::nocont:
ret = BinaryConsts::EncodedHeapType::nocont;
break;
}
o << S64LEB(ret); // TODO: Actually s33
}
Expand Down Expand Up @@ -1986,6 +1998,9 @@ bool WasmBinaryReader::getBasicType(int32_t code, Type& out) {
case BinaryConsts::EncodedType::funcref:
out = Type(HeapType::func, Nullable);
return true;
case BinaryConsts::EncodedType::contref:
out = Type(HeapType::cont, Nullable);
return true;
case BinaryConsts::EncodedType::externref:
out = Type(HeapType::ext, Nullable);
return true;
Expand Down Expand Up @@ -2031,6 +2046,9 @@ bool WasmBinaryReader::getBasicType(int32_t code, Type& out) {
case BinaryConsts::EncodedType::nullexnref:
out = Type(HeapType::noexn, Nullable);
return true;
case BinaryConsts::EncodedType::nullcontref:
out = Type(HeapType::nocont, Nullable);
return true;
default:
return false;
}
Expand All @@ -2041,6 +2059,9 @@ bool WasmBinaryReader::getBasicHeapType(int64_t code, HeapType& out) {
case BinaryConsts::EncodedHeapType::func:
out = HeapType::func;
return true;
case BinaryConsts::EncodedHeapType::cont:
out = HeapType::func;
return true;
case BinaryConsts::EncodedHeapType::ext:
out = HeapType::ext;
return true;
Expand Down Expand Up @@ -2086,6 +2107,9 @@ bool WasmBinaryReader::getBasicHeapType(int64_t code, HeapType& out) {
case BinaryConsts::EncodedHeapType::noexn:
out = HeapType::noexn;
return true;
case BinaryConsts::EncodedHeapType::nocont:
out = HeapType::nocont;
return true;
default:
return false;
}
Expand Down
12 changes: 12 additions & 0 deletions src/wasm/wasm-s-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,9 @@ Type SExpressionWasmBuilder::stringToType(std::string_view str,
if (str.substr(0, 7) == "funcref" && (prefix || str.size() == 7)) {
return Type(HeapType::func, Nullable);
}
if (str.substr(0, 7) == "contref" && (prefix || str.size() == 7)) {
return Type(HeapType::cont, Nullable);
}
if (str.substr(0, 9) == "externref" && (prefix || str.size() == 9)) {
return Type(HeapType::ext, Nullable);
}
Expand Down Expand Up @@ -1302,6 +1305,9 @@ Type SExpressionWasmBuilder::stringToType(std::string_view str,
if (str.substr(0, 10) == "nullexnref" && (prefix || str.size() == 10)) {
return Type(HeapType::noexn, Nullable);
}
if (str.substr(0, 11) == "nullcontref" && (prefix || str.size() == 11)) {
return Type(HeapType::nocont, Nullable);
}
if (allowError) {
return Type::none;
}
Expand All @@ -1314,6 +1320,9 @@ HeapType SExpressionWasmBuilder::stringToHeapType(std::string_view str,
if (str.substr(0, 4) == "func" && (prefix || str.size() == 4)) {
return HeapType::func;
}
if (str.substr(0, 4) == "cont" && (prefix || str.size() == 4)) {
return HeapType::cont;
}
if (str.substr(0, 2) == "eq" && (prefix || str.size() == 2)) {
return HeapType::eq;
}
Expand Down Expand Up @@ -1362,6 +1371,9 @@ HeapType SExpressionWasmBuilder::stringToHeapType(std::string_view str,
if (str.substr(0, 5) == "noexn" && (prefix || str.size() == 5)) {
return HeapType::noexn;
}
if (str.substr(0, 6) == "nocont" && (prefix || str.size() == 6)) {
return HeapType::nocont;
}
throw ParseException(std::string("invalid wasm heap type: ") +
std::string(str.data(), str.size()));
}
Expand Down
Loading
Loading