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
40fa7ef7
Commit
40fa7ef7
authored
Jul 20, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove generator pushing code
parent
d7fa6e8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
64 deletions
+3
-64
src/core/threading.cpp
src/core/threading.cpp
+0
-47
src/core/threading.h
src/core/threading.h
+0
-7
src/runtime/generator.cpp
src/runtime/generator.cpp
+3
-10
No files found.
src/core/threading.cpp
View file @
40fa7ef7
...
@@ -83,24 +83,6 @@ private:
...
@@ -83,24 +83,6 @@ private:
public:
public:
void
*
stack_start
;
void
*
stack_start
;
struct
StackInfo
{
BoxedGenerator
*
next_generator
;
void
*
stack_start
;
void
*
stack_limit
;
StackInfo
(
BoxedGenerator
*
next_generator
,
void
*
stack_start
,
void
*
stack_limit
)
:
next_generator
(
next_generator
),
stack_start
(
stack_start
),
stack_limit
(
stack_limit
)
{
#if STACK_GROWS_DOWN
assert
(
stack_start
>
stack_limit
);
assert
((
char
*
)
stack_start
-
(
char
*
)
stack_limit
<
(
1L
<<
30
));
#else
assert
(
stack_start
<
stack_limit
);
assert
((
char
*
)
stack_limit
-
(
char
*
)
stack_start
<
(
1L
<<
30
));
#endif
}
};
std
::
vector
<
StackInfo
>
previous_stacks
;
pthread_t
pthread_id
;
pthread_t
pthread_id
;
PyThreadState
*
public_thread_state
;
PyThreadState
*
public_thread_state
;
...
@@ -137,36 +119,10 @@ public:
...
@@ -137,36 +119,10 @@ public:
}
}
ucontext_t
*
getContext
()
{
return
&
ucontext
;
}
ucontext_t
*
getContext
()
{
return
&
ucontext
;
}
void
pushGenerator
(
BoxedGenerator
*
g
,
void
*
new_stack_start
,
void
*
old_stack_limit
)
{
previous_stacks
.
emplace_back
(
g
,
this
->
stack_start
,
old_stack_limit
);
this
->
stack_start
=
new_stack_start
;
}
void
popGenerator
()
{
assert
(
previous_stacks
.
size
());
StackInfo
&
stack
=
previous_stacks
.
back
();
stack_start
=
stack
.
stack_start
;
previous_stacks
.
pop_back
();
}
void
assertNoGenerators
()
{
assert
(
previous_stacks
.
size
()
==
0
);
}
};
};
static
std
::
unordered_map
<
pthread_t
,
ThreadStateInternal
*>
current_threads
;
static
std
::
unordered_map
<
pthread_t
,
ThreadStateInternal
*>
current_threads
;
static
__thread
ThreadStateInternal
*
current_internal_thread_state
=
0
;
static
__thread
ThreadStateInternal
*
current_internal_thread_state
=
0
;
void
pushGenerator
(
BoxedGenerator
*
g
,
void
*
new_stack_start
,
void
*
old_stack_limit
)
{
assert
(
new_stack_start
);
assert
(
old_stack_limit
);
assert
(
current_internal_thread_state
);
current_internal_thread_state
->
pushGenerator
(
g
,
new_stack_start
,
old_stack_limit
);
}
void
popGenerator
()
{
assert
(
current_internal_thread_state
);
current_internal_thread_state
->
popGenerator
();
}
// These are guarded by threading_lock
// These are guarded by threading_lock
static
int
signals_waiting
(
0
);
static
int
signals_waiting
(
0
);
...
@@ -243,8 +199,6 @@ static void tstate_delete_common(PyThreadState* tstate) {
...
@@ -243,8 +199,6 @@ static void tstate_delete_common(PyThreadState* tstate) {
}
}
static
void
unregisterThread
()
{
static
void
unregisterThread
()
{
current_internal_thread_state
->
assertNoGenerators
();
tstate_delete_common
(
current_internal_thread_state
->
public_thread_state
);
tstate_delete_common
(
current_internal_thread_state
->
public_thread_state
);
PyThreadState_Clear
(
current_internal_thread_state
->
public_thread_state
);
PyThreadState_Clear
(
current_internal_thread_state
->
public_thread_state
);
...
@@ -438,7 +392,6 @@ static void wait_for_thread_shutdown(void) noexcept {
...
@@ -438,7 +392,6 @@ static void wait_for_thread_shutdown(void) noexcept {
void
finishMainThread
()
{
void
finishMainThread
()
{
assert
(
current_internal_thread_state
);
assert
(
current_internal_thread_state
);
current_internal_thread_state
->
assertNoGenerators
();
wait_for_thread_shutdown
();
wait_for_thread_shutdown
();
}
}
...
...
src/core/threading.h
View file @
40fa7ef7
...
@@ -47,13 +47,6 @@ void finishMainThread();
...
@@ -47,13 +47,6 @@ void finishMainThread();
bool
isMainThread
();
bool
isMainThread
();
// Some hooks to keep track of the list of stacks that this thread has been using.
// Every time we switch to a new generator, we need to pass a reference to the generator
// itself (so we can access the registers it is saving), the location of the new stack, and
// where we stopped executing on the old stack.
void
pushGenerator
(
BoxedGenerator
*
g
,
void
*
new_stack_start
,
void
*
old_stack_limit
);
void
popGenerator
();
#ifndef THREADING_USE_GIL
#ifndef THREADING_USE_GIL
#define THREADING_USE_GIL 1
#define THREADING_USE_GIL 1
#define THREADING_USE_GRWL 0
#define THREADING_USE_GRWL 0
...
...
src/runtime/generator.cpp
View file @
40fa7ef7
...
@@ -92,7 +92,6 @@ void generatorEntry(BoxedGenerator* g) {
...
@@ -92,7 +92,6 @@ void generatorEntry(BoxedGenerator* g) {
assert
(
g
->
returnValue
==
Py_None
);
assert
(
g
->
returnValue
==
Py_None
);
Py_CLEAR
(
g
->
returnValue
);
Py_CLEAR
(
g
->
returnValue
);
threading
::
pushGenerator
(
g
,
g
->
stack_begin
,
g
->
returnContext
);
try
{
try
{
RegisterHelper
context_registerer
(
g
,
__builtin_frame_address
(
0
));
RegisterHelper
context_registerer
(
g
,
__builtin_frame_address
(
0
));
...
@@ -115,7 +114,6 @@ void generatorEntry(BoxedGenerator* g) {
...
@@ -115,7 +114,6 @@ void generatorEntry(BoxedGenerator* g) {
// we returned from the body of the generator. next/send/throw will notify the caller
// we returned from the body of the generator. next/send/throw will notify the caller
g
->
entryExited
=
true
;
g
->
entryExited
=
true
;
threading
::
popGenerator
();
}
}
assert
(
g
->
top_caller_frame_info
==
cur_thread_state
.
frame_info
);
assert
(
g
->
top_caller_frame_info
==
cur_thread_state
.
frame_info
);
swapContext
(
&
g
->
context
,
g
->
returnContext
,
0
);
swapContext
(
&
g
->
context
,
g
->
returnContext
,
0
);
...
@@ -333,16 +331,15 @@ Box* generatorHasnext(Box* s) {
...
@@ -333,16 +331,15 @@ Box* generatorHasnext(Box* s) {
extern
"C"
Box
*
yield_capi
(
BoxedGenerator
*
obj
,
STOLEN
(
Box
*
)
value
,
int
num_live_values
,
...)
noexcept
{
extern
"C"
Box
*
yield_capi
(
BoxedGenerator
*
obj
,
STOLEN
(
Box
*
)
value
,
int
num_live_values
,
...)
noexcept
{
try
{
try
{
llvm
::
SmallVector
<
Box
*
,
8
>
live_values
;
Box
**
live_values
=
(
Box
**
)
alloca
(
sizeof
(
Box
*
)
*
num_live_values
);
live_values
.
reserve
(
num_live_values
);
va_list
ap
;
va_list
ap
;
va_start
(
ap
,
num_live_values
);
va_start
(
ap
,
num_live_values
);
for
(
int
i
=
0
;
i
<
num_live_values
;
++
i
)
{
for
(
int
i
=
0
;
i
<
num_live_values
;
++
i
)
{
live_values
.
push_back
(
va_arg
(
ap
,
Box
*
)
);
live_values
[
i
]
=
va_arg
(
ap
,
Box
*
);
}
}
va_end
(
ap
);
va_end
(
ap
);
return
yield
(
obj
,
value
,
l
ive_values
);
return
yield
(
obj
,
value
,
l
lvm
::
makeArrayRef
(
live_values
,
num_live_values
)
);
}
catch
(
ExcInfo
e
)
{
}
catch
(
ExcInfo
e
)
{
setCAPIException
(
e
);
setCAPIException
(
e
);
return
NULL
;
return
NULL
;
...
@@ -357,8 +354,6 @@ extern "C" Box* yield(BoxedGenerator* obj, STOLEN(Box*) value, llvm::ArrayRef<Bo
...
@@ -357,8 +354,6 @@ extern "C" Box* yield(BoxedGenerator* obj, STOLEN(Box*) value, llvm::ArrayRef<Bo
assert
(
!
self
->
returnValue
);
assert
(
!
self
->
returnValue
);
self
->
returnValue
=
value
;
self
->
returnValue
=
value
;
threading
::
popGenerator
();
FrameInfo
*
generator_frame_info
=
(
FrameInfo
*
)
cur_thread_state
.
frame_info
;
FrameInfo
*
generator_frame_info
=
(
FrameInfo
*
)
cur_thread_state
.
frame_info
;
// a generator will only switch back (yield/unhandled exception) to its caller when it is one frame away from the
// a generator will only switch back (yield/unhandled exception) to its caller when it is one frame away from the
// caller
// caller
...
@@ -384,8 +379,6 @@ extern "C" Box* yield(BoxedGenerator* obj, STOLEN(Box*) value, llvm::ArrayRef<Bo
...
@@ -384,8 +379,6 @@ extern "C" Box* yield(BoxedGenerator* obj, STOLEN(Box*) value, llvm::ArrayRef<Bo
}
}
cur_thread_state
.
frame_info
=
generator_frame_info
;
cur_thread_state
.
frame_info
=
generator_frame_info
;
threading
::
pushGenerator
(
obj
,
obj
->
stack_begin
,
obj
->
returnContext
);
// if the generator receives a exception from the caller we have to throw it
// if the generator receives a exception from the caller we have to throw it
if
(
self
->
exception
.
type
)
{
if
(
self
->
exception
.
type
)
{
ExcInfo
e
=
self
->
exception
;
ExcInfo
e
=
self
->
exception
;
...
...
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