Cache values to get 30% speed up with some files (DNR)
This commit is contained in:
parent
dce16e9f12
commit
96c13fb05e
|
@ -32,6 +32,11 @@ namespace de4dot.blocks.cflow {
|
||||||
List<Value> locals = new List<Value>();
|
List<Value> locals = new List<Value>();
|
||||||
int argBase;
|
int argBase;
|
||||||
|
|
||||||
|
MethodDefinition prev_method;
|
||||||
|
List<Value> cached_args = new List<Value>();
|
||||||
|
List<Value> cached_locals = new List<Value>();
|
||||||
|
int cached_argBase;
|
||||||
|
|
||||||
public InstructionEmulator() {
|
public InstructionEmulator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,18 +53,28 @@ namespace de4dot.blocks.cflow {
|
||||||
this.variableDefinitions = method.Body.Variables;
|
this.variableDefinitions = method.Body.Variables;
|
||||||
valueStack.init();
|
valueStack.init();
|
||||||
|
|
||||||
args.Clear();
|
if (method != prev_method) {
|
||||||
argBase = 0;
|
prev_method = method;
|
||||||
if (method.HasImplicitThis) {
|
|
||||||
argBase = 1;
|
|
||||||
args.Add(new UnknownValue());
|
|
||||||
}
|
|
||||||
for (int i = 0; i < parameterDefinitions.Count; i++)
|
|
||||||
args.Add(getUnknownValue(parameterDefinitions[i].ParameterType));
|
|
||||||
|
|
||||||
|
cached_args.Clear();
|
||||||
|
cached_argBase = 0;
|
||||||
|
if (method.HasImplicitThis) {
|
||||||
|
cached_argBase = 1;
|
||||||
|
cached_args.Add(new UnknownValue());
|
||||||
|
}
|
||||||
|
for (int i = 0; i < parameterDefinitions.Count; i++)
|
||||||
|
cached_args.Add(getUnknownValue(parameterDefinitions[i].ParameterType));
|
||||||
|
|
||||||
|
cached_locals.Clear();
|
||||||
|
for (int i = 0; i < variableDefinitions.Count; i++)
|
||||||
|
cached_locals.Add(getUnknownValue(variableDefinitions[i].VariableType));
|
||||||
|
}
|
||||||
|
|
||||||
|
argBase = cached_argBase;
|
||||||
|
args.Clear();
|
||||||
|
args.AddRange(cached_args);
|
||||||
locals.Clear();
|
locals.Clear();
|
||||||
for (int i = 0; i < variableDefinitions.Count; i++)
|
locals.AddRange(cached_locals);
|
||||||
locals.Add(getUnknownValue(variableDefinitions[i].VariableType));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Value getUnknownValue(TypeReference typeReference) {
|
static Value getUnknownValue(TypeReference typeReference) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user