Skip to content
This repository has been archived by the owner on Aug 2, 2019. It is now read-only.

Initialized aggregate values / objects #46

Open
eliotmoss opened this issue Oct 29, 2015 · 2 comments
Open

Initialized aggregate values / objects #46

eliotmoss opened this issue Oct 29, 2015 · 2 comments

Comments

@eliotmoss
Copy link

For the C client, and more particularly for the Java client, we would like to be able to describe an initialized aggregate value. The obvious case is string literals for C. In Java we would like to be able to describe a Java char array for these. A Java array will be a HYBRID object. Not having these means unpleasant work-arounds involving element by element initialization by code that we have to arrange to have invoked before the objects could possibly be used.

@wks
Copy link
Member

wks commented Oct 29, 2015

The HAIL language addresses precisely this need. It is part of the spec now.
Spec: https://github.com/microvm/microvm-spec/blob/goto-with-values/hail.rest
Previous issue: #29

The API function load_hail can load such "HAIL bundles", creating and initialising objects. So the C/Java client can generate not only a Mu IR bundle, but also a companion HAIL bundle for initialising these objects.

For an ahead-of-time compiling implementation of Mu, the solution can be "let the ahead-of-time MuIR-to-ELF compiler generates an executable ELF file which, when executed, behaves as if it continues from a Mu instance where some Mu IR bundles are loaded, some HAIL bundles are loaded after that, a main stack is created with a particular function (probably @main) at the bottom, and a main thread is created". i.e. It behaves like a "frozen Mu instance". It still complies to what the spec defines, except some initialisation operations are "not really executed", or more precisely, "already executed".

Alternatively, in a JIT-compiling Mu VM, some MuIR programs can read .class files directly (via the unsafe Native Interface), create objects and copy these string contents at run time (run time for Mu, class-loading time for the Java client).

@wks
Copy link
Member

wks commented Nov 11, 2015

Revision microvm/microvm-refimpl2@814ffbb in branch https://github.com/microvm/microvm-refimpl2/tree/goto-with-values of the reference implementation now implements HAIL as described in https://github.com/microvm/microvm-spec/blob/goto-with-values/hail.rest

Note: the master branch (which still uses PHI nodes, and will be replaced by the goto-with-values branch) does not support HAIL. It is recommended to migrate to the goto-with-values form.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants