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
f8283fb1
Commit
f8283fb1
authored
Jul 10, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reenable type speculation
parent
b0555285
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
29 additions
and
31 deletions
+29
-31
src/analysis/type_analysis.cpp
src/analysis/type_analysis.cpp
+1
-8
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+2
-2
src/codegen/ast_interpreter.h
src/codegen/ast_interpreter.h
+2
-2
src/codegen/irgen/hooks.cpp
src/codegen/irgen/hooks.cpp
+12
-0
src/codegen/type_recording.h
src/codegen/type_recording.h
+1
-0
src/codegen/unwinding.cpp
src/codegen/unwinding.cpp
+7
-5
src/core/types.h
src/core/types.h
+3
-2
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+1
-9
test/tests/deopt_generator_tests.py
test/tests/deopt_generator_tests.py
+0
-1
test/tests/deopt_namescope_tests.py
test/tests/deopt_namescope_tests.py
+0
-1
test/tests/deopt_tests.py
test/tests/deopt_tests.py
+0
-1
No files found.
src/analysis/type_analysis.cpp
View file @
f8283fb1
...
@@ -74,10 +74,7 @@ static BoxedClass* simpleCallSpeculation(AST_Call* node, CompilerType* rtn_type,
...
@@ -74,10 +74,7 @@ static BoxedClass* simpleCallSpeculation(AST_Call* node, CompilerType* rtn_type,
if
(
node
->
func
->
type
==
AST_TYPE
::
Name
&&
ast_cast
<
AST_Name
>
(
node
->
func
)
->
id
.
s
()
==
"xrange"
)
if
(
node
->
func
->
type
==
AST_TYPE
::
Name
&&
ast_cast
<
AST_Name
>
(
node
->
func
)
->
id
.
s
()
==
"xrange"
)
return
xrange_cls
;
return
xrange_cls
;
// if (node->func->type == AST_TYPE::Attribute && ast_cast<AST_Attribute>(node->func)->attr == "dot")
return
predictClassFor
(
node
);
// return float_cls;
return
NULL
;
}
}
typedef
llvm
::
DenseMap
<
InternedString
,
CompilerType
*>
TypeMap
;
typedef
llvm
::
DenseMap
<
InternedString
,
CompilerType
*>
TypeMap
;
...
@@ -115,10 +112,6 @@ private:
...
@@ -115,10 +112,6 @@ private:
assert
(
old_type
);
assert
(
old_type
);
assert
(
speculation
!=
TypeAnalysis
::
NONE
);
assert
(
speculation
!=
TypeAnalysis
::
NONE
);
if
(
VERBOSITY
()
>=
3
)
printf
(
"Would maybe try to speculate but deopt is currently broken
\n
"
);
return
old_type
;
if
(
speculated_cls
!=
NULL
&&
speculated_cls
->
is_constant
)
{
if
(
speculated_cls
!=
NULL
&&
speculated_cls
->
is_constant
)
{
ConcreteCompilerType
*
speculated_type
=
unboxedType
(
typeFromClass
(
speculated_cls
));
ConcreteCompilerType
*
speculated_type
=
unboxedType
(
typeFromClass
(
speculated_cls
));
if
(
VERBOSITY
()
>=
2
)
{
if
(
VERBOSITY
()
>=
2
)
{
...
...
src/codegen/ast_interpreter.cpp
View file @
f8283fb1
...
@@ -1754,8 +1754,8 @@ Box* astInterpretFunctionEval(CLFunction* clfunc, Box* globals, Box* boxedLocals
...
@@ -1754,8 +1754,8 @@ Box* astInterpretFunctionEval(CLFunction* clfunc, Box* globals, Box* boxedLocals
return
v
.
o
?
v
.
o
:
None
;
return
v
.
o
?
v
.
o
:
None
;
}
}
Box
*
astInterpret
From
(
CLFunction
*
clfunc
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
Box
*
astInterpret
Deopt
(
CLFunction
*
clfunc
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
FrameStackState
frame_state
)
{
FrameStackState
frame_state
)
{
assert
(
clfunc
);
assert
(
clfunc
);
assert
(
enclosing_stmt
);
assert
(
enclosing_stmt
);
assert
(
frame_state
.
locals
);
assert
(
frame_state
.
locals
);
...
...
src/codegen/ast_interpreter.h
View file @
f8283fb1
...
@@ -75,8 +75,8 @@ void setupInterpreter();
...
@@ -75,8 +75,8 @@ void setupInterpreter();
Box
*
astInterpretFunction
(
CLFunction
*
f
,
int
nargs
,
Box
*
closure
,
Box
*
generator
,
Box
*
globals
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
astInterpretFunction
(
CLFunction
*
f
,
int
nargs
,
Box
*
closure
,
Box
*
generator
,
Box
*
globals
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
);
Box
*
arg3
,
Box
**
args
);
Box
*
astInterpretFunctionEval
(
CLFunction
*
cf
,
Box
*
globals
,
Box
*
boxedLocals
);
Box
*
astInterpretFunctionEval
(
CLFunction
*
cf
,
Box
*
globals
,
Box
*
boxedLocals
);
Box
*
astInterpret
From
(
CLFunction
*
cf
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
Box
*
astInterpret
Deopt
(
CLFunction
*
cf
,
AST_expr
*
after_expr
,
AST_stmt
*
enclosing_stmt
,
Box
*
expr_val
,
FrameStackState
frame_state
);
FrameStackState
frame_state
);
AST_stmt
*
getCurrentStatementForInterpretedFrame
(
void
*
frame_ptr
);
AST_stmt
*
getCurrentStatementForInterpretedFrame
(
void
*
frame_ptr
);
Box
*
getGlobalsForInterpretedFrame
(
void
*
frame_ptr
);
Box
*
getGlobalsForInterpretedFrame
(
void
*
frame_ptr
);
...
...
src/codegen/irgen/hooks.cpp
View file @
f8283fb1
...
@@ -670,6 +670,7 @@ void CompiledFunction::speculationFailed() {
...
@@ -670,6 +670,7 @@ void CompiledFunction::speculationFailed() {
CLFunction
*
cl
=
this
->
clfunc
;
CLFunction
*
cl
=
this
->
clfunc
;
assert
(
cl
);
assert
(
cl
);
assert
(
this
!=
cl
->
always_use_version
);
bool
found
=
false
;
bool
found
=
false
;
for
(
int
i
=
0
;
i
<
clfunc
->
versions
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
clfunc
->
versions
.
size
();
i
++
)
{
...
@@ -681,6 +682,17 @@ void CompiledFunction::speculationFailed() {
...
@@ -681,6 +682,17 @@ void CompiledFunction::speculationFailed() {
}
}
}
}
if
(
!
found
)
{
for
(
auto
it
=
clfunc
->
osr_versions
.
begin
();
it
!=
clfunc
->
osr_versions
.
end
();
++
it
)
{
if
(
it
->
second
==
this
)
{
clfunc
->
osr_versions
.
erase
(
it
);
this
->
dependent_callsites
.
invalidateAll
();
found
=
true
;
break
;
}
}
}
if
(
!
found
)
{
if
(
!
found
)
{
for
(
int
i
=
0
;
i
<
clfunc
->
versions
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
clfunc
->
versions
.
size
();
i
++
)
{
printf
(
"%p
\n
"
,
clfunc
->
versions
[
i
]);
printf
(
"%p
\n
"
,
clfunc
->
versions
[
i
]);
...
...
src/codegen/type_recording.h
View file @
f8283fb1
...
@@ -30,6 +30,7 @@ class TypeRecorder;
...
@@ -30,6 +30,7 @@ class TypeRecorder;
// (I think most compilers pass "this" as the argument 0 and then shift the rest of the
// (I think most compilers pass "this" as the argument 0 and then shift the rest of the
// arguments, but I'd rather not depend on that behavior since I can't find where that's
// arguments, but I'd rather not depend on that behavior since I can't find where that's
// specified.)
// specified.)
// The return value of this function is 'obj' for ease of use.
extern
"C"
Box
*
recordType
(
TypeRecorder
*
recorder
,
Box
*
obj
);
extern
"C"
Box
*
recordType
(
TypeRecorder
*
recorder
,
Box
*
obj
);
class
TypeRecorder
{
class
TypeRecorder
{
private:
private:
...
...
src/codegen/unwinding.cpp
View file @
f8283fb1
...
@@ -426,9 +426,11 @@ static bool inGeneratorEntry(unw_word_t ip) {
...
@@ -426,9 +426,11 @@ static bool inGeneratorEntry(unw_word_t ip) {
return
((
unw_word_t
)
generatorEntry
<
ip
&&
ip
<=
generator_entry_end
);
return
((
unw_word_t
)
generatorEntry
<
ip
&&
ip
<=
generator_entry_end
);
}
}
static
bool
inDeopt
(
unw_word_t
ip
)
{
static
bool
isDeopt
(
unw_word_t
ip
)
{
static
unw_word_t
deopt_end
=
getFunctionEnd
((
unw_word_t
)
deopt
);
// Check for astInterpretDeopt() instead of deopt(), since deopt() will do some
return
((
unw_word_t
)
deopt
<
ip
&&
ip
<=
deopt_end
);
// unwinding and we don't want it to skip things.
static
unw_word_t
deopt_end
=
getFunctionEnd
((
unw_word_t
)
astInterpretDeopt
);
return
((
unw_word_t
)
astInterpretDeopt
<
ip
&&
ip
<=
deopt_end
);
}
}
...
@@ -626,7 +628,7 @@ void unwindingThroughFrame(PythonUnwindSession* unwind_session, unw_cursor_t* cu
...
@@ -626,7 +628,7 @@ void unwindingThroughFrame(PythonUnwindSession* unwind_session, unw_cursor_t* cu
unw_word_t
bp
=
get_cursor_bp
(
cursor
);
unw_word_t
bp
=
get_cursor_bp
(
cursor
);
PythonFrameIteratorImpl
frame_iter
;
PythonFrameIteratorImpl
frame_iter
;
if
(
i
n
Deopt
(
ip
))
{
if
(
i
s
Deopt
(
ip
))
{
assert
(
!
unwind_session
->
shouldSkipFrame
());
assert
(
!
unwind_session
->
shouldSkipFrame
());
unwind_session
->
setShouldSkipNextFrame
(
true
);
unwind_session
->
setShouldSkipNextFrame
(
true
);
}
else
if
(
frameIsPythonFrame
(
ip
,
bp
,
cursor
,
&
frame_iter
))
{
}
else
if
(
frameIsPythonFrame
(
ip
,
bp
,
cursor
,
&
frame_iter
))
{
...
@@ -667,7 +669,7 @@ template <typename Func> void unwindPythonStack(Func func) {
...
@@ -667,7 +669,7 @@ template <typename Func> void unwindPythonStack(Func func) {
bool
stop_unwinding
=
false
;
bool
stop_unwinding
=
false
;
PythonFrameIteratorImpl
frame_iter
;
PythonFrameIteratorImpl
frame_iter
;
if
(
i
n
Deopt
(
ip
))
{
if
(
i
s
Deopt
(
ip
))
{
assert
(
!
unwind_session
->
shouldSkipFrame
());
assert
(
!
unwind_session
->
shouldSkipFrame
());
unwind_session
->
setShouldSkipNextFrame
(
true
);
unwind_session
->
setShouldSkipNextFrame
(
true
);
}
else
if
(
frameIsPythonFrame
(
ip
,
bp
,
&
cursor
,
&
frame_iter
))
{
}
else
if
(
frameIsPythonFrame
(
ip
,
bp
,
&
cursor
,
&
frame_iter
))
{
...
...
src/core/types.h
View file @
f8283fb1
...
@@ -347,8 +347,9 @@ public:
...
@@ -347,8 +347,9 @@ public:
compiled
->
clfunc
=
this
;
compiled
->
clfunc
=
this
;
if
(
compiled
->
entry_descriptor
==
NULL
)
{
if
(
compiled
->
entry_descriptor
==
NULL
)
{
if
(
versions
.
size
()
==
0
&&
compiled
->
effort
==
EffortLevel
::
MAXIMAL
&&
compiled
->
spec
->
accepts_all_inputs
bool
could_have_speculations
=
(
source
.
get
()
!=
NULL
);
&&
compiled
->
spec
->
boxed_return_value
)
if
(
!
could_have_speculations
&&
versions
.
size
()
==
0
&&
compiled
->
effort
==
EffortLevel
::
MAXIMAL
&&
compiled
->
spec
->
accepts_all_inputs
&&
compiled
->
spec
->
boxed_return_value
)
always_use_version
=
compiled
;
always_use_version
=
compiled
;
assert
(
compiled
->
spec
->
arg_types
.
size
()
==
paramspec
.
totalReceived
());
assert
(
compiled
->
spec
->
arg_types
.
size
()
==
paramspec
.
totalReceived
());
...
...
src/runtime/objmodel.cpp
View file @
f8283fb1
...
@@ -169,14 +169,6 @@ extern "C" Box* deopt(AST_expr* expr, Box* value) {
...
@@ -169,14 +169,6 @@ extern "C" Box* deopt(AST_expr* expr, Box* value) {
static
StatCounter
num_deopt
(
"num_deopt"
);
static
StatCounter
num_deopt
(
"num_deopt"
);
num_deopt
.
log
();
num_deopt
.
log
();
printf
(
"Deopt!
\n
"
);
print_ast
(
expr
);
printf
(
"
\n
"
);
dump
(
value
);
printf
(
"
\n
"
);
RELEASE_ASSERT
(
0
,
"deopt is currently broken..."
);
auto
deopt_state
=
getDeoptState
();
auto
deopt_state
=
getDeoptState
();
// Should we only do this selectively?
// Should we only do this selectively?
...
@@ -189,7 +181,7 @@ extern "C" Box* deopt(AST_expr* expr, Box* value) {
...
@@ -189,7 +181,7 @@ extern "C" Box* deopt(AST_expr* expr, Box* value) {
deopt_state
.
frame_state
.
frame_info
->
exc
.
value
=
NULL
;
deopt_state
.
frame_state
.
frame_info
->
exc
.
value
=
NULL
;
}
}
return
astInterpret
From
(
deopt_state
.
cf
->
clfunc
,
expr
,
deopt_state
.
current_stmt
,
value
,
deopt_state
.
frame_state
);
return
astInterpret
Deopt
(
deopt_state
.
cf
->
clfunc
,
expr
,
deopt_state
.
current_stmt
,
value
,
deopt_state
.
frame_state
);
}
}
extern
"C"
bool
softspace
(
Box
*
b
,
bool
newval
)
{
extern
"C"
bool
softspace
(
Box
*
b
,
bool
newval
)
{
...
...
test/tests/deopt_generator_tests.py
View file @
f8283fb1
# skip-if: '-O' in EXTRA_JIT_ARGS
# skip-if: '-O' in EXTRA_JIT_ARGS
# expected: statfail
# statcheck: 4 <= noninit_count('num_deopt') < 50
# statcheck: 4 <= noninit_count('num_deopt') < 50
# statcheck: 1 <= stats["num_osr_exits"] <= 2
# statcheck: 1 <= stats["num_osr_exits"] <= 2
...
...
test/tests/deopt_namescope_tests.py
View file @
f8283fb1
# skip-if: '-O' in EXTRA_JIT_ARGS
# skip-if: '-O' in EXTRA_JIT_ARGS
# expected: statfail
# statcheck: 4 <= noninit_count('num_deopt') < 50
# statcheck: 4 <= noninit_count('num_deopt') < 50
# statcheck: 1 <= stats["num_osr_exits"] <= 2
# statcheck: 1 <= stats["num_osr_exits"] <= 2
...
...
test/tests/deopt_tests.py
View file @
f8283fb1
# skip-if: '-O' in EXTRA_JIT_ARGS
# skip-if: '-O' in EXTRA_JIT_ARGS
# expected: statfail
# statcheck: 4 <= noninit_count('num_deopt') < 50
# statcheck: 4 <= noninit_count('num_deopt') < 50
# statcheck: 1 <= stats["num_osr_exits"] <= 2
# statcheck: 1 <= stats["num_osr_exits"] <= 2
...
...
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