Commit c0ffc375 authored by Chris Toshok's avatar Chris Toshok

do beginUnwind() inside __cxa_allocate_exception so we can support 'throw e' (instead of aborting)

parent 49d146cc
......@@ -926,7 +926,7 @@ void checkAndThrowCAPIException() {
RELEASE_ASSERT(value->cls == type, "unsupported");
if (tb != None)
raiseRaw(ExcInfo(value->cls, value, tb));
throw ExcInfo(value->cls, value, tb);
raiseExc(value);
}
}
......
......@@ -635,7 +635,7 @@ extern "C" void* __cxa_allocate_exception(size_t size) noexcept {
// our exception info in curexc_*, and then unset these in __cxa_end_catch, then we'll wipe our exception info
// during unwinding!
return pyston::getExceptionStorage(pyston::getUnwind());
return pyston::getExceptionStorage(pyston::beginUnwind());
}
// Takes the value that resume() sent us in RAX, and returns a pointer to the exception object actually thrown. In our
......
......@@ -155,7 +155,7 @@ static void generatorSendInternal(BoxedGenerator* self, Box* v) {
freeGeneratorStack(self);
// don't raise StopIteration exceptions because those are handled specially.
if (!self->exception.matches(StopIteration))
raiseRaw(self->exception);
throw self->exception;
return;
}
......@@ -193,7 +193,7 @@ Box* generatorSend(Box* s, Box* v) {
self->exception = ExcInfo(nullptr, nullptr, nullptr);
if (old_exc.type == NULL)
raiseExcHelper(StopIteration, (const char*)nullptr);
raiseRaw(old_exc);
throw old_exc;
}
return self->returnValue;
......@@ -272,7 +272,7 @@ extern "C" Box* yield(BoxedGenerator* obj, Box* value) {
if (self->exception.type) {
ExcInfo e = self->exception;
self->exception = ExcInfo(NULL, NULL, NULL);
raiseRaw(e);
throw e;
}
return self->returnValue;
}
......
......@@ -49,7 +49,7 @@ Box* createAndRunModule(const std::string& name, const std::string& fn) {
compileAndRunModule(ast, module);
} catch (ExcInfo e) {
removeModule(name);
raiseRaw(e);
throw e;
}
Box* r = getSysModulesDict()->getOrNull(boxString(name));
......@@ -74,7 +74,7 @@ static Box* createAndRunModule(const std::string& name, const std::string& fn, c
compileAndRunModule(ast, module);
} catch (ExcInfo e) {
removeModule(name);
raiseRaw(e);
throw e;
}
Box* r = getSysModulesDict()->getOrNull(boxString(name));
......@@ -406,7 +406,7 @@ static Box* importSub(const std::string& name, const std::string& full_name, Box
RELEASE_ASSERT(0, "%d", sr.type);
} catch (ExcInfo e) {
removeModule(name);
raiseRaw(e);
throw e;
}
if (parent_module && parent_module != None)
......@@ -560,7 +560,7 @@ static void ensureFromlist(Box* module, Box* fromlist, std::string& buf, bool re
pathlist = getattrInternal(module, path_str, NULL);
} catch (ExcInfo e) {
if (!e.matches(AttributeError))
raiseRaw(e);
throw e;
}
if (pathlist == NULL) {
......
......@@ -727,7 +727,7 @@ void listSort(BoxedList* self, Box* cmp, Box* key, Box* reverse) {
std::stable_sort<Box**, PyLt>(self->elts->elts, self->elts->elts + self->size, PyLt());
} catch (ExcInfo e) {
remove_keys();
raiseRaw(e);
throw e;
}
remove_keys();
......
......@@ -72,8 +72,6 @@ void raiseRaw(const ExcInfo& e) {
#endif
#endif
// printf ("beginning unwind\n");
beginUnwind();
throw e;
}
......@@ -88,7 +86,7 @@ void raiseSyntaxError(const char* msg, int lineno, int col_offset, llvm::StringR
auto tb = new BoxedTraceback();
tb->addLine(LineInfo(lineno, col_offset, file, func));
raiseRaw(ExcInfo(exc->cls, exc, tb));
throw ExcInfo(exc->cls, exc, tb);
}
void raiseSyntaxErrorHelper(llvm::StringRef file, llvm::StringRef func, AST* node_at, const char* msg, ...) {
......@@ -207,7 +205,7 @@ extern "C" void raise0() {
raiseExcHelper(TypeError, "exceptions must be old-style classes or derived from BaseException, not NoneType");
exc_info->reraise = true;
raiseRaw(*exc_info);
throw * exc_info;
}
#ifndef NDEBUG
......@@ -288,7 +286,7 @@ extern "C" void raise3(Box* arg0, Box* arg1, Box* arg2) {
auto exc_info = excInfoForRaise(arg0, arg1, arg2);
exc_info.reraise = reraise;
raiseRaw(exc_info);
throw exc_info;
}
void raiseExcHelper(BoxedClass* cls, Box* arg) {
......
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