Commit 91df8ebc authored by Kevin Modzelewski's avatar Kevin Modzelewski

Ref fixes

parent 7ebd2eb4
......@@ -1020,7 +1020,7 @@ extern "C" void abort() {
// In case displaying the traceback recursively calls abort:
static bool recursive = false;
if (!recursive && (uint64_t)PyTraceBack_Type.ob_refcnt > 0) {
if (!recursive && !IN_SHUTDOWN) {
recursive = true;
Stats::dump();
fprintf(stderr, "Someone called abort!\n");
......
......@@ -36,6 +36,12 @@ public:
typedef typename map_type::const_iterator const_iterator;
typedef typename std::vector<TVal>::size_type size_type;
void clear() {
map.clear();
vec.clear();
free_list.clear();
}
iterator find(TKey key) { return map.find(key); }
iterator begin() noexcept { return map.begin(); }
......
......@@ -110,7 +110,8 @@ extern "C" PyObject* PyImport_ExecCodeModuleEx(const char* name, PyObject* co, c
}
extern "C" Box* import(int level, Box* from_imports, llvm::StringRef module_name) {
Box* rtn = PyImport_ImportModuleLevel(module_name.str().c_str(), getGlobalsDict(), NULL, from_imports, level);
Box* rtn = PyImport_ImportModuleLevel(module_name.str().c_str(), autoDecref(getGlobalsDict()), NULL, from_imports,
level);
if (!rtn)
throwCAPIException();
return rtn;
......
......@@ -5780,7 +5780,8 @@ Box* getitemInternal(Box* target, Box* slice, GetitemRewriteArgs* rewrite_args)
// (after guarding it's not null), or maybe not. But the rewriter doesn't currently
// support calling a RewriterVar (can only call fixed function addresses).
r_m->addAttrGuard(offsetof(PyMappingMethods, mp_subscript), (intptr_t)m->mp_subscript);
RewriterVar* r_rtn = rewrite_args->rewriter->call(true, (void*)m->mp_subscript, r_obj, r_slice);
RewriterVar* r_rtn
= rewrite_args->rewriter->call(true, (void*)m->mp_subscript, r_obj, r_slice)->setType(RefType::OWNED);
if (S == CXX)
rewrite_args->rewriter->checkAndThrowCAPIException(r_rtn);
rewrite_args->out_success = true;
......@@ -6506,6 +6507,7 @@ Box* _typeNew(BoxedClass* metatype, BoxedString* name, BoxedTuple* bases, BoxedD
static BoxedString* module_str = getStaticString("__module__");
if (!made->hasattr(module_str)) {
Box* gl = getGlobalsDict();
AUTO_DECREF(gl);
static BoxedString* name_str = getStaticString("__name__");
Box* attr = PyDict_GetItem(gl, name_str);
if (attr)
......
......@@ -3485,6 +3485,14 @@ void BoxedModule::dealloc(Box* b) noexcept {
BoxedModule::clear(self);
self->str_constants.~ContiguousMap();
self->unicode_constants.~ContiguousMap();
self->int_constants.~ContiguousMap();
self->float_constants.~ContiguousMap();
self->imaginary_constants.~ContiguousMap();
self->long_constants.~ContiguousMap();
assert(!self->keep_alive.size());
b->cls->tp_free(self);
}
......@@ -3499,7 +3507,7 @@ void clearContiguousMap(CM& cm) {
for (auto&& p : cm) {
Py_DECREF(cm.getMapped(p.second));
}
cm.~ContiguousMap();
cm.clear();
}
int BoxedModule::clear(Box* b) noexcept {
......
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