diff --git a/src/ir/runtime-table.cpp b/src/ir/runtime-table.cpp index a2e2cb1da02..30d2d82f33b 100644 --- a/src/ir/runtime-table.cpp +++ b/src/ir/runtime-table.cpp @@ -31,7 +31,7 @@ namespace { } // namespace -void RealRuntimeTable::set(std::size_t i, Literal l) { +void RealRuntimeTable::set(Address i, Literal l) { if (i >= table.size()) { trap("RuntimeTable::set out of bounds"); WASM_UNREACHABLE("trapped"); @@ -40,7 +40,7 @@ void RealRuntimeTable::set(std::size_t i, Literal l) { table[i] = std::move(l); } -Literal RealRuntimeTable::get(std::size_t i) const { +Literal RealRuntimeTable::get(Address i) const { if (i >= table.size()) { trap("out of bounds table access"); WASM_UNREACHABLE("trapped"); @@ -49,10 +49,10 @@ Literal RealRuntimeTable::get(std::size_t i) const { return table[i]; } -std::optional RealRuntimeTable::grow(std::size_t delta, - Literal fill) { - std::size_t newSize; - if (std::ckd_add(&newSize, table.size(), delta)) { +std::optional
RealRuntimeTable::grow(Address delta, Literal fill) { + Address newSize; + if (std::ckd_add( + &newSize.addr, static_cast
(table.size()).addr, delta.addr)) { return std::nullopt; } @@ -60,7 +60,7 @@ std::optional RealRuntimeTable::grow(std::size_t delta, return std::nullopt; } - std::size_t oldSize = table.size(); + Address oldSize = table.size(); table.resize(newSize, fill); return oldSize; } diff --git a/src/ir/runtime-table.h b/src/ir/runtime-table.h index c38214f34b7..ca3f8b1268c 100644 --- a/src/ir/runtime-table.h +++ b/src/ir/runtime-table.h @@ -33,15 +33,15 @@ class RuntimeTable { RuntimeTable(Table table) : tableDefinition(table) {} virtual ~RuntimeTable() = default; - virtual void set(std::size_t i, Literal l) = 0; + virtual void set(Address i, Literal l) = 0; - virtual Literal get(std::size_t i) const = 0; + virtual Literal get(Address i) const = 0; // Returns nullopt if the table grew beyond the max possible size. - [[nodiscard]] virtual std::optional grow(std::size_t delta, - Literal fill) = 0; + [[nodiscard]] virtual std::optional
grow(Address delta, + Literal fill) = 0; - virtual std::size_t size() const = 0; + virtual Address size() const = 0; // True iff this is a subtype of the definition `other`. i.e. This table can // be imported with the definition of `other` @@ -66,13 +66,13 @@ class RealRuntimeTable : public RuntimeTable { RealRuntimeTable(const RealRuntimeTable&) = delete; RealRuntimeTable& operator=(const RealRuntimeTable&) = delete; - void set(std::size_t i, Literal l) override; + void set(Address i, Literal l) override; - Literal get(std::size_t i) const override; + Literal get(Address i) const override; - std::optional grow(std::size_t delta, Literal fill) override; + std::optional
grow(Address delta, Literal fill) override; - std::size_t size() const override { return table.size(); } + Address size() const override { return table.size(); } private: std::vector table; diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index 1c8f0c5216f..6e2c820fcb4 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -113,13 +113,13 @@ class EvallingRuntimeTable : public RuntimeTable { : RuntimeTable(table), instanceInitialized(instanceInitialized), wasm(wasm), makeFuncData(std::move(makeFuncData)) {} - void set(std::size_t i, Literal l) override { + void set(Address i, Literal l) override { if (instanceInitialized) { throw FailToEvalException("tableStore after init: TODO"); } } - Literal get(std::size_t index) const override { + Literal get(Address index) const override { // Look through the segments and find the value. Segments can overlap, // so we want the last one. Expression* value = nullptr; @@ -164,12 +164,12 @@ class EvallingRuntimeTable : public RuntimeTable { return Properties::getLiteral(value); } - [[nodiscard]] virtual std::optional grow(std::size_t delta, - Literal fill) override { + [[nodiscard]] virtual std::optional
grow(Address delta, + Literal fill) override { throw FailToEvalException("grow table"); } - std::size_t size() const override { + Address size() const override { // See set() above, we assume the table is not modified FIXME return tableDefinition.initial; }