Commit bd1e4b54 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add some function keep-alives

I think this is more than is necessary but it's so hard to reason about that.
parent 3ee01f02
......@@ -100,6 +100,7 @@ void generatorEntry(BoxedGenerator* g) {
// call body of the generator
BoxedFunctionBase* func = g->function;
KEEP_ALIVE(func);
Box** args = g->args ? &g->args->elts[0] : nullptr;
auto r = callCLFunc<ExceptionStyle::CXX, NOT_REWRITABLE>(func->md, nullptr, func->md->numReceivedArgs(),
......
......@@ -4490,8 +4490,6 @@ Box* callCLFunc(FunctionMetadata* md, CallRewriteArgs* rewrite_args, int num_out
rewrite_args = NULL;
}
assert(0 && "I think this is where the KEEP_ALIVE should go. should also keep the rewritten version alive.");
CompiledFunction* chosen_cf = pickVersion(md, S, num_output_args, oarg1, oarg2, oarg3, oargs);
if (!chosen_cf) {
......@@ -4664,8 +4662,10 @@ Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec ar
if (obj->cls != function_cls && obj->cls != builtin_function_or_method_cls && obj->cls != instancemethod_cls) {
// TODO: maybe eventually runtimeCallInternal should just be the default tpp_call?
if (obj->cls->tpp_call.get(S)) {
KEEP_ALIVE(obj); // CPython doesn't have this, but I think they should
return obj->cls->tpp_call.call<S>(obj, rewrite_args, argspec, arg1, arg2, arg3, args, keyword_names);
} else if (S == CAPI && obj->cls->tpp_call.get<CXX>()) {
KEEP_ALIVE(obj);
try {
return obj->cls->tpp_call.call<CXX>(obj, NULL, argspec, arg1, arg2, arg3, args, keyword_names);
} catch (ExcInfo e) {
......@@ -4673,6 +4673,7 @@ Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec ar
return NULL;
}
} else if (S == CXX && obj->cls->tpp_call.get<CAPI>()) {
KEEP_ALIVE(obj);
Box* r = obj->cls->tpp_call.call<CAPI>(obj, NULL, argspec, arg1, arg2, arg3, args, keyword_names);
if (!r)
throwCAPIException();
......@@ -4784,6 +4785,7 @@ Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec ar
callable = callFunc<S>;
}
KEEP_ALIVE(f);
Box* res = callable(f, rewrite_args, argspec, arg1, arg2, arg3, args, keyword_names);
return res;
} else if (obj->cls == instancemethod_cls) {
......
......@@ -626,6 +626,7 @@ static Box* typeCallInternal(BoxedFunctionBase* f, CallRewriteArgs* rewrite_args
if (argspec.has_starargs || argspec.num_args == 0) {
// Get callFunc to expand the arguments.
// TODO: update this to use rearrangeArguments instead.
KEEP_ALIVE(f);
return callFunc<CXX>(f, rewrite_args, argspec, arg1, arg2, arg3, args, keyword_names);
}
......
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