Commit 06dd454c authored by Kevin Modzelewski's avatar Kevin Modzelewski

Fix all other uses of addGuard

Hopefully this doesn't end up keeping things alive for too much
extra time.
parent a8b225a5
...@@ -972,8 +972,10 @@ Box* slotTpGetattrHookInternal(Box* self, BoxedString* name, GetattrRewriteArgs* ...@@ -972,8 +972,10 @@ Box* slotTpGetattrHookInternal(Box* self, BoxedString* name, GetattrRewriteArgs*
if (rewrite_args) { if (rewrite_args) {
// Fetching getattribute should have done the appropriate guarding on whether or not // Fetching getattribute should have done the appropriate guarding on whether or not
// getattribute exists. // getattribute exists.
if (getattribute) if (getattribute) {
r_getattribute->addGuard((intptr_t)getattribute); r_getattribute->addGuard((intptr_t)getattribute);
rewrite_args->rewriter->addGCReference(getattribute);
}
GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, rewrite_args->obj, rewrite_args->destination); GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, rewrite_args->obj, rewrite_args->destination);
try { try {
......
...@@ -564,6 +564,7 @@ void instanceSetattroInternal(Box* _inst, Box* _attr, STOLEN(Box*) value, Setatt ...@@ -564,6 +564,7 @@ void instanceSetattroInternal(Box* _inst, Box* _attr, STOLEN(Box*) value, Setatt
if (rewrite_args) { if (rewrite_args) {
RewriterVar* inst_r = rewrite_args->obj->getAttr(offsetof(BoxedInstance, inst_cls)); RewriterVar* inst_r = rewrite_args->obj->getAttr(offsetof(BoxedInstance, inst_cls));
inst_r->addGuard((uint64_t)inst->inst_cls); inst_r->addGuard((uint64_t)inst->inst_cls);
rewrite_args->rewriter->addGCReference(inst->inst_cls);
GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, inst_r, GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, inst_r,
rewrite_args->rewriter->getReturnDestination()); rewrite_args->rewriter->getReturnDestination());
Box* setattr = classLookup<REWRITABLE>(inst->inst_cls, setattr_str, &grewrite_args); Box* setattr = classLookup<REWRITABLE>(inst->inst_cls, setattr_str, &grewrite_args);
......
...@@ -3755,6 +3755,7 @@ Box* callattrInternal(Box* obj, BoxedString* attr, LookupScope scope, CallattrRe ...@@ -3755,6 +3755,7 @@ Box* callattrInternal(Box* obj, BoxedString* attr, LookupScope scope, CallattrRe
if (rewrite_args) { if (rewrite_args) {
r_val->addGuard((int64_t)val); r_val->addGuard((int64_t)val);
rewrite_args->rewriter->addGCReference(val);
rewrite_args->obj = r_val; rewrite_args->obj = r_val;
rewrite_args->func_guarded = true; rewrite_args->func_guarded = true;
} }
...@@ -5255,6 +5256,7 @@ Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec ar ...@@ -5255,6 +5256,7 @@ Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec ar
if (rewrite_args && !rewrite_args->func_guarded) { if (rewrite_args && !rewrite_args->func_guarded) {
r_im_func->addGuard((intptr_t)im->func); r_im_func->addGuard((intptr_t)im->func);
rewrite_args->rewriter->addGCReference(im->func);
rewrite_args->func_guarded = true; rewrite_args->func_guarded = true;
} }
...@@ -5567,8 +5569,11 @@ Box* binopInternal(Box* lhs, Box* rhs, int op_type, BinopRewriteArgs* rewrite_ar ...@@ -5567,8 +5569,11 @@ Box* binopInternal(Box* lhs, Box* rhs, int op_type, BinopRewriteArgs* rewrite_ar
RewriterVar* r_lhs_cls = r_lhs->getAttr(offsetof(Box, cls))->setType(RefType::BORROWED); RewriterVar* r_lhs_cls = r_lhs->getAttr(offsetof(Box, cls))->setType(RefType::BORROWED);
r_lhs_cls->addGuard((intptr_t)lhs->cls); r_lhs_cls->addGuard((intptr_t)lhs->cls);
rewrite_args->rewriter->addGCReference(lhs->cls);
RewriterVar* r_rhs_cls = r_rhs->getAttr(offsetof(Box, cls))->setType(RefType::BORROWED); RewriterVar* r_rhs_cls = r_rhs->getAttr(offsetof(Box, cls))->setType(RefType::BORROWED);
r_rhs_cls->addGuard((intptr_t)rhs->cls); r_rhs_cls->addGuard((intptr_t)rhs->cls);
rewrite_args->rewriter->addGCReference(rhs->cls);
r_lhs_cls->addAttrGuard(offsetof(BoxedClass, tp_mro), (intptr_t)lhs->cls->tp_mro); r_lhs_cls->addAttrGuard(offsetof(BoxedClass, tp_mro), (intptr_t)lhs->cls->tp_mro);
r_rhs_cls->addAttrGuard(offsetof(BoxedClass, tp_mro), (intptr_t)rhs->cls->tp_mro); r_rhs_cls->addAttrGuard(offsetof(BoxedClass, tp_mro), (intptr_t)rhs->cls->tp_mro);
...@@ -6786,6 +6791,7 @@ extern "C" Box* createBoxedIterWrapperIfNeeded(Box* o) { ...@@ -6786,6 +6791,7 @@ extern "C" Box* createBoxedIterWrapperIfNeeded(Box* o) {
} else if (r) { } else if (r) {
RewriterVar* rtn = rewrite_args.getReturn(ReturnConvention::HAS_RETURN); RewriterVar* rtn = rewrite_args.getReturn(ReturnConvention::HAS_RETURN);
rtn->addGuard((uint64_t)r); rtn->addGuard((uint64_t)r);
rewrite_args.rewriter->addGCReference(r);
rewriter->commitReturning(r_o); rewriter->commitReturning(r_o);
return incref(o); return incref(o);
} else /* if (!r) */ { } else /* if (!r) */ {
......
...@@ -823,6 +823,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo ...@@ -823,6 +823,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
if (rewrite_args) { if (rewrite_args) {
rewrite_args->arg1->addGuard((intptr_t)cls); rewrite_args->arg1->addGuard((intptr_t)cls);
rewrite_args->rewriter->addGCReference(cls);
} }
// Special-case unicode for now, maybe there's something about this that can eventually be generalized: // Special-case unicode for now, maybe there's something about this that can eventually be generalized:
...@@ -1083,6 +1084,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo ...@@ -1083,6 +1084,7 @@ static Box* typeCallInner(CallRewriteArgs* rewrite_args, ArgPassSpec argspec, Bo
if (init_attr) { if (init_attr) {
r_init = grewrite_args.getReturn(ReturnConvention::HAS_RETURN); r_init = grewrite_args.getReturn(ReturnConvention::HAS_RETURN);
r_init->addGuard((intptr_t)init_attr); r_init->addGuard((intptr_t)init_attr);
rewrite_args->rewriter->addGCReference(init_attr);
} else { } else {
grewrite_args.assertReturnConvention(ReturnConvention::NO_RETURN); grewrite_args.assertReturnConvention(ReturnConvention::NO_RETURN);
} }
......
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