diff options
author | Sam Clegg <sbc@chromium.org> | 2022-04-14 07:58:11 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-14 00:58:11 -0700 |
commit | 67c7490aea420a98bd90005cffd7544b804530a0 (patch) | |
tree | d920ff346577d01891263d2e8ba672af901d923a /src | |
parent | 39022f8cd717ec5f219c56f4ebd07f016c457afc (diff) | |
download | wabt-67c7490aea420a98bd90005cffd7544b804530a0.tar.gz wabt-67c7490aea420a98bd90005cffd7544b804530a0.tar.bz2 wabt-67c7490aea420a98bd90005cffd7544b804530a0.zip |
Remove signature mangling from wasm2c output (#1896)
This effectively means that we no longer support imports that are
overloaded by signature only. This is not something that we need to
support in order to support the core wasm spec.
This feature is available in the JS embedding but there is no good
reason (AFAICT) to support it in wasm2c, and this simplifies the
generated code.
Fixes #1858
Diffstat (limited to 'src')
-rw-r--r-- | src/c-writer.cc | 53 |
1 files changed, 7 insertions, 46 deletions
diff --git a/src/c-writer.cc b/src/c-writer.cc index e2bef4a3..fadd88d4 100644 --- a/src/c-writer.cc +++ b/src/c-writer.cc @@ -161,13 +161,8 @@ class CWriter { static std::string Deref(const std::string&); static char MangleType(Type); - static std::string MangleTypes(const TypeVector&); static std::string MangleMultivalueTypes(const TypeVector&); static std::string MangleName(std::string_view); - static std::string MangleFuncName(std::string_view, - const TypeVector& param_types, - const TypeVector& result_types); - static std::string MangleGlobalName(std::string_view, Type); static std::string LegalizeName(std::string_view); static std::string ExportName(std::string_view mangled_name); std::string DefineName(SymbolSet*, std::string_view); @@ -396,18 +391,6 @@ char CWriter::MangleType(Type type) { } // static -std::string CWriter::MangleTypes(const TypeVector& types) { - if (types.empty()) - return std::string("v"); - - std::string result; - for (auto type : types) { - result += MangleType(type); - } - return result; -} - -// static std::string CWriter::MangleMultivalueTypes(const TypeVector& types) { assert(types.size() >= 2); std::string result = "wasm_multi_"; @@ -437,20 +420,6 @@ std::string CWriter::MangleName(std::string_view name) { } // static -std::string CWriter::MangleFuncName(std::string_view name, - const TypeVector& param_types, - const TypeVector& result_types) { - std::string sig = MangleTypes(result_types) + MangleTypes(param_types); - return MangleName(name) + MangleName(sig); -} - -// static -std::string CWriter::MangleGlobalName(std::string_view name, Type type) { - std::string sig(1, MangleType(type)); - return MangleName(name) + MangleName(sig); -} - -// static std::string CWriter::ExportName(std::string_view mangled_name) { return "WASM_RT_ADD_PREFIX(" + std::string(mangled_name) + ")"; } @@ -889,22 +858,17 @@ void CWriter::WriteImports() { switch (import->kind()) { case ExternalKind::Func: { const Func& func = cast<FuncImport>(import)->func; - WriteFuncDeclaration( - func.decl, - DefineImportName( - func.name, import->module_name, - MangleFuncName(import->field_name, func.decl.sig.param_types, - func.decl.sig.result_types))); + WriteFuncDeclaration(func.decl, + DefineImportName(func.name, import->module_name, + MangleName(import->field_name))); Write(";"); break; } case ExternalKind::Global: { const Global& global = cast<GlobalImport>(import)->global; - WriteGlobal(global, - DefineImportName( - global.name, import->module_name, - MangleGlobalName(import->field_name, global.type))); + WriteGlobal(global, DefineImportName(global.name, import->module_name, + MangleName(import->field_name))); Write(";"); break; } @@ -1177,9 +1141,7 @@ void CWriter::WriteExports(WriteExportsKind kind) { switch (export_->kind) { case ExternalKind::Func: { const Func* func = module_->GetFunc(export_->var); - mangled_name = - ExportName(MangleFuncName(export_->name, func->decl.sig.param_types, - func->decl.sig.result_types)); + mangled_name = ExportName(MangleName(export_->name)); internal_name = func->name; if (kind != WriteExportsKind::Initializers) { WriteFuncDeclaration(func->decl, Deref(mangled_name)); @@ -1190,8 +1152,7 @@ void CWriter::WriteExports(WriteExportsKind kind) { case ExternalKind::Global: { const Global* global = module_->GetGlobal(export_->var); - mangled_name = - ExportName(MangleGlobalName(export_->name, global->type)); + mangled_name = ExportName(MangleName(export_->name)); internal_name = global->name; if (kind != WriteExportsKind::Initializers) { WriteGlobal(*global, Deref(mangled_name)); |