Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add F_POINTED_AT; seems to work after some minimal testing #298

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aeneas/src/ir/Facts.v3
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ enum Fact {
// facts for fields
F_VALUE, // field is read-only
F_NORM, // the field is an element of a normalized field
F_POINTED_AT, // subject of a Pointer.atField
// facts for methods
M_EQUALS, // method is an equality comparator
M_OVERRIDDEN, // method has been overridden in a subclass
Expand Down
2 changes: 2 additions & 0 deletions aeneas/src/ir/Normalization.v3
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ class ReachabilityNormalizer(config: NormalizerConfig, ra: ReachabilityAnalyzer)
var norms = Array<IrSpec>.new(tn.size);
var facts = if(tn.size > 1, Fact.F_NORM, Facts.NONE);
if (!rf.raFacts.RF_WRITTEN) facts |= (Fact.F_VALUE | Fact.O_FOLDABLE);
if (rf.orig.facts.F_POINTED_AT)
facts |= Fact.F_POINTED_AT;
for (i < norms.length) {
var ft = if(tn.sub == null, tn.newType, tn.sub[i]);
var nf = IrField.new(rc.oldType, ft);
Expand Down
13 changes: 13 additions & 0 deletions aeneas/src/ssa/SsaOptimizer.v3
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,10 @@ class SsaLoadOptimizer(context: SsaContext) {
}
ClassSetField(field) => return store(apply.input0(), field, apply, apply.input1());
ComponentSetField(field) => return store(null, field, apply, apply.input1());
PtrStore => {
pure.killPointedAt();
impure.killPointedAt();
}
Init,
CallMethod,
CallClassMethod,
Expand Down Expand Up @@ -2006,4 +2010,13 @@ class SsaLoadedFields {
}
length = i;
}
def killPointedAt() {
var i = 0;
for (j < length) {
var t = array[j];
if ((!t.1.facts.F_POINTED_AT) && i != j)
array[i++] = t;
}
length = i;
}
}
4 changes: 4 additions & 0 deletions aeneas/src/ssa/VstSsaGen.v3
Original file line number Diff line number Diff line change
Expand Up @@ -867,10 +867,14 @@ class VstSsaGen extends VstVisitor<VstSsaEnv, SsaInstr> {
}
PtrAtComponentField(receiver, field, ptrType) => {
var spec = specOf(receiver, field, null);
var irFld = spec.asField();
irFld.facts |= Fact.F_POINTED_AT;
return env.addApply(env.source, V3Op.newPtrAtComponentField(spec, ptrType), Ssa.NO_INSTRS);
}
PtrAtObjectField(receiver, field, ptrType) => {
var spec = specOf(receiver, field, null);
var irFld = spec.asField();
irFld.facts |= Fact.F_POINTED_AT;
return env.addApply(env.source, V3Op.newPtrAtObjectField(spec, ptrType), [target]);
}
PtrAtRefLayoutField(receiver, field, ptrType) => {
Expand Down