Jonathan S. Shapiro wrote:
>   1. Include the ASTs (or equivalent) for that stuff in the
>      dynamic library. Generate the code at dynamic load time
>      or at run time.
> 
>      Issue: run-time subsystem complexity.
>      Issue: LLVM is written in C++, so it would be difficult to ensure
>             that the runtime is safe. On the other hand, there really
>             doesn't appear to be any better alternative.

What sort of safety properties are you interested in?

> [...]
>   3. Use a compilation strategy in which all argument sizes are
>      fully parameterized. This is likely to yield low performance.

By this, I suppose you mean pointer operations on a parameter require a 
"size" parameter to also be passed in. Basically, a type-passing scheme 
of sorts.

>   4. Compile down to a native-code "template" in which sizes and
>      external references remain unresolved. Implement a low-level
>      run-time instantiator for these templates.

If I understand you correctly, I believe the .NET VM takes this approach 
with its generics [1]. Generic functions are compiled as "shape-indexed" 
functions, where the actual code invoked operates on all objects of the 
same shape. Finding the right code to jump to involves indexing a sort 
of function descriptor.

This is basically a hybrid of type-passing and poly-instantiation. This 
probably requires runtime codegen, but its seems like it might be a 
fairly simple form of it, where the code body can be copied, and the 
template params are updated in-place. This is probably a pretty 
reasonable trade-off, though I'm not sure how expensive indexing is. 
Unpredictable indirect jumps are pretty expensive on modern CPUs.

Sandro

[1] http://citeseer.ist.psu.edu/445672.html
_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to