// This base class has a single final field; // the constructor should have one fence. class Circle {
Circle(double radius) { this.radius = radius;
} publicdouble getRadius() { return radius;
} publicdouble getArea() { return radius * radius * Math.PI;
}
// This subclass adds an extra final field; // there should be an extra constructor fence added // (for a total of 2 after inlining). class Ellipse extends Circle {
Ellipse(double vertex, double covertex) { super(vertex);
// Make sure the constructor fence gets eliminated when the allocation is eliminated. staticdouble calcCircleArea(double radius) { returnnew Circle(radius).getArea();
}
// Multiple constructor fences can accumulate through inheritance, make sure // they are all eliminated when the allocation is eliminated. staticdouble calcEllipseArea(double vertex, double covertex) { returnnew Ellipse(vertex, covertex).getArea();
}
// The object allocation shall be eliminated by LSE and the load shall be replaced // by a Phi with the values that were previously being stored. staticdouble calcCircleAreaOrCircumference(double radius, boolean area_or_circumference) {
CalcCircleAreaOrCircumference calc = new CalcCircleAreaOrCircumference(
area_or_circumference ? CalcCircleAreaOrCircumference.TYPE_AREA :
CalcCircleAreaOrCircumference.TYPE_CIRCUMFERENCE);
// The object allocation is considered a singleton by LSE, // but we cannot eliminate the new because it is returned. // // The constructor fence must also not be removed because the object could escape the // current thread (in the caller). static Circle makeCircle(double radius) { returnnew Circle(radius);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.