Commit e7bd664b authored by Chris Toshok's avatar Chris Toshok

move the exception stat logging to PythonUnwindSession::logException, which is...

move the exception stat logging to PythonUnwindSession::logException, which is called from cxa_throw.  remove raiseRaw and make raiseExc use throw
parent a54e06e8
......@@ -521,6 +521,23 @@ public:
BoxedTraceback::Here(line_info, reinterpret_cast<BoxedTraceback**>(&exc_info.traceback));
}
void logException() {
#if STAT_EXCEPTIONS
static StatCounter num_exceptions("num_exceptions");
num_exceptions.log();
std::string stat_name;
if (PyType_Check(exc_info.type))
stat_name = "num_exceptions_" + std::string(static_cast<BoxedClass*>(exc_info.type)->tp_name);
else
stat_name = "num_exceptions_" + std::string(exc_info.value->cls->tp_name);
Stats::log(Stats::getStatCounter(stat_name));
#if STAT_EXCEPTIONS_LOCATION
logByCurrentPythonLine(stat_name);
#endif
#endif
}
static void gcHandler(GCVisitor* v, Box* _o) {
assert(_o->cls == unwind_session_cls);
......@@ -565,6 +582,11 @@ void* getPythonUnwindSessionExceptionStorage(PythonUnwindSession* unwind) {
return state->getExcInfoStorage();
}
void throwingException(PythonUnwindSession* unwind) {
RELEASE_ASSERT(unwind && unwind == cur_unwind, "");
unwind->logException();
}
static const LineInfo lineInfoForFrame(PythonFrameIteratorImpl* frame_it) {
AST_stmt* current_stmt = frame_it->getCurrentStatement();
auto* cf = frame_it->getCF();
......
......@@ -44,6 +44,7 @@ BoxedTraceback* getTraceback();
class PythonUnwindSession;
PythonUnwindSession* beginPythonUnwindSession();
PythonUnwindSession* getActivePythonUnwindSession();
void throwingException(PythonUnwindSession* unwind_session);
void endPythonUnwindSession(PythonUnwindSession* unwind_session);
void* getPythonUnwindSessionExceptionStorage(PythonUnwindSession* unwind_session);
void unwindingThroughFrame(PythonUnwindSession* unwind_session, unw_cursor_t* cursor);
......
......@@ -670,6 +670,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);
// let unwinding.cpp know we've started unwinding
pyston::throwingException(pyston::getActivePythonUnwindSession());
pyston::unwind(exc_data);
}
......
......@@ -36,7 +36,6 @@ ExcInfo excInfoForRaise(Box*, Box*, Box*);
extern "C" void raise0() __attribute__((__noreturn__));
extern "C" void raise3(Box*, Box*, Box*) __attribute__((__noreturn__));
void raiseExc(Box* exc_obj) __attribute__((__noreturn__));
void raiseRaw(const ExcInfo& e) __attribute__((__noreturn__));
void _printStacktrace();
extern "C" Box* deopt(AST_expr* expr, Box* value);
......
......@@ -46,37 +46,8 @@ void showBacktrace() {
}
}
void raiseRaw(const ExcInfo& e) __attribute__((__noreturn__));
void raiseRaw(const ExcInfo& e) {
STAT_TIMER(t0, "us_timer_raiseraw");
// Should set these to None rather than null before getting here:
assert(e.type);
assert(e.value);
assert(e.traceback);
assert(gc::isValidGCObject(e.type));
assert(gc::isValidGCObject(e.value));
assert(gc::isValidGCObject(e.traceback));
#if STAT_EXCEPTIONS
static StatCounter num_exceptions("num_exceptions");
num_exceptions.log();
std::string stat_name;
if (PyType_Check(e.type))
stat_name = "num_exceptions_" + std::string(static_cast<BoxedClass*>(e.type)->tp_name);
else
stat_name = "num_exceptions_" + std::string(e.value->cls->tp_name);
Stats::log(Stats::getStatCounter(stat_name));
#if STAT_EXCEPTIONS_LOCATION
logByCurrentPythonLine(stat_name);
#endif
#endif
throw e;
}
void raiseExc(Box* exc_obj) {
raiseRaw(ExcInfo(exc_obj->cls, exc_obj, new BoxedTraceback()));
throw ExcInfo(exc_obj->cls, exc_obj, new BoxedTraceback());
}
// Have a special helper function for syntax errors, since we want to include the location
......
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