Skip to content

Remove externref #4633

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

Merged
merged 8 commits into from
May 4, 2022
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
8 changes: 0 additions & 8 deletions scripts/wasm2js.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ var asmLibraryArg = {
console.log('get_f64 ' + [loc, index, value]);
return value;
},
get_externref: function(loc, index, value) {
console.log('get_externref ' + [loc, index, value]);
return value;
},
set_i32: function(loc, index, value) {
console.log('set_i32 ' + [loc, index, value]);
return value;
Expand All @@ -145,10 +141,6 @@ var asmLibraryArg = {
console.log('set_f64 ' + [loc, index, value]);
return value;
},
set_externref: function(loc, index, value) {
console.log('set_externref ' + [loc, index, value]);
return value;
},
load_ptr: function(loc, bytes, offset, ptr) {
console.log('load_ptr ' + [loc, bytes, offset, ptr]);
return ptr;
Expand Down
3 changes: 0 additions & 3 deletions src/asmjs/asm_v_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ JsType wasmToJsType(Type type) {
case Type::v128:
WASM_UNREACHABLE("v128 not implemented yet");
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -63,8 +62,6 @@ char getSig(Type type) {
return 'V';
case Type::funcref:
return 'F';
case Type::externref:
return 'X';
case Type::anyref:
return 'A';
case Type::eqref:
Expand Down
5 changes: 2 additions & 3 deletions src/binaryen-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ BinaryenLiteral toBinaryenLiteral(Literal x) {
case Type::funcref:
ret.func = x.isNull() ? nullptr : x.getFunc().c_str();
break;
case Type::externref:
case Type::anyref:
case Type::eqref:
assert(x.isNull() && "unexpected non-null reference type literal");
Expand Down Expand Up @@ -100,7 +99,6 @@ Literal fromBinaryenLiteral(BinaryenLiteral x) {
return Literal(x.v128);
case Type::funcref:
return Literal::makeFunc(x.func);
case Type::externref:
case Type::anyref:
case Type::eqref:
return Literal::makeNull(Type(x.type));
Expand Down Expand Up @@ -132,6 +130,7 @@ extern "C" {
//

// Core types
// TODO: Deprecate BinaryenTypeExternref?

BinaryenType BinaryenTypeNone(void) { return Type::none; }
BinaryenType BinaryenTypeInt32(void) { return Type::i32; }
Expand All @@ -140,7 +139,7 @@ BinaryenType BinaryenTypeFloat32(void) { return Type::f32; }
BinaryenType BinaryenTypeFloat64(void) { return Type::f64; }
BinaryenType BinaryenTypeVec128(void) { return Type::v128; }
BinaryenType BinaryenTypeFuncref(void) { return Type::funcref; }
BinaryenType BinaryenTypeExternref(void) { return Type::externref; }
BinaryenType BinaryenTypeExternref(void) { return Type::anyref; }
BinaryenType BinaryenTypeAnyref(void) { return Type::anyref; }
BinaryenType BinaryenTypeEqref(void) { return Type::eqref; }
BinaryenType BinaryenTypeI31ref(void) { return Type::i31ref; }
Expand Down
2 changes: 0 additions & 2 deletions src/ir/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ inline UnaryOp getUnary(Type type, Op op) {
}
case Type::v128:
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -295,7 +294,6 @@ inline BinaryOp getBinary(Type type, Op op) {
}
case Type::v128:
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down
8 changes: 3 additions & 5 deletions src/literal.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class Literal {
// To support the experimental RttFreshSub instruction, we not only store
// the type, but also a reference to an allocation.
std::unique_ptr<RttSupers> rttSupers;
// TODO: Literals of type `externref` can only be `null` currently but we
// will need to represent extern values eventually, to
// TODO: Literals of type `anyref` can only be `null` currently but we
// will need to represent external values eventually, to
// 1) run the spec tests and fuzzer with reference types enabled and
// 2) avoid bailing out when seeing a reference typed value in precompute
};
Expand Down Expand Up @@ -765,8 +765,7 @@ template<> struct hash<wasm::Literal> {
return digest;
}
// other non-null reference type literals cannot represent concrete
// values, i.e. there is no concrete externref, anyref or eqref other than
// null.
// values, i.e. there is no concrete anyref or eqref other than null.
WASM_UNREACHABLE("unexpected type");
};
if (a.type.isBasic()) {
Expand All @@ -790,7 +789,6 @@ template<> struct hash<wasm::Literal> {
wasm::rehash(digest, chunks[1]);
return digest;
case wasm::Type::funcref:
case wasm::Type::externref:
case wasm::Type::anyref:
case wasm::Type::eqref:
case wasm::Type::dataref:
Expand Down
1 change: 0 additions & 1 deletion src/passes/ConstHoisting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ struct ConstHoisting : public WalkerPass<PostWalker<ConstHoisting>> {
// not implemented yet
case Type::v128:
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down
2 changes: 0 additions & 2 deletions src/passes/FuncCastEmulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static Expression* toABI(Expression* value, Module* module) {
WASM_UNREACHABLE("v128 not implemented yet");
}
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -109,7 +108,6 @@ static Expression* fromABI(Expression* value, Type type, Module* module) {
WASM_UNREACHABLE("v128 not implemented yet");
}
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down
24 changes: 4 additions & 20 deletions src/passes/InstrumentLocals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ Name get_f32("get_f32");
Name get_f64("get_f64");
Name get_v128("get_v128");
Name get_funcref("get_funcref");
Name get_externref("get_externref");
Name get_anyref("get_anyref");
Name get_eqref("get_eqref");
Name get_i31ref("get_i31ref");
Expand All @@ -69,7 +68,6 @@ Name set_f32("set_f32");
Name set_f64("set_f64");
Name set_v128("set_v128");
Name set_funcref("set_funcref");
Name set_externref("set_externref");
Name set_anyref("set_anyref");
Name set_eqref("set_eqref");
Name set_i31ref("set_i31ref");
Expand Down Expand Up @@ -98,9 +96,6 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> {
case Type::funcref:
import = get_funcref;
break;
case Type::externref:
import = get_externref;
break;
case Type::anyref:
import = get_anyref;
break;
Expand Down Expand Up @@ -158,9 +153,6 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> {
case Type::funcref:
import = set_funcref;
break;
case Type::externref:
import = set_externref;
break;
case Type::anyref:
import = set_anyref;
break;
Expand Down Expand Up @@ -204,19 +196,11 @@ struct InstrumentLocals : public WalkerPass<PostWalker<InstrumentLocals>> {
set_funcref,
{Type::i32, Type::i32, Type::funcref},
Type::funcref);
addImport(curr,
get_externref,
{Type::i32, Type::i32, Type::externref},
Type::externref);
addImport(curr,
set_externref,
{Type::i32, Type::i32, Type::externref},
Type::externref);
addImport(
curr, get_anyref, {Type::i32, Type::i32, Type::anyref}, Type::anyref);
addImport(
curr, set_anyref, {Type::i32, Type::i32, Type::anyref}, Type::anyref);
if (curr->features.hasGC()) {
addImport(
curr, get_anyref, {Type::i32, Type::i32, Type::anyref}, Type::anyref);
addImport(
curr, set_anyref, {Type::i32, Type::i32, Type::anyref}, Type::anyref);
addImport(
curr, get_eqref, {Type::i32, Type::i32, Type::eqref}, Type::eqref);
addImport(
Expand Down
28 changes: 4 additions & 24 deletions src/tools/fuzzing/fuzzing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ TranslateToFuzzReader::TranslateToFuzzReader(Module& wasm,
: wasm(wasm), builder(wasm), random(std::move(input), wasm.features) {
// - funcref cannot be logged because referenced functions can be inlined or
// removed during optimization
// - there's no point in logging externref or anyref because these are opaque
// - there's no point in logging anyref because it is opaque
// - don't bother logging tuples
loggableTypes = {Type::i32, Type::i64, Type::f32, Type::f64};
if (wasm.features.hasSIMD()) {
Expand Down Expand Up @@ -1460,7 +1460,6 @@ Expression* TranslateToFuzzReader::makeNonAtomicLoad(Type type) {
16, false, offset, pick(1, 2, 4, 8, 16), ptr, type);
}
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -1564,7 +1563,6 @@ Expression* TranslateToFuzzReader::makeNonAtomicStore(Type type) {
16, offset, pick(1, 2, 4, 8, 16), ptr, value, type);
}
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -1700,7 +1698,6 @@ Literal TranslateToFuzzReader::makeLiteral(Type type) {
return Literal(getDouble());
case Type::v128:
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -1747,7 +1744,6 @@ Literal TranslateToFuzzReader::makeLiteral(Type type) {
return Literal(double(small));
case Type::v128:
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -1817,7 +1813,6 @@ Literal TranslateToFuzzReader::makeLiteral(Type type) {
break;
case Type::v128:
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -1846,7 +1841,6 @@ Literal TranslateToFuzzReader::makeLiteral(Type type) {
break;
case Type::v128:
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -1919,9 +1913,6 @@ Expression* TranslateToFuzzReader::makeConst(Type type) {
switch (heapType.getBasic()) {
case HeapType::func:
return makeRefFuncConst(type);
case HeapType::ext:
// No trivial way to create an externref.
break;
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 @@ -2067,7 +2058,6 @@ Expression* TranslateToFuzzReader::makeUnary(Type type) {
make(Type::v128)});
}
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -2208,7 +2198,6 @@ Expression* TranslateToFuzzReader::makeUnary(Type type) {
WASM_UNREACHABLE("invalid value");
}
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -2447,7 +2436,6 @@ Expression* TranslateToFuzzReader::makeBinary(Type type) {
make(Type::v128)});
}
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -2655,7 +2643,6 @@ Expression* TranslateToFuzzReader::makeSIMDExtract(Type type) {
break;
case Type::v128:
case Type::funcref:
case Type::externref:
case Type::anyref:
case Type::eqref:
case Type::i31ref:
Expand Down Expand Up @@ -2913,12 +2900,10 @@ Type TranslateToFuzzReader::getSingleConcreteType() {
WeightedOption{Type::f32, VeryImportant},
WeightedOption{Type::f64, VeryImportant})
.add(FeatureSet::SIMD, WeightedOption{Type::v128, Important})
.add(FeatureSet::ReferenceTypes, Type::funcref, Type::externref)
.add(FeatureSet::ReferenceTypes, Type::funcref, Type::anyref)
.add(FeatureSet::ReferenceTypes | FeatureSet::GC,
// Type(HeapType::func, NonNullable),
// Type(HeapType::ext, NonNullable),
Type(HeapType::any, Nullable),
Type(HeapType::any, NonNullable),
// Type(HeapType::any, NonNullable),
Type(HeapType::eq, Nullable),
Type(HeapType::eq, NonNullable),
Type(HeapType::i31, Nullable),
Expand All @@ -2929,11 +2914,9 @@ Type TranslateToFuzzReader::getSingleConcreteType() {

Type TranslateToFuzzReader::getReferenceType() {
return pick(FeatureOptions<Type>()
.add(FeatureSet::ReferenceTypes, Type::funcref, Type::externref)
.add(FeatureSet::ReferenceTypes, Type::funcref, Type::anyref)
.add(FeatureSet::ReferenceTypes | FeatureSet::GC,
Type(HeapType::func, NonNullable),
Type(HeapType::ext, NonNullable),
Type(HeapType::any, Nullable),
Type(HeapType::any, NonNullable),
Type(HeapType::eq, Nullable),
Type(HeapType::eq, NonNullable),
Expand Down Expand Up @@ -3016,12 +2999,9 @@ HeapType TranslateToFuzzReader::getSubType(HeapType type) {
case HeapType::func:
// TODO: Typed function references.
return HeapType::func;
case HeapType::ext:
return HeapType::ext;
case HeapType::any:
// TODO: nontrivial types as well.
return pick(HeapType::func,
HeapType::ext,
HeapType::any,
HeapType::eq,
HeapType::i31,
Expand Down
6 changes: 0 additions & 6 deletions src/tools/fuzzing/heap-types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ struct HeapTypeGeneratorImpl {

HeapType::BasicHeapType generateBasicHeapType() {
return rand.pick(HeapType::func,
HeapType::ext,
HeapType::any,
HeapType::eq,
HeapType::i31,
Expand All @@ -167,7 +166,6 @@ struct HeapTypeGeneratorImpl {
.add(FeatureSet::SIMD, Type::v128)
.add(FeatureSet::ReferenceTypes | FeatureSet::GC,
Type::funcref,
Type::externref,
Type::anyref,
Type::eqref,
Type::i31ref,
Expand Down Expand Up @@ -294,7 +292,6 @@ struct HeapTypeGeneratorImpl {
return type;
} else {
switch (type) {
case HeapType::ext:
case HeapType::i31:
// No other subtypes.
return type;
Expand Down Expand Up @@ -385,8 +382,6 @@ struct HeapTypeGeneratorImpl {
switch (type.getBasic()) {
case HeapType::func:
return pickSubFunc();
case HeapType::ext:
return HeapType::ext;
case HeapType::any:
return pickSubAny();
case HeapType::eq:
Expand Down Expand Up @@ -496,7 +491,6 @@ struct HeapTypeGeneratorImpl {
switch (*basic) {
case HeapType::func:
return SignatureKind{};
case HeapType::ext:
case HeapType::i31:
return super;
case HeapType::any:
Expand Down
3 changes: 0 additions & 3 deletions src/tools/spec-wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ inline std::string generateSpecWrapper(Module& wasm) {
case Type::funcref:
ret += "(ref.null func)";
break;
case Type::externref:
ret += "(ref.null extern)";
break;
case Type::anyref:
ret += "(ref.null any)";
break;
Expand Down
Loading