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

Introduce LongCollection interface for storing instrumentation traces #229

Merged
merged 1 commit into from
Dec 24, 2024
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
Expand Up @@ -3,7 +3,7 @@
//DO NOT EDIT!
//USE TRACER
public class TraceCollector {
public static LongHashSet trace = new LongHashSet();
public static LongCollection trace = new LongHashSet();
public static LongArrayWrapper statics = new LongArrayWrapper();

public static void jcInstructionCovered(long jcInstructionId) {
Expand All @@ -13,12 +13,27 @@ public static void jcStaticFieldAccessed(long jcStaticFieldAccessId) {
statics.add(jcStaticFieldAccessId);
}

public static class LongArrayWrapper {
public interface LongCollection {
void add(long key);

long[] getAllValues();

boolean contains(long key);

int realSize();

boolean isEmpty();

void clear();
}

public static class LongArrayWrapper implements LongCollection {
public long[] arr;
public int size;

LongArrayWrapper() {
public LongArrayWrapper() {
arr = new long[10];
size = 0;
}

public void add(long el) {
Expand All @@ -35,6 +50,31 @@ public void removeLast() {
size--;
}

public long[] getAllValues() {
long[] res = new long[size];
for (int i = 0; i < size; i++) {
res[i] = arr[i];
}
return res;
}

public boolean contains(long key) {
for (int i = 0; i < size; i++) {
if (arr[i] == key) {
return true;
}
}
return false;
}

public int realSize() {
return size;
}

public boolean isEmpty() {
return size == 0;
}

public void clear() {
for (int i = 0; i < size; i++) {
arr[i] = 0;
Expand All @@ -52,8 +92,7 @@ private void resize() {
}
}


public static class LongHashSet {
public static class LongHashSet implements LongCollection {
private static final int DEFAULT_CAPACITY = 1024;
private static final double DEFAULT_LOAD_FACTOR = 0.75;

Expand Down
Loading