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
f9ba4449
Commit
f9ba4449
authored
Mar 14, 2016
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make this a bit easier
parent
4c089036
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
45 deletions
+46
-45
src/runtime/capi.cpp
src/runtime/capi.cpp
+2
-15
src/runtime/descr.cpp
src/runtime/descr.cpp
+4
-25
src/runtime/types.cpp
src/runtime/types.cpp
+6
-5
src/runtime/types.h
src/runtime/types.h
+34
-0
No files found.
src/runtime/capi.cpp
View file @
f9ba4449
...
...
@@ -1718,7 +1718,6 @@ template <ExceptionStyle S>
Box
*
BoxedCApiFunction
::
tppCall
(
Box
*
_self
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
noexcept
(
S
==
CAPI
)
{
assert
(
0
&&
"check refcounting"
);
if
(
S
==
CAPI
)
{
try
{
return
tppCall
<
CXX
>
(
_self
,
NULL
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
);
...
...
@@ -1806,6 +1805,8 @@ Box* BoxedCApiFunction::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgPa
rearrangeArguments
(
paramspec
,
NULL
,
self
->
method_def
->
ml_name
,
defaults
,
rewrite_args
,
rewrite_success
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
oargs
,
keyword_names
);
AUTO_DECREF_ARGS
(
paramspec
,
arg1
,
arg2
,
arg3
,
oargs
);
if
(
!
rewrite_success
)
rewrite_args
=
NULL
;
...
...
@@ -1870,25 +1871,11 @@ Box* BoxedCApiFunction::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgPa
RELEASE_ASSERT
(
0
,
"0x%x"
,
flags
);
}
assert
(
paramspec
.
totalReceived
()
<=
3
);
assert
(
!
oargs
);
if
(
rewrite_args
)
{
rewrite_args
->
rewriter
->
checkAndThrowCAPIException
(
rewrite_args
->
out_rtn
);
rewrite_args
->
out_success
=
true
;
}
switch
(
paramspec
.
totalReceived
())
{
case
3
:
Py_XDECREF
(
arg3
);
case
2
:
Py_XDECREF
(
arg2
);
case
1
:
Py_XDECREF
(
arg1
);
default:
break
;
}
checkAndThrowCAPIException
();
assert
(
rtn
&&
"should have set + thrown an exception!"
);
return
rtn
;
...
...
src/runtime/descr.cpp
View file @
f9ba4449
...
...
@@ -247,7 +247,6 @@ template <ExceptionStyle S>
Box
*
BoxedMethodDescriptor
::
tppCall
(
Box
*
_self
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
noexcept
(
S
==
CAPI
)
{
assert
(
0
&&
"check refcounting"
);
if
(
S
==
CAPI
)
{
try
{
return
tppCall
<
CXX
>
(
_self
,
NULL
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
);
...
...
@@ -314,6 +313,8 @@ Box* BoxedMethodDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args, A
rearrangeArguments
(
paramspec
,
NULL
,
self
->
method
->
ml_name
,
defaults
,
rewrite_args
,
rewrite_success
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
oargs
,
keyword_names
);
AUTO_DECREF_ARGS
(
paramspec
,
arg1
,
arg2
,
arg3
,
oargs
);
if
(
!
rewrite_success
)
rewrite_args
=
NULL
;
...
...
@@ -394,15 +395,6 @@ Box* BoxedMethodDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args, A
RELEASE_ASSERT
(
0
,
"0x%x"
,
call_flags
);
}
if
(
paramspec
.
totalReceived
()
>=
1
)
Py_DECREF
(
arg1
);
if
(
paramspec
.
totalReceived
()
>=
2
)
Py_DECREF
(
arg2
);
if
(
paramspec
.
totalReceived
()
>=
3
)
Py_DECREF
(
arg3
);
for
(
int
i
=
0
;
i
<
paramspec
.
totalReceived
()
-
3
;
i
++
)
Py_DECREF
(
oargs
[
i
]);
if
(
!
rtn
)
throwCAPIException
();
...
...
@@ -602,7 +594,6 @@ template <ExceptionStyle S>
Box
*
BoxedWrapperDescriptor
::
tppCall
(
Box
*
_self
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
noexcept
(
S
==
CAPI
)
{
assert
(
0
&&
"Check refcounting"
);
if
(
S
==
CAPI
)
{
try
{
return
tppCall
<
CXX
>
(
_self
,
NULL
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
keyword_names
);
...
...
@@ -640,6 +631,8 @@ Box* BoxedWrapperDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args,
rearrangeArguments
(
paramspec
,
NULL
,
self
->
wrapper
->
name
.
data
(),
NULL
,
rewrite_args
,
rewrite_success
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
oargs
,
keyword_names
);
AUTO_DECREF_ARGS
(
paramspec
,
arg1
,
arg2
,
arg3
,
oargs
);
if
(
paramspec
.
takes_varargs
)
assert
(
arg2
&&
arg2
->
cls
==
tuple_cls
);
...
...
@@ -697,20 +690,6 @@ Box* BoxedWrapperDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args,
RELEASE_ASSERT
(
0
,
"%d"
,
flags
);
}
assert
(
paramspec
.
totalReceived
()
<=
3
);
assert
(
!
oargs
);
switch
(
paramspec
.
totalReceived
())
{
case
3
:
Py_XDECREF
(
arg3
);
case
2
:
Py_XDECREF
(
arg2
);
case
1
:
Py_XDECREF
(
arg1
);
default:
break
;
}
if
(
!
rtn
)
throwCAPIException
();
return
rtn
;
...
...
src/runtime/types.cpp
View file @
f9ba4449
...
...
@@ -570,7 +570,6 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
template
<
ExceptionStyle
S
>
static
Box
*
typeTppCall
(
Box
*
self
,
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
noexcept
(
S
==
CAPI
)
{
assert
(
0
&&
"check refcounting"
);
int
npassed_args
=
argspec
.
totalPassed
();
// Common CAPI path call this function with *args, **kw.
...
...
@@ -585,9 +584,9 @@ static Box* typeTppCall(Box* self, CallRewriteArgs* rewrite_args, ArgPassSpec ar
else
throwCAPIException
();
}
AUTO_DECREF
(
arg1
);
Box
*
r
=
cpython_type_call
(
static_cast
<
BoxedClass
*>
(
self
),
arg1
,
argspec
.
has_kwargs
?
arg2
:
NULL
);
Py_DECREF
(
arg1
);
if
(
S
==
CXX
&&
!
r
)
throwCAPIException
();
return
r
;
...
...
@@ -718,7 +717,6 @@ static Box* objectNewNoArgs(BoxedClass* cls) noexcept {
template
<
ExceptionStyle
S
>
static
Box
*
typeCallInner
(
CallRewriteArgs
*
rewrite_args
,
ArgPassSpec
argspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
,
const
std
::
vector
<
BoxedString
*>*
keyword_names
)
noexcept
(
S
==
CAPI
)
{
assert
(
0
&&
"check refcounting"
);
int
npassed_args
=
argspec
.
totalPassed
();
int
npositional
=
argspec
.
num_args
;
...
...
@@ -761,10 +759,13 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
static
Box
*
defaults
[
3
]
=
{
NULL
,
NULL
,
NULL
};
Box
*
oargs
[
1
];
rearrangeArguments
(
paramspec
,
&
param_names
,
"unicode"
,
defaults
,
rewrite_args
,
rewrite_success
,
argspec
,
arg1
,
arg2
,
arg3
,
args
,
oargs
,
keyword_names
);
assert
(
arg1
==
cls
);
AUTO_DECREF_ARGS
(
paramspec
,
arg1
,
arg2
,
arg3
,
oargs
);
if
(
!
rewrite_success
)
rewrite_args
=
NULL
;
...
...
@@ -1126,8 +1127,8 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
throw
e
;
}
AUTO_
X
DECREF
(
made
);
AUTO_
X
DECREF
(
arg2
);
AUTO_DECREF
(
made
);
AUTO_DECREF
(
arg2
);
AUTO_XDECREF
(
arg3
);
if
(
!
rewrite_success
)
...
...
src/runtime/types.h
View file @
f9ba4449
...
...
@@ -398,6 +398,40 @@ public:
#define AUTO_DECREF_ARRAY(x, size) AutoDecrefArray<false> CAT(_autodecref_, __LINE__)((x), (size))
#define AUTO_XDECREF_ARRAY(x, size) AutoDecrefArray<true> CAT(_autodecref_, __LINE__)((x), (size))
class
AutoDecrefArgs
{
private:
int
num_args
;
Box
*
arg1
,
*
arg2
,
*
arg3
;
Box
**
args
;
public:
AutoDecrefArgs
(
int
num_args
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
)
:
num_args
(
num_args
),
arg1
(
arg1
),
arg2
(
arg2
),
arg3
(
arg3
),
args
(
args
)
{}
AutoDecrefArgs
(
ParamReceiveSpec
paramspec
,
Box
*
arg1
,
Box
*
arg2
,
Box
*
arg3
,
Box
**
args
)
:
num_args
(
paramspec
.
totalReceived
()),
arg1
(
arg1
),
arg2
(
arg2
),
arg3
(
arg3
),
args
(
args
)
{}
~
AutoDecrefArgs
()
{
// TODO Minor optimization: only the last arg (kwargs) is allowed to be NULL.
switch
(
num_args
)
{
default:
for
(
int
i
=
0
;
i
<
num_args
-
3
;
i
++
)
{
Py_XDECREF
(
args
[
i
]);
}
case
3
:
Py_XDECREF
(
arg3
);
case
2
:
Py_XDECREF
(
arg2
);
case
1
:
Py_XDECREF
(
arg1
);
case
0
:
break
;
}
}
};
// Note: this captures the first three args by value (like AUTO_DECREF) but the array by reference.
// You can also pass a ParamReceiveSpec instead of an int for num_args
#define AUTO_DECREF_ARGS(num_args, arg1, arg2, arg3, args) AutoDecrefArgs CAT(_autodecref_, __LINE__)((num_args), (arg1), (arg2), (arg3), (args))
template
<
typename
B
>
B
*
incref
(
B
*
b
)
{
Py_INCREF
(
b
);
return
b
;
...
...
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