optimize memory by copy on write

pull/534/head
Nikhil Parasaram 6 years ago
parent 39e2b53b30
commit 98288da43c
  1. 2
      mythril/analysis/modules/dependence_on_predictable_vars.py
  2. 16
      mythril/laser/ethereum/state.py

@ -48,7 +48,7 @@ def execute(statespace):
found = []
for var in vars:
for constraint in call.node.constraints + [call.to]:
for constraint in call.node.constraints[:] + [call.to]:
if var in str(constraint):
found.append(var)

@ -147,6 +147,7 @@ class Constraints(list):
def append(self, constraint):
self.__possibility = None
super(Constraints, self).append(constraint)
self.solver = copy(self.solver)
self.solver.add(constraint)
def pop(self, index=-1):
@ -154,19 +155,18 @@ class Constraints(list):
def __copy__(self):
constraint_list = super(Constraints, self).copy()
solver = self.solver.translate(self.solver.ctx)
return Constraints(constraint_list, solver, self.__possibility)
return Constraints(constraint_list, self.solver, self.__possibility)
def __deepcopy__(self, memodict={}):
constraint_list = super(Constraints, self).copy()
solver = self.solver.translate(self.solver.ctx)
return Constraints(constraint_list, solver)
return Constraints(constraint_list, self.solver, self.__possibility)
def __add__(self, constraints):
"""
Implement constraint concatenation if needed
"""
raise NotImplementedError
constraints_list = super(Constraints, self).__add__(constraints)
new_solver = copy(self.solver)
for constraint in constraints:
new_solver.add(constraint)
return Constraints(constraint_list=constraints_list, solver=new_solver)
def __iadd__(self, other):
"""

Loading…
Cancel
Save