-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-17611. Move unwinding of stack for "pseudo exceptions" from interpreter to compiler. #5006
Merged
serhiy-storchaka
merged 85 commits into
python:master
from
serhiy-storchaka:unwind_stack
Feb 22, 2018
Merged
Changes from 1 commit
Commits
Show all changes
85 commits
Select commit
Hold shift + click to select a range
2315076
bpo-17611: Move unwinding of stack from interpreter to compiler
pitrou b160900
Cleanup
pitrou 9833631
Improve stack size calculation for SETUP_{EXCEPT,FINALLY}
pitrou 9116fb8
Update frozen importlib
pitrou 5b3796e
Remove useless code
pitrou 77caab0
Don't predict FOR_ITER as it breaks tracing without computed gotos
pitrou 9fffb61
Remove dead code and fix tracing tests
pitrou 5fe5e1b
Fix test_dis
pitrou a93f2e2
Add JUMP_FINALLY to avoid finally block duplication
pitrou b007b1c
Remove finally block duplication
pitrou 0bcf8a7
More precise computation of code object stack size
pitrou eecf02f
JUMP_FINALLY pushes 6 values to be consistent with the effect of an e…
pitrou 64225ce
Exact stack size computation by popping stale exception state in RERAISE
pitrou 04e055e
Remove the now pointless POP_MANY
pitrou a3e1b80
Add comment for RERAISE
pitrou a049635
Remove JUMP_FINALLY
pitrou 0741d02
Remove last block duplication
pitrou 5493616
Get rid of END_ITER
pitrou 5c68acf
Fix comments in frameobject.c
pitrou 2d41c17
Add stack size tests
pitrou afc2235
Fix test_dis.
serhiy-storchaka 00a6681
Simplify handling of 'for' loops in frame_setlineno() and fix it for …
serhiy-storchaka f8cc274
Do not duplicate the finally block.
serhiy-storchaka 160ce37
Refactor the frame unwinding code.
serhiy-storchaka b3b3250
Refactoring and optimizations in the compiler.
serhiy-storchaka e3f5099
Fix frame_setlineno().
serhiy-storchaka d8dd38d
Rename PUSH_NO_EXCEPT to BEGIN_FINALLY.
serhiy-storchaka f1d0bc9
Restore SETUP_WITH and SETUP_ASYNC_WITH.
serhiy-storchaka 84c6400
Fix stack depth calculation.
serhiy-storchaka 35bd61b
Remove SETUP_EXCEPT.
serhiy-storchaka 191f2da
Fix rebase error.
serhiy-storchaka f1a478d
Change codes of new instructions.
serhiy-storchaka f44d8cd
Update the magic number.
serhiy-storchaka 93ca80e
Remove debug print.
serhiy-storchaka c8b9129
Polishing.
serhiy-storchaka e7d03f3
Document changes.
serhiy-storchaka 9273f10
Make CALL_FINALLY a jump instruction, but exclude it from stack depth…
serhiy-storchaka 4ffb02f
Merge branch 'master' into unwind_stack
serhiy-storchaka b0ea014
Fix jump tests: jumping into a while block is possible now.
serhiy-storchaka bef9131
Polishing.
serhiy-storchaka 7fc9111
Fix unrolling the finally block.
serhiy-storchaka 800df5c
Optimize 'return' with constant value.
serhiy-storchaka cb806c5
Do not eliminate END_FINALLY in peepholer.
serhiy-storchaka c0623d6
Minimize changes in PyCompile_OpcodeStackEffect().
serhiy-storchaka 69d6900
Document POP_FINALLY and add tests for 'break' and 'return' in 'final…
serhiy-storchaka c879d2e
Polishing.
serhiy-storchaka 894a1f7
Minimize changes in WITH_CLEANUP_START and WITH_CLEANUP_START.
serhiy-storchaka dc6eae4
Address review comments.
serhiy-storchaka 88a9050
Disable FOR_ITER jump optimization.
serhiy-storchaka ed175f3
Reorder tests.
serhiy-storchaka 4485924
Merge branch 'master' into unwind_stack
serhiy-storchaka b49d46e
Merge branch 'master' into unwind_stack
serhiy-storchaka 4ca9831
Clarify the use case of POP_FINALLY.
serhiy-storchaka e34670a
bpo-24340: Fix estimation of the code stack size.
serhiy-storchaka 42b50d1
Add new tests for stack effect (ported from #5076).
serhiy-storchaka 3d04b53
Add comments.
serhiy-storchaka 4b1697d
Simplify the algorithm, add comments and asserts.
serhiy-storchaka dc25d14
Merge branch 'master' into stack-size
serhiy-storchaka 8a327cb
Merge branch 'master' into unwind_stack
serhiy-storchaka 4afb870
Merge branch 'stack-size' into unwind_stack
serhiy-storchaka 4d81d0d
Fix stack effect computation.
serhiy-storchaka edde33a
Update comments and docs in responce to the review.
serhiy-storchaka 44c7d39
Add more tests.
serhiy-storchaka 8dcb17f
Merge branch 'stack-size' into unwind_stack_new
serhiy-storchaka 0317c9d
Add more comments.
serhiy-storchaka 7a33146
Define all stack effects in a single place.
serhiy-storchaka 68e35bb
Make stack_effect() static.
serhiy-storchaka 6056bc7
Add braces for PEP 7.
serhiy-storchaka 44e1e1e
Merge branch 'master' into stack-size
serhiy-storchaka 04647d6
Merge branch 'master' into unwind_stack
serhiy-storchaka 6d5c333
Merge branch 'stack-size' into unwind_stack
serhiy-storchaka 660a117
Add braces for PEP 7.
serhiy-storchaka a03d212
Merge branch 'master' into unwind_stack
serhiy-storchaka ff0448f
Merge branch 'master' into unwind_stack
serhiy-storchaka bd39e0a
Simplify WITH_CLEANUP_START. It is never called after CALL_FINALLY.
serhiy-storchaka 156b455
Merge branch 'master' into unwind_stack
serhiy-storchaka cd56a99
Merge branch 'master' into unwind_stack
serhiy-storchaka 0816c92
Merge branch 'master' into unwind_stack
serhiy-storchaka c161251
Merge branch 'master' into unwind_stack
serhiy-storchaka af9ddf0
Update the magic number.
serhiy-storchaka c566673
Merge branch 'master' into unwind_stack
serhiy-storchaka 9aee1f0
Merge branch 'master' into unwind_stack
serhiy-storchaka 24667a4
Merge branch 'master' into unwind_stack
serhiy-storchaka 47c5067
Merge branch 'master' into unwind_stack
serhiy-storchaka 4a63042
Merge branch 'master' into unwind_stack
serhiy-storchaka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update comments and docs in responce to the review.
- Loading branch information
commit edde33aabfba9cb198fa72d5901b74e6514c746d
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1899,6 +1899,16 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) | |
} | ||
|
||
TARGET(POP_FINALLY) { | ||
/* If oparg is 0 at the top of the stack are 1 or 6 values: | ||
Either: | ||
- TOP = NULL or an integer | ||
or: | ||
- (TOP, SECOND, THIRD) = exc_info() | ||
- (FOURTH, FITH, SIXTH) = previous exception for EXCEPT_HANDLER | ||
|
||
If oparg is 1 the value for 'return' was additionally pushed | ||
at the top of the stack. | ||
*/ | ||
PyObject *res = NULL; | ||
if (oparg) { | ||
res = POP(); | ||
|
@@ -1950,6 +1960,9 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) | |
} | ||
|
||
TARGET(BEGIN_FINALLY) { | ||
/* Push NULL onto the stack for using it in END_FINALLY, | ||
POP_FINALLY, WITH_CLEANUP_START and WITH_CLEANUP_FINISH. | ||
*/ | ||
PUSH(NULL); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explain this is in a comment here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
FAST_DISPATCH(); | ||
} | ||
|
@@ -1958,7 +1971,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) | |
TARGET(END_FINALLY) { | ||
/* At the top of the stack are 1 or 6 values: | ||
Either: | ||
- NULL or an integer | ||
- TOP = NULL or an integer | ||
or: | ||
- (TOP, SECOND, THIRD) = exc_info() | ||
- (FOURTH, FITH, SIXTH) = previous exception for EXCEPT_HANDLER | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect a similar comment as at the to top of END_FINALLY here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.