453 int computeResult() {
454 // To compute the expected result, we remove all YIELDs from the trace and run it
455 Op[] trace0 = Arrays.stream(trace).filter(op -> op != Op.YIELD)
456 .collect(Collectors.toList()).toArray(Op[]::new);
457
458 Fuzz f0 = new Fuzz(trace0);
459 // if (VERBOSE) {
460 // System.out.println(">>>> RESULT");
461 // f0.verbose = true;
462 // }
463 f0.run();
464 return f0.result;
465 }
466
467 void verifyResult(int result) {
468 int computed = computeResult();
469 assert result == computed : "result: " + result + " expected: " + computed;
470 }
471
472 boolean shouldPin() {
473 return traceHas(Op.PIN::contains);
474 }
475
476 void verifyPin(boolean yieldResult) {
477 if (yieldResult) yields++;
478 if (!yieldResult && traceHas(op -> Op.INTERPRETED.contains(op) && Op.REFLECTED.contains(op))) return;
479 assert yieldResult != shouldPin() : "res: " + yieldResult + " shouldPin: " + shouldPin();
480 }
481
482 boolean shouldThrow() {
483 for (int i = 0; i <= index && i < trace.length; i++) {
484 switch (trace[i]) {
485 case CALL_I_CTCH, CALL_C_CTCH -> { return false; }
486 case THROW -> { return true; }
487 default -> {}
488 }
489 }
490 return false;
491 }
492
493 void captureStack() {
|
453 int computeResult() {
454 // To compute the expected result, we remove all YIELDs from the trace and run it
455 Op[] trace0 = Arrays.stream(trace).filter(op -> op != Op.YIELD)
456 .collect(Collectors.toList()).toArray(Op[]::new);
457
458 Fuzz f0 = new Fuzz(trace0);
459 // if (VERBOSE) {
460 // System.out.println(">>>> RESULT");
461 // f0.verbose = true;
462 // }
463 f0.run();
464 return f0.result;
465 }
466
467 void verifyResult(int result) {
468 int computed = computeResult();
469 assert result == computed : "result: " + result + " expected: " + computed;
470 }
471
472 boolean shouldPin() {
473 return traceHas(Op.PIN::contains) && !(Platform.isX64() || Platform.isAArch64());
474 }
475
476 void verifyPin(boolean yieldResult) {
477 if (yieldResult) yields++;
478 if (!yieldResult && traceHas(op -> Op.INTERPRETED.contains(op) && Op.REFLECTED.contains(op))) return;
479 assert yieldResult != shouldPin() : "res: " + yieldResult + " shouldPin: " + shouldPin();
480 }
481
482 boolean shouldThrow() {
483 for (int i = 0; i <= index && i < trace.length; i++) {
484 switch (trace[i]) {
485 case CALL_I_CTCH, CALL_C_CTCH -> { return false; }
486 case THROW -> { return true; }
487 default -> {}
488 }
489 }
490 return false;
491 }
492
493 void captureStack() {
|