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
8201e339
Commit
8201e339
authored
May 18, 2016
by
Kevin Modzelewski
Committed by
Kevin Modzelewski
May 18, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch from our custom magic class to llvm::function_ref
thanks Marius for the tip
parent
82fccc6a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
31 deletions
+2
-31
src/runtime/rewrite_args.h
src/runtime/rewrite_args.h
+2
-31
No files found.
src/runtime/rewrite_args.h
View file @
8201e339
...
...
@@ -292,37 +292,8 @@ struct CompareRewriteArgs {
:
rewriter
(
rewriter
),
lhs
(
lhs
),
rhs
(
rhs
),
destination
(
destination
),
out_success
(
false
),
out_rtn
(
NULL
)
{}
};
typedef
Box
*
(
*
rearrange_target_t
)(
void
*
,
CallRewriteArgs
*
,
Box
*
,
Box
*
,
Box
*
,
Box
**
);
// This is a magical helper class that converts a functor (in particular, lambdas) into a [function pointer, void* data]
// pair. This lets us pass the functor efficiently: we can avoid doing an allocation (by storing the functor on the
// stack),
// and also avoid making the receiving function have to be a template.
//
// In effect, it does what you would have to do to create a function pointer + void* pair, like one would pass to
// C-style functions.
class
FunctorPointer
{
private:
template
<
typename
Functor
>
class
ConversionHelper
{
public:
static
Box
*
call
(
void
*
f
,
CallRewriteArgs
*
rewrite_args
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
)
{
// static_assert(decltypeD
return
(
*
(
Functor
*
)
f
)(
rewrite_args
,
arg1
,
arg2
,
arg3
,
args
);
}
};
rearrange_target_t
function_pointer
;
void
*
functor
;
public:
template
<
typename
Functor
>
FunctorPointer
(
Functor
&
f
)
:
function_pointer
(
ConversionHelper
<
Functor
>::
call
),
functor
(
&
f
)
{}
Box
*
operator
()(
CallRewriteArgs
*
rewrite_args
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
)
{
return
function_pointer
(
functor
,
rewrite_args
,
arg1
,
arg2
,
arg3
,
args
);
}
};
using
FunctorPointer
=
llvm
::
function_ref
<
Box
*
(
CallRewriteArgs
*
rewrite_args
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
)
>
;
// rearrangeArgumentsAndCall maps from a given set of arguments (the structure specified by an ArgPassSpec) to the
// parameter form than the receiving function expects (given by the ParamReceiveSpec). After it does this, it will
...
...
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