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
2f60cce3
Commit
2f60cce3
authored
Jul 31, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #788 from undingen/bjit_opt2
Small bjit improvements + fixes the build
parents
bdf0764f
dd7aa0d5
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
40 additions
and
8 deletions
+40
-8
src/codegen/baseline_jit.cpp
src/codegen/baseline_jit.cpp
+27
-2
src/codegen/baseline_jit.h
src/codegen/baseline_jit.h
+1
-0
src/codegen/codegen.cpp
src/codegen/codegen.cpp
+1
-0
src/codegen/irgen/hooks.cpp
src/codegen/irgen/hooks.cpp
+3
-1
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+1
-1
src/codegen/type_recording.cpp
src/codegen/type_recording.cpp
+3
-0
src/codegen/type_recording.h
src/codegen/type_recording.h
+1
-2
src/codegen/unwinding.cpp
src/codegen/unwinding.cpp
+2
-2
src/core/types.h
src/core/types.h
+1
-0
No files found.
src/codegen/baseline_jit.cpp
View file @
2f60cce3
...
...
@@ -668,8 +668,13 @@ RewriterVar* JitFragmentWriter::emitPPCall(void* func_addr, llvm::ArrayRef<Rewri
RewriterVar
*
result
=
createNewVar
();
addAction
([
=
]()
{
this
->
_emitPPCall
(
result
,
func_addr
,
args_vec
,
num_slots
,
slot_size
);
},
args
,
ActionType
::
NORMAL
);
if
(
type_recorder
)
return
call
(
false
,
(
void
*
)
recordType
,
imm
(
type_recorder
),
result
);
if
(
type_recorder
)
{
RewriterVar
*
type_recorder_var
=
imm
(
type_recorder
);
RewriterVar
*
obj_cls_var
=
result
->
getAttr
(
offsetof
(
Box
,
cls
));
addAction
([
=
]()
{
_emitRecordType
(
type_recorder_var
,
obj_cls_var
);
},
{
type_recorder_var
,
obj_cls_var
},
ActionType
::
NORMAL
);
return
result
;
}
return
result
;
#else
assert
(
args_vec
.
size
()
<
7
);
...
...
@@ -868,6 +873,26 @@ void JitFragmentWriter::_emitPPCall(RewriterVar* result, void* func_addr, const
result
->
releaseIfNoUses
();
}
void
JitFragmentWriter
::
_emitRecordType
(
RewriterVar
*
type_recorder_var
,
RewriterVar
*
obj_cls_var
)
{
// This directly emits the instructions of the recordType() function.
assembler
::
Register
obj_cls_reg
=
obj_cls_var
->
getInReg
();
assembler
::
Register
type_recorder_reg
=
type_recorder_var
->
getInReg
(
Location
::
any
(),
true
,
obj_cls_reg
);
assembler
::
Indirect
last_seen_count
=
assembler
::
Indirect
(
type_recorder_reg
,
offsetof
(
TypeRecorder
,
last_count
));
assembler
::
Indirect
last_seen_indirect
=
assembler
::
Indirect
(
type_recorder_reg
,
offsetof
(
TypeRecorder
,
last_seen
));
assembler
->
cmp
(
last_seen_indirect
,
obj_cls_reg
);
{
assembler
::
ForwardJump
je
(
*
assembler
,
assembler
::
COND_EQUAL
);
assembler
->
mov
(
obj_cls_reg
,
last_seen_indirect
);
assembler
->
movq
(
assembler
::
Immediate
(
0ul
),
last_seen_count
);
}
assembler
->
incl
(
last_seen_count
);
type_recorder_var
->
bumpUse
();
obj_cls_var
->
bumpUse
();
}
void
JitFragmentWriter
::
_emitReturn
(
RewriterVar
*
return_val
)
{
return_val
->
getInReg
(
assembler
::
RDX
,
true
);
assembler
->
mov
(
assembler
::
Immediate
(
0ul
),
assembler
::
RAX
);
// TODO: use xor
...
...
src/codegen/baseline_jit.h
View file @
2f60cce3
...
...
@@ -296,6 +296,7 @@ private:
void
_emitOSRPoint
(
RewriterVar
*
result
,
RewriterVar
*
node_var
);
void
_emitPPCall
(
RewriterVar
*
result
,
void
*
func_addr
,
const
RewriterVar
::
SmallVector
&
args
,
int
num_slots
,
int
slot_size
);
void
_emitRecordType
(
RewriterVar
*
type_recorder_var
,
RewriterVar
*
obj_cls_var
);
void
_emitReturn
(
RewriterVar
*
v
);
void
_emitSideExit
(
RewriterVar
*
var
,
RewriterVar
*
val_constant
,
CFGBlock
*
next_block
,
RewriterVar
*
false_path
);
};
...
...
src/codegen/codegen.cpp
View file @
2f60cce3
...
...
@@ -63,6 +63,7 @@ SourceInfo::SourceInfo(BoxedModule* m, ScopingAnalysis* scoping, FutureFlags fut
std
::
vector
<
AST_stmt
*>
body
,
std
::
string
fn
)
:
parent_module
(
m
),
scoping
(
scoping
),
scope_info
(
NULL
),
future_flags
(
future_flags
),
ast
(
ast
),
cfg
(
NULL
),
...
...
src/codegen/irgen/hooks.cpp
View file @
2f60cce3
...
...
@@ -127,7 +127,9 @@ Box* SourceInfo::getDocString() {
}
ScopeInfo
*
SourceInfo
::
getScopeInfo
()
{
return
scoping
->
getScopeInfoForNode
(
ast
);
if
(
!
scope_info
)
scope_info
=
scoping
->
getScopeInfoForNode
(
ast
);
return
scope_info
;
}
LivenessAnalysis
*
SourceInfo
::
getLiveness
()
{
...
...
src/codegen/irgen/irgenerator.cpp
View file @
2f60cce3
...
...
@@ -299,7 +299,7 @@ private:
}
void
checkAndPropagateCapiException
(
const
UnwindInfo
&
unw_info
,
llvm
::
Value
*
returned_val
,
llvm
::
Value
*
exc_val
,
bool
double_check
)
{
bool
double_check
)
override
{
assert
(
!
double_check
);
// need to call PyErr_Occurred
llvm
::
BasicBlock
*
normal_dest
...
...
src/codegen/type_recording.cpp
View file @
2f60cce3
...
...
@@ -30,6 +30,9 @@ TypeRecorder* getTypeRecorderForNode(AST* node) {
}
Box
*
recordType
(
TypeRecorder
*
self
,
Box
*
obj
)
{
// The baseline JIT directly generates machine code for this function inside JitFragmentWriter::_emitRecordType.
// When changing this function one has to also change the bjit code.
BoxedClass
*
cls
=
obj
->
cls
;
if
(
cls
!=
self
->
last_seen
)
{
self
->
last_seen
=
cls
;
...
...
src/codegen/type_recording.h
View file @
2f60cce3
...
...
@@ -33,11 +33,10 @@ class TypeRecorder;
// The return value of this function is 'obj' for ease of use.
extern
"C"
Box
*
recordType
(
TypeRecorder
*
recorder
,
Box
*
obj
);
class
TypeRecorder
{
p
rivate
:
p
ublic
:
BoxedClass
*
last_seen
;
int64_t
last_count
;
public:
constexpr
TypeRecorder
()
:
last_seen
(
nullptr
),
last_count
(
0
)
{}
BoxedClass
*
predict
();
...
...
src/codegen/unwinding.cpp
View file @
2f60cce3
...
...
@@ -1188,8 +1188,8 @@ std::string getCurrentPythonLine() {
if
(
frame_iter
.
get
())
{
std
::
ostringstream
stream
;
auto
*
c
f
=
frame_iter
->
getCF
();
auto
source
=
c
f
->
c
lfunc
->
source
.
get
();
auto
*
c
lfunc
=
frame_iter
->
getCL
();
auto
source
=
clfunc
->
source
.
get
();
auto
current_stmt
=
frame_iter
->
getCurrentStatement
();
...
...
src/core/types.h
View file @
2f60cce3
...
...
@@ -328,6 +328,7 @@ class SourceInfo {
public:
BoxedModule
*
parent_module
;
ScopingAnalysis
*
scoping
;
ScopeInfo
*
scope_info
;
FutureFlags
future_flags
;
AST
*
ast
;
CFG
*
cfg
;
...
...
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