Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion site.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# can only expand system properties
#jpf-core = ${user.home}/IdeaProjects/VarexJ

jpf-core = ${user.dir}
jpf-core = ${user.home}/Documents/package/jpf-core

jpf-nhandler = ${jpf-core}/jpf-nhandler
extensions = ${jpf-core},${jpf-nhandler}
Expand Down
80 changes: 0 additions & 80 deletions src/main/gov/nasa/jpf/vm/va/DataCollect.java

This file was deleted.

32 changes: 32 additions & 0 deletions src/main/gov/nasa/jpf/vm/va/Log.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package gov.nasa.jpf.vm.va;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;;
public class Log {
static Logger logger = null;
public static void init() {
logger = Logger.getLogger("DataCollect");
logger.setLevel(Level.INFO);
FileHandler fileHandler = null;
try {
fileHandler = new FileHandler("/home/meng/Documents/1.log");
} catch(IOException e) {
}
fileHandler.setLevel(Level.INFO);
SimpleFormatter formatter = new SimpleFormatter();
fileHandler.setFormatter(formatter);
logger.addHandler(fileHandler);
logger.setUseParentHandlers(false);
logger.info("Begin Crawling, Good Luck!");
}
public static Logger getInstance() {
if(logger == null) {
System.out.println("init()");
init();
}
return logger;
}
}
10 changes: 5 additions & 5 deletions src/main/gov/nasa/jpf/vm/va/Stack.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public class Stack {

public int top;
public Entry[] slots;
public DataCollect owner;
public StackHandlerTracker c;


public Stack(int nOperands, DataCollect dc) {
public Stack(int nOperands, StackHandlerTracker dc) {
top = -1;
slots = new Entry[nOperands];
owner = dc;
c = dc;
}

public void clear() {
Expand Down Expand Up @@ -115,9 +115,9 @@ public void setIndex(int index, Integer value, boolean isRef) {


Stack copy() {
owner.numCopy += top+1;
c.stackcopy(this);
//System.out.println(owner.c.redNum);
Stack clone = new Stack(slots.length, owner);
Stack clone = new Stack(slots.length, c);
clone.top = top;
System.arraycopy(slots, 0, clone.slots, 0, top + 1);
return clone;
Expand Down
17 changes: 8 additions & 9 deletions src/main/gov/nasa/jpf/vm/va/StackHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ enum StackInstruction {
public FeatureExpr stackCTX;


//*** dataCollect class object***//
public DataCollect c = new DataCollect(this);
//*** StackHandlerTracker class object***//
public StackHandlerTracker c = new StackHandlerTracker();

static LinkedList<DataCollect> q = new LinkedList<DataCollect>();
//static LinkedList<StackHandlerTracker> q = new LinkedList<StackHandlerTracker>();


/* (non-Javadoc)
Expand Down Expand Up @@ -84,7 +84,6 @@ public String toString() {

@SuppressWarnings("unchecked")
public StackHandler(FeatureExpr ctx, int nLocals, int nOperands) {
c.setMin(nOperands);
if (ctx == null) {
throw new RuntimeException("CTX == NULL");
}
Expand All @@ -93,7 +92,7 @@ public StackHandler(FeatureExpr ctx, int nLocals, int nOperands) {
Arrays.fill(locals, nullValue);
stack = new One<>(new Stack(nOperands, this.c));
stackCTX = ctx;
q.addLast(this.c);
//q.addLast(this.c);
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -439,7 +438,7 @@ public Conditional<Stack> apply(final FeatureExpr f, final Stack stack) {
return ChoiceFactory.create(ctx, new One<>(clone), new One<>(stack));
}
}).simplify();
c.push();
c.push(this, ctx, value, isRef);
}

/* (non-Javadoc)
Expand Down Expand Up @@ -514,7 +513,7 @@ public Conditional<T> apply(final FeatureExpr f, final Stack s) {
}
}).simplifyValues();
stack = stack.simplify();
c.pop();
c.pop(this, ctx,0);
return result;
}

Expand Down Expand Up @@ -542,7 +541,7 @@ public Conditional<Stack> apply(final FeatureExpr f, final Stack s) {
return ChoiceFactory.create(f, new One<>(clone), new One<>(s));
}
}).simplify();
c.pop();
c.pop(this, ctx, n);
}

/* (non-Javadoc)
Expand Down Expand Up @@ -847,6 +846,7 @@ public void dup2(final FeatureExpr ctx) {
@Override
public void dup(final FeatureExpr ctx) {
function(ctx, StackInstruction.DUP);
c.dup(this, ctx);
}

/* (non-Javadoc)
Expand Down Expand Up @@ -910,7 +910,6 @@ public Conditional<Stack> apply(final FeatureExpr f, final Stack stack) {
return ChoiceFactory.create(ctx, new One<>(clone), new One<>(stack));
}
}).simplify();
c.dup();
}

@Override
Expand Down
168 changes: 168 additions & 0 deletions src/main/gov/nasa/jpf/vm/va/StackHandlerTracker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
package gov.nasa.jpf.vm.va;

import java.util.*;
import de.fosd.typechef.featureexpr.FeatureExpr;

public class StackHandlerTracker {
Integer numCopy;
Integer size;
Integer max;
Integer min;
Integer ave;
Integer gmax;


StackHandlerTracker() {
this.numCopy = 0;
this.size = 0;
this.max = 0;
this.min = 0;
this.ave = 0;
this.gmax = 0;
}

public void set(Integer size, Integer min, Integer max, Integer ave) {
this.size = size;
this.max = max;
this.min = min;
this.ave = ave;
}

/***
* StackHandler
* push pop isref INC
* set dup swap
*/
public void push(StackHandler sh, final FeatureExpr ctx, final Object value, final boolean isRef){
calculate(sh);
Log.getInstance().info("PUSH\n"+ sh.toString() + "\n" + this.toString());
}

public void pop(StackHandler sh, FeatureExpr ctx, final int n){
calculate(sh);
Log.getInstance().info("POP\n"+ sh.toString() + "\n" + this.toString());
}

public void set(StackHandler sh, final FeatureExpr ctx, final int offset, final int value, final boolean isRef){}

public void dup(StackHandler sh, final FeatureExpr ctx) {
calculate(sh);
Log.getInstance().info("DUP\n"+ sh.toString() + "\n" + this.toString());
}

public void isRef(StackHandler sh, final FeatureExpr ctx, final int offset) {}

public void set(final FeatureExpr ctx, final int offset, final int value, final boolean isRef) {}

public void getTop(StackHandler sh) {}

public void setTop(StackHandler sh, final FeatureExpr ctx, final int i) {}

public void clear(StackHandler sh, final FeatureExpr ctx) {}

public void getSlots(StackHandler sh, FeatureExpr ctx) {}

/***
* Stack operations
*
*
*/
public void dup_x1(StackHandler sh, final FeatureExpr ctx) {}

public void dup2_x2(StackHandler sh, final FeatureExpr ctx) {}

public void dup2_x1(StackHandler sh, final FeatureExpr ctx) {}

public void dup2(StackHandler sh, final FeatureExpr ctx) {}

public void dup_x2(StackHandler sh, final FeatureExpr ctx){}

public void swap(StackHandler sh, final FeatureExpr ctx) {}

public void getLength(StackHandler sh) {}

public void getStack(StackHandler sh) {}

public void getAllReferences(StackHandler sh) {}

public void getLocalWidth(StackHandler sh) {}

public void getMaxLocal(StackHandler sh) {}

public void IINC(StackHandler sh, FeatureExpr ctx, int index, final int increment){}

/***
* Stack
* stackcopy entrycopy
*
*/

public void stackcopy(Stack s) {
this.numCopy += s.top+1;
}

public void clear(Stack s){}

public void setRef(Stack s, int index, boolean ref){}

public void hasAnyRef(Stack s){}

public void getSlots(Stack s){}

public void get(Stack s, int index){}

public void peek(Stack s, int offset){}

public void push(Stack s, Integer value, boolean isRef){}

public void isRef(Stack s, int offset){}

public void isRefIndex(Stack s, int index){}

public void set(Stack s, int offset, int value, boolean isRef){}

public void setIndex(Stack s, int index, Integer value, boolean isRef){}

public void dup2_x1(Stack s){}

public void dup2(Stack s){}

public void dup(Stack s){}

public void dup_x2(Stack s){}

public void swap(Stack s){}

public void getReferences(Stack s){}

public void entrycopy(Stack s){}

public void calculate(StackHandler sh){
List<Integer> temp = sh.getTop().toList();
Integer len = temp.size();
Integer sum = temp.get(0) + 1;
max = temp.get(0) + 1;
min = temp.get(0) + 1;
for(int i = 1; i < len; i++){
if(temp.get(i) + 1 > max)
this.max = temp.get(i) + 1;
if(temp.get(i) + 1 < min){
this.min = temp.get(i) + 1;
}

sum += temp.get(i) + 1;
}
if(this.max > this.gmax){
this.gmax = this.max;
}
this.ave = sum/len;
this.size = len;
}




public String toString(){
return "The size is " + this.size + "\nMinimun elements is "+ this.min + "\nMaximum elements is " +this.max + "\nAverage is " + this.ave + "\nNumbers of copys " + this.numCopy + "\ngmax is "+ this.gmax+ "\n";
}
}
Loading