Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
YonahGoldberg committed Dec 3, 2024
1 parent e956a3f commit 78b3e2f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions aeneas/src/ssa/SsaSubtypeSpecializer.v3
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ class SsaSpecializingRebuilder extends SsaRebuilder {
newMethod.specialized = true;
newMethod.source = om.source;
newMethod.ssa = newGraph;
ssaPrinter.printGraph("Subtype Specialization", newMethod.render, newMethod.ssa, newMethod.sig);
// ssaPrinter.printGraph("Subtype Specialization", newMethod.render, newMethod.ssa, newMethod.sig);

def newIrSpec = IrSpec.new(newMethod.receiver, [newMethod.receiver], newMethod);
optContext.enterSpec(newIrSpec);
SsaEarlyInliner.new(optContext, norm.ra.compilation, gen).inline(0);
ssaPrinter.printGraph("Post-Inlined Subtype Specialization", newMethod.render, newMethod.ssa, newMethod.sig);
// ssaPrinter.printGraph("Post-Inlined Subtype Specialization", newMethod.render, newMethod.ssa, newMethod.sig);

optContext.enterSpec(newIrSpec);
SsaOptimizer.new(optContext).optGraph();
ssaPrinter.printGraph("Post-Optimized Subtype Specialization", newMethod.render, newMethod.ssa, newMethod.sig);
// ssaPrinter.printGraph("Post-Optimized Subtype Specialization", newMethod.render, newMethod.ssa, newMethod.sig);

norm.newIr.methods.put(newMethod);
return newMethod;
Expand Down Expand Up @@ -181,6 +181,7 @@ class SsaSpecializingRebuilder extends SsaRebuilder {
}
// Get the class to specialize this operation to, if there is one
def getSpecClass(oi: SsaApplyOp) -> RaClass {
if (oi.inputs.length == 0) return null;
if (SsaParam.?(oi.input0())) {
var param = SsaParam.!(oi.input0());
if (specs[param.index] != null) {
Expand Down Expand Up @@ -333,7 +334,7 @@ component SubtypeUtil {
specialized = true;
// Terminal.put2("Specializing %q to %q\n", orig[i].render, spec[i].render);
} else {
Terminal.put2("Mismatched types orig [%q] spec [%q]\n", orig[i].render, spec[i].render);
// Terminal.put2("Mismatched types orig [%q] spec [%q]\n", orig[i].render, spec[i].render);
return false;
}
}
Expand Down Expand Up @@ -363,10 +364,14 @@ class SsaSubtypeSpecializer {
return false;
}

// Currently we only specialize top-level methods
match (callers[0].instr.op.opcode) {
CallMethod(m) => ;
_ => return false;
for (i < callers.length) {
if (callers[i].instr == null)
continue;
// Currently we only specialize top-level methods
match (callers[i].instr.op.opcode) {
CallMethod(m) => break;
_ => return false;
}
}
return true;
}
Expand Down Expand Up @@ -478,6 +483,7 @@ class SsaSubtypeSpecializer {
// Since we just specialized a method, we could've enabled more specializations
// Add all the callees of the specialized method to the worklist
def newCallees = callGraph.callerToCallee[specMethod];
if (newCallees == null) continue;
for (j < newCallees.length) {
def callee = newCallees[j].callee;
addToWorklist(callee, callGraph.calleeToCaller[callee]);
Expand Down

0 comments on commit 78b3e2f

Please sign in to comment.