Commit 40df4bf5 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Separate out some more stattimers

- "Override" the stattimer stack while we are throwing an exception.
- Mark some more things as being back in "builtins" code.
parent e1ed10e8
......@@ -25,6 +25,7 @@ namespace pyston {
#if STAT_TIMERS
__thread StatTimer* StatTimer::stack;
__thread uint64_t* StatTimer::counter_override;
StatTimer* StatTimer::swapStack(StatTimer* s) {
uint64_t at_time = getCPUTicks();
......
......@@ -129,10 +129,22 @@ private:
int avoidability;
bool reset_avoidability;
static __thread uint64_t* counter_override;
public:
StatTimer(uint64_t* counter, int avoidability, bool reset_avoidability = false)
: _statcounter(counter), avoidability(avoidability), reset_avoidability(reset_avoidability) {}
static void overrideCounter(uint64_t* new_counter) {
assert(!counter_override);
counter_override = new_counter;
}
static void finishOverride() {
assert(counter_override);
counter_override = NULL;
}
void pushNonTopLevel() {
#ifndef NDEBUG
_start_time = 0;
......@@ -187,7 +199,10 @@ private:
assert(at_time > _start_time);
uint64_t _duration = at_time - _start_time;
Stats::log(_statcounter, _duration);
if (counter_override)
Stats::log(counter_override, _duration);
else
Stats::log(_statcounter, _duration);
_start_time = 0;
}
......
......@@ -561,6 +561,9 @@ static inline void unwind_loop(ExcInfo* exc_data) {
// we're transfering control to a non-cleanup landing pad.
// i.e. a catch block. thus ends our unwind session.
endPythonUnwindSession(unwind_session);
#if STAT_TIMERS
pyston::StatTimer::finishOverride();
#endif
}
static_assert(THREADING_USE_GIL, "have to make the unwind session usage in this file thread safe!");
// there is a python unwinding implementation detail leaked
......@@ -660,6 +663,10 @@ extern "C" void __cxa_end_catch() {
#define EXCINFO_TYPE_INFO _ZTIN6pyston7ExcInfoE
extern "C" std::type_info EXCINFO_TYPE_INFO;
#if STAT_TIMERS
static uint64_t* unwinding_stattimer = pyston::Stats::getStatCounter("us_timer_unwinding");
#endif
extern "C" void __cxa_throw(void* exc_obj, std::type_info* tinfo, void (*dtor)(void*)) {
assert(!pyston::in_cleanup_code);
assert(exc_obj);
......@@ -671,6 +678,9 @@ extern "C" void __cxa_throw(void* exc_obj, std::type_info* tinfo, void (*dtor)(v
pyston::ExcInfo* exc_data = (pyston::ExcInfo*)exc_obj;
checkExcInfo(exc_data);
#if STAT_TIMERS
pyston::StatTimer::overrideCounter(unwinding_stattimer);
#endif
// let unwinding.cpp know we've started unwinding
pyston::throwingException(pyston::getActivePythonUnwindSession());
pyston::unwind(exc_data);
......
......@@ -289,23 +289,35 @@ Box* BoxedMethodDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args, A
Box* rtn;
if (call_flags == METH_NOARGS) {
rtn = (Box*)self->method->ml_meth(oarg1, NULL);
{
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_in_builtins");
rtn = (Box*)self->method->ml_meth(oarg1, NULL);
}
if (rewrite_args)
rewrite_args->out_rtn
= rewrite_args->rewriter->call(true, (void*)self->method->ml_meth, rewrite_args->arg1,
rewrite_args->rewriter->loadConst(0, Location::forArg(1)));
} else if (call_flags == METH_VARARGS) {
rtn = (Box*)self->method->ml_meth(oarg1, oarg2);
{
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_in_builtins");
rtn = (Box*)self->method->ml_meth(oarg1, oarg2);
}
if (rewrite_args)
rewrite_args->out_rtn = rewrite_args->rewriter->call(true, (void*)self->method->ml_meth, rewrite_args->arg1,
rewrite_args->arg2);
} else if (call_flags == (METH_VARARGS | METH_KEYWORDS)) {
rtn = (Box*)((PyCFunctionWithKeywords)self->method->ml_meth)(oarg1, oarg2, oarg3);
{
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_in_builtins");
rtn = (Box*)((PyCFunctionWithKeywords)self->method->ml_meth)(oarg1, oarg2, oarg3);
}
if (rewrite_args)
rewrite_args->out_rtn = rewrite_args->rewriter->call(true, (void*)self->method->ml_meth, rewrite_args->arg1,
rewrite_args->arg2, rewrite_args->arg3);
} else if (call_flags == METH_O) {
rtn = (Box*)self->method->ml_meth(oarg1, oarg2);
{
UNAVOIDABLE_STAT_TIMER(t0, "us_timer_in_builtins");
rtn = (Box*)self->method->ml_meth(oarg1, oarg2);
}
if (rewrite_args)
rewrite_args->out_rtn = rewrite_args->rewriter->call(true, (void*)self->method->ml_meth, rewrite_args->arg1,
rewrite_args->arg2);
......
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