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
2e0b2c58
Commit
2e0b2c58
authored
Feb 03, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More refcount fixes
parent
28af3827
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
24 additions
and
26 deletions
+24
-26
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+4
-4
src/core/types.h
src/core/types.h
+0
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+8
-8
src/runtime/objmodel.h
src/runtime/objmodel.h
+1
-1
src/runtime/str.cpp
src/runtime/str.cpp
+9
-12
src/runtime/types.cpp
src/runtime/types.cpp
+2
-0
No files found.
src/codegen/ast_interpreter.cpp
View file @
2e0b2c58
...
...
@@ -467,9 +467,6 @@ void ASTInterpreter::doStore(AST_Name* node, STOLEN(Value) value) {
if
(
jit
)
jit
->
emitSetGlobal
(
globals
,
name
.
getBox
(),
value
);
setGlobal
(
globals
,
name
.
getBox
(),
value
.
o
);
Py_DECREF
(
value
.
o
);
if
(
jit
)
value
.
var
->
decvref
();
}
else
if
(
vst
==
ScopeInfo
::
VarScopeType
::
NAME
)
{
assert
(
0
&&
"check refcounting"
);
if
(
jit
)
...
...
@@ -510,9 +507,12 @@ void ASTInterpreter::doStore(AST_expr* node, STOLEN(Value) value) {
}
else
if
(
node
->
type
==
AST_TYPE
::
Attribute
)
{
AST_Attribute
*
attr
=
(
AST_Attribute
*
)
node
;
Value
o
=
visit_expr
(
attr
->
value
);
if
(
jit
)
if
(
jit
)
{
jit
->
emitSetAttr
(
node
,
o
,
attr
->
attr
.
getBox
(),
value
);
o
.
var
->
decvref
();
}
pyston
::
setattr
(
o
.
o
,
attr
->
attr
.
getBox
(),
value
.
o
);
Py_DECREF
(
o
.
o
);
}
else
if
(
node
->
type
==
AST_TYPE
::
Tuple
)
{
AST_Tuple
*
tuple
=
(
AST_Tuple
*
)
node
;
Box
**
array
=
unpackIntoArray
(
value
.
o
,
tuple
->
elts
.
size
());
...
...
src/core/types.h
View file @
2e0b2c58
...
...
@@ -671,7 +671,6 @@ public:
}
void
giveAttr
(
BoxedString
*
attr
,
Box
*
val
);
// for debugging mostly:
void
clearAttrs
();
// getattr() does the equivalent of PyDict_GetItem(obj->dict, attr): it looks up the attribute's value on the
...
...
src/runtime/objmodel.cpp
View file @
2e0b2c58
...
...
@@ -785,7 +785,7 @@ BoxedDict* Box::getDict() {
static
StatCounter
box_getattr_slowpath
(
"slowpath_box_getattr"
);
template
<
Rewritable
rewritable
>
B
ox
*
Box
::
getattr
(
BoxedString
*
attr
,
GetattrRewriteArgs
*
rewrite_args
)
{
template
<
Rewritable
rewritable
>
B
ORROWED
(
Box
*
)
Box
::
getattr
(
BoxedString
*
attr
,
GetattrRewriteArgs
*
rewrite_args
)
{
if
(
rewritable
==
NOT_REWRITABLE
)
{
assert
(
!
rewrite_args
);
rewrite_args
=
NULL
;
...
...
@@ -2541,6 +2541,8 @@ void setattrGeneric(Box* obj, BoxedString* attr, STOLEN(Box*) val, SetattrRewrit
}
obj
->
setattr
(
attr
,
val
,
rewrite_args
);
// TODO: make setattr() stealing
Py_DECREF
(
val
);
}
// TODO this should be in type_setattro
...
...
@@ -2639,10 +2641,8 @@ extern "C" void setattr(Box* obj, BoxedString* attr, Box* attr_val) {
}
}
// We should probably add this as a GC root, but we can cheat a little bit since
// we know it's not going to get deallocated:
// This is a borrowed reference so we don't need to register it
static
Box
*
object_setattr
=
object_cls
->
getattr
(
getStaticString
(
"__setattr__"
));
assert
(
object_setattr
);
// I guess this check makes it ok for us to just rely on having guarded on the value of setattr without
// invalidating on deallocation, since we assume that object.__setattr__ will never get deallocated.
...
...
@@ -6494,13 +6494,13 @@ extern "C" Box* getGlobal(Box* globals, BoxedString* name) {
rtn
=
builtins_module
->
getattr
(
name
);
}
// XXX
// XXX
#ifndef NDEBUG
rewriter
.
release
();
rewriter
.
release
();
#endif
assert
(
rtn
->
ob_refcnt
>
0
);
if
(
rtn
)
{
assert
(
rtn
->
ob_refcnt
>
0
);
Py_INCREF
(
rtn
);
return
rtn
;
}
...
...
@@ -6529,7 +6529,7 @@ Box* getFromGlobals(Box* globals, BoxedString* name) {
}
}
extern
"C"
void
setGlobal
(
Box
*
globals
,
BoxedString
*
name
,
Box
*
value
)
{
extern
"C"
void
setGlobal
(
Box
*
globals
,
BoxedString
*
name
,
STOLEN
(
Box
*
)
value
)
{
if
(
globals
->
cls
==
attrwrapper_cls
)
{
globals
=
unwrapAttrWrapper
(
globals
);
RELEASE_ASSERT
(
globals
->
cls
==
module_cls
,
"%s"
,
globals
->
cls
->
tp_name
);
...
...
src/runtime/objmodel.h
View file @
2e0b2c58
...
...
@@ -222,7 +222,7 @@ extern "C" Box* getGlobal(Box* globals, BoxedString* name);
// Checks for the name just in the passed globals object, and returns NULL if it is not found.
// This includes if the globals object defined a custom __getattr__ method that threw an AttributeError.
Box
*
getFromGlobals
(
Box
*
globals
,
BoxedString
*
name
);
extern
"C"
void
setGlobal
(
Box
*
globals
,
BoxedString
*
name
,
Box
*
value
);
extern
"C"
void
setGlobal
(
Box
*
globals
,
BoxedString
*
name
,
STOLEN
(
Box
*
)
value
);
extern
"C"
void
delGlobal
(
Box
*
globals
,
BoxedString
*
name
);
extern
"C"
void
boxedLocalsSet
(
Box
*
boxedLocals
,
BoxedString
*
attr
,
Box
*
val
);
...
...
src/runtime/str.cpp
View file @
2e0b2c58
...
...
@@ -1157,28 +1157,25 @@ extern "C" Box* strMod(BoxedString* lhs, Box* rhs) {
extern
"C"
Box
*
strMul
(
BoxedString
*
lhs
,
Box
*
rhs
)
{
assert
(
PyString_Check
(
lhs
));
int
n
;
if
(
PyIndex_Check
(
rhs
))
{
Box
*
index
=
PyNumber_Index
(
rhs
);
if
(
!
index
)
{
throwCAPIException
();
}
rhs
=
index
;
}
Py_ssize_t
n
;
if
(
PyInt_Check
(
rhs
))
n
=
static_cast
<
BoxedInt
*>
(
rhs
)
->
n
;
else
if
(
isSubclass
(
rhs
->
cls
,
long_cl
s
))
{
else
if
(
PyLong_Check
(
rh
s
))
{
n
=
_PyLong_AsInt
(
rhs
);
if
(
PyErr_Occurred
())
{
PyErr_Clear
();
raiseExcHelper
(
OverflowError
,
"cannot fit 'long' into index-sized integer"
);
}
}
else
if
(
PyIndex_Check
(
rhs
))
{
n
=
PyNumber_AsSsize_t
(
rhs
,
PyExc_OverflowError
);
if
(
n
==
-
1
&&
PyErr_Occurred
())
throwCAPIException
();
}
else
return
NotImplemented
;
return
incref
(
NotImplemented
);
if
(
n
<=
0
)
return
EmptyString
;
return
incref
(
EmptyString
)
;
// TODO: use createUninitializedString and getWriteableStringContents
int
sz
=
lhs
->
size
();
...
...
src/runtime/types.cpp
View file @
2e0b2c58
...
...
@@ -395,6 +395,8 @@ static void functionDtor(Box* b) {
self
->
dependent_ics
.
invalidateAll
();
self
->
dependent_ics
.
~
ICInvalidator
();
self
->
clearAttrs
();
Py_DECREF
(
self
->
doc
);
Py_DECREF
(
self
->
modname
);
Py_XDECREF
(
self
->
name
);
...
...
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