Commit 3b9634c9 authored by Kevin Modzelewski's avatar Kevin Modzelewski

[dont merge] reference checking helper function

parent 0f8b5369
......@@ -174,6 +174,10 @@ void addDecrefs(llvm::Value* v, bool nullable, int num_refs, llvm::Instruction*
getConstantInt(num_refs, g.i64), "", decref_pt);
new llvm::StoreInst(new_refcount, refcount_ptr, decref_pt);
#ifdef Py_REF_DEBUG
llvm::CallInst::Create(g.funcs.checkRefs, {v}, "", decref_pt);
#endif
llvm::BasicBlock* cur_block = decref_pt->getParent();
llvm::BasicBlock* continue_block = cur_block->splitBasicBlock(decref_pt);
llvm::BasicBlock* dealloc_block
......
......@@ -322,6 +322,7 @@ void initGlobalFuncs(GlobalState& g) {
GET(caughtCapiException);
GET(reraiseCapiExcAsCxx);
GET(deopt);
GET(checkRefs);
GET(div_float_float);
GET(floordiv_float_float);
......
......@@ -53,6 +53,7 @@ struct GlobalFuncs {
llvm::Value* raise0, *raise0_capi, *raise3, *raise3_capi, *rawThrow;
llvm::Value* PyErr_Fetch, *PyErr_NormalizeException, *PyErr_Restore, *caughtCapiException, *reraiseCapiExcAsCxx;
llvm::Value* deopt;
llvm::Value* checkRefs;
llvm::Value* div_float_float, *floordiv_float_float, *mod_float_float, *pow_float_float;
......
......@@ -136,6 +136,7 @@ void force() {
FORCE(caughtCapiException);
FORCE(reraiseCapiExcAsCxx);
FORCE(deopt);
FORCE(checkRefs);
FORCE(div_i64_i64);
FORCE(mod_i64_i64);
......
......@@ -6894,4 +6894,8 @@ extern "C" void boxedLocalsDel(Box* boxedLocals, BoxedString* attr) {
}
d.erase(it);
}
extern "C" void checkRefs(Box* b) {
RELEASE_ASSERT(b->ob_refcnt >= 0, "%ld", b->ob_refcnt);
}
}
......@@ -229,5 +229,7 @@ extern "C" void delGlobal(Box* globals, BoxedString* name);
extern "C" void boxedLocalsSet(Box* boxedLocals, BoxedString* attr, Box* val);
extern "C" Box* boxedLocalsGet(Box* boxedLocals, BoxedString* attr, Box* globals);
extern "C" void boxedLocalsDel(Box* boxedLocals, BoxedString* attr);
extern "C" void checkRefs(Box* b);
}
#endif
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