glossopoeia / mochivm Goto Github PK
View Code? Open in Web Editor NEWStack-based, some-batteries-included virtual machine supporting delimited continuations via effect handlers
License: MIT License
Stack-based, some-batteries-included virtual machine supporting delimited continuations via effect handlers
License: MIT License
Maybe these can support both the built-in dictionary type and the built-in scoped record type.
First argument - number of items to pop
Second argument - number N of items to push
Next N arguments - index of popped item to push
Example:
shuffle ab-ba = swap = SHUFFLE 2 2 1 0
shuffle a-aa = dup = SHUFFLE 1 2 0 0
shuffle ab- = drop2 = SHUFFLE 2 0
Should be capable of supporting 'embedding', aka scoped labels.
To support basic algebraic data type functionality, we need another custom object type and a few instructions for constructing, extracting, and 'pattern-matching' on those custom objects.
The current make file process leaves some things to be desired.
Tedious but adds a lot of usefulness to the VM. Helpful to read Laurence Tratt's Static Integer Types for concerns and context. The requirements of this issue may change after reading it more closely, and determining just how many fixed-size values Boba should support. Will also take a look at other VMs to see how they do this in their byte codes.
Current plan:
Possible:
Then we'll have three basic data representations to use for benchmarking. Now that NaN tagging has been fleshed out to support some values-as-objects this should be straightforward.
As the entry point of the project for most developers (coming in through GitHub especially), the README should be informative, good-looking, and inspire confidence and excitement to try out the Mochi VM.
Some operations don't need to allocate an immutable clone if the type is unique. Adding these core operations will allow the programmer to take advantage of efficiency gains provided by guaranteed uniqueness.
Making sure the VM can handle IO-bound evented calls properly. Good stress test for handlers and calling MochiVM closures (or at least setting up the calls) from C-code as well.
Basically a nice, easy to integrate wrapper for various async LibUV functions, and also integrates the LibUV event loop into the runtime.
Should implement #13 concurrently or before this issue.
Documentation for LibUV.
We have a special object type for potentially polymorphic Arrays that just store the base Value
type. While this object is highly re-usable, it is not at all space efficient for byte arrays.
Can we just re-use the string object for this? Or should the string object become a byte array object with some extra logic surrounding it in runtime operations?
There's a big block of text in vm.c
that does some debug instruction tracing. All that stuff should get its own function, which is then called from that #if inside the interpreter function.
Can we re-use some existing objects or instructions?
Might as well make it easy to get some GUI apps up and running for flashy demos.
Actions I'm currently interested in:
This should be a new descendant of Obj, providing fast access to the head and the foot of a list. Also implement instructions to create and modify list values.
Since Boba is a statically typed language, we generally don't need the object type tag on every single object.
However, it is very useful during VM development to have runtime type information enabled. So we should place runtime type information behind a compile tag, which will remove the field from the struct. A few key areas may need to change as well, such as printing and asserting object type.
Initial set of conditional instructions:
Large development effort here, but probably nothing that hasn't been done before elsewhere. Probably reasonable to stand on the shoulders of giants for this one.
Consider utf8proc for implementation or at least inspiration, as it is managed by the folks at JuliaLang and likely to be a good pattern or candidate for other managed-memory languages.
For future work on integrating debuggers. More of a placeholder for now, will be very similar to NOP.
Add the ability to start and wait on threads, receiving values from them too?
Arrays will be constant-time indexable, and provide operations for mutations. In Boba, these operations will probably come with linear types.
Slices will be lightweight index-offset 'windows' into a subsequence of an array. Their operations will be similar to those provided for arrays.
This would be helpful to have sooner rather than later, and should definitely be added before announcing the project on any socials/forums or IRL.
See GitHub docs about this as a starting point.
Lots of tests verifying that handlers and continuations work as expected. Need to cover non-resuming, single-shot, and multi-resuming actions, after-closures, action parameters, handlers in actions, handler nesting, handler injecting.
Programmers should have the ability to request permissions, and jump to offsets based on whether a permission is enabled
TODO: Should set of permissions be cross-platform?
Straightforward relative-location instruction pointer adjustment. Similar to tail-call, but the new location will be decided relative to the current instruction pointer, not the global start of the byte code.
Need to be able to do basic boolean transformations.
Currently the 'temporary GC root' feature is not thread safe since it is attached to the over-arching VM data structure, rather than to each 'fiber', some which will eventually correspond with threads. This means that one fiber can push a root, and another pop that root when it was expecting to pop the root below due to non-deterministic order of execution.
Each fiber should have a small root collection, rather than the VM struct having a single root collection.
Marking as a concept fits better in the GC. This will also allow us to rename the markId
field in the mark frame struct as handleId
or something that explicitly denotes the association with 'effect handling' contexts.
Requirements
Would be nice to have tests that don't reside in/are not driven by main.c
. It is likely that the completion of this issue would allow the current hand-made testing framework to be deprecated and removed.
Need a new object type ObjRef
, which will contain a pointer to another object.
Need a VM-level collection of ObjRef
to represent the shared (between threads) state.
Three instructions to manipulate the store:
Candidates that have a lot of overlap
if
branch with a few lines)For ESCAPE and REACT, it may be better to unify them into one function. Maybe we could introduce a three-mode execution style for handlers, doing specific things for no-resume, single-shot, and multi-resume capabilities. The default here would assume multi-resume, but compiler writers could choose to mark action handlers as no-resume or single-shot for some performance gains.
Pre-req is probably #12 so we can re-use that data structure to store, manage, and query label -> bytecode index maps.
The label set should always be initialized to a valid hash table, but should default to empty.
This would help make CALL
, TAILCALL
, CLOSURE
, and other functions that use direct locations more readable in the disassembly.
We need to handle the label set not having an item present in each instruction that might reference a direct location.
Should be capable of supporting scoped labels.
Basic first-order functions tests. Verify being able to create, call, and close over other values in the frame stack.
One instruction with two byte arguments, the from and to value type identifiers.
Currently only the default event loop is used throughout the entire VM. This may not be desirable, so we should at least provide the option for each thread 'fiber' to have it's own event loop, which is initialized when the fiber starts and destroyed when the fiber completes/dies.
Does this come with improvements, or is one loop good enough?
Seems like wrapping LibTomMath could be a good start here.
Provide op codes for these similar to the other INT instructions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.