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
f1f41e51
Commit
f1f41e51
authored
Nov 09, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix automatic lock acquisition for inplace assignments
parent
097b08db
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
5 deletions
+31
-5
Cython/Compiler/CypclassTransforms.py
Cython/Compiler/CypclassTransforms.py
+30
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
No files found.
Cython/Compiler/CypclassTransforms.py
View file @
f1f41e51
...
...
@@ -438,6 +438,13 @@ class CypclassLockTransform(Visitor.EnvTransform):
return
obj
.
entry
return
None
def
is_locked
(
self
,
obj
):
try
:
lock
=
self
.
locked
[
self
.
id
(
obj
)]
return
True
except
:
return
False
def
lock
(
self
,
obj
,
exclusive
=
True
):
try
:
lock
=
self
.
locked
[
self
.
id
(
obj
)]
...
...
@@ -511,16 +518,18 @@ class CypclassLockTransform(Visitor.EnvTransform):
autolocks
=
self
.
autolocks
node
=
self
.
visit
(
node
)
if
self
.
autolocks
>
autolocks
:
self
.
autolocks
=
autolocks
return
node
.
coerce_to_temp
(
self
.
current_env
())
return
node
def
visit_assignment
(
self
,
node
):
def
visit_assignment
(
self
,
node
,
rhs_attr
=
'rhs'
):
autowlocks
=
self
.
autowlocks
self
.
visitchildren
(
node
,
exclude
=
[
'rhs'
])
self
.
visitchildren
(
node
,
exclude
=
[
rhs_attr
])
if
self
.
autowlocks
>
autowlocks
:
node
.
rhs
=
self
.
visit_value
(
node
.
rhs
)
self
.
autowlocks
=
autowlocks
setattr
(
node
,
rhs_attr
,
self
.
visit_value
(
getattr
(
node
,
rhs_attr
)))
else
:
node
.
rhs
=
self
.
visit
(
node
.
rhs
)
setattr
(
node
,
rhs_attr
,
self
.
visit
(
getattr
(
node
,
rhs_attr
))
)
def
visit_SingleAssignmentNode
(
self
,
node
):
lhs
=
node
.
lhs
...
...
@@ -544,6 +553,23 @@ class CypclassLockTransform(Visitor.EnvTransform):
self
.
visit_assignment
(
node
)
return
node
def
visit_BinopNode
(
self
,
node
):
if
node
.
inplace
:
if
not
node
.
operator
.
endswith
(
'='
):
# operand1 will already be evaluated as lhs of assignment node.
operand1
=
node
.
operand1
if
operand1
.
is_attribute
and
operand1
.
obj
.
type
.
is_cyp_class
and
not
self
.
is_locked
(
operand1
.
obj
):
node
.
operand2
=
self
.
visit_value
(
node
.
operand2
)
else
:
self
.
visitchildren
(
node
,
exclude
=
[
"operand1"
])
else
:
old
,
node
.
operand1
.
is_target
=
node
.
operand1
.
is_target
,
True
self
.
visit_assignment
(
node
,
rhs_attr
=
"operand2"
)
node
.
operand1
.
is_target
=
old
else
:
self
.
visitchildren
(
node
)
return
node
def
visit_DelStatNode
(
self
,
node
):
for
arg
in
node
.
args
:
arg_entry
=
self
.
id
(
arg
)
...
...
Cython/Compiler/ExprNodes.py
View file @
f1f41e51
...
...
@@ -11530,7 +11530,7 @@ class BinopNode(ExprNode):
# - Determine result type and result code fragment.
# - Allocate temporary for result if needed.
subexprs
=
[
'operand
1'
,
'operand2
'
]
subexprs
=
[
'operand
2'
,
'operand1
'
]
inplace
=
False
op_func_type
=
None
...
...
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