Commit 2cbc3c4a authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add the concept of stattimer "avoidability"

ie roll up all the time into the most "avoidable" reason that we were doing it.
For example, if we are doing something like calling slot_tp_getttro on a builtin
type (very avoidable), roll up all the subsequent time (runtimeCall, etc) into
the slot_tp_getattro timer.  But if we call runtimeCall where we couldn't avoid it
(ex from the interpreter), log that separately.

Not sure how helpful it will be but for this specific investigation it seems to
somewhat work.  The idea of the "avoidability" is definitely pretty specific to
the type of work that you are thinking of doing; the numbers I put in are for
investigating slowpaths.

Also, remove all the timers that we have on specific runtime functions (ex: listMul).
I think we'll need another strategy for those.
parent 57d9d307
......@@ -18,7 +18,7 @@
namespace pyston {
Box* BoxedMethodDescriptor::__call__(BoxedMethodDescriptor* self, Box* obj, BoxedTuple* varargs, Box** _args) {
STAT_TIMER(t0, "us_timer_boxedmethoddescriptor__call__");
STAT_TIMER(t0, "us_timer_boxedmethoddescriptor__call__", 10);
BoxedDict* kwargs = static_cast<BoxedDict*>(_args[0]);
assert(self->cls == method_cls);
......
......@@ -59,8 +59,10 @@ static int hackcheck(PyObject* self, setattrofunc func, const char* what) noexce
return 1;
}
#define WRAP_AVOIDABILITY(obj) ((obj)->cls->is_user_defined ? 10 : 20)
static PyObject* wrap_setattr(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_setattr");
STAT_TIMER(t0, "us_timer_wrap_setattr", WRAP_AVOIDABILITY(self));
setattrofunc func = (setattrofunc)wrapped;
int res;
PyObject* name, *value;
......@@ -77,7 +79,7 @@ static PyObject* wrap_setattr(PyObject* self, PyObject* args, void* wrapped) noe
}
static PyObject* wrap_delattr(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_delattr");
STAT_TIMER(t0, "us_timer_wrap_delattr", WRAP_AVOIDABILITY(self));
setattrofunc func = (setattrofunc)wrapped;
int res;
PyObject* name;
......@@ -95,7 +97,7 @@ static PyObject* wrap_delattr(PyObject* self, PyObject* args, void* wrapped) noe
}
static PyObject* wrap_hashfunc(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_hashfunc");
STAT_TIMER(t0, "us_timer_wrap_hashfunc", WRAP_AVOIDABILITY(self));
hashfunc func = (hashfunc)wrapped;
long res;
......@@ -108,14 +110,14 @@ static PyObject* wrap_hashfunc(PyObject* self, PyObject* args, void* wrapped) no
}
static PyObject* wrap_call(PyObject* self, PyObject* args, void* wrapped, PyObject* kwds) noexcept {
STAT_TIMER(t0, "us_timer_wrap_call");
STAT_TIMER(t0, "us_timer_wrap_call", WRAP_AVOIDABILITY(self));
ternaryfunc func = (ternaryfunc)wrapped;
return (*func)(self, args, kwds);
}
static PyObject* wrap_richcmpfunc(PyObject* self, PyObject* args, void* wrapped, int op) noexcept {
STAT_TIMER(t0, "us_timer_wrap_richcmpfunc");
STAT_TIMER(t0, "us_timer_wrap_richcmpfunc", WRAP_AVOIDABILITY(self));
richcmpfunc func = (richcmpfunc)wrapped;
PyObject* other;
......@@ -139,7 +141,7 @@ RICHCMP_WRAPPER(gt, Py_GT)
RICHCMP_WRAPPER(ge, Py_GE)
static PyObject* wrap_next(PyObject* self, PyObject* args, void* wrapped) {
STAT_TIMER(t0, "us_timer_wrap_next");
STAT_TIMER(t0, "us_timer_wrap_next", WRAP_AVOIDABILITY(self));
unaryfunc func = (unaryfunc)wrapped;
PyObject* res;
......@@ -152,7 +154,7 @@ static PyObject* wrap_next(PyObject* self, PyObject* args, void* wrapped) {
}
static PyObject* wrap_descr_get(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_descr_get");
STAT_TIMER(t0, "us_timer_wrap_descr_get", WRAP_AVOIDABILITY(self));
descrgetfunc func = (descrgetfunc)wrapped;
PyObject* obj;
PyObject* type = NULL;
......@@ -171,7 +173,7 @@ static PyObject* wrap_descr_get(PyObject* self, PyObject* args, void* wrapped) n
}
static PyObject* wrap_coercefunc(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_coercefunc");
STAT_TIMER(t0, "us_timer_wrap_coercefunc", WRAP_AVOIDABILITY(self));
coercion func = (coercion)wrapped;
PyObject* other, *res;
int ok;
......@@ -198,7 +200,7 @@ static PyObject* wrap_coercefunc(PyObject* self, PyObject* args, void* wrapped)
}
static PyObject* wrap_ternaryfunc(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_ternaryfunc");
STAT_TIMER(t0, "us_timer_wrap_ternaryfunc", WRAP_AVOIDABILITY(self));
ternaryfunc func = (ternaryfunc)wrapped;
PyObject* other;
PyObject* third = Py_None;
......@@ -211,7 +213,7 @@ static PyObject* wrap_ternaryfunc(PyObject* self, PyObject* args, void* wrapped)
}
static PyObject* wrap_ternaryfunc_r(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_ternaryfunc_r");
STAT_TIMER(t0, "us_timer_wrap_ternaryfunc_r", WRAP_AVOIDABILITY(self));
ternaryfunc func = (ternaryfunc)wrapped;
PyObject* other;
PyObject* third = Py_None;
......@@ -224,7 +226,7 @@ static PyObject* wrap_ternaryfunc_r(PyObject* self, PyObject* args, void* wrappe
}
static PyObject* wrap_unaryfunc(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_unaryfunc");
STAT_TIMER(t0, "us_timer_wrap_unaryfunc", WRAP_AVOIDABILITY(self));
unaryfunc func = (unaryfunc)wrapped;
if (!check_num_args(args, 0))
......@@ -233,7 +235,7 @@ static PyObject* wrap_unaryfunc(PyObject* self, PyObject* args, void* wrapped) n
}
static PyObject* wrap_inquirypred(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_inquirypred");
STAT_TIMER(t0, "us_timer_wrap_inquirypred", WRAP_AVOIDABILITY(self));
inquiry func = (inquiry)wrapped;
int res;
......@@ -246,7 +248,7 @@ static PyObject* wrap_inquirypred(PyObject* self, PyObject* args, void* wrapped)
}
static PyObject* wrapInquirypred(PyObject* self, PyObject* args, void* wrapped) {
STAT_TIMER(t0, "us_timer_wrapInquirypred");
STAT_TIMER(t0, "us_timer_wrapInquirypred", WRAP_AVOIDABILITY(self));
inquiry func = (inquiry)wrapped;
int res;
......@@ -259,7 +261,7 @@ static PyObject* wrapInquirypred(PyObject* self, PyObject* args, void* wrapped)
}
static PyObject* wrap_binaryfunc(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_binaryfunc");
STAT_TIMER(t0, "us_timer_wrap_binaryfunc", WRAP_AVOIDABILITY(self));
binaryfunc func = (binaryfunc)wrapped;
PyObject* other;
......@@ -270,7 +272,7 @@ static PyObject* wrap_binaryfunc(PyObject* self, PyObject* args, void* wrapped)
}
static PyObject* wrap_binaryfunc_l(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_binaryfunc_l");
STAT_TIMER(t0, "us_timer_wrap_binaryfunc_l", WRAP_AVOIDABILITY(self));
binaryfunc func = (binaryfunc)wrapped;
PyObject* other;
......@@ -285,7 +287,7 @@ static PyObject* wrap_binaryfunc_l(PyObject* self, PyObject* args, void* wrapped
}
static PyObject* wrap_binaryfunc_r(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_binaryfunc_r");
STAT_TIMER(t0, "us_timer_wrap_binaryfunc_r", WRAP_AVOIDABILITY(self));
binaryfunc func = (binaryfunc)wrapped;
PyObject* other;
......@@ -318,7 +320,7 @@ static Py_ssize_t getindex(PyObject* self, PyObject* arg) noexcept {
}
static PyObject* wrap_lenfunc(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_lenfunc");
STAT_TIMER(t0, "us_timer_wrap_lenfunc", WRAP_AVOIDABILITY(self));
lenfunc func = (lenfunc)wrapped;
Py_ssize_t res;
......@@ -331,7 +333,7 @@ static PyObject* wrap_lenfunc(PyObject* self, PyObject* args, void* wrapped) noe
}
static PyObject* wrap_indexargfunc(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_indexargfunc");
STAT_TIMER(t0, "us_timer_wrap_indexargfunc", WRAP_AVOIDABILITY(self));
ssizeargfunc func = (ssizeargfunc)wrapped;
PyObject* o;
Py_ssize_t i;
......@@ -345,7 +347,7 @@ static PyObject* wrap_indexargfunc(PyObject* self, PyObject* args, void* wrapped
}
static PyObject* wrap_sq_item(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_sq_item");
STAT_TIMER(t0, "us_timer_wrap_sq_item", WRAP_AVOIDABILITY(self));
ssizeargfunc func = (ssizeargfunc)wrapped;
PyObject* arg;
Py_ssize_t i;
......@@ -363,7 +365,7 @@ static PyObject* wrap_sq_item(PyObject* self, PyObject* args, void* wrapped) noe
}
static PyObject* wrap_ssizessizeargfunc(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_ssizessizeargfunc");
STAT_TIMER(t0, "us_timer_wrap_ssizessizeargfunc", WRAP_AVOIDABILITY(self));
ssizessizeargfunc func = (ssizessizeargfunc)wrapped;
Py_ssize_t i, j;
......@@ -373,7 +375,7 @@ static PyObject* wrap_ssizessizeargfunc(PyObject* self, PyObject* args, void* wr
}
static PyObject* wrap_sq_setitem(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_sq_setitem");
STAT_TIMER(t0, "us_timer_wrap_sq_setitem", WRAP_AVOIDABILITY(self));
ssizeobjargproc func = (ssizeobjargproc)wrapped;
Py_ssize_t i;
int res;
......@@ -392,7 +394,7 @@ static PyObject* wrap_sq_setitem(PyObject* self, PyObject* args, void* wrapped)
}
static PyObject* wrap_sq_delitem(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_sq_delitem");
STAT_TIMER(t0, "us_timer_wrap_sq_delitem", WRAP_AVOIDABILITY(self));
ssizeobjargproc func = (ssizeobjargproc)wrapped;
Py_ssize_t i;
int res;
......@@ -412,7 +414,7 @@ static PyObject* wrap_sq_delitem(PyObject* self, PyObject* args, void* wrapped)
}
static PyObject* wrap_ssizessizeobjargproc(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_ssizessizeobjargproc");
STAT_TIMER(t0, "us_timer_wrap_ssizessizeobjargproc", WRAP_AVOIDABILITY(self));
ssizessizeobjargproc func = (ssizessizeobjargproc)wrapped;
Py_ssize_t i, j;
int res;
......@@ -428,7 +430,7 @@ static PyObject* wrap_ssizessizeobjargproc(PyObject* self, PyObject* args, void*
}
static PyObject* wrap_delslice(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_delslice");
STAT_TIMER(t0, "us_timer_wrap_delslice", WRAP_AVOIDABILITY(self));
ssizessizeobjargproc func = (ssizessizeobjargproc)wrapped;
Py_ssize_t i, j;
int res;
......@@ -444,7 +446,7 @@ static PyObject* wrap_delslice(PyObject* self, PyObject* args, void* wrapped) no
/* XXX objobjproc is a misnomer; should be objargpred */
static PyObject* wrap_objobjproc(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_objobjproc");
STAT_TIMER(t0, "us_timer_wrap_objobjproc", WRAP_AVOIDABILITY(self));
objobjproc func = (objobjproc)wrapped;
int res;
PyObject* value;
......@@ -460,7 +462,7 @@ static PyObject* wrap_objobjproc(PyObject* self, PyObject* args, void* wrapped)
}
static PyObject* wrap_objobjargproc(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_objobjargproc");
STAT_TIMER(t0, "us_timer_wrap_objobjargproc", WRAP_AVOIDABILITY(self));
objobjargproc func = (objobjargproc)wrapped;
int res;
PyObject* key, *value;
......@@ -475,7 +477,7 @@ static PyObject* wrap_objobjargproc(PyObject* self, PyObject* args, void* wrappe
}
static PyObject* wrap_delitem(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_delitem");
STAT_TIMER(t0, "us_timer_wrap_delitem", WRAP_AVOIDABILITY(self));
objobjargproc func = (objobjargproc)wrapped;
int res;
PyObject* key;
......@@ -491,7 +493,7 @@ static PyObject* wrap_delitem(PyObject* self, PyObject* args, void* wrapped) noe
}
static PyObject* wrap_cmpfunc(PyObject* self, PyObject* args, void* wrapped) noexcept {
STAT_TIMER(t0, "us_timer_wrap_cmpfunc");
STAT_TIMER(t0, "us_timer_wrap_cmpfunc", WRAP_AVOIDABILITY(self));
cmpfunc func = (cmpfunc)wrapped;
int res;
PyObject* other;
......@@ -512,7 +514,7 @@ static PyObject* wrap_cmpfunc(PyObject* self, PyObject* args, void* wrapped) noe
static PyObject* wrap_init(PyObject* self, PyObject* args, void* wrapped, PyObject* kwds) noexcept {
STAT_TIMER(t0, "us_timer_wrap_init");
STAT_TIMER(t0, "us_timer_wrap_init", WRAP_AVOIDABILITY(self));
initproc func = (initproc)wrapped;
if (func(self, args, kwds) < 0)
......@@ -666,8 +668,10 @@ extern "C" int _PyObject_SlotCompare(PyObject* self, PyObject* other) noexcept {
return (void*)self < (void*)other ? -1 : (void*)self > (void*)other ? 1 : 0;
}
#define SLOT_AVOIDABILITY(obj) ((obj)->cls->is_user_defined ? 10 : 20)
static PyObject* slot_tp_repr(PyObject* self) noexcept {
STAT_TIMER(t0, "us_timer_slot_tprepr");
STAT_TIMER(t0, "us_timer_slot_tprepr", SLOT_AVOIDABILITY(self));
try {
return repr(self);
......@@ -678,7 +682,7 @@ static PyObject* slot_tp_repr(PyObject* self) noexcept {
}
static PyObject* slot_tp_str(PyObject* self) noexcept {
STAT_TIMER(t0, "us_timer_slot_tpstr");
STAT_TIMER(t0, "us_timer_slot_tpstr", SLOT_AVOIDABILITY(self));
try {
return str(self);
......@@ -689,7 +693,7 @@ static PyObject* slot_tp_str(PyObject* self) noexcept {
}
static long slot_tp_hash(PyObject* self) noexcept {
STAT_TIMER(t0, "us_timer_slot_tphash");
STAT_TIMER(t0, "us_timer_slot_tphash", SLOT_AVOIDABILITY(self));
PyObject* func;
static PyObject* hash_str, *eq_str, *cmp_str;
......@@ -728,7 +732,7 @@ static long slot_tp_hash(PyObject* self) noexcept {
}
PyObject* slot_tp_call(PyObject* self, PyObject* args, PyObject* kwds) noexcept {
STAT_TIMER(t0, "us_timer_slot_tpcall");
STAT_TIMER(t0, "us_timer_slot_tpcall", SLOT_AVOIDABILITY(self));
try {
Py_FatalError("this function is untested");
......@@ -767,7 +771,7 @@ static PyObject* half_richcompare(PyObject* self, PyObject* other, int op) noexc
}
/* Pyston change: static*/ PyObject* slot_tp_richcompare(PyObject* self, PyObject* other, int op) noexcept {
STAT_TIMER(t0, "us_timer_slot_tprichcompare");
STAT_TIMER(t0, "us_timer_slot_tprichcompare", SLOT_AVOIDABILITY(self));
static StatCounter slowpath_richcompare("slowpath_richcompare");
slowpath_richcompare.log();
......@@ -797,7 +801,7 @@ static PyObject* half_richcompare(PyObject* self, PyObject* other, int op) noexc
}
static PyObject* slot_tp_iter(PyObject* self) noexcept {
STAT_TIMER(t0, "us_timer_slot_tpiter");
STAT_TIMER(t0, "us_timer_slot_tpiter", SLOT_AVOIDABILITY(self));
PyObject* func, *res;
static PyObject* iter_str, *getitem_str;
......@@ -824,14 +828,14 @@ static PyObject* slot_tp_iter(PyObject* self) noexcept {
}
static PyObject* slot_tp_iternext(PyObject* self) noexcept {
STAT_TIMER(t0, "us_timer_slot_tpiternext");
STAT_TIMER(t0, "us_timer_slot_tpiternext", SLOT_AVOIDABILITY(self));
static PyObject* next_str;
return call_method(self, "next", &next_str, "()");
}
static bool slotTppHasnext(PyObject* self) {
STAT_TIMER(t0, "us_timer_slot_tpphasnext");
STAT_TIMER(t0, "us_timer_slot_tpphasnext", SLOT_AVOIDABILITY(self));
static PyObject* hasnext_str;
Box* r = self->hasnextOrNullIC();
......@@ -840,7 +844,7 @@ static bool slotTppHasnext(PyObject* self) {
}
static PyObject* slot_tp_descr_get(PyObject* self, PyObject* obj, PyObject* type) noexcept {
STAT_TIMER(t0, "us_timer_slot_tpdescrget");
STAT_TIMER(t0, "us_timer_slot_tpdescrget", SLOT_AVOIDABILITY(self));
PyTypeObject* tp = Py_TYPE(self);
PyObject* get;
......@@ -861,7 +865,7 @@ static PyObject* slot_tp_descr_get(PyObject* self, PyObject* obj, PyObject* type
}
static PyObject* slot_tp_tpp_descr_get(PyObject* self, PyObject* obj, PyObject* type) noexcept {
STAT_TIMER(t0, "us_timer_slot_tppdescrget");
STAT_TIMER(t0, "us_timer_slot_tppdescrget", SLOT_AVOIDABILITY(self));
assert(self->cls->tpp_descr_get);
try {
......@@ -873,14 +877,14 @@ static PyObject* slot_tp_tpp_descr_get(PyObject* self, PyObject* obj, PyObject*
}
static PyObject* slot_tp_getattro(PyObject* self, PyObject* name) noexcept {
STAT_TIMER(t0, "us_timer_slot_tpgetattro");
STAT_TIMER(t0, "us_timer_slot_tpgetattro", SLOT_AVOIDABILITY(self));
static PyObject* getattribute_str = NULL;
return call_method(self, "__getattribute__", &getattribute_str, "(O)", name);
}
static int slot_tp_setattro(PyObject* self, PyObject* name, PyObject* value) noexcept {
STAT_TIMER(t0, "us_timer_slot_tpsetattro");
STAT_TIMER(t0, "us_timer_slot_tpsetattro", SLOT_AVOIDABILITY(self));
PyObject* res;
static PyObject* delattr_str, *setattr_str;
......@@ -918,7 +922,7 @@ static PyObject* call_attribute(PyObject* self, PyObject* attr, PyObject* name)
}
static PyObject* slot_tp_getattr_hook(PyObject* self, PyObject* name) noexcept {
STAT_TIMER(t0, "us_timer_slot_tpgetattrhook");
STAT_TIMER(t0, "us_timer_slot_tpgetattrhook", SLOT_AVOIDABILITY(self));
PyObject* getattr, *getattribute, * res = NULL;
......@@ -954,7 +958,7 @@ static PyObject* slot_tp_getattr_hook(PyObject* self, PyObject* name) noexcept {
}
static PyObject* slot_tp_new(PyTypeObject* self, PyObject* args, PyObject* kwds) noexcept {
STAT_TIMER(t0, "us_timer_slot_tpnew");
STAT_TIMER(t0, "us_timer_slot_tpnew", SLOT_AVOIDABILITY(self));
try {
// TODO: runtime ICs?
......@@ -970,7 +974,7 @@ static PyObject* slot_tp_new(PyTypeObject* self, PyObject* args, PyObject* kwds)
}
static int slot_tp_init(PyObject* self, PyObject* args, PyObject* kwds) noexcept {
STAT_TIMER(t0, "us_timer_slot_tpinit");
STAT_TIMER(t0, "us_timer_slot_tpinit", SLOT_AVOIDABILITY(self));
static PyObject* init_str;
PyObject* meth = lookup_method(self, "__init__", &init_str);
......@@ -992,7 +996,7 @@ static int slot_tp_init(PyObject* self, PyObject* args, PyObject* kwds) noexcept
}
PyObject* slot_sq_item(PyObject* self, Py_ssize_t i) noexcept {
STAT_TIMER(t0, "us_timer_slot_sqitem");
STAT_TIMER(t0, "us_timer_slot_sqitem", SLOT_AVOIDABILITY(self));
try {
return getitem(self, boxInt(i));
......@@ -1003,7 +1007,7 @@ PyObject* slot_sq_item(PyObject* self, Py_ssize_t i) noexcept {
}
static Py_ssize_t slot_sq_length(PyObject* self) noexcept {
STAT_TIMER(t0, "us_timer_slot_sqlength");
STAT_TIMER(t0, "us_timer_slot_sqlength", SLOT_AVOIDABILITY(self));
static PyObject* len_str;
PyObject* res = call_method(self, "__len__", &len_str, "()");
......@@ -1022,7 +1026,7 @@ static Py_ssize_t slot_sq_length(PyObject* self) noexcept {
}
static PyObject* slot_sq_slice(PyObject* self, Py_ssize_t i, Py_ssize_t j) noexcept {
STAT_TIMER(t0, "us_timer_slot_sqslice");
STAT_TIMER(t0, "us_timer_slot_sqslice", SLOT_AVOIDABILITY(self));
static PyObject* getslice_str;
......@@ -1034,7 +1038,7 @@ static PyObject* slot_sq_slice(PyObject* self, Py_ssize_t i, Py_ssize_t j) noexc
}
static int slot_sq_ass_item(PyObject* self, Py_ssize_t index, PyObject* value) noexcept {
STAT_TIMER(t0, "us_timer_slot_sqassitem");
STAT_TIMER(t0, "us_timer_slot_sqassitem", SLOT_AVOIDABILITY(self));
PyObject* res;
static PyObject* delitem_str, *setitem_str;
......@@ -1050,7 +1054,7 @@ static int slot_sq_ass_item(PyObject* self, Py_ssize_t index, PyObject* value) n
}
static int slot_sq_ass_slice(PyObject* self, Py_ssize_t i, Py_ssize_t j, PyObject* value) noexcept {
STAT_TIMER(t0, "us_timer_slot_sqassslice");
STAT_TIMER(t0, "us_timer_slot_sqassslice", SLOT_AVOIDABILITY(self));
PyObject* res;
static PyObject* delslice_str, *setslice_str;
......@@ -1075,7 +1079,7 @@ static int slot_sq_ass_slice(PyObject* self, Py_ssize_t i, Py_ssize_t j, PyObjec
}
static int slot_sq_contains(PyObject* self, PyObject* value) noexcept {
STAT_TIMER(t0, "us_timer_slot_sqcontains");
STAT_TIMER(t0, "us_timer_slot_sqcontains", SLOT_AVOIDABILITY(self));
PyObject* func, *res, *args;
int result = -1;
......@@ -1189,7 +1193,7 @@ static int method_is_overloaded(PyObject* left, PyObject* right, const char* nam
SLOT1(slot_mp_subscript, "__getitem__", PyObject*, "O")
static int slot_mp_ass_subscript(PyObject* self, PyObject* key, PyObject* value) noexcept {
STAT_TIMER(t0, "us_timer_slot_mpasssubscript");
STAT_TIMER(t0, "us_timer_slot_mpasssubscript", SLOT_AVOIDABILITY(self));
PyObject* res;
static PyObject* delitem_str, *setitem_str;
......@@ -1216,7 +1220,7 @@ static PyObject* slot_nb_power(PyObject*, PyObject*, PyObject*) noexcept;
SLOT1BINFULL(slot_nb_power_binary, slot_nb_power, nb_power, "__pow__", "__rpow__")
static PyObject* slot_nb_power(PyObject* self, PyObject* other, PyObject* modulus) noexcept {
STAT_TIMER(t0, "us_timer_slot_nbpower");
STAT_TIMER(t0, "us_timer_slot_nbpower", SLOT_AVOIDABILITY(self));
static PyObject* pow_str;
......@@ -1237,7 +1241,7 @@ SLOT0(slot_nb_positive, "__pos__")
SLOT0(slot_nb_absolute, "__abs__")
static int slot_nb_nonzero(PyObject* self) noexcept {
STAT_TIMER(t0, "us_timer_slot_nbnonzero");
STAT_TIMER(t0, "us_timer_slot_nbnonzero", SLOT_AVOIDABILITY(self));
PyObject* func, *args;
static PyObject* nonzero_str, *len_str;
......@@ -1274,7 +1278,7 @@ static int slot_nb_nonzero(PyObject* self) noexcept {
}
static PyObject* slot_nb_index(PyObject* self) noexcept {
STAT_TIMER(t0, "us_timer_slot_nbindex");
STAT_TIMER(t0, "us_timer_slot_nbindex", SLOT_AVOIDABILITY(self));
static PyObject* index_str;
return call_method(self, "__index__", &index_str, "()");
......@@ -1289,7 +1293,7 @@ SLOT1BIN(slot_nb_xor, nb_xor, "__xor__", "__rxor__")
SLOT1BIN(slot_nb_or, nb_or, "__or__", "__ror__")
static int slot_nb_coerce(PyObject** a, PyObject** b) noexcept {
STAT_TIMER(t0, "us_timer_slot_nbcoerce");
STAT_TIMER(t0, "us_timer_slot_nbcoerce", std::min(SLOT_AVOIDABILITY(*a), SLOT_AVOIDABILITY(*b)));
static PyObject* coerce_str;
PyObject* self = *a, * other = *b;
......@@ -1351,7 +1355,7 @@ SLOT1(slot_nb_inplace_divide, "__idiv__", PyObject*, "O")
SLOT1(slot_nb_inplace_remainder, "__imod__", PyObject*, "O")
/* Can't use SLOT1 here, because nb_inplace_power is ternary */
static PyObject* slot_nb_inplace_power(PyObject* self, PyObject* arg1, PyObject* arg2) {
STAT_TIMER(t0, "us_timer_slot_nbinplacepower");
STAT_TIMER(t0, "us_timer_slot_nbinplacepower", SLOT_AVOIDABILITY(self));
static PyObject* cache_str;
return call_method(self, "__ipow__", &cache_str, "("
......
......@@ -56,7 +56,7 @@ public:
}
static Box* __call__(BoxedCApiFunction* self, BoxedTuple* varargs, BoxedDict* kwargs) {
STAT_TIMER(t0, "us_timer_boxedcapifunction__call__");
STAT_TIMER(t0, "us_timer_boxedcapifunction__call__", (self->cls->is_user_defined ? 10 : 20));
assert(self->cls == capifunc_cls);
assert(varargs->cls == tuple_cls);
assert(kwargs->cls == dict_cls);
......@@ -164,7 +164,7 @@ public:
DEFAULT_CLASS(wrapperobject_cls);
static Box* __call__(BoxedWrapperObject* self, Box* args, Box* kwds) {
STAT_TIMER(t0, "us_timer_boxedwrapperobject__call__");
STAT_TIMER(t0, "us_timer_boxedwrapperobject__call__", (self->cls->is_user_defined ? 1 : 2));
assert(self->cls == wrapperobject_cls);
assert(args->cls == tuple_cls);
......
......@@ -386,7 +386,7 @@ Value ASTInterpreter::executeInner(ASTInterpreter& interpreter, CFGBlock* start_
}
Value ASTInterpreter::execute(ASTInterpreter& interpreter, CFGBlock* start_block, AST_stmt* start_at) {
STAT_TIMER(t0, "us_timer_astinterpreter_execute");
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_astinterpreter_execute");
RegisterHelper frame_registerer;
......@@ -605,7 +605,7 @@ Value ASTInterpreter::visit_jump(AST_Jump* node) {
arg_array.push_back(it.second);
}
STAT_TIMER(t0, "us_timer_astinterpreter_jump_osrexit");
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_astinterpreter_jump_osrexit");
CompiledFunction* partial_func = compilePartialFuncInternal(&exit);
auto arg_tuple = getTupleFromArgsArray(&arg_array[0], arg_array.size());
Box* r = partial_func->call(std::get<0>(arg_tuple), std::get<1>(arg_tuple), std::get<2>(arg_tuple),
......@@ -1007,8 +1007,6 @@ Value ASTInterpreter::visit_print(AST_Print* node) {
static BoxedString* newline_str = static_cast<BoxedString*>(PyString_InternFromString("\n"));
static BoxedString* space_str = static_cast<BoxedString*>(PyString_InternFromString(" "));
STAT_TIMER(t0, "us_timer_visit_print");
Box* dest = node->dest ? visit_expr(node->dest).o : getSysStdout();
int nvals = node->values.size();
assert(nvals <= 1 && "cfg should have lowered it to 0 or 1 values");
......
......@@ -177,7 +177,7 @@ static void compileIR(CompiledFunction* cf, EffortLevel effort) {
// The codegen_lock needs to be held in W mode before calling this function:
CompiledFunction* compileFunction(CLFunction* f, FunctionSpecialization* spec, EffortLevel effort,
const OSREntryDescriptor* entry_descriptor) {
STAT_TIMER(t0, "us_timer_compileFunction");
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_compileFunction");
Timer _t("for compileFunction()", 1000);
assert((entry_descriptor != NULL) + (spec != NULL) == 1);
......@@ -329,10 +329,10 @@ void compileAndRunModule(AST_Module* m, BoxedModule* bm) {
}
if (cf->is_interpreted) {
STAT_TIMER(t0, "us_timer_interpreted_module_toplevel");
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_interpreted_module_toplevel");
astInterpretFunction(cf, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
} else {
STAT_TIMER(t1, "us_timer_jitted_module_toplevel");
UNAVOIDABLE_STAT_TIMER(t1, "us_timer_jitted_module_toplevel");
((void (*)())cf->code)();
}
}
......
......@@ -995,7 +995,7 @@ AST_Module* parse_string(const char* code) {
}
AST_Module* parse_file(const char* fn) {
STAT_TIMER(t0, "us_timer_cpyton_parsing");
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_cpyton_parsing");
Timer _t("parsing");
if (ENABLE_PYPA_PARSER) {
......@@ -1095,7 +1095,7 @@ static ParseResult _reparse(const char* fn, const std::string& cache_fn, AST_Mod
// it's not a huge deal right now, but this caching version can significantly cut down
// on the startup time (40ms -> 10ms).
AST_Module* caching_parse_file(const char* fn) {
STAT_TIMER(t0, "us_timer_caching_parse_file");
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_caching_parse_file");
static StatCounter us_parsing("us_parsing");
Timer _t("parsing");
_t.setExitCallback([](uint64_t t) { us_parsing.log(t); });
......
......@@ -692,7 +692,7 @@ template <typename Func> void unwindPythonStack(Func func) {
}
static std::unique_ptr<PythonFrameIteratorImpl> getTopPythonFrame() {
STAT_TIMER(t0, "us_timer_getTopPythonFrame");
STAT_TIMER(t0, "us_timer_getTopPythonFrame", 10);
std::unique_ptr<PythonFrameIteratorImpl> rtn(nullptr);
unwindPythonStack([&](PythonFrameIteratorImpl* iter) {
rtn = std::unique_ptr<PythonFrameIteratorImpl>(new PythonFrameIteratorImpl(*iter));
......@@ -733,7 +733,7 @@ static std::unique_ptr<PythonFrameIteratorImpl> getTopPythonFrame() {
//
static StatCounter us_gettraceback("us_gettraceback");
BoxedTraceback* getTraceback() {
STAT_TIMER(t0, "us_timer_gettraceback");
STAT_TIMER(t0, "us_timer_gettraceback", 20);
if (!ENABLE_FRAME_INTROSPECTION) {
static bool printed_warning = false;
if (!printed_warning) {
......
......@@ -38,11 +38,15 @@ namespace pyston {
#define EXPENSIVE_STAT_TIMERS (0 && STAT_TIMERS)
#if STAT_TIMERS
#define STAT_TIMER(id, name) \
#define STAT_TIMER(id, name, avoidability) \
static uint64_t* _stcounter##id = Stats::getStatCounter(name); \
ScopedStatTimer _st##id(_stcounter##id)
ScopedStatTimer _st##id(_stcounter##id, avoidability)
#define UNAVOIDABLE_STAT_TIMER(id, name) \
static uint64_t* _stcounter##id = Stats::getStatCounter(name); \
ScopedStatTimer _st##id(_stcounter##id, 0, true)
#else
#define STAT_TIMER(id, name)
#define STAT_TIMER(id, name, avoidability)
#define UNAVOIDABLE_STAT_TIMER(id, name)
#endif
#define STAT_TIMER_NAME(id) _st##id
......@@ -122,34 +126,43 @@ private:
StatTimer* _prev;
uint64_t* _statcounter;
int avoidability;
bool reset_avoidability;
public:
StatTimer(uint64_t* counter) : _statcounter(counter) {}
StatTimer(uint64_t* counter, int avoidability, bool reset_avoidability = false)
: _statcounter(counter), avoidability(avoidability), reset_avoidability(reset_avoidability) {}
void pushNonTopLevel() {
uint64_t at_time = getCPUTicks();
#ifndef NDEBUG
_start_time = 0;
#endif
assert(stack);
_prev = stack;
stack = this;
_prev->pause(at_time);
resume(at_time);
}
void popNonTopLevel() {
assert(stack == this);
if (reset_avoidability || avoidability >= _prev->avoidability) {
uint64_t at_time = getCPUTicks();
uint64_t at_time;
assert(!isPaused());
at_time = getCPUTicks();
pause(at_time);
stack = this;
_prev->pause(at_time);
resume(at_time);
}
}
assert(_prev);
stack = _prev;
stack->resume(at_time);
void popNonTopLevel() {
if (reset_avoidability || avoidability >= _prev->avoidability) {
assert(stack == this);
uint64_t at_time;
assert(!isPaused());
at_time = getCPUTicks();
pause(at_time);
assert(_prev);
stack = _prev;
stack->resume(at_time);
}
}
void pushTopLevel(uint64_t at_time) {
......@@ -200,7 +213,10 @@ private:
StatTimer timer;
public:
ScopedStatTimer(uint64_t* counter) : timer(counter) { timer.pushNonTopLevel(); }
ScopedStatTimer(uint64_t* counter, int avoidability, bool reset_avoidability = false)
: timer(counter, avoidability, reset_avoidability) {
timer.pushNonTopLevel();
}
~ScopedStatTimer() { timer.popNonTopLevel(); }
};
#else
......
......@@ -400,7 +400,7 @@ void runCollection() {
static StatCounter sc("gc_collections");
sc.log();
STAT_TIMER(t0, "us_timer_gc_collection");
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_gc_collection");
ncollections++;
......
......@@ -269,7 +269,7 @@ static int main(int argc, char** argv) {
int rtncode = 0;
{
#if STAT_TIMERS
StatTimer timer(Stats::getStatCounter("us_timer_main_toplevel"));
StatTimer timer(Stats::getStatCounter("us_timer_main_toplevel"), 0, true);
timer.pushTopLevel(main_time.getStartTime());
#endif
......
......@@ -306,7 +306,6 @@ extern "C" Box* ord(Box* obj) {
}
Box* range(Box* start, Box* stop, Box* step) {
STAT_TIMER(t0, "us_timer_builtin_range");
i64 istart, istop, istep;
if (stop == NULL) {
istart = 0;
......@@ -350,7 +349,6 @@ Box* notimplementedRepr(Box* self) {
}
Box* sorted(Box* obj, Box* cmp, Box* key, Box** args) {
STAT_TIMER(t0, "us_timer_builtin_sorted");
Box* reverse = args[0];
BoxedList* rtn = new BoxedList();
......@@ -363,7 +361,6 @@ Box* sorted(Box* obj, Box* cmp, Box* key, Box** args) {
}
Box* isinstance_func(Box* obj, Box* cls) {
STAT_TIMER(t0, "us_timer_builtin_isinstance");
int rtn = PyObject_IsInstance(obj, cls);
if (rtn < 0)
checkAndThrowCAPIException();
......@@ -371,7 +368,6 @@ Box* isinstance_func(Box* obj, Box* cls) {
}
Box* issubclass_func(Box* child, Box* parent) {
STAT_TIMER(t0, "us_timer_builtin_issubclass");
int rtn = PyObject_IsSubclass(child, parent);
if (rtn < 0)
checkAndThrowCAPIException();
......
......@@ -66,7 +66,7 @@ static void* thread_start(Box* target, Box* varargs, Box* kwargs) {
#if STAT_TIMERS
// TODO: maybe we should just not log anything for threads...
static uint64_t* timer_counter = Stats::getStatCounter("us_timer_thread_start");
StatTimer timer(timer_counter);
StatTimer timer(timer_counter, 0, true);
timer.pushTopLevel(getCPUTicks());
#endif
......
......@@ -49,7 +49,6 @@ Box* dictRepr(BoxedDict* self) {
}
Box* dictClear(BoxedDict* self) {
STAT_TIMER(t0, "us_timer_dictClear");
if (!isSubclass(self->cls, dict_cls))
raiseExcHelper(TypeError, "descriptor 'clear' requires a 'dict' object but received a '%s'", getTypeName(self));
......@@ -58,7 +57,6 @@ Box* dictClear(BoxedDict* self) {
}
Box* dictCopy(BoxedDict* self) {
STAT_TIMER(t0, "us_timer_dictCopy");
if (!isSubclass(self->cls, dict_cls))
raiseExcHelper(TypeError, "descriptor 'copy' requires a 'dict' object but received a '%s'", getTypeName(self));
......@@ -68,7 +66,6 @@ Box* dictCopy(BoxedDict* self) {
}
Box* dictItems(BoxedDict* self) {
STAT_TIMER(t0, "us_timer_dictItems");
BoxedList* rtn = new BoxedList();
rtn->ensure(self->d.size());
......@@ -81,7 +78,6 @@ Box* dictItems(BoxedDict* self) {
}
Box* dictValues(BoxedDict* self) {
STAT_TIMER(t0, "us_timer_dictValues");
BoxedList* rtn = new BoxedList();
rtn->ensure(self->d.size());
for (const auto& p : self->d) {
......@@ -91,7 +87,6 @@ Box* dictValues(BoxedDict* self) {
}
Box* dictKeys(BoxedDict* self) {
STAT_TIMER(t0, "us_timer_dictKeys");
RELEASE_ASSERT(isSubclass(self->cls, dict_cls), "");
BoxedList* rtn = new BoxedList();
......@@ -188,7 +183,6 @@ extern "C" int PyDict_Update(PyObject* a, PyObject* b) noexcept {
}
Box* dictGetitem(BoxedDict* self, Box* k) {
STAT_TIMER(t0, "us_timer_dictGetitem");
if (!isSubclass(self->cls, dict_cls))
raiseExcHelper(TypeError, "descriptor '__getitem__' requires a 'dict' object but received a '%s'",
getTypeName(self));
......@@ -320,7 +314,6 @@ extern "C" PyObject* PyDict_GetItemString(PyObject* dict, const char* key) noexc
}
Box* dictSetitem(BoxedDict* self, Box* k, Box* v) {
STAT_TIMER(t0, "us_timer_dictSetitem");
// printf("Starting setitem\n");
Box*& pos = self->d[k];
// printf("Got the pos\n");
......@@ -335,7 +328,6 @@ Box* dictSetitem(BoxedDict* self, Box* k, Box* v) {
}
Box* dictDelitem(BoxedDict* self, Box* k) {
STAT_TIMER(t0, "us_timer_dictDelitem");
if (!isSubclass(self->cls, dict_cls))
raiseExcHelper(TypeError, "descriptor '__delitem__' requires a 'dict' object but received a '%s'",
getTypeName(self));
......
......@@ -302,7 +302,7 @@ extern "C" BoxedGenerator::BoxedGenerator(BoxedFunctionBase* function, Box* arg1
#if STAT_TIMERS
,
prev_stack(NULL),
my_timer(generator_timer_counter)
my_timer(generator_timer_counter, 0, true)
#endif
{
......
......@@ -561,8 +561,6 @@ extern "C" int PyList_Insert(PyObject* op, Py_ssize_t where, PyObject* newitem)
}
Box* listMul(BoxedList* self, Box* rhs) {
STAT_TIMER(t0, "us_timer_listMul");
if (rhs->cls != int_cls) {
raiseExcHelper(TypeError, "can't multiply sequence by non-int of type '%s'", getTypeName(rhs));
}
......
......@@ -233,7 +233,7 @@ extern "C" void my_assert(bool b) {
extern "C" bool isSubclass(BoxedClass* child, BoxedClass* parent) {
#if EXPENSIVE_STAT_TIMERS
STAT_TIMER(t0, "us_timer_isSubclass");
STAT_TIMER(t0, "us_timer_isSubclass", 10);
#endif
return PyType_IsSubtype(child, parent);
}
......@@ -536,7 +536,7 @@ void HiddenClass::addDependence(Rewriter* rewriter) {
}
HiddenClass* HiddenClass::getOrMakeChild(llvm::StringRef attr) {
STAT_TIMER(t0, "us_timer_hiddenclass_getOrMakeChild");
STAT_TIMER(t0, "us_timer_hiddenclass_getOrMakeChild", 0);
assert(type == NORMAL);
auto it = children.find(attr);
......@@ -570,7 +570,7 @@ HiddenClass* HiddenClass::getAttrwrapperChild() {
* del attr from current HiddenClass, maintaining the order of the remaining attrs
*/
HiddenClass* HiddenClass::delAttrToMakeHC(llvm::StringRef attr) {
STAT_TIMER(t0, "us_timer_hiddenclass_delAttrToMakeHC");
STAT_TIMER(t0, "us_timer_hiddenclass_delAttrToMakeHC", 0);
assert(type == NORMAL);
int idx = getOffset(attr);
......@@ -1354,7 +1354,7 @@ Box* getattrInternalEx(Box* obj, BoxedString* attr, GetattrRewriteArgs* rewrite_
if (!cls_only) {
BoxedClass* cls = obj->cls;
if (obj->cls->tp_getattro && obj->cls->tp_getattro != PyObject_GenericGetAttr) {
STAT_TIMER(t0, "us_timer_tp_getattro");
STAT_TIMER(t0, "us_timer_slowpath_tpgetattro", 10);
Box* r = obj->cls->tp_getattro(obj, attr);
if (!r)
......@@ -1363,7 +1363,7 @@ Box* getattrInternalEx(Box* obj, BoxedString* attr, GetattrRewriteArgs* rewrite_
}
if (obj->cls->tp_getattr) {
STAT_TIMER(t0, "us_timer_tp_getattr");
STAT_TIMER(t0, "us_timer_slowpath_tpgetattr", 10);
assert(attr->data()[attr->size()] == '\0');
Box* r = obj->cls->tp_getattr(obj, const_cast<char*>(attr->data()));
......@@ -1390,7 +1390,7 @@ inline Box* getclsattrInternal(Box* obj, BoxedString* attr, GetattrRewriteArgs*
}
extern "C" Box* getclsattr(Box* obj, BoxedString* attr) {
STAT_TIMER(t0, "us_timer_slowpath_getclsattr");
STAT_TIMER(t0, "us_timer_slowpath_getclsattr", 10);
static StatCounter slowpath_getclsattr("slowpath_getclsattr");
slowpath_getclsattr.log();
......@@ -1817,7 +1817,7 @@ Box* getattrMaybeNonstring(Box* obj, Box* attr) {
}
extern "C" Box* getattr(Box* obj, BoxedString* attr) {
STAT_TIMER(t0, "us_timer_slowpath_getattr");
STAT_TIMER(t0, "us_timer_slowpath_getattr", 10);
static StatCounter slowpath_getattr("slowpath_getattr");
slowpath_getattr.log();
......@@ -2021,13 +2021,13 @@ void setattrGeneric(Box* obj, BoxedString* attr, Box* val, SetattrRewriteArgs* r
}
extern "C" void setattr(Box* obj, BoxedString* attr, Box* attr_val) {
STAT_TIMER(t0, "us_timer_slowpath_setsattr");
STAT_TIMER(t0, "us_timer_slowpath_setsattr", 10);
static StatCounter slowpath_setattr("slowpath_setattr");
slowpath_setattr.log();
if (obj->cls->tp_setattr) {
STAT_TIMER(t1, "us_timer_tp_setattr");
STAT_TIMER(t1, "us_timer_slowpath_tpsetattr", 10);
assert(attr->data()[attr->size()] == '\0');
int rtn = obj->cls->tp_setattr(obj, const_cast<char*>(attr->data()), attr_val);
......@@ -2103,7 +2103,7 @@ extern "C" void setattr(Box* obj, BoxedString* attr, Box* attr_val) {
setattr = processDescriptor(setattr, obj, obj->cls);
runtimeCallInternal(setattr, NULL, ArgPassSpec(2), attr, attr_val, NULL, NULL, NULL);
} else {
STAT_TIMER(t0, "us_timer_tp_setattro");
STAT_TIMER(t0, "us_timer_slowpath_tpsetattro", 10);
int r = tp_setattro(obj, attr, attr_val);
if (r)
throwCAPIException();
......@@ -2116,7 +2116,7 @@ bool isUserDefined(BoxedClass* cls) {
}
extern "C" bool nonzero(Box* obj) {
STAT_TIMER(t0, "us_timer_slowpath_nonzero");
STAT_TIMER(t0, "us_timer_slowpath_nonzero", 10);
assert(gc::isValidGCObject(obj));
......@@ -2211,7 +2211,7 @@ extern "C" bool nonzero(Box* obj) {
}
extern "C" BoxedString* str(Box* obj) {
STAT_TIMER(t0, "us_timer_str");
STAT_TIMER(t0, "us_timer_str", 10);
static StatCounter slowpath_str("slowpath_str");
slowpath_str.log();
......@@ -2234,7 +2234,7 @@ extern "C" BoxedString* str(Box* obj) {
}
extern "C" Box* strOrUnicode(Box* obj) {
STAT_TIMER(t0, "us_timer_strOrUnicode");
STAT_TIMER(t0, "us_timer_strOrUnicode", 10);
// Like str, but returns unicode objects unchanged.
if (obj->cls == unicode_cls) {
return obj;
......@@ -2243,7 +2243,7 @@ extern "C" Box* strOrUnicode(Box* obj) {
}
extern "C" BoxedString* repr(Box* obj) {
STAT_TIMER(t0, "us_timer_repr");
STAT_TIMER(t0, "us_timer_repr", 10);
static StatCounter slowpath_repr("slowpath_repr");
slowpath_repr.log();
......@@ -2262,7 +2262,7 @@ extern "C" BoxedString* repr(Box* obj) {
}
extern "C" BoxedString* reprOrNull(Box* obj) {
STAT_TIMER(t0, "us_timer_reprOrNull");
STAT_TIMER(t0, "us_timer_reprOrNull", 10);
try {
Box* r = repr(obj);
assert(r->cls == str_cls); // this should be checked by repr()
......@@ -2273,7 +2273,7 @@ extern "C" BoxedString* reprOrNull(Box* obj) {
}
extern "C" BoxedString* strOrNull(Box* obj) {
STAT_TIMER(t0, "us_timer_strOrNull");
STAT_TIMER(t0, "us_timer_strOrNull", 10);
try {
BoxedString* r = str(obj);
return static_cast<BoxedString*>(r);
......@@ -2283,7 +2283,7 @@ extern "C" BoxedString* strOrNull(Box* obj) {
}
extern "C" bool exceptionMatches(Box* obj, Box* cls) {
STAT_TIMER(t0, "us_timer_exceptionMatches");
STAT_TIMER(t0, "us_timer_exceptionMatches", 10);
int rtn = PyErr_GivenExceptionMatches(obj, cls);
RELEASE_ASSERT(rtn >= 0, "");
return rtn;
......@@ -2376,7 +2376,7 @@ Box* lenCallInternal(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, Arg
}
extern "C" BoxedInt* len(Box* obj) {
STAT_TIMER(t0, "us_timer_slowpath_len");
STAT_TIMER(t0, "us_timer_slowpath_len", 10);
static StatCounter slowpath_len("slowpath_len");
slowpath_len.log();
......@@ -2385,7 +2385,7 @@ extern "C" BoxedInt* len(Box* obj) {
}
extern "C" i64 unboxedLen(Box* obj) {
STAT_TIMER(t0, "us_timer_slowpath_unboxedLen");
STAT_TIMER(t0, "us_timer_slowpath_unboxedLen", 10);
static StatCounter slowpath_unboxedlen("slowpath_unboxedlen");
slowpath_unboxedlen.log();
......@@ -2742,7 +2742,7 @@ extern "C" Box* callattrInternal(Box* obj, BoxedString* attr, LookupScope scope,
extern "C" Box* callattr(Box* obj, BoxedString* attr, CallattrFlags flags, ArgPassSpec argspec, Box* arg1, Box* arg2,
Box* arg3, Box** args, const std::vector<BoxedString*>* keyword_names) {
STAT_TIMER(t0, "us_timer_slowpath_callattr");
STAT_TIMER(t0, "us_timer_slowpath_callattr", 10);
ASSERT(gc::isValidGCObject(obj), "%p", obj);
......@@ -3305,7 +3305,7 @@ Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_arg
assert(chosen_cf->is_interpreted == (chosen_cf->code == NULL));
if (chosen_cf->is_interpreted) {
STAT_TIMER(t0, "us_timer_astInterpretFunction");
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_astInterpretFunction");
return astInterpretFunction(chosen_cf, num_output_args, closure, generator, globals, oarg1, oarg2, oarg3,
oargs);
......@@ -3339,10 +3339,10 @@ Box* callCLFunc(CLFunction* f, CallRewriteArgs* rewrite_args, int num_output_arg
// distinguish lexically between calls that target jitted python
// code and calls that target to builtins.
if (f->source) {
STAT_TIMER(t0, "us_timer_chosen_cf_body_jitted");
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_chosen_cf_body_jitted");
r = callChosenCF(chosen_cf, closure, generator, oarg1, oarg2, oarg3, oargs);
} else {
STAT_TIMER(t0, "us_timer_chosen_cf_body_builtins");
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_chosen_cf_body_builtins");
r = callChosenCF(chosen_cf, closure, generator, oarg1, oarg2, oarg3, oargs);
}
......@@ -3493,7 +3493,7 @@ Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec ar
extern "C" Box* runtimeCall(Box* obj, ArgPassSpec argspec, Box* arg1, Box* arg2, Box* arg3, Box** args,
const std::vector<BoxedString*>* keyword_names) {
STAT_TIMER(t0, "us_timer_slowpath_runtimecall");
STAT_TIMER(t0, "us_timer_slowpath_runtimecall", 10);
int npassed_args = argspec.totalPassed();
......@@ -3655,7 +3655,7 @@ extern "C" Box* binopInternal(Box* lhs, Box* rhs, int op_type, bool inplace, Bin
}
extern "C" Box* binop(Box* lhs, Box* rhs, int op_type) {
STAT_TIMER(t0, "us_timer_slowpath_binop");
STAT_TIMER(t0, "us_timer_slowpath_binop", 10);
static StatCounter slowpath_binop("slowpath_binop");
slowpath_binop.log();
......@@ -3693,7 +3693,7 @@ extern "C" Box* binop(Box* lhs, Box* rhs, int op_type) {
}
extern "C" Box* augbinop(Box* lhs, Box* rhs, int op_type) {
STAT_TIMER(t0, "us_timer_slowpath_augbinop");
STAT_TIMER(t0, "us_timer_slowpath_augbinop", 10);
static StatCounter slowpath_augbinop("slowpath_augbinop");
slowpath_augbinop.log();
......@@ -3954,7 +3954,7 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
}
extern "C" Box* compare(Box* lhs, Box* rhs, int op_type) {
STAT_TIMER(t0, "us_timer_slowpath_compare");
STAT_TIMER(t0, "us_timer_slowpath_compare", 10);
static StatCounter slowpath_compare("slowpath_compare");
slowpath_compare.log();
......@@ -4012,7 +4012,7 @@ extern "C" Box* compare(Box* lhs, Box* rhs, int op_type) {
}
extern "C" Box* unaryop(Box* operand, int op_type) {
STAT_TIMER(t0, "us_timer_slowpath_unaryop");
STAT_TIMER(t0, "us_timer_slowpath_unaryop", 10);
static StatCounter slowpath_unaryop("slowpath_unaryop");
slowpath_unaryop.log();
......@@ -4028,7 +4028,7 @@ extern "C" Box* unaryop(Box* operand, int op_type) {
}
extern "C" Box* getitem(Box* value, Box* slice) {
STAT_TIMER(t0, "us_timer_slowpath_getitem");
STAT_TIMER(t0, "us_timer_slowpath_getitem", 10);
// This possibly could just be represented as a single callattr; the only tricky part
// are the error messages.
......@@ -4074,7 +4074,7 @@ extern "C" Box* getitem(Box* value, Box* slice) {
// target[slice] = value
extern "C" void setitem(Box* target, Box* slice, Box* value) {
STAT_TIMER(t0, "us_timer_slowpath_setitem");
STAT_TIMER(t0, "us_timer_slowpath_setitem", 10);
static StatCounter slowpath_setitem("slowpath_setitem");
slowpath_setitem.log();
......@@ -4110,7 +4110,7 @@ extern "C" void setitem(Box* target, Box* slice, Box* value) {
// del target[start:end:step]
extern "C" void delitem(Box* target, Box* slice) {
STAT_TIMER(t0, "us_timer_slowpath_delitem");
STAT_TIMER(t0, "us_timer_slowpath_delitem", 10);
static StatCounter slowpath_delitem("slowpath_delitem");
slowpath_delitem.log();
......@@ -4252,7 +4252,7 @@ extern "C" void delattrInternal(Box* obj, BoxedString* attr, DelattrRewriteArgs*
// del target.attr
extern "C" void delattr(Box* obj, BoxedString* attr) {
STAT_TIMER(t0, "us_timer_slowpath_delattr");
STAT_TIMER(t0, "us_timer_slowpath_delattr", 10);
static StatCounter slowpath_delattr("slowpath_delattr");
slowpath_delattr.log();
......@@ -4273,7 +4273,7 @@ extern "C" Box* createBoxedIterWrapper(Box* o) {
}
extern "C" Box* createBoxedIterWrapperIfNeeded(Box* o) {
STAT_TIMER(t0, "us_timer_slowpath_createBoxedIterWrapperIfNeeded");
STAT_TIMER(t0, "us_timer_slowpath_createBoxedIterWrapperIfNeeded", 10);
std::unique_ptr<Rewriter> rewriter(Rewriter::createRewriter(
__builtin_extract_return_addr(__builtin_return_address(0)), 1, "createBoxedIterWrapperIfNeeded"));
......@@ -4307,7 +4307,7 @@ extern "C" Box* createBoxedIterWrapperIfNeeded(Box* o) {
}
extern "C" Box* getPystonIter(Box* o) {
STAT_TIMER(t0, "us_timer_slowpath_getPystonIter");
STAT_TIMER(t0, "us_timer_slowpath_getPystonIter", 10);
Box* r = getiter(o);
// assert((typeLookup(r->cls, hasnext_str, NULL) == NULL) == (r->cls->tpp_hasnext == object_cls->tpp_hasnext));
......@@ -4369,8 +4369,7 @@ void assertValidSlotIdentifier(Box* s) {
}
Box* typeNew(Box* _cls, Box* arg1, Box* arg2, Box** _args) {
STAT_TIMER(t0, "us_timer_typeNew");
STAT_TIMER(t0, "us_timer_typeNew", 10);
Box* arg3 = _args[0];
......@@ -4950,7 +4949,8 @@ extern "C" void delGlobal(Box* globals, BoxedString* name) {
}
extern "C" Box* getGlobal(Box* globals, BoxedString* name) {
STAT_TIMER(t0, "us_timer_slowpath_getglobal");
STAT_TIMER(t0, "us_timer_slowpath_getglobal", 10);
ASSERT(gc::isValidGCObject(globals), "%p", globals);
static StatCounter slowpath_getglobal("slowpath_getglobal");
......@@ -5073,7 +5073,7 @@ void setGlobal(Box* globals, BoxedString* name, Box* value) {
}
extern "C" Box* importFrom(Box* _m, BoxedString* name) {
STAT_TIMER(t0, "us_timer_importFrom");
STAT_TIMER(t0, "us_timer_importFrom", 10);
Box* r = getattrInternal(_m, name, NULL);
if (r)
......@@ -5083,7 +5083,7 @@ extern "C" Box* importFrom(Box* _m, BoxedString* name) {
}
extern "C" Box* importStar(Box* _from_module, Box* to_globals) {
STAT_TIMER(t0, "us_timer_importStar");
STAT_TIMER(t0, "us_timer_importStar", 10);
RELEASE_ASSERT(isSubclass(_from_module->cls, module_cls), "%s", _from_module->cls->tp_name);
BoxedModule* from_module = static_cast<BoxedModule*>(_from_module);
......
......@@ -1141,7 +1141,6 @@ extern "C" Box* strMod(BoxedString* lhs, Box* rhs) {
}
extern "C" Box* strMul(BoxedString* lhs, Box* rhs) {
STAT_TIMER(t0, "us_timer_strMul");
assert(isSubclass(lhs->cls, str_cls));
int n;
......@@ -1526,7 +1525,6 @@ failed:
}
extern "C" size_t unicodeHashUnboxed(PyUnicodeObject* self) {
STAT_TIMER(t0, "us_timer_unicodeHashUnboxed");
if (self->hash != -1)
return self->hash;
......@@ -1537,7 +1535,6 @@ extern "C" size_t unicodeHashUnboxed(PyUnicodeObject* self) {
}
extern "C" Box* strHash(BoxedString* self) {
STAT_TIMER(t0, "us_timer_strHash");
assert(isSubclass(self->cls, str_cls));
StringHash<char> H;
......
......@@ -169,7 +169,6 @@ Box* tupleAdd(BoxedTuple* self, Box* rhs) {
}
Box* tupleMul(BoxedTuple* self, Box* rhs) {
STAT_TIMER(t0, "us_timer_tupleMul");
if (rhs->cls != int_cls) {
raiseExcHelper(TypeError, "can't multiply sequence by non-int of type '%s'", getTypeName(rhs));
}
......
......@@ -1419,8 +1419,6 @@ public:
}
static Box* setitem(Box* _self, Box* _key, Box* value) {
STAT_TIMER(t0, "us_timer_AttrWrapper_setitem");
RELEASE_ASSERT(_self->cls == attrwrapper_cls, "");
AttrWrapper* self = static_cast<AttrWrapper*>(_self);
......@@ -1433,7 +1431,6 @@ public:
}
static Box* setdefault(Box* _self, Box* _key, Box* value) {
STAT_TIMER(t0, "us_timer_AttrWrapper_setdefault");
RELEASE_ASSERT(_self->cls == attrwrapper_cls, "");
AttrWrapper* self = static_cast<AttrWrapper*>(_self);
......@@ -1449,7 +1446,6 @@ public:
}
static Box* get(Box* _self, Box* _key, Box* def) {
STAT_TIMER(t0, "us_timer_AttrWrapper_get");
RELEASE_ASSERT(_self->cls == attrwrapper_cls, "");
AttrWrapper* self = static_cast<AttrWrapper*>(_self);
......@@ -1464,7 +1460,6 @@ public:
}
static Box* getitem(Box* _self, Box* _key) {
STAT_TIMER(t0, "us_timer_AttrWrapper_getitem");
RELEASE_ASSERT(_self->cls == attrwrapper_cls, "");
AttrWrapper* self = static_cast<AttrWrapper*>(_self);
......@@ -1498,7 +1493,6 @@ public:
}
static Box* delitem(Box* _self, Box* _key) {
STAT_TIMER(t0, "us_timer_AttrWrapper_delitem");
RELEASE_ASSERT(_self->cls == attrwrapper_cls, "");
AttrWrapper* self = static_cast<AttrWrapper*>(_self);
......@@ -1564,7 +1558,6 @@ public:
}
static Box* values(Box* _self) {
STAT_TIMER(t0, "us_timer_AttrWrapper_values");
RELEASE_ASSERT(_self->cls == attrwrapper_cls, "");
AttrWrapper* self = static_cast<AttrWrapper*>(_self);
......@@ -1579,7 +1572,6 @@ public:
}
static Box* items(Box* _self) {
STAT_TIMER(t0, "us_timer_AttrWrapper_items");
RELEASE_ASSERT(_self->cls == attrwrapper_cls, "");
AttrWrapper* self = static_cast<AttrWrapper*>(_self);
......@@ -1649,7 +1641,6 @@ public:
}
static Box* update(Box* _self, BoxedTuple* args, BoxedDict* kwargs) {
STAT_TIMER(t0, "us_timer_AttrWrapper_update");
RELEASE_ASSERT(_self->cls == attrwrapper_cls, "");
AttrWrapper* self = static_cast<AttrWrapper*>(_self);
......
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