Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xavier Thompson
cython
Commits
8400bc24
Commit
8400bc24
authored
Jul 03, 2019
by
gsamain
Committed by
Xavier Thompson
Jun 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change strategy for outer variables: lock them at the beginning, unlock at the end
parent
108d4195
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
18 deletions
+15
-18
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+5
-17
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+10
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
8400bc24
...
...
@@ -319,7 +319,7 @@ class ExprNode(Node):
result_is_used
=
True
is_numpy_attribute
=
False
tracked_state
=
None
was_locked
=
Tru
e
was_locked
=
Fals
e
# The Analyse Expressions phase for expressions is split
# into two sub-phases:
...
...
@@ -758,6 +758,8 @@ class ExprNode(Node):
self
.
tracked_state
=
env
.
lookup_tracked
(
self
.
entry
)
if
self
.
tracked_state
is
None
:
self
.
tracked_state
=
env
.
declare_tracked
(
self
.
entry
)
if
self
.
is_autolock
()
and
self
.
entry
.
is_variable
:
env
.
declare_autolocked
(
self
)
self
.
was_locked
=
self
.
tracked_state
.
was_locked
self
.
tracked_state
.
was_locked
=
True
...
...
@@ -802,7 +804,8 @@ class ExprNode(Node):
if
not
self
.
tracked_state
:
self
.
get_tracked_state
(
env
)
if
self
.
is_autolock
()
and
is_top_lhs
:
env
.
declare_autolocked
(
self
)
#env.declare_autolocked(self)
self
.
tracked_as_lhs
=
True
if
is_dereferenced
and
self
.
tracked_state
:
if
not
self
.
is_lhs_locked
(
env
):
if
self
.
is_checklock
():
...
...
@@ -2416,12 +2419,6 @@ class NameNode(AtomicExprNode):
elif
entry
.
type
.
is_cyp_class
:
code
.
put_cygotref
(
self
.
result
())
if
not
self
.
was_locked
and
self
.
is_autolock
():
tracked_state
=
self
.
tracked_state
if
tracked_state
.
needs_wlock
:
code
.
putln
(
"Cy_WLOCK(%s);"
%
self
.
result
())
elif
tracked_state
.
needs_rlock
:
code
.
putln
(
"Cy_RLOCK(%s);"
%
self
.
result
())
#pass
# code.putln(entry.cname)
elif
entry
.
is_local
or
entry
.
in_closure
or
entry
.
from_closure
or
entry
.
type
.
is_memoryviewslice
:
...
...
@@ -7560,12 +7557,6 @@ class AttributeNode(ExprNode):
'"Memoryview is not initialized");'
'%s'
'}'
%
(
self
.
result
(),
code
.
error_goto
(
self
.
pos
)))
elif
self
.
is_autolock
():
if
not
self
.
was_locked
:
if
self
.
tracked_state
.
needs_wlock
:
code
.
putln
(
"Cy_WLOCK(%s);"
%
self
.
result
())
elif
self
.
tracked_state
.
needs_rlock
:
code
.
putln
(
"Cy_RLOCK(%s);"
%
self
.
result
())
else
:
# result_code contains what is needed, but we may need to insert
# a check and raise an exception
...
...
@@ -7580,9 +7571,6 @@ class AttributeNode(ExprNode):
# mirror condition for putting the memview incref here:
code
.
put_xdecref_clear
(
self
.
result
(),
self
.
type
,
have_gil
=
True
)
else
:
if
self
.
is_temp
and
self
.
type
.
is_cyp_class
and
self
.
is_autolock
()
\
and
self
.
tracked_state
and
(
tracked_state
.
needs_rlock
or
tracked_state
.
needs_wlock
):
code
.
putln
(
"Cy_UNLOCK(%s);"
%
self
.
result
())
ExprNode
.
generate_disposal_code
(
self
,
code
)
def
generate_assignment_code
(
self
,
rhs
,
code
,
overloaded_assignment
=
False
,
...
...
Cython/Compiler/Nodes.py
View file @
8400bc24
...
...
@@ -2045,6 +2045,15 @@ class FuncDefNode(StatNode, BlockNode):
code
.
put_release_ensured_gil
()
code
.
funcstate
.
gil_owned
=
False
for
node
in
lenv
.
autolocked_nodes
:
if
node
.
entry
.
is_variable
and
not
node
.
entry
.
is_local
and
(
node
.
tracked_state
.
needs_wlock
or
node
.
tracked_state
.
needs_rlock
):
node_result
=
node
.
result
()
code
.
putln
(
"if (%s != NULL)"
%
node_result
)
if
node
.
needs_wlock
():
code
.
putln
(
" Cy_WLOCK(%s);"
%
node_result
)
elif
node
.
needs_rlock
():
code
.
putln
(
" Cy_RLOCK(%s);"
%
node_result
)
# -------------------------
# ----- Function body -----
# -------------------------
...
...
@@ -2214,7 +2223,7 @@ class FuncDefNode(StatNode, BlockNode):
# which leads to a dangling lock on the previous reference
# (and attempt to unlock a non-locked ref).
if
not
node
.
was_locked
and
(
node
.
tracked_state
.
needs_wlock
or
node
.
tracked_state
.
needs_rlock
):
if
not
node
.
get_was_locked
()
and
(
node
.
tracked_state
.
needs_wlock
or
node
.
tracked_state
.
needs_rlock
):
code
.
putln
(
"Cy_UNLOCK(%s);"
%
node
.
result
())
for
entry
in
lenv
.
var_entries
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment