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
ceb3e449
Commit
ceb3e449
authored
Jul 31, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bjit: directly inline recordType() function
parent
407a6276
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
4 deletions
+32
-4
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/type_recording.cpp
src/codegen/type_recording.cpp
+3
-0
src/codegen/type_recording.h
src/codegen/type_recording.h
+1
-2
No files found.
src/codegen/baseline_jit.cpp
View file @
ceb3e449
...
...
@@ -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 @
ceb3e449
...
...
@@ -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/type_recording.cpp
View file @
ceb3e449
...
...
@@ -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 @
ceb3e449
...
...
@@ -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
();
...
...
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