Fix bug in DFG simplifier

This commit is contained in:
Alexey Andreev 2015-03-13 12:11:53 +04:00
parent cd0dd134cc
commit cc009ff9bd
3 changed files with 16 additions and 15 deletions

View File

@ -62,15 +62,18 @@ public class DataFlowGraphBuilder implements InstructionReader {
} }
IntegerArray startNodes = new IntegerArray(graph.size()); IntegerArray startNodes = new IntegerArray(graph.size());
for (int i = paramCount; i < graph.size(); ++i) { for (int i = paramCount; i < graph.size(); ++i) {
if (importantNodes.contains(i)) {
continue;
}
for (int pred : graph.incomingEdges(i)) {
classes.union(pred, i);
}
if (graph.incomingEdgesCount(i) == 0) { if (graph.incomingEdgesCount(i) == 0) {
startNodes.add(i); startNodes.add(i);
} }
for (int pred : graph.incomingEdges(i)) {
if (importantNodes.contains(pred) && importantNodes.contains(i)) {
continue;
}
int newCls = classes.union(pred, i);
if (importantNodes.contains(pred)) {
importantNodes.add(newCls);
}
}
} }
int[][] sccs = GraphUtils.findStronglyConnectedComponents(graph, startNodes.getAll()); int[][] sccs = GraphUtils.findStronglyConnectedComponents(graph, startNodes.getAll());

View File

@ -54,7 +54,11 @@ class DependencyGraphBuilder {
resultNode = dep.getResult(); resultNode = dep.getResult();
DependencyNode[] origNodes = dep.getVariables(); DependencyNode[] origNodes = dep.getVariables();
int[] nodeMapping = new DataFlowGraphBuilder().buildMapping(program, dep.getParameterCount()); DataFlowGraphBuilder dfgBuilder = new DataFlowGraphBuilder();
for (int i = 0; i < dep.getParameterCount(); ++i) {
dfgBuilder.important(i);
}
int[] nodeMapping = dfgBuilder.buildMapping(program, dep.getParameterCount());
nodes = new DependencyNode[origNodes.length]; nodes = new DependencyNode[origNodes.length];
for (int i = 0; i < nodes.length; ++i) { for (int i = 0; i < nodes.length; ++i) {
nodes[i] = origNodes[nodeMapping[i]]; nodes[i] = origNodes[nodeMapping[i]];

View File

@ -417,20 +417,14 @@ JUnitClient.run = function() {
} }
JUnitClient.makeErrorMessage = function(message, e) { JUnitClient.makeErrorMessage = function(message, e) {
message.status = "exception"; message.status = "exception";
var stack = ""; var stack = e.stack;
while (e instanceof TeaVMAsyncError) {
stack += e.message + "\n" + e.stack + "\n";
e = e.cause;
}
if (e.$javaException && e.$javaException.constructor.$meta) { if (e.$javaException && e.$javaException.constructor.$meta) {
message.exception = e.$javaException.constructor.$meta.name; message.exception = e.$javaException.constructor.$meta.name;
message.stack = e.$javaException.constructor.$meta.name + ": "; message.stack = e.$javaException.constructor.$meta.name + ": ";
var exceptionMessage = extractException(e.$javaException); var exceptionMessage = extractException(e.$javaException);
message.stack += exceptionMessage ? $rt_ustr(exceptionMessage) : ""; message.stack += exceptionMessage ? $rt_ustr(exceptionMessage) : "";
message.stack += e.stack + "\n" + stack;
} else {
message.stack = stack;
} }
message.stack += "\n" + stack;
} }
JUnitClient.reportError = function(error) { JUnitClient.reportError = function(error) {
var handler = window.addEventListener("message", function() { var handler = window.addEventListener("message", function() {