fixes for weird cases with control flow in finally blocks.
code fixes and test that used to crash.
This commit is contained in:
parent
876e52c3f8
commit
ab16d9bc04
|
@ -0,0 +1,20 @@
|
|||
package com.ibm.wala.cast.js.rhino.callgraph.fieldbased.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.cast.ir.translator.TranslatorToCAst.Error;
|
||||
import com.ibm.wala.cast.js.test.FieldBasedCGUtil.BuilderType;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.WalaException;
|
||||
|
||||
public class FieldBasedJQueryTests extends AbstractFieldBasedTest {
|
||||
|
||||
@Test
|
||||
public void test1_8_2() throws IOException, WalaException, Error, CancelException {
|
||||
runTest(new URL("http://code.jquery.com/jquery-1.8.2.js"), new Object[][]{}, BuilderType.OPTIMISTIC_WORKLIST);
|
||||
}
|
||||
|
||||
}
|
|
@ -45,7 +45,7 @@ public class TestSimpleCallGraphShapeRhino extends TestSimpleCallGraphShape {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRewriterDoesNotChangeLablesBug() throws IOException, IllegalArgumentException, CancelException, WalaException {
|
||||
public void testRewriterDoesNotChangeLabelsBug() throws IOException, IllegalArgumentException, CancelException, WalaException {
|
||||
JSCallGraphBuilderUtil.makeScriptCG("tests", "rewrite_does_not_change_lables_bug.js");
|
||||
// all we need is for it to finish building CG successfully.
|
||||
}
|
||||
|
|
|
@ -8,4 +8,21 @@ var x = function() {
|
|||
}
|
||||
};
|
||||
|
||||
x();
|
||||
x();
|
||||
|
||||
var document = { };
|
||||
|
||||
x = function( fn ) {
|
||||
var div = document.createElement("div");
|
||||
|
||||
try {
|
||||
return fn( div );
|
||||
} catch (e) {
|
||||
return false;
|
||||
} finally {
|
||||
// release memory in IE
|
||||
div = null;
|
||||
}
|
||||
};
|
||||
|
||||
x(document);
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.junit.Test;
|
|||
|
||||
import com.ibm.wala.cast.ipa.callgraph.CAstCallGraphUtil;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.JSCFABuilder;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil;
|
||||
import com.ibm.wala.cast.js.ipa.callgraph.PropertyNameContextSelector;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
|
@ -707,7 +708,12 @@ public abstract class TestSimpleCallGraphShape extends TestJSCallGraphShape {
|
|||
|
||||
@Test
|
||||
public void testTryFinallyCrash() throws IllegalArgumentException, IOException, CancelException, WalaException {
|
||||
JSCallGraphBuilderUtil.makeScriptCG("tests", "try-finally-crash.js");
|
||||
JSCFABuilder B = JSCallGraphBuilderUtil.makeScriptCGBuilder("tests", "try-finally-crash.js");
|
||||
CallGraph CG = B.makeCallGraph(B.getOptions());
|
||||
boolean save = CAstCallGraphUtil.AVOID_DUMP;
|
||||
//CAstCallGraphUtil.AVOID_DUMP = false;
|
||||
CAstCallGraphUtil.dumpCG(B.getPointerAnalysis(), CG);
|
||||
CAstCallGraphUtil.AVOID_DUMP = save;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/com.ibm.wala.cast.js.rhino.test/harness-src/com/ibm/wala/cast/js/test/TestSimpleCallGraphShapeRhino.java"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="1"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
|
||||
<mapEntry key="[run]" value="org.eclipse.jdt.junit.launchconfig"/>
|
||||
</mapAttribute>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="/tmp/cg.out"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.ibm.wala.cast.js.test.TestSimpleCallGraphShapeRhino"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.cast.js.rhino.test"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx256M -Dcom.ibm.wala.tracefile=/tmp/jssimplecg.out -ea"/>
|
||||
</launchConfiguration>
|
|
@ -802,12 +802,13 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
}
|
||||
newBlock(false);
|
||||
|
||||
addEdge(currentBlock, getCurrentBlock());
|
||||
if (target != null) {
|
||||
addEdge(currentBlock, getCurrentBlock());
|
||||
addEdge(endBlock, target);
|
||||
|
||||
// `null' target is idiom for branch/throw to exit
|
||||
} else {
|
||||
if (exception) addEdge(currentBlock, getCurrentBlock());
|
||||
addDelayedEdge(endBlock, exitMarker, exception);
|
||||
}
|
||||
|
||||
|
@ -1106,6 +1107,20 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
|
|||
|
||||
currentBlock.setLastIndex(inst);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer(super.toString());
|
||||
for(PreBasicBlock b : blocks) {
|
||||
if (b.firstIndex > 0) {
|
||||
sb.append("\n" + b);
|
||||
for(int i = 0; i < b.instructions.size(); i++) {
|
||||
sb.append("\n" + b.instructions.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue