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
dc4d003b
Commit
dc4d003b
authored
Nov 19, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More refcounting fixes
parent
158465fc
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
108 additions
and
45 deletions
+108
-45
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+6
-2
src/runtime/capi.cpp
src/runtime/capi.cpp
+3
-1
src/runtime/dict.cpp
src/runtime/dict.cpp
+12
-3
src/runtime/hiddenclass.cpp
src/runtime/hiddenclass.cpp
+1
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+82
-36
src/runtime/types.cpp
src/runtime/types.cpp
+3
-2
src/runtime/util.cpp
src/runtime/util.cpp
+1
-1
No files found.
src/runtime/builtin_modules/builtins.cpp
View file @
dc4d003b
...
@@ -1137,6 +1137,8 @@ extern "C" PyObject* PyErr_NewException(char* name, PyObject* _base, PyObject* d
...
@@ -1137,6 +1137,8 @@ extern "C" PyObject* PyErr_NewException(char* name, PyObject* _base, PyObject* d
_base
=
Exception
;
_base
=
Exception
;
if
(
dict
==
NULL
)
if
(
dict
==
NULL
)
dict
=
new
BoxedDict
();
dict
=
new
BoxedDict
();
else
Py_INCREF
(
dict
);
try
{
try
{
char
*
dot_pos
=
strchr
(
name
,
'.'
);
char
*
dot_pos
=
strchr
(
name
,
'.'
);
...
@@ -1149,11 +1151,13 @@ extern "C" PyObject* PyErr_NewException(char* name, PyObject* _base, PyObject* d
...
@@ -1149,11 +1151,13 @@ extern "C" PyObject* PyErr_NewException(char* name, PyObject* _base, PyObject* d
BoxedClass
*
base
=
static_cast
<
BoxedClass
*>
(
_base
);
BoxedClass
*
base
=
static_cast
<
BoxedClass
*>
(
_base
);
if
(
PyDict_GetItemString
(
dict
,
"__module__"
)
==
NULL
)
{
if
(
PyDict_GetItemString
(
dict
,
"__module__"
)
==
NULL
)
{
PyDict_SetItemString
(
dict
,
"__module__"
,
boxString
(
llvm
::
StringRef
(
name
,
dot_pos
-
name
)));
PyDict_SetItemString
(
dict
,
"__module__"
,
autoDecref
(
boxString
(
llvm
::
StringRef
(
name
,
dot_pos
-
name
)
)));
}
}
checkAndThrowCAPIException
();
checkAndThrowCAPIException
();
Box
*
cls
=
runtimeCall
(
type_cls
,
ArgPassSpec
(
3
),
boxedName
,
BoxedTuple
::
create
({
base
}),
dict
,
NULL
,
NULL
);
Box
*
cls
=
runtimeCall
(
type_cls
,
ArgPassSpec
(
3
),
boxedName
,
autoDecref
(
BoxedTuple
::
create
({
base
})),
dict
,
NULL
,
NULL
);
Py_DECREF
(
boxedName
);
Py_DECREF
(
dict
);
return
cls
;
return
cls
;
}
catch
(
ExcInfo
e
)
{
}
catch
(
ExcInfo
e
)
{
// PyErr_NewException isn't supposed to fail, and callers sometimes take advantage of that
// PyErr_NewException isn't supposed to fail, and callers sometimes take advantage of that
...
...
src/runtime/capi.cpp
View file @
dc4d003b
...
@@ -878,10 +878,12 @@ extern "C" void PyErr_SetExcInfo(PyObject* type, PyObject* value, PyObject* trac
...
@@ -878,10 +878,12 @@ extern "C" void PyErr_SetExcInfo(PyObject* type, PyObject* value, PyObject* trac
}
}
extern
"C"
void
PyErr_SetString
(
PyObject
*
exception
,
const
char
*
string
)
noexcept
{
extern
"C"
void
PyErr_SetString
(
PyObject
*
exception
,
const
char
*
string
)
noexcept
{
PyErr_SetObject
(
exception
,
boxString
(
string
));
PyErr_SetObject
(
exception
,
autoDecref
(
boxString
(
string
)
));
}
}
extern
"C"
void
PyErr_SetObject
(
PyObject
*
exception
,
PyObject
*
value
)
noexcept
{
extern
"C"
void
PyErr_SetObject
(
PyObject
*
exception
,
PyObject
*
value
)
noexcept
{
Py_XINCREF
(
exception
);
Py_XINCREF
(
value
);
PyErr_Restore
(
exception
,
value
,
NULL
);
PyErr_Restore
(
exception
,
value
,
NULL
);
}
}
...
...
src/runtime/dict.cpp
View file @
dc4d003b
...
@@ -329,9 +329,18 @@ extern "C" PyObject* PyDict_GetItem(PyObject* dict, PyObject* key) noexcept {
...
@@ -329,9 +329,18 @@ extern "C" PyObject* PyDict_GetItem(PyObject* dict, PyObject* key) noexcept {
ASSERT
(
PyDict_Check
(
dict
)
||
dict
->
cls
==
attrwrapper_cls
,
"%s"
,
getTypeName
(
dict
));
ASSERT
(
PyDict_Check
(
dict
)
||
dict
->
cls
==
attrwrapper_cls
,
"%s"
,
getTypeName
(
dict
));
if
(
PyDict_Check
(
dict
))
{
if
(
PyDict_Check
(
dict
))
{
BoxedDict
*
d
=
static_cast
<
BoxedDict
*>
(
dict
);
BoxedDict
*
d
=
static_cast
<
BoxedDict
*>
(
dict
);
return
d
->
getOrNull
(
key
);
/* preserve the existing exception */
PyObject
*
err_type
,
*
err_value
,
*
err_tb
;
PyErr_Fetch
(
&
err_type
,
&
err_value
,
&
err_tb
);
Box
*
b
=
d
->
getOrNull
(
key
);
/* ignore errors */
PyErr_Restore
(
err_type
,
err_value
,
err_tb
);
return
b
;
}
}
assert
(
0
&&
"check refcounting"
);
auto
&&
tstate
=
_PyThreadState_Current
;
auto
&&
tstate
=
_PyThreadState_Current
;
if
(
tstate
!=
NULL
&&
tstate
->
curexc_type
!=
NULL
)
{
if
(
tstate
!=
NULL
&&
tstate
->
curexc_type
!=
NULL
)
{
/* preserve the existing exception */
/* preserve the existing exception */
...
@@ -392,7 +401,7 @@ extern "C" int PyDict_Next(PyObject* op, Py_ssize_t* ppos, PyObject** pkey, PyOb
...
@@ -392,7 +401,7 @@ extern "C" int PyDict_Next(PyObject* op, Py_ssize_t* ppos, PyObject** pkey, PyOb
extern
"C"
PyObject
*
PyDict_GetItemString
(
PyObject
*
dict
,
const
char
*
key
)
noexcept
{
extern
"C"
PyObject
*
PyDict_GetItemString
(
PyObject
*
dict
,
const
char
*
key
)
noexcept
{
if
(
dict
->
cls
==
attrwrapper_cls
)
if
(
dict
->
cls
==
attrwrapper_cls
)
return
unwrapAttrWrapper
(
dict
)
->
getattr
(
internStringMortal
(
key
));
return
unwrapAttrWrapper
(
dict
)
->
getattr
(
autoDecref
(
internStringMortal
(
key
)
));
Box
*
key_s
;
Box
*
key_s
;
try
{
try
{
...
@@ -400,7 +409,7 @@ extern "C" PyObject* PyDict_GetItemString(PyObject* dict, const char* key) noexc
...
@@ -400,7 +409,7 @@ extern "C" PyObject* PyDict_GetItemString(PyObject* dict, const char* key) noexc
}
catch
(
ExcInfo
e
)
{
}
catch
(
ExcInfo
e
)
{
abort
();
abort
();
}
}
return
PyDict_GetItem
(
dict
,
key_s
);
return
PyDict_GetItem
(
dict
,
autoDecref
(
key_s
)
);
}
}
Box
*
dictSetitem
(
BoxedDict
*
self
,
Box
*
k
,
Box
*
v
)
{
Box
*
dictSetitem
(
BoxedDict
*
self
,
Box
*
k
,
Box
*
v
)
{
...
...
src/runtime/hiddenclass.cpp
View file @
dc4d003b
...
@@ -79,6 +79,7 @@ HiddenClass* HiddenClass::getOrMakeChild(BoxedString* attr) {
...
@@ -79,6 +79,7 @@ HiddenClass* HiddenClass::getOrMakeChild(BoxedString* attr) {
static
StatCounter
num_hclses
(
"num_hidden_classes"
);
static
StatCounter
num_hclses
(
"num_hidden_classes"
);
num_hclses
.
log
();
num_hclses
.
log
();
// XXX: need to hold a ref to the string (or maybe we don't if we can hook the un-interning)
HiddenClass
*
rtn
=
new
HiddenClass
(
this
);
HiddenClass
*
rtn
=
new
HiddenClass
(
this
);
rtn
->
attr_offsets
[
attr
]
=
this
->
attributeArraySize
();
rtn
->
attr_offsets
[
attr
]
=
this
->
attributeArraySize
();
this
->
children
[
attr
]
=
rtn
;
this
->
children
[
attr
]
=
rtn
;
...
...
src/runtime/objmodel.cpp
View file @
dc4d003b
This diff is collapsed.
Click to expand it.
src/runtime/types.cpp
View file @
dc4d003b
...
@@ -2142,7 +2142,7 @@ public:
...
@@ -2142,7 +2142,7 @@ public:
internStringMortalInplace
(
key
);
internStringMortalInplace
(
key
);
self
->
b
->
setattr
(
key
,
value
,
NULL
);
self
->
b
->
setattr
(
key
,
value
,
NULL
);
return
None
;
Py_RETURN_NONE
;
}
}
static
int
ass_sub
(
PyDictObject
*
mp
,
PyObject
*
v
,
PyObject
*
w
)
noexcept
{
static
int
ass_sub
(
PyDictObject
*
mp
,
PyObject
*
v
,
PyObject
*
w
)
noexcept
{
...
@@ -2154,6 +2154,7 @@ public:
...
@@ -2154,6 +2154,7 @@ public:
res
=
AttrWrapper
::
setitem
((
Box
*
)
mp
,
v
,
w
);
res
=
AttrWrapper
::
setitem
((
Box
*
)
mp
,
v
,
w
);
}
}
assert
(
res
==
None
);
assert
(
res
==
None
);
Py_DECREF
(
res
);
}
catch
(
ExcInfo
e
)
{
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
setCAPIException
(
e
);
return
-
1
;
return
-
1
;
...
@@ -2259,7 +2260,7 @@ public:
...
@@ -2259,7 +2260,7 @@ public:
self
->
b
->
delattr
(
key
,
NULL
);
self
->
b
->
delattr
(
key
,
NULL
);
else
else
raiseExcHelper
(
KeyError
,
"'%s'"
,
key
->
data
());
raiseExcHelper
(
KeyError
,
"'%s'"
,
key
->
data
());
return
None
;
Py_RETURN_NONE
;
}
}
static
Box
*
str
(
Box
*
_self
)
{
static
Box
*
str
(
Box
*
_self
)
{
...
...
src/runtime/util.cpp
View file @
dc4d003b
...
@@ -77,7 +77,7 @@ void boundSliceWithLength(i64* start_out, i64* stop_out, i64 start, i64 stop, i6
...
@@ -77,7 +77,7 @@ void boundSliceWithLength(i64* start_out, i64* stop_out, i64 start, i64 stop, i6
Box
*
boxStringOrNone
(
const
char
*
s
)
{
Box
*
boxStringOrNone
(
const
char
*
s
)
{
if
(
s
==
NULL
)
{
if
(
s
==
NULL
)
{
return
None
;
return
incref
(
None
)
;
}
else
{
}
else
{
return
boxString
(
s
);
return
boxString
(
s
);
}
}
...
...
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