Skip to content

Commit

Permalink
GC skipped values
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-bell committed Aug 8, 2024
1 parent 9e2d445 commit 0a1ce57
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/evaluation-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
report_on_branches:
description: Other branches to include in the report
required: false
default: ci,fuzz-ir,fuzz-ir-performance
default: ci,fuzz-ir,fuzz-ir-performance,fuzz-ir-skip-ahead
type: string
fuzzer_to_invoke:
description: Path to script to invoke for fuzzing run, defaults to ./bin/jqf-zest
Expand Down
20 changes: 20 additions & 0 deletions fuzz/src/main/java/edu/berkeley/cs/jqf/fuzz/ei/ZestGuidance.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import janala.instrument.FastCoverageListener;
import org.eclipse.collections.api.iterator.IntIterator;
import org.eclipse.collections.api.list.primitive.IntList;
import org.eclipse.collections.impl.list.mutable.primitive.IntArrayList;
import org.eclipse.collections.impl.set.mutable.primitive.IntHashSet;

import javax.sound.sampled.Line;
Expand Down Expand Up @@ -1219,6 +1220,9 @@ public static class LinearInput extends Input<Integer> {
public int numAlignments;
public int misAlignments;

/** For GC **/
public IntArrayList skippedIndices;

public LinearInput() {
super();
this.values = new ArrayList<>();
Expand Down Expand Up @@ -1253,6 +1257,13 @@ public void gc() {
values.trimToSize();
}

if(skippedIndices != null){
//Delete values at skipped indices
for(int i = skippedIndices.size() - 1; i >= 0; i--){
values.remove(skippedIndices.get(i));
}
}

// Inputs should not be empty, otherwise mutations don't work
if (values.isEmpty()) {
throw new IllegalArgumentException("Input is either empty or nothing was requested from the input generator.");
Expand Down Expand Up @@ -1311,6 +1322,15 @@ public void add(TypedGeneratedValue val) {
requested = values.size();
}
}

public void skip(int from, int to){
if(skippedIndices == null){
skippedIndices = new IntArrayList(5);
}
for(int i = from; i < to; i++){
skippedIndices.add(i);
}
}
}

public static class SeedInput extends LinearInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private TypedGeneratedValue readValue(TypedGeneratedValue.Type type){
if(positionInInput + i < input.size()){
TypedGeneratedValue next = input.get(positionInInput + i);
if(next.type == type){
//TODO consider removing the values so that we never try to mutate them
input.skip(positionInInput, positionInInput + i);
positionInInput += i;
input.numAlignments++;
return next;
Expand Down

0 comments on commit 0a1ce57

Please sign in to comment.