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
0b3ebad3
Commit
0b3ebad3
authored
Nov 18, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ok, gc is clearing most things now
parent
437a1468
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
15 deletions
+43
-15
from_cpython/Include/Python.h
from_cpython/Include/Python.h
+6
-0
from_cpython/Objects/exceptions.c
from_cpython/Objects/exceptions.c
+4
-0
src/core/types.h
src/core/types.h
+1
-0
src/runtime/types.cpp
src/runtime/types.cpp
+32
-15
No files found.
from_cpython/Include/Python.h
View file @
0b3ebad3
...
...
@@ -119,6 +119,8 @@ PyAPI_FUNC(void) PyType_GiveHcAttrsDictDescr(PyTypeObject*) PYSTON_NOEXCEPT;
PyAPI_FUNC
(
PyObject
*
)
PyObject_GetHcAttrString
(
PyObject
*
,
const
char
*
)
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
int
)
PyObject_SetHcAttrString
(
PyObject
*
,
const
char
*
,
PyObject
*
)
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
int
)
PyObject_DelHcAttrString
(
PyObject
*
,
const
char
*
)
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
int
)
PyObject_ClearHcAttrs
(
PyHcAttrs
*
)
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
int
)
PyObject_TraverseHcAttrs
(
PyHcAttrs
*
,
visitproc
visit
,
void
*
arg
)
PYSTON_NOEXCEPT
;
// Workaround: call this instead of setting tp_dict.
PyAPI_FUNC
(
void
)
PyType_SetDict
(
PyTypeObject
*
,
PyObject
*
)
PYSTON_NOEXCEPT
;
...
...
@@ -128,6 +130,10 @@ PyAPI_FUNC(void) PyType_SetDict(PyTypeObject*, PyObject*) PYSTON_NOEXCEPT;
// PyType_Ready calls this automatically.
PyAPI_FUNC
(
void
)
PyGC_RegisterStaticConstant
(
PyObject
*
)
PYSTON_NOEXCEPT
;
// Pyston addition:
PyAPI_FUNC
(
void
)
PyGC_Enable
()
PYSTON_NOEXCEPT
;
PyAPI_FUNC
(
void
)
PyGC_Disable
()
PYSTON_NOEXCEPT
;
#include "codecs.h"
#include "pyerrors.h"
...
...
from_cpython/Objects/exceptions.c
View file @
0b3ebad3
...
...
@@ -117,6 +117,7 @@ BaseException_clear(PyBaseExceptionObject *self)
{
// Pyston change:
// Py_CLEAR(self->dict);
PyObject_ClearHcAttrs
(
&
self
->
hcattrs
);
Py_CLEAR
(
self
->
args
);
Py_CLEAR
(
self
->
message
);
return
0
;
...
...
@@ -135,6 +136,9 @@ BaseException_traverse(PyBaseExceptionObject *self, visitproc visit, void *arg)
{
// Pyston change:
// Py_VISIT(self->dict);
int
vret
=
PyObject_TraverseHcAttrs
(
&
self
->
hcattrs
,
visit
,
arg
);
if
(
vret
)
return
vret
;
Py_VISIT
(
self
->
args
);
Py_VISIT
(
self
->
message
);
return
0
;
...
...
src/core/types.h
View file @
0b3ebad3
...
...
@@ -592,6 +592,7 @@ public:
HCAttrs
(
HiddenClass
*
hcls
=
root_hcls
)
:
hcls
(
hcls
),
attr_list
(
nullptr
)
{}
int
traverse
(
visitproc
visit
,
void
*
arg
)
noexcept
;
void
clear
()
noexcept
;
};
static_assert
(
sizeof
(
HCAttrs
)
==
sizeof
(
struct
_hcattrs
),
""
);
...
...
src/runtime/types.cpp
View file @
0b3ebad3
...
...
@@ -3085,10 +3085,12 @@ extern "C" void PyObject_InitHcAttrs(HCAttrs* attrs) noexcept {
extern
"C"
PyObject
*
PyObject_GetHcAttrString
(
PyObject
*
obj
,
const
char
*
attr
)
PYSTON_NOEXCEPT
{
return
obj
->
getattr
(
internStringMortal
(
attr
));
}
extern
"C"
int
PyObject_SetHcAttrString
(
PyObject
*
obj
,
const
char
*
attr
,
PyObject
*
val
)
PYSTON_NOEXCEPT
{
obj
->
setattr
(
internStringMortal
(
attr
),
val
,
NULL
);
return
0
;
}
extern
"C"
int
PyObject_DelHcAttrString
(
PyObject
*
obj
,
const
char
*
attr
)
PYSTON_NOEXCEPT
{
BoxedString
*
attr_str
=
internStringMortal
(
attr
);
bool
has
=
obj
->
hasattr
(
attr_str
);
...
...
@@ -3098,6 +3100,15 @@ extern "C" int PyObject_DelHcAttrString(PyObject* obj, const char* attr) PYSTON_
return
0
;
}
extern
"C"
int
PyObject_ClearHcAttrs
(
HCAttrs
*
attrs
)
noexcept
{
attrs
->
clear
();
return
0
;
}
extern
"C"
int
PyObject_TraverseHcAttrs
(
HCAttrs
*
attrs
,
visitproc
visit
,
void
*
arg
)
noexcept
{
return
attrs
->
traverse
(
visit
,
arg
);
}
extern
"C"
PyVarObject
*
PyObject_InitVar
(
PyVarObject
*
op
,
PyTypeObject
*
tp
,
Py_ssize_t
size
)
noexcept
{
assert
(
op
);
assert
(
tp
);
...
...
@@ -3320,20 +3331,7 @@ static Box* getsetDelete(Box* self, Box* obj) {
void
Box
::
clearAttrs
()
{
if
(
cls
->
instancesHaveHCAttrs
())
{
HCAttrs
*
attrs
=
getHCAttrsPtr
();
HiddenClass
*
hcls
=
attrs
->
hcls
;
if
(
unlikely
(
hcls
->
type
==
HiddenClass
::
DICT_BACKED
))
{
Box
*
d
=
attrs
->
attr_list
->
attrs
[
0
];
Py_DECREF
(
d
);
return
;
}
assert
(
hcls
->
type
==
HiddenClass
::
NORMAL
||
hcls
->
type
==
HiddenClass
::
SINGLETON
);
for
(
int
i
=
0
;
i
<
hcls
->
attributeArraySize
();
i
++
)
{
Py_DECREF
(
attrs
->
attr_list
->
attrs
[
i
]);
}
new
((
void
*
)
attrs
)
HCAttrs
(
root_hcls
);
attrs
->
clear
();
return
;
}
...
...
@@ -3344,6 +3342,23 @@ void Box::clearAttrs() {
}
}
void
HCAttrs
::
clear
()
noexcept
{
HiddenClass
*
hcls
=
this
->
hcls
;
if
(
unlikely
(
hcls
->
type
==
HiddenClass
::
DICT_BACKED
))
{
Box
*
d
=
this
->
attr_list
->
attrs
[
0
];
Py_DECREF
(
d
);
return
;
}
assert
(
hcls
->
type
==
HiddenClass
::
NORMAL
||
hcls
->
type
==
HiddenClass
::
SINGLETON
);
for
(
int
i
=
0
;
i
<
hcls
->
attributeArraySize
();
i
++
)
{
Py_DECREF
(
this
->
attr_list
->
attrs
[
i
]);
}
new
((
void
*
)
this
)
HCAttrs
(
root_hcls
);
}
static
void
tupledealloc
(
PyTupleObject
*
op
)
noexcept
{
Py_ssize_t
i
;
Py_ssize_t
len
=
Py_SIZE
(
op
);
...
...
@@ -4127,7 +4142,9 @@ void setupRuntime() {
for
(
auto
b
:
classes
)
{
Py_DECREF
(
b
);
}
PyGC_Collect
();
// May need to run multiple collections to collect everything:
while
(
PyGC_Collect
())
;
PRINT_TOTAL_REFS
();
exit
(
0
);
// XXX
...
...
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