On Thu, Apr 23, 2015 at 10:03 AM, Jameson Nash <
vtj...@gmail.com> wrote:
> It might help if you can break down your questions into smaller bits.
> There's a lot of content here to address, which is probably slowing down
> response.
Thanks for your response.
>
> The code layer I believe you are referring to was restructured with the
> introduction of ABI-complient cfunction support. The code to support
> c-compatible function signatures was split off into a separate piece of
> machinery. `specFunctionObject` (previously `cFunctionObject`) is a
> `Function*` to a method with a specialized call signature. By contrast,
> `functionObject` is a `Function*` to a method with a generic, JL_CALLABLE
> signature. If you look at emit_call_function_object (and gen_cfun_wrapper),
> you will see that it detects whether the specFunctionObject is available and
> generates an appropriate call site.
This is very useful info for me.
Starting from here and trying to break down my questions:
1. Is it true that the `specFunctionObject` (by which I mean calling
the underlying c function) is more effecient than `functionObject`
(supposedly because there's less box/unbox overhead?) so should I try
to emit a specialized c function call when possible?
2. Can I use `emit_call_function_object` to emit a call to the
specialized function for `invoke` (and maybe "fallback" to emitting a
jlcall if necessary)? It seems to require a non-null
`specFunctionObject` which I couldn't figure out how.
The code I have right now is
```
Value *_theF = literal_pointer_val((jl_value_t*)mfunc);
Value *_theFptr = (Value*)mfunc->linfo->functionObject;
return emit_call_function_object(mfunc, _theF, _theFptr, true,
args + 2, nargs - 2, ctx);
```
where `mfunc` is the specialized function for `invoke` (should be the
same one that is called with `jl_apply()` at the end of
`jl_gf_invoke`)