Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
226ad371
Commit
226ad371
authored
Aug 24, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reuse known thread state in more places instead of looking it up again.
parent
105aba6b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
12 deletions
+13
-12
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+2
-2
Cython/Utility/Coroutine.c
Cython/Utility/Coroutine.c
+9
-10
Cython/Utility/Exceptions.c
Cython/Utility/Exceptions.c
+2
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
226ad371
...
...
@@ -9539,7 +9539,7 @@ class _YieldDelegationExprNode(YieldExprNode):
code
.
put_gotref
(
self
.
result
())
def
handle_iteration_exception
(
self
,
code
):
code
.
putln
(
"PyObject* exc_type = PyErr_Occurred();"
)
code
.
putln
(
"PyObject* exc_type =
__Pyx_
PyErr_Occurred();"
)
code
.
putln
(
"if (exc_type) {"
)
code
.
putln
(
"if (likely(exc_type == PyExc_StopIteration || (exc_type != PyExc_GeneratorExit &&"
" __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))) PyErr_Clear();"
)
...
...
@@ -9589,7 +9589,7 @@ class AwaitIterNextExprNode(AwaitExprNode):
def
_generate_break
(
self
,
code
):
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"StopAsyncIteration"
,
"Coroutine.c"
))
code
.
putln
(
"PyObject* exc_type = PyErr_Occurred();"
)
code
.
putln
(
"PyObject* exc_type =
__Pyx_
PyErr_Occurred();"
)
code
.
putln
(
"if (unlikely(exc_type && (exc_type == __Pyx_PyExc_StopAsyncIteration || ("
" exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit &&"
" __Pyx_PyErr_GivenExceptionMatches(exc_type, __Pyx_PyExc_StopAsyncIteration))))) {"
)
...
...
Cython/Utility/Coroutine.c
View file @
226ad371
...
...
@@ -355,6 +355,7 @@ static void __Pyx_Generator_Replace_StopIteration(CYTHON_UNUSED int in_async_gen
//////////////////// CoroutineBase.proto ////////////////////
//@substitute: naming
typedef
PyObject
*
(
*
__pyx_coroutine_body_t
)(
PyObject
*
,
PyObject
*
);
...
...
@@ -401,12 +402,14 @@ static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args); /*proto*/
}
static
CYTHON_INLINE
void
__Pyx_Coroutine_ResetFrameBackpointer
(
__pyx_CoroutineObject
*
self
);
#if 1 || PY_VERSION_HEX < 0x030300B0
static
int
__Pyx_PyGen_FetchStopIterationValue
(
PyObject
**
pvalue
);
/*proto*/
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyGen_FetchStopIterationValue(pvalue) \
__Pyx_PyGen__FetchStopIterationValue($local_tstate_cname, pvalue)
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue)
#define __Pyx_PyGen_FetchStopIterationValue(pvalue) \
__Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
#endif
static
int
__Pyx_PyGen__FetchStopIterationValue
(
PyThreadState
*
tstate
,
PyObject
**
pvalue
);
/*proto*/
//////////////////// Coroutine.proto ////////////////////
...
...
@@ -462,12 +465,9 @@ static int __pyx_Generator_init(void); /*proto*/
// Returns 0 if no exception or StopIteration is set.
// If any other exception is set, returns -1 and leaves
// pvalue unchanged.
#if 1 || PY_VERSION_HEX < 0x030300B0
static
int
__Pyx_PyGen_FetchStopIterationValue
(
PyObject
**
pvalue
)
{
static
int
__Pyx_PyGen__FetchStopIterationValue
(
CYTHON_UNUSED
PyThreadState
*
$
local_tstate_cname
,
PyObject
**
pvalue
)
{
PyObject
*
et
,
*
ev
,
*
tb
;
PyObject
*
value
=
NULL
;
__Pyx_PyThreadState_declare
__Pyx_PyThreadState_assign
__Pyx_ErrFetch
(
&
et
,
&
ev
,
&
tb
);
...
...
@@ -554,7 +554,6 @@ static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
*
pvalue
=
value
;
return
0
;
}
#endif
static
CYTHON_INLINE
void
__Pyx_Coroutine_ExceptionClear
(
__pyx_CoroutineObject
*
self
)
{
...
...
@@ -714,7 +713,7 @@ PyObject *__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen) {
PyObject
*
ret
;
PyObject
*
val
=
NULL
;
__Pyx_Coroutine_Undelegate
(
gen
);
__Pyx_PyGen_
FetchStopIterationValue
(
&
val
);
__Pyx_PyGen_
_FetchStopIterationValue
(
__Pyx_PyThreadState_Current
,
&
val
);
// val == NULL on failure => pass on exception
ret
=
__Pyx_Coroutine_SendEx
(
gen
,
val
,
0
);
Py_XDECREF
(
val
);
...
...
Cython/Utility/Exceptions.c
View file @
226ad371
...
...
@@ -11,6 +11,7 @@
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare PyThreadState *$local_tstate_cname;
#define __Pyx_PyErr_Occurred() $local_tstate_cname->curexc_type
#if PY_VERSION_HEX >= 0x03050000
#define __Pyx_PyThreadState_assign $local_tstate_cname = _PyThreadState_UncheckedGet();
#elif PY_VERSION_HEX >= 0x03000000
...
...
@@ -23,6 +24,7 @@
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred() PyErr_Occurred()
#endif
...
...
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