Skip to content

Commit 229da8d

Browse files
committed
Merge branch 'main' into add-compile-hints
2 parents 8416e6b + 0f5ba6f commit 229da8d

File tree

98 files changed

+5279
-1356
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+5279
-1356
lines changed

.flake8

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
2-
ignore =
3-
E501, # line too long
4-
W504 # line break after binary operator
2+
# E501: line too long
3+
# W504: line break after binary operator
4+
ignore = E501,W504
55
exclude = ./third_party ./out

.github/workflows/build.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: actions/checkout@v1
2020
- name: install tools
2121
run: |
22-
pip3 install flake8==3.7.8
22+
pip3 install flake8==7.3.0
2323
sudo apt-get install clang-format
2424
- run: flake8
2525
- run: ./scripts/clang-format-diff.sh
@@ -30,7 +30,9 @@ jobs:
3030
runs-on: ${{ matrix.os }}
3131
strategy:
3232
matrix:
33-
os: [ubuntu-latest, macos-13, macos-latest, windows-latest]
33+
# Temporarily replaced macos-latest with macos-14.
34+
# See https://github.com/WebAssembly/wabt/issues/2654
35+
os: [ubuntu-latest, macos-14, windows-latest]
3436
steps:
3537
- uses: actions/setup-python@v5
3638
with:
@@ -43,7 +45,7 @@ jobs:
4345
if: matrix.os == 'ubuntu-latest'
4446
- name: install ninja (osx)
4547
run: brew install ninja
46-
if: matrix.os == 'macos-13' || matrix.os == 'macos-latest'
48+
if: startsWith(matrix.os, 'macos-')
4749
- name: install ninja (win)
4850
run: choco install ninja
4951
if: matrix.os == 'windows-latest'
@@ -222,6 +224,9 @@ jobs:
222224

223225
build-cross:
224226
runs-on: ubuntu-latest
227+
# Temporatily disabled until we can get it fixed:
228+
# https://github.com/WebAssembly/wabt/issues/2655
229+
if: ${{ false }}
225230
strategy:
226231
fail-fast: false
227232
matrix:

.github/workflows/build_release.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,21 @@ jobs:
1414
name: build
1515
runs-on: ${{ matrix.os }}
1616
strategy:
17+
fail-fast: false
1718
matrix:
18-
os: [ubuntu-20.04, macos-14, windows-latest]
19+
include:
20+
- os: ubuntu-22.04
21+
arch: x86_64
22+
name: linux-x64
23+
- os: ubuntu-22.04-arm
24+
arch: aarch64
25+
name: linux-arm64
26+
- os: macos-14
27+
arch: aarch64
28+
name: macos-arm64
29+
- os: windows-latest
30+
arch: x86_64
31+
name: windows-x64
1932
defaults:
2033
run:
2134
shell: bash
@@ -29,7 +42,7 @@ jobs:
2942

3043
- name: install ninja (linux)
3144
run: sudo apt-get install ninja-build
32-
if: startsWith(matrix.os, 'ubuntu-')
45+
if: contains(matrix.os, 'ubuntu')
3346

3447
- name: install ninja (osx)
3548
run: brew install ninja
@@ -60,7 +73,7 @@ jobs:
6073

6174
- uses: ./.github/actions/release-archive
6275
with:
63-
os: ${{ matrix.os }}
76+
os: ${{ matrix.name }}
6477
upload_to_release: true
6578

6679
build-wasi:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616

1717
cmake_minimum_required(VERSION 3.16)
18-
project(WABT LANGUAGES C CXX VERSION 1.0.37)
18+
project(WABT LANGUAGES C CXX VERSION 1.0.39)
1919

2020
include(GNUInstallDirs)
2121

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Wabt has been compiled to JavaScript via emscripten. Some of the functionality i
6363
| [extended-const][] | `--enable-extended-const` | ||||||
6464
| [relaxed-simd][] | `--enable-relaxed-simd` | ||||| |
6565
| [custom-page-sizes][] | `--enable-custom-page-sizes`| ||||||
66+
| [function-references][] | `--enable-function-references` | ||||| |
6667

6768
[exception handling]: https://github.com/WebAssembly/exception-handling
6869
[mutable globals]: https://github.com/WebAssembly/mutable-global
@@ -80,6 +81,7 @@ Wabt has been compiled to JavaScript via emscripten. Some of the functionality i
8081
[extended-const]: https://github.com/WebAssembly/extended-const
8182
[relaxed-simd]: https://github.com/WebAssembly/relaxed-simd
8283
[custom-page-sizes]: https://github.com/WebAssembly/custom-page-sizes
84+
[function-references]: https://github.com/WebAssembly/function-references
8385

8486
## Cloning
8587

include/wabt/binary-reader-logging.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,13 @@ class BinaryReaderLogging : public BinaryReaderDelegate {
9696

9797
Result BeginTableSection(Offset size) override;
9898
Result OnTableCount(Index count) override;
99-
Result OnTable(Index index,
100-
Type elem_type,
101-
const Limits* elem_limits) override;
99+
Result BeginTable(Index index,
100+
Type elem_type,
101+
const Limits* elem_limits,
102+
TableInitExprStatus init_provided) override;
103+
Result BeginTableInitExpr(Index index) override;
104+
Result EndTableInitExpr(Index index) override;
105+
Result EndTable(Index index) override;
102106
Result EndTableSection() override;
103107

104108
Result BeginMemorySection(Offset size) override;
@@ -174,14 +178,16 @@ class BinaryReaderLogging : public BinaryReaderDelegate {
174178
Result OnBlockExpr(Type sig_type) override;
175179
Result OnBrExpr(Index depth) override;
176180
Result OnBrIfExpr(Index depth) override;
181+
Result OnBrOnNonNullExpr(Index depth) override;
182+
Result OnBrOnNullExpr(Index depth) override;
177183
Result OnBrTableExpr(Index num_targets,
178184
Index* target_depths,
179185
Index default_target_depth) override;
180186
Result OnCallExpr(Index func_index) override;
181187
Result OnCatchExpr(Index tag_index) override;
182188
Result OnCatchAllExpr() override;
183189
Result OnCallIndirectExpr(Index sig_index, Index table_index) override;
184-
Result OnCallRefExpr() override;
190+
Result OnCallRefExpr(Type sig_type) override;
185191
Result OnCompareExpr(Opcode opcode) override;
186192
Result OnConvertExpr(Opcode opcode) override;
187193
Result OnDelegateExpr(Index depth) override;
@@ -218,12 +224,14 @@ class BinaryReaderLogging : public BinaryReaderDelegate {
218224
Result OnTableGrowExpr(Index table) override;
219225
Result OnTableSizeExpr(Index table) override;
220226
Result OnTableFillExpr(Index table) override;
227+
Result OnRefAsNonNullExpr() override;
221228
Result OnRefFuncExpr(Index index) override;
222229
Result OnRefNullExpr(Type type) override;
223230
Result OnRefIsNullExpr() override;
224231
Result OnNopExpr() override;
225232
Result OnRethrowExpr(Index depth) override;
226233
Result OnReturnCallExpr(Index func_index) override;
234+
Result OnReturnCallRefExpr(Type sig_type) override;
227235
Result OnReturnCallIndirectExpr(Index sig_index, Index table_index) override;
228236
Result OnReturnExpr() override;
229237
Result OnSelectExpr(Index result_count, Type* result_types) override;

include/wabt/binary-reader-nop.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,15 @@ class BinaryReaderNop : public BinaryReaderDelegate {
121121
/* Table section */
122122
Result BeginTableSection(Offset size) override { return Result::Ok; }
123123
Result OnTableCount(Index count) override { return Result::Ok; }
124-
Result OnTable(Index index,
125-
Type elem_type,
126-
const Limits* elem_limits) override {
124+
Result BeginTable(Index index,
125+
Type elem_type,
126+
const Limits* elem_limits,
127+
TableInitExprStatus init_provided) override {
127128
return Result::Ok;
128129
}
130+
Result BeginTableInitExpr(Index index) override { return Result::Ok; }
131+
Result EndTableInitExpr(Index index) override { return Result::Ok; }
132+
Result EndTable(Index index) override { return Result::Ok; }
129133
Result EndTableSection() override { return Result::Ok; }
130134

131135
/* Memory section */
@@ -241,6 +245,8 @@ class BinaryReaderNop : public BinaryReaderDelegate {
241245
Result OnBlockExpr(Type sig_type) override { return Result::Ok; }
242246
Result OnBrExpr(Index depth) override { return Result::Ok; }
243247
Result OnBrIfExpr(Index depth) override { return Result::Ok; }
248+
Result OnBrOnNonNullExpr(Index depth) override { return Result::Ok; }
249+
Result OnBrOnNullExpr(Index depth) override { return Result::Ok; }
244250
Result OnBrTableExpr(Index num_targets,
245251
Index* target_depths,
246252
Index default_target_depth) override {
@@ -250,7 +256,7 @@ class BinaryReaderNop : public BinaryReaderDelegate {
250256
Result OnCallIndirectExpr(Index sig_index, Index table_index) override {
251257
return Result::Ok;
252258
}
253-
Result OnCallRefExpr() override { return Result::Ok; }
259+
Result OnCallRefExpr(Type sig_type) override { return Result::Ok; }
254260
Result OnCatchExpr(Index tag_index) override { return Result::Ok; }
255261
Result OnCatchAllExpr() override { return Result::Ok; }
256262
Result OnCompareExpr(Opcode opcode) override { return Result::Ok; }
@@ -299,6 +305,7 @@ class BinaryReaderNop : public BinaryReaderDelegate {
299305
Result OnTableGrowExpr(Index table_index) override { return Result::Ok; }
300306
Result OnTableSizeExpr(Index table_index) override { return Result::Ok; }
301307
Result OnTableFillExpr(Index table_index) override { return Result::Ok; }
308+
Result OnRefAsNonNullExpr() override { return Result::Ok; }
302309
Result OnRefFuncExpr(Index func_index) override { return Result::Ok; }
303310
Result OnRefNullExpr(Type type) override { return Result::Ok; }
304311
Result OnRefIsNullExpr() override { return Result::Ok; }
@@ -308,6 +315,7 @@ class BinaryReaderNop : public BinaryReaderDelegate {
308315
Result OnReturnCallIndirectExpr(Index sig_index, Index table_index) override {
309316
return Result::Ok;
310317
}
318+
Result OnReturnCallRefExpr(Type sig_type) override { return Result::Ok; }
311319
Result OnReturnExpr() override { return Result::Ok; }
312320
Result OnSelectExpr(Index result_count, Type* result_types) override {
313321
return Result::Ok;

include/wabt/binary-reader.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ struct CatchClause {
6666
};
6767
using CatchClauseVector = std::vector<CatchClause>;
6868

69+
enum class TableInitExprStatus {
70+
TableWithInitExpression,
71+
TableWithoutInitExpression,
72+
};
73+
6974
class BinaryReaderDelegate {
7075
public:
7176
struct State {
@@ -156,9 +161,13 @@ class BinaryReaderDelegate {
156161
/* Table section */
157162
virtual Result BeginTableSection(Offset size) = 0;
158163
virtual Result OnTableCount(Index count) = 0;
159-
virtual Result OnTable(Index index,
160-
Type elem_type,
161-
const Limits* elem_limits) = 0;
164+
virtual Result BeginTable(Index index,
165+
Type elem_type,
166+
const Limits* elem_limits,
167+
TableInitExprStatus init_provided) = 0;
168+
virtual Result BeginTableInitExpr(Index index) = 0;
169+
virtual Result EndTableInitExpr(Index index) = 0;
170+
virtual Result EndTable(Index index) = 0;
162171
virtual Result EndTableSection() = 0;
163172

164173
/* Memory section */
@@ -250,12 +259,14 @@ class BinaryReaderDelegate {
250259
virtual Result OnBlockExpr(Type sig_type) = 0;
251260
virtual Result OnBrExpr(Index depth) = 0;
252261
virtual Result OnBrIfExpr(Index depth) = 0;
262+
virtual Result OnBrOnNonNullExpr(Index depth) = 0;
263+
virtual Result OnBrOnNullExpr(Index depth) = 0;
253264
virtual Result OnBrTableExpr(Index num_targets,
254265
Index* target_depths,
255266
Index default_target_depth) = 0;
256267
virtual Result OnCallExpr(Index func_index) = 0;
257268
virtual Result OnCallIndirectExpr(Index sig_index, Index table_index) = 0;
258-
virtual Result OnCallRefExpr() = 0;
269+
virtual Result OnCallRefExpr(Type sig_type) = 0;
259270
virtual Result OnCatchExpr(Index tag_index) = 0;
260271
virtual Result OnCatchAllExpr() = 0;
261272
virtual Result OnCompareExpr(Opcode opcode) = 0;
@@ -294,6 +305,7 @@ class BinaryReaderDelegate {
294305
virtual Result OnTableGrowExpr(Index table_index) = 0;
295306
virtual Result OnTableSizeExpr(Index table_index) = 0;
296307
virtual Result OnTableFillExpr(Index table_index) = 0;
308+
virtual Result OnRefAsNonNullExpr() = 0;
297309
virtual Result OnRefFuncExpr(Index func_index) = 0;
298310
virtual Result OnRefNullExpr(Type type) = 0;
299311
virtual Result OnRefIsNullExpr() = 0;
@@ -303,6 +315,7 @@ class BinaryReaderDelegate {
303315
virtual Result OnReturnCallExpr(Index func_index) = 0;
304316
virtual Result OnReturnCallIndirectExpr(Index sig_index,
305317
Index table_index) = 0;
318+
virtual Result OnReturnCallRefExpr(Type sig_type) = 0;
306319
virtual Result OnSelectExpr(Index result_count, Type* result_types) = 0;
307320
virtual Result OnStoreExpr(Opcode opcode,
308321
Index memidx,

include/wabt/expr-visitor.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class ExprVisitor::Delegate {
7373
virtual Result EndBlockExpr(BlockExpr*) = 0;
7474
virtual Result OnBrExpr(BrExpr*) = 0;
7575
virtual Result OnBrIfExpr(BrIfExpr*) = 0;
76+
virtual Result OnBrOnNonNullExpr(BrOnNonNullExpr*) = 0;
77+
virtual Result OnBrOnNullExpr(BrOnNullExpr*) = 0;
7678
virtual Result OnBrTableExpr(BrTableExpr*) = 0;
7779
virtual Result BeginTryTableExpr(TryTableExpr*) = 0;
7880
virtual Result EndTryTableExpr(TryTableExpr*) = 0;
@@ -109,13 +111,15 @@ class ExprVisitor::Delegate {
109111
virtual Result OnTableGrowExpr(TableGrowExpr*) = 0;
110112
virtual Result OnTableSizeExpr(TableSizeExpr*) = 0;
111113
virtual Result OnTableFillExpr(TableFillExpr*) = 0;
114+
virtual Result OnRefAsNonNullExpr(RefAsNonNullExpr*) = 0;
112115
virtual Result OnRefFuncExpr(RefFuncExpr*) = 0;
113116
virtual Result OnRefNullExpr(RefNullExpr*) = 0;
114117
virtual Result OnRefIsNullExpr(RefIsNullExpr*) = 0;
115118
virtual Result OnNopExpr(NopExpr*) = 0;
116119
virtual Result OnReturnExpr(ReturnExpr*) = 0;
117120
virtual Result OnReturnCallExpr(ReturnCallExpr*) = 0;
118121
virtual Result OnReturnCallIndirectExpr(ReturnCallIndirectExpr*) = 0;
122+
virtual Result OnReturnCallRefExpr(ReturnCallRefExpr*) = 0;
119123
virtual Result OnSelectExpr(SelectExpr*) = 0;
120124
virtual Result OnStoreExpr(StoreExpr*) = 0;
121125
virtual Result OnUnaryExpr(UnaryExpr*) = 0;
@@ -150,6 +154,8 @@ class ExprVisitor::DelegateNop : public ExprVisitor::Delegate {
150154
Result EndBlockExpr(BlockExpr*) override { return Result::Ok; }
151155
Result OnBrExpr(BrExpr*) override { return Result::Ok; }
152156
Result OnBrIfExpr(BrIfExpr*) override { return Result::Ok; }
157+
Result OnBrOnNonNullExpr(BrOnNonNullExpr*) override { return Result::Ok; };
158+
Result OnBrOnNullExpr(BrOnNullExpr*) override { return Result::Ok; };
153159
Result OnBrTableExpr(BrTableExpr*) override { return Result::Ok; }
154160
Result BeginTryTableExpr(TryTableExpr*) override { return Result::Ok; }
155161
Result EndTryTableExpr(TryTableExpr*) override { return Result::Ok; }
@@ -186,6 +192,7 @@ class ExprVisitor::DelegateNop : public ExprVisitor::Delegate {
186192
Result OnTableGrowExpr(TableGrowExpr*) override { return Result::Ok; }
187193
Result OnTableSizeExpr(TableSizeExpr*) override { return Result::Ok; }
188194
Result OnTableFillExpr(TableFillExpr*) override { return Result::Ok; }
195+
Result OnRefAsNonNullExpr(RefAsNonNullExpr*) override { return Result::Ok; }
189196
Result OnRefFuncExpr(RefFuncExpr*) override { return Result::Ok; }
190197
Result OnRefNullExpr(RefNullExpr*) override { return Result::Ok; }
191198
Result OnRefIsNullExpr(RefIsNullExpr*) override { return Result::Ok; }
@@ -195,6 +202,7 @@ class ExprVisitor::DelegateNop : public ExprVisitor::Delegate {
195202
Result OnReturnCallIndirectExpr(ReturnCallIndirectExpr*) override {
196203
return Result::Ok;
197204
}
205+
Result OnReturnCallRefExpr(ReturnCallRefExpr*) override { return Result::Ok; }
198206
Result OnSelectExpr(SelectExpr*) override { return Result::Ok; }
199207
Result OnStoreExpr(StoreExpr*) override { return Result::Ok; }
200208
Result OnUnaryExpr(UnaryExpr*) override { return Result::Ok; }

include/wabt/interp/interp-inl.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ inline bool FuncType::classof(const ExternType* type) {
4242
}
4343

4444
inline FuncType::FuncType(ValueTypes params, ValueTypes results)
45-
: ExternType(ExternKind::Func), params(params), results(results) {}
45+
: ExternType(ExternKind::Func), params(params), results(results), func_types(nullptr) {}
4646

4747
//// TableType ////
4848
// static
@@ -422,12 +422,6 @@ void RequireType(ValueType type) {
422422
assert(HasType<T>(type));
423423
}
424424

425-
inline bool TypesMatch(ValueType expected, ValueType actual) {
426-
// Currently there is no subtyping, so expected and actual must match
427-
// exactly. In the future this may be expanded.
428-
return expected == actual;
429-
}
430-
431425
//// Value ////
432426
inline Value WABT_VECTORCALL Value::Make(s32 val) { Value res; res.i32_ = val; res.SetType(ValueType::I32); return res; }
433427
inline Value WABT_VECTORCALL Value::Make(u32 val) { Value res; res.i32_ = val; res.SetType(ValueType::I32); return res; }
@@ -682,8 +676,8 @@ inline bool Table::classof(const Object* obj) {
682676
}
683677

684678
// static
685-
inline Table::Ptr Table::New(Store& store, TableType type) {
686-
return store.Alloc<Table>(store, type);
679+
inline Table::Ptr Table::New(Store& store, TableType type, Ref init_ref) {
680+
return store.Alloc<Table>(store, type, init_ref);
687681
}
688682

689683
inline const ExternType& Table::extern_type() {

0 commit comments

Comments
 (0)