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

Ref fixes

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