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

CODETOOLS-7903291: jcstress: Optimize jcstress trap handling #121

Merged
merged 1 commit into from
Sep 8, 2022
Merged
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
Original file line number Diff line number Diff line change
@@ -561,10 +561,6 @@ private void generateContinuous(TestInfo info) {
pw.println(" }");
pw.println();

for (String type : new String[] { "int", "short", "byte", "char", "long", "float", "double", "Object" }) {
pw.println(" private void " + AUX_PREFIX + "sink(" + type + " v) {};");
}

int n = 0;
for (ExecutableElement a : info.getActors()) {
pw.println();
@@ -604,26 +600,24 @@ private void generateContinuous(TestInfo info) {
// compiler to avoid null-pointer checks in the workload, which will
// free it to choose alternative load/store orders.
//
// For results, we access the most convenient result field, and make sure
// its null-checking effects stays behind by calling the empty method.
// That method would be normally inlined and eliminated, but the NP-check
// would persist.
// For results, we access the most convenient result field, and access it.
// Java rules require the JVMs to perform the NP-check there anyway.
//
// For states that are passed as arguments we can do the same.
// For states that are receivers themselves, we already have the NP-check.

pw.println(" " + s + " s = ls[c];");
if (hasResultArgs(a)) {
pw.println(" " + r + " r = lr[c];");
pw.println(" " + AUX_PREFIX + "sink(r.jcstress_trap);");
pw.println(" int trap_r = r.jcstress_trap;");
}

if (isStateItself) {
emitMethod(pw, a, " s." + a.getSimpleName(), "s", "r", true);
} else {
String sf = selectSinkField(info.getState());
String[] sf = selectSinkField(info.getState());
if (sf != null) {
pw.println(" " + AUX_PREFIX + "sink(s." + sf + ");");
pw.println(" " + sf[0] + " trap_s = s." + sf[1] + ";");
}
emitMethod(pw, a, " lt." + a.getSimpleName(), "s", "r", true);
}
@@ -639,7 +633,7 @@ private void generateContinuous(TestInfo info) {
pw.close();
}

private String selectSinkField(TypeElement cl) {
private String[] selectSinkField(TypeElement cl) {
String[] typePref = { "int", "short", "byte", "char", "long", "float", "double" };

// Select first field of preferential type
@@ -650,7 +644,7 @@ private String selectSinkField(TypeElement cl) {
if (mods.contains(Modifier.PRIVATE)) continue;

String t = var.asType().toString();
if (t.equals(typeP)) return var.getSimpleName().toString();
if (t.equals(typeP)) return new String[] { t, var.getSimpleName().toString() };
}
}

@@ -660,7 +654,7 @@ private String selectSinkField(TypeElement cl) {
if (mods.contains(Modifier.STATIC)) continue;
if (mods.contains(Modifier.PRIVATE)) continue;

return var.getSimpleName().toString();
return new String[] { "Object", var.getSimpleName().toString() };
}

return null;