fix bind for @dynamicCompileEmit

This commit is contained in:
Ivan 2018-04-10 00:16:27 +03:00
parent 9386295f91
commit 355b4cb46b
3 changed files with 6 additions and 5 deletions

View file

@ -117,7 +117,9 @@ GlobalValsMap createGlobalValsFilter(IRState *irs) {
newFunctions.reserve(irs->dynamicCompiledFunctions.size());
for (auto &&it : irs->dynamicCompiledFunctions) {
ret.insert({it.first, GlobalValVisibility::External});
auto vis = (it.second.thunkVar != nullptr ? GlobalValVisibility::External
: GlobalValVisibility::Internal);
ret.insert({it.first, vis});
newFunctions.push_back(it.first);
}

View file

@ -235,7 +235,7 @@ void generateBind(const Context &context, JITContext &jitContext,
moduleInfo.addBindHandle(func->getName(), bindPtr);
bindFuncs.insert({bindPtr, func});
} else {
// TODO: ignore for now, user must explicitly check BindPtr
fatal(context, "Bind: function body not available");
}
};
for (auto &&bind : jitContext.getBindInstances()) {

View file

@ -125,9 +125,8 @@ auto bind(F, Args...)(F func, Args args) if (isFunctionPointer!F)
{
F saved_func = null;
}
@dynamicCompile static auto wrapper(Context context, FuncParams wrapperArgs)
@dynamicCompileEmit static auto wrapper(Context context, FuncParams wrapperArgs)
{
//assert(context.saved_func !is null);
return context.saved_func(wrapperArgs);
}
return bindImpl(&wrapper, Context(func), args);
@ -311,7 +310,7 @@ struct BindPayload(OF, F, int[] Index, Args...)
alias Ret = ReturnType!F;
alias Params = Parameters!F;
@dynamicCompile static Ret exampleFunc(Params) { assert(false); }
@dynamicCompileEmit static Ret exampleFunc(Params) { assert(false); }
registerBindPayload(&base.func, cast(void*)originalFunc, cast(void*)&exampleFunc, desc.ptr, desc.length);
registered = true;
}