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
a505e7ef
Commit
a505e7ef
authored
Dec 08, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check isolation only for non-sendable cypclass fields
parent
f5984db3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+10
-7
Cython/Utility/CyObjects.cpp
Cython/Utility/CyObjects.cpp
+3
-3
No files found.
Cython/Compiler/ModuleNode.py
View file @
a505e7ef
...
...
@@ -975,9 +975,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
"""
scope
=
entry
.
type
.
scope
all_cypclass_attrs
=
[
e
for
e
in
scope
.
entries
.
values
()
if
e
.
type
.
is_cyp_class
and
not
e
.
name
==
"this"
and
not
e
.
is_type
]
check_cypclass_attrs
=
[
e
for
e
in
scope
.
entries
.
values
()
if
e
.
type
.
is_cyp_class
and
e
.
name
!=
"this"
and
not
e
.
is_type
and
not
e
.
type
.
is_qualified_cyp_class
]
# potential template
if
entry
.
type
.
templates
:
templates_code
=
"template <typename %s>"
%
", typename "
.
join
(
t
.
name
for
t
in
entry
.
type
.
templates
)
...
...
@@ -987,9 +990,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
namespace
=
entry
.
type
.
empty_declaration_code
()
if
templates_code
:
code
.
putln
(
templates_code
)
code
.
putln
(
"int %s::CyObject_traverse(void *(*visit)(const CyObject *o, void *arg), void *arg) const"
%
namespace
)
code
.
putln
(
"int %s::CyObject_traverse
_iso
(void *(*visit)(const CyObject *o, void *arg), void *arg) const"
%
namespace
)
code
.
putln
(
"{"
)
for
attr
in
all
_cypclass_attrs
:
for
attr
in
check
_cypclass_attrs
:
code
.
putln
(
"if (void *ret = visit(this->%s, arg)) return (int) (intptr_t) ret;"
%
attr
.
cname
)
code
.
putln
(
"return 0;"
)
code
.
putln
(
"}"
)
...
...
@@ -998,7 +1001,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
templates_code
)
code
.
putln
(
"int %s::CyObject_iso() const"
%
namespace
)
code
.
putln
(
"{"
)
if
all
_cypclass_attrs
:
if
check
_cypclass_attrs
:
code
.
putln
(
"return __Pyx_CyObject_owning(this) == 1;"
)
else
:
code
.
putln
(
"return this->CyObject_GETREF() == 1;"
)
...
...
@@ -1669,7 +1672,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# Declare the method to check isolation
code
.
putln
(
"virtual int CyObject_iso() const;"
)
# Declare the traverse method
code
.
putln
(
"virtual int CyObject_traverse(void *(*visit)(const CyObject *o, void *arg), void *arg) const;"
)
code
.
putln
(
"virtual int CyObject_traverse
_iso
(void *(*visit)(const CyObject *o, void *arg), void *arg) const;"
)
if
type
.
is_cyp_class
and
cypclass_attrs
:
# Declaring a small destruction handler which will always try to Cy_XDECREF
...
...
Cython/Utility/CyObjects.cpp
View file @
a505e7ef
...
...
@@ -94,7 +94,7 @@
virtual
int
CyObject_iso
()
const
{
return
this
->
nogil_ob_refcnt
==
1
;
}
virtual
int
CyObject_traverse
(
void
*
(
*
visit
)(
const
CyObject
*
o
,
void
*
arg
),
void
*
arg
)
const
{
virtual
int
CyObject_traverse
_iso
(
void
*
(
*
visit
)(
const
CyObject
*
o
,
void
*
arg
),
void
*
arg
)
const
{
return
0
;
}
...
...
@@ -524,11 +524,11 @@
root
->
__refcnt
=
root
->
CyObject_GETREF
();
/* Collect the reachable objects */
for
(
current
=
root
;
current
!=
NULL
;
current
=
current
->
__next
)
{
current
->
CyObject_traverse
(
__Pyx_CyObject_visit_collect
,
(
void
*
)
current
);
current
->
CyObject_traverse
_iso
(
__Pyx_CyObject_visit_collect
,
(
void
*
)
current
);
}
/* Decref the reachable objects */
for
(
current
=
root
;
current
!=
NULL
;
current
=
current
->
__next
)
{
current
->
CyObject_traverse
(
__Pyx_CyObject_visit_decref
,
(
void
*
)
current
);
current
->
CyObject_traverse
_iso
(
__Pyx_CyObject_visit_decref
,
(
void
*
)
current
);
}
/* Search for externally reachable object */
for
(
current
=
root
->
__next
;
current
!=
NULL
;
current
=
current
->
__next
)
{
...
...
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