Commit e6b853ef authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[wasm] Rename 'anyfunc' to 'funcref'.

Change-Id: Ia506f4741e6ff9f024199d1b1fa7abb7dafe2b25
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1682835
Commit-Queue: Bill Budge <bbudge@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarBen Smith <binji@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62581}
parent 5f9dfee5
...@@ -2196,7 +2196,7 @@ Node* WasmGraphBuilder::Throw(uint32_t exception_index, ...@@ -2196,7 +2196,7 @@ Node* WasmGraphBuilder::Throw(uint32_t exception_index,
graph()->NewNode(m->I32x4ExtractLane(3), value)); graph()->NewNode(m->I32x4ExtractLane(3), value));
break; break;
case wasm::kWasmAnyRef: case wasm::kWasmAnyRef:
case wasm::kWasmAnyFunc: case wasm::kWasmFuncRef:
case wasm::kWasmExceptRef: case wasm::kWasmExceptRef:
STORE_FIXED_ARRAY_SLOT_ANY(values_array, index, value); STORE_FIXED_ARRAY_SLOT_ANY(values_array, index, value);
++index; ++index;
...@@ -2335,7 +2335,7 @@ Node** WasmGraphBuilder::GetExceptionValues( ...@@ -2335,7 +2335,7 @@ Node** WasmGraphBuilder::GetExceptionValues(
BuildDecodeException32BitValue(values_array, &index)); BuildDecodeException32BitValue(values_array, &index));
break; break;
case wasm::kWasmAnyRef: case wasm::kWasmAnyRef:
case wasm::kWasmAnyFunc: case wasm::kWasmFuncRef:
case wasm::kWasmExceptRef: case wasm::kWasmExceptRef:
value = LOAD_FIXED_ARRAY_SLOT_ANY(values_array, index); value = LOAD_FIXED_ARRAY_SLOT_ANY(values_array, index);
++index; ++index;
...@@ -3493,7 +3493,7 @@ Node* WasmGraphBuilder::TableGet(uint32_t table_index, Node* index, ...@@ -3493,7 +3493,7 @@ Node* WasmGraphBuilder::TableGet(uint32_t table_index, Node* index,
return LOAD_RAW_NODE_OFFSET(base, offset, return LOAD_RAW_NODE_OFFSET(base, offset,
MachineType::TypeCompressedTagged()); MachineType::TypeCompressedTagged());
} }
// We access anyfunc tables through runtime calls. // We access funcref tables through runtime calls.
WasmTableGetDescriptor interface_descriptor; WasmTableGetDescriptor interface_descriptor;
auto call_descriptor = Linkage::GetStubCallDescriptor( auto call_descriptor = Linkage::GetStubCallDescriptor(
mcgraph()->zone(), // zone mcgraph()->zone(), // zone
...@@ -3522,7 +3522,7 @@ Node* WasmGraphBuilder::TableSet(uint32_t table_index, Node* index, Node* val, ...@@ -3522,7 +3522,7 @@ Node* WasmGraphBuilder::TableSet(uint32_t table_index, Node* index, Node* val,
return STORE_RAW_NODE_OFFSET( return STORE_RAW_NODE_OFFSET(
base, offset, val, MachineRepresentation::kTagged, kFullWriteBarrier); base, offset, val, MachineRepresentation::kTagged, kFullWriteBarrier);
} else { } else {
// We access anyfunc tables through runtime calls. // We access funcref tables through runtime calls.
WasmTableSetDescriptor interface_descriptor; WasmTableSetDescriptor interface_descriptor;
auto call_descriptor = Linkage::GetStubCallDescriptor( auto call_descriptor = Linkage::GetStubCallDescriptor(
mcgraph()->zone(), // zone mcgraph()->zone(), // zone
...@@ -5175,7 +5175,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder { ...@@ -5175,7 +5175,7 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
case wasm::kWasmF64: case wasm::kWasmF64:
return BuildChangeFloat64ToTagged(node); return BuildChangeFloat64ToTagged(node);
case wasm::kWasmAnyRef: case wasm::kWasmAnyRef:
case wasm::kWasmAnyFunc: case wasm::kWasmFuncRef:
case wasm::kWasmExceptRef: case wasm::kWasmExceptRef:
return node; return node;
default: default:
...@@ -5235,10 +5235,10 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder { ...@@ -5235,10 +5235,10 @@ class WasmWrapperGraphBuilder : public WasmGraphBuilder {
return node; return node;
} }
if (type == wasm::kWasmAnyFunc) { if (type == wasm::kWasmFuncRef) {
Node* check = Node* check =
BuildChangeSmiToInt32(SetEffect(BuildCallToRuntimeWithContext( BuildChangeSmiToInt32(SetEffect(BuildCallToRuntimeWithContext(
Runtime::kWasmIsValidAnyFuncValue, js_context, &node, 1, effect_, Runtime::kWasmIsValidFuncRefValue, js_context, &node, 1, effect_,
Control()))); Control())));
Diamond type_check(graph(), mcgraph()->common(), check, Diamond type_check(graph(), mcgraph()->common(), check,
......
...@@ -62,7 +62,7 @@ Object ThrowWasmError(Isolate* isolate, MessageTemplate message) { ...@@ -62,7 +62,7 @@ Object ThrowWasmError(Isolate* isolate, MessageTemplate message) {
} }
} // namespace } // namespace
RUNTIME_FUNCTION(Runtime_WasmIsValidAnyFuncValue) { RUNTIME_FUNCTION(Runtime_WasmIsValidFuncRefValue) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(1, args.length()); DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(Object, function, 0); CONVERT_ARG_HANDLE_CHECKED(Object, function, 0);
...@@ -224,7 +224,7 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) { ...@@ -224,7 +224,7 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
CASE_ARG_TYPE(kWasmF64, double) CASE_ARG_TYPE(kWasmF64, double)
#undef CASE_ARG_TYPE #undef CASE_ARG_TYPE
case wasm::kWasmAnyRef: case wasm::kWasmAnyRef:
case wasm::kWasmAnyFunc: case wasm::kWasmFuncRef:
case wasm::kWasmExceptRef: { case wasm::kWasmExceptRef: {
DCHECK_EQ(wasm::ValueTypes::ElementSizeInBytes(sig->GetParam(i)), DCHECK_EQ(wasm::ValueTypes::ElementSizeInBytes(sig->GetParam(i)),
kSystemPointerSize); kSystemPointerSize);
...@@ -275,7 +275,7 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) { ...@@ -275,7 +275,7 @@ RUNTIME_FUNCTION(Runtime_WasmRunInterpreter) {
CASE_RET_TYPE(kWasmF64, double) CASE_RET_TYPE(kWasmF64, double)
#undef CASE_RET_TYPE #undef CASE_RET_TYPE
case wasm::kWasmAnyRef: case wasm::kWasmAnyRef:
case wasm::kWasmAnyFunc: case wasm::kWasmFuncRef:
case wasm::kWasmExceptRef: { case wasm::kWasmExceptRef: {
DCHECK_EQ(wasm::ValueTypes::ElementSizeInBytes(sig->GetReturn(i)), DCHECK_EQ(wasm::ValueTypes::ElementSizeInBytes(sig->GetReturn(i)),
kSystemPointerSize); kSystemPointerSize);
......
...@@ -548,7 +548,7 @@ namespace internal { ...@@ -548,7 +548,7 @@ namespace internal {
F(WasmTableCopy, 5, 1) \ F(WasmTableCopy, 5, 1) \
F(WasmTableGrow, 3, 1) \ F(WasmTableGrow, 3, 1) \
F(WasmTableFill, 4, 1) \ F(WasmTableFill, 4, 1) \
F(WasmIsValidAnyFuncValue, 1, 1) \ F(WasmIsValidFuncRefValue, 1, 1) \
F(WasmCompileLazy, 2, 1) F(WasmCompileLazy, 2, 1)
#define FOR_EACH_INTRINSIC_RETURN_PAIR_IMPL(F, I) \ #define FOR_EACH_INTRINSIC_RETURN_PAIR_IMPL(F, I) \
......
...@@ -218,7 +218,7 @@ class LiftoffCompiler { ...@@ -218,7 +218,7 @@ class LiftoffCompiler {
case kWasmS128: case kWasmS128:
return kSimd; return kSimd;
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmNullRef: case kWasmNullRef:
return kAnyRef; return kAnyRef;
case kWasmExceptRef: case kWasmExceptRef:
......
...@@ -226,7 +226,7 @@ auto valtype(const byte_t*& pos) // NOLINT(runtime/references) ...@@ -226,7 +226,7 @@ auto valtype(const byte_t*& pos) // NOLINT(runtime/references)
return ValType::make(F32); return ValType::make(F32);
case i::wasm::kLocalF64: case i::wasm::kLocalF64:
return ValType::make(F64); return ValType::make(F64);
case i::wasm::kLocalAnyFunc: case i::wasm::kLocalFuncRef:
return ValType::make(FUNCREF); return ValType::make(FUNCREF);
case i::wasm::kLocalAnyRef: case i::wasm::kLocalAnyRef:
return ValType::make(ANYREF); return ValType::make(ANYREF);
...@@ -584,7 +584,7 @@ auto v8_valtype_to_wasm(i::wasm::ValueType v8_valtype) -> ::wasm::ValKind { ...@@ -584,7 +584,7 @@ auto v8_valtype_to_wasm(i::wasm::ValueType v8_valtype) -> ::wasm::ValKind {
return ::wasm::F32; return ::wasm::F32;
case i::wasm::kWasmF64: case i::wasm::kWasmF64:
return ::wasm::F64; return ::wasm::F64;
case i::wasm::kWasmAnyFunc: case i::wasm::kWasmFuncRef:
return ::wasm::FUNCREF; return ::wasm::FUNCREF;
case i::wasm::kWasmAnyRef: case i::wasm::kWasmAnyRef:
return ::wasm::ANYREF; return ::wasm::ANYREF;
...@@ -605,7 +605,7 @@ i::wasm::ValueType wasm_valtype_to_v8(::wasm::ValKind type) { ...@@ -605,7 +605,7 @@ i::wasm::ValueType wasm_valtype_to_v8(::wasm::ValKind type) {
case ::wasm::F64: case ::wasm::F64:
return i::wasm::kWasmF64; return i::wasm::kWasmF64;
case ::wasm::FUNCREF: case ::wasm::FUNCREF:
return i::wasm::kWasmAnyFunc; return i::wasm::kWasmFuncRef;
case ::wasm::ANYREF: case ::wasm::ANYREF:
return i::wasm::kWasmAnyRef; return i::wasm::kWasmAnyRef;
default: default:
...@@ -1719,7 +1719,7 @@ void PushArgs(i::wasm::FunctionSig* sig, const Val args[], ...@@ -1719,7 +1719,7 @@ void PushArgs(i::wasm::FunctionSig* sig, const Val args[],
packer->Push(args[i].f64()); packer->Push(args[i].f64());
break; break;
case i::wasm::kWasmAnyRef: case i::wasm::kWasmAnyRef:
case i::wasm::kWasmAnyFunc: case i::wasm::kWasmFuncRef:
packer->Push(impl(args[i].ref())->v8_object()->ptr()); packer->Push(impl(args[i].ref())->v8_object()->ptr());
break; break;
case i::wasm::kWasmExceptRef: case i::wasm::kWasmExceptRef:
...@@ -1751,7 +1751,7 @@ void PopArgs(i::wasm::FunctionSig* sig, Val results[], ...@@ -1751,7 +1751,7 @@ void PopArgs(i::wasm::FunctionSig* sig, Val results[],
results[i] = Val(packer->Pop<double>()); results[i] = Val(packer->Pop<double>());
break; break;
case i::wasm::kWasmAnyRef: case i::wasm::kWasmAnyRef:
case i::wasm::kWasmAnyFunc: { case i::wasm::kWasmFuncRef: {
i::Address raw = packer->Pop<i::Address>(); i::Address raw = packer->Pop<i::Address>();
if (raw == i::kNullAddress) { if (raw == i::kNullAddress) {
results[i] = Val(nullptr); results[i] = Val(nullptr);
...@@ -2042,7 +2042,7 @@ void Global::set(const Val& val) { ...@@ -2042,7 +2042,7 @@ void Global::set(const Val& val) {
case ANYREF: case ANYREF:
return v8_global->SetAnyRef(impl(val.ref())->v8_object()); return v8_global->SetAnyRef(impl(val.ref())->v8_object());
case FUNCREF: { case FUNCREF: {
bool result = v8_global->SetAnyFunc(impl(this)->store()->i_isolate(), bool result = v8_global->SetFuncRef(impl(this)->store()->i_isolate(),
impl(val.ref())->v8_object()); impl(val.ref())->v8_object());
DCHECK(result); DCHECK(result);
USE(result); USE(result);
...@@ -2076,7 +2076,7 @@ auto Table::make(Store* store_abs, const TableType* type, const Ref* ref) ...@@ -2076,7 +2076,7 @@ auto Table::make(Store* store_abs, const TableType* type, const Ref* ref)
i::wasm::ValueType i_type; i::wasm::ValueType i_type;
switch (type->element()->kind()) { switch (type->element()->kind()) {
case FUNCREF: case FUNCREF:
i_type = i::wasm::kWasmAnyFunc; i_type = i::wasm::kWasmFuncRef;
break; break;
case ANYREF: case ANYREF:
if (enabled_features.anyref) { if (enabled_features.anyref) {
......
...@@ -230,8 +230,8 @@ inline bool decode_local_type(uint8_t val, ValueType* result) { ...@@ -230,8 +230,8 @@ inline bool decode_local_type(uint8_t val, ValueType* result) {
case kLocalS128: case kLocalS128:
*result = kWasmS128; *result = kWasmS128;
return true; return true;
case kLocalAnyFunc: case kLocalFuncRef:
*result = kWasmAnyFunc; *result = kWasmFuncRef;
return true; return true;
case kLocalAnyRef: case kLocalAnyRef:
*result = kWasmAnyRef; *result = kWasmAnyRef;
...@@ -850,13 +850,13 @@ class WasmDecoder : public Decoder { ...@@ -850,13 +850,13 @@ class WasmDecoder : public Decoder {
} }
decoder->error(decoder->pc() - 1, "invalid local type"); decoder->error(decoder->pc() - 1, "invalid local type");
return false; return false;
case kLocalAnyFunc: case kLocalFuncRef:
if (enabled.anyref) { if (enabled.anyref) {
type = kWasmAnyFunc; type = kWasmFuncRef;
break; break;
} }
decoder->error(decoder->pc() - 1, decoder->error(decoder->pc() - 1,
"local type 'anyfunc' is not enabled with " "local type 'funcref' is not enabled with "
"--experimental-wasm-anyref"); "--experimental-wasm-anyref");
return false; return false;
case kLocalExceptRef: case kLocalExceptRef:
...@@ -1016,8 +1016,8 @@ class WasmDecoder : public Decoder { ...@@ -1016,8 +1016,8 @@ class WasmDecoder : public Decoder {
return false; return false;
} }
if (!VALIDATE(module_ != nullptr && if (!VALIDATE(module_ != nullptr &&
module_->tables[imm.table_index].type == kWasmAnyFunc)) { module_->tables[imm.table_index].type == kWasmFuncRef)) {
error("table of call_indirect must be of type anyfunc"); error("table of call_indirect must be of type funcref");
return false; return false;
} }
if (!Complete(pc, imm)) { if (!Complete(pc, imm)) {
...@@ -2105,7 +2105,7 @@ class WasmFullDecoder : public WasmDecoder<validate> { ...@@ -2105,7 +2105,7 @@ class WasmFullDecoder : public WasmDecoder<validate> {
CHECK_PROTOTYPE_OPCODE(anyref); CHECK_PROTOTYPE_OPCODE(anyref);
FunctionIndexImmediate<validate> imm(this, this->pc_); FunctionIndexImmediate<validate> imm(this, this->pc_);
if (!this->Validate(this->pc_, imm)) break; if (!this->Validate(this->pc_, imm)) break;
auto* value = Push(kWasmAnyFunc); auto* value = Push(kWasmFuncRef);
CALL_INTERFACE_IF_REACHABLE(RefFunc, imm.index, value); CALL_INTERFACE_IF_REACHABLE(RefFunc, imm.index, value);
len = 1 + imm.length; len = 1 + imm.length;
break; break;
......
...@@ -691,7 +691,7 @@ class WasmGraphBuildingInterface { ...@@ -691,7 +691,7 @@ class WasmGraphBuildingInterface {
case kWasmS128: case kWasmS128:
return builder_->S128Zero(); return builder_->S128Zero();
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmExceptRef: case kWasmExceptRef:
return builder_->RefNull(); return builder_->RefNull();
default: default:
......
...@@ -123,7 +123,7 @@ ValueType TypeOf(const WasmModule* module, const WasmInitExpr& expr) { ...@@ -123,7 +123,7 @@ ValueType TypeOf(const WasmModule* module, const WasmInitExpr& expr) {
case WasmInitExpr::kRefNullConst: case WasmInitExpr::kRefNullConst:
return kWasmNullRef; return kWasmNullRef;
case WasmInitExpr::kRefFuncConst: case WasmInitExpr::kRefFuncConst:
return kWasmAnyFunc; return kWasmFuncRef;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
...@@ -550,7 +550,7 @@ class ModuleDecoderImpl : public Decoder { ...@@ -550,7 +550,7 @@ class ModuleDecoderImpl : public Decoder {
table->imported = true; table->imported = true;
ValueType type = consume_reference_type(); ValueType type = consume_reference_type();
if (!enabled_features_.anyref) { if (!enabled_features_.anyref) {
if (type != kWasmAnyFunc) { if (type != kWasmFuncRef) {
error(pc_ - 1, "invalid table type"); error(pc_ - 1, "invalid table type");
break; break;
} }
...@@ -808,16 +808,16 @@ class ModuleDecoderImpl : public Decoder { ...@@ -808,16 +808,16 @@ class ModuleDecoderImpl : public Decoder {
errorf(pos, "out of bounds table index %u", table_index); errorf(pos, "out of bounds table index %u", table_index);
break; break;
} }
if (!ValueTypes::IsSubType(kWasmAnyFunc, if (!ValueTypes::IsSubType(kWasmFuncRef,
module_->tables[table_index].type)) { module_->tables[table_index].type)) {
errorf(pos, errorf(pos,
"Invalid element segment. Table %u is not of type AnyFunc", "Invalid element segment. Table %u is not of type FuncRef",
table_index); table_index);
break; break;
} }
} else { } else {
ValueType type = consume_reference_type(); ValueType type = consume_reference_type();
if (!ValueTypes::IsSubType(kWasmAnyFunc, type)) { if (!ValueTypes::IsSubType(kWasmFuncRef, type)) {
error(pc_ - 1, "invalid element segment type"); error(pc_ - 1, "invalid element segment type");
break; break;
} }
...@@ -1595,8 +1595,8 @@ class ModuleDecoderImpl : public Decoder { ...@@ -1595,8 +1595,8 @@ class ModuleDecoderImpl : public Decoder {
case kLocalS128: case kLocalS128:
if (enabled_features_.simd) return kWasmS128; if (enabled_features_.simd) return kWasmS128;
break; break;
case kLocalAnyFunc: case kLocalFuncRef:
if (enabled_features_.anyref) return kWasmAnyFunc; if (enabled_features_.anyref) return kWasmFuncRef;
break; break;
case kLocalAnyRef: case kLocalAnyRef:
if (enabled_features_.anyref) return kWasmAnyRef; if (enabled_features_.anyref) return kWasmAnyRef;
...@@ -1618,8 +1618,8 @@ class ModuleDecoderImpl : public Decoder { ...@@ -1618,8 +1618,8 @@ class ModuleDecoderImpl : public Decoder {
byte val = consume_u8("reference type"); byte val = consume_u8("reference type");
ValueTypeCode t = static_cast<ValueTypeCode>(val); ValueTypeCode t = static_cast<ValueTypeCode>(val);
switch (t) { switch (t) {
case kLocalAnyFunc: case kLocalFuncRef:
return kWasmAnyFunc; return kWasmFuncRef;
case kLocalAnyRef: case kLocalAnyRef:
if (!enabled_features_.anyref) { if (!enabled_features_.anyref) {
error(pc_ - 1, error(pc_ - 1,
......
...@@ -176,7 +176,7 @@ class InstanceBuilder { ...@@ -176,7 +176,7 @@ class InstanceBuilder {
Handle<String> import_name, Handle<String> import_name,
Handle<Object> value); Handle<Object> value);
// Initialize imported tables of type anyfunc. // Initialize imported tables of type funcref.
bool InitializeImportedIndirectFunctionTable( bool InitializeImportedIndirectFunctionTable(
Handle<WasmInstanceObject> instance, int table_index, int import_index, Handle<WasmInstanceObject> instance, int table_index, int import_index,
Handle<WasmTableObject> table_object); Handle<WasmTableObject> table_object);
...@@ -417,7 +417,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { ...@@ -417,7 +417,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
// iteration below. // iteration below.
for (int i = 1; i < table_count; ++i) { for (int i = 1; i < table_count; ++i) {
const WasmTable& table = module_->tables[i]; const WasmTable& table = module_->tables[i];
if (table.type == kWasmAnyFunc) { if (table.type == kWasmFuncRef) {
Handle<WasmIndirectFunctionTable> table_obj = Handle<WasmIndirectFunctionTable> table_obj =
WasmIndirectFunctionTable::New(isolate_, table.initial_size); WasmIndirectFunctionTable::New(isolate_, table.initial_size);
tables->set(i, *table_obj); tables->set(i, *table_obj);
...@@ -750,7 +750,7 @@ void InstanceBuilder::WriteGlobalValue(const WasmGlobal& global, ...@@ -750,7 +750,7 @@ void InstanceBuilder::WriteGlobalValue(const WasmGlobal& global,
break; break;
} }
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmExceptRef: { case kWasmExceptRef: {
tagged_globals_->set(global.offset, *value->GetRef()); tagged_globals_->set(global.offset, *value->GetRef());
break; break;
...@@ -994,7 +994,7 @@ bool InstanceBuilder::ProcessImportedTable(Handle<WasmInstanceObject> instance, ...@@ -994,7 +994,7 @@ bool InstanceBuilder::ProcessImportedTable(Handle<WasmInstanceObject> instance,
return false; return false;
} }
if (table.type == kWasmAnyFunc && if (table.type == kWasmFuncRef &&
!InitializeImportedIndirectFunctionTable(instance, table_index, !InitializeImportedIndirectFunctionTable(instance, table_index,
import_index, table_object)) { import_index, table_object)) {
return false; return false;
...@@ -1161,11 +1161,11 @@ bool InstanceBuilder::ProcessImportedGlobal(Handle<WasmInstanceObject> instance, ...@@ -1161,11 +1161,11 @@ bool InstanceBuilder::ProcessImportedGlobal(Handle<WasmInstanceObject> instance,
if (ValueTypes::IsReferenceType(global.type)) { if (ValueTypes::IsReferenceType(global.type)) {
// There shouldn't be any null-ref globals. // There shouldn't be any null-ref globals.
DCHECK_NE(ValueType::kWasmNullRef, global.type); DCHECK_NE(ValueType::kWasmNullRef, global.type);
if (global.type == ValueType::kWasmAnyFunc) { if (global.type == ValueType::kWasmFuncRef) {
if (!value->IsNull(isolate_) && if (!value->IsNull(isolate_) &&
!WasmExportedFunction::IsWasmExportedFunction(*value)) { !WasmExportedFunction::IsWasmExportedFunction(*value)) {
ReportLinkError( ReportLinkError(
"imported anyfunc global must be null or an exported function", "imported funcref global must be null or an exported function",
import_index, module_name, import_name); import_index, module_name, import_name);
return false; return false;
} }
...@@ -1430,7 +1430,7 @@ Handle<JSArrayBuffer> InstanceBuilder::AllocateMemory(uint32_t initial_pages, ...@@ -1430,7 +1430,7 @@ Handle<JSArrayBuffer> InstanceBuilder::AllocateMemory(uint32_t initial_pages,
bool InstanceBuilder::NeedsWrappers() const { bool InstanceBuilder::NeedsWrappers() const {
if (module_->num_exported_functions > 0) return true; if (module_->num_exported_functions > 0) return true;
for (auto& table : module_->tables) { for (auto& table : module_->tables) {
if (table.type == kWasmAnyFunc) return true; if (table.type == kWasmFuncRef) return true;
} }
return false; return false;
} }
...@@ -1613,7 +1613,7 @@ void InstanceBuilder::InitializeIndirectFunctionTables( ...@@ -1613,7 +1613,7 @@ void InstanceBuilder::InitializeIndirectFunctionTables(
for (int i = 0; i < static_cast<int>(module_->tables.size()); ++i) { for (int i = 0; i < static_cast<int>(module_->tables.size()); ++i) {
const WasmTable& table = module_->tables[i]; const WasmTable& table = module_->tables[i];
if (table.type == kWasmAnyFunc) { if (table.type == kWasmFuncRef) {
WasmInstanceObject::EnsureIndirectFunctionTableWithMinimumSize( WasmInstanceObject::EnsureIndirectFunctionTableWithMinimumSize(
instance, i, table.initial_size); instance, i, table.initial_size);
} }
...@@ -1638,7 +1638,7 @@ bool LoadElemSegmentImpl(Isolate* isolate, Handle<WasmInstanceObject> instance, ...@@ -1638,7 +1638,7 @@ bool LoadElemSegmentImpl(Isolate* isolate, Handle<WasmInstanceObject> instance,
int entry_index = static_cast<int>(dst + i); int entry_index = static_cast<int>(dst + i);
if (func_index == WasmElemSegment::kNullIndex) { if (func_index == WasmElemSegment::kNullIndex) {
if (table_object->type() == kWasmAnyFunc) { if (table_object->type() == kWasmFuncRef) {
IndirectFunctionTableEntry(instance, elem_segment.table_index, IndirectFunctionTableEntry(instance, elem_segment.table_index,
entry_index) entry_index)
.clear(); .clear();
...@@ -1651,7 +1651,7 @@ bool LoadElemSegmentImpl(Isolate* isolate, Handle<WasmInstanceObject> instance, ...@@ -1651,7 +1651,7 @@ bool LoadElemSegmentImpl(Isolate* isolate, Handle<WasmInstanceObject> instance,
const WasmFunction* function = &module->functions[func_index]; const WasmFunction* function = &module->functions[func_index];
// Update the local dispatch table first if necessary. // Update the local dispatch table first if necessary.
if (table_object->type() == kWasmAnyFunc) { if (table_object->type() == kWasmFuncRef) {
uint32_t sig_id = module->signature_ids[function->sig_index]; uint32_t sig_id = module->signature_ids[function->sig_index];
IndirectFunctionTableEntry(instance, elem_segment.table_index, IndirectFunctionTableEntry(instance, elem_segment.table_index,
entry_index) entry_index)
...@@ -1720,7 +1720,7 @@ void InstanceBuilder::LoadTableSegments(Handle<WasmInstanceObject> instance) { ...@@ -1720,7 +1720,7 @@ void InstanceBuilder::LoadTableSegments(Handle<WasmInstanceObject> instance) {
int table_count = static_cast<int>(module_->tables.size()); int table_count = static_cast<int>(module_->tables.size());
for (int index = 0; index < table_count; ++index) { for (int index = 0; index < table_count; ++index) {
if (module_->tables[index].type == kWasmAnyFunc) { if (module_->tables[index].type == kWasmFuncRef) {
auto table_object = handle( auto table_object = handle(
WasmTableObject::cast(instance->tables().get(index)), isolate_); WasmTableObject::cast(instance->tables().get(index)), isolate_);
......
...@@ -21,7 +21,7 @@ namespace wasm { ...@@ -21,7 +21,7 @@ namespace wasm {
// //
// AnyRef // AnyRef
// / \ // / \
// AnyFunc ExceptRef // FuncRef ExceptRef
// \ / // \ /
// I32 I64 F32 F64 NullRef // I32 I64 F32 F64 NullRef
// \ \ \ \ / // \ \ \ \ /
...@@ -34,7 +34,7 @@ enum ValueType : uint8_t { ...@@ -34,7 +34,7 @@ enum ValueType : uint8_t {
kWasmF64, kWasmF64,
kWasmS128, kWasmS128,
kWasmAnyRef, kWasmAnyRef,
kWasmAnyFunc, kWasmFuncRef,
kWasmNullRef, kWasmNullRef,
kWasmExceptRef, kWasmExceptRef,
kWasmBottom, kWasmBottom,
...@@ -191,9 +191,9 @@ class V8_EXPORT_PRIVATE ValueTypes { ...@@ -191,9 +191,9 @@ class V8_EXPORT_PRIVATE ValueTypes {
static inline bool IsSubType(ValueType actual, ValueType expected) { static inline bool IsSubType(ValueType actual, ValueType expected) {
return (expected == actual) || return (expected == actual) ||
(expected == kWasmAnyRef && actual == kWasmNullRef) || (expected == kWasmAnyRef && actual == kWasmNullRef) ||
(expected == kWasmAnyRef && actual == kWasmAnyFunc) || (expected == kWasmAnyRef && actual == kWasmFuncRef) ||
(expected == kWasmAnyRef && actual == kWasmExceptRef) || (expected == kWasmAnyRef && actual == kWasmExceptRef) ||
(expected == kWasmAnyFunc && actual == kWasmNullRef) || (expected == kWasmFuncRef && actual == kWasmNullRef) ||
// TODO(mstarzinger): For now we treat "null_ref" as a sub-type of // TODO(mstarzinger): For now we treat "null_ref" as a sub-type of
// "except_ref", which is correct but might change. See here: // "except_ref", which is correct but might change. See here:
// https://github.com/WebAssembly/exception-handling/issues/55 // https://github.com/WebAssembly/exception-handling/issues/55
...@@ -201,7 +201,7 @@ class V8_EXPORT_PRIVATE ValueTypes { ...@@ -201,7 +201,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
} }
static inline bool IsReferenceType(ValueType type) { static inline bool IsReferenceType(ValueType type) {
return type == kWasmAnyRef || type == kWasmAnyFunc || return type == kWasmAnyRef || type == kWasmFuncRef ||
type == kWasmExceptRef; type == kWasmExceptRef;
} }
...@@ -231,7 +231,7 @@ class V8_EXPORT_PRIVATE ValueTypes { ...@@ -231,7 +231,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
case kWasmS128: case kWasmS128:
return 16; return 16;
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmExceptRef: case kWasmExceptRef:
return kSystemPointerSize; return kSystemPointerSize;
default: default:
...@@ -250,7 +250,7 @@ class V8_EXPORT_PRIVATE ValueTypes { ...@@ -250,7 +250,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
case kWasmS128: case kWasmS128:
return 4; return 4;
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmExceptRef: case kWasmExceptRef:
return kSystemPointerSizeLog2; return kSystemPointerSizeLog2;
default: default:
...@@ -274,8 +274,8 @@ class V8_EXPORT_PRIVATE ValueTypes { ...@@ -274,8 +274,8 @@ class V8_EXPORT_PRIVATE ValueTypes {
return kLocalS128; return kLocalS128;
case kWasmAnyRef: case kWasmAnyRef:
return kLocalAnyRef; return kLocalAnyRef;
case kWasmAnyFunc: case kWasmFuncRef:
return kLocalAnyFunc; return kLocalFuncRef;
case kWasmExceptRef: case kWasmExceptRef:
return kLocalExceptRef; return kLocalExceptRef;
case kWasmStmt: case kWasmStmt:
...@@ -296,7 +296,7 @@ class V8_EXPORT_PRIVATE ValueTypes { ...@@ -296,7 +296,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
case kWasmF64: case kWasmF64:
return MachineType::Float64(); return MachineType::Float64();
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmExceptRef: case kWasmExceptRef:
return MachineType::TaggedPointer(); return MachineType::TaggedPointer();
case kWasmS128: case kWasmS128:
...@@ -319,7 +319,7 @@ class V8_EXPORT_PRIVATE ValueTypes { ...@@ -319,7 +319,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
case kWasmF64: case kWasmF64:
return MachineRepresentation::kFloat64; return MachineRepresentation::kFloat64;
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmNullRef: case kWasmNullRef:
case kWasmExceptRef: case kWasmExceptRef:
return MachineRepresentation::kTaggedPointer; return MachineRepresentation::kTaggedPointer;
...@@ -365,7 +365,7 @@ class V8_EXPORT_PRIVATE ValueTypes { ...@@ -365,7 +365,7 @@ class V8_EXPORT_PRIVATE ValueTypes {
return 'd'; return 'd';
case kWasmAnyRef: case kWasmAnyRef:
return 'r'; return 'r';
case kWasmAnyFunc: case kWasmFuncRef:
return 'a'; return 'a';
case kWasmS128: case kWasmS128:
return 's'; return 's';
...@@ -390,8 +390,8 @@ class V8_EXPORT_PRIVATE ValueTypes { ...@@ -390,8 +390,8 @@ class V8_EXPORT_PRIVATE ValueTypes {
return "f64"; return "f64";
case kWasmAnyRef: case kWasmAnyRef:
return "anyref"; return "anyref";
case kWasmAnyFunc: case kWasmFuncRef:
return "anyfunc"; return "funcref";
case kWasmNullRef: case kWasmNullRef:
return "nullref"; return "nullref";
case kWasmExceptRef: case kWasmExceptRef:
......
...@@ -26,7 +26,7 @@ enum ValueTypeCode : uint8_t { ...@@ -26,7 +26,7 @@ enum ValueTypeCode : uint8_t {
kLocalF32 = 0x7d, kLocalF32 = 0x7d,
kLocalF64 = 0x7c, kLocalF64 = 0x7c,
kLocalS128 = 0x7b, kLocalS128 = 0x7b,
kLocalAnyFunc = 0x70, kLocalFuncRef = 0x70,
kLocalAnyRef = 0x6f, kLocalAnyRef = 0x6f,
kLocalExceptRef = 0x68, kLocalExceptRef = 0x68,
}; };
......
...@@ -1284,7 +1284,7 @@ class ThreadImpl { ...@@ -1284,7 +1284,7 @@ class ThreadImpl {
WASM_CTYPES(CASE_TYPE) WASM_CTYPES(CASE_TYPE)
#undef CASE_TYPE #undef CASE_TYPE
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmExceptRef: { case kWasmExceptRef: {
HandleScope handle_scope(isolate_); // Avoid leaking handles. HandleScope handle_scope(isolate_); // Avoid leaking handles.
Handle<FixedArray> global_buffer; // The buffer of the global. Handle<FixedArray> global_buffer; // The buffer of the global.
...@@ -1465,7 +1465,7 @@ class ThreadImpl { ...@@ -1465,7 +1465,7 @@ class ThreadImpl {
WASM_CTYPES(CASE_TYPE) WASM_CTYPES(CASE_TYPE)
#undef CASE_TYPE #undef CASE_TYPE
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmExceptRef: { case kWasmExceptRef: {
val = WasmValue(isolate_->factory()->null_value()); val = WasmValue(isolate_->factory()->null_value());
break; break;
...@@ -2607,7 +2607,7 @@ class ThreadImpl { ...@@ -2607,7 +2607,7 @@ class ThreadImpl {
break; break;
} }
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmExceptRef: { case kWasmExceptRef: {
Handle<Object> anyref = value.to_anyref(); Handle<Object> anyref = value.to_anyref();
encoded_values->set(encoded_index++, *anyref); encoded_values->set(encoded_index++, *anyref);
...@@ -2707,7 +2707,7 @@ class ThreadImpl { ...@@ -2707,7 +2707,7 @@ class ThreadImpl {
break; break;
} }
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmExceptRef: { case kWasmExceptRef: {
Handle<Object> anyref(encoded_values->get(encoded_index++), isolate_); Handle<Object> anyref(encoded_values->get(encoded_index++), isolate_);
value = WasmValue(anyref); value = WasmValue(anyref);
...@@ -3165,7 +3165,7 @@ class ThreadImpl { ...@@ -3165,7 +3165,7 @@ class ThreadImpl {
WASM_CTYPES(CASE_TYPE) WASM_CTYPES(CASE_TYPE)
#undef CASE_TYPE #undef CASE_TYPE
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmExceptRef: { case kWasmExceptRef: {
HandleScope handle_scope(isolate_); // Avoid leaking handles. HandleScope handle_scope(isolate_); // Avoid leaking handles.
Handle<FixedArray> global_buffer; // The buffer of the global. Handle<FixedArray> global_buffer; // The buffer of the global.
...@@ -3626,7 +3626,7 @@ class ThreadImpl { ...@@ -3626,7 +3626,7 @@ class ThreadImpl {
packer.Push(arg.to<double>()); packer.Push(arg.to<double>());
break; break;
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmExceptRef: case kWasmExceptRef:
packer.Push(arg.to_anyref()->ptr()); packer.Push(arg.to_anyref()->ptr());
break; break;
...@@ -3665,7 +3665,7 @@ class ThreadImpl { ...@@ -3665,7 +3665,7 @@ class ThreadImpl {
Push(WasmValue(packer.Pop<double>())); Push(WasmValue(packer.Pop<double>()));
break; break;
case kWasmAnyRef: case kWasmAnyRef:
case kWasmAnyFunc: case kWasmFuncRef:
case kWasmExceptRef: { case kWasmExceptRef: {
Handle<Object> ref(Object(packer.Pop<Address>()), isolate); Handle<Object> ref(Object(packer.Pop<Address>()), isolate);
Push(WasmValue(ref)); Push(WasmValue(ref));
......
...@@ -1094,7 +1094,7 @@ void WebAssemblyTable(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -1094,7 +1094,7 @@ void WebAssemblyTable(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (!value->ToString(context).ToLocal(&string)) return; if (!value->ToString(context).ToLocal(&string)) return;
auto enabled_features = i::wasm::WasmFeaturesFromFlags(); auto enabled_features = i::wasm::WasmFeaturesFromFlags();
if (string->StringEquals(v8_str(isolate, "anyfunc"))) { if (string->StringEquals(v8_str(isolate, "anyfunc"))) {
type = i::wasm::kWasmAnyFunc; type = i::wasm::kWasmFuncRef;
} else if (enabled_features.anyref && } else if (enabled_features.anyref &&
string->StringEquals(v8_str(isolate, "anyref"))) { string->StringEquals(v8_str(isolate, "anyref"))) {
type = i::wasm::kWasmAnyRef; type = i::wasm::kWasmAnyRef;
...@@ -1222,7 +1222,7 @@ bool GetValueType(Isolate* isolate, MaybeLocal<Value> maybe, ...@@ -1222,7 +1222,7 @@ bool GetValueType(Isolate* isolate, MaybeLocal<Value> maybe,
*type = i::wasm::kWasmAnyRef; *type = i::wasm::kWasmAnyRef;
} else if (enabled_features.anyref && } else if (enabled_features.anyref &&
string->StringEquals(v8_str(isolate, "anyfunc"))) { string->StringEquals(v8_str(isolate, "anyfunc"))) {
*type = i::wasm::kWasmAnyFunc; *type = i::wasm::kWasmFuncRef;
} else { } else {
// Unrecognized type. // Unrecognized type.
*type = i::wasm::kWasmStmt; *type = i::wasm::kWasmStmt;
...@@ -1347,15 +1347,15 @@ void WebAssemblyGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -1347,15 +1347,15 @@ void WebAssemblyGlobal(const v8::FunctionCallbackInfo<v8::Value>& args) {
global_obj->SetAnyRef(Utils::OpenHandle(*value)); global_obj->SetAnyRef(Utils::OpenHandle(*value));
break; break;
} }
case i::wasm::kWasmAnyFunc: { case i::wasm::kWasmFuncRef: {
if (args.Length() < 2) { if (args.Length() < 2) {
// When no inital value is provided, we have to use the WebAssembly // When no inital value is provided, we have to use the WebAssembly
// default value 'null', and not the JS default value 'undefined'. // default value 'null', and not the JS default value 'undefined'.
global_obj->SetAnyFunc(i_isolate, i_isolate->factory()->null_value()); global_obj->SetFuncRef(i_isolate, i_isolate->factory()->null_value());
break; break;
} }
if (!global_obj->SetAnyFunc(i_isolate, Utils::OpenHandle(*value))) { if (!global_obj->SetFuncRef(i_isolate, Utils::OpenHandle(*value))) {
thrower.TypeError( thrower.TypeError(
"The value of anyfunc globals must be null or an " "The value of anyfunc globals must be null or an "
"exported function"); "exported function");
...@@ -1685,7 +1685,7 @@ void WebAssemblyTableType(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -1685,7 +1685,7 @@ void WebAssemblyTableType(const v8::FunctionCallbackInfo<v8::Value>& args) {
Local<String> element; Local<String> element;
auto enabled_features = i::wasm::WasmFeaturesFromFlags(); auto enabled_features = i::wasm::WasmFeaturesFromFlags();
if (table->type() == i::wasm::ValueType::kWasmAnyFunc) { if (table->type() == i::wasm::ValueType::kWasmFuncRef) {
element = v8_str(isolate, "anyfunc"); element = v8_str(isolate, "anyfunc");
} else if (enabled_features.anyref && } else if (enabled_features.anyref &&
table->type() == i::wasm::ValueType::kWasmAnyRef) { table->type() == i::wasm::ValueType::kWasmAnyRef) {
...@@ -1693,7 +1693,6 @@ void WebAssemblyTableType(const v8::FunctionCallbackInfo<v8::Value>& args) { ...@@ -1693,7 +1693,6 @@ void WebAssemblyTableType(const v8::FunctionCallbackInfo<v8::Value>& args) {
} else { } else {
UNREACHABLE(); UNREACHABLE();
} }
// TODO(aseemgarg): update anyfunc to funcref
if (!ret->CreateDataProperty(isolate->GetCurrentContext(), if (!ret->CreateDataProperty(isolate->GetCurrentContext(),
v8_str(isolate, "element"), element) v8_str(isolate, "element"), element)
.IsJust()) { .IsJust()) {
...@@ -1864,7 +1863,7 @@ void WebAssemblyGlobalGetValueCommon( ...@@ -1864,7 +1863,7 @@ void WebAssemblyGlobalGetValueCommon(
return_value.Set(receiver->GetF64()); return_value.Set(receiver->GetF64());
break; break;
case i::wasm::kWasmAnyRef: case i::wasm::kWasmAnyRef:
case i::wasm::kWasmAnyFunc: case i::wasm::kWasmFuncRef:
case i::wasm::kWasmExceptRef: case i::wasm::kWasmExceptRef:
return_value.Set(Utils::ToLocal(receiver->GetRef())); return_value.Set(Utils::ToLocal(receiver->GetRef()));
break; break;
...@@ -1938,8 +1937,8 @@ void WebAssemblyGlobalSetValue( ...@@ -1938,8 +1937,8 @@ void WebAssemblyGlobalSetValue(
receiver->SetAnyRef(Utils::OpenHandle(*args[0])); receiver->SetAnyRef(Utils::OpenHandle(*args[0]));
break; break;
} }
case i::wasm::kWasmAnyFunc: { case i::wasm::kWasmFuncRef: {
if (!receiver->SetAnyFunc(i_isolate, Utils::OpenHandle(*args[0]))) { if (!receiver->SetFuncRef(i_isolate, Utils::OpenHandle(*args[0]))) {
thrower.TypeError( thrower.TypeError(
"value of an anyfunc reference must be either null or an " "value of an anyfunc reference must be either null or an "
"exported function"); "exported function");
......
...@@ -404,7 +404,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer* buffer) const { ...@@ -404,7 +404,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer* buffer) const {
if (indirect_functions_.size() > 0) { if (indirect_functions_.size() > 0) {
size_t start = EmitSection(kTableSectionCode, buffer); size_t start = EmitSection(kTableSectionCode, buffer);
buffer->write_u8(1); // table count buffer->write_u8(1); // table count
buffer->write_u8(kLocalAnyFunc); buffer->write_u8(kLocalFuncRef);
buffer->write_u8(kHasMaximumFlag); buffer->write_u8(kHasMaximumFlag);
buffer->write_size(indirect_functions_.size()); buffer->write_size(indirect_functions_.size());
buffer->write_size(indirect_functions_.size()); buffer->write_size(indirect_functions_.size());
......
...@@ -165,7 +165,7 @@ double WasmGlobalObject::GetF64() { ...@@ -165,7 +165,7 @@ double WasmGlobalObject::GetF64() {
} }
Handle<Object> WasmGlobalObject::GetRef() { Handle<Object> WasmGlobalObject::GetRef() {
// We use this getter for anyref, anyfunc, and except_ref. // We use this getter for anyref, funcref, and except_ref.
DCHECK(wasm::ValueTypes::IsReferenceType(type())); DCHECK(wasm::ValueTypes::IsReferenceType(type()));
return handle(tagged_buffer().get(offset()), GetIsolate()); return handle(tagged_buffer().get(offset()), GetIsolate());
} }
...@@ -192,8 +192,8 @@ void WasmGlobalObject::SetAnyRef(Handle<Object> value) { ...@@ -192,8 +192,8 @@ void WasmGlobalObject::SetAnyRef(Handle<Object> value) {
tagged_buffer().set(offset(), *value); tagged_buffer().set(offset(), *value);
} }
bool WasmGlobalObject::SetAnyFunc(Isolate* isolate, Handle<Object> value) { bool WasmGlobalObject::SetFuncRef(Isolate* isolate, Handle<Object> value) {
DCHECK_EQ(type(), wasm::kWasmAnyFunc); DCHECK_EQ(type(), wasm::kWasmFuncRef);
if (!value->IsNull(isolate) && if (!value->IsNull(isolate) &&
!WasmExportedFunction::IsWasmExportedFunction(*value) && !WasmExportedFunction::IsWasmExportedFunction(*value) &&
!WasmCapiFunction::IsWasmCapiFunction(*value)) { !WasmCapiFunction::IsWasmCapiFunction(*value)) {
......
...@@ -898,7 +898,7 @@ bool WasmTableObject::IsValidElement(Isolate* isolate, ...@@ -898,7 +898,7 @@ bool WasmTableObject::IsValidElement(Isolate* isolate,
Handle<Object> entry) { Handle<Object> entry) {
// Anyref tables take everything. // Anyref tables take everything.
if (table->type() == wasm::kWasmAnyRef) return true; if (table->type() == wasm::kWasmAnyRef) return true;
// Anyfunc tables can store {null}, {WasmExportedFunction}, {WasmJSFunction}, // FuncRef tables can store {null}, {WasmExportedFunction}, {WasmJSFunction},
// or {WasmCapiFunction} objects. // or {WasmCapiFunction} objects.
if (entry->IsNull(isolate)) return true; if (entry->IsNull(isolate)) return true;
return WasmExportedFunction::IsWasmExportedFunction(*entry) || return WasmExportedFunction::IsWasmExportedFunction(*entry) ||
...@@ -962,7 +962,7 @@ Handle<Object> WasmTableObject::Get(Isolate* isolate, ...@@ -962,7 +962,7 @@ Handle<Object> WasmTableObject::Get(Isolate* isolate,
// First we handle the easy anyref table case. // First we handle the easy anyref table case.
if (table->type() == wasm::kWasmAnyRef) return entry; if (table->type() == wasm::kWasmAnyRef) return entry;
// Now we handle the anyfunc case. // Now we handle the funcref case.
if (WasmExportedFunction::IsWasmExportedFunction(*entry) || if (WasmExportedFunction::IsWasmExportedFunction(*entry) ||
WasmCapiFunction::IsWasmCapiFunction(*entry)) { WasmCapiFunction::IsWasmCapiFunction(*entry)) {
return entry; return entry;
...@@ -1135,7 +1135,7 @@ void WasmTableObject::GetFunctionTableEntry( ...@@ -1135,7 +1135,7 @@ void WasmTableObject::GetFunctionTableEntry(
Isolate* isolate, Handle<WasmTableObject> table, int entry_index, Isolate* isolate, Handle<WasmTableObject> table, int entry_index,
bool* is_valid, bool* is_null, MaybeHandle<WasmInstanceObject>* instance, bool* is_valid, bool* is_null, MaybeHandle<WasmInstanceObject>* instance,
int* function_index, MaybeHandle<WasmJSFunction>* maybe_js_function) { int* function_index, MaybeHandle<WasmJSFunction>* maybe_js_function) {
DCHECK_EQ(table->type(), wasm::kWasmAnyFunc); DCHECK_EQ(table->type(), wasm::kWasmFuncRef);
DCHECK_LT(entry_index, table->entries().length()); DCHECK_LT(entry_index, table->entries().length());
// We initialize {is_valid} with {true}. We may change it later. // We initialize {is_valid} with {true}. We may change it later.
*is_valid = true; *is_valid = true;
...@@ -2197,7 +2197,7 @@ uint32_t WasmExceptionPackage::GetEncodedSize( ...@@ -2197,7 +2197,7 @@ uint32_t WasmExceptionPackage::GetEncodedSize(
encoded_size += 8; encoded_size += 8;
break; break;
case wasm::kWasmAnyRef: case wasm::kWasmAnyRef:
case wasm::kWasmAnyFunc: case wasm::kWasmFuncRef:
case wasm::kWasmExceptRef: case wasm::kWasmExceptRef:
encoded_size += 1; encoded_size += 1;
break; break;
......
...@@ -416,7 +416,7 @@ class WasmGlobalObject : public JSObject { ...@@ -416,7 +416,7 @@ class WasmGlobalObject : public JSObject {
inline void SetF32(float value); inline void SetF32(float value);
inline void SetF64(double value); inline void SetF64(double value);
inline void SetAnyRef(Handle<Object> value); inline void SetAnyRef(Handle<Object> value);
inline bool SetAnyFunc(Isolate* isolate, Handle<Object> value); inline bool SetFuncRef(Isolate* isolate, Handle<Object> value);
private: private:
// This function returns the address of the global's data in the // This function returns the address of the global's data in the
......
...@@ -436,7 +436,7 @@ bool IsJSCompatibleSignature(const FunctionSig* sig, bool hasBigIntFeature); ...@@ -436,7 +436,7 @@ bool IsJSCompatibleSignature(const FunctionSig* sig, bool hasBigIntFeature);
V(TableCopy, 0xfc0e, v_iii) \ V(TableCopy, 0xfc0e, v_iii) \
V(TableGrow, 0xfc0f, i_ai) \ V(TableGrow, 0xfc0f, i_ai) \
V(TableSize, 0xfc10, i_v) \ V(TableSize, 0xfc10, i_v) \
/*TableFill is polymorph in the second parameter. It's anyref or anyfunc.*/ \ /*TableFill is polymorph in the second parameter. It's anyref or funcref.*/ \
V(TableFill, 0xfc11, v_iii) V(TableFill, 0xfc11, v_iii)
#define FOREACH_ATOMIC_OPCODE(V) \ #define FOREACH_ATOMIC_OPCODE(V) \
...@@ -565,7 +565,7 @@ bool IsJSCompatibleSignature(const FunctionSig* sig, bool hasBigIntFeature); ...@@ -565,7 +565,7 @@ bool IsJSCompatibleSignature(const FunctionSig* sig, bool hasBigIntFeature);
V(i_iil, kWasmI32, kWasmI32, kWasmI32, kWasmI64) \ V(i_iil, kWasmI32, kWasmI32, kWasmI32, kWasmI64) \
V(i_ill, kWasmI32, kWasmI32, kWasmI64, kWasmI64) \ V(i_ill, kWasmI32, kWasmI32, kWasmI64, kWasmI64) \
V(i_r, kWasmI32, kWasmAnyRef) \ V(i_r, kWasmI32, kWasmAnyRef) \
V(i_ai, kWasmI32, kWasmAnyFunc, kWasmI32) V(i_ai, kWasmI32, kWasmFuncRef, kWasmI32)
#define FOREACH_SIMD_SIGNATURE(V) \ #define FOREACH_SIMD_SIGNATURE(V) \
V(s_s, kWasmS128, kWasmS128) \ V(s_s, kWasmS128, kWasmS128) \
......
...@@ -170,7 +170,7 @@ void TestingModuleBuilder::AddIndirectFunctionTable( ...@@ -170,7 +170,7 @@ void TestingModuleBuilder::AddIndirectFunctionTable(
table.initial_size = table_size; table.initial_size = table_size;
table.maximum_size = table_size; table.maximum_size = table_size;
table.has_maximum_size = true; table.has_maximum_size = true;
table.type = kWasmAnyFunc; table.type = kWasmFuncRef;
WasmInstanceObject::EnsureIndirectFunctionTableWithMinimumSize( WasmInstanceObject::EnsureIndirectFunctionTableWithMinimumSize(
instance_object(), 0, table_size); instance_object(), 0, table_size);
Handle<WasmTableObject> table_obj = Handle<WasmTableObject> table_obj =
......
...@@ -27,7 +27,7 @@ class TestSignatures { ...@@ -27,7 +27,7 @@ class TestSignatures {
sig_i_dd(1, 2, kIntDoubleTypes4), sig_i_dd(1, 2, kIntDoubleTypes4),
sig_i_r(1, 1, kIntAnyRefTypes4), sig_i_r(1, 1, kIntAnyRefTypes4),
sig_i_rr(1, 2, kIntAnyRefTypes4), sig_i_rr(1, 2, kIntAnyRefTypes4),
sig_i_a(1, 1, kIntAnyFuncTypes4), sig_i_a(1, 1, kIntFuncRefTypes4),
sig_l_v(1, 0, kLongTypes4), sig_l_v(1, 0, kLongTypes4),
sig_l_l(1, 1, kLongTypes4), sig_l_l(1, 1, kLongTypes4),
sig_l_ll(1, 2, kLongTypes4), sig_l_ll(1, 2, kLongTypes4),
...@@ -55,18 +55,18 @@ class TestSignatures { ...@@ -55,18 +55,18 @@ class TestSignatures {
for (int i = 0; i < 4; i++) kFloatTypes4[i] = kWasmF32; for (int i = 0; i < 4; i++) kFloatTypes4[i] = kWasmF32;
for (int i = 0; i < 4; i++) kDoubleTypes4[i] = kWasmF64; for (int i = 0; i < 4; i++) kDoubleTypes4[i] = kWasmF64;
for (int i = 0; i < 4; i++) kRefTypes4[i] = kWasmAnyRef; for (int i = 0; i < 4; i++) kRefTypes4[i] = kWasmAnyRef;
for (int i = 0; i < 4; i++) kFuncTypes4[i] = kWasmAnyFunc; for (int i = 0; i < 4; i++) kFuncTypes4[i] = kWasmFuncRef;
for (int i = 1; i < 4; i++) kIntLongTypes4[i] = kWasmI64; for (int i = 1; i < 4; i++) kIntLongTypes4[i] = kWasmI64;
for (int i = 1; i < 4; i++) kIntFloatTypes4[i] = kWasmF32; for (int i = 1; i < 4; i++) kIntFloatTypes4[i] = kWasmF32;
for (int i = 1; i < 4; i++) kIntDoubleTypes4[i] = kWasmF64; for (int i = 1; i < 4; i++) kIntDoubleTypes4[i] = kWasmF64;
for (int i = 1; i < 4; i++) kIntAnyRefTypes4[i] = kWasmAnyRef; for (int i = 1; i < 4; i++) kIntAnyRefTypes4[i] = kWasmAnyRef;
for (int i = 1; i < 4; i++) kIntAnyFuncTypes4[i] = kWasmAnyFunc; for (int i = 1; i < 4; i++) kIntFuncRefTypes4[i] = kWasmFuncRef;
for (int i = 0; i < 4; i++) kSimd128IntTypes4[i] = kWasmS128; for (int i = 0; i < 4; i++) kSimd128IntTypes4[i] = kWasmS128;
kIntLongTypes4[0] = kWasmI32; kIntLongTypes4[0] = kWasmI32;
kIntFloatTypes4[0] = kWasmI32; kIntFloatTypes4[0] = kWasmI32;
kIntDoubleTypes4[0] = kWasmI32; kIntDoubleTypes4[0] = kWasmI32;
kIntAnyRefTypes4[0] = kWasmI32; kIntAnyRefTypes4[0] = kWasmI32;
kIntAnyFuncTypes4[0] = kWasmI32; kIntFuncRefTypes4[0] = kWasmI32;
kSimd128IntTypes4[1] = kWasmI32; kSimd128IntTypes4[1] = kWasmI32;
} }
...@@ -129,7 +129,7 @@ class TestSignatures { ...@@ -129,7 +129,7 @@ class TestSignatures {
ValueType kIntFloatTypes4[4]; ValueType kIntFloatTypes4[4];
ValueType kIntDoubleTypes4[4]; ValueType kIntDoubleTypes4[4];
ValueType kIntAnyRefTypes4[4]; ValueType kIntAnyRefTypes4[4];
ValueType kIntAnyFuncTypes4[4]; ValueType kIntFuncRefTypes4[4];
ValueType kSimd128IntTypes4[4]; ValueType kSimd128IntTypes4[4];
FunctionSig sig_i_v; FunctionSig sig_i_v;
......
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
#define WASM_SELECT_R(tval, fval, cond) \ #define WASM_SELECT_R(tval, fval, cond) \
tval, fval, cond, kExprSelectWithType, U32V_1(1), kLocalAnyRef tval, fval, cond, kExprSelectWithType, U32V_1(1), kLocalAnyRef
#define WASM_SELECT_A(tval, fval, cond) \ #define WASM_SELECT_A(tval, fval, cond) \
tval, fval, cond, kExprSelectWithType, U32V_1(1), kLocalAnyFunc tval, fval, cond, kExprSelectWithType, U32V_1(1), kLocalFuncRef
#define WASM_RETURN0 kExprReturn #define WASM_RETURN0 kExprReturn
#define WASM_RETURN1(val) val, kExprReturn #define WASM_RETURN1(val) val, kExprReturn
......
...@@ -254,7 +254,7 @@ class TestModuleBuilder { ...@@ -254,7 +254,7 @@ class TestModuleBuilder {
byte AddTable(ValueType type, uint32_t initial_size, bool has_maximum_size, byte AddTable(ValueType type, uint32_t initial_size, bool has_maximum_size,
uint32_t maximum_size) { uint32_t maximum_size) {
CHECK(type == kWasmAnyRef || type == kWasmAnyFunc); CHECK(type == kWasmAnyRef || type == kWasmFuncRef);
mod.tables.emplace_back(); mod.tables.emplace_back();
WasmTable& table = mod.tables.back(); WasmTable& table = mod.tables.back();
table.type = type; table.type = type;
...@@ -1637,7 +1637,7 @@ TEST_F(FunctionBodyDecoderTest, SimpleIndirectReturnCalls) { ...@@ -1637,7 +1637,7 @@ TEST_F(FunctionBodyDecoderTest, SimpleIndirectReturnCalls) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder; TestModuleBuilder builder;
builder.AddTable(kWasmAnyFunc, 20, true, 30); builder.AddTable(kWasmFuncRef, 20, true, 30);
module = builder.module(); module = builder.module();
byte f0 = builder.AddSignature(sigs.i_v()); byte f0 = builder.AddSignature(sigs.i_v());
...@@ -1656,7 +1656,7 @@ TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsOutOfBounds) { ...@@ -1656,7 +1656,7 @@ TEST_F(FunctionBodyDecoderTest, IndirectReturnCallsOutOfBounds) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder; TestModuleBuilder builder;
builder.AddTable(kWasmAnyFunc, 20, false, 20); builder.AddTable(kWasmFuncRef, 20, false, 20);
module = builder.module(); module = builder.module();
ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT0(0, WASM_ZERO)}); ExpectFailure(sig, {WASM_RETURN_CALL_INDIRECT0(0, WASM_ZERO)});
...@@ -1779,7 +1779,7 @@ TEST_F(FunctionBodyDecoderTest, MultiReturnType) { ...@@ -1779,7 +1779,7 @@ TEST_F(FunctionBodyDecoderTest, MultiReturnType) {
TEST_F(FunctionBodyDecoderTest, SimpleIndirectCalls) { TEST_F(FunctionBodyDecoderTest, SimpleIndirectCalls) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder; TestModuleBuilder builder;
builder.AddTable(kWasmAnyFunc, 20, false, 20); builder.AddTable(kWasmFuncRef, 20, false, 20);
module = builder.module(); module = builder.module();
byte f0 = builder.AddSignature(sigs.i_v()); byte f0 = builder.AddSignature(sigs.i_v());
...@@ -1795,7 +1795,7 @@ TEST_F(FunctionBodyDecoderTest, SimpleIndirectCalls) { ...@@ -1795,7 +1795,7 @@ TEST_F(FunctionBodyDecoderTest, SimpleIndirectCalls) {
TEST_F(FunctionBodyDecoderTest, IndirectCallsOutOfBounds) { TEST_F(FunctionBodyDecoderTest, IndirectCallsOutOfBounds) {
FunctionSig* sig = sigs.i_i(); FunctionSig* sig = sigs.i_i();
TestModuleBuilder builder; TestModuleBuilder builder;
builder.AddTable(kWasmAnyFunc, 20, false, 20); builder.AddTable(kWasmFuncRef, 20, false, 20);
module = builder.module(); module = builder.module();
ExpectFailure(sig, {WASM_CALL_INDIRECT0(0, WASM_ZERO)}); ExpectFailure(sig, {WASM_CALL_INDIRECT0(0, WASM_ZERO)});
...@@ -2036,10 +2036,10 @@ TEST_F(FunctionBodyDecoderTest, TableSet) { ...@@ -2036,10 +2036,10 @@ TEST_F(FunctionBodyDecoderTest, TableSet) {
TestModuleBuilder builder; TestModuleBuilder builder;
module = builder.module(); module = builder.module();
byte tab_ref1 = builder.AddTable(kWasmAnyRef, 10, true, 20); byte tab_ref1 = builder.AddTable(kWasmAnyRef, 10, true, 20);
byte tab_func1 = builder.AddTable(kWasmAnyFunc, 20, true, 30); byte tab_func1 = builder.AddTable(kWasmFuncRef, 20, true, 30);
byte tab_func2 = builder.AddTable(kWasmAnyFunc, 10, false, 20); byte tab_func2 = builder.AddTable(kWasmFuncRef, 10, false, 20);
byte tab_ref2 = builder.AddTable(kWasmAnyRef, 10, false, 20); byte tab_ref2 = builder.AddTable(kWasmAnyRef, 10, false, 20);
ValueType sig_types[]{kWasmAnyRef, kWasmAnyFunc, kWasmI32}; ValueType sig_types[]{kWasmAnyRef, kWasmFuncRef, kWasmI32};
FunctionSig sig(0, 3, sig_types); FunctionSig sig(0, 3, sig_types);
byte local_ref = 0; byte local_ref = 0;
byte local_func = 1; byte local_func = 1;
...@@ -2053,7 +2053,7 @@ TEST_F(FunctionBodyDecoderTest, TableSet) { ...@@ -2053,7 +2053,7 @@ TEST_F(FunctionBodyDecoderTest, TableSet) {
ExpectValidates(&sig, {WASM_TABLE_SET(tab_ref2, WASM_I32V(8), ExpectValidates(&sig, {WASM_TABLE_SET(tab_ref2, WASM_I32V(8),
WASM_GET_LOCAL(local_ref))}); WASM_GET_LOCAL(local_ref))});
// We can store anyfunc values as anyref, but not the other way around. // We can store funcref values as anyref, but not the other way around.
ExpectValidates(&sig, {WASM_TABLE_SET(tab_ref1, WASM_I32V(4), ExpectValidates(&sig, {WASM_TABLE_SET(tab_ref1, WASM_I32V(4),
WASM_GET_LOCAL(local_func))}); WASM_GET_LOCAL(local_func))});
ExpectFailure(&sig, {WASM_TABLE_SET(tab_func1, WASM_I32V(9), ExpectFailure(&sig, {WASM_TABLE_SET(tab_func1, WASM_I32V(9),
...@@ -2079,10 +2079,10 @@ TEST_F(FunctionBodyDecoderTest, TableGet) { ...@@ -2079,10 +2079,10 @@ TEST_F(FunctionBodyDecoderTest, TableGet) {
TestModuleBuilder builder; TestModuleBuilder builder;
module = builder.module(); module = builder.module();
byte tab_ref1 = builder.AddTable(kWasmAnyRef, 10, true, 20); byte tab_ref1 = builder.AddTable(kWasmAnyRef, 10, true, 20);
byte tab_func1 = builder.AddTable(kWasmAnyFunc, 20, true, 30); byte tab_func1 = builder.AddTable(kWasmFuncRef, 20, true, 30);
byte tab_func2 = builder.AddTable(kWasmAnyFunc, 10, false, 20); byte tab_func2 = builder.AddTable(kWasmFuncRef, 10, false, 20);
byte tab_ref2 = builder.AddTable(kWasmAnyRef, 10, false, 20); byte tab_ref2 = builder.AddTable(kWasmAnyRef, 10, false, 20);
ValueType sig_types[]{kWasmAnyRef, kWasmAnyFunc, kWasmI32}; ValueType sig_types[]{kWasmAnyRef, kWasmFuncRef, kWasmI32};
FunctionSig sig(0, 3, sig_types); FunctionSig sig(0, 3, sig_types);
byte local_ref = 0; byte local_ref = 0;
byte local_func = 1; byte local_func = 1;
...@@ -2100,7 +2100,7 @@ TEST_F(FunctionBodyDecoderTest, TableGet) { ...@@ -2100,7 +2100,7 @@ TEST_F(FunctionBodyDecoderTest, TableGet) {
&sig, &sig,
{WASM_SET_LOCAL(local_func, WASM_TABLE_GET(tab_func2, WASM_I32V(7)))}); {WASM_SET_LOCAL(local_func, WASM_TABLE_GET(tab_func2, WASM_I32V(7)))});
// We can store anyfunc values as anyref, but not the other way around. // We can store funcref values as anyref, but not the other way around.
ExpectFailure(&sig, {WASM_SET_LOCAL(local_func, ExpectFailure(&sig, {WASM_SET_LOCAL(local_func,
WASM_TABLE_GET(tab_ref1, WASM_I32V(4)))}); WASM_TABLE_GET(tab_ref1, WASM_I32V(4)))});
ExpectValidates( ExpectValidates(
...@@ -2129,13 +2129,13 @@ TEST_F(FunctionBodyDecoderTest, MultiTableCallIndirect) { ...@@ -2129,13 +2129,13 @@ TEST_F(FunctionBodyDecoderTest, MultiTableCallIndirect) {
TestModuleBuilder builder; TestModuleBuilder builder;
module = builder.module(); module = builder.module();
byte tab_ref = builder.AddTable(kWasmAnyRef, 10, true, 20); byte tab_ref = builder.AddTable(kWasmAnyRef, 10, true, 20);
byte tab_func = builder.AddTable(kWasmAnyFunc, 20, true, 30); byte tab_func = builder.AddTable(kWasmFuncRef, 20, true, 30);
ValueType sig_types[]{kWasmAnyRef, kWasmAnyFunc, kWasmI32}; ValueType sig_types[]{kWasmAnyRef, kWasmFuncRef, kWasmI32};
FunctionSig sig(0, 3, sig_types); FunctionSig sig(0, 3, sig_types);
byte sig_index = builder.AddSignature(sigs.i_v()); byte sig_index = builder.AddSignature(sigs.i_v());
// We can store anyfunc values as anyref, but not the other way around. // We can store funcref values as anyref, but not the other way around.
ExpectValidates(sigs.i_v(), ExpectValidates(sigs.i_v(),
{kExprI32Const, 0, kExprCallIndirect, sig_index, tab_func}); {kExprI32Const, 0, kExprCallIndirect, sig_index, tab_func});
...@@ -3220,7 +3220,7 @@ TEST_F(FunctionBodyDecoderTest, TableCopy) { ...@@ -3220,7 +3220,7 @@ TEST_F(FunctionBodyDecoderTest, TableCopy) {
TEST_F(FunctionBodyDecoderTest, TableGrow) { TEST_F(FunctionBodyDecoderTest, TableGrow) {
TestModuleBuilder builder; TestModuleBuilder builder;
byte tab_func = builder.AddTable(kWasmAnyFunc, 10, true, 20); byte tab_func = builder.AddTable(kWasmFuncRef, 10, true, 20);
byte tab_ref = builder.AddTable(kWasmAnyRef, 10, true, 20); byte tab_ref = builder.AddTable(kWasmAnyRef, 10, true, 20);
module = builder.module(); module = builder.module();
...@@ -3232,10 +3232,10 @@ TEST_F(FunctionBodyDecoderTest, TableGrow) { ...@@ -3232,10 +3232,10 @@ TEST_F(FunctionBodyDecoderTest, TableGrow) {
{WASM_TABLE_GROW(tab_func, WASM_REF_NULL, WASM_ONE)}); {WASM_TABLE_GROW(tab_func, WASM_REF_NULL, WASM_ONE)});
ExpectValidates(sigs.i_r(), ExpectValidates(sigs.i_r(),
{WASM_TABLE_GROW(tab_ref, WASM_REF_NULL, WASM_ONE)}); {WASM_TABLE_GROW(tab_ref, WASM_REF_NULL, WASM_ONE)});
// Anyfunc table cannot be initialized with an anyref value. // FuncRef table cannot be initialized with an anyref value.
ExpectFailure(sigs.i_r(), ExpectFailure(sigs.i_r(),
{WASM_TABLE_GROW(tab_func, WASM_GET_LOCAL(0), WASM_ONE)}); {WASM_TABLE_GROW(tab_func, WASM_GET_LOCAL(0), WASM_ONE)});
// Anyref table can be initialized with an anyfunc value. // Anyref table can be initialized with an funcref value.
ExpectValidates(sigs.i_a(), ExpectValidates(sigs.i_a(),
{WASM_TABLE_GROW(tab_ref, WASM_GET_LOCAL(0), WASM_ONE)}); {WASM_TABLE_GROW(tab_ref, WASM_GET_LOCAL(0), WASM_ONE)});
// Check that the table index gets verified. // Check that the table index gets verified.
...@@ -3245,7 +3245,7 @@ TEST_F(FunctionBodyDecoderTest, TableGrow) { ...@@ -3245,7 +3245,7 @@ TEST_F(FunctionBodyDecoderTest, TableGrow) {
TEST_F(FunctionBodyDecoderTest, TableSize) { TEST_F(FunctionBodyDecoderTest, TableSize) {
TestModuleBuilder builder; TestModuleBuilder builder;
int tab = builder.AddTable(kWasmAnyFunc, 10, true, 20); int tab = builder.AddTable(kWasmFuncRef, 10, true, 20);
module = builder.module(); module = builder.module();
...@@ -3257,7 +3257,7 @@ TEST_F(FunctionBodyDecoderTest, TableSize) { ...@@ -3257,7 +3257,7 @@ TEST_F(FunctionBodyDecoderTest, TableSize) {
TEST_F(FunctionBodyDecoderTest, TableFill) { TEST_F(FunctionBodyDecoderTest, TableFill) {
TestModuleBuilder builder; TestModuleBuilder builder;
byte tab_func = builder.AddTable(kWasmAnyFunc, 10, true, 20); byte tab_func = builder.AddTable(kWasmFuncRef, 10, true, 20);
byte tab_ref = builder.AddTable(kWasmAnyRef, 10, true, 20); byte tab_ref = builder.AddTable(kWasmAnyRef, 10, true, 20);
module = builder.module(); module = builder.module();
...@@ -3269,10 +3269,10 @@ TEST_F(FunctionBodyDecoderTest, TableFill) { ...@@ -3269,10 +3269,10 @@ TEST_F(FunctionBodyDecoderTest, TableFill) {
WASM_REF_NULL, WASM_ONE)}); WASM_REF_NULL, WASM_ONE)});
ExpectValidates(sigs.v_r(), {WASM_TABLE_FILL(tab_ref, WASM_ONE, WASM_REF_NULL, ExpectValidates(sigs.v_r(), {WASM_TABLE_FILL(tab_ref, WASM_ONE, WASM_REF_NULL,
WASM_ONE)}); WASM_ONE)});
// Anyfunc table cannot be initialized with an anyref value. // FuncRef table cannot be initialized with an anyref value.
ExpectFailure(sigs.v_r(), {WASM_TABLE_FILL(tab_func, WASM_ONE, ExpectFailure(sigs.v_r(), {WASM_TABLE_FILL(tab_func, WASM_ONE,
WASM_GET_LOCAL(0), WASM_ONE)}); WASM_GET_LOCAL(0), WASM_ONE)});
// Anyref table can be initialized with an anyfunc value. // Anyref table can be initialized with an funcref value.
ExpectValidates(sigs.v_a(), {WASM_TABLE_FILL(tab_ref, WASM_ONE, ExpectValidates(sigs.v_a(), {WASM_TABLE_FILL(tab_ref, WASM_ONE,
WASM_GET_LOCAL(0), WASM_ONE)}); WASM_GET_LOCAL(0), WASM_ONE)});
// Check that the table index gets verified. // Check that the table index gets verified.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment