work on Wala with Yannis' group
This commit is contained in:
parent
8edfd285d7
commit
0ad11fefc3
|
@ -32,6 +32,7 @@ import com.ibm.wala.cast.ir.ssa.AstLexicalRead;
|
|||
import com.ibm.wala.cast.ir.ssa.AstLexicalWrite;
|
||||
import com.ibm.wala.cast.ir.ssa.AstPropertyRead;
|
||||
import com.ibm.wala.cast.ir.ssa.AstPropertyWrite;
|
||||
import com.ibm.wala.cast.ir.ssa.AstYieldInstruction;
|
||||
import com.ibm.wala.cast.ir.translator.AstTranslator;
|
||||
import com.ibm.wala.cast.ir.translator.AstTranslator.AstLexicalInformation;
|
||||
import com.ibm.wala.cast.java.ssa.AstJavaInstructionFactory;
|
||||
|
@ -660,6 +661,11 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
|
|||
return new AstLexicalWrite(iindex, definer, globalName, type, rhs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstYieldInstruction YieldInstruction(int iindex, int[] rvals) {
|
||||
return new AstYieldInstruction(iindex, rvals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstPropertyRead PropertyRead(int iindex, int result, int objectRef, int memberRef) {
|
||||
assert false;
|
||||
|
|
|
@ -10,6 +10,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
|||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.ibm.wala.cast.ir.ssa.AstLexicalRead;
|
|||
import com.ibm.wala.cast.ir.ssa.AstLexicalWrite;
|
||||
import com.ibm.wala.cast.ir.ssa.AstPropertyRead;
|
||||
import com.ibm.wala.cast.ir.ssa.AstPropertyWrite;
|
||||
import com.ibm.wala.cast.ir.ssa.AstYieldInstruction;
|
||||
import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction;
|
||||
import com.ibm.wala.cast.ir.ssa.EachElementHasNextInstruction;
|
||||
import com.ibm.wala.cast.ir.translator.AstTranslator.AstLexicalInformation;
|
||||
|
@ -308,6 +309,11 @@ public class JavaScriptLoader extends CAstAbstractModuleLoader {
|
|||
return new AstEchoInstruction(iindex, rvals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstYieldInstruction YieldInstruction(int iindex, int[] rvals) {
|
||||
return new AstYieldInstruction(iindex, rvals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AstGlobalRead GlobalRead(int iindex, int lhs, FieldReference global) {
|
||||
return new AstGlobalRead(iindex, lhs, global);
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2013 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.cast.ir.ssa;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
public abstract class AstConsumeInstruction extends SSAInstruction {
|
||||
protected final int[] rvals;
|
||||
|
||||
public AstConsumeInstruction(int iindex, int[] rvals) {
|
||||
super(iindex);
|
||||
this.rvals = rvals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfDefs() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions.UNREACHABLE();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfUses() {
|
||||
return rvals.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUse(int i) {
|
||||
return rvals[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int v = 1;
|
||||
for (int rval : rvals) {
|
||||
v *= rval;
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFallThrough() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TypeReference> getExceptionTypes() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
}
|
|
@ -10,21 +10,14 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.cast.ir.ssa;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstructionFactory;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
public class AstEchoInstruction extends SSAInstruction {
|
||||
private final int[] rvals;
|
||||
public class AstEchoInstruction extends AstConsumeInstruction {
|
||||
|
||||
public AstEchoInstruction(int iindex, int[] rvals) {
|
||||
super(iindex);
|
||||
this.rvals = rvals;
|
||||
super(iindex, rvals);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,36 +25,6 @@ public class AstEchoInstruction extends SSAInstruction {
|
|||
return ((AstInstructionFactory)insts).EchoInstruction(iindex, uses==null? rvals: uses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfDefs() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions.UNREACHABLE();
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfUses() {
|
||||
return rvals.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUse(int i) {
|
||||
return rvals[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int v = 1;
|
||||
for (int rval : rvals) {
|
||||
v *= rval;
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(SymbolTable symbolTable) {
|
||||
|
@ -78,14 +41,5 @@ public class AstEchoInstruction extends SSAInstruction {
|
|||
((AstInstructionVisitor)v).visitEcho(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFallThrough() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TypeReference> getExceptionTypes() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,4 +55,6 @@ public interface AstInstructionFactory extends SSAInstructionFactory {
|
|||
|
||||
AstPropertyWrite PropertyWrite(int iindex, int objectRef, int memberRef, int value);
|
||||
|
||||
AstYieldInstruction YieldInstruction(int iindex, int[] rvals);
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ public interface AstInstructionVisitor extends SSAInstruction.IVisitor {
|
|||
|
||||
default void visitEcho(AstEchoInstruction inst){ }
|
||||
|
||||
default void visitYield(AstYieldInstruction inst){ }
|
||||
|
||||
default void visitPropertyRead(AstPropertyRead instruction){ }
|
||||
|
||||
default void visitPropertyWrite(AstPropertyWrite instruction){ }
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2013 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.cast.ir.ssa;
|
||||
|
||||
import com.ibm.wala.ssa.SSAInstruction;
|
||||
import com.ibm.wala.ssa.SSAInstructionFactory;
|
||||
import com.ibm.wala.ssa.SymbolTable;
|
||||
|
||||
public class AstYieldInstruction extends AstConsumeInstruction {
|
||||
|
||||
public AstYieldInstruction(int iindex, int[] rvals) {
|
||||
super(iindex, rvals);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SSAInstruction copyForSSA(SSAInstructionFactory insts, int[] defs, int[] uses) {
|
||||
return ((AstInstructionFactory)insts).EchoInstruction(iindex, uses==null? rvals: uses);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString(SymbolTable symbolTable) {
|
||||
StringBuffer result = new StringBuffer("echo/print ");
|
||||
for (int rval : rvals) {
|
||||
result.append(getValueString(symbolTable, rval)).append(" ");
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(IVisitor v) {
|
||||
((AstInstructionVisitor)v).visitYield(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -30,6 +30,7 @@ import com.ibm.wala.cast.ir.ssa.AstIsDefinedInstruction;
|
|||
import com.ibm.wala.cast.ir.ssa.AstLexicalAccess.Access;
|
||||
import com.ibm.wala.cast.ir.ssa.AstLexicalRead;
|
||||
import com.ibm.wala.cast.ir.ssa.AstLexicalWrite;
|
||||
import com.ibm.wala.cast.ir.ssa.AstYieldInstruction;
|
||||
import com.ibm.wala.cast.ir.ssa.CAstBinaryOp;
|
||||
import com.ibm.wala.cast.ir.ssa.CAstUnaryOp;
|
||||
import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction;
|
||||
|
@ -4705,6 +4706,27 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
wc.cfg().noteOperands(currentInstruction, rposs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean visitYield(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void leaveYield(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) {
|
||||
WalkContext wc = c;
|
||||
|
||||
int rvals[] = new int[n.getChildCount()];
|
||||
Position rposs[] = new Position[n.getChildCount()];
|
||||
for (int i = 0; i < n.getChildCount(); i++) {
|
||||
rvals[i] = c.getValue(n.getChild(i));
|
||||
rposs[i] = c.getSourceMap().getPosition(n.getChild(i));
|
||||
}
|
||||
|
||||
int currentInstruction = wc.cfg().getCurrentInstruction();
|
||||
wc.cfg().addInstruction(new AstYieldInstruction(currentInstruction, rvals));
|
||||
wc.cfg().noteOperands(currentInstruction, rposs);
|
||||
}
|
||||
|
||||
public CAstEntity getIncludedEntity(CAstNode n) {
|
||||
if (n.getChild(0).getKind() == CAstNode.NAMED_ENTITY_REF) {
|
||||
assert namedEntityResolver != null;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.cast.ir.translator;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ibm.wala.cast.tree.CAst;
|
||||
|
@ -71,11 +72,17 @@ public abstract class ConstantFoldingRewriter extends CAstBasicRewriter<NonCopyi
|
|||
for (int i = 0; i < children.length; i++) {
|
||||
children[i] = copyNodes(root.getChild(i), cfg, context, nodeMap);
|
||||
}
|
||||
for(Object label: cfg.getTargetLabels(root)) {
|
||||
if (label instanceof CAstNode) {
|
||||
copyNodes((CAstNode)label, cfg, context, nodeMap);
|
||||
if (cfg != null) {
|
||||
Collection<Object> labels = cfg.getTargetLabels(root);
|
||||
if (labels != null) {
|
||||
for(Object label: labels) {
|
||||
if (label instanceof CAstNode) {
|
||||
copyNodes((CAstNode)label, cfg, context, nodeMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CAstNode copy = Ast.makeNode(root.getKind(), children);
|
||||
result = copy;
|
||||
}
|
||||
|
|
|
@ -871,6 +871,17 @@ public abstract class CAstVisitor<C extends CAstVisitor.Context> {
|
|||
break;
|
||||
}
|
||||
|
||||
case CAstNode.RETURN_WITHOUT_BRANCH: {
|
||||
if (visitor.visitYield(n, context, visitor)) {
|
||||
break;
|
||||
}
|
||||
for(int i = 0; i < n.getChildCount(); i++) {
|
||||
visitor.visit(n.getChild(i), context, visitor);
|
||||
}
|
||||
visitor.leaveYield(n, context, visitor);
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
if (!visitor.doVisit(n, context, visitor)) {
|
||||
System.err.println(("looking at unhandled " + n + "(" + NT + ")" + " of " + n.getClass()));
|
||||
|
@ -1269,6 +1280,19 @@ public abstract class CAstVisitor<C extends CAstVisitor.Context> {
|
|||
* @param c a visitor-specific context
|
||||
*/
|
||||
protected void leaveReturn(CAstNode n, C c, CAstVisitor<C> visitor) { visitor.leaveNode(n, c, visitor); }
|
||||
/**
|
||||
* Visit a Return node.
|
||||
* @param n the node to process
|
||||
* @param c a visitor-specific context
|
||||
* @return true if no further processing is needed
|
||||
*/
|
||||
protected boolean visitYield(CAstNode n, C c, CAstVisitor<C> visitor) { return visitor.visitNode(n, c, visitor); }
|
||||
/**
|
||||
* Leave a Return node.
|
||||
* @param n the node to process
|
||||
* @param c a visitor-specific context
|
||||
*/
|
||||
protected void leaveYield(CAstNode n, C c, CAstVisitor<C> visitor) { visitor.leaveNode(n, c, visitor); }
|
||||
/**
|
||||
* Visit an Ifgoto node.
|
||||
* @param n the node to process
|
||||
|
|
|
@ -42,6 +42,8 @@ public class CallGraphTestUtil {
|
|||
|
||||
public static String REGRESSION_EXCLUSIONS = "Java60RegressionExclusions.txt";
|
||||
|
||||
public static String REGRESSION_EXCLUSIONS_FOR_GUI = "Java60RegressionExclusionsForGUI.txt";
|
||||
|
||||
/**
|
||||
* should we check the heap footprint before and after CG construction?
|
||||
*/
|
||||
|
|
|
@ -49,6 +49,11 @@ public class ClassBasedInstanceKeys implements InstanceKeyFactory {
|
|||
throw new IllegalArgumentException("allocation is null");
|
||||
}
|
||||
|
||||
if (String.valueOf(allocation).contains("java/lang/invoke/DirectMethodHandle$StaticAccessor")) {
|
||||
System.err.println("got " + allocation + " in " + node);
|
||||
}
|
||||
|
||||
|
||||
if (options.getClassTargetSelector() == null) {
|
||||
throw new IllegalStateException("options did not specify class target selector");
|
||||
}
|
||||
|
@ -130,6 +135,7 @@ public class ClassBasedInstanceKeys implements InstanceKeyFactory {
|
|||
public InstanceKey getInstanceKeyForMetadataObject(Object obj, TypeReference objType) {
|
||||
IClass cls = cha.lookupClass(objType);
|
||||
assert cls != null : objType;
|
||||
|
||||
if (obj instanceof TypeReference) {
|
||||
IClass klass = cha.lookupClass((TypeReference)obj);
|
||||
if (klass == null) {
|
||||
|
@ -141,7 +147,7 @@ public class ClassBasedInstanceKeys implements InstanceKeyFactory {
|
|||
} else if (obj instanceof MethodReference) {
|
||||
IMethod m = cha.resolveMethod((MethodReference)obj);
|
||||
if (m == null) {
|
||||
return new ConcreteTypeKey(cls);
|
||||
return new ConcreteTypeKey(cls);
|
||||
} else {
|
||||
return new ConstantKey<>(m, cls);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public final class ConstantKey<T> implements InstanceKey {
|
|||
if (value == null)
|
||||
return "[ConstantKey:null]";
|
||||
else
|
||||
return "[ConstantKey:" + value + ":" + value.getClass() + "]";
|
||||
return "[ConstantKey:" + value + ":" + valueClass.getReference() + "]";
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -9,10 +9,12 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
|
|||
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=error
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=error
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=error
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=error
|
||||
|
@ -21,6 +23,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
|||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=error
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=error
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
|
|
|
@ -19,6 +19,7 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
|
|||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
|
|
Loading…
Reference in New Issue