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
82c402a6
Commit
82c402a6
authored
Jul 22, 2016
by
Marius Wachtler
Committed by
GitHub
Jul 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1306 from undingen/generator_opt
generator optimizations
parents
99719a45
d9b5310f
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
116 deletions
+85
-116
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
+84
-61
src/runtime/generator.h
src/runtime/generator.h
+1
-1
No files found.
src/core/threading.cpp
View file @
82c402a6
...
...
@@ -83,24 +83,6 @@ private:
public:
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
;
PyThreadState
*
public_thread_state
;
...
...
@@ -137,36 +119,10 @@ public:
}
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
__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
static
int
signals_waiting
(
0
);
...
...
@@ -243,8 +199,6 @@ static void tstate_delete_common(PyThreadState* tstate) {
}
static
void
unregisterThread
()
{
current_internal_thread_state
->
assertNoGenerators
();
tstate_delete_common
(
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 {
void
finishMainThread
()
{
assert
(
current_internal_thread_state
);
current_internal_thread_state
->
assertNoGenerators
();
wait_for_thread_shutdown
();
}
...
...
src/core/threading.h
View file @
82c402a6
...
...
@@ -47,13 +47,6 @@ void finishMainThread();
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
#define THREADING_USE_GIL 1
#define THREADING_USE_GRWL 0
...
...
src/runtime/generator.cpp
View file @
82c402a6
This diff is collapsed.
Click to expand it.
src/runtime/generator.h
View file @
82c402a6
...
...
@@ -26,7 +26,7 @@ struct Context;
extern
BoxedClass
*
generator_cls
;
void
setupGenerator
();
void
generatorEntry
(
BoxedGenerator
*
g
);
void
generatorEntry
(
BoxedGenerator
*
g
)
noexcept
;
Context
*
getReturnContextForGeneratorFrame
(
void
*
frame_addr
);
extern
"C"
Box
*
yield
(
BoxedGenerator
*
obj
,
STOLEN
(
Box
*
)
value
,
llvm
::
ArrayRef
<
Box
*>
live_values
=
{});
...
...
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