das-labor / panopticon

A libre cross-platform disassembler.
https://panopticon.re
GNU General Public License v3.0
1.43k stars 78 forks source link

Completely removes graph_algos from core #335

Closed m4b closed 6 years ago

m4b commented 6 years ago

@flanfly Only thing that remains of graph_algos is in abstract_interp

Seems you're working on data-flow esque stuff, so perhaps I'll leave that to you, especially if you add a new impl for neo (it's also apparently only used in QT currently)?

If that's alright, I won't mess with abstract_interp so we don't step on each others toes; if you're working on something else, let me know.

Also I'll rebase this branch off of bincode as though its master, in case this keeps going, so no need to delete (until it gets merged into master, that is) ;)

Anyway:

  1. Totally removes graph_algos from core!
  2. Also removes longstanding pointless imports field from project
  3. re-adds to_dot impls using petgraphs version

Also, hilariously, adding this patch to disassembler (which I assumed was safe and would be a quick allocation-less gain in disassembler) causes the benchmarks to spiral out of control and use all memory on my system :sob:

diff --git a/amd64/src/architecture.rs b/amd64/src/architecture.rs
index 2d056e6..19e7e65 100644
--- a/amd64/src/architecture.rs
+++ b/amd64/src/architecture.rs
@@ -55,14 +55,16 @@ impl Architecture for Amd64 {
     }

     fn decode(reg: &Region, start: u64, cfg: &Self::Configuration) -> Result<Match<Self>> {
+        const MAX: usize = 16;
         let data = reg.iter();
-        let mut buf: Vec<u8> = vec![];
+        let mut buf: [u8; MAX] = [0; MAX];
         let mut i = data.seek(start);
         let p = start;
-
+        let mut len = 0;
         while let Some(Some(b)) = i.next() {
-            buf.push(b);
-            if buf.len() == 15 {
+            buf[len] = b;
+            len += 1;
+            if len == MAX {
                 break;
             }
         }

Anyway, I think I want to work on the disassembler because:

  1. I think there could be some easy perf gains (ostensibly like above, I suspect that's some weird compiler/benchmark bug?)
  2. I don't really understand
m4b commented 6 years ago

:scream: wrong brranch