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
b9ed25a8
Commit
b9ed25a8
authored
Nov 12, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
list dealloc
parent
b6df2364
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
5 deletions
+56
-5
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+1
-1
src/runtime/types.cpp
src/runtime/types.cpp
+54
-4
src/runtime/types.h
src/runtime/types.h
+1
-0
No files found.
src/capi/typeobject.cpp
View file @
b9ed25a8
...
...
@@ -2077,7 +2077,7 @@ static void add_tp_new_wrapper(BoxedClass* type) noexcept {
if
(
type
->
getattr
(
new_str
))
return
;
type
->
giveAttr
(
new_str
,
new
BoxedCApiFunction
(
tp_new_methoddef
,
type
));
type
->
giveAttr
(
incref
(
new_str
)
,
new
BoxedCApiFunction
(
tp_new_methoddef
,
type
));
}
void
add_operators
(
BoxedClass
*
cls
)
noexcept
{
...
...
src/runtime/types.cpp
View file @
b9ed25a8
...
...
@@ -3678,13 +3678,62 @@ void BoxedModule::dealloc(Box* b) noexcept {
self
->
clearAttrs
();
}
void
BoxedList
::
dealloc
(
Box
*
b
)
noexcept
{
BoxedList
*
op
=
static_cast
<
BoxedList
*>
(
b
);
Py_ssize_t
i
;
PyObject_GC_UnTrack
(
op
);
Py_TRASHCAN_SAFE_BEGIN
(
op
)
if
(
op
->
elts
!=
NULL
)
{
/* Do it backwards, for Christian Tismer.
There's a simple test case where somehow this reduces
thrashing when a *very* large list is created and
immediately deleted. */
i
=
Py_SIZE
(
op
);
while
(
--
i
>=
0
)
{
Py_XDECREF
(
op
->
elts
->
elts
[
i
]);
}
PyMem_FREE
(
op
->
elts
);
}
#if 0
if (numfree < PyList_MAXFREELIST && PyList_CheckExact(op))
free_list[numfree++] = op;
else
#endif
Py_TYPE
(
op
)
->
tp_free
((
PyObject
*
)
op
);
Py_TRASHCAN_SAFE_END
(
op
)
}
void
BoxedClass
::
dealloc
(
Box
*
b
)
noexcept
{
BoxedClass
*
self
=
static_cast
<
BoxedClass
*>
(
b
);
BoxedClass
*
type
=
static_cast
<
BoxedClass
*>
(
b
);
self
->
clearAttrs
();
Py_XDECREF
(
self
->
tp_dict
);
type
->
clearAttrs
();
// XXX: need to import cpython's type_dealloc
Py_XDECREF
(
type
->
tp_dict
);
Py_XDECREF
(
type
->
tp_bases
);
Py_XDECREF
(
type
->
tp_subclasses
);
//Py_XDECREF(type->tp_mro); // XXX was done manually
#if 0
/* Assert this is a heap-allocated type object */
assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE);
_PyObject_GC_UNTRACK(type);
PyObject_ClearWeakRefs((PyObject *)type);
BoxedHeapClass* et = (BoxedHeapClass *)type;
Py_XDECREF(type->tp_base);
Py_XDECREF(type->tp_dict);
Py_XDECREF(type->tp_bases);
Py_XDECREF(type->tp_mro);
Py_XDECREF(type->tp_cache);
Py_XDECREF(type->tp_subclasses);
/* A type's tp_doc is heap allocated, unlike the tp_doc slots
* of most other objects. It's okay to cast it to char *.
*/
PyObject_Free((char *)type->tp_doc);
Py_XDECREF(et->ht_name);
Py_XDECREF(et->ht_slots);
Py_TYPE(type)->tp_free((PyObject *)type);
#endif
}
...
...
@@ -3773,6 +3822,7 @@ void setupRuntime() {
gc
::
registerPermanentRoot
(
EmptyTuple
);
list_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
&
BoxedList
::
gcHandler
,
0
,
0
,
sizeof
(
BoxedList
),
false
,
"list"
);
list_cls
->
tp_flags
|=
Py_TPFLAGS_LIST_SUBCLASS
;
list_cls
->
tp_dealloc
=
BoxedList
::
dealloc
;
pyston_getset_cls
=
new
(
0
)
BoxedClass
(
object_cls
,
NULL
,
0
,
0
,
sizeof
(
BoxedGetsetDescriptor
),
false
,
"getset_descriptor"
);
attrwrapper_cls
=
new
(
0
)
...
...
src/runtime/types.h
View file @
b9ed25a8
...
...
@@ -539,6 +539,7 @@ public:
DEFAULT_CLASS_SIMPLE
(
list_cls
);
static
void
gcHandler
(
GCVisitor
*
v
,
Box
*
b
);
static
void
dealloc
(
Box
*
self
)
noexcept
;
};
static_assert
(
sizeof
(
BoxedList
)
<=
sizeof
(
PyListObject
),
""
);
static_assert
(
sizeof
(
BoxedList
)
>=
sizeof
(
PyListObject
),
""
);
...
...
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