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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
2575a500
Commit
2575a500
authored
Nov 03, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid unnecessary reference counting around locks
parent
a80ce036
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+15
-6
No files found.
Cython/Compiler/ExprNodes.py
View file @
2575a500
...
...
@@ -14262,14 +14262,19 @@ class CoerceToTempNode(CoercionNode):
class
CoerceToLockedNode
(
CoercionNode
):
# This node is used to lock a node of cypclass type around the evaluation of its subexpressions.
# exclusive boolean
# exclusive boolean
# needs_decref boolean used internally
def
__init__
(
self
,
arg
,
env
=
None
,
exclusive
=
True
):
self
.
exclusive
=
exclusive
self
.
type
=
arg
.
type
arg
=
arg
.
coerce_to_temp
(
env
)
arg
.
postpone_subexpr_disposal
=
True
super
(
CoerceToLockedNode
,
self
).
__init__
(
arg
)
temp_arg
=
arg
.
coerce_to_temp
(
env
)
temp_arg
.
postpone_subexpr_disposal
=
True
# Avoid incrementing the reference count when assigning to the temporary
# but ensure it will be decremented if it was already incremented previously.
self
.
needs_decref
=
not
temp_arg
.
use_managed_ref
temp_arg
.
use_managed_ref
=
False
super
(
CoerceToLockedNode
,
self
).
__init__
(
temp_arg
)
def
result
(
self
):
return
self
.
arg
.
result
()
...
...
@@ -14307,8 +14312,12 @@ class CoerceToLockedNode(CoercionNode):
def
generate_disposal_code
(
self
,
code
):
# Close the scope to release the lock.
code
.
putln
(
"}"
)
# Dispose of subexpressions.
super
(
CoerceToLockedNode
,
self
).
generate_disposal_code
(
code
)
# Dispose of and free subexpressions.
self
.
arg
.
generate_subexpr_disposal_code
(
code
)
self
.
arg
.
free_subexpr_temps
(
code
)
# Decref only if previously incref-ed.
if
self
.
needs_decref
:
code
.
put_xdecref_clear
(
self
.
result
(),
self
.
ctype
(),
have_gil
=
not
self
.
in_nogil_context
)
class
ProxyNode
(
CoercionNode
):
...
...
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