Set<Op> highProb = new HashSet<Op>();
Set<Op> lowProb = new HashSet<Op>();
if (percent(100)) highProb.addAll(Op.BASIC); if (percent(100)) highProb.addAll(Op.STANDARD); if (percent(1)) lowProb.add(Op.THROW); if (percent(3)) lowProb.addAll(Op.PIN); if (percent(3)) lowProb.addAll(Op.MH); if (percent(0)) lowProb.addAll(Op.REFLECTED); if (percent(50)) {
highProb.removeAll(Op.INTERPRETED);
lowProb.removeAll(Op.INTERPRETED);
}
Op[] highProb0 = highProb.toArray(Op[]::new);
Op[] lowProb0 = lowProb.toArray(Op[]::new);
int loops = 7;
Op[] trace = new Op[length]; for (int i=0; i < trace.length; i++) {
trace[i] = pick((lowProb.isEmpty() || percent(90)) ? highProb0 : lowProb0); if (trace[i] == Op.LOOP && (loops--) <= 0) i--;
} return trace;
}
for (Method m : compile) {
WB.deoptimizeMethod(m);
WB.clearMethodState(m);
}
}
staticvoid enqueueForCompilation(Method m) { if (WB.isMethodCompiled(m)) return; // WB compilation tasks do not expire while others do, // so we wait for an existing task to finish before enqueuing. // Alternatively run with -XX:TieredCompileTaskTimeout=5000
Utils.waitForCondition(() -> WB.isMethodQueuedForCompilation(m), 1000); if (WB.isMethodCompiled(m)) return;
WB.enqueueMethodForCompilation(m, COMPILE_LEVEL);
}
staticvoid compileContinuation() { var compile = new HashSet<Method>(); for (Method m : Continuation.class.getDeclaredMethods()) { if (!WB.isMethodCompiled(m)) { if (!Modifier.isNative(m.getModifiers())
&& (m.getName().startsWith("enter")
|| m.getName().startsWith("yield"))) {
enqueueForCompilation(m);
compile.add(m);
}
}
}
for (Method m : interpret) WB.makeMethodNotCompilable(m);
for (Method m : compile) enqueueForCompilation(m); for (Method m : compile) waitForCompilation(m); for (Method m : compile) assert WB.isMethodCompiled(m) : "method: " + m; for (Method m : interpret) assert !WB.isMethodCompiled(m) : "method: " + m;
time(start, "Compile");
}
boolean checkContinuationCompilation() { for (Method m : Continuation.class.getDeclaredMethods()) { if (!WB.isMethodCompiled(m)) { if (!Modifier.isNative(m.getModifiers())
&& (m.getName().startsWith("enter")
|| m.getName().startsWith("yield"))) { returnfalse;
}
}
} returntrue;
}
boolean checkCompilation() { boolean res = true;
if (!checkContinuationCompilation()) {
res = false;
System.out.println("CHANGED CONTINUATION COMPILATION");
}
Op[] newTrace = Arrays.copyOf(trace, trace.length); if (!checkCompilation(newTrace)) {
res = false;
System.out.println("CHANGED COMPILATION");
printTrace(newTrace);
}
return res;
}
staticboolean checkCompilation(Op[] trace) { boolean ok = true; for (int i = 0; i < trace.length; i++) {
Op op = trace[i]; if (Op.COMPILED.contains(op) && !WB.isMethodCompiled(method(op))) trace[i] = Op.toInterpreted(op); if (Op.INTERPRETED.contains(op) && WB.isMethodCompiled(method(op))) trace[i] = Op.toCompiled(op); if (op != trace[i]) ok = false;
} return ok;
}
int depth() { int d = 0; for (int i=0; i<=index && i < trace.length; i++) if (!Op.NON_CALLS.contains(trace[i])) d++; return d;
}
boolean traceHas(Predicate<Op> pred) { for (int i = 0; i < index; i++) if (pred.test(trace[i])) returntrue; returnfalse;
}
String[] expectedStackTrace() { var ms = new ArrayList<String>(); for (int i = index; i >= 0; i--) if (!Op.NON_CALLS.contains(trace[i])) ms.add(method(trace[i]).getName());
ms.add("run"); return ms.toArray(new String[0]);
}
int computeResult() { // To compute the expected result, we remove all YIELDs from the trace and run it
Op[] trace0 = Arrays.stream(trace).filter(op -> op != Op.YIELD)
.collect(Collectors.toList()).toArray(Op[]::new);
static <T> T[] cutStack(T[] stack) { var list = new ArrayList<T>(); int i = 0; while (i < stack.length && (!Fuzz.class.getName().equals(sfClassName(stack[i])) || isPrePostYield(stack[i]) || isStackCaptureMechanism(stack[i]))) i++; while (i < stack.length && !Continuation.class.getName().equals(sfClassName(stack[i]))) { list.add(stack[i]); i++; } // while (i < stack.length && Continuation.class.getName().equals(sfClassName(stack[i])) && !"enterSpecial".equals(sfMethodName(stack[i]))) { list.add(stack[i]); i++; } return list.toArray(arrayType(stack));
}
staticvoid verifyStack(Object[] expected, Object[] observed) {
expected = cutStack(expected);
observed = cutStack(observed); boolean equal = true; if (expected.length == observed.length) { for (int i=0; i < expected.length; i++) { if (!sfEquals(expected[i], observed[i])) { // we allow a different line number for the first element if (i > 0 || !Objects.equals(sfClassName(expected[i]), sfClassName(observed[i])) || !Objects.equals(sfMethodName(expected[i]), sfMethodName(observed[i]))) {
System.out.println("At index " + i + " expected: " + sfToString(expected[i]) + " observed: " + sfToString(observed[i]));
staticboolean sfEquals(Object a, Object b) { if (a instanceof String) return sfClassName(a).equals(sfClassName(b)) && sfMethodName(a).equals(sfMethodName(b));
return a instanceof StackTraceElement ? Objects.equals(a, b)
: StackWalkerHelper.equals((StackFrame)a, (StackFrame)b);
}
for (int c = 1, index0 = index; c > 0; c--, maybeResetIndex(index0)) { // index0 is the index to which we return when we loop switch (next(c)) { caseTHROW -> throwException(); case LOOP -> { c += 2; index0 = index; } case YIELD -> { preYield(); boolean y = Continuation.yield(SCOPE); postYield(y); c++; } case DONE -> { break; } case CALL_I_INT -> res += int_int(depth+1, (int)res); case CALL_C_INT -> res += com_int(depth+1, (int)res); case CALL_I_DBL -> res += (int)int_dbl(depth+1, res); case CALL_C_DBL -> res += (int)com_dbl(depth+1, res); case CALL_I_PIN -> res += int_pin(depth+1, (int)res); case CALL_C_PIN -> res += com_pin(depth+1, (int)res); case CALL_I_MANY -> res += int_mny(depth+1, x1, d1, l1, f1, o1, x2, d2, l2, f2, o2, x3, d3, l3, f3, o3, x4, d4, l4, f4, o4); case CALL_C_MANY -> res += com_mny(depth+1, x1, d1, l1, f1, o1, x2, d2, l2, f2, o2, x3, d3, l3, f3, o3, x4, d4, l4, f4, o4); case CALL_I_CTCH -> {try { res += int_int(depth+1, (int)res); } catch (FuzzException e) {}} case CALL_C_CTCH -> {try { res += com_int(depth+1, (int)res); } catch (FuzzException e) {}} case MH_I_INT, MH_C_INT -> {try { res += (int)handle(current()).invokeExact(this, depth+1, (int)res); } catch (Throwable e) { rethrow(e); }} case MH_I_MANY, MH_C_MANY -> {try { res += (int)handle(current()).invokeExact(this, depth+1, x1, d1, l1, f1, o1, x2, d2, l2, f2, o2, x3, d3, l3, f3, o3, x4, d4, l4, f4, o4); } catch (Throwable e) { rethrow(e); }} case REF_I_INT, REF_C_INT -> {try { res += (int)method(current()).invoke(this, depth+1, (int)res); } catch (InvocationTargetException e) { rethrow(e.getCause()); } catch (IllegalAccessException e) { assertfalse; }} case REF_I_MANY, REF_C_MANY -> {try { res += (int)method(current()).invoke(this, depth+1, x1, d1, l1, f1, o1, x2, d2, l2, f2, o2, x3, d3, l3, f3, o3, x4, d4, l4, f4, o4); } catch (InvocationTargetException e) { rethrow(e.getCause()); } catch (IllegalAccessException e) { assertfalse; }} default -> thrownew AssertionError("Unknown op: " + current());
}
}
}
return log(res);
}
@DontInline int int_mny(int depth, int x1, double d1, long l1, float f1, Object o1, int x2, double d2, long l2, float f2, Object o2, int x3, double d3, long l3, float f3, Object o3, int x4, double d4, long l4, float f4, Object o4) {
for (int c = 1, index0 = index; c > 0; c--, maybeResetIndex(index0)) { // index0 is the index to which we return when we loop switch (next(c)) { caseTHROW -> throwException(); case LOOP -> { c += 2; index0 = index; } case YIELD -> { preYield(); boolean y = Continuation.yield(SCOPE); postYield(y); c++; } case DONE -> { break; } case CALL_I_INT -> res += int_int(depth+1, (int)res); case CALL_C_INT -> res += com_int(depth+1, (int)res); case CALL_I_DBL -> res += (int)int_dbl(depth+1, res); case CALL_C_DBL -> res += (int)com_dbl(depth+1, res); case CALL_I_PIN -> res += int_pin(depth+1, (int)res); case CALL_C_PIN -> res += com_pin(depth+1, (int)res); case CALL_I_MANY -> res += int_mny(depth+1, x1, d1, l1, f1, o1, x2, d2, l2, f2, o2, x3, d3, l3, f3, o3, x4, d4, l4, f4, o4); case CALL_C_MANY -> res += com_mny(depth+1, x1, d1, l1, f1, o1, x2, d2, l2, f2, o2, x3, d3, l3, f3, o3, x4, d4, l4, f4, o4); case CALL_I_CTCH -> {try { res += int_int(depth+1, (int)res); } catch (FuzzException e) {}} case CALL_C_CTCH -> {try { res += com_int(depth+1, (int)res); } catch (FuzzException e) {}} case MH_I_INT, MH_C_INT -> {try { res += (int)handle(current()).invokeExact(this, depth+1, (int)res); } catch (Throwable e) { rethrow(e); }} case MH_I_MANY, MH_C_MANY -> {try { res += (int)handle(current()).invokeExact(this, depth+1, x1, d1, l1, f1, o1, x2, d2, l2, f2, o2, x3, d3, l3, f3, o3, x4, d4, l4, f4, o4); } catch (Throwable e) { rethrow(e); }} case REF_I_INT, REF_C_INT -> {try { res += (int)method(current()).invoke(this, depth+1, (int)res); } catch (InvocationTargetException e) { rethrow(e.getCause()); } catch (IllegalAccessException e) { assertfalse; }} case REF_I_MANY, REF_C_MANY -> {try { res += (int)method(current()).invoke(this, depth+1, x1, d1, l1, f1, o1, x2, d2, l2, f2, o2, x3, d3, l3, f3, o3, x4, d4, l4, f4, o4); } catch (InvocationTargetException e) { rethrow(e.getCause()); } catch (IllegalAccessException e) { assertfalse; }} default -> thrownew AssertionError("Unknown op: " + current());
}
}
return log((int)res);
}
@DontInline int com_mny(int depth, int x1, double d1, long l1, float f1, Object o1, int x2, double d2, long l2, float f2, Object o2, int x3, double d3, long l3, float f3, Object o3, int x4, double d4, long l4, float f4, Object o4) {
for (int c = 1, index0 = index; c > 0; c--, maybeResetIndex(index0)) { // index0 is the index to which we return when we loop switch (next(c)) { caseTHROW -> throwException(); case LOOP -> { c += 2; index0 = index; } case YIELD -> { preYield(); boolean y = Continuation.yield(SCOPE); postYield(y); c++; } case DONE -> { break; } case CALL_I_INT -> res += int_int(depth+1, (int)res); case CALL_C_INT -> res += com_int(depth+1, (int)res); case CALL_I_DBL -> res += (int)int_dbl(depth+1, res); case CALL_C_DBL -> res += (int)com_dbl(depth+1, res); case CALL_I_PIN -> res += int_pin(depth+1, (int)res); case CALL_C_PIN -> res += com_pin(depth+1, (int)res); case CALL_I_MANY -> res += int_mny(depth+1, x1, d1, l1, f1, o1, x2, d2, l2, f2, o2, x3, d3, l3, f3, o3, x4, d4, l4, f4, o4); case CALL_C_MANY -> res += com_mny(depth+1, x1, d1, l1, f1, o1, x2, d2, l2, f2, o2, x3, d3, l3, f3, o3, x4, d4, l4, f4, o4); case CALL_I_CTCH -> {try { res += int_int(depth+1, (int)res); } catch (FuzzException e) {}} case CALL_C_CTCH -> {try { res += com_int(depth+1, (int)res); } catch (FuzzException e) {}} case MH_I_INT, MH_C_INT -> {try { res += (int)handle(current()).invokeExact(this, depth+1, (int)res); } catch (Throwable e) { rethrow(e); }} case MH_I_MANY, MH_C_MANY -> {try { res += (int)handle(current()).invokeExact(this, depth+1, x1, d1, l1, f1, o1, x2, d2, l2, f2, o2, x3, d3, l3, f3, o3, x4, d4, l4, f4, o4); } catch (Throwable e) { rethrow(e); }} case REF_I_INT, REF_C_INT -> {try { res += (int)method(current()).invoke(this, depth+1, (int)res); } catch (InvocationTargetException e) { rethrow(e.getCause()); } catch (IllegalAccessException e) { assertfalse; }} case REF_I_MANY, REF_C_MANY -> {try { res += (int)method(current()).invoke(this, depth+1, x1, d1, l1, f1, o1, x2, d2, l2, f2, o2, x3, d3, l3, f3, o3, x4, d4, l4, f4, o4); } catch (InvocationTargetException e) { rethrow(e.getCause()); } catch (IllegalAccessException e) { assertfalse; }} default -> thrownew AssertionError("Unknown op: " + current());
}
}
return log((int)res);
}
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.79Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-06-10)
¤
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.