Skip to content

Commit d663c80

Browse files
authored
Update testsuite (#1308)
* Remove `assert_return_func`. This is now handled by using `assert_return` with `(ref.func)`. * The reference types proposal depends on the bulk memory proposal, so using `--enable-reference-types` automatically includes `--enable-bulk-memory`. * `table.fill` no longer clamps to the valid range, and instead checks before writing anything. This matches the other bulk instructions.
1 parent 0fdf727 commit d663c80

40 files changed

+3263
-1088
lines changed

src/binary-writer-spec.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ void BinaryWriterSpec::WriteCommandType(const Command& command) {
130130
"assert_unlinkable",
131131
"assert_uninstantiable",
132132
"assert_return",
133-
"assert_return_func",
134133
"assert_trap",
135134
"assert_exhaustion",
136135
};
@@ -496,14 +495,6 @@ void BinaryWriterSpec::WriteCommands() {
496495
break;
497496
}
498497

499-
case CommandType::AssertReturnFunc: {
500-
auto* assert_return_command = cast<AssertReturnFuncCommand>(command);
501-
WriteLocation(assert_return_command->action->loc);
502-
WriteSeparator();
503-
WriteAction(*assert_return_command->action);
504-
break;
505-
}
506-
507498
case CommandType::AssertTrap: {
508499
auto* assert_trap_command = cast<AssertTrapCommand>(command);
509500
WriteLocation(assert_trap_command->action->loc);

src/feature.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,11 @@ void Features::AddOptions(OptionParser* parser) {
3636
[this]() { EnableAll(); });
3737
}
3838

39+
void Features::UpdateDependencies() {
40+
// Reference types requires bulk memory.
41+
if (reference_types_enabled_) {
42+
bulk_memory_enabled_ = true;
43+
}
44+
}
45+
3946
} // namespace wabt

src/feature.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,18 @@ class Features {
3535

3636
#define WABT_FEATURE(variable, flag, default_, help) \
3737
bool variable##_enabled() const { return variable##_enabled_; } \
38-
void enable_##variable() { variable##_enabled_ = true; } \
39-
void disable_##variable() { variable##_enabled_ = false; } \
40-
void set_##variable##_enabled(bool value) { variable##_enabled_ = value; }
38+
void enable_##variable() { set_##variable##_enabled(true); } \
39+
void disable_##variable() { set_##variable##_enabled(false); } \
40+
void set_##variable##_enabled(bool value) { \
41+
variable##_enabled_ = value; \
42+
UpdateDependencies(); \
43+
}
4144
#include "src/feature.def"
4245
#undef WABT_FEATURE
4346

4447
private:
48+
void UpdateDependencies();
49+
4550
#define WABT_FEATURE(variable, flag, default_, help) \
4651
bool variable##_enabled_ = default_;
4752
#include "src/feature.def"

src/interp/interp.cc

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,23 +1018,6 @@ Result Thread::AtomicRmwCmpxchg(const uint8_t** pc) {
10181018
return Push<ResultValueType>(static_cast<ExtendedType>(read));
10191019
}
10201020

1021-
// This function is used to clanp the bound for table.fill operations. This
1022-
// can be removed once the behaviour of table.fill is updated to match the
1023-
// new bulk meory semantics, which is to trap early on OOB.
1024-
// See: https://github.com/webassembly/bulk-memory-operations/issues/111
1025-
static bool ClampToBounds(uint32_t start, uint32_t* length, uint32_t max) {
1026-
if (start > max) {
1027-
*length = 0;
1028-
return false;
1029-
}
1030-
uint32_t avail = max - start;
1031-
if (*length > avail) {
1032-
*length = avail;
1033-
return false;
1034-
}
1035-
return true;
1036-
}
1037-
10381021
static bool CheckBounds(uint32_t start, uint32_t length, uint32_t max) {
10391022
if (start > max) {
10401023
return false;
@@ -1144,15 +1127,16 @@ Result Thread::TableGet(const uint8_t** pc) {
11441127

11451128
Result Thread::TableFill(const uint8_t** pc) {
11461129
Table* table = ReadTable(pc);
1147-
uint32_t table_size = table->size();
11481130
uint32_t size = Pop<uint32_t>();
11491131
Ref value = static_cast<Ref>(Pop<Ref>());
11501132
uint32_t dst = Pop<uint32_t>();
1151-
bool ok = ClampToBounds(dst, &size, table_size);
1133+
bool ok = CheckBounds(dst, size, table->size());
1134+
if (!ok) {
1135+
TRAP_MSG(TableAccessOutOfBounds, "table.fill out of bounds");
1136+
}
11521137
for (uint32_t i = 0; i < size; i++) {
11531138
table->entries[dst+i] = value;
11541139
}
1155-
TRAP_IF(!ok, TableAccessOutOfBounds);
11561140
return ResultType::Ok;
11571141
}
11581142

src/ir.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,6 @@ enum class CommandType {
10491049
AssertUnlinkable,
10501050
AssertUninstantiable,
10511051
AssertReturn,
1052-
AssertReturnFunc,
10531052
AssertTrap,
10541053
AssertExhaustion,
10551054

@@ -1105,12 +1104,6 @@ class AssertReturnCommand : public CommandMixin<CommandType::AssertReturn> {
11051104
ConstVector expected;
11061105
};
11071106

1108-
class AssertReturnFuncCommand
1109-
: public CommandMixin<CommandType::AssertReturnFunc> {
1110-
public:
1111-
ActionPtr action;
1112-
};
1113-
11141107
template <CommandType TypeEnum>
11151108
class AssertTrapCommandBase : public CommandMixin<TypeEnum> {
11161109
public:

src/lexer-keywords.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ assert_exhaustion, TokenType::AssertExhaustion
2020
assert_invalid, TokenType::AssertInvalid
2121
assert_malformed, TokenType::AssertMalformed
2222
assert_return, TokenType::AssertReturn
23-
assert_return_func, TokenType::AssertReturnFunc
2423
assert_trap, TokenType::AssertTrap
2524
assert_unlinkable, TokenType::AssertUnlinkable
2625
atomic.notify, TokenType::AtomicNotify, Opcode::AtomicNotify

0 commit comments

Comments
 (0)