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

Rename "more_guards_after" to "call_done_guarding"

(which has flipped value)
should hopefully be more clear what this is for -- at least
I hope that's what this is for.
parent 55c2366f
...@@ -58,15 +58,15 @@ struct GetattrRewriteArgs { ...@@ -58,15 +58,15 @@ struct GetattrRewriteArgs {
Rewriter* rewriter; Rewriter* rewriter;
RewriterVarUsage obj; RewriterVarUsage obj;
Location destination; Location destination;
bool more_guards_after; bool call_done_guarding;
bool out_success; bool out_success;
RewriterVarUsage out_rtn; RewriterVarUsage out_rtn;
bool obj_hcls_guarded; bool obj_hcls_guarded;
GetattrRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& obj, Location destination, bool more_guards_after) GetattrRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& obj, Location destination, bool call_done_guarding)
: rewriter(rewriter), obj(std::move(obj)), destination(destination), more_guards_after(more_guards_after), : rewriter(rewriter), obj(std::move(obj)), destination(destination), call_done_guarding(call_done_guarding),
out_success(false), out_rtn(RewriterVarUsage::empty()), obj_hcls_guarded(false) {} out_success(false), out_rtn(RewriterVarUsage::empty()), obj_hcls_guarded(false) {}
~GetattrRewriteArgs() { ~GetattrRewriteArgs() {
...@@ -81,12 +81,12 @@ struct GetattrRewriteArgs { ...@@ -81,12 +81,12 @@ struct GetattrRewriteArgs {
struct SetattrRewriteArgs { struct SetattrRewriteArgs {
Rewriter* rewriter; Rewriter* rewriter;
RewriterVarUsage obj, attrval; RewriterVarUsage obj, attrval;
bool more_guards_after; bool call_done_guarding;
bool out_success; bool out_success;
SetattrRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& obj, RewriterVarUsage&& attrval, bool more_guards_after) SetattrRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& obj, RewriterVarUsage&& attrval, bool call_done_guarding)
: rewriter(rewriter), obj(std::move(obj)), attrval(std::move(attrval)), more_guards_after(more_guards_after), : rewriter(rewriter), obj(std::move(obj)), attrval(std::move(attrval)), call_done_guarding(call_done_guarding),
out_success(false) {} out_success(false) {}
~SetattrRewriteArgs() { ~SetattrRewriteArgs() {
...@@ -101,12 +101,12 @@ struct SetattrRewriteArgs { ...@@ -101,12 +101,12 @@ struct SetattrRewriteArgs {
struct DelattrRewriteArgs { struct DelattrRewriteArgs {
Rewriter* rewriter; Rewriter* rewriter;
RewriterVarUsage obj; RewriterVarUsage obj;
bool more_guards_after; bool call_done_guarding;
bool out_success; bool out_success;
DelattrRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& obj, bool more_guards_after) DelattrRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& obj, bool call_done_guarding)
: rewriter(rewriter), obj(std::move(obj)), more_guards_after(more_guards_after), out_success(false) {} : rewriter(rewriter), obj(std::move(obj)), call_done_guarding(call_done_guarding), out_success(false) {}
~DelattrRewriteArgs() { ~DelattrRewriteArgs() {
if (!out_success) { if (!out_success) {
...@@ -121,13 +121,13 @@ struct LenRewriteArgs { ...@@ -121,13 +121,13 @@ struct LenRewriteArgs {
Rewriter* rewriter; Rewriter* rewriter;
RewriterVarUsage obj; RewriterVarUsage obj;
Location destination; Location destination;
bool more_guards_after; bool call_done_guarding;
bool out_success; bool out_success;
RewriterVarUsage out_rtn; RewriterVarUsage out_rtn;
LenRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& obj, Location destination, bool more_guards_after) LenRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& obj, Location destination, bool call_done_guarding)
: rewriter(rewriter), obj(std::move(obj)), destination(destination), more_guards_after(more_guards_after), : rewriter(rewriter), obj(std::move(obj)), destination(destination), call_done_guarding(call_done_guarding),
out_success(false), out_rtn(RewriterVarUsage::empty()) {} out_success(false), out_rtn(RewriterVarUsage::empty()) {}
~LenRewriteArgs() { ~LenRewriteArgs() {
...@@ -146,15 +146,15 @@ struct CallRewriteArgs { ...@@ -146,15 +146,15 @@ struct CallRewriteArgs {
bool func_guarded; bool func_guarded;
bool args_guarded; bool args_guarded;
Location destination; Location destination;
bool more_guards_after; bool call_done_guarding;
bool out_success; bool out_success;
RewriterVarUsage out_rtn; RewriterVarUsage out_rtn;
CallRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& obj, Location destination, bool more_guards_after) CallRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& obj, Location destination, bool call_done_guarding)
: rewriter(rewriter), obj(std::move(obj)), arg1(RewriterVarUsage::empty()), arg2(RewriterVarUsage::empty()), : rewriter(rewriter), obj(std::move(obj)), arg1(RewriterVarUsage::empty()), arg2(RewriterVarUsage::empty()),
arg3(RewriterVarUsage::empty()), args(RewriterVarUsage::empty()), func_guarded(false), args_guarded(false), arg3(RewriterVarUsage::empty()), args(RewriterVarUsage::empty()), func_guarded(false), args_guarded(false),
destination(destination), more_guards_after(more_guards_after), out_success(false), destination(destination), call_done_guarding(call_done_guarding), out_success(false),
out_rtn(RewriterVarUsage::empty()) {} out_rtn(RewriterVarUsage::empty()) {}
~CallRewriteArgs() { ~CallRewriteArgs() {
...@@ -176,15 +176,15 @@ struct BinopRewriteArgs { ...@@ -176,15 +176,15 @@ struct BinopRewriteArgs {
Rewriter* rewriter; Rewriter* rewriter;
RewriterVarUsage lhs, rhs; RewriterVarUsage lhs, rhs;
Location destination; Location destination;
bool more_guards_after; bool call_done_guarding;
bool out_success; bool out_success;
RewriterVarUsage out_rtn; RewriterVarUsage out_rtn;
BinopRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& lhs, RewriterVarUsage&& rhs, Location destination, BinopRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& lhs, RewriterVarUsage&& rhs, Location destination,
bool more_guards_after) bool call_done_guarding)
: rewriter(rewriter), lhs(std::move(lhs)), rhs(std::move(rhs)), destination(destination), : rewriter(rewriter), lhs(std::move(lhs)), rhs(std::move(rhs)), destination(destination),
more_guards_after(more_guards_after), out_success(false), out_rtn(RewriterVarUsage::empty()) {} call_done_guarding(call_done_guarding), out_success(false), out_rtn(RewriterVarUsage::empty()) {}
~BinopRewriteArgs() { ~BinopRewriteArgs() {
if (!out_success) { if (!out_success) {
...@@ -202,15 +202,15 @@ struct CompareRewriteArgs { ...@@ -202,15 +202,15 @@ struct CompareRewriteArgs {
Rewriter* rewriter; Rewriter* rewriter;
RewriterVarUsage lhs, rhs; RewriterVarUsage lhs, rhs;
Location destination; Location destination;
bool more_guards_after; bool call_done_guarding;
bool out_success; bool out_success;
RewriterVarUsage out_rtn; RewriterVarUsage out_rtn;
CompareRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& lhs, RewriterVarUsage&& rhs, Location destination, CompareRewriteArgs(Rewriter* rewriter, RewriterVarUsage&& lhs, RewriterVarUsage&& rhs, Location destination,
bool more_guards_after) bool call_done_guarding)
: rewriter(rewriter), lhs(std::move(lhs)), rhs(std::move(rhs)), destination(destination), : rewriter(rewriter), lhs(std::move(lhs)), rhs(std::move(rhs)), destination(destination),
more_guards_after(more_guards_after), out_success(false), out_rtn(RewriterVarUsage::empty()) {} call_done_guarding(call_done_guarding), out_success(false), out_rtn(RewriterVarUsage::empty()) {}
~CompareRewriteArgs() { ~CompareRewriteArgs() {
if (!out_success) { if (!out_success) {
...@@ -561,7 +561,7 @@ Box* Box::getattr(const std::string& attr, GetattrRewriteArgs* rewrite_args) { ...@@ -561,7 +561,7 @@ Box* Box::getattr(const std::string& attr, GetattrRewriteArgs* rewrite_args) {
if (!cls->instancesHaveAttrs()) { if (!cls->instancesHaveAttrs()) {
if (rewrite_args) { if (rewrite_args) {
rewrite_args->obj.setDoneUsing(); rewrite_args->obj.setDoneUsing();
if (!rewrite_args->more_guards_after) if (rewrite_args->call_done_guarding)
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
} }
...@@ -575,7 +575,7 @@ Box* Box::getattr(const std::string& attr, GetattrRewriteArgs* rewrite_args) { ...@@ -575,7 +575,7 @@ Box* Box::getattr(const std::string& attr, GetattrRewriteArgs* rewrite_args) {
if (!rewrite_args->obj_hcls_guarded) if (!rewrite_args->obj_hcls_guarded)
rewrite_args->obj.addAttrGuard(cls->attrs_offset + HCATTRS_HCLS_OFFSET, (intptr_t)hcls); rewrite_args->obj.addAttrGuard(cls->attrs_offset + HCATTRS_HCLS_OFFSET, (intptr_t)hcls);
if (!rewrite_args->more_guards_after) if (rewrite_args->call_done_guarding)
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
} }
...@@ -652,7 +652,7 @@ void Box::setattr(const std::string& attr, Box* val, SetattrRewriteArgs* rewrite ...@@ -652,7 +652,7 @@ void Box::setattr(const std::string& attr, Box* val, SetattrRewriteArgs* rewrite
if (rewrite_args) { if (rewrite_args) {
rewrite_args->obj.addAttrGuard(cls->attrs_offset + HCATTRS_HCLS_OFFSET, (intptr_t)hcls); rewrite_args->obj.addAttrGuard(cls->attrs_offset + HCATTRS_HCLS_OFFSET, (intptr_t)hcls);
if (!rewrite_args->more_guards_after) if (rewrite_args->call_done_guarding)
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
// rewrite_args->rewriter->addDecision(offset == -1 ? 1 : 0); // rewrite_args->rewriter->addDecision(offset == -1 ? 1 : 0);
} }
...@@ -733,8 +733,8 @@ Box* typeLookup(BoxedClass* cls, const std::string& attr, GetattrRewriteArgs* re ...@@ -733,8 +733,8 @@ Box* typeLookup(BoxedClass* cls, const std::string& attr, GetattrRewriteArgs* re
assert(!rewrite_args->out_success); assert(!rewrite_args->out_success);
RewriterVarUsage obj_saved = rewrite_args->obj.addUse(); RewriterVarUsage obj_saved = rewrite_args->obj.addUse();
bool more_guards_after_saved = rewrite_args->more_guards_after; bool call_done_guarding = rewrite_args->call_done_guarding;
rewrite_args->more_guards_after = true; rewrite_args->call_done_guarding = false;
val = cls->getattr(attr, rewrite_args); val = cls->getattr(attr, rewrite_args);
assert(rewrite_args->out_success); assert(rewrite_args->out_success);
...@@ -745,7 +745,7 @@ Box* typeLookup(BoxedClass* cls, const std::string& attr, GetattrRewriteArgs* re ...@@ -745,7 +745,7 @@ Box* typeLookup(BoxedClass* cls, const std::string& attr, GetattrRewriteArgs* re
} else { } else {
obj_saved.setDoneUsing(); obj_saved.setDoneUsing();
} }
if (!more_guards_after_saved) if (call_done_guarding)
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
return val; return val;
} else { } else {
...@@ -769,7 +769,7 @@ Box* nondataDescriptorInstanceSpecialCases(GetattrRewriteArgs* rewrite_args, Box ...@@ -769,7 +769,7 @@ Box* nondataDescriptorInstanceSpecialCases(GetattrRewriteArgs* rewrite_args, Box
// can't guard after because we make this call... the call is trivial enough // can't guard after because we make this call... the call is trivial enough
// that we can probably work around it if it's important, but otherwise, if // that we can probably work around it if it's important, but otherwise, if
// this triggers, just abort rewriting, I guess // this triggers, just abort rewriting, I guess
assert(!rewrite_args->more_guards_after); assert(rewrite_args->call_done_guarding);
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
rewrite_args->out_rtn = rewrite_args->rewriter->call(false, (void*)boxInstanceMethod, rewrite_args->out_rtn = rewrite_args->rewriter->call(false, (void*)boxInstanceMethod,
std::move(rewrite_args->obj), std::move(r_descr)); std::move(rewrite_args->obj), std::move(r_descr));
...@@ -778,7 +778,7 @@ Box* nondataDescriptorInstanceSpecialCases(GetattrRewriteArgs* rewrite_args, Box ...@@ -778,7 +778,7 @@ Box* nondataDescriptorInstanceSpecialCases(GetattrRewriteArgs* rewrite_args, Box
return boxInstanceMethod(obj, descr); return boxInstanceMethod(obj, descr);
} else { } else {
if (rewrite_args) { if (rewrite_args) {
if (!rewrite_args->more_guards_after) if (rewrite_args->call_done_guarding)
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
rewrite_args->obj.setDoneUsing(); rewrite_args->obj.setDoneUsing();
rewrite_args->out_rtn = std::move(r_descr); rewrite_args->out_rtn = std::move(r_descr);
...@@ -801,7 +801,7 @@ Box* descriptorClsSpecialCases(GetattrRewriteArgs* rewrite_args, BoxedClass* cls ...@@ -801,7 +801,7 @@ Box* descriptorClsSpecialCases(GetattrRewriteArgs* rewrite_args, BoxedClass* cls
if (!for_call) { if (!for_call) {
if (rewrite_args) { if (rewrite_args) {
assert(!rewrite_args->more_guards_after); assert(rewrite_args->call_done_guarding);
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
rewrite_args->obj.setDoneUsing(); rewrite_args->obj.setDoneUsing();
...@@ -813,7 +813,7 @@ Box* descriptorClsSpecialCases(GetattrRewriteArgs* rewrite_args, BoxedClass* cls ...@@ -813,7 +813,7 @@ Box* descriptorClsSpecialCases(GetattrRewriteArgs* rewrite_args, BoxedClass* cls
return boxUnboundInstanceMethod(descr); return boxUnboundInstanceMethod(descr);
} else { } else {
if (rewrite_args) { if (rewrite_args) {
if (!rewrite_args->more_guards_after) if (rewrite_args->call_done_guarding)
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
rewrite_args->obj.setDoneUsing(); rewrite_args->obj.setDoneUsing();
rewrite_args->out_success = true; rewrite_args->out_success = true;
...@@ -830,7 +830,7 @@ Box* descriptorClsSpecialCases(GetattrRewriteArgs* rewrite_args, BoxedClass* cls ...@@ -830,7 +830,7 @@ Box* descriptorClsSpecialCases(GetattrRewriteArgs* rewrite_args, BoxedClass* cls
r_descr.addAttrGuard(BOX_CLS_OFFSET, (uint64_t)descr->cls); r_descr.addAttrGuard(BOX_CLS_OFFSET, (uint64_t)descr->cls);
if (rewrite_args) { if (rewrite_args) {
assert(!rewrite_args->more_guards_after); assert(rewrite_args->call_done_guarding);
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
rewrite_args->obj.setDoneUsing(); rewrite_args->obj.setDoneUsing();
...@@ -853,7 +853,7 @@ Box* dataDescriptorInstanceSpecialCases(GetattrRewriteArgs* rewrite_args, Box* o ...@@ -853,7 +853,7 @@ Box* dataDescriptorInstanceSpecialCases(GetattrRewriteArgs* rewrite_args, Box* o
// TODO should also have logic to raise a type error if type of obj is wrong // TODO should also have logic to raise a type error if type of obj is wrong
if (rewrite_args) { if (rewrite_args) {
if (!rewrite_args->more_guards_after) if (rewrite_args->call_done_guarding)
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
r_descr.setDoneUsing(); r_descr.setDoneUsing();
} }
...@@ -931,7 +931,7 @@ extern "C" Box* getclsattr(Box* obj, const char* attr) { ...@@ -931,7 +931,7 @@ extern "C" Box* getclsattr(Box* obj, const char* attr) {
if (rewriter.get()) { if (rewriter.get()) {
// rewriter->trap(); // rewriter->trap();
GetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getReturnDestination(), false); GetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getReturnDestination(), true);
gotten = getclsattr_internal(obj, attr, &rewrite_args); gotten = getclsattr_internal(obj, attr, &rewrite_args);
if (rewrite_args.out_success && gotten) { if (rewrite_args.out_success && gotten) {
...@@ -977,13 +977,13 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -977,13 +977,13 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
Box* val = NULL; Box* val = NULL;
if (rewrite_args) { if (rewrite_args) {
GetattrRewriteArgs hrewrite_args(rewrite_args->rewriter, rewrite_args->obj.addUse(), GetattrRewriteArgs hrewrite_args(rewrite_args->rewriter, rewrite_args->obj.addUse(),
rewrite_args->destination, true); rewrite_args->destination, false);
val = obj->getattr(attr, &hrewrite_args); val = obj->getattr(attr, &hrewrite_args);
if (!hrewrite_args.out_success) { if (!hrewrite_args.out_success) {
rewrite_args = NULL; rewrite_args = NULL;
} else if (val) { } else if (val) {
if (!rewrite_args->more_guards_after) if (rewrite_args->call_done_guarding)
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
rewrite_args->out_rtn = std::move(hrewrite_args.out_rtn); rewrite_args->out_rtn = std::move(hrewrite_args.out_rtn);
rewrite_args->out_success = true; rewrite_args->out_success = true;
...@@ -1005,7 +1005,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1005,7 +1005,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
if (closure->parent) { if (closure->parent) {
if (rewrite_args) { if (rewrite_args) {
rewrite_args->obj = rewrite_args->obj.getAttr(offsetof(BoxedClosure, parent), RewriterVarUsage::NoKill); rewrite_args->obj = rewrite_args->obj.getAttr(offsetof(BoxedClosure, parent), RewriterVarUsage::NoKill);
if (!rewrite_args->more_guards_after) if (rewrite_args->call_done_guarding)
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
} }
return getattrInternal(closure->parent, attr, rewrite_args); return getattrInternal(closure->parent, attr, rewrite_args);
...@@ -1051,7 +1051,8 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1051,7 +1051,8 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
if (rewrite_args) { if (rewrite_args) {
RewriterVarUsage r_obj_cls RewriterVarUsage r_obj_cls
= rewrite_args->obj.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::NoKill, Location::any()); = rewrite_args->obj.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::NoKill, Location::any());
GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, std::move(r_obj_cls), rewrite_args->destination, true); GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, std::move(r_obj_cls), rewrite_args->destination,
false);
descr = typeLookup(obj->cls, attr, &grewrite_args); descr = typeLookup(obj->cls, attr, &grewrite_args);
if (!grewrite_args.out_success) { if (!grewrite_args.out_success) {
...@@ -1085,7 +1086,8 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1085,7 +1086,8 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
if (rewrite_args) { if (rewrite_args) {
RewriterVarUsage r_descr_cls RewriterVarUsage r_descr_cls
= r_descr.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::NoKill, Location::any()); = r_descr.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::NoKill, Location::any());
GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, std::move(r_descr_cls), Location::any(), true); GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, std::move(r_descr_cls), Location::any(),
false);
_get_ = typeLookup(descr->cls, "__get__", &grewrite_args); _get_ = typeLookup(descr->cls, "__get__", &grewrite_args);
if (!grewrite_args.out_success) { if (!grewrite_args.out_success) {
rewrite_args = NULL; rewrite_args = NULL;
...@@ -1104,7 +1106,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1104,7 +1106,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
RewriterVarUsage r_descr_cls RewriterVarUsage r_descr_cls
= r_descr.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::NoKill, Location::any()); = r_descr.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::NoKill, Location::any());
GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, std::move(r_descr_cls), Location::any(), GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, std::move(r_descr_cls), Location::any(),
true); false);
_set_ = typeLookup(descr->cls, "__set__", &grewrite_args); _set_ = typeLookup(descr->cls, "__set__", &grewrite_args);
if (!grewrite_args.out_success) { if (!grewrite_args.out_success) {
rewrite_args = NULL; rewrite_args = NULL;
...@@ -1118,13 +1120,13 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1118,13 +1120,13 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
// Call __get__(descr, obj, obj->cls) // Call __get__(descr, obj, obj->cls)
if (_set_) { if (_set_) {
// this could happen for the callattr path... // this could happen for the callattr path...
if (rewrite_args && rewrite_args->more_guards_after) if (rewrite_args && !rewrite_args->call_done_guarding)
rewrite_args = NULL; rewrite_args = NULL;
Box* res; Box* res;
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(r_get), CallRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(r_get),
rewrite_args->destination, rewrite_args->more_guards_after); rewrite_args->destination, rewrite_args->call_done_guarding);
crewrite_args.arg1 = std::move(r_descr); crewrite_args.arg1 = std::move(r_descr);
crewrite_args.arg2 = rewrite_args->obj.addUse(); crewrite_args.arg2 = rewrite_args->obj.addUse();
crewrite_args.arg3 crewrite_args.arg3
...@@ -1156,7 +1158,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1156,7 +1158,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
RewriterVarUsage r_val(RewriterVarUsage::empty()); RewriterVarUsage r_val(RewriterVarUsage::empty());
if (rewrite_args) { if (rewrite_args) {
GetattrRewriteArgs hrewrite_args(rewrite_args->rewriter, rewrite_args->obj.addUse(), GetattrRewriteArgs hrewrite_args(rewrite_args->rewriter, rewrite_args->obj.addUse(),
rewrite_args->destination, true); rewrite_args->destination, false);
val = obj->getattr(attr, &hrewrite_args); val = obj->getattr(attr, &hrewrite_args);
if (!hrewrite_args.out_success) { if (!hrewrite_args.out_success) {
...@@ -1170,7 +1172,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1170,7 +1172,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
if (val) { if (val) {
if (rewrite_args) { if (rewrite_args) {
if (!rewrite_args->more_guards_after) if (rewrite_args->call_done_guarding)
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
rewrite_args->obj.setDoneUsing(); rewrite_args->obj.setDoneUsing();
rewrite_args->out_rtn = std::move(r_val); rewrite_args->out_rtn = std::move(r_val);
...@@ -1191,7 +1193,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1191,7 +1193,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
RewriterVarUsage r_val(RewriterVarUsage::empty()); RewriterVarUsage r_val(RewriterVarUsage::empty());
if (rewrite_args) { if (rewrite_args) {
GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, rewrite_args->obj.addUse(), GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, rewrite_args->obj.addUse(),
rewrite_args->destination, true); rewrite_args->destination, false);
val = typeLookup(static_cast<BoxedClass*>(obj), attr, &grewrite_args); val = typeLookup(static_cast<BoxedClass*>(obj), attr, &grewrite_args);
if (!grewrite_args.out_success) { if (!grewrite_args.out_success) {
...@@ -1220,7 +1222,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1220,7 +1222,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
RewriterVarUsage r_val_cls RewriterVarUsage r_val_cls
= r_val.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::NoKill, Location::any()); = r_val.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::NoKill, Location::any());
GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, std::move(r_val_cls), Location::any(), GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, std::move(r_val_cls), Location::any(),
true); false);
local_get = typeLookup(val->cls, "__get__", &grewrite_args); local_get = typeLookup(val->cls, "__get__", &grewrite_args);
if (!grewrite_args.out_success) { if (!grewrite_args.out_success) {
rewrite_args = NULL; rewrite_args = NULL;
...@@ -1236,12 +1238,12 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1236,12 +1238,12 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
Box* res; Box* res;
// this could happen for the callattr path... // this could happen for the callattr path...
if (rewrite_args && rewrite_args->more_guards_after) if (rewrite_args && !rewrite_args->call_done_guarding)
rewrite_args = NULL; rewrite_args = NULL;
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(r_get), CallRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(r_get),
rewrite_args->destination, rewrite_args->more_guards_after); rewrite_args->destination, rewrite_args->call_done_guarding);
crewrite_args.arg1 = std::move(r_val); crewrite_args.arg1 = std::move(r_val);
crewrite_args.arg2 = rewrite_args->rewriter->loadConst((intptr_t)None, Location::any()); crewrite_args.arg2 = rewrite_args->rewriter->loadConst((intptr_t)None, Location::any());
crewrite_args.arg3 = std::move(rewrite_args->obj); crewrite_args.arg3 = std::move(rewrite_args->obj);
...@@ -1263,7 +1265,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1263,7 +1265,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
// If there was no local __get__, just return val // If there was no local __get__, just return val
if (rewrite_args) { if (rewrite_args) {
if (!rewrite_args->more_guards_after) if (rewrite_args->call_done_guarding)
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
rewrite_args->obj.setDoneUsing(); rewrite_args->obj.setDoneUsing();
rewrite_args->out_rtn = std::move(r_val); rewrite_args->out_rtn = std::move(r_val);
...@@ -1288,13 +1290,13 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1288,13 +1290,13 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
// the result. // the result.
if (_get_) { if (_get_) {
// this could happen for the callattr path... // this could happen for the callattr path...
if (rewrite_args && rewrite_args->more_guards_after) if (rewrite_args && !rewrite_args->call_done_guarding)
rewrite_args = NULL; rewrite_args = NULL;
Box* res; Box* res;
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(r_get), rewrite_args->destination, CallRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(r_get), rewrite_args->destination,
rewrite_args->more_guards_after); rewrite_args->call_done_guarding);
crewrite_args.arg1 = std::move(r_descr); crewrite_args.arg1 = std::move(r_descr);
crewrite_args.arg2 = rewrite_args->obj.addUse(); crewrite_args.arg2 = rewrite_args->obj.addUse();
crewrite_args.arg3 = rewrite_args->obj.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::Kill, Location::any()); crewrite_args.arg3 = rewrite_args->obj.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::Kill, Location::any());
...@@ -1316,7 +1318,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg ...@@ -1316,7 +1318,7 @@ Box* getattrInternalGeneral(Box* obj, const std::string& attr, GetattrRewriteArg
// Otherwise, just return descr. // Otherwise, just return descr.
if (rewrite_args) { if (rewrite_args) {
rewrite_args->obj.setDoneUsing(); rewrite_args->obj.setDoneUsing();
if (!rewrite_args->more_guards_after) if (rewrite_args->call_done_guarding)
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
rewrite_args->out_rtn = std::move(r_descr); rewrite_args->out_rtn = std::move(r_descr);
rewrite_args->out_success = true; rewrite_args->out_success = true;
...@@ -1386,7 +1388,7 @@ extern "C" Box* getattr(Box* obj, const char* attr) { ...@@ -1386,7 +1388,7 @@ extern "C" Box* getattr(Box* obj, const char* attr) {
dest = Location::forArg(1); dest = Location::forArg(1);
else else
dest = rewriter->getReturnDestination(); dest = rewriter->getReturnDestination();
GetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), dest, false); GetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), dest, true);
val = getattrInternal(obj, attr, &rewrite_args); val = getattrInternal(obj, attr, &rewrite_args);
// should make sure getattrInternal calls finishes using obj itself // should make sure getattrInternal calls finishes using obj itself
...@@ -1429,7 +1431,7 @@ void setattrInternal(Box* obj, const std::string& attr, Box* val, SetattrRewrite ...@@ -1429,7 +1431,7 @@ void setattrInternal(Box* obj, const std::string& attr, Box* val, SetattrRewrite
RewriterVarUsage r_cls RewriterVarUsage r_cls
= rewrite_args->obj.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::KillFlag::NoKill, Location::any()); = rewrite_args->obj.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::KillFlag::NoKill, Location::any());
GetattrRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(r_cls), GetattrRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(r_cls),
rewrite_args->rewriter->getReturnDestination(), true); rewrite_args->rewriter->getReturnDestination(), false);
descr = typeLookup(obj->cls, attr, &crewrite_args); descr = typeLookup(obj->cls, attr, &crewrite_args);
if (!crewrite_args.out_success) { if (!crewrite_args.out_success) {
...@@ -1447,7 +1449,7 @@ void setattrInternal(Box* obj, const std::string& attr, Box* val, SetattrRewrite ...@@ -1447,7 +1449,7 @@ void setattrInternal(Box* obj, const std::string& attr, Box* val, SetattrRewrite
if (rewrite_args) { if (rewrite_args) {
RewriterVarUsage r_cls RewriterVarUsage r_cls
= r_descr.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::KillFlag::NoKill, Location::any()); = r_descr.getAttr(BOX_CLS_OFFSET, RewriterVarUsage::KillFlag::NoKill, Location::any());
GetattrRewriteArgs trewrite_args(rewrite_args->rewriter, std::move(r_cls), Location::any(), true); GetattrRewriteArgs trewrite_args(rewrite_args->rewriter, std::move(r_cls), Location::any(), false);
_set_ = typeLookup(descr->cls, "__set__", &trewrite_args); _set_ = typeLookup(descr->cls, "__set__", &trewrite_args);
if (!trewrite_args.out_success) { if (!trewrite_args.out_success) {
rewrite_args = NULL; rewrite_args = NULL;
...@@ -1464,7 +1466,7 @@ void setattrInternal(Box* obj, const std::string& attr, Box* val, SetattrRewrite ...@@ -1464,7 +1466,7 @@ void setattrInternal(Box* obj, const std::string& attr, Box* val, SetattrRewrite
if (descr && _set_) { if (descr && _set_) {
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(r_set), Location::any(), CallRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(r_set), Location::any(),
rewrite_args->more_guards_after); rewrite_args->call_done_guarding);
crewrite_args.arg1 = std::move(r_descr); crewrite_args.arg1 = std::move(r_descr);
crewrite_args.arg2 = std::move(rewrite_args->obj); crewrite_args.arg2 = std::move(rewrite_args->obj);
crewrite_args.arg3 = std::move(rewrite_args->attrval); crewrite_args.arg3 = std::move(rewrite_args->attrval);
...@@ -1506,7 +1508,7 @@ extern "C" void setattr(Box* obj, const char* attr, Box* attr_val) { ...@@ -1506,7 +1508,7 @@ extern "C" void setattr(Box* obj, const char* attr, Box* attr_val) {
if (rewriter.get()) { if (rewriter.get()) {
// rewriter->trap(); // rewriter->trap();
SetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getArg(2), false); SetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getArg(2), true);
setattrInternal(obj, attr, attr_val, &rewrite_args); setattrInternal(obj, attr, attr_val, &rewrite_args);
if (rewrite_args.out_success) { if (rewrite_args.out_success) {
rewriter->commit(); rewriter->commit();
...@@ -1716,7 +1718,7 @@ extern "C" BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewrite_args) { ...@@ -1716,7 +1718,7 @@ extern "C" BoxedInt* lenInternal(Box* obj, LenRewriteArgs* rewrite_args) {
static std::string attr_str("__len__"); static std::string attr_str("__len__");
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(rewrite_args->obj), rewrite_args->destination, CallRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(rewrite_args->obj), rewrite_args->destination,
rewrite_args->more_guards_after); rewrite_args->call_done_guarding);
rtn = callattrInternal0(obj, &attr_str, CLASS_ONLY, &crewrite_args, ArgPassSpec(0)); rtn = callattrInternal0(obj, &attr_str, CLASS_ONLY, &crewrite_args, ArgPassSpec(0));
if (!crewrite_args.out_success) if (!crewrite_args.out_success)
rewrite_args = NULL; rewrite_args = NULL;
...@@ -1757,7 +1759,7 @@ extern "C" i64 unboxedLen(Box* obj) { ...@@ -1757,7 +1759,7 @@ extern "C" i64 unboxedLen(Box* obj) {
RewriterVarUsage r_boxed(RewriterVarUsage::empty()); RewriterVarUsage r_boxed(RewriterVarUsage::empty());
if (rewriter.get()) { if (rewriter.get()) {
// rewriter->trap(); // rewriter->trap();
LenRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getReturnDestination(), false); LenRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getReturnDestination(), true);
lobj = lenInternal(obj, &rewrite_args); lobj = lenInternal(obj, &rewrite_args);
if (!rewrite_args.out_success) { if (!rewrite_args.out_success) {
...@@ -1866,7 +1868,7 @@ extern "C" Box* callattrInternal(Box* obj, const std::string* attr, LookupScope ...@@ -1866,7 +1868,7 @@ extern "C" Box* callattrInternal(Box* obj, const std::string* attr, LookupScope
Box* val; Box* val;
RewriterVarUsage r_val(RewriterVarUsage::empty()); RewriterVarUsage r_val(RewriterVarUsage::empty());
if (rewrite_args) { if (rewrite_args) {
GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, rewrite_args->obj.addUse(), Location::any(), true); GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, rewrite_args->obj.addUse(), Location::any(), false);
val = getattrInternalGeneral(obj, *attr, &grewrite_args, scope == CLASS_ONLY, true, &should_bind); val = getattrInternalGeneral(obj, *attr, &grewrite_args, scope == CLASS_ONLY, true, &should_bind);
if (!grewrite_args.out_success) { if (!grewrite_args.out_success) {
rewrite_args = NULL; rewrite_args = NULL;
...@@ -1901,7 +1903,7 @@ extern "C" Box* callattrInternal(Box* obj, const std::string* attr, LookupScope ...@@ -1901,7 +1903,7 @@ extern "C" Box* callattrInternal(Box* obj, const std::string* attr, LookupScope
Box* rtn; Box* rtn;
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs srewrite_args(rewrite_args->rewriter, std::move(r_val), rewrite_args->destination, CallRewriteArgs srewrite_args(rewrite_args->rewriter, std::move(r_val), rewrite_args->destination,
rewrite_args->more_guards_after); rewrite_args->call_done_guarding);
srewrite_args.arg1 = std::move(rewrite_args->obj); srewrite_args.arg1 = std::move(rewrite_args->obj);
// should be no-ops: // should be no-ops:
...@@ -1941,7 +1943,7 @@ extern "C" Box* callattrInternal(Box* obj, const std::string* attr, LookupScope ...@@ -1941,7 +1943,7 @@ extern "C" Box* callattrInternal(Box* obj, const std::string* attr, LookupScope
Box* rtn; Box* rtn;
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs srewrite_args(rewrite_args->rewriter, std::move(r_val), rewrite_args->destination, CallRewriteArgs srewrite_args(rewrite_args->rewriter, std::move(r_val), rewrite_args->destination,
rewrite_args->more_guards_after); rewrite_args->call_done_guarding);
srewrite_args.arg1 = std::move(rewrite_args->obj); srewrite_args.arg1 = std::move(rewrite_args->obj);
srewrite_args.arg2 = std::move(rewrite_args->arg1); srewrite_args.arg2 = std::move(rewrite_args->arg1);
srewrite_args.arg3 = std::move(rewrite_args->arg2); srewrite_args.arg3 = std::move(rewrite_args->arg2);
...@@ -1983,7 +1985,7 @@ extern "C" Box* callattrInternal(Box* obj, const std::string* attr, LookupScope ...@@ -1983,7 +1985,7 @@ extern "C" Box* callattrInternal(Box* obj, const std::string* attr, LookupScope
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs srewrite_args(rewrite_args->rewriter, std::move(r_val), rewrite_args->destination, CallRewriteArgs srewrite_args(rewrite_args->rewriter, std::move(r_val), rewrite_args->destination,
rewrite_args->more_guards_after); rewrite_args->call_done_guarding);
if (npassed_args >= 1) if (npassed_args >= 1)
srewrite_args.arg1 = std::move(rewrite_args->arg1); srewrite_args.arg1 = std::move(rewrite_args->arg1);
if (npassed_args >= 2) if (npassed_args >= 2)
...@@ -2039,7 +2041,7 @@ extern "C" Box* callattr(Box* obj, const std::string* attr, bool clsonly, ArgPas ...@@ -2039,7 +2041,7 @@ extern "C" Box* callattr(Box* obj, const std::string* attr, bool clsonly, ArgPas
// rewriter->getArg(3).addGuard(npassed_args); // rewriter->getArg(3).addGuard(npassed_args);
CallRewriteArgs rewrite_args(rewriter.get(), std::move(rewriter->getArg(0)), rewriter->getReturnDestination(), CallRewriteArgs rewrite_args(rewriter.get(), std::move(rewriter->getArg(0)), rewriter->getReturnDestination(),
false); true);
if (npassed_args >= 1) if (npassed_args >= 1)
rewrite_args.arg1 = std::move(rewriter->getArg(4)); rewrite_args.arg1 = std::move(rewriter->getArg(4));
if (npassed_args >= 2) if (npassed_args >= 2)
...@@ -2223,7 +2225,7 @@ Box* callFunc(BoxedFunction* func, CallRewriteArgs* rewrite_args, ArgPassSpec ar ...@@ -2223,7 +2225,7 @@ Box* callFunc(BoxedFunction* func, CallRewriteArgs* rewrite_args, ArgPassSpec ar
} else { } else {
rewrite_args->obj.setDoneUsing(); rewrite_args->obj.setDoneUsing();
} }
assert(!rewrite_args->more_guards_after); assert(rewrite_args->call_done_guarding);
if (!rewrite_args->rewriter->isDoneGuarding()) if (!rewrite_args->rewriter->isDoneGuarding())
rewrite_args->rewriter->setDoneGuarding(); rewrite_args->rewriter->setDoneGuarding();
// if (guard_clfunc) { // if (guard_clfunc) {
...@@ -2598,7 +2600,7 @@ Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec ar ...@@ -2598,7 +2600,7 @@ Box* runtimeCallInternal(Box* obj, CallRewriteArgs* rewrite_args, ArgPassSpec ar
// (since we've already guarded on the function). // (since we've already guarded on the function).
// rewriter enforce that we give it one, though // rewriter enforce that we give it one, though
CallRewriteArgs srewrite_args(rewrite_args->rewriter, rewrite_args->obj.addUse(), CallRewriteArgs srewrite_args(rewrite_args->rewriter, rewrite_args->obj.addUse(),
rewrite_args->destination, rewrite_args->more_guards_after); rewrite_args->destination, rewrite_args->call_done_guarding);
srewrite_args.arg1 = rewrite_args->obj.getAttr(INSTANCEMETHOD_OBJ_OFFSET, srewrite_args.arg1 = rewrite_args->obj.getAttr(INSTANCEMETHOD_OBJ_OFFSET,
RewriterVarUsage::KillFlag::Kill, Location::any()); RewriterVarUsage::KillFlag::Kill, Location::any());
...@@ -2663,7 +2665,7 @@ extern "C" Box* runtimeCall(Box* obj, ArgPassSpec argspec, Box* arg1, Box* arg2, ...@@ -2663,7 +2665,7 @@ extern "C" Box* runtimeCall(Box* obj, ArgPassSpec argspec, Box* arg1, Box* arg2,
// rewriter->getArg(1).addGuard(npassed_args); // rewriter->getArg(1).addGuard(npassed_args);
CallRewriteArgs rewrite_args(rewriter.get(), std::move(rewriter->getArg(0)), rewriter->getReturnDestination(), CallRewriteArgs rewrite_args(rewriter.get(), std::move(rewriter->getArg(0)), rewriter->getReturnDestination(),
false); true);
if (npassed_args >= 1) if (npassed_args >= 1)
rewrite_args.arg1 = std::move(rewriter->getArg(2)); rewrite_args.arg1 = std::move(rewriter->getArg(2));
if (npassed_args >= 2) if (npassed_args >= 2)
...@@ -2708,7 +2710,7 @@ extern "C" Box* binopInternal(Box* lhs, Box* rhs, int op_type, bool inplace, Bin ...@@ -2708,7 +2710,7 @@ extern "C" Box* binopInternal(Box* lhs, Box* rhs, int op_type, bool inplace, Bin
std::string iop_name = getInplaceOpName(op_type); std::string iop_name = getInplaceOpName(op_type);
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs srewrite_args(rewrite_args->rewriter, rewrite_args->lhs.addUse(), rewrite_args->destination, CallRewriteArgs srewrite_args(rewrite_args->rewriter, rewrite_args->lhs.addUse(), rewrite_args->destination,
rewrite_args->more_guards_after); rewrite_args->call_done_guarding);
srewrite_args.arg1 = rewrite_args->rhs.addUse(); srewrite_args.arg1 = rewrite_args->rhs.addUse();
srewrite_args.args_guarded = true; srewrite_args.args_guarded = true;
irtn = callattrInternal1(lhs, &iop_name, CLASS_ONLY, &srewrite_args, ArgPassSpec(1), rhs); irtn = callattrInternal1(lhs, &iop_name, CLASS_ONLY, &srewrite_args, ArgPassSpec(1), rhs);
...@@ -2741,7 +2743,7 @@ extern "C" Box* binopInternal(Box* lhs, Box* rhs, int op_type, bool inplace, Bin ...@@ -2741,7 +2743,7 @@ extern "C" Box* binopInternal(Box* lhs, Box* rhs, int op_type, bool inplace, Bin
Box* lrtn; Box* lrtn;
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs srewrite_args(rewrite_args->rewriter, std::move(rewrite_args->lhs), rewrite_args->destination, CallRewriteArgs srewrite_args(rewrite_args->rewriter, std::move(rewrite_args->lhs), rewrite_args->destination,
rewrite_args->more_guards_after); rewrite_args->call_done_guarding);
srewrite_args.arg1 = std::move(rewrite_args->rhs); srewrite_args.arg1 = std::move(rewrite_args->rhs);
lrtn = callattrInternal1(lhs, &op_name, CLASS_ONLY, &srewrite_args, ArgPassSpec(1), rhs); lrtn = callattrInternal1(lhs, &op_name, CLASS_ONLY, &srewrite_args, ArgPassSpec(1), rhs);
...@@ -2831,7 +2833,7 @@ extern "C" Box* binop(Box* lhs, Box* rhs, int op_type) { ...@@ -2831,7 +2833,7 @@ extern "C" Box* binop(Box* lhs, Box* rhs, int op_type) {
if (rewriter.get()) { if (rewriter.get()) {
// rewriter->trap(); // rewriter->trap();
BinopRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getArg(1), BinopRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getArg(1),
rewriter->getReturnDestination(), false); rewriter->getReturnDestination(), true);
rtn = binopInternal(lhs, rhs, op_type, false, &rewrite_args); rtn = binopInternal(lhs, rhs, op_type, false, &rewrite_args);
assert(rtn); assert(rtn);
if (!rewrite_args.out_success) { if (!rewrite_args.out_success) {
...@@ -2867,7 +2869,7 @@ extern "C" Box* augbinop(Box* lhs, Box* rhs, int op_type) { ...@@ -2867,7 +2869,7 @@ extern "C" Box* augbinop(Box* lhs, Box* rhs, int op_type) {
Box* rtn; Box* rtn;
if (rewriter.get()) { if (rewriter.get()) {
BinopRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getArg(1), BinopRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getArg(1),
rewriter->getReturnDestination(), false); rewriter->getReturnDestination(), true);
rtn = binopInternal(lhs, rhs, op_type, true, &rewrite_args); rtn = binopInternal(lhs, rhs, op_type, true, &rewrite_args);
if (!rewrite_args.out_success) { if (!rewrite_args.out_success) {
rewrite_args.ensureAllDone(); rewrite_args.ensureAllDone();
...@@ -2941,7 +2943,7 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit ...@@ -2941,7 +2943,7 @@ Box* compareInternal(Box* lhs, Box* rhs, int op_type, CompareRewriteArgs* rewrit
Box* lrtn; Box* lrtn;
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(rewrite_args->lhs), rewrite_args->destination, CallRewriteArgs crewrite_args(rewrite_args->rewriter, std::move(rewrite_args->lhs), rewrite_args->destination,
rewrite_args->more_guards_after); rewrite_args->call_done_guarding);
crewrite_args.arg1 = std::move(rewrite_args->rhs); crewrite_args.arg1 = std::move(rewrite_args->rhs);
lrtn = callattrInternal1(lhs, &op_name, CLASS_ONLY, &crewrite_args, ArgPassSpec(1), rhs); lrtn = callattrInternal1(lhs, &op_name, CLASS_ONLY, &crewrite_args, ArgPassSpec(1), rhs);
...@@ -3038,7 +3040,7 @@ extern "C" Box* compare(Box* lhs, Box* rhs, int op_type) { ...@@ -3038,7 +3040,7 @@ extern "C" Box* compare(Box* lhs, Box* rhs, int op_type) {
if (rewriter.get()) { if (rewriter.get()) {
// rewriter->trap(); // rewriter->trap();
CompareRewriteArgs rewrite_args(rewriter.get(), std::move(rewriter->getArg(0)), std::move(rewriter->getArg(1)), CompareRewriteArgs rewrite_args(rewriter.get(), std::move(rewriter->getArg(0)), std::move(rewriter->getArg(1)),
rewriter->getReturnDestination(), false); rewriter->getReturnDestination(), true);
rtn = compareInternal(lhs, rhs, op_type, &rewrite_args); rtn = compareInternal(lhs, rhs, op_type, &rewrite_args);
if (!rewrite_args.out_success) { if (!rewrite_args.out_success) {
rewrite_args.ensureAllDone(); rewrite_args.ensureAllDone();
...@@ -3081,7 +3083,7 @@ extern "C" Box* getitem(Box* value, Box* slice) { ...@@ -3081,7 +3083,7 @@ extern "C" Box* getitem(Box* value, Box* slice) {
Box* rtn; Box* rtn;
if (rewriter.get()) { if (rewriter.get()) {
CallRewriteArgs rewrite_args(rewriter.get(), std::move(rewriter->getArg(0)), rewriter->getReturnDestination(), CallRewriteArgs rewrite_args(rewriter.get(), std::move(rewriter->getArg(0)), rewriter->getReturnDestination(),
false); true);
rewrite_args.arg1 = std::move(rewriter->getArg(1)); rewrite_args.arg1 = std::move(rewriter->getArg(1));
rtn = callattrInternal1(value, &str_getitem, CLASS_ONLY, &rewrite_args, ArgPassSpec(1), slice); rtn = callattrInternal1(value, &str_getitem, CLASS_ONLY, &rewrite_args, ArgPassSpec(1), slice);
...@@ -3124,7 +3126,7 @@ extern "C" void setitem(Box* target, Box* slice, Box* value) { ...@@ -3124,7 +3126,7 @@ extern "C" void setitem(Box* target, Box* slice, Box* value) {
Box* rtn; Box* rtn;
if (rewriter.get()) { if (rewriter.get()) {
CallRewriteArgs rewrite_args(rewriter.get(), std::move(rewriter->getArg(0)), rewriter->getReturnDestination(), CallRewriteArgs rewrite_args(rewriter.get(), std::move(rewriter->getArg(0)), rewriter->getReturnDestination(),
false); true);
rewrite_args.arg1 = std::move(rewriter->getArg(1)); rewrite_args.arg1 = std::move(rewriter->getArg(1));
rewrite_args.arg2 = std::move(rewriter->getArg(2)); rewrite_args.arg2 = std::move(rewriter->getArg(2));
...@@ -3159,7 +3161,7 @@ extern "C" void delitem(Box* target, Box* slice) { ...@@ -3159,7 +3161,7 @@ extern "C" void delitem(Box* target, Box* slice) {
Box* rtn; Box* rtn;
if (rewriter.get()) { if (rewriter.get()) {
CallRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getReturnDestination(), false); CallRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getReturnDestination(), true);
rewrite_args.arg1 = std::move(rewriter->getArg(1)); rewrite_args.arg1 = std::move(rewriter->getArg(1));
rtn = callattrInternal1(target, &str_delitem, CLASS_ONLY, &rewrite_args, ArgPassSpec(1), slice); rtn = callattrInternal1(target, &str_delitem, CLASS_ONLY, &rewrite_args, ArgPassSpec(1), slice);
...@@ -3414,7 +3416,7 @@ Box* typeCallInternal(BoxedFunction* f, CallRewriteArgs* rewrite_args, ArgPassSp ...@@ -3414,7 +3416,7 @@ Box* typeCallInternal(BoxedFunction* f, CallRewriteArgs* rewrite_args, ArgPassSp
BoxedClass* cls = static_cast<BoxedClass*>(_cls); BoxedClass* cls = static_cast<BoxedClass*>(_cls);
if (rewrite_args) { if (rewrite_args) {
GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, r_ccls.addUse(), rewrite_args->destination, true); GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, r_ccls.addUse(), rewrite_args->destination, false);
new_attr = typeLookup(cls, _new_str, &grewrite_args); new_attr = typeLookup(cls, _new_str, &grewrite_args);
if (!grewrite_args.out_success) if (!grewrite_args.out_success)
...@@ -3431,7 +3433,7 @@ Box* typeCallInternal(BoxedFunction* f, CallRewriteArgs* rewrite_args, ArgPassSp ...@@ -3431,7 +3433,7 @@ Box* typeCallInternal(BoxedFunction* f, CallRewriteArgs* rewrite_args, ArgPassSp
assert(new_attr && "This should always resolve"); assert(new_attr && "This should always resolve");
if (rewrite_args) { if (rewrite_args) {
GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, r_ccls.addUse(), rewrite_args->destination, true); GetattrRewriteArgs grewrite_args(rewrite_args->rewriter, r_ccls.addUse(), rewrite_args->destination, false);
init_attr = typeLookup(cls, _init_str, &grewrite_args); init_attr = typeLookup(cls, _init_str, &grewrite_args);
if (!grewrite_args.out_success) if (!grewrite_args.out_success)
...@@ -3462,7 +3464,7 @@ Box* typeCallInternal(BoxedFunction* f, CallRewriteArgs* rewrite_args, ArgPassSp ...@@ -3462,7 +3464,7 @@ Box* typeCallInternal(BoxedFunction* f, CallRewriteArgs* rewrite_args, ArgPassSp
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs srewrite_args(rewrite_args->rewriter, std::move(r_new), rewrite_args->destination, CallRewriteArgs srewrite_args(rewrite_args->rewriter, std::move(r_new), rewrite_args->destination,
rewrite_args->more_guards_after); rewrite_args->call_done_guarding);
int new_npassed_args = new_argspec.totalPassed(); int new_npassed_args = new_argspec.totalPassed();
if (new_npassed_args >= 1) if (new_npassed_args >= 1)
...@@ -3501,7 +3503,7 @@ Box* typeCallInternal(BoxedFunction* f, CallRewriteArgs* rewrite_args, ArgPassSp ...@@ -3501,7 +3503,7 @@ Box* typeCallInternal(BoxedFunction* f, CallRewriteArgs* rewrite_args, ArgPassSp
Box* initrtn; Box* initrtn;
if (rewrite_args) { if (rewrite_args) {
CallRewriteArgs srewrite_args(rewrite_args->rewriter, std::move(r_init), rewrite_args->destination, CallRewriteArgs srewrite_args(rewrite_args->rewriter, std::move(r_init), rewrite_args->destination,
rewrite_args->more_guards_after); rewrite_args->call_done_guarding);
if (npassed_args >= 1) if (npassed_args >= 1)
srewrite_args.arg1 = r_made.addUse(); srewrite_args.arg1 = r_made.addUse();
if (npassed_args >= 2) if (npassed_args >= 2)
...@@ -3596,7 +3598,7 @@ extern "C" Box* getGlobal(BoxedModule* m, std::string* name) { ...@@ -3596,7 +3598,7 @@ extern "C" Box* getGlobal(BoxedModule* m, std::string* name) {
// rewriter->trap(); // rewriter->trap();
GetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getReturnDestination(), GetattrRewriteArgs rewrite_args(rewriter.get(), rewriter->getArg(0), rewriter->getReturnDestination(),
true); false);
r = m->getattr(*name, &rewrite_args); r = m->getattr(*name, &rewrite_args);
if (!rewrite_args.obj.isDoneUsing()) { if (!rewrite_args.obj.isDoneUsing()) {
rewrite_args.obj.setDoneUsing(); rewrite_args.obj.setDoneUsing();
...@@ -3639,7 +3641,7 @@ extern "C" Box* getGlobal(BoxedModule* m, std::string* name) { ...@@ -3639,7 +3641,7 @@ extern "C" Box* getGlobal(BoxedModule* m, std::string* name) {
if (rewriter.get()) { if (rewriter.get()) {
RewriterVarUsage builtins = rewriter->loadConst((intptr_t)builtins_module, Location::any()); RewriterVarUsage builtins = rewriter->loadConst((intptr_t)builtins_module, Location::any());
GetattrRewriteArgs rewrite_args(rewriter.get(), std::move(builtins), rewriter->getReturnDestination(), GetattrRewriteArgs rewrite_args(rewriter.get(), std::move(builtins), rewriter->getReturnDestination(),
false); true);
rtn = builtins_module->getattr(*name, &rewrite_args); rtn = builtins_module->getattr(*name, &rewrite_args);
if (!rtn || !rewrite_args.out_success) { if (!rtn || !rewrite_args.out_success) {
......
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