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
71b2fa6b
Commit
71b2fa6b
authored
Nov 04, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coming along
parent
da6f4229
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
6 deletions
+58
-6
src/core/types.h
src/core/types.h
+3
-0
src/runtime/str.cpp
src/runtime/str.cpp
+10
-0
src/runtime/types.cpp
src/runtime/types.cpp
+45
-6
No files found.
src/core/types.h
View file @
71b2fa6b
...
...
@@ -647,6 +647,9 @@ public:
this
->
setattr
(
attr
,
val
,
NULL
);
}
// for debugging mostly:
void
clearAttrs
();
// getattr() does the equivalent of PyDict_GetItem(obj->dict, attr): it looks up the attribute's value on the
// object's attribute storage. it doesn't look at other objects or do any descriptor logic.
template
<
Rewritable
rewritable
=
REWRITABLE
>
...
...
src/runtime/str.cpp
View file @
71b2fa6b
...
...
@@ -395,11 +395,21 @@ extern "C" void PyString_InternInPlace(PyObject** p) noexcept {
num_interned_strings
.
log
();
entry
=
(
BoxedString
*
)
PyGC_AddRoot
(
s
);
Py_INCREF
(
s
);
// CPython returns mortal but in our current implementation they are inmortal
s
->
interned_state
=
SSTATE_INTERNED_IMMORTAL
;
}
}
extern
"C"
void
_Py_ReleaseInternedStrings
()
noexcept
{
//printf("%ld interned strings\n", interned_strings.size());
for
(
const
auto
&
p
:
interned_strings
)
{
Py_DECREF
(
p
.
second
);
}
interned_strings
.
clear
();
}
extern
"C"
int
_PyString_CheckInterned
(
PyObject
*
p
)
noexcept
{
RELEASE_ASSERT
(
PyString_Check
(
p
),
""
);
BoxedString
*
s
=
(
BoxedString
*
)
p
;
...
...
src/runtime/types.cpp
View file @
71b2fa6b
...
...
@@ -3609,6 +3609,39 @@ 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
];
PyDict_Clear
(
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
);
return
;
}
if
(
cls
->
instancesHaveDictAttrs
())
{
BoxedDict
*
d
=
getDict
();
PyDict_Clear
(
d
);
return
;
}
}
#ifndef Py_REF_DEBUG
#define PRINT_TOTAL_REFS()
#else
/* Py_REF_DEBUG */
#define PRINT_TOTAL_REFS() fprintf(stderr, "[%" PY_FORMAT_SIZE_T "d refs]\n", _Py_GetRefTotal())
#endif
bool
TRACK_ALLOCATIONS
=
false
;
void
setupRuntime
()
{
...
...
@@ -3666,6 +3699,18 @@ void setupRuntime() {
none_cls
->
giveAttr
(
"__base__"
,
object_cls
);
object_cls
->
giveAttr
(
"__base__"
,
None
);
auto
classes
=
{
type_cls
,
object_cls
,
none_cls
,
str_cls
,
basestring_cls
};
_Py_ReleaseInternedStrings
();
for
(
auto
b
:
classes
)
b
->
clearAttrs
();
for
(
auto
b
:
{
None
})
Py_DECREF
(
b
);
for
(
auto
b
:
classes
)
Py_DECREF
(
b
);
// XXX
PRINT_TOTAL_REFS
();
exit
(
0
);
// Not sure why CPython defines sizeof(PyTupleObject) to include one element,
// but we copy that, which means we have to subtract that extra pointer to get the tp_basicsize:
...
...
@@ -4188,12 +4233,6 @@ static void call_sys_exitfunc(void) {
PyErr_Clear
();
}
#ifndef Py_REF_DEBUG
#define PRINT_TOTAL_REFS()
#else
/* Py_REF_DEBUG */
#define PRINT_TOTAL_REFS() fprintf(stderr, "[%" PY_FORMAT_SIZE_T "d refs]\n", _Py_GetRefTotal())
#endif
extern
"C"
void
Py_Finalize
()
noexcept
{
// In the future this will have to wait for non-daemon
// threads to finish
...
...
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