mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 10:57:35 +03:00
fix bind for @dynamicCompileEmit
This commit is contained in:
parent
9386295f91
commit
355b4cb46b
3 changed files with 6 additions and 5 deletions
|
@ -117,7 +117,9 @@ GlobalValsMap createGlobalValsFilter(IRState *irs) {
|
||||||
newFunctions.reserve(irs->dynamicCompiledFunctions.size());
|
newFunctions.reserve(irs->dynamicCompiledFunctions.size());
|
||||||
|
|
||||||
for (auto &&it : irs->dynamicCompiledFunctions) {
|
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);
|
newFunctions.push_back(it.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ void generateBind(const Context &context, JITContext &jitContext,
|
||||||
moduleInfo.addBindHandle(func->getName(), bindPtr);
|
moduleInfo.addBindHandle(func->getName(), bindPtr);
|
||||||
bindFuncs.insert({bindPtr, func});
|
bindFuncs.insert({bindPtr, func});
|
||||||
} else {
|
} else {
|
||||||
// TODO: ignore for now, user must explicitly check BindPtr
|
fatal(context, "Bind: function body not available");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
for (auto &&bind : jitContext.getBindInstances()) {
|
for (auto &&bind : jitContext.getBindInstances()) {
|
||||||
|
|
|
@ -125,9 +125,8 @@ auto bind(F, Args...)(F func, Args args) if (isFunctionPointer!F)
|
||||||
{
|
{
|
||||||
F saved_func = null;
|
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 context.saved_func(wrapperArgs);
|
||||||
}
|
}
|
||||||
return bindImpl(&wrapper, Context(func), args);
|
return bindImpl(&wrapper, Context(func), args);
|
||||||
|
@ -311,7 +310,7 @@ struct BindPayload(OF, F, int[] Index, Args...)
|
||||||
|
|
||||||
alias Ret = ReturnType!F;
|
alias Ret = ReturnType!F;
|
||||||
alias Params = Parameters!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);
|
registerBindPayload(&base.func, cast(void*)originalFunc, cast(void*)&exampleFunc, desc.ptr, desc.length);
|
||||||
registered = true;
|
registered = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue