Commit 406c1885 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Switch super to tp_getattro

parent a80e0725
...@@ -1022,7 +1022,7 @@ $(call make_target,_gcc) ...@@ -1022,7 +1022,7 @@ $(call make_target,_gcc)
nosearch_runpy_% nosearch_pyrun_%: %.py ext_python nosearch_runpy_% nosearch_pyrun_%: %.py ext_python
$(VERB) PYTHONPATH=test/test_extension/build/lib.linux-x86_64-2.7 zsh -c 'time python $<' $(VERB) PYTHONPATH=test/test_extension/build/lib.linux-x86_64-2.7 zsh -c 'time python $<'
nosearch_pypyrun_%: %.py ext_python nosearch_pypyrun_%: %.py ext_python
$(VERB) PYTHONPATH=test/test_extension/build/lib.linux-x86_64-2.7 zsh -c 'time python $<' $(VERB) PYTHONPATH=test/test_extension/build/lib.linux-x86_64-2.7 zsh -c 'time pypy $<'
$(call make_search,runpy_%) $(call make_search,runpy_%)
$(call make_search,pyrun_%) $(call make_search,pyrun_%)
$(call make_search,pypyrun_%) $(call make_search,pypyrun_%)
......
...@@ -856,6 +856,9 @@ static PyObject* slot_tp_tpp_descr_get(PyObject* self, PyObject* obj, PyObject* ...@@ -856,6 +856,9 @@ static PyObject* slot_tp_tpp_descr_get(PyObject* self, PyObject* obj, PyObject*
} }
static PyObject* slot_tp_getattro(PyObject* self, PyObject* name) noexcept { static PyObject* slot_tp_getattro(PyObject* self, PyObject* name) noexcept {
static StatCounter slowpath_tp_getattro("slowpath_tp_getattro");
slowpath_tp_getattro.log();
static PyObject* getattribute_str = NULL; static PyObject* getattribute_str = NULL;
return call_method(self, "__getattribute__", &getattribute_str, "(O)", name); return call_method(self, "__getattribute__", &getattribute_str, "(O)", name);
} }
......
...@@ -134,6 +134,15 @@ Box* superGetattribute(Box* _s, Box* _attr) { ...@@ -134,6 +134,15 @@ Box* superGetattribute(Box* _s, Box* _attr) {
return processDescriptor(r, s, s->cls); return processDescriptor(r, s, s->cls);
} }
Box* super_getattro(Box* _s, Box* _attr) noexcept {
try {
return superGetattribute(_s, _attr);
} catch (ExcInfo e) {
setCAPIException(e);
return NULL;
}
}
Box* superRepr(Box* _s) { Box* superRepr(Box* _s) {
RELEASE_ASSERT(_s->cls == super_cls, ""); RELEASE_ASSERT(_s->cls == super_cls, "");
BoxedSuper* s = static_cast<BoxedSuper*>(_s); BoxedSuper* s = static_cast<BoxedSuper*>(_s);
...@@ -191,7 +200,7 @@ void setupSuper() { ...@@ -191,7 +200,7 @@ void setupSuper() {
super_cls = BoxedHeapClass::create(type_cls, object_cls, &BoxedSuper::gcHandler, 0, 0, sizeof(BoxedSuper), false, super_cls = BoxedHeapClass::create(type_cls, object_cls, &BoxedSuper::gcHandler, 0, 0, sizeof(BoxedSuper), false,
"super"); "super");
super_cls->giveAttr("__getattribute__", new BoxedFunction(boxRTFunction((void*)superGetattribute, UNKNOWN, 2))); // super_cls->giveAttr("__getattribute__", new BoxedFunction(boxRTFunction((void*)superGetattribute, UNKNOWN, 2)));
super_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)superRepr, STR, 1))); super_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)superRepr, STR, 1)));
super_cls->giveAttr("__init__", super_cls->giveAttr("__init__",
...@@ -205,5 +214,6 @@ void setupSuper() { ...@@ -205,5 +214,6 @@ void setupSuper() {
new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedSuper, obj_type))); new BoxedMemberDescriptor(BoxedMemberDescriptor::OBJECT, offsetof(BoxedSuper, obj_type)));
super_cls->freeze(); super_cls->freeze();
super_cls->tp_getattro = super_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