summaryrefslogtreecommitdiff
path: root/static/source/embindmaker/embindmaker.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <stephan.bergmann@allotropia.de>2024-01-28 20:15:40 +0100
committerStephan Bergmann <stephan.bergmann@allotropia.de>2024-01-28 21:30:21 +0100
commit8dc4a2e40b1afe26b6ae4649628eb8aa064e8823 (patch)
tree665b06fca0ac9bfb31a52e3c8afc23a636f20912 /static/source/embindmaker/embindmaker.cxx
parentf0f60a8138d9abc66d3135d56cf3735abe1c7a5d (diff)
Hack to speed up compilation of generated UNO Embind source
...workdir/CustomTarget/static/unoembind/bindings_uno.cxx, reducing an otherwise no-op build for me (against emcc 3.1.51) from multiple hours to "just" 3 min wall-clock time. Change-Id: Ic6477134b72f9d28cc3193fb514ceaa32b84209c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162666 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Diffstat (limited to 'static/source/embindmaker/embindmaker.cxx')
-rw-r--r--static/source/embindmaker/embindmaker.cxx25
1 files changed, 19 insertions, 6 deletions
diff --git a/static/source/embindmaker/embindmaker.cxx b/static/source/embindmaker/embindmaker.cxx
index 5c176f94d033..e987a5ccab70 100644
--- a/static/source/embindmaker/embindmaker.cxx
+++ b/static/source/embindmaker/embindmaker.cxx
@@ -533,17 +533,18 @@ SAL_IMPLEMENT_MAIN()
cppOut << " template<> void raw_destructor<" << cppName(ifc) << ">(" << cppName(ifc)
<< " *) {}\n";
}
- cppOut << "}\n\n"
- "EMSCRIPTEN_BINDINGS(unoembind_"
- << name << ") {\n";
+ cppOut << "}\n\n";
+ unsigned long long n = 0;
for (auto const& ifc : interfaces)
{
auto const ent = mgr->getManager()->findEntity(ifc);
assert(ent.is());
assert(ent->getSort() == unoidl::Entity::SORT_INTERFACE_TYPE);
rtl::Reference const ifcEnt(static_cast<unoidl::InterfaceTypeEntity*>(ent.get()));
- cppOut << " ::emscripten::class_<" << cppName(ifc) << ">(\"" << jsName(ifc)
- << "\")\n";
+ cppOut << "static void __attribute__((noinline)) register" << n
+ << "() {\n"
+ " ::emscripten::class_<"
+ << cppName(ifc) << ">(\"" << jsName(ifc) << "\")\n";
dumpAttributes(cppOut, ifc, ifcEnt);
dumpMethods(cppOut, mgr, ifc, ifcEnt, false);
cppOut << " ;\n"
@@ -569,7 +570,19 @@ SAL_IMPLEMENT_MAIN()
<< cppName(ifc) << ">::set))\n";
dumpAttributes(cppOut, ifc, ifcEnt);
dumpMethods(cppOut, mgr, ifc, ifcEnt, true);
- cppOut << " ;\n";
+ cppOut << " ;\n"
+ "}\n";
+ ++n;
+ if (n == 0)
+ {
+ std::cerr << "Emitting too many register functions\n";
+ std::exit(EXIT_FAILURE);
+ }
+ }
+ cppOut << "EMSCRIPTEN_BINDINGS(unoembind_" << name << ") {\n";
+ for (unsigned long long i = 0; i != n; ++i)
+ {
+ cppOut << " register" << i << "();\n";
}
cppOut << "}\n";
cppOut.close();