Merge lp:~zorba-coders/zorba/no-copy into lp:zorba

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 11080
Merged at revision: 11087
Proposed branch: lp:~zorba-coders/zorba/no-copy
Merge into: lp:zorba
Diff against target: 129 lines (+19/-76)
3 files modified
src/compiler/rewriter/rules/nodeid_rules.cpp (+19/-40)
test/rbkt/ExpQueryResults/zorba/eval/eval13.xml.res (+0/-2)
test/rbkt/Queries/zorba/eval/eval13.xq (+0/-34)
To merge this branch: bzr merge lp:~zorba-coders/zorba/no-copy
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+127764@code.launchpad.net

Commit message

1. The target expr of insert and rename exprs is unsafe only if it returns a shared node
2. block expr is safe

Description of the change

1. the target expr of insert and rename exprs is unsafe only if it returns a shared node
2. block expr is safe

To post a comment you must log in.
lp:~zorba-coders/zorba/no-copy updated
11079. By Markos Zaharioudakis

block expr is safe

11080. By Markos Zaharioudakis

merge from trunk

Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job no-copy-2012-10-04T11-42-43.984Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/compiler/rewriter/rules/nodeid_rules.cpp'
2--- src/compiler/rewriter/rules/nodeid_rules.cpp 2012-10-03 13:10:43 +0000
3+++ src/compiler/rewriter/rules/nodeid_rules.cpp 2012-10-04 11:36:24 +0000
4@@ -868,16 +868,30 @@
5 case replace_expr_kind:
6 {
7 update_expr_base* e = static_cast<update_expr_base*>(node);
8+ expr_kind_t kind = e->get_expr_kind();
9
10- std::vector<expr*> sources;
11- theSourceFinder->findNodeSources(e->getTargetExpr(), &udfCaller, sources);
12- markSources(sources);
13+ // The target node cannot be a shared node because the update would be seen
14+ // by multiple trees. For updates that delete nodes (delete and replace), the
15+ // whole tree must be standalone because we have to sum up the reference
16+ // counts of all the nodes in the delete subtree and that won't work if the
17+ // deleted subtree contains shared nodes.
18+ if (kind == replace_expr_kind || kind == delete_expr_kind)
19+ {
20+ std::vector<expr*> sources;
21+ theSourceFinder->findNodeSources(e->getTargetExpr(), &udfCaller, sources);
22+ markSources(sources);
23+ }
24+ else
25+ {
26+ markInUnsafeContext(node);
27+ }
28
29 static_context* sctx = e->get_sctx();
30
31+ // TODO: apply no-copy rule to insert and replace updates
32 if (e->getSourceExpr() != NULL &&
33- (e->get_expr_kind() == insert_expr_kind ||
34- (e->get_expr_kind() == replace_expr_kind &&
35+ (kind == insert_expr_kind ||
36+ (kind == replace_expr_kind &&
37 static_cast<replace_expr*>(e)->getType() == store::UpdateConsts::NODE)) &&
38 sctx->inherit_ns() &&
39 sctx->preserve_ns())
40@@ -919,43 +933,8 @@
41 case flowctl_expr_kind:
42 case exit_expr_kind:
43 case exit_catcher_expr_kind:
44- {
45- break;
46- }
47-
48 case block_expr_kind:
49 {
50- block_expr* e = static_cast<block_expr *>(node);
51-
52- if (e->is_sequential())
53- {
54- csize numChildren = e->size();
55- bool haveUpdates = false;
56-
57- for (csize i = numChildren; i > 0; --i)
58- {
59- expr* child = (*e)[i-1];
60-
61- if (haveUpdates)
62- {
63- std::vector<expr*> sources;
64- theSourceFinder->findNodeSources(child, &udfCaller, sources);
65- markSources(sources);
66- }
67- else
68- {
69- short scriptingKind = child->get_scripting_detail();
70-
71- if (scriptingKind & APPLYING_EXPR ||
72- scriptingKind & EXITING_EXPR ||
73- scriptingKind & SEQUENTIAL_FUNC_EXPR)
74- {
75- haveUpdates = true;
76- }
77- }
78- }
79- }
80-
81 break;
82 }
83
84
85=== removed file 'test/rbkt/ExpQueryResults/zorba/eval/eval13.xml.res'
86--- test/rbkt/ExpQueryResults/zorba/eval/eval13.xml.res 2012-03-05 13:31:47 +0000
87+++ test/rbkt/ExpQueryResults/zorba/eval/eval13.xml.res 1970-01-01 00:00:00 +0000
88@@ -1,2 +0,0 @@
89-<?xml version="1.0" encoding="UTF-8"?>
90-<root><a><b><c/></b></a></root><root><a><b><c/></b></a></root><a><b><c/></b></a><b><c/></b>
91
92=== removed file 'test/rbkt/Queries/zorba/eval/eval13.xq'
93--- test/rbkt/Queries/zorba/eval/eval13.xq 2012-03-05 13:31:47 +0000
94+++ test/rbkt/Queries/zorba/eval/eval13.xq 1970-01-01 00:00:00 +0000
95@@ -1,34 +0,0 @@
96-import module namespace refl = "http://www.zorba-xquery.com/modules/reflection";
97-
98-
99-declare function local:dummy($n as node())
100-{
101-};
102-
103-
104-declare function local:foo($n as node()) as node()*
105-{
106- local:dummy($n),
107- $n/ancestor::node()
108-};
109-
110-
111-declare function local:constr($n as node()) as node()*
112-{
113- local:dummy($n),
114- <root>{$n}</root>
115-};
116-
117-
118-declare variable $doc :=
119-<a>
120- <b>
121- <c/>
122- </b>
123-</a>
124-;
125-
126-
127-local:constr($doc)
128-,
129-refl:eval("local:foo(local:constr($doc)//c)")

Subscribers

People subscribed via source and target branches