зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1730188 - wasm: Fix Table.type method to report type as RefType instead of TableRepr. r=lth
We should report the precise RefType that a table has, not the flattened TableRepr. Depends on D125225 Differential Revision: https://phabricator.services.mozilla.com/D125226
This commit is contained in:
Родитель
4d3baaf516
Коммит
8e0afc31b8
|
@ -3076,26 +3076,14 @@ static bool ToTableIndex(JSContext* cx, HandleValue v, const Table& table,
|
|||
#ifdef ENABLE_WASM_TYPE_REFLECTIONS
|
||||
/* static */
|
||||
bool WasmTableObject::typeImpl(JSContext* cx, const CallArgs& args) {
|
||||
Rooted<IdValueVector> props(cx, IdValueVector(cx));
|
||||
Table& table = args.thisv().toObject().as<WasmTableObject>().table();
|
||||
|
||||
const char* elementValue;
|
||||
switch (table.repr()) {
|
||||
case TableRepr::Func:
|
||||
elementValue = "funcref";
|
||||
break;
|
||||
case TableRepr::Ref:
|
||||
elementValue = "externref";
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("Should not happen");
|
||||
}
|
||||
JSString* elementString = UTF8CharsToString(cx, elementValue);
|
||||
if (!elementString) {
|
||||
return false;
|
||||
}
|
||||
if (!props.append(IdValuePair(NameToId(cx->names().element),
|
||||
StringValue(elementString)))) {
|
||||
Rooted<IdValueVector> props(cx, IdValueVector(cx));
|
||||
|
||||
RootedString elementType(
|
||||
cx, UTF8CharsToString(cx, ToString(table.elemType()).get()));
|
||||
if (!elementType || !props.append(IdValuePair(NameToId(cx->names().element),
|
||||
StringValue(elementType)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,8 @@ bool wasm::ToValType(JSContext* cx, HandleValue v, ValType* out) {
|
|||
return true;
|
||||
}
|
||||
|
||||
UniqueChars wasm::ToString(RefType type) { return ToString(ValType(type)); }
|
||||
|
||||
UniqueChars wasm::ToString(ValType type) {
|
||||
const char* literal = nullptr;
|
||||
switch (type.kind()) {
|
||||
|
|
|
@ -725,6 +725,8 @@ static inline jit::MIRType ToMIRType(const Maybe<ValType>& t) {
|
|||
|
||||
extern bool ToValType(JSContext* cx, HandleValue v, ValType* out);
|
||||
|
||||
extern UniqueChars ToString(RefType type);
|
||||
|
||||
extern UniqueChars ToString(ValType type);
|
||||
|
||||
extern UniqueChars ToString(const Maybe<ValType>& type);
|
||||
|
|
Загрузка…
Ссылка в новой задаче