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
719cbb6d
Commit
719cbb6d
authored
Jul 12, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rewriter: factor out call setup code, fix scratch validation test + add assembler::skipBytes()
parent
fc8b1d26
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
10 deletions
+32
-10
src/asm_writing/assembler.cpp
src/asm_writing/assembler.cpp
+10
-0
src/asm_writing/assembler.h
src/asm_writing/assembler.h
+1
-0
src/asm_writing/rewriter.cpp
src/asm_writing/rewriter.cpp
+17
-9
src/asm_writing/rewriter.h
src/asm_writing/rewriter.h
+4
-1
No files found.
src/asm_writing/assembler.cpp
View file @
719cbb6d
...
...
@@ -1034,6 +1034,16 @@ void Assembler::emitAnnotation(int num) {
nop
();
}
void
Assembler
::
skipBytes
(
int
num
)
{
if
(
addr
+
num
>=
end_addr
)
{
addr
=
end_addr
;
failed
=
true
;
return
;
}
addr
+=
num
;
}
ForwardJump
::
ForwardJump
(
Assembler
&
assembler
,
ConditionCode
condition
)
:
assembler
(
assembler
),
condition
(
condition
),
jmp_inst
(
assembler
.
curInstPointer
())
{
assembler
.
jmp_cond
(
JumpDestination
::
fromStart
(
assembler
.
bytesWritten
()
+
max_jump_size
),
condition
);
...
...
src/asm_writing/assembler.h
View file @
719cbb6d
...
...
@@ -193,6 +193,7 @@ public:
void
fillWithNops
();
void
fillWithNopsExcept
(
int
bytes
);
void
emitAnnotation
(
int
num
);
void
skipBytes
(
int
num
);
uint8_t
*
startAddr
()
const
{
return
start_addr
;
}
int
bytesLeft
()
const
{
return
end_addr
-
addr
;
}
...
...
src/asm_writing/rewriter.cpp
View file @
719cbb6d
...
...
@@ -792,10 +792,8 @@ RewriterVar* Rewriter::call(bool has_side_effects, void* func_addr, const Rewrit
return
result
;
}
void
Rewriter
::
_call
(
RewriterVar
*
result
,
bool
has_side_effects
,
void
*
func_addr
,
const
RewriterVar
::
SmallVector
&
args
,
const
RewriterVar
::
SmallVector
&
args_xmm
)
{
assembler
->
comment
(
"_call"
);
void
Rewriter
::
_setupCall
(
RewriterVar
*
result
,
bool
has_side_effects
,
const
RewriterVar
::
SmallVector
&
args
,
const
RewriterVar
::
SmallVector
&
args_xmm
)
{
if
(
has_side_effects
)
assert
(
done_guarding
);
...
...
@@ -828,9 +826,6 @@ void Rewriter::_call(RewriterVar* result, bool has_side_effects, void* func_addr
}
}
// RewriterVarUsage scratch = createNewVar(Location::any());
assembler
::
Register
r
=
allocReg
(
assembler
::
R11
);
for
(
int
i
=
0
;
i
<
args
.
size
();
i
++
)
{
Location
l
(
Location
::
forArg
(
i
));
RewriterVar
*
var
=
args
[
i
];
...
...
@@ -950,6 +945,19 @@ void Rewriter::_call(RewriterVar* result, bool has_side_effects, void* func_addr
assert
(
!
l
.
isClobberedByCall
());
}
#endif
}
void
Rewriter
::
_call
(
RewriterVar
*
result
,
bool
has_side_effects
,
void
*
func_addr
,
const
RewriterVar
::
SmallVector
&
args
,
const
RewriterVar
::
SmallVector
&
args_xmm
)
{
assembler
->
comment
(
"_call"
);
// RewriterVarUsage scratch = createNewVar(Location::any());
assembler
::
Register
r
=
allocReg
(
assembler
::
R11
);
_setupCall
(
result
,
has_side_effects
,
args
,
args_xmm
);
// make sure setupCall doesn't use R11
assert
(
vars_by_location
.
count
(
assembler
::
R11
)
==
0
);
uint64_t
asm_address
=
(
uint64_t
)
assembler
->
curInstPointer
()
+
5
;
uint64_t
real_asm_address
=
asm_address
+
(
uint64_t
)
rewrite
->
getSlotStart
()
-
(
uint64_t
)
assembler
->
startAddr
();
...
...
@@ -1737,10 +1745,10 @@ Rewriter::Rewriter(std::unique_ptr<ICSlotRewrite> rewrite, int num_args, const s
// the entire scratch space.
bool
VALIDATE_SCRATCH_SPACE
=
false
;
if
(
VALIDATE_SCRATCH_SPACE
)
{
int
scratch_size
=
rewrite
->
getScratchSize
();
int
scratch_size
=
this
->
rewrite
->
getScratchSize
();
for
(
int
i
=
0
;
i
<
scratch_size
;
i
+=
8
)
{
assembler
->
movq
(
assembler
::
Immediate
(
0x12345678UL
),
assembler
::
Indirect
(
assembler
::
RSP
,
i
+
rewrite
->
getScratchRspOffset
()));
assembler
::
Indirect
(
assembler
::
RSP
,
i
+
this
->
rewrite
->
getScratchRspOffset
()));
}
}
}
...
...
src/asm_writing/rewriter.h
View file @
719cbb6d
...
...
@@ -19,6 +19,7 @@
#include <memory>
#include <tuple>
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallSet.h"
...
...
@@ -349,7 +350,7 @@ protected:
Rewriter
(
std
::
unique_ptr
<
ICSlotRewrite
>
rewrite
,
int
num_args
,
const
std
::
vector
<
int
>&
live_outs
);
llvm
::
SmallVector
<
RewriterAction
,
32
>
actions
;
void
addAction
(
std
::
function
<
void
()
>
action
,
std
::
vector
<
RewriterVar
*>
const
&
vars
,
ActionType
type
)
{
void
addAction
(
std
::
function
<
void
()
>
action
,
llvm
::
ArrayRef
<
RewriterVar
*>
vars
,
ActionType
type
)
{
assertPhaseCollecting
();
for
(
RewriterVar
*
var
:
vars
)
{
assert
(
var
!=
NULL
);
...
...
@@ -413,6 +414,8 @@ protected:
void
_trap
();
void
_loadConst
(
RewriterVar
*
result
,
int64_t
val
);
void
_setupCall
(
RewriterVar
*
result
,
bool
has_side_effects
,
const
RewriterVar
::
SmallVector
&
args
,
const
RewriterVar
::
SmallVector
&
args_xmm
);
void
_call
(
RewriterVar
*
result
,
bool
has_side_effects
,
void
*
func_addr
,
const
RewriterVar
::
SmallVector
&
args
,
const
RewriterVar
::
SmallVector
&
args_xmm
);
void
_add
(
RewriterVar
*
result
,
RewriterVar
*
a
,
int64_t
b
,
Location
dest
);
...
...
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