Merge lp:~zorba-coders/zorba/markos-scratch into lp:zorba
- markos-scratch
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 11619 |
Proposed branch: | lp:~zorba-coders/zorba/markos-scratch |
Merge into: | lp:zorba |
Diff against target: |
430 lines (+67/-105) 11 files modified
ChangeLog (+1/-0) src/compiler/expression/expr_base.h (+2/-2) src/compiler/expression/var_expr.cpp (+3/-1) src/compiler/expression/var_expr.h (+6/-0) src/compiler/rewriter/rules/flwor_rules.cpp (+10/-2) src/compiler/rewriter/rules/fold_rules.cpp (+2/-1) src/compiler/translator/translator.cpp (+34/-25) src/compiler/xqddf/value_index.cpp (+1/-1) src/functions/func_index_ddl.h (+7/-2) test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx5.iter (+1/-35) test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/hoist01.iter (+0/-36) |
To merge this branch: | bzr merge lp:~zorba-coders/zorba/markos-scratch |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Markos Zaharioudakis | Approve | ||
Review via email: mp+185014@code.launchpad.net |
Commit message
More aggressive eliminationof unused LET variables
Description of the change
More aggressive eliminationof unused LET variables
Markos Zaharioudakis (markos-za) : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue result for https:/
Stage "TestZorbaUbuntu" failed.
5 tests failed (8425 total tests run).
Check test results at http://
- 11220. By Markos Zaharioudakis
-
More aggressive eliminationof unused LET variables
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for the following merge proposals:
https:/
Progress dashboard at http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue result for https:/
Stage "TestZorbaUbuntu" failed.
4 tests failed (8425 total tests run).
Check test results at http://
- 11221. By Markos Zaharioudakis
-
More aggressive eliminationof unused LET variables
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue starting for the following merge proposals:
https:/
Progress dashboard at http://
Zorba Build Bot (zorba-buildbot) wrote : | # |
Validation queue succeeded - proposal merged!
Preview Diff
1 | === modified file 'ChangeLog' |
2 | --- ChangeLog 2013-09-11 01:43:33 +0000 |
3 | +++ ChangeLog 2013-09-12 07:54:27 +0000 |
4 | @@ -36,6 +36,7 @@ |
5 | * Optimized implementation of function caching and removed the restriction |
6 | on the return type. |
7 | * No node ordering/distinct required for self axis. |
8 | + * More aggressive eliminationof unused LET variables |
9 | |
10 | Bug Fixes/Other Changes: |
11 | * Fixed bug #1117952 (Improve XML error output format) |
12 | |
13 | === modified file 'src/compiler/expression/expr_base.h' |
14 | --- src/compiler/expression/expr_base.h 2013-05-29 04:17:01 +0000 |
15 | +++ src/compiler/expression/expr_base.h 2013-09-12 07:54:27 +0000 |
16 | @@ -234,6 +234,8 @@ |
17 | |
18 | unsigned short get_scripting_detail() const { return theScriptingKind; } |
19 | |
20 | + void set_scripting_detail(unsigned short k) { theScriptingKind = k; } |
21 | + |
22 | bool is_updating() const; |
23 | |
24 | bool is_sequential() const; |
25 | @@ -246,8 +248,6 @@ |
26 | |
27 | void set_not_exiting(); |
28 | |
29 | - void adjustSequential(); |
30 | - |
31 | void checkScriptingKind() const; |
32 | |
33 | void compute_return_type(bool deep, bool* modified); |
34 | |
35 | === modified file 'src/compiler/expression/var_expr.cpp' |
36 | --- src/compiler/expression/var_expr.cpp 2013-04-24 01:35:58 +0000 |
37 | +++ src/compiler/expression/var_expr.cpp 2013-09-12 07:54:27 +0000 |
38 | @@ -85,6 +85,7 @@ |
39 | theCopyClause(NULL), |
40 | theParamPos(0), |
41 | theVarInfo(NULL), |
42 | + theNumRefs(0), |
43 | theIsExternal(false), |
44 | theIsPrivate(false), |
45 | theIsMutable(true), |
46 | @@ -95,7 +96,7 @@ |
47 | |
48 | |
49 | /******************************************************************************* |
50 | - |
51 | + Used when cloning FLWOR clauses that define variables. |
52 | ********************************************************************************/ |
53 | var_expr::var_expr(user_function* udf, const var_expr& source) |
54 | : |
55 | @@ -108,6 +109,7 @@ |
56 | theCopyClause(NULL), |
57 | theParamPos(source.theParamPos), |
58 | theVarInfo(NULL), |
59 | + theNumRefs(source.theNumRefs), |
60 | theIsExternal(source.theIsExternal), |
61 | theIsPrivate(source.theIsPrivate), |
62 | theIsMutable(source.theIsMutable), |
63 | |
64 | === modified file 'src/compiler/expression/var_expr.h' |
65 | --- src/compiler/expression/var_expr.h 2013-04-24 01:35:58 +0000 |
66 | +++ src/compiler/expression/var_expr.h 2013-09-12 07:54:27 +0000 |
67 | @@ -178,6 +178,8 @@ |
68 | |
69 | VarInfo * theVarInfo; |
70 | |
71 | + csize theNumRefs; |
72 | + |
73 | bool theIsExternal; |
74 | |
75 | bool theIsPrivate; |
76 | @@ -217,6 +219,10 @@ |
77 | |
78 | void set_kind(var_kind k) { theVarKind = k; } |
79 | |
80 | + csize get_num_refs() const { return theNumRefs; } |
81 | + |
82 | + void add_ref() { ++theNumRefs; } |
83 | + |
84 | bool is_private() const { return theIsPrivate; } |
85 | |
86 | void set_private(bool v) { theIsPrivate = v; } |
87 | |
88 | === modified file 'src/compiler/rewriter/rules/flwor_rules.cpp' |
89 | --- src/compiler/rewriter/rules/flwor_rules.cpp 2013-08-09 10:23:10 +0000 |
90 | +++ src/compiler/rewriter/rules/flwor_rules.cpp 2013-09-12 07:54:27 +0000 |
91 | @@ -566,8 +566,16 @@ |
92 | |
93 | if (safe && numRefs == 0) |
94 | { |
95 | - if (varDomExpr->isNonDiscardable() || !isSafeVar) |
96 | - { |
97 | + if (varDomExpr->get_function_kind() == FunctionConsts::OP_CREATE_INTERNAL_INDEX_2 || |
98 | + !isSafeVar) |
99 | + { |
100 | + return false; |
101 | + } |
102 | + else if (varDomExpr->isNonDiscardable()) |
103 | + { |
104 | + if (var->get_kind() == var_expr::let_var && var->get_num_refs() == 0) |
105 | + return true; |
106 | + |
107 | return false; |
108 | } |
109 | else |
110 | |
111 | === modified file 'src/compiler/rewriter/rules/fold_rules.cpp' |
112 | --- src/compiler/rewriter/rules/fold_rules.cpp 2013-08-14 15:16:42 +0000 |
113 | +++ src/compiler/rewriter/rules/fold_rules.cpp 2013-09-12 07:54:27 +0000 |
114 | @@ -216,7 +216,8 @@ |
115 | |
116 | case var_expr_kind: |
117 | { |
118 | - var_expr::var_kind varKind = static_cast<var_expr *>(node)->get_kind(); |
119 | + var_expr* var = static_cast<var_expr *>(node); |
120 | + var_expr::var_kind varKind = var->get_kind(); |
121 | |
122 | if (varKind == var_expr::prolog_var || varKind == var_expr::local_var) |
123 | curUnfoldable = ANNOTATION_TRUE_FIXED; |
124 | |
125 | === modified file 'src/compiler/translator/translator.cpp' |
126 | --- src/compiler/translator/translator.cpp 2013-08-30 14:50:21 +0000 |
127 | +++ src/compiler/translator/translator.cpp 2013-09-12 07:54:27 +0000 |
128 | @@ -1669,10 +1669,13 @@ |
129 | argVars.push_back(argVar); |
130 | |
131 | expr* arg = CREATE(wrapper)(theRootSctx, theUDF, loc, argVar); |
132 | + argVar->add_ref(); |
133 | arg = normalize_fo_arg(i, arg, inlineUDF.get(), loc); |
134 | arguments.push_back(arg); |
135 | } |
136 | |
137 | + fiSubstVar->add_ref(); |
138 | + |
139 | expr* body = |
140 | CREATE(dynamic_function_invocation)(theRootSctx, |
141 | theUDF, |
142 | @@ -1935,6 +1938,8 @@ |
143 | // compute the size of the input seq |
144 | expr* varWrapper = CREATE(wrapper)(theRootSctx, theUDF, loc, lcInputVar); |
145 | |
146 | + lcInputVar->add_ref(); |
147 | + |
148 | fo_expr* countExpr = CREATE(fo)(theRootSctx, |
149 | theUDF, |
150 | loc, |
151 | @@ -6605,6 +6610,8 @@ |
152 | ERROR_PARAMS(ve->get_name()->getStringValue())); |
153 | } |
154 | |
155 | + ve->add_ref(); |
156 | + |
157 | xqtref_t varType = ve->get_type(); |
158 | |
159 | expr* valueExpr = pop_nodestack(); |
160 | @@ -7629,6 +7636,8 @@ |
161 | |
162 | inputExpr = CREATE(wrapper)(theRootSctx, theUDF, specLoc, inputExpr); |
163 | |
164 | + var->getVar()->add_ref(); |
165 | + |
166 | inputExpr = wrap_in_atomization(inputExpr); |
167 | |
168 | inputExpr = wrap_in_type_match(inputExpr, |
169 | @@ -7681,6 +7690,8 @@ |
170 | expr* inputExpr = |
171 | theExprManager->create_wrapper_expr(theRootSctx, theUDF, loc, inputVar); |
172 | |
173 | + inputVar->add_ref(); |
174 | + |
175 | nongrouping_rebind.push_back(std::pair<expr*, var_expr*>(inputExpr, ngVar)); |
176 | } |
177 | |
178 | @@ -10343,8 +10354,11 @@ |
179 | // |
180 | // The flworExpr as well as the $$predInput varExpr are pushed to the nodestack. |
181 | const for_clause* fcOuterDot = static_cast<const for_clause*>(flworExpr->get_clause(0)); |
182 | - relpath_expr* predPathExpr = theExprManager->create_relpath_expr(theRootSctx, theUDF, loc); |
183 | - predPathExpr->add_back(theExprManager->create_wrapper_expr(theRootSctx, theUDF, loc, fcOuterDot->get_var())); |
184 | + relpath_expr* predPathExpr = CREATE(relpath)(theRootSctx, theUDF, loc); |
185 | + predPathExpr->add_back(CREATE(wrapper)(theRootSctx, theUDF, loc, fcOuterDot->get_var())); |
186 | + |
187 | + fcOuterDot->get_var()->add_ref(); |
188 | + |
189 | predPathExpr->add_back(axisExpr); |
190 | |
191 | expr* predInputExpr = predPathExpr; |
192 | @@ -11317,6 +11331,8 @@ |
193 | throw; |
194 | } |
195 | |
196 | + ve->add_ref(); |
197 | + |
198 | if (ve->get_kind() == var_expr::prolog_var) |
199 | { |
200 | TypeManager* tm = CTX_TM; |
201 | @@ -11389,6 +11405,8 @@ |
202 | } |
203 | } |
204 | |
205 | + dotVar->add_ref(); |
206 | + |
207 | return CREATE(wrapper)(theRootSctx, theUDF, loc, dotVar); |
208 | } |
209 | |
210 | @@ -11408,6 +11426,8 @@ |
211 | } |
212 | } |
213 | |
214 | + posVar->add_ref(); |
215 | + |
216 | return CREATE(wrapper)(theRootSctx, theUDF, loc, posVar); |
217 | } |
218 | |
219 | @@ -11427,6 +11447,8 @@ |
220 | } |
221 | } |
222 | |
223 | + sizeVar->add_ref(); |
224 | + |
225 | return CREATE(wrapper)(theRootSctx, theUDF, loc, sizeVar); |
226 | } |
227 | |
228 | @@ -11445,17 +11467,7 @@ |
229 | { |
230 | TRACE_VISIT_OUT(); |
231 | |
232 | - var_expr* ve = lookup_ctx_var(getDotItemVarName(), loc); |
233 | - |
234 | - if (ve->get_kind() == var_expr::prolog_var) |
235 | - { |
236 | - if (!theCurrentPrologVFDecl.isNull()) |
237 | - { |
238 | - thePrologGraph.addEdge(theCurrentPrologVFDecl, ve); |
239 | - } |
240 | - } |
241 | - |
242 | - push_nodestack(CREATE(wrapper)(theRootSctx, theUDF, loc, ve)); |
243 | + push_nodestack(dotRef(loc)); |
244 | } |
245 | |
246 | |
247 | @@ -11992,18 +12004,7 @@ |
248 | } |
249 | case FunctionConsts::FN_ZORBA_CONTEXT_ITEM_0: |
250 | { |
251 | - // copy+pasted from the ContextItemExpr |
252 | - var_expr* ve = lookup_ctx_var(getDotItemVarName(), loc); |
253 | - |
254 | - if (ve->get_kind() == var_expr::prolog_var) |
255 | - { |
256 | - if (!theCurrentPrologVFDecl.isNull()) |
257 | - { |
258 | - thePrologGraph.addEdge(theCurrentPrologVFDecl, ve); |
259 | - } |
260 | - } |
261 | - |
262 | - resultExpr = CREATE(wrapper)(theRootSctx, theUDF, loc, ve); |
263 | + resultExpr = dotRef(loc); |
264 | break; |
265 | } |
266 | case FunctionConsts::FN_STRING_LENGTH_0: |
267 | @@ -12352,6 +12353,8 @@ |
268 | std::vector<expr*> fncall_args; |
269 | fncall_args.push_back(CREATE(wrapper)(theRootSctx, theUDF, loc, seq_fc->get_var())); |
270 | |
271 | + seq_fc->get_var()->add_ref(); |
272 | + |
273 | expr* dynamic_fncall = |
274 | CREATE(dynamic_function_invocation)(theRootSctx, theUDF, loc, |
275 | arguments[1], |
276 | @@ -12381,6 +12384,8 @@ |
277 | std::vector<expr*> fncall_args; |
278 | fncall_args.push_back(CREATE(wrapper)(theRootSctx, theUDF, loc, seq_fc->get_var())); |
279 | |
280 | + seq_fc->get_var()->add_ref(); |
281 | + |
282 | expr* dynamic_fncall = |
283 | CREATE(dynamic_function_invocation)(theRootSctx, theUDF, loc, |
284 | arguments[1], |
285 | @@ -12563,6 +12568,8 @@ |
286 | |
287 | sourceExpr = CREATE(wrapper)(theRootSctx, theUDF, loc, fc->get_var()); |
288 | |
289 | + fc->get_var()->add_ref(); |
290 | + |
291 | expr* dynFuncInvocation = |
292 | CREATE(dynamic_function_invocation)(theRootSctx, theUDF, loc, |
293 | sourceExpr, |
294 | @@ -12825,6 +12832,8 @@ |
295 | flworBody->add_clause(lc); |
296 | foArgs[1] = CREATE(wrapper)(theRootSctx, theUDF, loc, lc->get_var()); |
297 | |
298 | + lc->get_var()->add_ref(); |
299 | + |
300 | flworBody->set_return_expr(generate_fn_body(func, foArgs, loc)); |
301 | body = flworBody; |
302 | break; |
303 | |
304 | === modified file 'src/compiler/xqddf/value_index.cpp' |
305 | --- src/compiler/xqddf/value_index.cpp 2013-05-31 01:47:24 +0000 |
306 | +++ src/compiler/xqddf/value_index.cpp 2013-09-12 07:54:27 +0000 |
307 | @@ -569,7 +569,7 @@ |
308 | |
309 | expr* keyClone = theKeyExprs[i]->clone(udf, subst); |
310 | |
311 | - keyClone->setNonDiscardable(ANNOTATION_TRUE_FIXED); |
312 | + keyClone->set_scripting_detail(SEQUENTIAL_FUNC_EXPR); |
313 | |
314 | const QueryLoc& keyloc = keyClone->get_loc(); |
315 | |
316 | |
317 | === modified file 'src/functions/func_index_ddl.h' |
318 | --- src/functions/func_index_ddl.h 2013-02-07 17:24:36 +0000 |
319 | +++ src/functions/func_index_ddl.h 2013-09-12 07:54:27 +0000 |
320 | @@ -45,10 +45,15 @@ |
321 | { |
322 | } |
323 | |
324 | - unsigned short getScriptingKind() const { return SIMPLE_EXPR; } |
325 | - |
326 | bool accessesDynCtx() const { return true; } |
327 | |
328 | + unsigned short getScriptingKind() const |
329 | + { |
330 | + // Although the index creation will be applied immediately, we should |
331 | + // NOT mark this function as sequential. |
332 | + return SIMPLE_EXPR; |
333 | + } |
334 | + |
335 | bool mustCopyInputNodes(expr* fo, csize input) const { return false; } |
336 | |
337 | BoolAnnotationValue ignoresSortedNodes(expr* fo, csize input) const |
338 | |
339 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx5.iter' |
340 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx5.iter 2013-02-07 17:24:36 +0000 |
341 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/hashjoins/idx5.iter 2013-09-12 07:54:27 +0000 |
342 | @@ -19,40 +19,6 @@ |
343 | <SingletonIterator value="xs:QName(,,tests)"/> |
344 | </ElementIterator> |
345 | </CtxVarDeclareIterator> |
346 | - <flwor::FLWORIterator> |
347 | - <LetVariable name="test_old" materialize="true"> |
348 | - <flwor::FLWORIterator> |
349 | - <ForVariable name="$$context-item"> |
350 | - <CtxVarIterator varid="4" varname="tests" varkind="global"/> |
351 | - </ForVariable> |
352 | - <WhereClause> |
353 | - <FnBooleanIterator> |
354 | - <TypedValueCompareIterator_STRING> |
355 | - <PromoteIterator type="xs:anyAtomicType"> |
356 | - <FnDataIterator> |
357 | - <ChildAxisIterator test kind="match_text_test" qname="*" typename="*" nill allowed="0"> |
358 | - <ForVarIterator varname="$$context-item"/> |
359 | - </ChildAxisIterator> |
360 | - </FnDataIterator> |
361 | - </PromoteIterator> |
362 | - <PromoteIterator type="xs:anyAtomicType"> |
363 | - <FnDataIterator> |
364 | - <ChildAxisIterator test kind="match_text_test" qname="*" typename="*" nill allowed="0"> |
365 | - <CtxVarIterator varid="4" varname="tests" varkind="global"/> |
366 | - </ChildAxisIterator> |
367 | - </FnDataIterator> |
368 | - </PromoteIterator> |
369 | - </TypedValueCompareIterator_STRING> |
370 | - </FnBooleanIterator> |
371 | - </WhereClause> |
372 | - <ReturnClause> |
373 | - <ForVarIterator varname="$$context-item"/> |
374 | - </ReturnClause> |
375 | - </flwor::FLWORIterator> |
376 | - </LetVariable> |
377 | - <ReturnClause> |
378 | - <SingletonIterator value="xs:integer(1)"/> |
379 | - </ReturnClause> |
380 | - </flwor::FLWORIterator> |
381 | + <SingletonIterator value="xs:integer(1)"/> |
382 | </SequentialIterator> |
383 | |
384 | |
385 | === modified file 'test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/hoist01.iter' |
386 | --- test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/hoist01.iter 2013-03-04 21:00:58 +0000 |
387 | +++ test/rbkt/ExpCompilerResults/IterPlan/zorba/optim/hoist01.iter 2013-09-12 07:54:27 +0000 |
388 | @@ -9,42 +9,6 @@ |
389 | </OrIterator> |
390 | |
391 | Iterator tree for const-folded expr: |
392 | -<HoistIterator> |
393 | - <FnBooleanIterator> |
394 | - <IfThenElseIterator> |
395 | - <FnBooleanIterator> |
396 | - <FnConcatIterator/> |
397 | - </FnBooleanIterator> |
398 | - <FnConcatIterator/> |
399 | - <FnConcatIterator/> |
400 | - </IfThenElseIterator> |
401 | - </FnBooleanIterator> |
402 | -</HoistIterator> |
403 | - |
404 | -Iterator tree for const-folded expr: |
405 | -<HoistIterator> |
406 | - <FnBooleanIterator> |
407 | - <IfThenElseIterator> |
408 | - <FnBooleanIterator> |
409 | - <FnConcatIterator/> |
410 | - </FnBooleanIterator> |
411 | - <FnConcatIterator/> |
412 | - <FnConcatIterator/> |
413 | - </IfThenElseIterator> |
414 | - </FnBooleanIterator> |
415 | -</HoistIterator> |
416 | - |
417 | -Iterator tree for const-folded expr: |
418 | -<UnhoistIterator> |
419 | - <SingletonIterator value="xs:boolean(false)"/> |
420 | -</UnhoistIterator> |
421 | - |
422 | -Iterator tree for const-folded expr: |
423 | -<UnhoistIterator> |
424 | - <SingletonIterator value="xs:boolean(false)"/> |
425 | -</UnhoistIterator> |
426 | - |
427 | -Iterator tree for const-folded expr: |
428 | <UDFunctionCallIterator function="testlib:searchUser"> |
429 | <SingletonIterator value="xs:integer(0)"/> |
430 | </UDFunctionCallIterator> |
Validation queue starting for the following merge proposals: /code.launchpad .net/~zorba- coders/ zorba/markos- scratch/ +merge/ 185014
https:/
Progress dashboard at http:// jenkins. lambda. nu/view/ ValidationQueue