diff --git a/Krakatau/ssa/blockmaker.py b/Krakatau/ssa/blockmaker.py index 5326b47..5bb9e22 100644 --- a/Krakatau/ssa/blockmaker.py +++ b/Krakatau/ssa/blockmaker.py @@ -10,8 +10,16 @@ from .ssa_types import slots_t, BasicBlock _charToSSAType = {'D':SSA_DOUBLE, 'F':SSA_FLOAT, 'I':SSA_INT, 'J':SSA_LONG, 'B':SSA_INT, 'C':SSA_INT, 'S':SSA_INT} def getCategory(c): return 2 if c in 'JD' else 1 - -def makeDict(**kwargs): return kwargs + +class Dct(object): + def __init__(self, line=None, newstack=None, newlocals=None, jump=None): + self.line = line + self.newstack = newstack + self.jump = jump + self.newlocals = newlocals + +def makeDict(line=None, newstack=None, jump=None, newlocals=None): + return Dct(line=line, newstack=newstack, jump=jump, newlocals=newlocals) ############################################################################## def makeConstVar(parent, type_, val): @@ -435,7 +443,7 @@ def processArrayInfo(newarray_info, iNode, vals): op = iNode.instruction[0] if op == vops.NEWARRAY or op == vops.ANEWARRAY: - line = vals['line'] + line = vals.line lenvar = line.params[1] assert(lenvar.type == SSA_INT) @@ -445,7 +453,7 @@ def processArrayInfo(newarray_info, iNode, vals): line.outException = None elif op == vops.ARRSTORE or op == vops.ARRSTORE_OBJ: - line = vals['line'] + line = vals.line m, a, i, x = line.params if a not in newarray_info: return @@ -490,9 +498,9 @@ def fromInstruction(parent, block, newarray_info, iNode, initMap): processArrayInfo(newarray_info, iNode, vals) - line, jump = map(vals.get, ('line','jump')) - newstack = vals.get('newstack', inslots.stack) - newlocals = vals.get('newlocals', inslots.locals) + line, jump = vals.line, vals.jump + newstack = vals.newstack if vals.newstack is not None else inslots.stack + newlocals = vals.newlocals if vals.newlocals is not None else inslots.locals newmonad = line.outMonad if (line and line.outMonad) else inslots.monad outslot_norm = slots_t(monad=newmonad, locals=newlocals, stack=newstack) @@ -565,4 +573,4 @@ def makeBlocks(parent, iNodes, myclsname): for block in blocks: block.successorStates = collections.OrderedDict(block.successorStates) block.tempvars = [t for t in block.tempvars if t is not None] - return blocks \ No newline at end of file + return blocks diff --git a/benchmark.py b/benchmark.py index 1d4f933..cf0e619 100644 --- a/benchmark.py +++ b/benchmark.py @@ -33,20 +33,25 @@ def makeGraph(m): def decompileClass(path=[], targets=None, outpath=None): e = Environment() + import time for part in path: e.addToPath(part) with e, Timer('warming up'): for i,target in enumerate(targets): - for _ in range(40): + for _ in range(5): c = e.getClass(target) source = javaclass.generateAST(c, makeGraph).print_() with e, Timer('testing'): + l = [] for i,target in enumerate(targets): - for _ in range(200): + for _ in range(15): c = e.getClass(target) + t0 = time.time() source = javaclass.generateAST(c, makeGraph).print_() + l.append(time.time() - t0) + print l if __name__== "__main__": print 'Krakatau Copyright (C) 2012-13 Robert Grosse' @@ -64,4 +69,4 @@ if __name__== "__main__": path.extend(part.split(';')) targets = ['sun/text/normalizer/Utility'] - decompileClass(path, targets, args.out) \ No newline at end of file + decompileClass(path, targets, args.out)