LWDR SAOC Milestone 1, Weekly Report for 22nd SEP to 29th SEP

Dylan Graham dylan.graham2000 at gmail.com
Thu Sep 30 06:53:41 UTC 2021


[Source Code](https://github.com/hmmdyl/LWDR)
[Plan](https://github.com/hmmdyl/SAoC2021/blob/main/plan.md)
[Proposal](https://github.com/hmmdyl/SAoC2021/blob/main/proposal.md)
[SAOC 
Projects](https://dlang.org/blog/2021/08/30/saoc-2021-projects/)

[Report for week 1 of milestone 
1](https://forum.dlang.org/thread/vodbtqqwvdmapnjzlzaq@forum.dlang.org)

Light Weight D Runtime.
30th September, 2021
Symmetry Autumn of Code, Week 2 of Milestone 1.

Hi all,
My apologies for posting this update late. Over the past week, I 
completed testing for task 3 - manual deallocation of delegates. 
I'm pleased to say that from my internal tests it appears to be 
working well. Tests have been completed on an STM32F407. Progress 
has been made on task 1 - support for `ModuleInfo` and 
static/module constructors and destructors.

I've had to slightly deviate from the plan due to how [LDC 
handles](https://github.com/ldc-developers/druntime/blob/ldc/src/rt/sections_ldc.d) module information. The original plan was based off DMD's implementation, but those hooks are unavailable on LDC (obviously, in retrospect -_- ). Instead, LDC relies on a linked list, and the initial pointer is available as `_Dmodule_ref`. The linked list contains pointers to `ModuleInfo`, which LWDR can then iterate over.

There hasn't been much formal code written, instead I've been 
doing tests and ensuring that it behaves as expected. There was a 
bug where a `shared static this() {...}` constructor was unable 
to see TLS variables, despite them being allocated. It was due to 
an alignment issue during allocation. This still needs to be 
corrected - it is a very quick fix, fortunately.

To reduce program size, I have been applying 
[`LDC_no_moduleinfo`](https://wiki.dlang.org/LDC-specific_language_changes#LDC_no_moduleinfo) and [`LDC_no_typeinfo`](https://wiki.dlang.org/LDC-specific_language_changes#LDC_no_typeinfo) pragmas to LWDR's internal modules and types, respectively. Public facing modules and types do not have these pragmas. In debug mode, which the `-O0` and `-gc` flags, this saved ~1KB of program memory.

To cut down on the size of `ModuleInfo`, I have made it so the 
[`unitTest` 
function](https://github.com/hmmdyl/LWDR/blob/master/source/object.d#L748) is only compiled in when unit tests are active. This is in accordance with my previous work to reduce the size of vtables for `TypeInfo`. It may interfere with custom unit testing libraries.

Going forward next week, I will need to fix the alignment issue, 
and work on the `minfo` module, which will handle ctor sorting 
and dispatches calls to module constructors and destructors.

All the best,
Dylan Graham


More information about the Digitalmars-d mailing list