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
d163fb4d
Commit
d163fb4d
authored
Jun 24, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add BoxedWrapperDescriptor::tppCall
parent
88b62b62
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
2 deletions
+92
-2
src/asm_writing/rewriter.cpp
src/asm_writing/rewriter.cpp
+11
-0
src/asm_writing/rewriter.h
src/asm_writing/rewriter.h
+2
-0
src/runtime/descr.cpp
src/runtime/descr.cpp
+76
-0
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+0
-2
src/runtime/rewrite_args.h
src/runtime/rewrite_args.h
+1
-0
src/runtime/types.h
src/runtime/types.h
+2
-0
No files found.
src/asm_writing/rewriter.cpp
View file @
d163fb4d
...
...
@@ -694,6 +694,17 @@ RewriterVar* Rewriter::call(bool has_side_effects, void* func_addr, RewriterVar*
return
call
(
has_side_effects
,
func_addr
,
args
,
args_xmm
);
}
RewriterVar
*
Rewriter
::
call
(
bool
has_side_effects
,
void
*
func_addr
,
RewriterVar
*
arg0
,
RewriterVar
*
arg1
,
RewriterVar
*
arg2
,
RewriterVar
*
arg3
)
{
RewriterVar
::
SmallVector
args
;
RewriterVar
::
SmallVector
args_xmm
;
args
.
push_back
(
arg0
);
args
.
push_back
(
arg1
);
args
.
push_back
(
arg2
);
args
.
push_back
(
arg3
);
return
call
(
has_side_effects
,
func_addr
,
args
,
args_xmm
);
}
static
const
Location
caller_save_registers
[]{
assembler
::
RAX
,
assembler
::
RCX
,
assembler
::
RDX
,
assembler
::
RSI
,
assembler
::
RDI
,
assembler
::
R8
,
assembler
::
R9
,
assembler
::
R10
,
assembler
::
R11
,
assembler
::
XMM0
,
...
...
src/asm_writing/rewriter.h
View file @
d163fb4d
...
...
@@ -505,6 +505,8 @@ public:
RewriterVar
*
call
(
bool
has_side_effects
,
void
*
func_addr
,
RewriterVar
*
arg0
);
RewriterVar
*
call
(
bool
has_side_effects
,
void
*
func_addr
,
RewriterVar
*
arg0
,
RewriterVar
*
arg1
);
RewriterVar
*
call
(
bool
has_side_effects
,
void
*
func_addr
,
RewriterVar
*
arg0
,
RewriterVar
*
arg1
,
RewriterVar
*
arg2
);
RewriterVar
*
call
(
bool
has_side_effects
,
void
*
func_addr
,
RewriterVar
*
arg0
,
RewriterVar
*
arg1
,
RewriterVar
*
arg2
,
RewriterVar
*
arg3
);
RewriterVar
*
add
(
RewriterVar
*
a
,
int64_t
b
,
Location
dest
);
// Allocates n pointer-sized stack slots:
RewriterVar
*
allocate
(
int
n
);
...
...
src/runtime/descr.cpp
View file @
d163fb4d
...
...
@@ -469,6 +469,81 @@ Box* BoxedWrapperObject::__call__(BoxedWrapperObject* self, Box* args, Box* kwds
return
rtn
;
}
Box
*
BoxedWrapperObject
::
tppCall
(
Box
*
_self
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
{
assert
(
_self
->
cls
==
wrapperobject_cls
);
BoxedWrapperObject
*
self
=
static_cast
<
BoxedWrapperObject
*>
(
_self
);
int
flags
=
self
->
descr
->
wrapper
->
flags
;
wrapperfunc
wrapper
=
self
->
descr
->
wrapper
->
wrapper
;
assert
(
self
->
descr
->
wrapper
->
offset
>
0
);
if
(
rewrite_args
&&
!
rewrite_args
->
func_guarded
)
{
rewrite_args
->
obj
->
addAttrGuard
(
offsetof
(
BoxedWrapperObject
,
descr
),
(
intptr_t
)
self
->
descr
);
}
ParamReceiveSpec
paramspec
(
0
,
0
,
true
,
false
);
if
(
flags
==
PyWrapperFlag_KEYWORDS
)
{
paramspec
=
ParamReceiveSpec
(
0
,
0
,
true
,
true
);
}
else
if
(
flags
==
PyWrapperFlag_PYSTON
||
flags
==
0
)
{
paramspec
=
ParamReceiveSpec
(
0
,
0
,
true
,
false
);
}
else
{
RELEASE_ASSERT
(
0
,
"%d"
,
flags
);
}
Box
*
oarg1
=
NULL
;
Box
*
oarg2
=
NULL
;
Box
*
oarg3
=
NULL
;
Box
**
oargs
=
NULL
;
bool
rewrite_success
=
false
;
rearrangeArguments
(
paramspec
,
NULL
,
self
->
descr
->
wrapper
->
name
.
data
(),
NULL
,
rewrite_args
,
rewrite_success
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
,
oarg1
,
oarg2
,
oarg3
,
args
);
assert
(
oarg1
&&
oarg1
->
cls
==
tuple_cls
);
if
(
!
paramspec
.
takes_kwargs
)
assert
(
oarg2
==
NULL
);
assert
(
oarg3
==
NULL
);
assert
(
oargs
==
NULL
);
if
(
!
rewrite_success
)
rewrite_args
=
NULL
;
Box
*
rtn
;
if
(
flags
==
PyWrapperFlag_KEYWORDS
)
{
wrapperfunc_kwds
wk
=
(
wrapperfunc_kwds
)
wrapper
;
rtn
=
(
*
wk
)(
self
->
obj
,
oarg1
,
self
->
descr
->
wrapped
,
oarg2
);
if
(
rewrite_args
)
{
auto
rewriter
=
rewrite_args
->
rewriter
;
auto
r_obj
=
rewrite_args
->
obj
->
getAttr
(
offsetof
(
BoxedWrapperObject
,
obj
),
Location
::
forArg
(
0
));
rewrite_args
->
out_rtn
=
rewriter
->
call
(
true
,
(
void
*
)
wk
,
r_obj
,
rewrite_args
->
arg1
,
rewriter
->
loadConst
((
intptr_t
)
self
->
descr
->
wrapped
,
Location
::
forArg
(
2
)),
rewrite_args
->
arg2
);
rewriter
->
call
(
false
,
(
void
*
)
checkAndThrowCAPIException
);
rewrite_args
->
out_success
=
true
;
}
}
else
if
(
flags
==
PyWrapperFlag_PYSTON
||
flags
==
0
)
{
rtn
=
(
*
wrapper
)(
self
->
obj
,
oarg1
,
self
->
descr
->
wrapped
);
if
(
rewrite_args
)
{
auto
rewriter
=
rewrite_args
->
rewriter
;
auto
r_obj
=
rewrite_args
->
obj
->
getAttr
(
offsetof
(
BoxedWrapperObject
,
obj
),
Location
::
forArg
(
0
));
rewrite_args
->
out_rtn
=
rewriter
->
call
(
true
,
(
void
*
)
wrapper
,
r_obj
,
rewrite_args
->
arg1
,
rewriter
->
loadConst
((
intptr_t
)
self
->
descr
->
wrapped
,
Location
::
forArg
(
2
)));
rewriter
->
call
(
false
,
(
void
*
)
checkAndThrowCAPIException
);
rewrite_args
->
out_success
=
true
;
}
}
else
{
RELEASE_ASSERT
(
0
,
"%d"
,
flags
);
}
checkAndThrowCAPIException
();
assert
(
rtn
&&
"should have set + thrown an exception!"
);
return
rtn
;
}
void
BoxedWrapperObject
::
gcHandler
(
GCVisitor
*
v
,
Box
*
_o
)
{
assert
(
_o
->
cls
==
wrapperobject_cls
);
BoxedWrapperObject
*
o
=
static_cast
<
BoxedWrapperObject
*>
(
_o
);
...
...
@@ -535,6 +610,7 @@ void setupDescr() {
wrapperobject_cls
->
giveAttr
(
"__call__"
,
new
BoxedFunction
(
boxRTFunction
((
void
*
)
BoxedWrapperObject
::
__call__
,
UNKNOWN
,
1
,
0
,
true
,
true
)));
wrapperobject_cls
->
tpp_call
=
BoxedWrapperObject
::
tppCall
;
wrapperobject_cls
->
freeze
();
}
...
...
src/runtime/objmodel.cpp
View file @
d163fb4d
...
...
@@ -2985,8 +2985,6 @@ void rearrangeArguments(ParamReceiveSpec paramspec, const ParamNames* param_name
if
(
rewrite_args
)
{
rewrite_success
=
false
;
// default case
assert
(
rewrite_args
->
args_guarded
&&
"need to guard args here"
);
assert
(
rewrite_args
->
func_guarded
&&
"this is the callers responsibility"
);
}
// Fast path: if it's a simple-enough call, we don't have to do anything special. On a simple
...
...
src/runtime/rewrite_args.h
View file @
d163fb4d
...
...
@@ -124,6 +124,7 @@ struct CompareRewriteArgs {
// Passes the output arguments back through oarg. Passes the rewrite success by setting rewrite_success.
// Directly modifies rewrite_args args in place, but only if rewrite_success got set.
// oargs needs to be pre-allocated by the caller, since it's assumed that they will want to use alloca.
// The caller is responsible for guarding for paramspec, argspec, param_names, and defaults.
// TODO Fix this function's signature. should we pass back out through args? the common case is that they
// match anyway. Or maybe it should call a callback function, which could save on the common case.
void
rearrangeArguments
(
ParamReceiveSpec
paramspec
,
const
ParamNames
*
param_names
,
const
char
*
func_name
,
...
...
src/runtime/types.h
View file @
d163fb4d
...
...
@@ -911,6 +911,8 @@ public:
DEFAULT_CLASS
(
wrapperobject_cls
);
static
Box
*
__call__
(
BoxedWrapperObject
*
self
,
Box
*
args
,
Box
*
kwds
);
static
Box
*
tppCall
(
Box
*
_self
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
);
static
void
gcHandler
(
GCVisitor
*
v
,
Box
*
_o
);
};
...
...
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