evoasm / evoasm.rb

An AIMGP (Automatic Induction of Machine code by Genetic Programming) engine
GNU Affero General Public License v3.0
92 stars 13 forks source link

nice tool! #1

Closed aquynh closed 8 years ago

aquynh commented 8 years ago

this looks amazing! sounds like program synthesis to me.

linked to your tool just now from our website: http://www.capstone-engine.org/showcase.html

keep it up, cheers.

furunkel commented 8 years ago

Thanks!

In case you are interested, I have just finished the Getting Started wiki page.

aquynh commented 8 years ago

i havent looked at the source yet. can you give a quick explanation how this was done? do you need to translate machine code to IR?

furunkel commented 8 years ago

No. It contains a x64 runtime assembler and a "sandbox" JIT. The assembly is generated and executed on the fly. Then, fitness is determined by comparing written registers to the expected output.

aquynh commented 8 years ago

How do you generate assembly: randomly, or with any strategy? What if you have to combine more than 1 instruction to get the desired result?

furunkel commented 8 years ago

Initially, the population is seeded randomly, yes. From then on it's a classical evolutionary process. A program, usually, indeed is longer than a single instruction. I compiled an extensive list of instruction information that helps with generating only valid sequences.

aquynh commented 8 years ago

this is interesting!

not sure what assembler you are using, but you might be interested in Keystone, a "sister" of Capstone: www.keystone-engine.org

furunkel commented 8 years ago

It contains its own assembler :).

BTW: It would be interesting to compile such tables for different architectures, that could be shared across multiple projects. Also, autogenerated assemblers are so much more maintainable.

aquynh commented 8 years ago

what is practical usage of Awasm?

furunkel commented 8 years ago

Good question. My goal is to have something that lies between a program synthesizer and a superoptimizer. Awasm might implement simple programs (actually functions) in ways human would never think of. Of course, classical superoptimizers will usually produce better code in terms of size or performance, but Awasm doesn't need an ordinary compiler to bootstrap the search process (generate the initial assembly).

So, on the long run, you might build something like a language compiler whose code generation is based on examples, or a more complex program synthesizer, or a simple tool that helps with writing assembly by hand: it will propose a baseline program, that can be improved on manually.