Giter Site home page Giter Site logo

Prologue and epilogue about mijit HOT 1 CLOSED

apt1002 avatar apt1002 commented on May 28, 2024
Prologue and epilogue

from mijit.

Comments (1)

apt1002 avatar apt1002 commented on May 28, 2024

An analysis of goals:

  1. We want the Slots (unbounded in number) to be on the stack.
  2. We want the Registers and Slots to be dead when Mijit is not running.
  3. We want some Registers and Slots to be live in the root Machine::States, and we want to specify the live set in an ergonomic way.
  4. We want to allow the Machine to choose the Save data structure used to persist the state of the VM when Mijit is not running.
  5. We want to minimise the marshalling code that gets run on entry to and exit from Mijit.

Goal 1 deserves an issue of its own (#26) which also covers goal 2.

The combination of goals 2 and 3 motivates the prologue and epilogue code, whose purpose it to marshal data between the persistent state and the live set.

Goal 4 does not require any support from Mijit beyond providing a single persistent pointer to the prologue and epilogue code. The Machine can use it as a pointer to a Save if it wants; Mijit does not need to understand. So Machine::Save is an unnecessary concept.

Goal 5 essentially boils down to sharing between the persistent state and the live set. This can be done by reference, e.g. via the pointer to the Save. However, it is cheap and probably useful to provide some state that is shared "by value" too. I propose a constant-sized array of words (Globals?) that can be accessed as Values (alongside Registers and Slots) but which are always live and which persist when Mijit is not running. This is a mild generalisation of the single persistent pointer required by goal 4.

In summary, I propose the following design:

  • Add a case Global to code::Value, alongside Register and Slot, to represent a 64-bit word that persists when Mijit is not running. This deserves its own issue (#27).
  • Machine::Save does not exist.
  • Machine::values() does not exist. Instead Mijit defines a set of 64 Values: the first 12 Registers and the first 52 Slots. It is not necessary to include Globals, which are always live.
  • Machine::num_globals() returns the number of Globals that the Machine would like to use. This resurrects an earlier Mijit feature, with the difference that the Globals are not considered to be a subset of the Slots.
  • Machine::get_code(state) returns (among other things) a 64-bit mask indicating the Values that are live in state. The bitmask selects from the Mijit-defined set.
  • Machine::prologue() returns a list of Mijit Actions to marshal data from the Globals to the live values. It is not passed anything on entry. On exit it must have initialised all Values that are live in any State.
  • Machine::epilogue() returns a list of Mijit Actions to marshal data from the live values back to the Globals. On entry, it gets all Values that are live in any State; those that are dead are set to a dummy value (0xdeaddeaddeaddead). On exit nothing is live.

from mijit.

Related Issues (20)

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.