Commit 02483cc1 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Save the exc_info in JITted code as well

parent b4d71529
......@@ -371,6 +371,7 @@ private:
case AST_LangPrimitive::IMPORT_NAME:
return UNKNOWN;
case AST_LangPrimitive::NONE:
case AST_LangPrimitive::SET_EXC_INFO:
return NONE;
case AST_LangPrimitive::NONZERO:
return BOOL;
......
......@@ -600,6 +600,30 @@ private:
return boolFromI1(emitter, v);
}
case AST_LangPrimitive::SET_EXC_INFO: {
assert(node->args.size() == 3);
CompilerVariable* type = evalExpr(node->args[0], unw_info);
CompilerVariable* value = evalExpr(node->args[1], unw_info);
CompilerVariable* traceback = evalExpr(node->args[2], unw_info);
auto* builder = emitter.getBuilder();
llvm::Value* frame_info = irstate->getFrameInfoVar();
llvm::Value* exc_info = builder->CreateConstInBoundsGEP2_32(frame_info, 0, 0);
assert(exc_info->getType() == g.llvm_excinfo_type->getPointerTo());
ConcreteCompilerVariable* converted_type = type->makeConverted(emitter, UNKNOWN);
builder->CreateStore(converted_type->getValue(), builder->CreateConstInBoundsGEP2_32(exc_info, 0, 0));
converted_type->decvref(emitter);
ConcreteCompilerVariable* converted_value = value->makeConverted(emitter, UNKNOWN);
builder->CreateStore(converted_value->getValue(), builder->CreateConstInBoundsGEP2_32(exc_info, 0, 1));
converted_value->decvref(emitter);
ConcreteCompilerVariable* converted_traceback = traceback->makeConverted(emitter, UNKNOWN);
builder->CreateStore(converted_traceback->getValue(), builder->CreateConstInBoundsGEP2_32(exc_info, 0, 2));
converted_traceback->decvref(emitter);
return getNone();
}
default:
RELEASE_ASSERT(0, "%d", node->opcode);
}
......
......@@ -236,6 +236,9 @@ public:
if (loc.type == StackMap::Record::Location::LocationType::Register) {
// TODO: need to make sure we deal with patchpoints appropriately
return getReg(loc.regnum);
} else if (loc.type == StackMap::Record::Location::LocationType::Direct) {
uint64_t reg_val = getReg(loc.regnum);
return reg_val + loc.offset;
} else if (loc.type == StackMap::Record::Location::LocationType::Indirect) {
uint64_t reg_val = getReg(loc.regnum);
uint64_t addr = reg_val + loc.offset;
......@@ -283,6 +286,11 @@ public:
FrameInfo* getFrameInfo() {
if (id.type == PythonFrameId::COMPILED) {
CompiledFunction* cf = getCF();
assert(cf->location_map->frameInfoFound());
const auto& frame_info_loc = cf->location_map->frame_info_location;
return reinterpret_cast<FrameInfo*>(readLocation(frame_info_loc));
} else if (id.type == PythonFrameId::INTERPRETED) {
return getFrameInfoForInterpretedFrame((void*)id.bp);
}
......
......@@ -100,6 +100,11 @@ static std::vector<const LineInfo*> last_tb;
void raiseRaw(const ExcInfo& e) __attribute__((__noreturn__));
void raiseRaw(const ExcInfo& e) {
// Should set these to None before getting here:
assert(e.type);
assert(e.value);
assert(e.traceback);
// Using libgcc:
throw e;
......@@ -112,7 +117,7 @@ void raiseExc(Box* exc_obj) {
last_tb = std::move(entries);
last_exc = exc_obj;
raiseRaw(ExcInfo(exc_obj->cls, exc_obj, NULL));
raiseRaw(ExcInfo(exc_obj->cls, exc_obj, None));
}
// Have a special helper function for syntax errors, since we want to include the location
......@@ -125,7 +130,7 @@ void raiseSyntaxError(const char* msg, int lineno, int col_offset, const std::st
// TODO: leaks this!
last_tb.push_back(new LineInfo(lineno, col_offset, file, func));
raiseRaw(ExcInfo(SyntaxError, last_exc, NULL));
raiseRaw(ExcInfo(SyntaxError, last_exc, None));
}
static void _printTraceback(const std::vector<const LineInfo*>& tb) {
......
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