Commit 68b5c5ea authored by Kevin Modzelewski's avatar Kevin Modzelewski Committed by Kevin Modzelewski

Rewrite calls to tp_getattro

Only do this for calls with immortally-interned strings so that
we can side-step the track-gc-references-in-ics issue for now.
parent 0c84c153
......@@ -1393,6 +1393,23 @@ Box* getattrInternalEx(Box* obj, BoxedString* attr, GetattrRewriteArgs* rewrite_
Box* r = obj->cls->tp_getattro(obj, attr);
if (!r)
throwCAPIException();
// If attr is immortal, then we are free to write an embedded reference to it.
// Immortal are (unfortunately) common right now, so this is an easy way to get
// around the fact that we don't currently scan ICs for GC references, but eventually
// we should just add that.
if (rewrite_args && attr->interned_state == SSTATE_INTERNED_IMMORTAL) {
// In theory we could also just guard that the tp_getattro slot is non-null and then call
// into it, instead of guarding that it is the same as it is here.
rewrite_args->obj->getAttr(offsetof(Box, cls))
->addAttrGuard(offsetof(BoxedClass, tp_getattro), (uint64_t)obj->cls->tp_getattro);
auto r_box = rewrite_args->rewriter->loadConst((intptr_t)attr);
auto r_rtn = rewrite_args->rewriter->call(true, (void*)obj->cls->tp_getattro, rewrite_args->obj, r_box);
rewrite_args->rewriter->call(true, (void*)checkAndThrowCAPIException);
rewrite_args->out_rtn = r_rtn;
rewrite_args->out_success = true;
}
return r;
}
......
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