Coder Social home page Coder Social logo

mijit-beetle's People

Contributors

apt1002 avatar rrthomas avatar

Watchers

 avatar  avatar  avatar

mijit-beetle's Issues

Simplify `vm:: machine::Machine::code()`

Importing from Mijit #5.

The code() method of vm::machine::Machine has unnecessary complexity in a number of ways:

  • The code for Lshift and Rshift differs only in one BinaryOp.

  • The following code sequence is common, and could be abbreviated:

    b.load_global(<reg>, <global>);
    b.const_binary(<op>, <reg>, <reg>, <constant>);
    b.store_global(<reg>, <global>);
    

    Usually, <op> is Add and <constant> is cell_bytes(<int>).

  • The following code sequence is common, and could be abbreviated:

    b.const_binary(Add, <reg>, <value>, cell_bytes(<n>));
    b.load(RD, <reg>);
    
  • Code to increment B_EP and jump to Root is common. It occurs in: Qbranch, Loop.

  • The code for Ploopp and Ploopm appears to be identical.

  • The code for Ploopip and Ploopim appears to be identical.

  • The code for Ploop and Ploopi differs only in the States they jump to.

  • The difference between instructions and their i variant are very small and could be parametrized. This occurs in: Qbranch, Loop, Ploop.

  • The difference between 0, 1, -1, CELL and -CELL could be parametrized.

  • The difference between the various unary operators could be parametrized.

  • The difference between the various binary operators could be parametrized.

  • The difference between the various item op constant operators could be parametrized.

  • The difference between the various constant op item operators could be parametrized.

  • The difference between the various <reg>@ operators could be parametrized.

  • The difference between the various <reg>! operators could be parametrized.

Focus on CBeetle

Currently Mijit Beetle can be used as a stand-alone virtual machine. However, it is limited and possibly buggy, and nobody is using it that way. Maybe in the future we will want to write Rust Beetle, but for now the main use of Mijit Beetle is as part of C Beetle. Therefore, focus on that use case.

  1. Delete main.rs.
  2. Pass M0 and the pointer to the register struct as extra arguments to mijit_beetle_run() or mijit_beetle_init().
  3. Delete struct AllRegisters (leaving only struct Registers) and use three extra Globals e.g. as follows:
    • Global(1) is M0.
    • Global(2) is R2.
    • Global(3) is R3.
  4. Remove the dependency of lib.rs on struct VM, by reimplementing it in terms of machine directly. This basically involves inlining the methods of VM into their callers.
  5. Reverse the nesting of mod vm and mod machine and annotate mod vm with #[cfg(test)].

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.