Skip to content

Commit a145d4a

Browse files
committed
some docs
1 parent 6c03353 commit a145d4a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

docs/dynamic_compile_bind.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Dynamic compile bind
2+
3+
## D part
4+
5+
* bind function returns `BindPtr` object which is reference counted internally
6+
* `BindPtr` have `opCall` and `toDelegate` methods to call directly or create D delegate
7+
* On creation `BindPtr` call `void registerBindPayload(void* handle, void* originalFunc, void* exampleFunc, const ParamSlice* params, size_t paramsSize)` function
8+
* `handle` - pointer to pointer to function, which uniquely identifies bind object, actual function pointer to generated code will be written here during `compileDynamicCode` call.
9+
* `originalFunc` - pointer to `original` function, this is special function, generated inside `bind`, which just forwards parameter to user function or delegate, this function always have `@dynamicCompileEmit` attribute, so jit runtime will fins it even if user function wasn't marked `@dynamicCompile`
10+
* `exampleFunc` - special function with parameters matched to original user function, runtime will extracts parameters types from it, never called
11+
* `params` - list of slices to bind parameters, will be null for placeholders
12+
* `paramsSize` - items count in `params`
13+
* On destruction `BindPtr` call `void unregisterBindPayload(void* handle);`
14+
* `handle` - same handle as passed in `registerBindPayload` previously
15+
16+
## Runtime part
17+
18+
* `registerBindPayload` add handle to internal list
19+
* During `compileDynamicCode`
20+
* `generateBind` - Generate new function for each bind handle
21+
* Parse each bind parameter into llvm constant using existing `parseInitializer` (previously used for `@dynamicCompileConst`)
22+
* If parameter is function pointer from another bind handle, replace with direct reference to that function
23+
* Generate call to original function (this call will be inlined)
24+
* Generate and optimize module as usual
25+
* `applyBind` - update handles to generated code

0 commit comments

Comments
 (0)