You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
D’s betterC mode is an important tool to be able to use D on bare-metal and embedded platforms. By disabling, for example the class support, the compiles does not need to as many runtime functions and types to be implemented for the code to compile and link. This makes the life of a bare-metal developer much easier.
But there is a catch! A lot of the language features runtime hooks, which in turn requires the TypeInfo class to be able to function. One way of solving both of these problems is by moving runtime hooks to use templates instead. This solves the betterC by removing the dependency of classes (the TypeInfo class), and it solves the safety issue because now the compiler will have all the information about the hook and it can verify it itself and not just trust that the runtime developer remembered to mark the hook correctly.
This proposal will work on translating all the array hooks from using the TypeInfo class to templates.
The array lengths setting is lowered to _d_arraysetlengthT!int, and because this hook is called inside a pure function, the hook also needs to be pure. So I had to fake pureness when needed, but I also need to make sure that the compiler won't remove the function call. As function calls to pure functions, where you don't care about the return value can be removed. (More info on this is on the document above). I've also had to fake @safety to make sure I don't break code.
But even with all of this hacks it does not decrease the safety of how it was before, as the underlining code is (often) the same.
I want to continue on my WIP druntime & dmd PRs, but I don't know when I will have time to invest on fixing them. So anyone can feel free to continue working on them.
Generally what you need to do to translate a hook:
In expressionsem.d rewrite the expression to a function calls that calls the correct
e2ir.d disable the old backend hook calling
Fix dinterpret.d so it can do what the hook used to use.
I would guess that most hook (if not all) should be moved to use a template entrypoint, that still calls the old hook function, before trying to rewrite the hook code. As there is a lot of usage of typeid within the old it is basically impossible to change everything to be template functions without making huge PR that change way too much. It is probably better to start at the top (the hook entrypoint) and then move downwards (the functions it calls), where each step is its own PR.
And then when everything is done you can start removing the pure and @safe hacks to make sure that hooks are actually safe. It is much easier to do this later than at the beginning of the translation process.
Activity
burner commentedon May 11, 2019
this is being worked on by Dan Printzell during GSoC 2019
wilzbach commentedon May 12, 2019
CC @Vild
RazvanN7 commentedon Feb 18, 2020
@Vild maybe you can share what is the status of this project so that future contributors know where to pick it up from.
Vild commentedon Feb 27, 2020
I haven't had time to work on this for a long while now due to school, so I haven't been able to finish my "information extraction" document, but most important parts are there: https://github.com/Vild/GSOC2019/blob/master/TechnicalInformationExtraction/TechnicalInformationExtraction.org
Generally the changes I've done contains hacks around security features.
For example:
The array lengths setting is lowered to
_d_arraysetlengthT!int, and because this hook is called inside apurefunction, the hook also needs to be pure. So I had to fake pureness when needed, but I also need to make sure that the compiler won't remove the function call. As function calls topurefunctions, where you don't care about the return value can be removed. (More info on this is on the document above). I've also had to fake@safety to make sure I don't break code.But even with all of this hacks it does not decrease the safety of how it was before, as the underlining code is (often) the same.
I want to continue on my WIP druntime & dmd PRs, but I don't know when I will have time to invest on fixing them. So anyone can feel free to continue working on them.
Generally what you need to do to translate a hook:
_d_HookTraceImpl.I would guess that most hook (if not all) should be moved to use a template entrypoint, that still calls the old hook function, before trying to rewrite the hook code. As there is a lot of usage of
typeidwithin the old it is basically impossible to change everything to be template functions without making huge PR that change way too much. It is probably better to start at the top (the hook entrypoint) and then move downwards (the functions it calls), where each step is its own PR.And then when everything is done you can start removing the
pureand@safehacks to make sure that hooks are actually safe. It is much easier to do this later than at the beginning of the translation process.mdparker commentedon Feb 5, 2024
Given that this project has been ongoing for a few years now and is nearly completed, there's no reason for it to be on this list anymore.