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
9a8eaf07
Commit
9a8eaf07
authored
Mar 15, 2016
by
Marius Wachtler
1
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1123 from undingen/exc_capi_problem
fix two python frame handling crashes
parents
7b941863
ac7fe907
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
376 additions
and
532 deletions
+376
-532
section_ordering.txt
section_ordering.txt
+329
-520
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+5
-9
src/codegen/ast_interpreter.h
src/codegen/ast_interpreter.h
+3
-2
src/codegen/ast_interpreter_exec.S
src/codegen/ast_interpreter_exec.S
+26
-1
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+1
-0
test/tests/exceptions_test2.py
test/tests/exceptions_test2.py
+12
-0
No files found.
section_ordering.txt
View file @
9a8eaf07
This diff is collapsed.
Click to expand it.
src/codegen/ast_interpreter.cpp
View file @
9a8eaf07
...
...
@@ -1857,10 +1857,11 @@ Box* astInterpretFunctionEval(FunctionMetadata* md, Box* globals, Box* boxedLoca
return
v
?
v
:
None
;
}
static
Box
*
astInterpretDeoptInner
(
FunctionMetadata
*
md
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
FrameStackState
frame_state
)
__attribute__
((
noinline
));
static
Box
*
astInterpretDeoptInner
(
FunctionMetadata
*
md
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
FrameStackState
frame_state
)
{
// caution when changing the function arguments: this function gets called from an assembler wrapper!
extern
"C"
Box
*
astInterpretDeoptFromASM
(
FunctionMetadata
*
md
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
FrameStackState
frame_state
)
{
static_assert
(
sizeof
(
FrameStackState
)
<=
2
*
8
,
"astInterpretDeopt assumes that all args get passed in regs!"
);
assert
(
md
);
assert
(
enclosing_stmt
);
assert
(
frame_state
.
locals
);
...
...
@@ -1958,11 +1959,6 @@ static Box* astInterpretDeoptInner(FunctionMetadata* md, AST_expr* after_expr, A
return
v
?
v
:
None
;
}
Box
*
astInterpretDeopt
(
FunctionMetadata
*
md
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
FrameStackState
frame_state
)
{
return
astInterpretDeoptInner
(
md
,
after_expr
,
enclosing_stmt
,
expr_val
,
frame_state
);
}
extern
"C"
void
printExprHelper
(
Box
*
obj
)
{
Box
*
displayhook
=
PySys_GetObject
(
"displayhook"
);
if
(
!
displayhook
)
...
...
src/codegen/ast_interpreter.h
View file @
9a8eaf07
...
...
@@ -77,8 +77,9 @@ struct Value {
Box
*
astInterpretFunction
(
FunctionMetadata
*
f
,
Box
*
closure
,
Box
*
generator
,
Box
*
globals
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
);
Box
*
astInterpretFunctionEval
(
FunctionMetadata
*
cf
,
Box
*
globals
,
Box
*
boxedLocals
);
Box
*
astInterpretDeopt
(
FunctionMetadata
*
cf
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
FrameStackState
frame_state
);
// this function is implemented in the src/codegen/ast_interpreter_exec.S assembler file
extern
"C"
Box
*
astInterpretDeopt
(
FunctionMetadata
*
cf
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
FrameStackState
frame_state
);
struct
FrameInfo
;
FrameInfo
*
getFrameInfoForInterpretedFrame
(
void
*
frame_ptr
);
...
...
src/codegen/ast_interpreter_exec.S
View file @
9a8eaf07
...
...
@@ -32,11 +32,36 @@ executeInnerAndSetupFrame:
sub
$
16
,
%
rsp
mov
%
rdi
,
-
8
(%
rbp
)
call
executeInnerFromASM
leave
add
$
16
,
%
rsp
pop
%
rbp
.
cfi_def_cfa
rsp
,
8
ret
.
cfi_endproc
.
size
executeInnerAndSetupFrame
,.-
executeInnerAndSetupFrame
//
This
function
is
just
a
small
wrapper
around
astInterpretDeoptFromASM
.
//
Our
unwinder
must
be
able
to
detect
deopt
frames
and
by
writting
this
wrapper
in
assembler
we
can
be
sure
to
correctly
//
detect
the
frame
independent
of
compiler
optimizations
because
this
function
will
always
appear
in
the
call
stack
.
//
//
Box
*
astInterpretDeopt
(
FunctionMetadata
*
cf
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
//
FrameStackState
frame_state
)
;
.
text
.
globl
astInterpretDeopt
.
type
astInterpretDeopt
,@
function
.
align
16
astInterpretDeopt
:
.
cfi_startproc
push
%
rbp
.
cfi_def_cfa_offset
16
.
cfi_offset
rbp
,-
16
mov
%
rsp
,
%
rbp
.
cfi_def_cfa_register
rbp
call
astInterpretDeoptFromASM
pop
%
rbp
.
cfi_def_cfa
rsp
,
8
ret
.
cfi_endproc
.
size
astInterpretDeopt
,.-
astInterpretDeopt
.
section
.
note.GNU
-
stack
,"",%
progbits
//
we
don
't need executable stack
src/codegen/irgen/irgenerator.cpp
View file @
9a8eaf07
...
...
@@ -3058,6 +3058,7 @@ public:
// just not created an Invoke and let the exception machinery propagate it for us.
assert
(
irstate
->
getExceptionStyle
()
==
CAPI
);
builder
->
CreateCall3
(
g
.
funcs
.
PyErr_Restore
,
exc_type
,
exc_value
,
exc_traceback
);
builder
->
CreateCall
(
g
.
funcs
.
deinitFrame
,
irstate
->
getFrameInfoVar
());
builder
->
CreateRet
(
getNullPtr
(
g
.
llvm_value_type_ptr
));
}
...
...
test/tests/exceptions_test2.py
0 → 100644
View file @
9a8eaf07
# this test caused crashes because of a missing deinitFrame call in the LLVM tier when compiling funcs in CAPI mode
def
next
(
x
):
1
/
x
def
foo
(
x
):
try
:
next
(
x
)
except
Exception
as
e
:
print
"exc"
,
e
foo
(
1
)
foo
(
0
)
Boxiang Sun
@Daetalus
mentioned in commit
84e3eeb8
·
Sep 08, 2016
mentioned in commit
84e3eeb8
mentioned in commit 84e3eeb8b37084dd76df06a251a5610bfcb22fc3
Toggle commit list
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