diff options
| author | serpilliere <serpilliere@users.noreply.github.com> | 2015-10-22 10:19:41 +0200 |
|---|---|---|
| committer | serpilliere <serpilliere@users.noreply.github.com> | 2015-10-22 10:19:41 +0200 |
| commit | 477436aa1f6062b0963caa9f12c6ac2aad00a391 (patch) | |
| tree | ccd6cd6578c24c2a3822276b52cdc73d66bb67d6 /miasm2/jitter/jitload.py | |
| parent | 1fe49d61bbb4fa59260fc19110f75fef50277899 (diff) | |
| parent | 24d3e96d8805fc2b8fa19788c018bbe2c71529c1 (diff) | |
| download | miasm-477436aa1f6062b0963caa9f12c6ac2aad00a391.tar.gz miasm-477436aa1f6062b0963caa9f12c6ac2aad00a391.zip | |
Merge pull request #226 from fmonjalet/optimize_jitter
Optimize jitter execution time
Diffstat (limited to 'miasm2/jitter/jitload.py')
| -rw-r--r-- | miasm2/jitter/jitload.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/miasm2/jitter/jitload.py b/miasm2/jitter/jitload.py index 1c88d0b7..112920a1 100644 --- a/miasm2/jitter/jitload.py +++ b/miasm2/jitter/jitload.py @@ -113,6 +113,9 @@ class CallbackHandler(object): return empty_keys + def has_callbacks(self, name): + return name in self.callbacks + def call_callbacks(self, name, *args): """Call callbacks associated to key 'name' with arguments args. While callbacks return True, continue with next callback. @@ -134,13 +137,17 @@ class CallbackHandlerBitflag(CallbackHandler): "Handle a list of callback with conditions on bitflag" + # Overrides CallbackHandler's implem, but do not serve for optimization + def has_callbacks(self, bitflag): + return any(cb_mask & bitflag != 0 for cb_mask in self.callbacks) + def __call__(self, bitflag, *args): """Call each callbacks associated with bit set in bitflag. While callbacks return True, continue with next callback. Iterator on other results""" res = True - for b in self.callbacks.keys(): + for b in self.callbacks: if b & bitflag != 0: # If the flag matched @@ -301,9 +308,10 @@ class jitter: # Check breakpoints old_pc = self.pc - for res in self.breakpoints_handler(self.pc, self): - if res is not True: - yield res + if self.breakpoints_handler.has_callbacks(self.pc): + for res in self.breakpoints_handler(self.pc, self): + if res is not True: + yield res # If a callback changed pc, re call every callback if old_pc != self.pc: |