Commit 20efccc7 authored by Aibek Sarimbekov's avatar Aibek Sarimbekov

fixed some issues

parent c90205f1
......@@ -17,9 +17,7 @@ public class DiSLClass {
@AfterReturning(marker = BytecodeMarker.class, args = "newarray, anewarray, multianewarray")
public static void eee(DynamicContext dc, MyMethodStaticContext sc, UniqueMethodId id) {
Object allocatedObj = dc.getStackValue(0, Object.class);
// int offset = sc.getOffset();
// int methodID = id.get();
// int clID = System.identityHashCode(allocatedObj.getClass().getClassLoader());
HPROFAnalysis.instanceOf().onObjectInitialization(
allocatedObj, //the allocated object
sc.getExtendedID(),
......@@ -36,13 +34,9 @@ public class DiSLClass {
/** ALLOCATION SITE **/
@AfterReturning(marker = NewObjMarker.class, order = 10)
public static void afterReturningNew(MyMethodStaticContext sc, DynamicContext dc, UniqueMethodId id) {
// System.err.println("allocation snippet in " + sc.thisMethodFullName());
// if(objStack != null) {
if(!objStack.empty()) {
Object allocatedObj = objStack.pop();
// int offset = sc.getOffset();
// int methodID = id.get();
// int clID = System.identityHashCode(allocatedObj.getClass().getClassLoader());
HPROFAnalysis.instanceOf().onObjectInitialization(
allocatedObj, //the allocated object
sc.getExtendedID(),
......@@ -51,7 +45,6 @@ public class DiSLClass {
} else {
System.out.println("EMPTY STACK\t" + Thread.currentThread().getName() +"\t" + sc.thisMethodFullName());
}
// }
}
}
package ch.usi.dag.disl.example.hprof;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import ch.usi.dag.disl.staticcontext.MethodStaticContext;
......@@ -22,33 +19,4 @@ public class MyMethodStaticContext extends MethodStaticContext {
return thisMethodFullName() + "_" + getOffset() + "_";
}
public String getAllocationSite() {
int idx = 0;
for(AbstractInsnNode instr = staticContextData.getRegionStart(); instr != null; instr = instr.getPrevious()) {
idx++;
}
return thisMethodFullName() + thisMethodDescriptor() + "[" + String.valueOf(idx) + "]";
}
public String getFieldId() {
AbstractInsnNode instr = staticContextData.getRegionStart();
if (instr.getOpcode() == Opcodes.PUTFIELD || instr.getOpcode() == Opcodes.GETFIELD) {
return ((FieldInsnNode) instr).owner + ":" + ((FieldInsnNode) instr).name + ":" + ((FieldInsnNode) instr).desc.replace('.', '/');
} else {
throw new RuntimeException("[MyMethodStaticContext.getFieldId] Error! Improper use of getFieldId()");
}
}
public String getInstructionTarget(){
AbstractInsnNode instr = staticContextData.getRegionStart();
if (instr.getOpcode() == Opcodes.INVOKESPECIAL) {
return ((MethodInsnNode) instr).owner + ":" + ((MethodInsnNode) instr).name;
} else {
throw new RuntimeException("[MyMethodStaticContext.getFieldId] Error! Improper use of getFieldId()");
}
}
}
......@@ -8,7 +8,8 @@ public class Counter {
private final String objectType;
private long totalSize;
private long currentSize;
//maybe not the best solution
private String allocationSite;
public Counter(String objType) {
this.objectType = objType;
......@@ -30,6 +31,13 @@ public class Counter {
return currentNumberOfObjects;
}
public synchronized void setAllocationSite(String allocationSite) {
this.allocationSite = allocationSite;
}
public String getAllocationSite() {
return allocationSite;
}
public synchronized void incrementCounter(long size) {
......@@ -49,6 +57,6 @@ public class Counter {
}
public String toString() {
return getObjectType() + "\t" + "...";
return getCurrentSize() + "\t" + getCurrentNumberOfObjects() + "\t" + getTotalSize() + "\t" + getTotalNumberOfObjects() + "\t" + getObjectType() + "\t" + getAllocationSite();
}
}
package ch.usi.dag.disl.example.hprof.runtime;
import java.util.Comparator;
public class CounterComparator implements Comparator<Object> {
@Override
public int compare(Object arg0, Object arg1) {
long arg0Size = ((Counter) arg0).getTotalSize();
long arg1Size = ((Counter) arg1).getTotalSize();
if(arg0Size > arg1Size)
return -1;
else if (arg0Size < arg1Size)
return 1;
else
return 0;
}
}
......@@ -5,11 +5,11 @@ package ch.usi.dag.disl.example.hprof.runtime;
import java.lang.instrument.Instrumentation;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.LinkedBlockingQueue;
import ch.usi.dag.disl.dynamicbypass.DynamicBypass;
import ch.usi.dag.dislagent.DiSLAgent;
......@@ -24,7 +24,7 @@ public class HPROFAnalysis {
public void run() {
DynamicBypass.activate();
//TODO: maybe this should be an int --> call gc multiple times in a row if not refs are available
boolean blocking = false;
// boolean blocking = false;
while(true) {
try {
......@@ -95,23 +95,23 @@ public class HPROFAnalysis {
System.err.println("In shutdown hook!");
//
try {
//
ArrayList<Counter> list = new ArrayList<Counter>();
Iterator<Entry<String, Counter>> iterator = counterMap.entrySet().iterator();
int idx = 0;
while (iterator.hasNext()) {
idx++;
Entry<String, Counter> entry = iterator.next();
String key = entry.getKey();
Counter myCounter = entry.getValue();
//TODO: myCounter.toString();
int totalNumber = myCounter.getTotalNumberOfObjects();
long totalSize = myCounter.getTotalSize();
long currentSize = myCounter.getCurrentSize();
int currentNumber = myCounter.getCurrentNumberOfObjects();
String typeOfObject = myCounter.getObjectType();
System.err.println(idx + " TOTAL SIZE " + totalSize + " TOTAL # " + totalNumber + " CURRENT SIZE " + currentSize + " CURRENT # "+ currentNumber + " TYPE OF THE OBJECT " + typeOfObject + " ALLOCATION SITE: " + key );
myCounter.setAllocationSite(key);
list.add(myCounter);
}
Object[] counters = list.toArray();
Arrays.sort(counters, new CounterComparator());
for (Object counter:counters) {
idx++;
System.err.println(idx + "\t" + ((Counter)counter).toString());
}
} catch (Throwable e) {
e.printStackTrace();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment