Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
d7490eda
Commit
d7490eda
authored
Nov 18, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GC handling pretty much everything it can
parent
f2c88c16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
+19
-6
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+3
-0
src/runtime/types.cpp
src/runtime/types.cpp
+16
-6
No files found.
src/runtime/objmodel.cpp
View file @
d7490eda
...
...
@@ -5659,6 +5659,7 @@ void Box::delattr(BoxedString* attr, DelattrRewriteArgs* rewrite_args) {
// of remaining attributes
int
num_attrs
=
hcls
->
attributeArraySize
();
int
offset
=
hcls
->
getOffset
(
attr
);
Box
*
removed_object
=
attrs
->
attr_list
->
attrs
[
offset
];
assert
(
offset
>=
0
);
Box
**
start
=
attrs
->
attr_list
->
attrs
;
memmove
(
start
+
offset
,
start
+
offset
+
1
,
(
num_attrs
-
offset
-
1
)
*
sizeof
(
Box
*
));
...
...
@@ -5674,6 +5675,8 @@ void Box::delattr(BoxedString* attr, DelattrRewriteArgs* rewrite_args) {
// guarantee the size of the attr_list equals the number of attrs
int
new_size
=
sizeof
(
HCAttrs
::
AttrList
)
+
sizeof
(
Box
*
)
*
(
num_attrs
-
1
);
attrs
->
attr_list
=
(
HCAttrs
::
AttrList
*
)
PyMem_REALLOC
(
attrs
->
attr_list
,
new_size
);
Py_DECREF
(
removed_object
);
return
;
}
...
...
src/runtime/types.cpp
View file @
d7490eda
...
...
@@ -2375,20 +2375,24 @@ public:
return
rtn
;
}
static
Box
*
clear
(
Box
*
_self
)
{
static
void
_
clear
(
Box
*
_self
)
{
RELEASE_ASSERT
(
_self
->
cls
==
attrwrapper_cls
,
""
);
AttrWrapper
*
self
=
static_cast
<
AttrWrapper
*>
(
_self
);
HCAttrs
*
attrs
=
self
->
b
->
getHCAttrsPtr
();
RELEASE_ASSERT
(
attrs
->
hcls
->
type
==
HiddenClass
::
NORMAL
||
attrs
->
hcls
->
type
==
HiddenClass
::
SINGLETON
,
""
);
attrs
->
clear
();
// Clear the attrs array:
new
((
void
*
)
attrs
)
HCAttrs
(
root_hcls
);
// Add the existing attrwrapper object (ie self) back as the attrwrapper:
self
->
b
->
appendNewHCAttr
(
self
,
NULL
);
attrs
->
hcls
=
attrs
->
hcls
->
getAttrwrapperChild
();
}
return
None
;
static
Box
*
clear
(
Box
*
_self
)
{
RELEASE_ASSERT
(
_self
->
cls
==
attrwrapper_cls
,
""
);
_clear
(
_self
);
Py_RETURN_NONE
;
}
static
Box
*
len
(
Box
*
_self
)
{
...
...
@@ -2561,7 +2565,7 @@ void attrwrapperDel(Box* b, llvm::StringRef attr) {
}
void
attrwrapperClear
(
Box
*
aw
)
{
AttrWrapper
::
clear
(
aw
);
AttrWrapper
::
_
clear
(
aw
);
}
BoxedDict
*
attrwrapperToDict
(
Box
*
b
)
{
...
...
@@ -3353,9 +3357,11 @@ void HCAttrs::clear() noexcept {
assert
(
hcls
->
type
==
HiddenClass
::
NORMAL
||
hcls
->
type
==
HiddenClass
::
SINGLETON
);
// TODO: should swap in the new HCAttrs before doing any decrefs.
for
(
int
i
=
0
;
i
<
hcls
->
attributeArraySize
();
i
++
)
{
Py_DECREF
(
this
->
attr_list
->
attrs
[
i
]);
}
// TODO need to free the attrs memory
new
((
void
*
)
this
)
HCAttrs
(
root_hcls
);
}
...
...
@@ -3522,6 +3528,8 @@ type_traverse(PyTypeObject *type, visitproc visit, void *arg)
// Pyston change: HEAPTYPE is not about whether it is in GC or not
// assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE);
Py_VISIT_HCATTRS
(
type
->
attrs
);
Py_VISIT
(
type
->
tp_dict
);
Py_VISIT
(
type
->
tp_cache
);
Py_VISIT
(
type
->
tp_mro
);
...
...
@@ -3573,6 +3581,8 @@ type_clear(PyTypeObject *type)
PyType_Modified
(
type
);
if
(
type
->
tp_dict
)
PyDict_Clear
(
type
->
tp_dict
);
type
->
attrs
.
clear
();
Py_CLEAR
(
type
->
tp_dict
);
Py_CLEAR
(
type
->
tp_mro
);
return
0
;
...
...
@@ -4146,8 +4156,8 @@ void setupRuntime() {
_Py_ReleaseInternedStrings
();
_PyUnicode_Fini
();
for
(
auto
b
:
classes
)
{
b
->
clearAttrs
();
if
(
!
PyObject_IS_GC
(
b
))
{
b
->
clearAttrs
();
Py_CLEAR
(
b
->
tp_mro
);
}
}
...
...
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