LibWasm: Remove Wasm::ValueType::Kind::Null* variants

As far as I know, they're not in the spec and don't serve any purposes
in the internals of LibWasm.
This commit is contained in:
Diego 2024-07-07 19:01:28 -07:00 committed by Ali Mohammad Pur
commit 5382fbb617
Notes: sideshowbarker 2024-07-17 20:58:35 +09:00
4 changed files with 4 additions and 29 deletions

View file

@ -328,12 +328,6 @@ JS_DEFINE_NATIVE_FUNCTION(WebAssemblyModule::wasm_invoke)
} }
arguments.append(Wasm::Value(Wasm::Reference { Wasm::Reference::Extern { static_cast<u64>(double_value) } })); arguments.append(Wasm::Value(Wasm::Reference { Wasm::Reference::Extern { static_cast<u64>(double_value) } }));
break; break;
case Wasm::ValueType::Kind::NullFunctionReference:
arguments.append(Wasm::Value(Wasm::Reference { Wasm::Reference::Null { Wasm::ValueType(Wasm::ValueType::Kind::FunctionReference) } }));
break;
case Wasm::ValueType::Kind::NullExternReference:
arguments.append(Wasm::Value(Wasm::Reference { Wasm::Reference::Null { Wasm::ValueType(Wasm::ValueType::Kind::ExternReference) } }));
break;
} }
} }

View file

@ -108,14 +108,6 @@ public:
case ValueType::Kind::F64: case ValueType::Kind::F64:
m_value = bit_cast<double>(raw_value); m_value = bit_cast<double>(raw_value);
break; break;
case ValueType::Kind::NullFunctionReference:
VERIFY(raw_value == 0);
m_value = Reference { Reference::Null { ValueType(ValueType::Kind::FunctionReference) } };
break;
case ValueType::Kind::NullExternReference:
VERIFY(raw_value == 0);
m_value = Reference { Reference::Null { ValueType(ValueType::Kind::ExternReference) } };
break;
case ValueType::Kind::V128: case ValueType::Kind::V128:
m_value = u128(0ull, bit_cast<u64>(raw_value)); m_value = u128(0ull, bit_cast<u64>(raw_value));
break; break;
@ -184,7 +176,7 @@ public:
return type.ref().visit( return type.ref().visit(
[](Reference::Func const&) { return ValueType::Kind::FunctionReference; }, [](Reference::Func const&) { return ValueType::Kind::FunctionReference; },
[](Reference::Null const& null_type) { [](Reference::Null const& null_type) {
return null_type.type.kind() == ValueType::ExternReference ? ValueType::Kind::NullExternReference : ValueType::Kind::NullFunctionReference; return null_type.type.kind();
}, },
[](Reference::Extern const&) { return ValueType::Kind::ExternReference; }); [](Reference::Extern const&) { return ValueType::Kind::ExternReference; });
})); }));

View file

@ -165,8 +165,6 @@ public:
V128, V128,
FunctionReference, FunctionReference,
ExternReference, ExternReference,
NullFunctionReference,
NullExternReference,
}; };
explicit ValueType(Kind kind) explicit ValueType(Kind kind)
@ -176,7 +174,7 @@ public:
bool operator==(ValueType const&) const = default; bool operator==(ValueType const&) const = default;
auto is_reference() const { return m_kind == ExternReference || m_kind == FunctionReference || m_kind == NullExternReference || m_kind == NullFunctionReference; } auto is_reference() const { return m_kind == ExternReference || m_kind == FunctionReference; }
auto is_vector() const { return m_kind == V128; } auto is_vector() const { return m_kind == V128; }
auto is_numeric() const { return !is_reference() && !is_vector(); } auto is_numeric() const { return !is_reference() && !is_vector(); }
auto kind() const { return m_kind; } auto kind() const { return m_kind; }
@ -200,10 +198,6 @@ public:
return "funcref"; return "funcref";
case ExternReference: case ExternReference:
return "externref"; return "externref";
case NullFunctionReference:
return "ref.null externref";
case NullExternReference:
return "ref.null funcref";
} }
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();
} }

View file

@ -412,10 +412,9 @@ JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::VM& vm, JS::Value va
auto number = TRY(value.to_double(vm)); auto number = TRY(value.to_double(vm));
return Wasm::Value { static_cast<float>(number) }; return Wasm::Value { static_cast<float>(number) };
} }
case Wasm::ValueType::FunctionReference: case Wasm::ValueType::FunctionReference: {
case Wasm::ValueType::NullFunctionReference: {
if (value.is_null()) if (value.is_null())
return Wasm::Value { Wasm::ValueType(Wasm::ValueType::NullExternReference), 0ull }; return Wasm::Value { Wasm::ValueType(Wasm::ValueType::FunctionReference), 0ull };
if (value.is_function()) { if (value.is_function()) {
auto& function = value.as_function(); auto& function = value.as_function();
@ -429,7 +428,6 @@ JS::ThrowCompletionOr<Wasm::Value> to_webassembly_value(JS::VM& vm, JS::Value va
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "Exported function"); return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "Exported function");
} }
case Wasm::ValueType::ExternReference: case Wasm::ValueType::ExternReference:
case Wasm::ValueType::NullExternReference:
TODO(); TODO();
case Wasm::ValueType::V128: case Wasm::ValueType::V128:
return vm.throw_completion<JS::TypeError>("Cannot convert a vector value to a javascript value"sv); return vm.throw_completion<JS::TypeError>("Cannot convert a vector value to a javascript value"sv);
@ -453,11 +451,8 @@ JS::Value to_js_value(JS::VM& vm, Wasm::Value& wasm_value)
case Wasm::ValueType::FunctionReference: case Wasm::ValueType::FunctionReference:
// FIXME: What's the name of a function reference that isn't exported? // FIXME: What's the name of a function reference that isn't exported?
return create_native_function(vm, wasm_value.to<Wasm::Reference::Func>().value().address, "FIXME_IHaveNoIdeaWhatThisShouldBeCalled"); return create_native_function(vm, wasm_value.to<Wasm::Reference::Func>().value().address, "FIXME_IHaveNoIdeaWhatThisShouldBeCalled");
case Wasm::ValueType::NullFunctionReference:
return JS::js_null();
case Wasm::ValueType::V128: case Wasm::ValueType::V128:
case Wasm::ValueType::ExternReference: case Wasm::ValueType::ExternReference:
case Wasm::ValueType::NullExternReference:
TODO(); TODO();
} }
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();