Open arthurp opened 7 years ago
I have been thinking about this a little and I suspect that we should support both detached and attached metadata. The reason is that requiring detached meta-data is a recipe for divergence between the metadata and the implementation if the methods are being co-developed with the Orc program. However, we could make these languages one and the same.
If we define a metadata language independently of the attachment to classes, we can either put it in an annotation on the Java/Scala class, or in a separate metadata file which provides a little extra syntax to provide class names (or another import identifier if we are importing from a Polyglot VM language). We could also allow the metadata language to be specified at the import site in Orc, though I'm not sure this is a good idea since it would make updating the metadata for a new version of the external library more error prone (though if all the imports were in an include file it would actually be pretty reasonable).
Through out the development of our data data we should think about how we can allow metadata to be changed for specific objects or call sites. This is particularly important for distribution since many Java libraries return mutable data, (like an array) but never change it later. This means that the specific array is in fact immutable as long as the Orc program doesn't change it. Another use case is annotating calls to say they are pure or will publish immediately even if the call target does not guarantee that.
Both of these cases could be handled using a wrapper of some sort which overrides the metadata of the underlying value, but just forwards to it at runtime. For compile-time metadata (like side-effects and delay) these wrappers could probably be eliminated by the compiler before the code runs. But for any metadata that distribution uses the wrapper will need to persist at runtime to enable the distribution engine to examine it. Truffle can probably eliminate most of the runtime overhead (memory overhead and a pointer dereference would be unavoidable), but it will take some care to make sure this is possible.
This API would replace the ad-hoc API in
orc.values.sites.SiteMetadata
with something a bit more principled and powerful. The new API needs to have the following features:Range
.All values need to have safe conservative values. For instance, it is safe to assume that a site will have side-effects even if it does not. Sites that do not provide this information will use those values by default.
Many of these values will need to have data types defined from them. Some of those (delay, and effect information) need to be designed pretty carefully and have well defined semantics.
Once this API is implemented it should immediately replace the old version. The SiteMetadata API was never documented or officially made public.