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
0ccfdcb8
Commit
0ccfdcb8
authored
Jun 26, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up our iternext handling
ie try to avoid api conversion.
parent
89cdcc7e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
57 deletions
+43
-57
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+1
-1
src/capi/typeobject.h
src/capi/typeobject.h
+1
-0
src/core/types.h
src/core/types.h
+0
-1
src/runtime/capi.cpp
src/runtime/capi.cpp
+0
-19
src/runtime/iterators.cpp
src/runtime/iterators.cpp
+5
-18
src/runtime/iterobject.cpp
src/runtime/iterobject.cpp
+7
-13
src/runtime/types.cpp
src/runtime/types.cpp
+29
-5
No files found.
src/capi/typeobject.cpp
View file @
0ccfdcb8
...
...
@@ -827,7 +827,7 @@ static PyObject* slot_tp_iter(PyObject* self) noexcept {
return
PySeqIter_New
(
self
);
}
static
PyObject
*
slot_tp_iternext
(
PyObject
*
self
)
noexcept
{
/* Pyston change: static */
PyObject
*
slot_tp_iternext
(
PyObject
*
self
)
noexcept
{
STAT_TIMER
(
t0
,
"us_timer_slot_tpiternext"
,
SLOT_AVOIDABILITY
(
self
));
static
PyObject
*
next_str
;
...
...
src/capi/typeobject.h
View file @
0ccfdcb8
...
...
@@ -35,6 +35,7 @@ PyObject* mro_external(PyObject* self) noexcept;
int
type_set_bases
(
PyTypeObject
*
type
,
PyObject
*
value
,
void
*
context
)
noexcept
;
PyObject
*
slot_tp_richcompare
(
PyObject
*
self
,
PyObject
*
other
,
int
op
)
noexcept
;
PyObject
*
slot_tp_iternext
(
PyObject
*
self
)
noexcept
;
}
#endif
src/core/types.h
View file @
0ccfdcb8
...
...
@@ -531,7 +531,6 @@ public:
BoxedString
*
reprICAsString
();
bool
nonzeroIC
();
Box
*
hasnextOrNullIC
();
Box
*
nextIC
();
friend
class
AttrWrapper
;
};
...
...
src/runtime/capi.cpp
View file @
0ccfdcb8
...
...
@@ -633,25 +633,6 @@ extern "C" int PyObject_Print(PyObject* obj, FILE* fp, int flags) noexcept {
return
internal_print
(
obj
,
fp
,
flags
,
0
);
};
extern
"C"
PyObject
*
PyIter_Next
(
PyObject
*
iter
)
noexcept
{
try
{
Box
*
hasnext
=
iter
->
hasnextOrNullIC
();
if
(
hasnext
)
{
if
(
hasnext
->
nonzeroIC
())
return
iter
->
nextIC
();
else
return
NULL
;
}
else
{
return
iter
->
nextIC
();
}
}
catch
(
ExcInfo
e
)
{
if
(
e
.
matches
(
StopIteration
))
return
NULL
;
setCAPIException
(
e
);
}
return
NULL
;
}
extern
"C"
int
PyCallable_Check
(
PyObject
*
x
)
noexcept
{
if
(
x
==
NULL
)
return
0
;
...
...
src/runtime/iterators.cpp
View file @
0ccfdcb8
...
...
@@ -41,24 +41,11 @@ public:
void
next
()
override
{
STAT_TIMER
(
t0
,
"us_timer_iteratorgeneric_next"
,
0
);
assert
(
iterator
);
Box
*
hasnext
=
iterator
->
hasnextOrNullIC
();
if
(
hasnext
)
{
if
(
hasnext
->
nonzeroIC
())
{
value
=
iterator
->
nextIC
();
}
else
{
*
this
=
*
end
();
}
}
else
{
try
{
value
=
iterator
->
nextIC
();
}
catch
(
ExcInfo
e
)
{
if
(
e
.
matches
(
StopIteration
))
*
this
=
*
end
();
else
throw
e
;
}
}
Box
*
next
=
PyIter_Next
(
iterator
);
if
(
next
)
value
=
next
;
else
*
this
=
*
end
();
}
Box
*
getValue
()
override
{
return
value
;
}
...
...
src/runtime/iterobject.cpp
View file @
0ccfdcb8
...
...
@@ -132,20 +132,14 @@ bool iterwrapperHasnextUnboxed(Box* s) {
RELEASE_ASSERT
(
s
->
cls
==
iterwrapper_cls
,
""
);
BoxedIterWrapper
*
self
=
static_cast
<
BoxedIterWrapper
*>
(
s
);
static
BoxedString
*
next_str
=
static_cast
<
BoxedString
*>
(
PyString_InternFromString
(
"next"
));
Box
*
next
;
try
{
next
=
callattr
(
self
->
iter
,
next_str
,
CallattrFlags
({.
cls_only
=
true
,
.
null_on_nonexistent
=
false
}),
ArgPassSpec
(
0
),
NULL
,
NULL
,
NULL
,
NULL
,
NULL
);
}
catch
(
ExcInfo
e
)
{
if
(
e
.
matches
(
StopIteration
))
{
self
->
next
=
NULL
;
return
false
;
}
throw
e
;
}
Box
*
next
=
PyIter_Next
(
self
->
iter
);
self
->
next
=
next
;
return
true
;
if
(
!
next
)
{
if
(
PyErr_Occurred
()
&&
!
PyErr_ExceptionMatches
(
PyExc_StopIteration
))
throwCAPIException
();
PyErr_Clear
();
}
return
next
!=
NULL
;
}
Box
*
iterwrapperHasnext
(
Box
*
s
)
{
...
...
src/runtime/types.cpp
View file @
0ccfdcb8
...
...
@@ -238,9 +238,38 @@ Box* BoxedClass::callHasnextIC(Box* obj, bool null_on_nonexistent) {
ArgPassSpec
(
0
),
nullptr
,
nullptr
,
nullptr
,
nullptr
,
nullptr
);
}
extern
"C"
PyObject
*
PyIter_Next
(
PyObject
*
iter
)
noexcept
{
if
(
iter
->
cls
->
tp_iternext
!=
slot_tp_iternext
)
{
PyObject
*
result
;
result
=
(
*
iter
->
cls
->
tp_iternext
)(
iter
);
if
(
result
==
NULL
&&
PyErr_Occurred
()
&&
PyErr_ExceptionMatches
(
PyExc_StopIteration
))
PyErr_Clear
();
return
result
;
}
try
{
Box
*
hasnext
=
iter
->
hasnextOrNullIC
();
if
(
hasnext
)
{
if
(
hasnext
->
nonzeroIC
())
return
iter
->
cls
->
callNextIC
(
iter
);
else
return
NULL
;
}
else
{
return
iter
->
cls
->
callNextIC
(
iter
);
}
}
catch
(
ExcInfo
e
)
{
if
(
!
e
.
matches
(
StopIteration
))
setCAPIException
(
e
);
return
NULL
;
}
}
Box
*
BoxedClass
::
callNextIC
(
Box
*
obj
)
{
assert
(
obj
->
cls
==
this
);
// This would work, but it would have been better to just call tp_iternext
assert
(
this
->
tp_iternext
==
slot_tp_iternext
);
auto
ic
=
next_ic
.
get
();
if
(
!
ic
)
{
ic
=
new
CallattrIC
();
...
...
@@ -303,11 +332,6 @@ Box* Box::hasnextOrNullIC() {
return
this
->
cls
->
callHasnextIC
(
this
,
true
);
}
Box
*
Box
::
nextIC
()
{
return
this
->
cls
->
callNextIC
(
this
);
}
std
::
string
builtinStr
(
"__builtin__"
);
extern
"C"
BoxedFunctionBase
::
BoxedFunctionBase
(
CLFunction
*
f
)
...
...
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