Commit 9cda8dda authored by Marius Wachtler's avatar Marius Wachtler

support 'for_call' optimization in slotTpGetattrHookInternal

parent 36ff3d23
...@@ -894,11 +894,12 @@ static PyObject* call_attribute(PyObject* self, PyObject* attr, PyObject* name) ...@@ -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 { /* Pyston change: static */ PyObject* slot_tp_getattr_hook(PyObject* self, PyObject* name) noexcept {
assert(name->cls == str_cls); 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> 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) { if (rewritable == NOT_REWRITABLE) {
assert(!rewrite_args); assert(!rewrite_args);
rewrite_args = NULL; rewrite_args = NULL;
...@@ -982,7 +983,8 @@ Box* slotTpGetattrHookInternal(Box* self, BoxedString* name, GetattrRewriteArgs* ...@@ -982,7 +983,8 @@ Box* slotTpGetattrHookInternal(Box* self, BoxedString* name, GetattrRewriteArgs*
GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, rewrite_args->obj, rewrite_args->destination); GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, rewrite_args->obj, rewrite_args->destination);
try { try {
assert(!PyType_Check(self)); // There would be a getattribute 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) { } catch (ExcInfo e) {
if (!e.matches(AttributeError)) { if (!e.matches(AttributeError)) {
if (S == CAPI) { if (S == CAPI) {
...@@ -1108,13 +1110,17 @@ Box* slotTpGetattrHookInternal(Box* self, BoxedString* name, GetattrRewriteArgs* ...@@ -1108,13 +1110,17 @@ Box* slotTpGetattrHookInternal(Box* self, BoxedString* name, GetattrRewriteArgs*
} }
// Force instantiation of the template // Force instantiation of the template
template Box* slotTpGetattrHookInternal<CAPI, REWRITABLE>(Box* self, BoxedString* name, template Box* slotTpGetattrHookInternal<CAPI, REWRITABLE>(Box* self, BoxedString* name,
GetattrRewriteArgs* rewrite_args); GetattrRewriteArgs* rewrite_args, bool for_call,
template Box* slotTpGetattrHookInternal<CXX, REWRITABLE>(Box* self, BoxedString* name, Box** bind_obj_out, RewriterVar** r_bind_obj_out);
GetattrRewriteArgs* rewrite_args); 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, 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, 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 { /* Pyston change: static */ PyObject* slot_tp_new(PyTypeObject* self, PyObject* args, PyObject* kwds) noexcept {
STAT_TIMER(t0, "us_timer_slot_tpnew", SLOT_AVOIDABILITY(self)); STAT_TIMER(t0, "us_timer_slot_tpnew", SLOT_AVOIDABILITY(self));
......
...@@ -56,7 +56,8 @@ int slot_tp_init(PyObject* self, PyObject* args, PyObject* kwds) noexcept; ...@@ -56,7 +56,8 @@ int slot_tp_init(PyObject* self, PyObject* args, PyObject* kwds) noexcept;
class GetattrRewriteArgs; class GetattrRewriteArgs;
template <ExceptionStyle S, Rewritable rewritable> 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 #endif
...@@ -1561,7 +1561,8 @@ Box* getattrInternalEx(Box* obj, BoxedString* attr, GetattrRewriteArgs* rewrite_ ...@@ -1561,7 +1561,8 @@ Box* getattrInternalEx(Box* obj, BoxedString* attr, GetattrRewriteArgs* rewrite_
STAT_TIMER(t0, "us_timer_slowpath_tpgetattro", 10); STAT_TIMER(t0, "us_timer_slowpath_tpgetattro", 10);
if (obj->cls->tp_getattro == slot_tp_getattr_hook) { 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) { } else if (obj->cls->tp_getattro == instance_getattro) {
return instanceGetattroInternal<S>(obj, attr, rewrite_args); return instanceGetattroInternal<S>(obj, attr, rewrite_args);
} else if (obj->cls->tp_getattro == type_getattro) { } else if (obj->cls->tp_getattro == type_getattro) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment