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
448680a3
Commit
448680a3
authored
Feb 10, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Free instance attributes
parent
cf3ae02d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
src/core/types.h
src/core/types.h
+2
-2
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+7
-2
No files found.
src/core/types.h
View file @
448680a3
...
@@ -634,7 +634,7 @@ private:
...
@@ -634,7 +634,7 @@ private:
BoxedDict
**
getDictPtr
();
BoxedDict
**
getDictPtr
();
// Appends a new value to the hcattrs array.
// Appends a new value to the hcattrs array.
void
appendNewHCAttr
(
B
ox
*
val
,
SetattrRewriteArgs
*
rewrite_args
);
void
appendNewHCAttr
(
B
ORROWED
(
Box
*
)
val
,
SetattrRewriteArgs
*
rewrite_args
);
public:
public:
// Add a no-op constructor to make sure that we don't zero-initialize cls
// Add a no-op constructor to make sure that we don't zero-initialize cls
...
@@ -660,7 +660,7 @@ public:
...
@@ -660,7 +660,7 @@ public:
// Note, setattr does *not* steal a reference, but it probably should
// Note, setattr does *not* steal a reference, but it probably should
void
setattr
(
BoxedString
*
attr
,
B
ox
*
val
,
SetattrRewriteArgs
*
rewrite_args
);
void
setattr
(
BoxedString
*
attr
,
B
ORROWED
(
Box
*
)
val
,
SetattrRewriteArgs
*
rewrite_args
);
// giveAttr consumes a reference to val and attr
// giveAttr consumes a reference to val and attr
void
giveAttr
(
const
char
*
attr
,
Box
*
val
)
{
giveAttr
(
internStringMortal
(
attr
),
val
);
}
void
giveAttr
(
const
char
*
attr
,
Box
*
val
)
{
giveAttr
(
internStringMortal
(
attr
),
val
);
}
// giveAttrBorrowed consumes a reference only to attr (but it only has the const char* variant
// giveAttrBorrowed consumes a reference only to attr (but it only has the const char* variant
...
...
src/runtime/objmodel.cpp
View file @
448680a3
...
@@ -480,6 +480,11 @@ static void subtype_dealloc(Box* self) noexcept {
...
@@ -480,6 +480,11 @@ static void subtype_dealloc(Box* self) noexcept {
}
}
}
}
// Pyston addition: same for hcattrs
if
(
type
->
attrs_offset
&&
!
base
->
attrs_offset
)
{
self
->
getHCAttrsPtr
()
->
clear
();
}
/* Extract the type again; tp_del may have changed it */
/* Extract the type again; tp_del may have changed it */
type
=
Py_TYPE
(
self
);
type
=
Py_TYPE
(
self
);
...
@@ -1110,7 +1115,7 @@ template <Rewritable rewritable> BORROWED(Box*) Box::getattr(BoxedString* attr,
...
@@ -1110,7 +1115,7 @@ template <Rewritable rewritable> BORROWED(Box*) Box::getattr(BoxedString* attr,
template
Box
*
Box
::
getattr
<
REWRITABLE
>(
BoxedString
*
,
GetattrRewriteArgs
*
);
template
Box
*
Box
::
getattr
<
REWRITABLE
>(
BoxedString
*
,
GetattrRewriteArgs
*
);
template
Box
*
Box
::
getattr
<
NOT_REWRITABLE
>(
BoxedString
*
,
GetattrRewriteArgs
*
);
template
Box
*
Box
::
getattr
<
NOT_REWRITABLE
>(
BoxedString
*
,
GetattrRewriteArgs
*
);
void
Box
::
appendNewHCAttr
(
B
ox
*
new_attr
,
SetattrRewriteArgs
*
rewrite_args
)
{
void
Box
::
appendNewHCAttr
(
B
ORROWED
(
Box
*
)
new_attr
,
SetattrRewriteArgs
*
rewrite_args
)
{
Py_INCREF
(
new_attr
);
Py_INCREF
(
new_attr
);
assert
(
cls
->
instancesHaveHCAttrs
());
assert
(
cls
->
instancesHaveHCAttrs
());
...
@@ -1161,7 +1166,7 @@ void Box::giveAttr(BoxedString* attr, Box* val) {
...
@@ -1161,7 +1166,7 @@ void Box::giveAttr(BoxedString* attr, Box* val) {
Py_DECREF
(
attr
);
Py_DECREF
(
attr
);
}
}
void
Box
::
setattr
(
BoxedString
*
attr
,
B
ox
*
val
,
SetattrRewriteArgs
*
rewrite_args
)
{
void
Box
::
setattr
(
BoxedString
*
attr
,
B
ORROWED
(
Box
*
)
val
,
SetattrRewriteArgs
*
rewrite_args
)
{
assert
(
attr
->
interned_state
!=
SSTATE_NOT_INTERNED
);
assert
(
attr
->
interned_state
!=
SSTATE_NOT_INTERNED
);
// Have to guard on the memory layout of this object.
// Have to guard on the memory layout of this object.
...
...
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