static/source/embindmaker/embindmaker.cxx |   25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

New commits:
commit 8dc4a2e40b1afe26b6ae4649628eb8aa064e8823
Author:     Stephan Bergmann <stephan.bergm...@allotropia.de>
AuthorDate: Sun Jan 28 20:15:40 2024 +0100
Commit:     Stephan Bergmann <stephan.bergm...@allotropia.de>
CommitDate: Sun Jan 28 21:30:21 2024 +0100

    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.bergm...@allotropia.de>

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)
                    << " *) {}
";
         }
-        cppOut << "}

"
-                  "EMSCRIPTEN_BINDINGS(unoembind_"
-               << name << ") {
";
+        cppOut << "}

";
+        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)
-                   << "\")
";
+            cppOut << "static void __attribute__((noinline)) register" << n
+                   << "() {
"
+                      "    ::emscripten::class_<"
+                   << cppName(ifc) << ">(\"" << jsName(ifc) << "\")
";
             dumpAttributes(cppOut, ifc, ifcEnt);
             dumpMethods(cppOut, mgr, ifc, ifcEnt, false);
             cppOut << "        ;
"
@@ -569,7 +570,19 @@ SAL_IMPLEMENT_MAIN()
                    << cppName(ifc) << ">::set))
";
             dumpAttributes(cppOut, ifc, ifcEnt);
             dumpMethods(cppOut, mgr, ifc, ifcEnt, true);
-            cppOut << "        ;
";
+            cppOut << "        ;
"
+                      "}
";
+            ++n;
+            if (n == 0)
+            {
+                std::cerr << "Emitting too many register functions
";
+                std::exit(EXIT_FAILURE);
+            }
+        }
+        cppOut << "EMSCRIPTEN_BINDINGS(unoembind_" << name << ") {
";
+        for (unsigned long long i = 0; i != n; ++i)
+        {
+            cppOut << "    register" << i << "();
";
         }
         cppOut << "}
";
         cppOut.close();

Reply via email to