summaryrefslogtreecommitdiff
path: root/src/ir
diff options
context:
space:
mode:
Diffstat (limited to 'src/ir')
-rw-r--r--src/ir/ExpressionAnalyzer.cpp2
-rw-r--r--src/ir/ReFinalize.cpp2
-rw-r--r--src/ir/function-utils.h4
-rw-r--r--src/ir/hashed.h3
-rw-r--r--src/ir/module-splitting.cpp29
-rw-r--r--src/ir/module-utils.h4
-rw-r--r--src/ir/table-utils.h2
-rw-r--r--src/ir/utils.h2
8 files changed, 24 insertions, 24 deletions
diff --git a/src/ir/ExpressionAnalyzer.cpp b/src/ir/ExpressionAnalyzer.cpp
index 0c6081b03..260a9a6c4 100644
--- a/src/ir/ExpressionAnalyzer.cpp
+++ b/src/ir/ExpressionAnalyzer.cpp
@@ -60,7 +60,7 @@ bool ExpressionAnalyzer::isResultUsed(ExpressionStack& stack, Function* func) {
}
}
// The value might be used, so it depends on if the function returns
- return func->sig.results != Type::none;
+ return func->getResults() != Type::none;
}
// Checks if a value is dropped.
diff --git a/src/ir/ReFinalize.cpp b/src/ir/ReFinalize.cpp
index 6f1a22095..419b83cc2 100644
--- a/src/ir/ReFinalize.cpp
+++ b/src/ir/ReFinalize.cpp
@@ -171,7 +171,7 @@ void ReFinalize::visitRefAs(RefAs* curr) { curr->finalize(); }
void ReFinalize::visitFunction(Function* curr) {
// we may have changed the body from unreachable to none, which might be bad
// if the function has a return value
- if (curr->sig.results != Type::none && curr->body->type == Type::none) {
+ if (curr->getResults() != Type::none && curr->body->type == Type::none) {
Builder builder(*getModule());
curr->body = builder.blockify(curr->body, builder.makeUnreachable());
}
diff --git a/src/ir/function-utils.h b/src/ir/function-utils.h
index f172240e2..b1654d965 100644
--- a/src/ir/function-utils.h
+++ b/src/ir/function-utils.h
@@ -28,13 +28,13 @@ namespace FunctionUtils {
// everything but their name (which can't be the same, in the same
// module!) - same params, vars, body, result, etc.
inline bool equal(Function* left, Function* right) {
- if (left->sig != right->sig) {
+ if (left->type != right->type) {
return false;
}
if (left->getNumVars() != right->getNumVars()) {
return false;
}
- for (Index i = left->sig.params.size(); i < left->getNumLocals(); i++) {
+ for (Index i = left->getParams().size(); i < left->getNumLocals(); i++) {
if (left->getLocalType(i) != right->getLocalType(i)) {
return false;
}
diff --git a/src/ir/hashed.h b/src/ir/hashed.h
index fe959936a..4a6e1647e 100644
--- a/src/ir/hashed.h
+++ b/src/ir/hashed.h
@@ -64,8 +64,7 @@ struct FunctionHasher : public WalkerPass<PostWalker<FunctionHasher>> {
void doWalkFunction(Function* func) { output->at(func) = hashFunction(func); }
static size_t hashFunction(Function* func) {
- auto digest = hash(func->sig.params.getID());
- rehash(digest, func->sig.results.getID());
+ auto digest = hash(func->type);
for (auto type : func->vars) {
rehash(digest, type.getID());
}
diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp
index 62c10222a..2ef9f505d 100644
--- a/src/ir/module-splitting.cpp
+++ b/src/ir/module-splitting.cpp
@@ -122,7 +122,7 @@ struct TableSlotManager {
ElementSegment* makeElementSegment();
// Returns the table index for `func`, allocating a new index if necessary.
- Slot getSlot(Name func, Signature sig);
+ Slot getSlot(Name func, HeapType type);
void addSlot(Name func, Slot slot);
};
@@ -209,7 +209,7 @@ ElementSegment* TableSlotManager::makeElementSegment() {
Builder(module).makeConst(int32_t(0))));
}
-TableSlotManager::Slot TableSlotManager::getSlot(Name func, Signature sig) {
+TableSlotManager::Slot TableSlotManager::getSlot(Name func, HeapType type) {
auto slotIt = funcIndices.find(func);
if (slotIt != funcIndices.end()) {
return slotIt->second;
@@ -237,7 +237,7 @@ TableSlotManager::Slot TableSlotManager::getSlot(Name func, Signature sig) {
activeBase.index + Index(activeSegment->data.size())};
Builder builder(module);
- activeSegment->data.push_back(builder.makeRefFunc(func, sig));
+ activeSegment->data.push_back(builder.makeRefFunc(func, type));
addSlot(func, newSlot);
if (activeTable->initial <= newSlot.index) {
@@ -365,7 +365,7 @@ void ModuleSplitter::exportImportFunction(Name funcName) {
// module.
if (secondary.getFunctionOrNull(funcName) == nullptr) {
auto func =
- Builder::makeFunction(funcName, primary.getFunction(funcName)->sig, {});
+ Builder::makeFunction(funcName, primary.getFunction(funcName)->type, {});
func->module = config.importNamespace;
func->base = exportName;
secondary.addFunction(std::move(func));
@@ -399,14 +399,15 @@ void ModuleSplitter::thunkExportedSecondaryFunctions() {
continue;
}
auto* func = primary.addFunction(Builder::makeFunction(
- secondaryFunc, secondary.getFunction(secondaryFunc)->sig, {}));
+ secondaryFunc, secondary.getFunction(secondaryFunc)->type, {}));
std::vector<Expression*> args;
- for (size_t i = 0, size = func->sig.params.size(); i < size; ++i) {
- args.push_back(builder.makeLocalGet(i, func->sig.params[i]));
+ Type params = func->getParams();
+ for (size_t i = 0, size = params.size(); i < size; ++i) {
+ args.push_back(builder.makeLocalGet(i, params[i]));
}
- auto tableSlot = tableManager.getSlot(secondaryFunc, func->sig);
+ auto tableSlot = tableManager.getSlot(secondaryFunc, func->type);
func->body = builder.makeCallIndirect(
- tableSlot.tableName, tableSlot.makeExpr(primary), args, func->sig);
+ tableSlot.tableName, tableSlot.makeExpr(primary), args, func->getSig());
}
}
@@ -425,12 +426,12 @@ void ModuleSplitter::indirectCallsToSecondaryFunctions() {
return;
}
auto* func = parent.secondary.getFunction(curr->target);
- auto tableSlot = parent.tableManager.getSlot(curr->target, func->sig);
+ auto tableSlot = parent.tableManager.getSlot(curr->target, func->type);
replaceCurrent(
builder.makeCallIndirect(tableSlot.tableName,
tableSlot.makeExpr(parent.primary),
curr->operands,
- func->sig,
+ func->getSig(),
curr->isReturn));
}
void visitRefFunc(RefFunc* curr) {
@@ -496,7 +497,7 @@ void ModuleSplitter::setupTablePatching() {
primary,
std::string("placeholder_") + std::string(placeholder->base.c_str()));
placeholder->hasExplicitName = false;
- placeholder->sig = secondaryFunc->sig;
+ placeholder->type = secondaryFunc->type;
elem = placeholder->name;
primary.addFunction(std::move(placeholder));
}
@@ -535,7 +536,7 @@ void ModuleSplitter::setupTablePatching() {
if (replacement->first == i) {
// primarySeg->data[i] is a placeholder, so use the secondary function.
auto* func = replacement->second;
- auto* ref = Builder(secondary).makeRefFunc(func->name, func->sig);
+ auto* ref = Builder(secondary).makeRefFunc(func->name, func->type);
secondaryElems.push_back(ref);
++replacement;
} else if (auto* get = primarySeg->data[i]->dynCast<RefFunc>()) {
@@ -574,7 +575,7 @@ void ModuleSplitter::setupTablePatching() {
currData.clear();
}
auto* func = curr->second;
- currData.push_back(Builder(secondary).makeRefFunc(func->name, func->sig));
+ currData.push_back(Builder(secondary).makeRefFunc(func->name, func->type));
}
if (currData.size()) {
finishSegment();
diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h
index 9c9f5cbfb..2cbab414b 100644
--- a/src/ir/module-utils.h
+++ b/src/ir/module-utils.h
@@ -33,7 +33,7 @@ namespace ModuleUtils {
inline Function* copyFunction(Function* func, Module& out) {
auto* ret = new Function();
ret->name = func->name;
- ret->sig = func->sig;
+ ret->type = func->type;
ret->vars = func->vars;
ret->localNames = func->localNames;
ret->localIndices = func->localIndices;
@@ -526,7 +526,7 @@ inline void collectHeapTypes(Module& wasm,
// Collect info from functions in parallel.
ModuleUtils::ParallelFunctionAnalysis<Counts, InsertOrderedMap> analysis(
wasm, [&](Function* func, Counts& counts) {
- counts.note(func->sig);
+ counts.note(func->type);
for (auto type : func->vars) {
counts.note(type);
}
diff --git a/src/ir/table-utils.h b/src/ir/table-utils.h
index 59d7cc3df..99a5bbf5b 100644
--- a/src/ir/table-utils.h
+++ b/src/ir/table-utils.h
@@ -87,7 +87,7 @@ inline Index append(Table& table, Name name, Module& wasm) {
auto* func = wasm.getFunctionOrNull(name);
assert(func != nullptr && "Cannot append non-existing function to a table.");
- segment->data.push_back(Builder(wasm).makeRefFunc(name, func->sig));
+ segment->data.push_back(Builder(wasm).makeRefFunc(name, func->type));
table.initial++;
return tableIndex;
}
diff --git a/src/ir/utils.h b/src/ir/utils.h
index 78b546962..157293e31 100644
--- a/src/ir/utils.h
+++ b/src/ir/utils.h
@@ -237,7 +237,7 @@ struct AutoDrop : public WalkerPass<ExpressionStackWalker<AutoDrop>> {
void doWalkFunction(Function* curr) {
ReFinalize().walkFunctionInModule(curr, getModule());
walk(curr->body);
- if (curr->sig.results == Type::none && curr->body->type.isConcrete()) {
+ if (curr->getResults() == Type::none && curr->body->type.isConcrete()) {
curr->body = Builder(*getModule()).makeDrop(curr->body);
}
ReFinalize().walkFunctionInModule(curr, getModule());