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
472952d8
Commit
472952d8
authored
Mar 08, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lots of fixes
parent
886b4fd7
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
59 additions
and
21 deletions
+59
-21
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+6
-0
src/core/cfg.cpp
src/core/cfg.cpp
+3
-4
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+11
-1
src/runtime/inline/list.cpp
src/runtime/inline/list.cpp
+1
-1
src/runtime/int.cpp
src/runtime/int.cpp
+1
-1
src/runtime/iterators.cpp
src/runtime/iterators.cpp
+10
-3
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+14
-7
src/runtime/set.cpp
src/runtime/set.cpp
+10
-4
src/runtime/types.cpp
src/runtime/types.cpp
+3
-0
No files found.
src/capi/typeobject.cpp
View file @
472952d8
...
...
@@ -782,6 +782,7 @@ static llvm_compat_bool slotTppHasnext(PyObject* self) {
Box
*
r
=
self
->
hasnextOrNullIC
();
assert
(
r
);
AUTO_DECREF
(
r
);
return
r
->
nonzeroIC
();
}
...
...
@@ -3355,6 +3356,11 @@ static Box* tppProxyToTpCall(Box* self, CallRewriteArgs* rewrite_args, ArgPassSp
throw
e
;
}
AUTO_DECREF
(
arg1
);
if
(
!
paramspec
.
takes_kwargs
)
arg2
=
NULL
;
AUTO_XDECREF
(
arg2
);
if
(
!
rewrite_success
)
rewrite_args
=
NULL
;
...
...
src/core/cfg.cpp
View file @
472952d8
...
...
@@ -1421,7 +1421,9 @@ public:
}
}
bool
is_raise
=
(
node
->
type
==
AST_TYPE
::
Raise
);
// We remapped asserts to just be assertion failures at this point.
bool
is_raise
=
(
node
->
type
==
AST_TYPE
::
Raise
||
node
->
type
==
AST_TYPE
::
Assert
);
// If we invoke a raise statement, generate an invoke where both destinations
// are the exception handler, since we know the non-exceptional path won't be taken.
// TODO: would be much better (both more efficient and require less special casing)
...
...
@@ -1657,9 +1659,6 @@ public:
curblock
=
iffalse
;
// The rest of this is pretty hacky:
// Emit a "assert(0, msg()); while (1) {}" section that basically captures
// what the assert will do but in a very hacky way.
AST_Assert
*
remapped
=
new
AST_Assert
();
if
(
node
->
msg
)
remapped
->
msg
=
remapExpr
(
node
->
msg
);
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
472952d8
...
...
@@ -631,6 +631,8 @@ Box* setattrFunc(Box* obj, Box* _str, Box* value) {
}
static
Box
*
hasattrFuncHelper
(
Box
*
return_val
)
noexcept
{
AUTO_XDECREF
(
return_val
);
if
(
return_val
)
Py_RETURN_TRUE
;
...
...
@@ -652,6 +654,9 @@ Box* hasattrFuncInternal(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args,
if
(
!
rewrite_success
)
rewrite_args
=
NULL
;
AUTO_DECREF
(
arg1
);
AUTO_DECREF
(
arg2
);
Box
*
obj
=
arg1
;
Box
*
_str
=
arg2
;
...
...
@@ -677,6 +682,7 @@ Box* hasattrFuncInternal(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args,
_str
=
coerceUnicodeToStr
<
S
>
(
_str
);
if
(
S
==
CAPI
&&
!
_str
)
return
NULL
;
AUTO_DECREF
(
_str
);
if
(
!
PyString_Check
(
_str
))
{
if
(
S
==
CAPI
)
{
...
...
@@ -687,8 +693,11 @@ Box* hasattrFuncInternal(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args,
}
BoxedString
*
str
=
static_cast
<
BoxedString
*>
(
_str
);
Py_INCREF
(
str
);
if
(
!
PyString_CHECK_INTERNED
(
str
))
internStringMortalInplace
(
str
);
AUTO_DECREF
(
str
);
Box
*
rtn
;
RewriterVar
*
r_rtn
;
...
...
@@ -717,7 +726,8 @@ Box* hasattrFuncInternal(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args,
}
if
(
rewrite_args
)
{
RewriterVar
*
final_rtn
=
rewrite_args
->
rewriter
->
call
(
false
,
(
void
*
)
hasattrFuncHelper
,
r_rtn
);
RewriterVar
*
final_rtn
=
rewrite_args
->
rewriter
->
call
(
false
,
(
void
*
)
hasattrFuncHelper
,
r_rtn
)
->
setType
(
RefType
::
OWNED
);
if
(
S
==
CXX
)
rewrite_args
->
rewriter
->
checkAndThrowCAPIException
(
final_rtn
);
...
...
src/runtime/inline/list.cpp
View file @
472952d8
...
...
@@ -27,7 +27,7 @@ BoxedListIterator::BoxedListIterator(BoxedList* l, int start) : l(l), pos(start)
}
Box
*
listIterIter
(
Box
*
s
)
{
return
s
;
return
incref
(
s
)
;
}
Box
*
listIter
(
Box
*
s
)
noexcept
{
...
...
src/runtime/int.cpp
View file @
472952d8
...
...
@@ -1118,7 +1118,7 @@ Box* intCoerce(BoxedInt* lhs, Box* rhs) {
getTypeName
(
lhs
));
if
(
!
PyInt_Check
(
rhs
))
{
return
NotImplemented
;
return
incref
(
NotImplemented
)
;
}
BoxedInt
*
rhs_int
=
static_cast
<
BoxedInt
*>
(
rhs
);
...
...
src/runtime/iterators.cpp
View file @
472952d8
...
...
@@ -82,25 +82,32 @@ private:
uint64_t
index
;
static
bool
hasnext
(
BoxedList
*
o
,
uint64_t
i
)
{
return
i
<
o
->
size
;
}
static
Box
*
getValue
(
BoxedList
*
o
,
uint64_t
i
)
{
return
o
->
elts
->
elts
[
i
]
;
}
static
Box
*
getValue
(
BoxedList
*
o
,
uint64_t
i
)
{
return
incref
(
o
->
elts
->
elts
[
i
])
;
}
static
bool
hasnext
(
BoxedTuple
*
o
,
uint64_t
i
)
{
return
i
<
o
->
size
();
}
static
Box
*
getValue
(
BoxedTuple
*
o
,
uint64_t
i
)
{
return
o
->
elts
[
i
]
;
}
static
Box
*
getValue
(
BoxedTuple
*
o
,
uint64_t
i
)
{
return
incref
(
o
->
elts
[
i
])
;
}
static
bool
hasnext
(
BoxedString
*
o
,
uint64_t
i
)
{
return
i
<
o
->
size
();
}
static
Box
*
getValue
(
BoxedString
*
o
,
uint64_t
i
)
{
return
boxString
(
llvm
::
StringRef
(
o
->
data
()
+
i
,
1
));
}
public:
BoxIteratorIndex
(
T
*
obj
)
:
obj
(
obj
),
index
(
0
)
{
Py_XINCREF
(
obj
);
if
(
obj
&&
!
hasnext
(
obj
,
index
))
*
this
=
*
end
();
}
~
BoxIteratorIndex
()
{
Py_XDECREF
(
obj
);
}
void
next
()
override
{
if
(
!
end
()
->
isSame
(
this
))
{
++
index
;
if
(
!
hasnext
(
obj
,
index
))
if
(
!
hasnext
(
obj
,
index
))
{
Py_CLEAR
(
obj
);
*
this
=
*
end
();
}
}
}
...
...
src/runtime/objmodel.cpp
View file @
472952d8
...
...
@@ -4169,6 +4169,7 @@ void rearrangeArgumentsInternal(ParamReceiveSpec paramspec, const ParamNames* pa
for
(
int
i
=
0
;
i
<
paramspec
.
num_args
-
paramspec
.
num_defaults
;
i
++
)
{
if
(
params_filled
[
i
])
continue
;
RELEASE_ASSERT
(
0
,
"TODO: decref everything that we incref'd as part of this process"
);
raiseExcHelper
(
TypeError
,
"%s() takes exactly %d arguments (%ld given)"
,
func_name_cb
(),
paramspec
.
num_args
,
argspec
.
num_args
+
argspec
.
num_keywords
+
varargs_size
);
}
...
...
@@ -5250,9 +5251,9 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
// This could be inlined:
RewriterVar
*
r_r
;
if
(
op_type
==
AST_TYPE
::
NotIn
)
r_r
=
rewrite_args
->
rewriter
->
call
(
false
,
(
void
*
)
boxBoolNegated
,
r_b
);
r_r
=
rewrite_args
->
rewriter
->
call
(
false
,
(
void
*
)
boxBoolNegated
,
r_b
)
->
setType
(
RefType
::
OWNED
)
;
else
r_r
=
rewrite_args
->
rewriter
->
call
(
false
,
(
void
*
)
boxBool
,
r_b
);
r_r
=
rewrite_args
->
rewriter
->
call
(
false
,
(
void
*
)
boxBool
,
r_b
)
->
setType
(
RefType
::
OWNED
)
;
rewrite_args
->
out_success
=
true
;
rewrite_args
->
out_rtn
=
r_r
;
...
...
@@ -5313,11 +5314,17 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
rewrite_args
->
out_success
=
true
;
}
bool
b
;
if
(
contained
->
cls
==
bool_cls
)
b
=
contained
==
True
;
else
b
=
contained
->
nonzeroIC
();
if
(
contained
->
cls
==
bool_cls
)
{
if
(
op_type
==
AST_TYPE
::
NotIn
)
{
Py_DECREF
(
contained
);
return
boxBool
(
contained
==
False
);
}
else
{
return
contained
;
}
}
AUTO_DECREF
(
contained
);
bool
b
=
contained
->
nonzeroIC
();
if
(
op_type
==
AST_TYPE
::
NotIn
)
return
boxBool
(
!
b
);
return
boxBool
(
b
);
...
...
src/runtime/set.cpp
View file @
472952d8
...
...
@@ -86,12 +86,12 @@ Box* setiter_next(Box* _self) noexcept {
Box
*
setiteratorIter
(
BoxedSetIterator
*
self
)
{
RELEASE_ASSERT
(
self
->
cls
==
set_iterator_cls
,
""
);
return
self
;
return
incref
(
self
)
;
}
static
void
_setAddStolen
(
BoxedSet
*
self
,
STOLEN
(
BoxAndHash
)
val
)
{
auto
&&
p
=
self
->
s
.
insert
(
val
);
if
(
p
.
second
/* already exists */
)
{
if
(
!
p
.
second
/* already exists */
)
{
Py_DECREF
(
p
.
first
->
value
);
*
p
.
first
=
val
;
}
...
...
@@ -155,7 +155,13 @@ Box* frozensetNew(Box* _cls, Box* container, BoxedDict* kwargs) {
}
Py_DECREF
(
result
);
}
static
Box
*
emptyfrozenset
=
new
(
frozenset_cls
)
BoxedSet
();
static
Box
*
emptyfrozenset
=
NULL
;
if
(
!
emptyfrozenset
)
{
emptyfrozenset
=
new
(
frozenset_cls
)
BoxedSet
();
PyGC_RegisterStaticConstant
(
emptyfrozenset
);
}
Py_INCREF
(
emptyfrozenset
);
return
emptyfrozenset
;
}
...
...
@@ -277,7 +283,7 @@ static void _setSymmetricDifferenceUpdate(BoxedSet* self, Box* other) {
for
(
auto
elt
:
other_set
->
s
)
{
auto
&&
p
=
self
->
s
.
insert
(
elt
);
if
(
p
.
second
/* already exists */
)
{
if
(
!
p
.
second
/* already exists */
)
{
self
->
s
.
erase
(
p
.
first
);
Py_DECREF
(
elt
.
value
);
}
else
{
...
...
src/runtime/types.cpp
View file @
472952d8
...
...
@@ -398,6 +398,9 @@ static void functionDtor(Box* b) {
BoxedFunctionBase
*
self
=
static_cast
<
BoxedFunctionBase
*>
(
b
);
PyObject_GC_UnTrack
(
self
);
PyObject_ClearWeakRefs
((
PyObject
*
)
self
);
self
->
dependent_ics
.
invalidateAll
();
self
->
dependent_ics
.
~
ICInvalidator
();
...
...
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