mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Further refactoring of debugger
This commit is contained in:
parent
45c336ebb8
commit
deea4e995a
|
@ -12,7 +12,7 @@ import org.codehaus.jackson.JsonNode;
|
|||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.teavm.chromerdp.data.*;
|
||||
import org.teavm.chromerdp.messages.*;
|
||||
import org.teavm.debugging.*;
|
||||
import org.teavm.debugging.javascript.*;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
package org.teavm.chromerdp;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import org.teavm.debugging.JavaScriptBreakpoint;
|
||||
import org.teavm.debugging.JavaScriptLocation;
|
||||
import org.teavm.debugging.javascript.JavaScriptBreakpoint;
|
||||
import org.teavm.debugging.javascript.JavaScriptLocation;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -17,9 +17,9 @@ package org.teavm.chromerdp;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import org.teavm.debugging.JavaScriptCallFrame;
|
||||
import org.teavm.debugging.JavaScriptLocation;
|
||||
import org.teavm.debugging.JavaScriptVariable;
|
||||
import org.teavm.debugging.javascript.JavaScriptCallFrame;
|
||||
import org.teavm.debugging.javascript.JavaScriptLocation;
|
||||
import org.teavm.debugging.javascript.JavaScriptVariable;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.teavm.chromerdp;
|
||||
|
||||
import org.teavm.debugging.JavaScriptValue;
|
||||
import org.teavm.debugging.JavaScriptVariable;
|
||||
import org.teavm.debugging.javascript.JavaScriptValue;
|
||||
import org.teavm.debugging.javascript.JavaScriptVariable;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -3,8 +3,8 @@ package org.teavm.chromerdp;
|
|||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.teavm.debugging.JavaScriptValue;
|
||||
import org.teavm.debugging.JavaScriptVariable;
|
||||
import org.teavm.debugging.javascript.JavaScriptValue;
|
||||
import org.teavm.debugging.javascript.JavaScriptVariable;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -17,6 +17,8 @@ package org.teavm.debugging;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.teavm.debugging.information.SourceLocation;
|
||||
import org.teavm.debugging.javascript.JavaScriptBreakpoint;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -17,6 +17,8 @@ package org.teavm.debugging;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import org.teavm.debugging.information.SourceLocation;
|
||||
import org.teavm.debugging.javascript.JavaScriptLocation;
|
||||
import org.teavm.model.MethodReference;
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.util.concurrent.BlockingQueue;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import org.teavm.debugging.information.*;
|
||||
import org.teavm.debugging.javascript.*;
|
||||
import org.teavm.model.MethodReference;
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,6 +19,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.teavm.debugging.javascript.JavaScriptVariable;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.teavm.debugging;
|
|||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.teavm.debugging.javascript.JavaScriptValue;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import org.teavm.debugging.javascript.JavaScriptLocation;
|
||||
import org.teavm.debugging.javascript.JavaScriptVariable;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
/**
|
||||
*
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
@ -48,7 +48,7 @@ public class DebugInformation {
|
|||
RecordArray callSiteMapping;
|
||||
RecordArray[] variableMappings;
|
||||
RecordArray[] lineCallSites;
|
||||
CFG[] controlFlowGraphs;
|
||||
RecordArray[] controlFlowGraphs;
|
||||
List<ClassMetadata> classesMetadata;
|
||||
RecordArray methodEntrances;
|
||||
MethodTree methodTree;
|
||||
|
@ -216,28 +216,26 @@ public class DebugInformation {
|
|||
if (fileIndex == null) {
|
||||
return null;
|
||||
}
|
||||
CFG cfg = controlFlowGraphs[fileIndex];
|
||||
RecordArray cfg = controlFlowGraphs[fileIndex];
|
||||
if (cfg == null) {
|
||||
return null;
|
||||
}
|
||||
if (location.getLine() >= cfg.offsets.length - 1) {
|
||||
if (location.getLine() >= cfg.size()) {
|
||||
return null;
|
||||
}
|
||||
int start = cfg.offsets[location.getLine()];
|
||||
int end = cfg.offsets[location.getLine() + 1];
|
||||
if (end - start == 1 && cfg.offsets[start] == -1) {
|
||||
return new SourceLocation[0];
|
||||
} else if (start == end) {
|
||||
int type = cfg.get(location.getLine()).get(0);
|
||||
if (type == 0) {
|
||||
return null;
|
||||
}
|
||||
SourceLocation[] result = new SourceLocation[end - start];
|
||||
for (int i = 0; i < result.length; ++i) {
|
||||
int line = cfg.lines[i + start];
|
||||
if (line >= 0) {
|
||||
result[i] = new SourceLocation(fileNames[cfg.files[i + start]], line);
|
||||
} else {
|
||||
result[i] = null;
|
||||
int[] data = cfg.get(location.getLine()).getArray(0);
|
||||
int length = data.length / 2;
|
||||
int size = length;
|
||||
if (type == 2) {
|
||||
++size;
|
||||
}
|
||||
SourceLocation[] result = new SourceLocation[size];
|
||||
for (int i = 0; i < length; ++i) {
|
||||
result[i] = new SourceLocation(fileNames[data[i * 2]], data[i * 2 + 1]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -598,11 +596,6 @@ public class DebugInformation {
|
|||
int[] methods;
|
||||
}
|
||||
|
||||
static class CFG {
|
||||
int[] lines;
|
||||
int[] files;
|
||||
int[] offsets;
|
||||
}
|
||||
|
||||
class MethodTree {
|
||||
int[] data;
|
|
@ -13,11 +13,10 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import java.util.*;
|
||||
import org.teavm.codegen.LocationProvider;
|
||||
import org.teavm.common.IntegerArray;
|
||||
import org.teavm.common.RecordArray;
|
||||
import org.teavm.common.RecordArrayBuilder;
|
||||
import org.teavm.model.MethodDescriptor;
|
||||
|
@ -41,14 +40,14 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
|
|||
private RecordArrayBuilder lineMapping = new RecordArrayBuilder(3, 0);
|
||||
private RecordArrayBuilder classMapping = new RecordArrayBuilder(3, 0);
|
||||
private RecordArrayBuilder methodMapping = new RecordArrayBuilder(3, 0);
|
||||
private RecordArrayBuilder callSiteMapping = new RecordArrayBuilder(3, 1);
|
||||
private RecordArrayBuilder callSiteMapping = new RecordArrayBuilder(4, 0);
|
||||
private Map<Integer, RecordArrayBuilder> variableMappings = new HashMap<>();
|
||||
private MethodDescriptor currentMethod;
|
||||
private String currentClass;
|
||||
private String currentFileName;
|
||||
private int currentClassMetadata = -1;
|
||||
private List<ClassMetadata> classesMetadata = new ArrayList<>();
|
||||
private List<CFG> cfgs = new ArrayList<>();
|
||||
private List<RecordArrayBuilder> cfgs = new ArrayList<>();
|
||||
private int currentLine;
|
||||
|
||||
public LocationProvider getLocationProvider() {
|
||||
|
@ -149,20 +148,17 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
|
|||
@Override
|
||||
public void setVirtualMethod(MethodReference method) {
|
||||
record.set(2, DebuggerCallSite.VIRTUAL);
|
||||
RecordArrayBuilder.RecordSubArray array = record.getArray(0);
|
||||
array.clear();
|
||||
array.add(getExactMethodIndex(method));
|
||||
record.set(3, getExactMethodIndex(method));
|
||||
}
|
||||
@Override
|
||||
public void setStaticMethod(MethodReference method) {
|
||||
record.set(2, DebuggerCallSite.STATIC);
|
||||
RecordArrayBuilder.RecordSubArray array = record.getArray(0);
|
||||
array.clear();
|
||||
array.add(getExactMethodIndex(method));
|
||||
record.set(3, getExactMethodIndex(method));
|
||||
}
|
||||
@Override
|
||||
public void clean() {
|
||||
record.set(2, DebuggerCallSite.NONE);
|
||||
record.set(3, 0);
|
||||
}
|
||||
private int getExactMethodIndex(MethodReference method) {
|
||||
int methodIndex = methods.index(method.getDescriptor().toString());
|
||||
|
@ -202,19 +198,21 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
|
|||
@Override
|
||||
public void addSuccessors(SourceLocation location, SourceLocation[] successors) {
|
||||
int fileIndex = files.index(location.getFileName());
|
||||
if (cfgs.size() <= fileIndex) {
|
||||
cfgs.addAll(Collections.<CFG>nCopies(fileIndex - cfgs.size() + 1, null));
|
||||
while (cfgs.size() <= fileIndex) {
|
||||
cfgs.add(new RecordArrayBuilder(1, 1));
|
||||
}
|
||||
CFG cfg = cfgs.get(fileIndex);
|
||||
if (cfg == null) {
|
||||
cfg = new CFG();
|
||||
cfgs.set(fileIndex, cfg);
|
||||
RecordArrayBuilder cfg = cfgs.get(fileIndex);
|
||||
RecordArrayBuilder.Record record = cfg.get(location.getLine());
|
||||
if (record.get(0) == 0) {
|
||||
record.set(0, 1);
|
||||
}
|
||||
RecordArrayBuilder.RecordSubArray array = record.getArray(0);
|
||||
for (SourceLocation succ : successors) {
|
||||
if (succ == null) {
|
||||
cfg.add(location.getLine(), -1, fileIndex);
|
||||
record.set(0, 2);
|
||||
} else {
|
||||
cfg.add(location.getLine(), succ.getLine(), files.index(succ.getFileName()));
|
||||
array.add(files.index(succ.getFileName()));
|
||||
array.add(succ.getLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -297,7 +295,7 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
|
|||
}
|
||||
debugInformation.classesMetadata = builtMetadata;
|
||||
|
||||
DebugInformation.CFG[] cfgs = new DebugInformation.CFG[files.list.size()];
|
||||
RecordArray[] cfgs = new RecordArray[files.list.size()];
|
||||
for (int i = 0; i < this.cfgs.size(); ++i) {
|
||||
if (this.cfgs.get(i) != null) {
|
||||
cfgs[i] = this.cfgs.get(i).build();
|
||||
|
@ -339,59 +337,4 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
|
|||
int parentIndex;
|
||||
Map<Integer, Integer> fieldMap = new HashMap<>();
|
||||
}
|
||||
|
||||
static class CFG {
|
||||
IntegerArray start = new IntegerArray(1);
|
||||
IntegerArray next = new IntegerArray(1);
|
||||
IntegerArray lines = new IntegerArray(1);
|
||||
IntegerArray files = new IntegerArray(1);
|
||||
|
||||
public void add(int line, int succLine, int succFile) {
|
||||
while (start.size() <= line) {
|
||||
start.add(-1);
|
||||
}
|
||||
int ptr = start.get(line);
|
||||
start.set(line, lines.size());
|
||||
next.add(ptr);
|
||||
lines.add(succLine);
|
||||
files.add(succFile);
|
||||
}
|
||||
|
||||
public DebugInformation.CFG build() {
|
||||
int[] offsets = new int[start.size() + 1];
|
||||
IntegerArray linesData = new IntegerArray(1);
|
||||
IntegerArray filesData = new IntegerArray(1);
|
||||
for (int i = 0; i < start.size(); ++i) {
|
||||
IntegerArray linesChunk = new IntegerArray(1);
|
||||
IntegerArray filesChunk = new IntegerArray(1);
|
||||
int ptr = start.get(i);
|
||||
while (ptr >= 0) {
|
||||
linesChunk.add(lines.get(ptr));
|
||||
filesChunk.add(files.get(ptr));
|
||||
ptr = next.get(ptr);
|
||||
}
|
||||
long[] pairs = new long[linesChunk.size()];
|
||||
for (int j = 0; j < pairs.length; ++j) {
|
||||
pairs[j] = (((long)filesChunk.get(j)) << 32) | linesChunk.get(j);
|
||||
}
|
||||
Arrays.sort(pairs);
|
||||
int distinctSize = 0;
|
||||
for (int j = 0; j < pairs.length; ++j) {
|
||||
long pair = pairs[j];
|
||||
if (distinctSize == 0 || pair != pairs[distinctSize - 1]) {
|
||||
pairs[distinctSize++] = pair;
|
||||
filesData.add((int)(pair >>> 32));
|
||||
linesData.add((int)pair);
|
||||
}
|
||||
}
|
||||
offsets[i + 1] = linesData.size();
|
||||
}
|
||||
DebugInformation.CFG cfg = new DebugInformation.CFG();
|
||||
cfg.offsets = offsets;
|
||||
cfg.lines = linesData.getAll();
|
||||
cfg.files = filesData.getAll();
|
||||
return cfg;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import org.teavm.codegen.LocationProvider;
|
||||
import org.teavm.model.MethodDescriptor;
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
/**
|
||||
*
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
|
@ -21,6 +21,7 @@ import java.io.InputStream;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.teavm.common.IntegerArray;
|
||||
import org.teavm.common.RecordArray;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -54,8 +55,8 @@ class DebugInformationReader {
|
|||
return debugInfo;
|
||||
}
|
||||
|
||||
private DebugInformation.MultiMapping[] readVariableMappings(int count) throws IOException {
|
||||
DebugInformation.MultiMapping[] mappings = new DebugInformation.MultiMapping[count];
|
||||
private RecordArray[] readVariableMappings(int count) throws IOException {
|
||||
RecordArray[] mappings = new RecordArray[count];
|
||||
int varCount = readUnsignedNumber();
|
||||
int lastVar = 0;
|
||||
while (varCount-- > 0) {
|
||||
|
@ -136,7 +137,7 @@ class DebugInformationReader {
|
|||
return !negative ? number : -number;
|
||||
}
|
||||
|
||||
private DebugInformation.MultiMapping readMultiMapping() throws IOException {
|
||||
private RecordArray readMultiMapping() throws IOException {
|
||||
int[] lines = readRle();
|
||||
int last = 0;
|
||||
for (int i = 0; i < lines.length; ++i) {
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
@ -21,8 +21,9 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.teavm.common.IntegerArray;
|
||||
import org.teavm.common.RecordArray;
|
||||
import org.teavm.debugging.DebugInformation.ClassMetadata;
|
||||
import org.teavm.debugging.information.DebugInformation.ClassMetadata;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -48,7 +49,7 @@ class DebugInformationWriter {
|
|||
writeMapping(debugInfo.lineMapping);
|
||||
writeMapping(debugInfo.classMapping);
|
||||
writeMapping(debugInfo.methodMapping);
|
||||
writeMapping(debugInfo.callSiteMapping);
|
||||
writeCallSiteMapping(debugInfo.callSiteMapping);
|
||||
writeVariableMappings(debugInfo);
|
||||
writeClassMetadata(debugInfo.classesMetadata);
|
||||
writeCFGs(debugInfo);
|
||||
|
@ -115,27 +116,6 @@ class DebugInformationWriter {
|
|||
}
|
||||
}
|
||||
|
||||
private void writeLinesAndColumns(RecordArray mapping) throws IOException {
|
||||
int[] lines = mapping.cut(0);
|
||||
int last = 0;
|
||||
for (int i = 0; i < lines.length; ++i) {
|
||||
int next = lines[i];
|
||||
lines[i] -= last;
|
||||
last = next;
|
||||
}
|
||||
writeRle(lines);
|
||||
resetRelativeNumber();
|
||||
int[] columns = mapping.cut(1);
|
||||
int lastLine = -1;
|
||||
for (int i = 0; i < columns.length; ++i) {
|
||||
if (lastLine != mapping.get(i).get(0)) {
|
||||
resetRelativeNumber();
|
||||
lastLine = mapping.get(i).get(0);
|
||||
}
|
||||
writeRelativeNumber(columns[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeMultiMapping(RecordArray mapping) throws IOException {
|
||||
writeLinesAndColumns(mapping);
|
||||
for (int i = 0; i < mapping.size(); ++i) {
|
||||
|
@ -151,47 +131,108 @@ class DebugInformationWriter {
|
|||
|
||||
private void writeMapping(RecordArray mapping) throws IOException {
|
||||
writeLinesAndColumns(mapping);
|
||||
resetRelativeNumber();
|
||||
int[] values = mapping.cut(2);
|
||||
for (int i = 0; i < values.length; ++i) {
|
||||
writeRelativeNumber(values[i]);
|
||||
writeRle(extractValues(mapping));
|
||||
}
|
||||
|
||||
private void writeCallSiteMapping(RecordArray mapping) throws IOException {
|
||||
writeLinesAndColumns(mapping);
|
||||
writeRle(extractValues(mapping));
|
||||
writeRle(extractCallSites(mapping));
|
||||
}
|
||||
|
||||
private void writeLinesAndColumns(RecordArray mapping) throws IOException {
|
||||
writeUnsignedNumber(mapping.size());
|
||||
writeRle(extractLines(mapping));
|
||||
writeRle(extractColumns(mapping));
|
||||
}
|
||||
|
||||
private int[] extractLines(RecordArray mapping) {
|
||||
int[] lines = mapping.cut(0);
|
||||
int last = 0;
|
||||
for (int i = 0; i < lines.length; ++i) {
|
||||
int next = lines[i];
|
||||
lines[i] -= last;
|
||||
last = next;
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
private int[] extractColumns(RecordArray mapping) {
|
||||
int[] columns = mapping.cut(1);
|
||||
int lastLine = -1;
|
||||
int lastColumn = 0;
|
||||
for (int i = 0; i < columns.length; ++i) {
|
||||
if (lastLine != mapping.get(i).get(0)) {
|
||||
lastColumn = 0;
|
||||
lastLine = mapping.get(i).get(0);
|
||||
}
|
||||
int column = columns[i];
|
||||
columns[i] = column - lastColumn;
|
||||
lastColumn = column;
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
|
||||
private int[] extractValues(RecordArray mapping) {
|
||||
int[] values = mapping.cut(2);
|
||||
int last = 0;
|
||||
for (int i = 0; i < values.length; ++i) {
|
||||
int value = values[i];
|
||||
if (value == -1) {
|
||||
values[i] = 0;
|
||||
} else {
|
||||
values[i] = 1 + convertToSigned(value - last);
|
||||
last = value;
|
||||
}
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
private int[] extractCallSites(RecordArray mapping) {
|
||||
int[] callSites = mapping.cut(3);
|
||||
int last = 0;
|
||||
int j = 0;
|
||||
for (int i = 0; i < callSites.length; ++i) {
|
||||
int type = mapping.get(i).get(2);
|
||||
if (type != 0) {
|
||||
int callSite = callSites[i];
|
||||
callSites[j++] = 1 + convertToSigned(callSite - last);
|
||||
last = callSite;
|
||||
}
|
||||
}
|
||||
return Arrays.copyOf(callSites, j);
|
||||
}
|
||||
|
||||
private void writeCFGs(DebugInformation debugInfo) throws IOException {
|
||||
for (int i = 0; i < debugInfo.controlFlowGraphs.length; ++i) {
|
||||
writeCFG(debugInfo.controlFlowGraphs[i], i);
|
||||
writeCFG(debugInfo.controlFlowGraphs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeCFG(DebugInformation.CFG mapping, int fileIndex) throws IOException {
|
||||
writeUnsignedNumber(mapping.lines.length);
|
||||
int lastLine = -1;
|
||||
for (int i = 0; i < mapping.offsets.length - 1; ++i) {
|
||||
int start = mapping.offsets[i];
|
||||
int sz = mapping.offsets[i + 1] - start;
|
||||
if (sz == 0) {
|
||||
private void writeCFG(RecordArray mapping) throws IOException {
|
||||
writeUnsignedNumber(mapping.size());
|
||||
writeRle(mapping.cut(0));
|
||||
IntegerArray files = new IntegerArray(1);
|
||||
IntegerArray lines = new IntegerArray(1);
|
||||
int lastFile = 0;
|
||||
int lastLine = 0;
|
||||
for (int i = 0; i < mapping.size(); ++i) {
|
||||
int type = mapping.get(i).get(0);
|
||||
if (type == 0) {
|
||||
continue;
|
||||
}
|
||||
writeUnsignedNumber(i - lastLine);
|
||||
if (sz == 1 && mapping.lines[start] == -1) {
|
||||
writeUnsignedNumber(0);
|
||||
} else if (sz == 1 && mapping.lines[start] == i + 1 && mapping.files[start] == fileIndex) {
|
||||
writeUnsignedNumber(1);
|
||||
} else {
|
||||
writeUnsignedNumber(1 + sz);
|
||||
int[] lines = Arrays.copyOfRange(mapping.lines, start, start + sz);
|
||||
int[] files = Arrays.copyOfRange(mapping.files, start, start + sz);
|
||||
int last = i;
|
||||
for (int j = 0; j < sz; ++j) {
|
||||
int succ = lines[j];
|
||||
writeNumber(succ - last);
|
||||
writeNumber(files[j] - fileIndex);
|
||||
last = succ;
|
||||
int[] data = mapping.get(i).getArray(0);
|
||||
for (int j = 0; j < data.length; j += 2) {
|
||||
int file = data[j];
|
||||
int line = data[j + 1];
|
||||
files.add(file - lastFile);
|
||||
lines.add(line - lastLine);
|
||||
lastFile = file;
|
||||
lastLine = line;
|
||||
}
|
||||
}
|
||||
lastLine = i;
|
||||
}
|
||||
writeRle(files.getAll());
|
||||
writeRle(lines.getAll());
|
||||
}
|
||||
|
||||
private void writeNumber(int number) throws IOException {
|
||||
|
@ -214,20 +255,26 @@ class DebugInformationWriter {
|
|||
}
|
||||
|
||||
private void writeRle(int[] array) throws IOException {
|
||||
writeUnsignedNumber(array.length);
|
||||
int last = 0;
|
||||
for (int i = 0; i < array.length;) {
|
||||
int e = array[i];
|
||||
int count = 1;
|
||||
int current = i;
|
||||
++i;
|
||||
while (i < array.length && array[i] == e) {
|
||||
++count;
|
||||
++i;
|
||||
}
|
||||
if (count > 1) {
|
||||
if (current > last) {
|
||||
writeUnsignedNumber(convertToSigned(current - last) | 0);
|
||||
while (last < current) {
|
||||
writeUnsignedNumber(array[last++]);
|
||||
}
|
||||
}
|
||||
writeUnsignedNumber((convertToSigned(e) << 1) | 1);
|
||||
writeUnsignedNumber(count);
|
||||
} else {
|
||||
writeUnsignedNumber(convertToSigned(e) << 1);
|
||||
last = i;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
/**
|
||||
*
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
/**
|
||||
*
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import org.teavm.model.MethodReference;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import org.teavm.model.MethodReference;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import org.teavm.model.MethodReference;
|
||||
|
|
@ -13,13 +13,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import org.teavm.codegen.LocationProvider;
|
||||
import org.teavm.model.MethodDescriptor;
|
||||
import org.teavm.model.MethodReference;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import org.teavm.common.RecordArray;
|
||||
import org.teavm.model.MethodDescriptor;
|
|
@ -13,7 +13,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
|
||||
/**
|
||||
*
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
/**
|
||||
*
|
|
@ -13,7 +13,8 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
|
||||
/**
|
||||
*
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import org.teavm.model.MethodDescriptor;
|
||||
|
|
@ -13,8 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
/**
|
||||
*
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import org.teavm.common.RecordArray;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.information;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.javascript;
|
||||
|
||||
/**
|
||||
*
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.javascript;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.javascript;
|
||||
|
||||
/**
|
||||
*
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.javascript;
|
||||
|
||||
/**
|
||||
*
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.javascript;
|
||||
|
||||
import java.util.Objects;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.javascript;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.teavm.debugging;
|
||||
package org.teavm.debugging.javascript;
|
||||
|
||||
/**
|
||||
*
|
|
@ -23,9 +23,9 @@ import org.teavm.codegen.NamingException;
|
|||
import org.teavm.codegen.NamingStrategy;
|
||||
import org.teavm.codegen.SourceWriter;
|
||||
import org.teavm.common.ServiceRepository;
|
||||
import org.teavm.debugging.DebugInformationEmitter;
|
||||
import org.teavm.debugging.DeferredCallSite;
|
||||
import org.teavm.debugging.DummyDebugInformationEmitter;
|
||||
import org.teavm.debugging.information.DebugInformationEmitter;
|
||||
import org.teavm.debugging.information.DeferredCallSite;
|
||||
import org.teavm.debugging.information.DummyDebugInformationEmitter;
|
||||
import org.teavm.javascript.ast.*;
|
||||
import org.teavm.javascript.ni.GeneratorContext;
|
||||
import org.teavm.javascript.ni.InjectedBy;
|
||||
|
|
|
@ -21,8 +21,8 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.teavm.common.ThreadPoolFiniteExecutor;
|
||||
import org.teavm.debugging.DebugInformation;
|
||||
import org.teavm.debugging.DebugInformationBuilder;
|
||||
import org.teavm.debugging.information.DebugInformation;
|
||||
import org.teavm.debugging.information.DebugInformationBuilder;
|
||||
import org.teavm.javascript.RenderingContext;
|
||||
import org.teavm.model.ClassHolderTransformer;
|
||||
import org.teavm.model.MethodDescriptor;
|
||||
|
|
|
@ -20,8 +20,8 @@ import java.util.*;
|
|||
import org.teavm.codegen.*;
|
||||
import org.teavm.common.FiniteExecutor;
|
||||
import org.teavm.common.ServiceRepository;
|
||||
import org.teavm.debugging.DebugInformationEmitter;
|
||||
import org.teavm.debugging.SourceLocation;
|
||||
import org.teavm.debugging.information.DebugInformationEmitter;
|
||||
import org.teavm.debugging.information.SourceLocation;
|
||||
import org.teavm.dependency.*;
|
||||
import org.teavm.javascript.Decompiler;
|
||||
import org.teavm.javascript.Renderer;
|
||||
|
|
Loading…
Reference in New Issue
Block a user