Skip to content

Commit fe540c0

Browse files
author
Zoltan Herczeg
committed
Implement changes of function reference proposal
1 parent 5e81f6a commit fe540c0

11 files changed

+123
-115
lines changed

Diff for: include/wabt/ir.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,7 @@ class CallRefExpr : public ExprMixin<ExprType::CallRef> {
734734
explicit CallRefExpr(const Location& loc = Location())
735735
: ExprMixin<ExprType::CallRef>(loc) {}
736736

737-
// This field is setup only during Validate phase,
738-
// so keep that in mind when you use it.
739-
Var function_type_index;
737+
Var function_type;
740738
};
741739

742740
template <ExprType TypeEnum>

Diff for: include/wabt/shared-validator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class SharedValidator {
140140
Result EndBrTable(const Location&);
141141
Result OnCall(const Location&, Var func_var);
142142
Result OnCallIndirect(const Location&, Var sig_var, Var table_var);
143-
Result OnCallRef(const Location&, Index* function_type_index);
143+
Result OnCallRef(const Location&, Var function_type_var);
144144
Result OnCatch(const Location&, Var tag_var, bool is_catch_all);
145145
Result OnCompare(const Location&, Opcode);
146146
Result OnConst(const Location&, Type);

Diff for: include/wabt/token.def

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ WABT_TOKEN(Module, "module")
5555
WABT_TOKEN(Mut, "mut")
5656
WABT_TOKEN(NanArithmetic, "nan:arithmetic")
5757
WABT_TOKEN(NanCanonical, "nan:canonical")
58+
WABT_TOKEN(Null, "null")
5859
WABT_TOKEN(Offset, "offset")
5960
WABT_TOKEN(Output, "output")
6061
WABT_TOKEN(PageSize, "pagesize")

Diff for: include/wabt/type.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class Type {
4646
FuncRef = -0x10, // 0x70
4747
ExternRef = -0x11, // 0x6f
4848
Reference = -0x15, // 0x6b
49+
HeapRef = -0x1c, // 0x64
50+
HeapNullRef = -0x1d, // 0x63
4951
Func = -0x20, // 0x60
5052
Struct = -0x21, // 0x5f
5153
Array = -0x22, // 0x5e
@@ -63,7 +65,8 @@ class Type {
6365
: enum_(static_cast<Enum>(code)), type_index_(kInvalidIndex) {}
6466
Type(Enum e) : enum_(e), type_index_(kInvalidIndex) {}
6567
Type(Enum e, Index type_index) : enum_(e), type_index_(type_index) {
66-
assert(e == Enum::Reference);
68+
assert(e == Enum::Reference || e == Enum::HeapRef ||
69+
e == Enum::HeapNullRef || type_index == kInvalidIndex);
6770
}
6871
constexpr operator Enum() const { return enum_; }
6972

Diff for: include/wabt/wast-parser.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class WastParser {
134134
bool ParseElemExprOpt(ExprList* out_elem_expr);
135135
bool ParseElemExprListOpt(ExprListVector* out_list);
136136
bool ParseElemExprVarListOpt(ExprListVector* out_list);
137-
Result ParseValueType(Var* out_type);
137+
Result ParseValueType(Type::Enum *out_code, Var* out_type);
138138
Result ParseValueTypeList(
139139
TypeVector* out_type_list,
140140
std::unordered_map<uint32_t, std::string>* type_names);

Diff for: src/ir-util.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ ModuleContext::Arities ModuleContext::GetExprArity(const Expr& expr) const {
140140
}
141141

142142
case ExprType::CallRef: {
143-
const Var& var = cast<CallRefExpr>(&expr)->function_type_index;
143+
const Var& var = cast<CallRefExpr>(&expr)->function_type;
144144
return {GetFuncParamCount(var) + 1, GetFuncResultCount(var)};
145145
}
146146

Diff for: src/lexer-keywords.txt

+1
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ mut, TokenType::Mut
556556
nan:arithmetic, TokenType::NanArithmetic
557557
nan:canonical, TokenType::NanCanonical
558558
nop, TokenType::Nop, Opcode::Nop
559+
null, TokenType::Null
559560
offset, TokenType::Offset
560561
output, TokenType::Output
561562
pagesize, TokenType::PageSize

0 commit comments

Comments
 (0)