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

Remove VariantReplaceNull operator #264

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 0 additions & 3 deletions aeneas/src/core/Eval.v3
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,6 @@ def evalOp(op: Operator, args: Arguments) -> Result {
var object = args.r(0);
return if(object != null, object.values[field.index]);
}
VariantReplaceNull => {
return args.vals[0];
}
VariantGetMethod(method) => {
var object = args.r(0);
var spec = getIrSpec(method, args);
Expand Down
2 changes: 0 additions & 2 deletions aeneas/src/core/Opcode.v3
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ type Opcode {
case VariantEq;
case VariantGetTag;
case VariantGetField(field: IrField);
case VariantReplaceNull;
case VariantGetMethod(method: IrMethod);
case VariantGetVirtual(method: IrMethod);
case VariantGetSelector(selector: IrSelector);
Expand Down Expand Up @@ -290,7 +289,6 @@ component Opcodes {
t[Opcode.VariantEq.tag] = P |C;
t[Opcode.VariantGetTag.tag] = P|NNEG;
t[Opcode.VariantGetField.tag] = P;
t[Opcode.VariantReplaceNull.tag] = P|NZ;
t[Opcode.VariantGetMethod.tag] = NZ|P;
t[Opcode.VariantGetVirtual.tag] = NZ|P;
t[Opcode.VariantGetSelector.tag] = NZ|P;
Expand Down
5 changes: 0 additions & 5 deletions aeneas/src/core/Operator.v3
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,6 @@ component V3Op {
return newOp0(Opcode.VariantGetSelector(selector), typeArgs, [methodRef.receiver],
methodRef.getFuncType());
}
//----------------------------------------------------------------------------
def newVariantReplaceNull(vtype: Type) -> Operator {
var tt = [vtype];
return newOp0(Opcode.VariantReplaceNull, tt, tt, vtype);
}
//----------------------------------------------------------------------------
def newNullCheck(rtype: Type) -> Operator {
var tt = [rtype];
Expand Down
20 changes: 0 additions & 20 deletions aeneas/src/ir/SsaNormalizer.v3
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,6 @@ class SsaRaNormalizer extends SsaRebuilder {
if (rc.isUnboxed()) {
// flattened data type becomes component call and needs new receiver
ai_new = Arrays.prepend(newGraph.nullReceiver(), ai_new);
} else {
var obj = ai_new[0];
if (V3Op.needsNullCheck(i_old, obj)) {
// XXX: make CallVariantMethod operator for null replacement?
ai_new[0] = curBlock.add(V3Op.newVariantReplaceNull(m.receiver), [obj], Facts.NONE);
norm.newIr.getIrClass(m.receiver).facts |= Fact.C_HEAP;
}
}
}
normCall(i_old, funcNorm, newOp, ai_new);
Expand Down Expand Up @@ -315,13 +308,6 @@ class SsaRaNormalizer extends SsaRebuilder {
if (rc.isUnboxed()) {
// flattened data type becomes component call and needs new receiver
ai_new = Arrays.prepend(newGraph.nullReceiver(), ai_new);
} else {
// for variant calls, replace null receiver with record
var obj = normVariantGetTag(rc.variantNorm, ai_new);
if (!obj.facts.V_NON_ZERO) {
ai_new[0] = curBlock.add(V3Op.newVariantReplaceNull(m.receiver), [obj], Facts.NONE);
norm.newIr.makeIrClass(m.receiver).facts |= Fact.C_HEAP;
}
}
normCall(i_old, funcNorm, V3Op.newCallMethod(m), ai_new);
}
Expand Down Expand Up @@ -744,12 +730,6 @@ class SsaRaNormalizer extends SsaRebuilder {
if (t.1) {
newOp = V3Op.newCallVariantSelector(m);
} else {
var obj = x;
if (!obj.facts.V_NON_ZERO) {
// XXX: make CallVariantMethod operator for null replacement?
x = curBlock.add(V3Op.newVariantReplaceNull(m.receiver), [obj], Facts.NONE);
norm.newIr.getIrClass(m.receiver).facts |= Fact.C_HEAP;
}
newOp = V3Op.newCallMethod(m);
facts |= Fact.O_NO_NULL_CHECK;
}
Expand Down
20 changes: 0 additions & 20 deletions aeneas/src/jvm/JvmRep.v3
Original file line number Diff line number Diff line change
Expand Up @@ -234,26 +234,6 @@ class JvmTypeReps(jprog: JvmProgram) {
jprog.jheap.emitRecordValue(code, jclass.defaultRecord);
}
def emitInvokeVirtual(code: JvmCodeBuilder, spec: IrSpec, nonnull: bool) {
if (!nonnull && V3.isVariant(spec.receiver)) {
{
var ic = jprog.prog.ir.getIrClass(spec.receiver);
var m = spec.member;
while (ic.parent != null && ic.parent.methods.length > m.index) {
m = ic.parent.methods[m.index];
ic = ic.parent;
}
var classType = m.receiver;
if (classType != spec.receiver) spec = IrSpec.new(classType, Arrays.replace(spec.typeArgs, 0, classType), m);
}
var tag = V3.classDecl(spec.receiver).variantTag;
// Call the static dispatcher method that can deal with null
var jclass = jprog.jvmClass(spec.receiver);
var nsig = jprog.makeJvmSig(jclass, spec.getMethodType(), null);
var virtualName = V3.mangleIrMember(spec.member);
var staticName = Arrays.concat(virtualName, "$$dispatch");
code.invokestatic(jclass.name, staticName, nsig);
return;
}
var jclass = jprog.jvmClass(spec.receiver);
var nsig = jprog.jvmSig(spec.getMethodType());
var virtualName = V3.mangleIrMember(spec.member);
Expand Down
8 changes: 0 additions & 8 deletions aeneas/src/jvm/SsaJvmGen.v3
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,6 @@ class SsaJvmGen(jprog: JvmProgram, context: SsaContext, jsig: JvmSig, code: JvmC
var dclass = jprog.newClosure(methodRef);
code.invokestatic(dclass.name, "$get", JvmSig.new([jclass], dclass));
}
VariantReplaceNull => {
var t = op.typeArgs[0];
code.dup();
var b = code.branch_fw(JvmBytecode.IFNONNULL);
code.pop();
code.builder.jprog.jrep.emitDefaultVariantRecord(t, code);
code.patchBranch(b);
}
Init => ; // do nothing
ComponentGetField(field) => jprog.jrep.emitGetField(V3Op.extractIrSpec(op, field), code);
ComponentSetField(field) => {
Expand Down
15 changes: 0 additions & 15 deletions aeneas/src/mach/MachLowering.v3
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ class MachLowering(mach: MachProgram, compiler: Compiler, config: MachLoweringCo
VariantGetField(field) => return genClassGetField(true, i_old, field);
VariantGetMethod(method) => i_new = genVariantGetMethod(i_old, method);
VariantGetSelector(selector) => i_new = genVariantGetSelector(i_old, selector);
VariantReplaceNull => i_new = genVariantReplaceNull(i_old);
ComponentGetField(field) => return genComponentGetField(i_old, field);
ComponentSetField(field) => return genComponentSetField(i_old, field);
TupleGetElem(index) => return genTupleGetElem(i_old, index);
Expand Down Expand Up @@ -1720,20 +1719,6 @@ class MachLowering(mach: MachProgram, compiler: Compiler, config: MachLoweringCo
var mtbl = context.graph.valConst(mach.data.ptrType, mach.methodTable(methodRef));
return ptrLoad(funcRep.machType, ptrAdd(mtbl, tid), 0);
}
def genVariantReplaceNull(i_old: SsaApplyOp) -> SsaInstr {
var vt = i_old.op.typeArgs[0];
var val = i_old.input0();
if (V3.getVariantTag(vt) == 0) return val; // tag == 0 should be prepared for null
var t = addIfNull(val);
var tblock = t.0, fblock = t.1, merge = t.2;
curBlock = fblock;
fblock.addGoto(merge.block);
tblock.addGoto(merge.block);
curBlock = merge;
var record = V3.makeDefaultVariantRecord(context.prog, vt);
var addr = mach.machVal(record);
return curBlock.addPhi(vt, [val, context.graph.valConst(mach.machType(vt), addr)]);
}
def genComponentGetField(i_old: SsaApplyOp, field: IrField) {
if (config.ObjectSystem) return void(normId(i_old));
var fieldRef = V3Op.extractIrSpec(i_old.op, field);
Expand Down
2 changes: 1 addition & 1 deletion aeneas/src/main/Version.v3
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

// Updated by VCS scripts. DO NOT EDIT.
component Version {
def version: string = "III-7.1745";
def version: string = "III-7.1746";
var buildData: string;
}