Commit c0a273ff authored by Marius Wachtler's avatar Marius Wachtler

BST: remove the cxx_exception_count field

parent 482d2e86
...@@ -366,7 +366,7 @@ Box* ASTInterpreter::execJITedBlock(CFGBlock* b) { ...@@ -366,7 +366,7 @@ Box* ASTInterpreter::execJITedBlock(CFGBlock* b) {
assert(getPythonFrameInfo(0) == getFrameInfo()); assert(getPythonFrameInfo(0) == getFrameInfo());
stmt->cxx_exception_count++; ++getCode()->cxx_exception_count[stmt];
caughtCxxException(&e); caughtCxxException(&e);
next_block = ((BST_Invoke*)stmt)->exc_dest; next_block = ((BST_Invoke*)stmt)->exc_dest;
...@@ -774,7 +774,7 @@ Value ASTInterpreter::visit_invoke(BST_Invoke* node) { ...@@ -774,7 +774,7 @@ Value ASTInterpreter::visit_invoke(BST_Invoke* node) {
assert(getPythonFrameInfo(0) == getFrameInfo()); assert(getPythonFrameInfo(0) == getFrameInfo());
node->cxx_exception_count++; ++getCode()->cxx_exception_count[node];
caughtCxxException(&e); caughtCxxException(&e);
next_block = node->exc_dest; next_block = node->exc_dest;
......
...@@ -36,6 +36,7 @@ class IREmitter; ...@@ -36,6 +36,7 @@ class IREmitter;
struct UnwindInfo { struct UnwindInfo {
public: public:
BoxedCode* code;
BST_stmt* current_stmt; BST_stmt* current_stmt;
llvm::BasicBlock* exc_dest; llvm::BasicBlock* exc_dest;
...@@ -45,15 +46,15 @@ public: ...@@ -45,15 +46,15 @@ public:
bool hasHandler() const { return exc_dest != NULL; } bool hasHandler() const { return exc_dest != NULL; }
UnwindInfo(BST_stmt* current_stmt, llvm::BasicBlock* exc_dest, bool is_after_deopt = false) UnwindInfo(BoxedCode* code, BST_stmt* current_stmt, llvm::BasicBlock* exc_dest, bool is_after_deopt = false)
: current_stmt(current_stmt), exc_dest(exc_dest), is_after_deopt(is_after_deopt) {} : code(code), current_stmt(current_stmt), exc_dest(exc_dest), is_after_deopt(is_after_deopt) {}
ExceptionStyle preferredExceptionStyle() const; ExceptionStyle preferredExceptionStyle() const;
// Risky! This means that we can't unwind from this location, and should be used in the // Risky! This means that we can't unwind from this location, and should be used in the
// rare case that there are language-specific reasons that the statement should not unwind // rare case that there are language-specific reasons that the statement should not unwind
// (ex: loading function arguments into the appropriate scopes). // (ex: loading function arguments into the appropriate scopes).
static UnwindInfo cantUnwind() { return UnwindInfo(NULL, NULL); } static UnwindInfo cantUnwind() { return UnwindInfo(NULL, NULL, NULL); }
}; };
// TODO get rid of this // TODO get rid of this
......
...@@ -145,7 +145,7 @@ ExceptionStyle UnwindInfo::preferredExceptionStyle() const { ...@@ -145,7 +145,7 @@ ExceptionStyle UnwindInfo::preferredExceptionStyle() const {
// tend to run this check after executing the statement a somewhat-fixed // tend to run this check after executing the statement a somewhat-fixed
// number of times. // number of times.
// We might want to zero these out after we are done compiling, though. // We might want to zero these out after we are done compiling, though.
if (current_stmt->cxx_exception_count >= 10) if (code && code->cxx_exception_count[current_stmt] >= 10)
return CAPI; return CAPI;
return CXX; return CXX;
...@@ -715,7 +715,7 @@ public: ...@@ -715,7 +715,7 @@ public:
llvm::Value* createDeopt(BST_stmt* current_stmt, llvm::Value* node_value) override { llvm::Value* createDeopt(BST_stmt* current_stmt, llvm::Value* node_value) override {
llvm::Instruction* v = createIC(createDeoptIC(), (void*)pyston::deopt, { node_value }, llvm::Instruction* v = createIC(createDeoptIC(), (void*)pyston::deopt, { node_value },
UnwindInfo(current_stmt, NULL, /* is_after_deopt*/ true)); UnwindInfo(irstate->getCode(), current_stmt, NULL, /* is_after_deopt*/ true));
llvm::Value* rtn = createAfter<llvm::IntToPtrInst>(v, v, g.llvm_value_type_ptr, ""); llvm::Value* rtn = createAfter<llvm::IntToPtrInst>(v, v, g.llvm_value_type_ptr, "");
setType(rtn, RefType::OWNED); setType(rtn, RefType::OWNED);
return rtn; return rtn;
...@@ -2448,7 +2448,7 @@ private: ...@@ -2448,7 +2448,7 @@ private:
assert(!unw_info.hasHandler()); assert(!unw_info.hasHandler());
BST_Invoke* invoke = bst_cast<BST_Invoke>(node); BST_Invoke* invoke = bst_cast<BST_Invoke>(node);
doStmt(invoke->stmt, UnwindInfo(node, entry_blocks[invoke->exc_dest])); doStmt(invoke->stmt, UnwindInfo(irstate->getCode(), node, entry_blocks[invoke->exc_dest]));
assert(state == RUNNING || state == DEAD); assert(state == RUNNING || state == DEAD);
if (state == RUNNING) { if (state == RUNNING) {
...@@ -2951,7 +2951,7 @@ public: ...@@ -2951,7 +2951,7 @@ public:
doSafePoint(block->body[i]); doSafePoint(block->body[i]);
#endif #endif
doStmt(block->body[i], UnwindInfo(block->body[i], NULL)); doStmt(block->body[i], UnwindInfo(irstate->getCode(), block->body[i], NULL));
} }
if (VERBOSITY("irgenerator") >= 2) { // print ending symbol table if (VERBOSITY("irgenerator") >= 2) { // print ending symbol table
printf(" %d fini:", block->idx); printf(" %d fini:", block->idx);
......
...@@ -636,7 +636,7 @@ public: ...@@ -636,7 +636,7 @@ public:
if (!getIsReraiseFlag()) { if (!getIsReraiseFlag()) {
// TODO: shouldn't fetch this multiple times? // TODO: shouldn't fetch this multiple times?
frame_iter.getCurrentStatement()->cxx_exception_count++; ++frame_iter.getFrameInfo()->code->cxx_exception_count[frame_iter.getCurrentStatement()];
exceptionAtLine(&exc_info.traceback); exceptionAtLine(&exc_info.traceback);
} else } else
getIsReraiseFlag() = false; getIsReraiseFlag() = false;
......
...@@ -134,7 +134,6 @@ public: ...@@ -134,7 +134,6 @@ public:
const BST_TYPE::BST_TYPE type; const BST_TYPE::BST_TYPE type;
uint32_t lineno; uint32_t lineno;
int cxx_exception_count = 0;
virtual void accept(BSTVisitor* v) = 0; virtual void accept(BSTVisitor* v) = 0;
virtual void accept_stmt(StmtVisitor* v) = 0; virtual void accept_stmt(StmtVisitor* v) = 0;
......
...@@ -1120,6 +1120,7 @@ public: ...@@ -1120,6 +1120,7 @@ public:
long bjit_num_inside = 0; long bjit_num_inside = 0;
std::vector<std::unique_ptr<JitCodeBlock>> code_blocks; std::vector<std::unique_ptr<JitCodeBlock>> code_blocks;
ICInvalidator dependent_interp_callsites; ICInvalidator dependent_interp_callsites;
llvm::DenseMap<BST_stmt*, int> cxx_exception_count;
// Functions can provide an "internal" version, which will get called instead // Functions can provide an "internal" version, which will get called instead
......
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