digitalmars.D - Replace druntime Hooks with Templates: Milestone 1, Week 2
- Teodor Dutu (16/16) Oct 03 2022 Hi,
- Johan (9/21) Oct 03 2022 Hi Teodor,
- Teodor Dutu (9/32) Oct 07 2022 Hi Johan,
- Johan (11/42) Oct 07 2022 Of course you can override anything by writing your own
- max haughton (5/24) Oct 07 2022 You can also override the GC using a custom GC class.
- Steven Schveighoffer (10/33) Oct 07 2022 Given that one of the purposes is to remove the dependence on `TypeInfo`...
Hi, This week I faced a few setbacks with `_d_arraycatnTX` due to type mismatches. Due to the hustle of moving house, I haven't made much progress on this front. To take a break from this, I temporarily moved on to the `_d_newitem{T,iT,U}` hooks. I implemented templated one templated hook for `_d_newitemT` and added unittests for it. The difference will now be made by the compiler during the lowering, by calling the constructor, copying the default initialiser, or doing nothing (`void` initialisation). This week I am looking to make some progress with this hook and come up with the aforementioned lowerings. Thanks,\ Teodor
Oct 03 2022
On Monday, 3 October 2022 at 20:28:19 UTC, Teodor Dutu wrote:Hi, This week I faced a few setbacks with `_d_arraycatnTX` due to type mismatches. Due to the hustle of moving house, I haven't made much progress on this front. To take a break from this, I temporarily moved on to the `_d_newitem{T,iT,U}` hooks. I implemented templated one templated hook for `_d_newitemT` and added unittests for it. The difference will now be made by the compiler during the lowering, by calling the constructor, copying the default initialiser, or doing nothing (`void` initialisation).Hi Teodor, Are you aware about the capability to override these implementations by the user? DMD itself is using this, see for example: https://github.com/dlang/dmd/blob/16fad687b0e894879564864d7eb75747fb41a057/compiler/src/dmd/root/rmem.d#L257-L262 Is this still possible after your work? regards, Johan
Oct 03 2022
On Monday, 3 October 2022 at 22:28:51 UTC, Johan wrote:On Monday, 3 October 2022 at 20:28:19 UTC, Teodor Dutu wrote:Hi Johan, I am aware of this and it will still be possible to override these implementations by writing your own `object.d` module, which is where they are instantiated from. I will also look into the link you gave and update the definitions there to conform to the new template. Thanks, TeodorHi, This week I faced a few setbacks with `_d_arraycatnTX` due to type mismatches. Due to the hustle of moving house, I haven't made much progress on this front. To take a break from this, I temporarily moved on to the `_d_newitem{T,iT,U}` hooks. I implemented templated one templated hook for `_d_newitemT` and added unittests for it. The difference will now be made by the compiler during the lowering, by calling the constructor, copying the default initialiser, or doing nothing (`void` initialisation).Hi Teodor, Are you aware about the capability to override these implementations by the user? DMD itself is using this, see for example: https://github.com/dlang/dmd/blob/16fad687b0e894879564864d7eb75747fb41a057/compiler/src/dmd/root/rmem.d#L257-L262 Is this still possible after your work? regards, Johan
Oct 07 2022
On Friday, 7 October 2022 at 08:25:25 UTC, Teodor Dutu wrote:On Monday, 3 October 2022 at 22:28:51 UTC, Johan wrote:Of course you can override anything by writing your own `object.d` module = writing your own druntime. The question is, can the user still override it using the current way. This impacts DMD itself. What DMD wants to override is the memory allocation itself, not necessarily the initialization of the memory. If the templates invoke an ` weak` **non-template** function for allocation, then there is still the possibility of overriding that in user code. Please think about that. regards, JohanOn Monday, 3 October 2022 at 20:28:19 UTC, Teodor Dutu wrote:Hi Johan, I am aware of this and it will still be possible to override these implementations by writing your own `object.d` module, which is where they are instantiated from.Hi, This week I faced a few setbacks with `_d_arraycatnTX` due to type mismatches. Due to the hustle of moving house, I haven't made much progress on this front. To take a break from this, I temporarily moved on to the `_d_newitem{T,iT,U}` hooks. I implemented templated one templated hook for `_d_newitemT` and added unittests for it. The difference will now be made by the compiler during the lowering, by calling the constructor, copying the default initialiser, or doing nothing (`void` initialisation).Hi Teodor, Are you aware about the capability to override these implementations by the user? DMD itself is using this, see for example: https://github.com/dlang/dmd/blob/16fad687b0e894879564864d7eb75747fb41a057/compiler/src/dmd/root/rmem.d#L257-L262 Is this still possible after your work? regards, Johan
Oct 07 2022
On Friday, 7 October 2022 at 10:16:25 UTC, Johan wrote:On Friday, 7 October 2022 at 08:25:25 UTC, Teodor Dutu wrote:You can also override the GC using a custom GC class. The way dmd does memory allocation is quite dumb anyway I don't think it would be missed. If needed the GC's collections could just be disabledOn Monday, 3 October 2022 at 22:28:51 UTC, Johan wrote:Of course you can override anything by writing your own `object.d` module = writing your own druntime. The question is, can the user still override it using the current way. This impacts DMD itself. What DMD wants to override is the memory allocation itself, not necessarily the initialization of the memory. If the templates invoke an ` weak` **non-template** function for allocation, then there is still the possibility of overriding that in user code. Please think about that. regards, Johan[...]Hi Johan, I am aware of this and it will still be possible to override these implementations by writing your own `object.d` module, which is where they are instantiated from.
Oct 07 2022
On 10/3/22 6:28 PM, Johan wrote:On Monday, 3 October 2022 at 20:28:19 UTC, Teodor Dutu wrote:Given that one of the purposes is to remove the dependence on `TypeInfo` for such things, is there a way to do this override without it? Otherwise, you could potentially provide a function pointer that you can set if you want to override the hook, and the hook can first check that pointer to see if it should call that first. Another idea is provide an easier way to override object things, like maybe if you plop a `customobject.d` into the dmd import path, it can provide overrides of things that `object` looks for. -SteveHi, This week I faced a few setbacks with `_d_arraycatnTX` due to type mismatches. Due to the hustle of moving house, I haven't made much progress on this front. To take a break from this, I temporarily moved on to the `_d_newitem{T,iT,U}` hooks. I implemented templated one templated hook for `_d_newitemT` and added unittests for it. The difference will now be made by the compiler during the lowering, by calling the constructor, copying the default initialiser, or doing nothing (`void` initialisation).Hi Teodor, Are you aware about the capability to override these implementations by the user? DMD itself is using this, see for example: https://github.com/dlang/dmd/blob/16fad687b0e894879564864d7eb75747fb41a057/compiler/src/dmd/r ot/rmem.d#L257-L262 Is this still possible after your work?
Oct 07 2022