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
5b3e6adf
Commit
5b3e6adf
authored
Jul 10, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #681 from undingen/small_fixes_bjit
Small fixes for the baseline JIT
parents
94687bdb
28359b7f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
25 deletions
+96
-25
src/asm_writing/icinfo.cpp
src/asm_writing/icinfo.cpp
+2
-2
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+28
-22
src/codegen/baseline_jit.cpp
src/codegen/baseline_jit.cpp
+6
-1
test/tests/incremental_tb_bjit.py
test/tests/incremental_tb_bjit.py
+60
-0
No files found.
src/asm_writing/icinfo.cpp
View file @
5b3e6adf
...
...
@@ -206,7 +206,7 @@ ICInfo::ICInfo(void* start_addr, void* slowpath_rtn_addr, void* continue_addr, S
}
}
static
std
::
unordered_m
ap
<
void
*
,
ICInfo
*>
ics_by_return_addr
;
static
llvm
::
DenseM
ap
<
void
*
,
ICInfo
*>
ics_by_return_addr
;
std
::
unique_ptr
<
ICInfo
>
registerCompiledPatchpoint
(
uint8_t
*
start_addr
,
uint8_t
*
slowpath_start_addr
,
uint8_t
*
continue_addr
,
uint8_t
*
slowpath_rtn_addr
,
const
ICSetupInfo
*
ic
,
StackInfo
stack_info
,
...
...
@@ -263,7 +263,7 @@ void deregisterCompiledPatchpoint(ICInfo* ic) {
ICInfo
*
getICInfo
(
void
*
rtn_addr
)
{
// TODO: load this from the CF instead of tracking it separately
std
::
unordered_map
<
void
*
,
ICInfo
*>::
iterator
it
=
ics_by_return_addr
.
find
(
rtn_addr
);
auto
&&
it
=
ics_by_return_addr
.
find
(
rtn_addr
);
if
(
it
==
ics_by_return_addr
.
end
())
return
NULL
;
return
it
->
second
;
...
...
src/codegen/ast_interpreter.cpp
View file @
5b3e6adf
...
...
@@ -91,7 +91,6 @@ public:
__attribute__
((
__no_inline__
))
__attribute__
((
noinline
))
static
Value
executeInner
(
ASTInterpreter
&
interpreter
,
CFGBlock
*
start_block
,
AST_stmt
*
start_at
,
RegisterHelper
*
reg
);
private:
Box
*
createFunction
(
AST
*
node
,
AST_arguments
*
args
,
const
std
::
vector
<
AST_stmt
*>&
body
);
Value
doBinOp
(
Value
left
,
Value
right
,
int
op
,
BinExpType
exp_type
);
...
...
@@ -148,6 +147,8 @@ private:
void
startJITing
(
CFGBlock
*
block
,
int
exit_offset
=
0
);
void
abortJITing
();
void
finishJITing
(
CFGBlock
*
continue_block
=
NULL
);
// This method is not allowed to get inlined into 'executeInner' otherwise tracebacks are wrong.
__attribute__
((
__no_inline__
))
__attribute__
((
noinline
))
Box
*
execJITedBlock
(
CFGBlock
*
b
);
// this variables are used by the baseline JIT, make sure they have an offset < 0x80 so we can use shorter
// instructions
...
...
@@ -374,6 +375,27 @@ void ASTInterpreter::finishJITing(CFGBlock* continue_block) {
startJITing
(
continue_block
,
exit_offset
);
}
Box
*
ASTInterpreter
::
execJITedBlock
(
CFGBlock
*
b
)
{
try
{
UNAVOIDABLE_STAT_TIMER
(
t0
,
"us_timer_in_baseline_jitted_code"
);
std
::
pair
<
CFGBlock
*
,
Box
*>
rtn
=
b
->
entry_code
(
this
,
b
);
next_block
=
rtn
.
first
;
if
(
!
next_block
)
return
rtn
.
second
;
}
catch
(
ExcInfo
e
)
{
AST_stmt
*
stmt
=
getCurrentStatement
();
if
(
stmt
->
type
!=
AST_TYPE
::
Invoke
)
throw
e
;
auto
source
=
getCF
()
->
clfunc
->
source
.
get
();
exceptionCaughtInInterpreter
(
LineInfo
(
stmt
->
lineno
,
stmt
->
col_offset
,
source
->
fn
,
source
->
getName
()),
&
e
);
next_block
=
((
AST_Invoke
*
)
stmt
)
->
exc_dest
;
last_exception
=
e
;
}
return
nullptr
;
}
Value
ASTInterpreter
::
executeInner
(
ASTInterpreter
&
interpreter
,
CFGBlock
*
start_block
,
AST_stmt
*
start_at
,
RegisterHelper
*
reg
)
{
...
...
@@ -428,26 +450,10 @@ Value ASTInterpreter::executeInner(ASTInterpreter& interpreter, CFGBlock* start_
CFGBlock
*
b
=
interpreter
.
current_block
;
if
(
b
->
entry_code
)
{
should_jit
=
true
;
try
{
UNAVOIDABLE_STAT_TIMER
(
t0
,
"us_timer_in_baseline_jitted_code"
);
std
::
pair
<
CFGBlock
*
,
Box
*>
rtn
=
b
->
entry_code
(
&
interpreter
,
b
);
interpreter
.
next_block
=
rtn
.
first
;
if
(
!
interpreter
.
next_block
)
return
Value
(
rtn
.
second
,
0
);
}
catch
(
ExcInfo
e
)
{
AST_stmt
*
stmt
=
interpreter
.
getCurrentStatement
();
if
(
stmt
->
type
!=
AST_TYPE
::
Invoke
)
throw
e
;
auto
source
=
interpreter
.
getCF
()
->
clfunc
->
source
.
get
();
exceptionCaughtInInterpreter
(
LineInfo
(
stmt
->
lineno
,
stmt
->
col_offset
,
source
->
fn
,
source
->
getName
()),
&
e
);
interpreter
.
next_block
=
((
AST_Invoke
*
)
stmt
)
->
exc_dest
;
interpreter
.
last_exception
=
e
;
}
continue
;
Box
*
rtn
=
interpreter
.
execJITedBlock
(
b
);
if
(
interpreter
.
next_block
)
continue
;
return
Value
(
rtn
,
nullptr
);
}
}
...
...
@@ -1604,7 +1610,7 @@ Box* ASTInterpreterJitInterface::getLocalHelper(void* _interpreter, InternedStri
Box
*
ASTInterpreterJitInterface
::
landingpadHelper
(
void
*
_interpreter
)
{
ASTInterpreter
*
interpreter
=
(
ASTInterpreter
*
)
_interpreter
;
aut
o
&
last_exception
=
interpreter
->
last_exception
;
ExcInf
o
&
last_exception
=
interpreter
->
last_exception
;
Box
*
type
=
last_exception
.
type
;
Box
*
value
=
last_exception
.
value
?
last_exception
.
value
:
None
;
Box
*
traceback
=
last_exception
.
traceback
?
last_exception
.
traceback
:
None
;
...
...
src/codegen/baseline_jit.cpp
View file @
5b3e6adf
...
...
@@ -203,7 +203,11 @@ RewriterVar* JitFragmentWriter::emitCreateList(const llvm::ArrayRef<RewriterVar*
}
RewriterVar
*
JitFragmentWriter
::
emitCreateSet
(
const
llvm
::
ArrayRef
<
RewriterVar
*>
values
)
{
return
call
(
false
,
(
void
*
)
createSetHelper
,
imm
(
values
.
size
()),
allocArgs
(
values
));
auto
num
=
values
.
size
();
if
(
num
==
0
)
return
call
(
false
,
(
void
*
)
createSet
);
else
return
call
(
false
,
(
void
*
)
createSetHelper
,
imm
(
num
),
allocArgs
(
values
));
}
RewriterVar
*
JitFragmentWriter
::
emitCreateSlice
(
RewriterVar
*
start
,
RewriterVar
*
stop
,
RewriterVar
*
step
)
{
...
...
@@ -532,6 +536,7 @@ bool JitFragmentWriter::finishAssembly(int continue_offset) {
RewriterVar
*
JitFragmentWriter
::
allocArgs
(
const
llvm
::
ArrayRef
<
RewriterVar
*>
args
)
{
auto
num
=
args
.
size
();
assert
(
num
);
RewriterVar
*
array
=
allocate
(
num
);
for
(
int
i
=
0
;
i
<
num
;
++
i
)
array
->
setAttr
(
sizeof
(
void
*
)
*
i
,
args
[
i
]);
...
...
test/tests/incremental_tb_bjit.py
0 → 100644
View file @
5b3e6adf
# This is the same as incremental_tb_bjit.py but tests the baseline JIT.
try
:
import
__pyston__
__pyston__
.
setOption
(
"REOPT_THRESHOLD_INTERPRETER"
,
1
)
except
:
pass
import
traceback
import
sys
def
f
():
a
,
b
,
c
=
sys
.
exc_info
()
raise
a
,
b
,
c
et0
,
ev0
,
tb0
=
None
,
None
,
None
try
:
1
/
0
except
:
pass
for
i
in
xrange
(
10
):
try
:
f
()
except
:
et0
,
ev0
,
tb0
=
sys
.
exc_info
()
print
"******** 0"
,
''
.
join
(
traceback
.
format_exception
(
et0
,
ev0
,
tb0
))
et1
,
ev1
,
tb1
=
None
,
None
,
None
et2
,
ev2
,
tb2
=
None
,
None
,
None
def
f1
():
raise
def
f2
():
f1
()
def
f21
():
raise
Exception
()
def
f3
():
try
:
f21
()
except
:
global
et1
,
tv1
,
tb1
et1
,
tv1
,
tb1
=
sys
.
exc_info
()
f2
()
try
:
f3
()
except
:
et2
,
tv2
,
tb2
=
sys
.
exc_info
()
print
"******** 1"
,
''
.
join
(
traceback
.
format_exception
(
et1
,
ev1
,
tb1
))
print
"******** 2"
,
''
.
join
(
traceback
.
format_exception
(
et2
,
ev2
,
tb2
))
print
et1
is
et2
print
ev1
is
ev2
print
tb1
is
tb2
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