Commit 2d4fd67f authored by Kevin Modzelewski's avatar Kevin Modzelewski

More refcount fixes

parent d0585d43
...@@ -281,16 +281,18 @@ void ASTInterpreter::initArguments(BoxedClosure* _closure, BoxedGenerator* _gene ...@@ -281,16 +281,18 @@ void ASTInterpreter::initArguments(BoxedClosure* _closure, BoxedGenerator* _gene
int i = 0; int i = 0;
for (auto& name : param_names.arg_names) { for (auto& name : param_names.arg_names) {
doStore(name, Value(getArg(i++, arg1, arg2, arg3, args), 0)); doStore(name, Value(incref(getArg(i++, arg1, arg2, arg3, args)), 0));
} }
if (param_names.vararg_name) if (param_names.vararg_name)
doStore(param_names.vararg_name, Value(getArg(i++, arg1, arg2, arg3, args), 0)); doStore(param_names.vararg_name, Value(incref(getArg(i++, arg1, arg2, arg3, args)), 0));
if (param_names.kwarg_name) { if (param_names.kwarg_name) {
Box* val = getArg(i++, arg1, arg2, arg3, args); Box* val = getArg(i++, arg1, arg2, arg3, args);
if (!val) if (!val)
val = createDict(); val = createDict();
else
Py_INCREF(val);
doStore(param_names.kwarg_name, Value(val, 0)); doStore(param_names.kwarg_name, Value(val, 0));
} }
assert(i == param_names.totalParameters()); assert(i == param_names.totalParameters());
......
...@@ -191,8 +191,8 @@ extern "C" void printHelper(Box* dest, Box* var, bool nl) { ...@@ -191,8 +191,8 @@ extern "C" void printHelper(Box* dest, Box* var, bool nl) {
// begin code for handling of softspace // begin code for handling of softspace
bool new_softspace = !nl; bool new_softspace = !nl;
if (softspace(dest, new_softspace)) if (softspace(dest, new_softspace))
callattrInternal<CXX, NOT_REWRITABLE>(dest, write_str, CLASS_OR_INST, 0, ArgPassSpec(1), space_str, 0, 0, 0, autoDecref(callattrInternal<CXX, NOT_REWRITABLE>(dest, write_str, CLASS_OR_INST, 0, ArgPassSpec(1),
0); space_str, 0, 0, 0, 0));
Box* str_or_unicode_var = (var->cls == unicode_cls) ? incref(var) : str(var); Box* str_or_unicode_var = (var->cls == unicode_cls) ? incref(var) : str(var);
Box* write_rtn = callattrInternal<CXX, NOT_REWRITABLE>(dest, write_str, CLASS_OR_INST, 0, ArgPassSpec(1), Box* write_rtn = callattrInternal<CXX, NOT_REWRITABLE>(dest, write_str, CLASS_OR_INST, 0, ArgPassSpec(1),
...@@ -4156,7 +4156,7 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe ...@@ -4156,7 +4156,7 @@ Box* callFunc(BoxedFunctionBase* func, CallRewriteArgs* rewrite_args, ArgPassSpe
Py_XDECREF(arg2); Py_XDECREF(arg2);
Py_XDECREF(arg3); Py_XDECREF(arg3);
for (int i = 0; i < num_output_args - 3; i++) { for (int i = 0; i < num_output_args - 3; i++) {
Py_DECREF(oargs[i]); Py_XDECREF(oargs[i]);
} }
if (rewrite_args) { if (rewrite_args) {
RELEASE_ASSERT(num_output_args <= 3, "figure out vrefs for arg array"); RELEASE_ASSERT(num_output_args <= 3, "figure out vrefs for arg array");
......
...@@ -442,7 +442,7 @@ std::string BoxedModule::name() { ...@@ -442,7 +442,7 @@ std::string BoxedModule::name() {
} }
} }
BoxedString* BoxedModule::getStringConstant(llvm::StringRef ast_str, bool intern) { BORROWED(BoxedString*) BoxedModule::getStringConstant(llvm::StringRef ast_str, bool intern) {
BoxedString*& r = str_constants[ast_str]; BoxedString*& r = str_constants[ast_str];
if (intern) { if (intern) {
// If we had previously created a box for this string, we have to create a new // If we had previously created a box for this string, we have to create a new
...@@ -4413,5 +4413,8 @@ extern "C" void Py_Finalize() noexcept { ...@@ -4413,5 +4413,8 @@ extern "C" void Py_Finalize() noexcept {
teardownCodegen(); teardownCodegen();
PRINT_TOTAL_REFS(); PRINT_TOTAL_REFS();
#ifdef Py_REF_DEBUG
assert(_Py_RefTotal == 0);
#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