mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-24 12:35:31 +00:00
Dead code removal
This commit is contained in:
parent
01001ed92e
commit
b96330920c
2 changed files with 26 additions and 123 deletions
|
|
@ -517,18 +517,12 @@ namespace Indy.IL2CPU {
|
||||||
mDebugMode != DebugModeEnum.None,
|
mDebugMode != DebugModeEnum.None,
|
||||||
mMethods[xCurrentMethod].Info);
|
mMethods[xCurrentMethod].Info);
|
||||||
}
|
}
|
||||||
bool xIsCustomImplementation = false;
|
|
||||||
MethodBase xCustomImplementation = GetCustomMethodImplementation(xMethodName);
|
MethodBase xCustomImplementation = GetCustomMethodImplementation(xMethodName);
|
||||||
if (xCustomImplementation != null) {
|
if (xCustomImplementation != null) {
|
||||||
xIsCustomImplementation = true;
|
|
||||||
QueueMethod(xCustomImplementation);
|
QueueMethod(xCustomImplementation);
|
||||||
using (mMethodsLocker.AcquireReaderLock()) {
|
using (mMethodsLocker.AcquireReaderLock()) {
|
||||||
mMethods[xCurrentMethod].Implementation = xCustomImplementation;
|
mMethods[xCurrentMethod].Implementation = xCustomImplementation;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// what to do if a method doesn't have a body?
|
|
||||||
if (xIsCustomImplementation) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Type xOpType = mMap.GetOpForCustomMethodImplementation(xMethodName);
|
Type xOpType = mMap.GetOpForCustomMethodImplementation(xMethodName);
|
||||||
|
|
@ -540,10 +534,8 @@ namespace Indy.IL2CPU {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mMap.HasCustomAssembleImplementation(xMethodInfo,
|
if (mMap.HasCustomAssembleImplementation(xMethodInfo, false)) {
|
||||||
false)) {
|
mMap.ScanCustomAssembleImplementation(xMethodInfo, false);
|
||||||
mMap.ScanCustomAssembleImplementation(xMethodInfo,
|
|
||||||
false);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -555,53 +547,17 @@ namespace Indy.IL2CPU {
|
||||||
mAssembler.StackContents.Clear();
|
mAssembler.StackContents.Clear();
|
||||||
ILReader xReader = new ILReader(xCurrentMethod);
|
ILReader xReader = new ILReader(xCurrentMethod);
|
||||||
var xInstructionInfos = new List<DebugSymbolsAssemblyTypeMethodInstruction>();
|
var xInstructionInfos = new List<DebugSymbolsAssemblyTypeMethodInstruction>();
|
||||||
//int xPreviousOffset = -1;
|
|
||||||
int[] xCodeOffsets = null;
|
|
||||||
ISymbolDocument[] xCodeDocuments = null;
|
|
||||||
int[] xCodeLines = null;
|
|
||||||
int[] xCodeColumns = null;
|
|
||||||
int[] xCodeEndLines = null;
|
|
||||||
int[] xCodeEndColumns = null;
|
|
||||||
//int xCurrentOffset = 0;
|
|
||||||
bool xHasSymbols = false;
|
|
||||||
if (mDebugMode == DebugModeEnum.Source) {
|
|
||||||
var xSymbolReader = GetSymbolReaderForAssembly(xCurrentMethod.DeclaringType.Assembly);
|
|
||||||
if (xSymbolReader != null) {
|
|
||||||
var xSmbMethod = xSymbolReader.GetMethod(new SymbolToken(xCurrentMethod.MetadataToken));
|
|
||||||
if (xSmbMethod != null) {
|
|
||||||
xCodeOffsets = new int[xSmbMethod.SequencePointCount];
|
|
||||||
xCodeDocuments = new ISymbolDocument[xSmbMethod.SequencePointCount];
|
|
||||||
xCodeLines = new int[xSmbMethod.SequencePointCount];
|
|
||||||
xCodeColumns = new int[xSmbMethod.SequencePointCount];
|
|
||||||
xCodeEndLines = new int[xSmbMethod.SequencePointCount];
|
|
||||||
xCodeEndColumns = new int[xSmbMethod.SequencePointCount];
|
|
||||||
xSmbMethod.GetSequencePoints(xCodeOffsets,
|
|
||||||
xCodeDocuments,
|
|
||||||
xCodeLines,
|
|
||||||
xCodeColumns,
|
|
||||||
xCodeEndLines,
|
|
||||||
xCodeEndColumns);
|
|
||||||
xHasSymbols = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//int xILIndex = -1;
|
|
||||||
while (xReader.Read()) {
|
while (xReader.Read()) {
|
||||||
SortedList<string, object> xInfo = null;
|
SortedList<string, object> xInfo = null;
|
||||||
using (mMethodsLocker.AcquireReaderLock()) {
|
using (mMethodsLocker.AcquireReaderLock()) {
|
||||||
xInfo = mMethods[xCurrentMethod].Info;
|
xInfo = mMethods[xCurrentMethod].Info;
|
||||||
}
|
}
|
||||||
mMap.ScanILCode(xReader,
|
mMap.ScanILCode(xReader, xMethodInfo, xInfo);
|
||||||
xMethodInfo,
|
|
||||||
xInfo);
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
OnDebugLog(LogSeverityEnum.Error,
|
OnDebugLog(LogSeverityEnum.Error, xCurrentMethod.GetFullName());
|
||||||
xCurrentMethod.GetFullName());
|
OnDebugLog(LogSeverityEnum.Warning, e.ToString());
|
||||||
OnDebugLog(LogSeverityEnum.Warning,
|
|
||||||
e.ToString());
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
//OnProgressChanged();
|
//OnProgressChanged();
|
||||||
|
|
@ -615,9 +571,8 @@ namespace Indy.IL2CPU {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}finally {
|
} finally {
|
||||||
mThreadEvents[xThreadIndex].Set();
|
mThreadEvents[xThreadIndex].Set();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1375,11 +1330,9 @@ while(true) {
|
||||||
xMethodInfo);
|
xMethodInfo);
|
||||||
xOp.Assembler = mAssembler;
|
xOp.Assembler = mAssembler;
|
||||||
#if VERBOSE_DEBUG
|
#if VERBOSE_DEBUG
|
||||||
string comment = "";
|
string comment = "(No Type Info available)";
|
||||||
if (xMethodInfo.TypeInfo == null) {
|
if (xMethodInfo.TypeInfo != null) {
|
||||||
comment = "(No Type Info available)";
|
comment = "Type Info:\r\n \r\n" + xMethodInfo.TypeInfo;
|
||||||
} else {
|
|
||||||
comment = "Type Info:\r\n \r\n" + xMethodInfo.TypeInfo.ToString();
|
|
||||||
}
|
}
|
||||||
foreach (string s in comment.Trim().Split(new string[] {"\r\n"},
|
foreach (string s in comment.Trim().Split(new string[] {"\r\n"},
|
||||||
StringSplitOptions.RemoveEmptyEntries)) {
|
StringSplitOptions.RemoveEmptyEntries)) {
|
||||||
|
|
@ -1392,11 +1345,8 @@ while(true) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
xOp.Assemble();
|
xOp.Assemble();
|
||||||
bool xIsCustomImplementation = false;
|
|
||||||
MethodBase xCustomImplementation = GetCustomMethodImplementation(xMethodName);
|
MethodBase xCustomImplementation = GetCustomMethodImplementation(xMethodName);
|
||||||
if (xCustomImplementation != null) {
|
bool xIsCustomImplementation = (xCustomImplementation != null);
|
||||||
xIsCustomImplementation = true;
|
|
||||||
}
|
|
||||||
// what to do if a method doesn't have a body?
|
// what to do if a method doesn't have a body?
|
||||||
bool xContentProduced = false;
|
bool xContentProduced = false;
|
||||||
if (xIsCustomImplementation) {
|
if (xIsCustomImplementation) {
|
||||||
|
|
@ -1449,35 +1399,6 @@ while(true) {
|
||||||
ILReader xReader = new ILReader(xCurrentMethod);
|
ILReader xReader = new ILReader(xCurrentMethod);
|
||||||
var xInstructionInfos = new List<DebugSymbolsAssemblyTypeMethodInstruction>();
|
var xInstructionInfos = new List<DebugSymbolsAssemblyTypeMethodInstruction>();
|
||||||
int xPreviousOffset = -1;
|
int xPreviousOffset = -1;
|
||||||
int[] xCodeOffsets = null;
|
|
||||||
ISymbolDocument[] xCodeDocuments = null;
|
|
||||||
int[] xCodeLines = null;
|
|
||||||
int[] xCodeColumns = null;
|
|
||||||
int[] xCodeEndLines = null;
|
|
||||||
int[] xCodeEndColumns = null;
|
|
||||||
int xCurrentOffset = 0;
|
|
||||||
bool xHasSymbols = false;
|
|
||||||
if (mDebugMode == DebugModeEnum.Source) {
|
|
||||||
var xSymbolReader = GetSymbolReaderForAssembly(xCurrentMethod.DeclaringType.Assembly);
|
|
||||||
if (xSymbolReader != null) {
|
|
||||||
var xSmbMethod = xSymbolReader.GetMethod(new SymbolToken(xCurrentMethod.MetadataToken));
|
|
||||||
if (xSmbMethod != null) {
|
|
||||||
xCodeOffsets = new int[xSmbMethod.SequencePointCount];
|
|
||||||
xCodeDocuments = new ISymbolDocument[xSmbMethod.SequencePointCount];
|
|
||||||
xCodeLines = new int[xSmbMethod.SequencePointCount];
|
|
||||||
xCodeColumns = new int[xSmbMethod.SequencePointCount];
|
|
||||||
xCodeEndLines = new int[xSmbMethod.SequencePointCount];
|
|
||||||
xCodeEndColumns = new int[xSmbMethod.SequencePointCount];
|
|
||||||
xSmbMethod.GetSequencePoints(xCodeOffsets,
|
|
||||||
xCodeDocuments,
|
|
||||||
xCodeLines,
|
|
||||||
xCodeColumns,
|
|
||||||
xCodeEndLines,
|
|
||||||
xCodeEndColumns);
|
|
||||||
xHasSymbols = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int xILIndex = -1;
|
int xILIndex = -1;
|
||||||
while (xReader.Read()) {
|
while (xReader.Read()) {
|
||||||
xILIndex++;
|
xILIndex++;
|
||||||
|
|
@ -1567,32 +1488,25 @@ while(true) {
|
||||||
// For IL, we emit for every one
|
// For IL, we emit for every one
|
||||||
xEmitTracer = true;
|
xEmitTracer = true;
|
||||||
} else if (mDebugMode == DebugModeEnum.Source) {
|
} else if (mDebugMode == DebugModeEnum.Source) {
|
||||||
if (xPreviousOffset == -1) {
|
// We should detect each line, but it appears
|
||||||
xEmitTracer = true;
|
// some recent chagnes already cause this
|
||||||
} else if (xHasSymbols) {
|
// method only to be called already on chagnes.
|
||||||
xEmitTracer =
|
// So if so, IL above is wrong
|
||||||
(xCodeDocuments[xPreviousOffset] != xCodeDocuments[xCurrentOffset]
|
xEmitTracer = true;
|
||||||
|| xCodeLines[xPreviousOffset] != xCodeLines[xCurrentOffset]
|
|
||||||
|| xCodeColumns[xPreviousOffset] != xCodeColumns[xCurrentOffset]
|
|
||||||
|| xCodeEndLines[xPreviousOffset] != xCodeEndLines[xCurrentOffset]
|
|
||||||
|| xCodeEndColumns[xPreviousOffset] != xCodeEndColumns[xCurrentOffset]);
|
|
||||||
// The above code doesnt work correctly and produces horrible results
|
|
||||||
// For now we enable all, and it works pretty well
|
|
||||||
xEmitTracer = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (xEmitTracer) {
|
if (xEmitTracer) {
|
||||||
mMap.EmitOpDebugHeader(mAssembler, 0, xLabel);
|
mMap.EmitOpDebugHeader(mAssembler, 0, xLabel);
|
||||||
using (mDebugSymbolsLocker.AcquireWriterLock()) {
|
using (mDebugSymbolsLocker.AcquireWriterLock()) {
|
||||||
mDebugSymbols.Add(new DebugSymbol() {
|
mDebugSymbols.Add(new DebugSymbol() {
|
||||||
AssemblyFileName = xCurrentMethod.DeclaringType.Assembly.Location,
|
AssemblyFileName = xCurrentMethod.DeclaringType.Assembly.Location,
|
||||||
InstructionOffset = xCurrentOffset,
|
InstructionOffset = 0,
|
||||||
LabelName = xLabel,
|
LabelName = xLabel,
|
||||||
MethodMetaDataToken = xCurrentMethod.MetadataToken
|
MethodMetaDataToken = xCurrentMethod.MetadataToken
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
xPreviousOffset = xCurrentOffset;
|
}
|
||||||
} using (mSymbolsLocker.AcquireWriterLock()) {
|
|
||||||
|
using (mSymbolsLocker.AcquireWriterLock()) {
|
||||||
if (mSymbols != null) {
|
if (mSymbols != null) {
|
||||||
var xMLSymbol = new MLDebugSymbol();
|
var xMLSymbol = new MLDebugSymbol();
|
||||||
xMLSymbol.LabelName = xLabel;
|
xMLSymbol.LabelName = xLabel;
|
||||||
|
|
@ -2534,18 +2448,7 @@ while(true) {
|
||||||
|
|
||||||
private static bool mEmitDependencyGraph = false;
|
private static bool mEmitDependencyGraph = false;
|
||||||
|
|
||||||
public static void EmitDependencyGraphLine(bool aIsContainer,
|
public static void EmitDependencyGraphLine(bool aIsContainer, string aMessage) {
|
||||||
string aMessage) {
|
|
||||||
if (!mEmitDependencyGraph) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
if (!aIsContainer) {
|
|
||||||
aMessage = "\t" + aMessage;
|
|
||||||
}
|
|
||||||
aMessage += "\r\n";
|
|
||||||
File.AppendAllText(@"d:\dependencygraph.txt",
|
|
||||||
aMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Engine() {
|
static Engine() {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ using System.Diagnostics;
|
||||||
namespace Indy.IL2CPU {
|
namespace Indy.IL2CPU {
|
||||||
[DebuggerStepThrough]
|
[DebuggerStepThrough]
|
||||||
public static class GCImplementation {
|
public static class GCImplementation {
|
||||||
private static int mLock = 0;
|
private static int mLock;
|
||||||
private static void AcquireLock() {
|
private static void AcquireLock() {
|
||||||
// do {
|
// do {
|
||||||
// } while (Interlocked.CompareExchange(ref mLock, 1, 0) != 0);
|
// } while (Interlocked.CompareExchange(ref mLock, 1, 0) != 0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue