[Libreoffice-commits] core.git: sc/inc sc/source

Luboš Luňák l.lunak at collabora.com
Fri Jun 22 15:00:30 UTC 2018


 sc/inc/tokenarray.hxx         |    3 ++-
 sc/source/core/tool/token.cxx |   41 ++++++++++++++++++++++++++++++-----------
 2 files changed, 32 insertions(+), 12 deletions(-)

New commits:
commit a4f7c91c933c24e812acac9d6566c57fcbe412e0
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Fri Jun 22 11:01:24 2018 +0200

    disable calc's threading for external references
    
    Since the code uses ScExternalRefManager, which caches values, so
    better just disable it. Can be seen e.g. with fdo#78490-1 (and
    mnOpenCLMinimumFormulaGroupSize disabled). The doc actually asserts
    in GetFormatTable() called from ScExternalRefManager, but there
    seems to be no point in fixing just the assert if the whole class
    is possibly problematic.
    
    Change-Id: I4ace488414fd15b4ad0b88da51205b02c561c7a6
    Reviewed-on: https://gerrit.libreoffice.org/56289
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/sc/inc/tokenarray.hxx b/sc/inc/tokenarray.hxx
index feac9acf32f6..1e747e8b5dcc 100644
--- a/sc/inc/tokenarray.hxx
+++ b/sc/inc/tokenarray.hxx
@@ -55,6 +55,8 @@ class SAL_WARN_UNUSED SC_DLLPUBLIC ScTokenArray : public formula::FormulaTokenAr
     bool mbOpenCLEnabled : 1;
     bool mbThreadingEnabled : 1;
 
+    void CheckForThreading( const formula::FormulaToken& r );
+
 public:
     ScTokenArray();
     /** Assignment with incrementing references of FormulaToken entries
@@ -97,7 +99,6 @@ public:
         svl::SharedStringPool& rSPool,
         formula::ExternalReferenceHelper* _pRef) override;
     virtual void CheckToken( const formula::FormulaToken& r ) override;
-    void CheckForThreading( OpCode eOp );
     virtual formula::FormulaToken* AddOpCode( OpCode eCode ) override;
     /** ScSingleRefToken with ocPush. */
     formula::FormulaToken* AddSingleReference( const ScSingleRefData& rRef );
diff --git a/sc/source/core/tool/token.cxx b/sc/source/core/tool/token.cxx
index a27c1441e143..7bd456c31284 100644
--- a/sc/source/core/tool/token.cxx
+++ b/sc/source/core/tool/token.cxx
@@ -1308,7 +1308,7 @@ bool ScTokenArray::AddFormulaToken(
     return bError;
 }
 
-void ScTokenArray::CheckForThreading( OpCode eOp  )
+void ScTokenArray::CheckForThreading( const FormulaToken& r )
 {
     static const std::set<OpCode> aThreadedCalcBlackList({
         ocIndirect,
@@ -1333,29 +1333,48 @@ void ScTokenArray::CheckForThreading( OpCode eOp  )
 
     static const bool bThreadingProhibited = std::getenv("SC_NO_THREADED_CALCULATION");
 
-    if (!bThreadingProhibited)
+    if (bThreadingProhibited)
     {
-        if (aThreadedCalcBlackList.count(eOp))
+        mbThreadingEnabled = false;
+        return;
+    }
+
+    OpCode eOp = r.GetOpCode();
+
+    if (aThreadedCalcBlackList.count(eOp))
+    {
+        SAL_INFO("sc.core.formulagroup", "opcode " << formula::FormulaCompiler().GetOpCodeMap(sheet::FormulaLanguage::ENGLISH)->getSymbol(eOp)
+            << "(" << int(eOp) << ") disables threaded calculation of formula group");
+        mbThreadingEnabled = false;
+        return;
+    }
+
+    if (eOp == ocPush)
+    {
+        switch (r.GetType())
         {
-            SAL_INFO("sc.core.formulagroup", "opcode " << formula::FormulaCompiler().GetOpCodeMap(sheet::FormulaLanguage::ENGLISH)->getSymbol(eOp)
-                << "(" << int(eOp) << ") disables threaded calculation of formula group");
-            mbThreadingEnabled = false;
+            case svExternalDoubleRef:
+            case svExternalSingleRef:
+                SAL_INFO("sc.core.formulagroup", "opcode ocPush: variable type " << StackVarEnumToString(r.GetType())
+                    << " disables threaded calculcation of formula group");
+                mbThreadingEnabled = false;
+                return;
+            default:
+                break;
         }
     }
-    else
-        mbThreadingEnabled = false;
 }
 
 void ScTokenArray::CheckToken( const FormulaToken& r )
 {
-    OpCode eOp = r.GetOpCode();
-
     if (mbThreadingEnabled)
-        CheckForThreading(eOp);
+        CheckForThreading(r);
 
     if (IsFormulaVectorDisabled())
         return; // It's already disabled.  No more checking needed.
 
+    OpCode eOp = r.GetOpCode();
+
     if (SC_OPCODE_START_FUNCTION <= eOp && eOp < SC_OPCODE_STOP_FUNCTION)
     {
         if (ScInterpreter::GetGlobalConfig().mbOpenCLSubsetOnly &&


More information about the Libreoffice-commits mailing list