LCOV - code coverage report
Current view: top level - monetdb5/optimizer - opt_fastpath.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 61 65 93.8 %
Date: 2024-04-26 00:35:57 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  * SPDX-License-Identifier: MPL-2.0
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0.  If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * Copyright 2024 MonetDB Foundation;
       9             :  * Copyright August 2008 - 2023 MonetDB B.V.;
      10             :  * Copyright 1997 - July 2008 CWI.
      11             :  */
      12             : 
      13             : #include "monetdb_config.h"
      14             : #include "opt_fastpath.h"
      15             : #include "opt_aliases.h"
      16             : #include "opt_coercion.h"
      17             : #include "opt_commonTerms.h"
      18             : #include "opt_candidates.h"
      19             : #include "opt_constants.h"
      20             : #include "opt_costModel.h"
      21             : #include "opt_dataflow.h"
      22             : #include "opt_deadcode.h"
      23             : #include "opt_dict.h"
      24             : #include "opt_for.h"
      25             : #include "opt_emptybind.h"
      26             : #include "opt_evaluate.h"
      27             : #include "opt_garbageCollector.h"
      28             : #include "opt_generator.h"
      29             : #include "opt_inline.h"
      30             : #include "opt_projectionpath.h"
      31             : #include "opt_matpack.h"
      32             : #include "opt_postfix.h"
      33             : #include "opt_mergetable.h"
      34             : #include "opt_mitosis.h"
      35             : #include "opt_multiplex.h"
      36             : #include "opt_profiler.h"
      37             : #include "opt_pushselect.h"
      38             : #include "opt_querylog.h"
      39             : #include "opt_reduce.h"
      40             : #include "opt_remap.h"
      41             : #include "opt_remoteQueries.h"
      42             : #include "opt_reorder.h"
      43             : #include "opt_fastpath.h"
      44             : #include "optimizer_private.h"
      45             : #include "mal_interpreter.h"
      46             : #include "opt_prelude.h"
      47             : 
      48             : #define optcall(TEST, OPT)                                                                                              \
      49             :         do {                                                                                                                            \
      50             :                 if (TEST) {                                                                                                             \
      51             :                         if ((msg = OPT(cntxt, mb, stk, pci)) != MAL_SUCCEED)            \
      52             :                                 goto bailout;                                                                                   \
      53             :                         actions += *(int*)getVarValue(mb, getArg(pci, pci->argc - 1)); \
      54             :                         delArgument(pci, pci->argc - 1); /* keep number of argc low, so 'pci' is not reallocated */ \
      55             :                 }                                                                                                                               \
      56             :         } while (0)
      57             : 
      58             : str
      59       66126 : OPTminimalfastImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
      60             :                                                          InstrPtr pci)
      61             : {
      62       66126 :         str msg = MAL_SUCCEED;
      63       66126 :         int generator = 0, multiplex = 0, actions = 0;
      64             : 
      65             :         /* perform a single scan through the plan to determine which optimizer steps to skip */
      66     1417994 :         for (int i = 0; i < mb->stop; i++) {
      67     1351868 :                 InstrPtr q = getInstrPtr(mb, i);
      68     1351868 :                 if (getModuleId(q) == generatorRef)
      69           0 :                         generator = 1;
      70     1351868 :                 if (getFunctionId(q) == multiplexRef)
      71           0 :                         multiplex = 1;
      72             :         }
      73             : 
      74       66126 :         optcall(true, OPTinlineImplementation);
      75       66636 :         optcall(true, OPTremapImplementation);
      76       67293 :         optcall(true, OPTemptybindImplementation);
      77       67332 :         optcall(true, OPTdeadcodeImplementation);
      78       67165 :         optcall(true, OPTforImplementation);
      79       67367 :         optcall(true, OPTdictImplementation);
      80       67246 :         optcall(multiplex, OPTmultiplexImplementation);
      81       67201 :         optcall(generator, OPTgeneratorImplementation);
      82       67249 :         optcall(profilerStatus, OPTprofilerImplementation);
      83       67250 :         optcall(profilerStatus, OPTcandidatesImplementation);
      84       67250 :         optcall(true, OPTgarbageCollectorImplementation);
      85             : 
      86             :         /* Defense line against incorrect plans  handled by optimizer steps */
      87             :         /* keep actions taken as a fake argument */
      88       67049 :   bailout:
      89       67049 :         (void) pushInt(mb, pci, actions);
      90       67223 :         return msg;
      91             : }
      92             : 
      93             : str
      94       31908 : OPTdefaultfastImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
      95             :                                                          InstrPtr pci)
      96             : {
      97       31908 :         str msg = MAL_SUCCEED;
      98       31908 :         int generator = 0, multiplex = 0, actions = 0;
      99             : 
     100             :         /* perform a single scan through the plan to determine which optimizer steps to skip */
     101     1005181 :         for (int i = 0; i < mb->stop; i++) {
     102      973273 :                 InstrPtr q = getInstrPtr(mb, i);
     103      973273 :                 if (getModuleId(q) == generatorRef)
     104           0 :                         generator = 1;
     105      973273 :                 if (getFunctionId(q) == multiplexRef)
     106           0 :                         multiplex = 1;
     107             :         }
     108             : 
     109       31908 :         optcall(true, OPTinlineImplementation);
     110       31917 :         optcall(true, OPTremapImplementation);
     111       31988 :         optcall(true, OPTcostModelImplementation);
     112       31982 :         optcall(true, OPTcoercionImplementation);
     113       31998 :         optcall(true, OPTaliasesImplementation);
     114       31980 :         optcall(true, OPTevaluateImplementation);
     115       31991 :         optcall(true, OPTemptybindImplementation);
     116       31985 :         optcall(true, OPTdeadcodeImplementation);
     117       31989 :         optcall(true, OPTpushselectImplementation);
     118       31977 :         optcall(true, OPTaliasesImplementation);
     119       31987 :         optcall(true, OPTforImplementation);
     120       31985 :         optcall(true, OPTdictImplementation);
     121       31987 :         optcall(true, OPTmitosisImplementation);
     122       31983 :         optcall(true, OPTmergetableImplementation);
     123       31986 :         optcall(true, OPTaliasesImplementation);
     124       31995 :         optcall(true, OPTconstantsImplementation);
     125       31993 :         optcall(true, OPTcommonTermsImplementation);
     126       31993 :         optcall(true, OPTprojectionpathImplementation);
     127       31990 :         optcall(true, OPTdeadcodeImplementation);
     128       31989 :         optcall(true, OPTreorderImplementation);
     129       31988 :         optcall(true, OPTmatpackImplementation);
     130       31994 :         optcall(true, OPTdataflowImplementation);
     131       31973 :         optcall(true, OPTquerylogImplementation);
     132       31991 :         optcall(multiplex, OPTmultiplexImplementation);
     133       31984 :         optcall(generator, OPTgeneratorImplementation);
     134       31974 :         optcall(profilerStatus, OPTprofilerImplementation);
     135       31981 :         optcall(profilerStatus, OPTcandidatesImplementation);
     136       31981 :         optcall(true, OPTdeadcodeImplementation);
     137       31994 :         optcall(true, OPTpostfixImplementation);
     138       31988 :         optcall(true, OPTgarbageCollectorImplementation);
     139             : 
     140             :         /* Defense line against incorrect plans  handled by optimizer steps */
     141             :         /* keep actions taken as a fake argument */
     142       31975 :   bailout:
     143       31975 :         (void) pushInt(mb, pci, actions);
     144       31957 :         return msg;
     145             : }

Generated by: LCOV version 1.14