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
9cda8dda
Commit
9cda8dda
authored
Oct 21, 2015
by
Marius Wachtler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support 'for_call' optimization in slotTpGetattrHookInternal
parent
36ff3d23
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
10 deletions
+18
-10
src/capi/typeobject.cpp
src/capi/typeobject.cpp
+14
-8
src/capi/typeobject.h
src/capi/typeobject.h
+2
-1
src/runtime/objmodel.cpp
src/runtime/objmodel.cpp
+2
-1
No files found.
src/capi/typeobject.cpp
View file @
9cda8dda
...
...
@@ -894,11 +894,12 @@ static PyObject* call_attribute(PyObject* self, PyObject* attr, PyObject* name)
/* Pyston change: static */
PyObject
*
slot_tp_getattr_hook
(
PyObject
*
self
,
PyObject
*
name
)
noexcept
{
assert
(
name
->
cls
==
str_cls
);
return
slotTpGetattrHookInternal
<
CAPI
,
NOT_REWRITABLE
>
(
self
,
(
BoxedString
*
)
name
,
NULL
);
return
slotTpGetattrHookInternal
<
CAPI
,
NOT_REWRITABLE
>
(
self
,
(
BoxedString
*
)
name
,
NULL
,
false
,
NULL
,
NULL
);
}
template
<
ExceptionStyle
S
,
Rewritable
rewritable
>
Box
*
slotTpGetattrHookInternal
(
Box
*
self
,
BoxedString
*
name
,
GetattrRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
CAPI
)
{
Box
*
slotTpGetattrHookInternal
(
Box
*
self
,
BoxedString
*
name
,
GetattrRewriteArgs
*
rewrite_args
,
bool
for_call
,
Box
**
bind_obj_out
,
RewriterVar
**
r_bind_obj_out
)
noexcept
(
S
==
CAPI
)
{
if
(
rewritable
==
NOT_REWRITABLE
)
{
assert
(
!
rewrite_args
);
rewrite_args
=
NULL
;
...
...
@@ -982,7 +983,8 @@ Box* slotTpGetattrHookInternal(Box* self, BoxedString* name, GetattrRewriteArgs*
GetattrRewriteArgs
grewrite_args
(
rewrite_args
->
rewriter
,
rewrite_args
->
obj
,
rewrite_args
->
destination
);
try
{
assert
(
!
PyType_Check
(
self
));
// There would be a getattribute
res
=
getattrInternalGeneric
<
false
,
rewritable
>
(
self
,
name
,
&
grewrite_args
,
false
,
false
,
NULL
,
NULL
);
res
=
getattrInternalGeneric
<
false
,
rewritable
>
(
self
,
name
,
&
grewrite_args
,
false
,
for_call
,
bind_obj_out
,
r_bind_obj_out
);
}
catch
(
ExcInfo
e
)
{
if
(
!
e
.
matches
(
AttributeError
))
{
if
(
S
==
CAPI
)
{
...
...
@@ -1108,13 +1110,17 @@ Box* slotTpGetattrHookInternal(Box* self, BoxedString* name, GetattrRewriteArgs*
}
// Force instantiation of the template
template
Box
*
slotTpGetattrHookInternal
<
CAPI
,
REWRITABLE
>(
Box
*
self
,
BoxedString
*
name
,
GetattrRewriteArgs
*
rewrite_args
);
template
Box
*
slotTpGetattrHookInternal
<
CXX
,
REWRITABLE
>(
Box
*
self
,
BoxedString
*
name
,
GetattrRewriteArgs
*
rewrite_args
);
GetattrRewriteArgs
*
rewrite_args
,
bool
for_call
,
Box
**
bind_obj_out
,
RewriterVar
**
r_bind_obj_out
);
template
Box
*
slotTpGetattrHookInternal
<
CXX
,
REWRITABLE
>(
Box
*
self
,
BoxedString
*
name
,
GetattrRewriteArgs
*
rewrite_args
,
bool
for_call
,
Box
**
bind_obj_out
,
RewriterVar
**
r_bind_obj_out
);
template
Box
*
slotTpGetattrHookInternal
<
CAPI
,
NOT_REWRITABLE
>(
Box
*
self
,
BoxedString
*
name
,
GetattrRewriteArgs
*
rewrite_args
);
GetattrRewriteArgs
*
rewrite_args
,
bool
for_call
,
Box
**
bind_obj_out
,
RewriterVar
**
r_bind_obj_out
);
template
Box
*
slotTpGetattrHookInternal
<
CXX
,
NOT_REWRITABLE
>(
Box
*
self
,
BoxedString
*
name
,
GetattrRewriteArgs
*
rewrite_args
);
GetattrRewriteArgs
*
rewrite_args
,
bool
for_call
,
Box
**
bind_obj_out
,
RewriterVar
**
r_bind_obj_out
);
/* Pyston change: static */
PyObject
*
slot_tp_new
(
PyTypeObject
*
self
,
PyObject
*
args
,
PyObject
*
kwds
)
noexcept
{
STAT_TIMER
(
t0
,
"us_timer_slot_tpnew"
,
SLOT_AVOIDABILITY
(
self
));
...
...
src/capi/typeobject.h
View file @
9cda8dda
...
...
@@ -56,7 +56,8 @@ int slot_tp_init(PyObject* self, PyObject* args, PyObject* kwds) noexcept;
class
GetattrRewriteArgs
;
template
<
ExceptionStyle
S
,
Rewritable
rewritable
>
Box
*
slotTpGetattrHookInternal
(
Box
*
self
,
BoxedString
*
attr
,
GetattrRewriteArgs
*
rewrite_args
)
noexcept
(
S
==
CAPI
);
Box
*
slotTpGetattrHookInternal
(
Box
*
self
,
BoxedString
*
attr
,
GetattrRewriteArgs
*
rewrite_args
,
bool
for_call
,
Box
**
bind_obj_out
,
RewriterVar
**
r_bind_obj_out
)
noexcept
(
S
==
CAPI
);
}
#endif
src/runtime/objmodel.cpp
View file @
9cda8dda
...
...
@@ -1561,7 +1561,8 @@ Box* getattrInternalEx(Box* obj, BoxedString* attr, GetattrRewriteArgs* rewrite_
STAT_TIMER
(
t0
,
"us_timer_slowpath_tpgetattro"
,
10
);
if
(
obj
->
cls
->
tp_getattro
==
slot_tp_getattr_hook
)
{
return
slotTpGetattrHookInternal
<
S
,
rewritable
>
(
obj
,
attr
,
rewrite_args
);
return
slotTpGetattrHookInternal
<
S
,
rewritable
>
(
obj
,
attr
,
rewrite_args
,
for_call
,
bind_obj_out
,
r_bind_obj_out
);
}
else
if
(
obj
->
cls
->
tp_getattro
==
instance_getattro
)
{
return
instanceGetattroInternal
<
S
>
(
obj
,
attr
,
rewrite_args
);
}
else
if
(
obj
->
cls
->
tp_getattro
==
type_getattro
)
{
...
...
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