Changeset: 73100b4f4dae for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=73100b4f4dae
Modified Files:
sql/backends/monet5/sql_execute.c
sql/backends/monet5/sql_gencode.c
Branch: jit
Log Message:
Fix optimization of inline/pre-defined functions
diffs (120 lines):
diff --git a/sql/backends/monet5/sql_execute.c
b/sql/backends/monet5/sql_execute.c
--- a/sql/backends/monet5/sql_execute.c
+++ b/sql/backends/monet5/sql_execute.c
@@ -481,8 +481,10 @@ SQLstatementIntern(Client c, str *expr,
if( backend_callinline(be, c) < 0 ||
backend_dumpstmt(be, c->curprg->def, s, 1, 1) < 0)
err = 1;
- else
+ else{
SQLaddQueryToCache(c);
+ SQLoptimizeFunction(c,c->curprg->def,m);
+ }
if (err ||c->curprg->def->errors) {
/* restore the state */
@@ -696,8 +698,10 @@ RAstatement(Client c, MalBlkPtr mb, MalS
if( backend_callinline(b, c) < 0 ||
backend_dumpstmt(b, c->curprg->def, s, 1, 1) < 0)
msg = createException(SQL,"RAstatement","Program
contains errors");
- else
+ else {
SQLaddQueryToCache(c);
+ SQLoptimizeFunction(c,c->curprg->def,m);
+ }
SQLrun(c,b,m);
if (!msg) {
resetMalBlk(c->curprg->def, oldstop);
diff --git a/sql/backends/monet5/sql_gencode.c
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -31,10 +31,14 @@
#include "sql_gencode.h"
#include "sql_optimizer.h"
#include "sql_scenario.h"
+#include "sql_mvc.h"
+#include "sql_qc.h"
+#include "sql_optimizer.h"
#include "mal_namespace.h"
#include "opt_prelude.h"
#include "querylog.h"
#include "mal_builder.h"
+#include "mal_debugger.h"
#include <rel_select.h>
#include <rel_optimizer.h>
@@ -483,8 +487,13 @@ static int
if (inline_func)
curBlk->inlineProp =1;
/* optimize the code */
- SQLoptimizeQuery(c, c->curprg->def);
SQLaddQueryToCache(c);
+ if( curBlk->inlineProp == 0)
+ SQLoptimizeQuery(c, c->curprg->def);
+ else{
+ chkProgram(c->fdout, c->nspace, c->curprg->def);
+ SQLoptimizeFunction(c,c->curprg->def,be->mvc);
+ }
if (backup)
c->curprg = backup;
return 0;
@@ -703,9 +712,10 @@ static int
/* SQL function definitions meant for inlineing should not be optimized
before */
curBlk->inlineProp = 1;
- SQLoptimizeFunction(c,c->curprg->def,m);
SQLaddQueryToCache(c);
+ chkProgram(c->fdout, c->nspace, c->curprg->def);
+ //SQLoptimizeFunction(c,c->curprg->def,be->mvc);
if (backup)
c->curprg = backup;
name[0] = old; /* make sure stub is called */
@@ -724,7 +734,6 @@ monet5_create_relational_function(mvc *m
}
/*
- * @-
* Some utility routines to generate code
* The equality operator in MAL is '==' instead of '='.
*/
@@ -946,7 +955,6 @@ pushSchema(MalBlkPtr mb, InstrPtr q, sql
}
/*
- * @-
* The big code generation switch.
*/
static int
@@ -2753,7 +2761,6 @@ static int
}
/*
- * @-
* The kernel uses two calls to procedures defined in SQL.
* They have to be initialized, which is currently hacked
* by using the SQLstatment.
@@ -2930,7 +2937,7 @@ backend_dumpproc(backend *be, Client c,
if (cq){
SQLaddQueryToCache(c);
// optimize this code the 'old' way
- if ( m->emode == m_prepare)
+ if ( m->emode == m_prepare ||
!qc_isaquerytemplate(getFunctionId(getInstrPtr(c->curprg->def,0))) )
SQLoptimizeFunction(c,c->curprg->def,m);
}
@@ -3153,8 +3160,13 @@ backend_create_sql_func(backend *be, sql
f->sa = sa;
m->sa = osa;
/* optimize the code */
- SQLoptimizeQuery(c, c->curprg->def);
SQLaddQueryToCache(c);
+ if( curBlk->inlineProp == 0)
+ SQLoptimizeFunction(c, c->curprg->def,m);
+ else{
+ chkProgram(c->fdout, c->nspace, c->curprg->def);
+ SQLoptimizeFunction(c,c->curprg->def,be->mvc);
+ }
if (backup)
c->curprg = backup;
return 0;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list