Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ir/runtime-table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ std::optional<std::size_t> RealRuntimeTable::grow(std::size_t delta,
return std::nullopt;
}

if (newSize > WebLimitations::MaxTableSize || newSize > tableMeta_.max) {
if (newSize > WebLimitations::MaxTableSize || newSize > tableDefinition.max) {
return std::nullopt;
}

Expand Down
14 changes: 7 additions & 7 deletions src/ir/runtime-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace wasm {
// out-of-bounds access.
class RuntimeTable {
public:
RuntimeTable(Table table) : tableMeta_(table) {}
RuntimeTable(Table table) : tableDefinition(table) {}
virtual ~RuntimeTable() = default;

virtual void set(std::size_t i, Literal l) = 0;
Expand All @@ -46,21 +46,21 @@ class RuntimeTable {
// True iff this is a subtype of the definition `other`. i.e. This table can
// be imported with the definition of `other`
virtual bool isSubType(const Table& other) {
return tableMeta_.addressType == other.addressType &&
Type::isSubType(tableMeta_.type, other.type) &&
size() >= other.initial && tableMeta_.max <= other.max;
return tableDefinition.addressType == other.addressType &&
Type::isSubType(tableDefinition.type, other.type) &&
size() >= other.initial && tableDefinition.max <= other.max;
}

const Table* tableMeta() const { return &tableMeta_; }
const Table* getDefinition() const { return &tableDefinition; }

protected:
const Table tableMeta_;
const Table tableDefinition;
};

class RealRuntimeTable : public RuntimeTable {
public:
RealRuntimeTable(Literal initial, Table table_) : RuntimeTable(table_) {
table.resize(tableMeta_.initial, initial);
table.resize(tableDefinition.initial, initial);
}

RealRuntimeTable(const RealRuntimeTable&) = delete;
Expand Down
4 changes: 2 additions & 2 deletions src/tools/wasm-ctor-eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class EvallingRuntimeTable : public RuntimeTable {
// so we want the last one.
Expression* value = nullptr;
for (auto& segment : wasm.elementSegments) {
if (segment->table != tableMeta_.name) {
if (segment->table != tableDefinition.name) {
continue;
}

Expand Down Expand Up @@ -157,7 +157,7 @@ class EvallingRuntimeTable : public RuntimeTable {

std::size_t size() const override {
// See set() above, we assume the table is not modified FIXME
return tableMeta_.initial;
return tableDefinition.initial;
}

private:
Expand Down
9 changes: 5 additions & 4 deletions src/wasm-interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -3415,7 +3415,7 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
if (!importedTable->isSubType(**tableDecl)) {
trap(
(std::stringstream()
<< "Imported table " << importedTable->tableMeta()
<< "Imported table " << importedTable->getDefinition()
<< " with size " << importedTable->size()
<< " isn't compatible with import declaration: " << **tableDecl)
.str());
Expand Down Expand Up @@ -3858,7 +3858,7 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
Flow visitTableSize(TableSize* curr) {
auto* table = allTables[curr->table];
return Literal::makeFromInt64(static_cast<int64_t>(table->size()),
table->tableMeta()->addressType);
table->getDefinition()->addressType);
}

Flow visitTableGrow(TableGrow* curr) {
Expand All @@ -3868,10 +3868,11 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
auto* table = allTables[curr->table];
if (auto newSize = table->grow(deltaFlow.getSingleValue().getUnsigned(),
valueFlow.getSingleValue())) {
return Literal::makeFromInt64(*newSize, table->tableMeta()->addressType);
return Literal::makeFromInt64(*newSize,
table->getDefinition()->addressType);
}

return Literal::makeFromInt64(-1, table->tableMeta()->addressType);
return Literal::makeFromInt64(-1, table->getDefinition()->addressType);
}

Flow visitTableFill(TableFill* curr) {
Expand Down
Loading