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
1f843a06
Commit
1f843a06
authored
Mar 22, 2016
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Plain Diff
Merge commit '
b77872ef
' into refcounting
parents
c7c868eb
b77872ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
src/codegen/baseline_jit.cpp
src/codegen/baseline_jit.cpp
+11
-10
src/codegen/baseline_jit.h
src/codegen/baseline_jit.h
+5
-5
No files found.
src/codegen/baseline_jit.cpp
View file @
1f843a06
...
...
@@ -39,17 +39,18 @@ static llvm::DenseMap<CFGBlock*, std::vector<void*>> block_patch_locations;
// long foo(char* c);
// void bjit() {
// asm volatile ("" ::: "r14");
// asm volatile ("" ::: "r1
2
");
// asm volatile ("" ::: "r1
3
");
// char scratch[256+16];
// foo(scratch);
// }
//
// It omits the frame pointer but saves R12 and R14
// It omits the frame pointer but saves r13 and r14
// use 'objdump -s -j .eh_frame <obj.file>' to dump it
const
unsigned
char
eh_info
[]
=
{
0x14
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x03
,
0x7a
,
0x52
,
0x00
,
0x01
,
0x78
,
0x10
,
0x01
,
0x1b
,
0x0c
,
0x07
,
0x08
,
0x90
,
0x01
,
0x00
,
0x00
,
0x1c
,
0x00
,
0x00
,
0x00
,
0x1c
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x20
,
0x00
,
0x00
,
0x00
,
0x00
,
0x42
,
0x0e
,
0x10
,
0x42
,
0x0e
,
0x18
,
0x47
,
0x0e
,
0xb0
,
0x02
,
0x8
c
,
0x03
,
0x8e
,
0x02
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
0x0e
,
0x18
,
0x47
,
0x0e
,
0xb0
,
0x02
,
0x8
d
,
0x03
,
0x8e
,
0x02
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
static_assert
(
JitCodeBlock
::
num_stack_args
==
2
,
"have to update EH table!"
);
static_assert
(
JitCodeBlock
::
scratch_size
==
256
,
"have to update EH table!"
);
...
...
@@ -70,10 +71,10 @@ JitCodeBlock::JitCodeBlock(llvm::StringRef name)
// emit prolog
a
.
push
(
assembler
::
R14
);
a
.
push
(
assembler
::
R1
2
);
a
.
push
(
assembler
::
R1
3
);
static_assert
(
sp_adjustment
%
16
==
8
,
"stack isn't aligned"
);
a
.
sub
(
assembler
::
Immediate
(
sp_adjustment
),
assembler
::
RSP
);
a
.
mov
(
assembler
::
RDI
,
assembler
::
R1
2
);
// interpreter pointer
a
.
mov
(
assembler
::
RDI
,
assembler
::
R1
3
);
// interpreter pointer
a
.
mov
(
assembler
::
RDX
,
assembler
::
R14
);
// vreg array
a
.
jmp
(
assembler
::
Indirect
(
assembler
::
RSI
,
offsetof
(
CFGBlock
,
code
)));
// jump to block
...
...
@@ -146,7 +147,7 @@ JitFragmentWriter::JitFragmentWriter(CFGBlock* block, std::unique_ptr<ICInfo> ic
ic_info
(
std
::
move
(
ic_info
))
{
if
(
LOG_BJIT_ASSEMBLY
)
comment
(
"BJIT: JitFragmentWriter() start"
);
interp
=
createNewVar
();
addLocationToVar
(
interp
,
assembler
::
R1
2
);
addLocationToVar
(
interp
,
assembler
::
R1
3
);
interp
->
setAttr
(
ASTInterpreterJitInterface
::
getCurrentBlockOffset
(),
imm
(
block
));
vregs_array
=
createNewVar
();
...
...
@@ -893,7 +894,7 @@ void JitFragmentWriter::_emitJump(CFGBlock* b, RewriterVar* block_next, ExitInfo
exit_info
.
exit_start
=
assembler
->
curInstPointer
();
block_next
->
getInReg
(
assembler
::
RAX
,
true
);
assembler
->
add
(
assembler
::
Immediate
(
JitCodeBlock
::
sp_adjustment
),
assembler
::
RSP
);
assembler
->
pop
(
assembler
::
R1
2
);
assembler
->
pop
(
assembler
::
R1
3
);
assembler
->
pop
(
assembler
::
R14
);
assembler
->
retq
();
...
...
@@ -917,7 +918,7 @@ void JitFragmentWriter::_emitOSRPoint() {
// this generates code for:
// if (++interpreter.edgecount < OSR_THRESHOLD_BASELINE)
// return std::make_pair((CFGBlock*)0, ASTInterpreterJitInterface::osr_dummy_value);
assembler
::
Register
interp_reg
=
getInterp
()
->
getInReg
();
// will always be
R12
assembler
::
Register
interp_reg
=
getInterp
()
->
getInReg
();
// will always be
r13
assembler
::
Indirect
edgecount
=
assembler
::
Indirect
(
interp_reg
,
ASTInterpreterJitInterface
::
getEdgeCountOffset
());
assembler
->
incl
(
edgecount
);
// 32bit inc
assembler
->
cmpl
(
edgecount
,
assembler
::
Immediate
(
OSR_THRESHOLD_BASELINE
));
// 32bit cmp
...
...
@@ -926,7 +927,7 @@ void JitFragmentWriter::_emitOSRPoint() {
assembler
->
clear_reg
(
assembler
::
RAX
);
// = next block to execute
assembler
->
mov
(
assembler
::
Immediate
(
ASTInterpreterJitInterface
::
osr_dummy_value
),
assembler
::
RDX
);
assembler
->
add
(
assembler
::
Immediate
(
JitCodeBlock
::
sp_adjustment
),
assembler
::
RSP
);
assembler
->
pop
(
assembler
::
R1
2
);
assembler
->
pop
(
assembler
::
R1
3
);
assembler
->
pop
(
assembler
::
R14
);
assembler
->
retq
();
}
...
...
@@ -1027,7 +1028,7 @@ void JitFragmentWriter::_emitReturn(RewriterVar* return_val) {
return_val
->
getInReg
(
assembler
::
RDX
,
true
);
assembler
->
clear_reg
(
assembler
::
RAX
);
assembler
->
add
(
assembler
::
Immediate
(
JitCodeBlock
::
sp_adjustment
),
assembler
::
RSP
);
assembler
->
pop
(
assembler
::
R1
2
);
assembler
->
pop
(
assembler
::
R1
3
);
assembler
->
pop
(
assembler
::
R14
);
assembler
->
retq
();
return_val
->
bumpUse
();
...
...
src/codegen/baseline_jit.h
View file @
1f843a06
...
...
@@ -70,7 +70,7 @@ class JitFragmentWriter;
// register or stack slot but we aren't if it outlives the block - we have to store it in the interpreter instance.
//
// We use the following callee-save regs to speed up the generated code:
// r1
2
: pointer to ASTInterpreter instance
// r1
3
: pointer to ASTInterpreter instance
// r14: pointer to the vregs array
//
// To execute a specific CFGBlock one has to call:
...
...
@@ -91,10 +91,10 @@ class JitFragmentWriter;
// Basic layout of generated code block is:
// entry_code:
// push %r14 ; save r14
// push %r1
2 ; save r12
// push %r1
3 ; save r13
// sub $0x118,%rsp ; setup scratch, 0x118 = scratch_size + 16 = space for two func args passed on the
// stack + 8 byte for stack alignment
// mov %rdi,%r1
2 ; copy the pointer to ASTInterpreter instance into r12
// mov %rdi,%r1
3 ; copy the pointer to ASTInterpreter instance into r13
// mov %rdx,%r14 ; copy the pointer to the vregs array into r14
// jmpq *0x8(%rsi) ; jump to block->code
// possible values: first_JitFragment, second_JitFragment,...
...
...
@@ -107,7 +107,7 @@ class JitFragmentWriter;
// jne end_side_exit
// movabs $0x215bb60,%rax ; rax = CFGBlock* to interpret next (rax is the 1. return reg)
// add $0x118,%rsp ; restore stack pointer
// pop %r1
2 ; restore r12
// pop %r1
3 ; restore r13
// pop %r14 ; restore r14
// ret ; exit to the interpreter which will interpret the specified CFGBLock*
// end_side_exit:
...
...
@@ -120,7 +120,7 @@ class JitFragmentWriter;
// in this case 0 which means we are finished
// movabs $0x1270014108,%rdx ; rdx must contain the Box* value to return
// add $0x118,%rsp ; restore stack pointer
// pop %r1
2 ; restore r12
// pop %r1
3 ; restore r13
// pop %r14 ; restore r14
// ret
//
...
...
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