Skip to content

Instantly share code, notes, and snippets.

@cygx
Last active August 14, 2019 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cygx/70a8ab676245945d497842abf067100c to your computer and use it in GitHub Desktop.
Save cygx/70a8ab676245945d497842abf067100c to your computer and use it in GitHub Desktop.

RFC: MoarVM Resource interface

Eventually, we want to be able to fatpack code into a single executable file. For this, we need some way to get data out of the executable.

We could of course nativecall into our own process, but that gets a bit more dicey if we want to package NativeCall itself.

It's proably a better idea to provide a proper interface such as a C function

int MVM_vm_register_resource(MVMInstance *instance, const char *c_name, const void *bytes, size_t size)

and an op

loadres (str NAME, obj TYPE, int64 COPY?) --> obj NEW_OBJECT

If COPY? is 0, TYPE must have representation CArray, CStruct, etc. If we do make a copy, we allow additional representations, in particular VMArray.

This is supposed to unlock the following use case:

CompUnit::Loader.load-precompilation:
    nqp::loadres('Foo::Bar:auth<dummy>:ver<0.1>', blob8.self, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment